summaryrefslogtreecommitdiffstats
path: root/third_party/undoview
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-10 00:56:08 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-10 00:56:08 +0000
commit6ec61ab284475f5e9d03cfdc47b1c406dc32c720 (patch)
treea6fbb6a125afcbc983b93d438432ad19c7f6d9ad /third_party/undoview
parent0686afadc3d6567975ff2571e4f26efd08197476 (diff)
downloadchromium_src-6ec61ab284475f5e9d03cfdc47b1c406dc32c720.zip
chromium_src-6ec61ab284475f5e9d03cfdc47b1c406dc32c720.tar.gz
chromium_src-6ec61ab284475f5e9d03cfdc47b1c406dc32c720.tar.bz2
Update internal state on undo to avoid a crash.
Update actions_in_current_group when removing an action so that it doesn't crash afterwards. BUG=61607,62609 TEST=manual (see bug) Do not set text if it didn't change, because it registers a delete/insert undo-able action-couple. Review URL: http://codereview.chromium.org/4683002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65609 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/undoview')
-rw-r--r--third_party/undoview/undo_manager.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/third_party/undoview/undo_manager.c b/third_party/undoview/undo_manager.c
index 9136b37..6efba9c 100644
--- a/third_party/undoview/undo_manager.c
+++ b/third_party/undoview/undo_manager.c
@@ -118,6 +118,29 @@ enum {
LAST_SIGNAL
};
+#if !defined(NDEBUG)
+static void
+print_state(GtkSourceUndoManager* um)
+{
+ fprintf(stderr, "\n***\n");
+ GList* actions = um->priv->actions;
+
+ for (; actions; actions = g_list_next(actions)) {
+ GtkSourceUndoAction* act = actions->data;
+ fprintf(stderr, "* type = %s\n", act->action_type == GTK_SOURCE_UNDO_ACTION_DELETE ?
+ "delete" : "insert");
+
+ fprintf(stderr, "\ttext = %s\n", act->action_type == GTK_SOURCE_UNDO_ACTION_DELETE
+ ? act->action.delete.text : act->action.insert.text);
+ fprintf(stderr, "\torder = %d\n", act->order_in_group);
+ }
+
+ fprintf(stderr, "* next redo: %d\n", um->priv->next_redo);
+ fprintf(stderr, "* num of groups: %d\n", um->priv->num_of_groups);
+ fprintf(stderr, "* actions in group: %d\n", um->priv->actions_in_current_group);
+}
+#endif
+
static void gtk_source_undo_manager_class_init(GtkSourceUndoManagerClass *klass);
static void gtk_source_undo_manager_init(GtkSourceUndoManager *um);
static void gtk_source_undo_manager_finalize(GObject *object);
@@ -624,6 +647,7 @@ gtk_source_undo_manager_free_action_list(GtkSourceUndoManager *um) {
if(action->order_in_group == 1)
--um->priv->num_of_groups;
+ um->priv->actions_in_current_group = action->order_in_group - 1;
if(action->modified)
um->priv->modified_action = INVALID;
@@ -787,6 +811,7 @@ gtk_source_undo_manager_free_first_n_actions(GtkSourceUndoManager *um,
if(action->order_in_group == 1)
--um->priv->num_of_groups;
+ um->priv->actions_in_current_group = action->order_in_group - 1;
if(action->modified)
um->priv->modified_action = INVALID;
@@ -827,6 +852,7 @@ gtk_source_undo_manager_check_list_size(GtkSourceUndoManager *um) {
if(undo_action->order_in_group == 1)
--um->priv->num_of_groups;
+ um->priv->actions_in_current_group = undo_action->order_in_group - 1;
if(undo_action->modified)
um->priv->modified_action = INVALID;