[gnumeric] GUI: Avoid gtk+ criticals.



commit e408cfa4c2d5a9665d8c6e03b035e0f6ce61c122
Author: Morten Welinder <terra gnome org>
Date:   Tue Feb 25 17:44:06 2014 -0500

    GUI: Avoid gtk+ criticals.

 ChangeLog                           |    3 +++
 NEWS                                |    1 +
 src/dialogs/dialog-stf-fixed-page.c |    3 +--
 src/gui-util.c                      |   22 ++++++++++++----------
 src/gui-util.h                      |    4 ++--
 src/item-cursor.c                   |    6 ++----
 src/sheet-control-gui.c             |    7 +++----
 7 files changed, 24 insertions(+), 22 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a9cd9a7..0655026 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2014-02-25  Morten Welinder  <terra gnome org>
 
+       * src/gui-util.c (kill_popup_menu): Avoid criticals inside gtk+.
+       (gnumeric_create_popup_menu): Drop return value from handler.
+
        * src/xml-sax-write.c (xml_write_objects): Sort sheet objects that
        are cell comments by position.
 
diff --git a/NEWS b/NEWS
index c40255d..12d2b5b 100644
--- a/NEWS
+++ b/NEWS
@@ -37,6 +37,7 @@ Morten:
        * Fix xlsx export of rotated styles.
        * Make window geometry round-trip through xlsx.
        * Fix xlsx import of comments.
+       * Work around gtk+ criticals.  [#725142]
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.11
diff --git a/src/dialogs/dialog-stf-fixed-page.c b/src/dialogs/dialog-stf-fixed-page.c
index 4042f77..0a5e1ec 100644
--- a/src/dialogs/dialog-stf-fixed-page.c
+++ b/src/dialogs/dialog-stf-fixed-page.c
@@ -210,7 +210,7 @@ select_column (StfDialogData *pagedata, int col)
        gtk_widget_grab_focus (gtk_tree_view_column_get_button (column));
 }
 
-static gboolean
+static void
 fixed_context_menu_handler (GnumericPopupMenuElement const *element,
                            gpointer user_data)
 {
@@ -236,7 +236,6 @@ fixed_context_menu_handler (GnumericPopupMenuElement const *element,
        default:
                ; /* Nothing */
        }
-       return TRUE;
 }
 
 static void
diff --git a/src/gui-util.c b/src/gui-util.c
index 427a627..66d600c 100644
--- a/src/gui-util.c
+++ b/src/gui-util.c
@@ -443,13 +443,19 @@ gnm_gui_group_value (gpointer gui, char const * const group[])
        return -1;
 }
 
-static void
-kill_popup_menu (G_GNUC_UNUSED GtkWidget *widget, GtkMenu *menu)
+static gboolean
+cb_delayed_destroy (gpointer w)
 {
-       g_return_if_fail (menu != NULL);
-       g_return_if_fail (GTK_IS_MENU (menu));
+       gtk_widget_destroy (w);
+       return FALSE;
+}
 
-       g_object_unref (menu);
+static void
+kill_popup_menu (GtkWidget *widget, G_GNUC_UNUSED GtkMenu *menu)
+{
+       /* gtk+ currently gets unhappy if we destroy here, see bug 725142 */
+       g_idle_add (cb_delayed_destroy,
+                   gtk_widget_get_toplevel (widget));
 }
 
 /**
@@ -466,8 +472,6 @@ gnumeric_popup_menu (GtkMenu *menu, GdkEvent *event)
        g_return_if_fail (menu != NULL);
        g_return_if_fail (GTK_IS_MENU (menu));
 
-       g_object_ref_sink (menu);
-
        if (event)
                gtk_menu_set_screen (menu, gdk_event_get_screen (event));
 
@@ -590,7 +594,6 @@ gnm_gtk_builder_load (char const *uifile, char const *domain, GOCmdContext *cc)
        return gui;
 }
 
-
 static void
 popup_item_activate (GtkWidget *item, gpointer *user_data)
 {
@@ -602,8 +605,7 @@ popup_item_activate (GtkWidget *item, gpointer *user_data)
        g_return_if_fail (elem != NULL);
        g_return_if_fail (handler != NULL);
 
-       if (handler (elem, user_data))
-               gtk_widget_destroy (gtk_widget_get_toplevel (item));
+       handler (elem, user_data);
 }
 
 /**
diff --git a/src/gui-util.h b/src/gui-util.h
index 23f5e6a..b522897 100644
--- a/src/gui-util.h
+++ b/src/gui-util.h
@@ -58,8 +58,8 @@ typedef struct {
        char *allocated_name;
 } GnumericPopupMenuElement;
 
-typedef gboolean (*GnumericPopupMenuHandler) (GnumericPopupMenuElement const *e,
-                                             gpointer user_data);
+typedef void (*GnumericPopupMenuHandler) (GnumericPopupMenuElement const *e,
+                                         gpointer user_data);
 
 void gnumeric_create_popup_menu (GnumericPopupMenuElement const *elements,
                                 GnumericPopupMenuHandler handler,
diff --git a/src/item-cursor.c b/src/item-cursor.c
index 9c0cc8a..aeeb04f 100644
--- a/src/item-cursor.c
+++ b/src/item-cursor.c
@@ -803,14 +803,12 @@ item_cursor_do_action (GnmItemCursor *ic, ActionType action)
        scg_special_cursor_stop (ic->scg);
 }
 
-static gboolean
+static void
 context_menu_hander (GnumericPopupMenuElement const *element,
                     gpointer ic)
 {
-       g_return_val_if_fail (element != NULL, TRUE);
-
+       g_return_if_fail (element != NULL);
        item_cursor_do_action (ic, element->index);
-       return TRUE;
 }
 
 static void
diff --git a/src/sheet-control-gui.c b/src/sheet-control-gui.c
index 3c1a257..892f3b4 100644
--- a/src/sheet-control-gui.c
+++ b/src/sheet-control-gui.c
@@ -1935,7 +1935,7 @@ enum {
        CONTEXT_DATA_SLICER_REFRESH,    /* refresh and redraw */
        CONTEXT_DATA_SLICER_EDIT        /* prop dialog */
 };
-static gboolean
+static void
 context_menu_handler (GnumericPopupMenuElement const *element,
                      gpointer user_data)
 {
@@ -1946,8 +1946,8 @@ context_menu_handler (GnumericPopupMenuElement const *element,
        WBCGtk          *wbcg = scg->wbcg;
        WorkbookControl *wbc = sc->wbc;
 
-       g_return_val_if_fail (element != NULL, TRUE);
-       g_return_val_if_fail (IS_SHEET (sheet), TRUE);
+       g_return_if_fail (element != NULL);
+       g_return_if_fail (IS_SHEET (sheet));
 
        switch (element->index) {
        case CONTEXT_CUT :
@@ -2070,7 +2070,6 @@ context_menu_handler (GnumericPopupMenuElement const *element,
        default :
                break;
        }
-       return TRUE;
 }
 
 void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]