[gtk+] GtkDialog: avoid a crash



commit 9c6c4fdeb844310ed77104d8f4640c619c46326c
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jun 6 12:19:24 2014 -0400

    GtkDialog: avoid a crash
    
    Just because use-header-bar is set, it is not safe to assume
    every action widget is in the headerbar, so be careful when
    setting child properties.

 gtk/gtkdialog.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c
index 4ffdd5e..a97282b 100644
--- a/gtk/gtkdialog.c
+++ b/gtk/gtkdialog.c
@@ -1840,18 +1840,17 @@ gtk_dialog_buildable_custom_finished (GtkBuildable *buildable,
                                      gpointer      user_data)
 {
   GtkDialog *dialog = GTK_DIALOG (buildable);
-  GtkDialogPrivate *priv = dialog->priv;
   GSList *l;
   ActionWidgetsSubParserData *parser_data;
   GObject *object;
   ResponseData *ad;
   guint signal_id;
 
-  if (strcmp (tagname, "action-widgets"))
+  if (strcmp (tagname, "action-widgets") != 0)
     {
-    parent_buildable_iface->custom_finished (buildable, builder, child,
-                                            tagname, user_data);
-    return;
+      parent_buildable_iface->custom_finished (buildable, builder, child,
+                                               tagname, user_data);
+      return;
     }
 
   parser_data = (ActionWidgetsSubParserData*)user_data;
@@ -1887,10 +1886,10 @@ gtk_dialog_buildable_custom_finished (GtkBuildable *buildable,
          g_signal_connect_closure_by_id (object, signal_id, 0, closure, FALSE);
        }
 
-      if (!priv->use_header_bar)
-        apply_response_for_action_area (dialog, GTK_WIDGET (object), ad->response_id);
-      else
+      if (GTK_IS_HEADER_BAR (gtk_widget_get_parent (GTK_WIDGET (object))))
         apply_response_for_header_bar (dialog, GTK_WIDGET (object), ad->response_id);
+      else
+        apply_response_for_action_area (dialog, GTK_WIDGET (object), ad->response_id);
 
       if (item->is_default)
         gtk_widget_grab_default (GTK_WIDGET (object));


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