[gnumeric] GUI: Avoid infinite loop in sheet reordering.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] GUI: Avoid infinite loop in sheet reordering.
- Date: Mon, 3 Mar 2014 03:43:55 +0000 (UTC)
commit 9e6e9c4394ad19edefbacf6b25890e726c21a5c4
Author: Morten Welinder <terra gnome org>
Date: Sun Mar 2 22:43:18 2014 -0500
GUI: Avoid infinite loop in sheet reordering.
ChangeLog | 2 ++
NEWS | 1 +
src/wbc-gtk.c | 46 +++++++++++++++++++++++++++++-----------------
3 files changed, 32 insertions(+), 17 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8558a64..93e1d68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
* src/wbc-gtk.c (cb_workbook_debug_info): New debug flag
name-collections.
+ (wbcg_sheet_order_changed): Mark ui as being updated.
+ (cb_bnotebook_page_reordered): Ignore during UI update.
* src/expr-name.c (gnm_named_expr_collection_dump)
(gnm_named_expr_collection_sanity_check): New function.
diff --git a/NEWS b/NEWS
index 94bd3b5..0423b3b 100644
--- a/NEWS
+++ b/NEWS
@@ -52,6 +52,7 @@ Morten:
* Fix name criticals.
* Fix sheet duplication issue. [#725504]
* Fix named expressions crasher. [Part of #725459]
+ * Fix GUI sheet re-ordering mess. [Part of #725459]
--------------------------------------------------------------------------
Gnumeric 1.12.11
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index 8d8d318..3a05c22 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -94,6 +94,8 @@ enum {
TARGET_SHEET
};
+
+static gboolean debug_tab_order;
static char const *uifilename = NULL;
static GtkActionEntry const *extra_actions = NULL;
static int extra_actions_nb;
@@ -864,7 +866,8 @@ cb_notebook_switch_page (G_GNUC_UNUSED GtkNotebook *notebook_,
if (wbcg->snotebook == NULL)
return;
- if (0) g_printerr ("Notebook page switch\n");
+ if (debug_tab_order)
+ g_printerr ("Notebook page switch\n");
/* While initializing adding the sheets will trigger page changes, but
* we do not actually want to change the focus sheet for the view
@@ -957,7 +960,11 @@ cb_bnotebook_page_reordered (GtkNotebook *notebook, GtkWidget *child,
GtkNotebook *snotebook = GTK_NOTEBOOK (wbcg->snotebook);
int old = gtk_notebook_get_current_page (snotebook);
- if (0) g_printerr ("Reordered %d -> %d\n", old, page_num);
+ if (wbcg->updating_ui)
+ return;
+
+ if (debug_tab_order)
+ g_printerr ("Reordered %d -> %d\n", old, page_num);
if (old != page_num) {
Workbook *wb = wb_control_get_workbook (WORKBOOK_CONTROL (wbcg));
@@ -1257,23 +1264,26 @@ by_sheet_index (gconstpointer a, gconstpointer b)
static void
wbcg_sheet_order_changed (WBCGtk *wbcg)
{
- GSList *l, *scgs = get_all_scgs (wbcg);
- int i;
+ if (wbcg_ui_update_begin (wbcg)) {
+ GSList *l, *scgs;
+ int i;
- /* Reorder all tabs so they end up in index_in_wb order. */
- scgs = g_slist_sort (scgs, by_sheet_index);
+ /* Reorder all tabs so they end up in index_in_wb order. */
+ scgs = g_slist_sort (get_all_scgs (wbcg), by_sheet_index);
- for (i = 0, l = scgs; l; l = l->next, i++) {
- SheetControlGUI *scg = l->data;
- gtk_notebook_reorder_child (wbcg->snotebook,
- GTK_WIDGET (scg->grid),
- i);
- gnm_notebook_move_tab (wbcg->bnotebook,
- GTK_WIDGET (scg->label),
- i);
- }
+ for (i = 0, l = scgs; l; l = l->next, i++) {
+ SheetControlGUI *scg = l->data;
+ gtk_notebook_reorder_child (wbcg->snotebook,
+ GTK_WIDGET (scg->grid),
+ i);
+ gnm_notebook_move_tab (wbcg->bnotebook,
+ GTK_WIDGET (scg->label),
+ i);
+ }
+ g_slist_free (scgs);
- g_slist_free (scgs);
+ wbcg_ui_update_end (wbcg);
+ }
}
static void
@@ -5590,6 +5600,8 @@ wbc_gtk_class_init (GObjectClass *gobject_class)
g_return_if_fail (wbc_class != NULL);
+ debug_tab_order = gnm_debug_flag ("tab-order");
+
parent_class = g_type_class_peek_parent (gobject_class);
gobject_class->get_property = wbc_gtk_get_property;
gobject_class->set_property = wbc_gtk_set_property;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]