[nautilus/gnome-3-20] content-bar: don't auto destroy the widget



commit afdc6f9ac8f67de6ac1a34cbb78e8c4acf242dd7
Author: Carlos Soriano <csoriano gnome org>
Date:   Mon Mar 7 12:13:59 2016 +0100

    content-bar: don't auto destroy the widget
    
    We were auto destroying the content bar if the mime type couldn't
    be handled.
    
    This is wrong since the caller is not aware of anything, trying to show
    or do other things with the destroyed widget.
    
    I'm not sure how this even work, if it worked at all.
    Previously it wasn't crashing because gtk+ was failing gratefully,
    however, with the gadget rework, this makes gtk+ crash.
    
    We fixed this in the previous patch, only creating the content bar if
    we can handle the myme types.
    This patch adds a few more guards and, in any case, avoid to destroy the
    widget inside the widget itself.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=762703

 src/nautilus-x-content-bar.c |   14 +++++---------
 1 files changed, 5 insertions(+), 9 deletions(-)
---
diff --git a/src/nautilus-x-content-bar.c b/src/nautilus-x-content-bar.c
index e4a6c1e..5f9ef40 100644
--- a/src/nautilus-x-content-bar.c
+++ b/src/nautilus-x-content-bar.c
@@ -91,6 +91,11 @@ nautilus_x_content_bar_set_x_content_types (NautilusXContentBar *bar, const char
 
        g_strfreev (bar->priv->x_content_types);
 
+        if (!should_handle_content_types (x_content_types)) {
+                g_warning ("Content types in content types bar cannot be handled. Check before creating the 
content bar if they can be handled.");
+                return;
+        }
+
        types = g_ptr_array_new ();
        apps = g_ptr_array_new ();
        g_ptr_array_set_free_func (apps, g_object_unref);
@@ -109,9 +114,6 @@ nautilus_x_content_bar_set_x_content_types (NautilusXContentBar *bar, const char
        bar->priv->x_content_types = (char **) g_ptr_array_free (types, FALSE);
 
        switch (num_types) {
-       case 0:
-               message = NULL;
-               break;
        case 1:
                message = get_message_for_content_type (bar->priv->x_content_types[0]);
                break;
@@ -123,12 +125,6 @@ nautilus_x_content_bar_set_x_content_types (NautilusXContentBar *bar, const char
                break;
        }
 
-       if (message == NULL) {
-               g_ptr_array_free (apps, TRUE);
-               gtk_widget_destroy (GTK_WIDGET (bar));
-               return;
-       }
-
        gtk_label_set_text (GTK_LABEL (bar->priv->label), message);
        g_free (message);
 


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