Bug fix: Bookmark DnD
authorColin Clark <colin.clark@cclark.uk>
Tue, 23 Jan 2018 19:48:24 +0000 (19:48 +0000)
committerColin Clark <colin.clark@cclark.uk>
Tue, 23 Jan 2018 19:48:24 +0000 (19:48 +0000)
In some cases dragging-and-dropping something that is not a URI to
create a bookmark will cause Geeqie to crash.

src/ui_bookmark.c

index 91ee6ba..24df75a 100644 (file)
@@ -731,32 +731,35 @@ static void bookmark_dnd_get_data(GtkWidget *widget,
 
        if (!bm->editable) return;
 
-       uris = gtk_selection_data_get_uris(selection_data);
-       list = uri_pathlist_from_uris(uris, &errors);
-       if(errors)
+       uris = gtk_selection_data_get_uris(selection_data);
+       if (uris)
                {
-               warning_dialog_dnd_uri_error(errors);
-               string_list_free(errors);
-               }
-       g_strfreev(uris);
+               list = uri_pathlist_from_uris(uris, &errors);
+               if(errors)
+                       {
+                       warning_dialog_dnd_uri_error(errors);
+                       string_list_free(errors);
+                       }
+               g_strfreev(uris);
 
-       work = list;
-       while (work)
-               {
-               gchar *path = work->data;
-               gchar *buf;
+               work = list;
+               while (work)
+                       {
+                       gchar *path = work->data;
+                       gchar *buf;
 
-               work = work->next;
+                       work = work->next;
 
-               if (bm->only_directories && !isdir(path)) continue;
-               buf = bookmark_string(filename_from_path(path), path, NULL);
-               history_list_add_to_key(bm->key, buf, 0);
-               g_free(buf);
-               }
+                       if (bm->only_directories && !isdir(path)) continue;
+                       buf = bookmark_string(filename_from_path(path), path, NULL);
+                       history_list_add_to_key(bm->key, buf, 0);
+                       g_free(buf);
+                       }
 
-       string_list_free(list);
+               string_list_free(list);
 
-       bookmark_populate_all(bm->key);
+               bookmark_populate_all(bm->key);
+               }
 }
 
 static void bookmark_list_destroy(GtkWidget *widget, gpointer data)