Commit 9e6e9c43 authored by Morten Welinder's avatar Morten Welinder

GUI: Avoid infinite loop in sheet reordering.

parent 2721cda0
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
* src/wbc-gtk.c (cb_workbook_debug_info): New debug flag * src/wbc-gtk.c (cb_workbook_debug_info): New debug flag
name-collections. 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) * src/expr-name.c (gnm_named_expr_collection_dump)
(gnm_named_expr_collection_sanity_check): New function. (gnm_named_expr_collection_sanity_check): New function.
......
...@@ -52,6 +52,7 @@ Morten: ...@@ -52,6 +52,7 @@ Morten:
* Fix name criticals. * Fix name criticals.
* Fix sheet duplication issue. [#725504] * Fix sheet duplication issue. [#725504]
* Fix named expressions crasher. [Part of #725459] * Fix named expressions crasher. [Part of #725459]
* Fix GUI sheet re-ordering mess. [Part of #725459]
-------------------------------------------------------------------------- --------------------------------------------------------------------------
Gnumeric 1.12.11 Gnumeric 1.12.11
......
...@@ -94,6 +94,8 @@ enum { ...@@ -94,6 +94,8 @@ enum {
TARGET_SHEET TARGET_SHEET
}; };
static gboolean debug_tab_order;
static char const *uifilename = NULL; static char const *uifilename = NULL;
static GtkActionEntry const *extra_actions = NULL; static GtkActionEntry const *extra_actions = NULL;
static int extra_actions_nb; static int extra_actions_nb;
...@@ -864,7 +866,8 @@ cb_notebook_switch_page (G_GNUC_UNUSED GtkNotebook *notebook_, ...@@ -864,7 +866,8 @@ cb_notebook_switch_page (G_GNUC_UNUSED GtkNotebook *notebook_,
if (wbcg->snotebook == NULL) if (wbcg->snotebook == NULL)
return; 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 /* While initializing adding the sheets will trigger page changes, but
* we do not actually want to change the focus sheet for the view * 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, ...@@ -957,7 +960,11 @@ cb_bnotebook_page_reordered (GtkNotebook *notebook, GtkWidget *child,
GtkNotebook *snotebook = GTK_NOTEBOOK (wbcg->snotebook); GtkNotebook *snotebook = GTK_NOTEBOOK (wbcg->snotebook);
int old = gtk_notebook_get_current_page (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) { if (old != page_num) {
Workbook *wb = wb_control_get_workbook (WORKBOOK_CONTROL (wbcg)); Workbook *wb = wb_control_get_workbook (WORKBOOK_CONTROL (wbcg));
...@@ -1257,23 +1264,26 @@ by_sheet_index (gconstpointer a, gconstpointer b) ...@@ -1257,23 +1264,26 @@ by_sheet_index (gconstpointer a, gconstpointer b)
static void static void
wbcg_sheet_order_changed (WBCGtk *wbcg) wbcg_sheet_order_changed (WBCGtk *wbcg)
{ {
GSList *l, *scgs = get_all_scgs (wbcg); if (wbcg_ui_update_begin (wbcg)) {
int i; GSList *l, *scgs;
int i;
/* Reorder all tabs so they end up in index_in_wb order. */ /* Reorder all tabs so they end up in index_in_wb order. */
scgs = g_slist_sort (scgs, by_sheet_index); scgs = g_slist_sort (get_all_scgs (wbcg), by_sheet_index);
for (i = 0, l = scgs; l; l = l->next, i++) { for (i = 0, l = scgs; l; l = l->next, i++) {
SheetControlGUI *scg = l->data; SheetControlGUI *scg = l->data;
gtk_notebook_reorder_child (wbcg->snotebook, gtk_notebook_reorder_child (wbcg->snotebook,
GTK_WIDGET (scg->grid), GTK_WIDGET (scg->grid),
i); i);
gnm_notebook_move_tab (wbcg->bnotebook, gnm_notebook_move_tab (wbcg->bnotebook,
GTK_WIDGET (scg->label), GTK_WIDGET (scg->label),
i); i);
} }
g_slist_free (scgs);
g_slist_free (scgs); wbcg_ui_update_end (wbcg);
}
} }
static void static void
...@@ -5590,6 +5600,8 @@ wbc_gtk_class_init (GObjectClass *gobject_class) ...@@ -5590,6 +5600,8 @@ wbc_gtk_class_init (GObjectClass *gobject_class)
g_return_if_fail (wbc_class != NULL); g_return_if_fail (wbc_class != NULL);
debug_tab_order = gnm_debug_flag ("tab-order");
parent_class = g_type_class_peek_parent (gobject_class); parent_class = g_type_class_peek_parent (gobject_class);
gobject_class->get_property = wbc_gtk_get_property; gobject_class->get_property = wbc_gtk_get_property;
gobject_class->set_property = wbc_gtk_set_property; gobject_class->set_property = wbc_gtk_set_property;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment