I've just stumbled upon a subtle problem with my insert comment and undo functions. Steps to reproduce:
- open editor
- insert comment somewhere in the sourcebuffer
- hit ctrl+z to undo
insert another comment, the comment is inserted ok, but the following error shows up in the stdout:
GtkSourceView-CRITICAL **: modified_changed_handler: assertion `action != NULL' failed
insert another comment, which also works
try to undo by hitting ctrl+z, undo does not work, and the following error shows up in stdout:
GtkSourceView-CRITICAL **: gtk_source_undo_manager_undo_impl: assertion `undo_action != NULL' failed
From here on undo does not work.
Here is my insert_comment():
...
tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(txtinput[current_tab]));
gtk_text_buffer_get_selection_bounds (tbuffer, &start, &end);
gtk_text_iter_set_line_offset (&start, 0);
gtk_text_buffer_insert (tbuffer, &start, "// \0", -1);
...
and my undo keypress definition:
case GDK_KEY_z:
if (event -> state & GDK_CONTROL_MASK)
{
GtkSourceBuffer *sbuffer;
sbuffer = GTK_SOURCE_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(txtinput[current_tab])));
if (gtk_source_buffer_can_undo(sbuffer))
{
gtk_source_buffer_undo(sbuffer);
}
return TRUE;
}
break;
I saw one other person who had this same problem, but no solution was presented. Has anyone else had this problem?
I tried commenting out the "modified-changed" signal connection as a troubleshooting step, but the problem persists.
Any ideas on what I might be doing wrong? Thanks.