summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2016-03-07 12:13:59 +0100
committerCarlos Soriano <csoriano@gnome.org>2016-03-07 12:24:01 +0100
commitafdc6f9ac8f67de6ac1a34cbb78e8c4acf242dd7 (patch)
tree00c5176b3e1560c369da98fd2075d7cbc4bf8071
parenta974938cb40cc18ac1ef6921c84dacdf0037b773 (diff)
downloadnautilus-afdc6f9ac8f67de6ac1a34cbb78e8c4acf242dd7.tar.gz
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
-rw-r--r--src/nautilus-x-content-bar.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/nautilus-x-content-bar.c b/src/nautilus-x-content-bar.c
index e4a6c1eaf..5f9ef40ff 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);