[nautilus/gnome-2-28] Always check if the drag dest supports the source.



commit 4bd9cb8d3e1b59667334550472b1ffd6a6768e73
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Oct 9 19:19:42 2009 +0200

    Always check if the drag dest supports the source.
    
    In the "drag-motion" callback, make sure we check for target != GDK_NONE
    before getting non-existent data for it.

 libnautilus-private/nautilus-dnd.c |    9 ++++++++-
 src/nautilus-places-sidebar.c      |   17 +++++++++++++----
 2 files changed, 21 insertions(+), 5 deletions(-)
---
diff --git a/libnautilus-private/nautilus-dnd.c b/libnautilus-private/nautilus-dnd.c
index b7e1df2..15b6395 100644
--- a/libnautilus-private/nautilus-dnd.c
+++ b/libnautilus-private/nautilus-dnd.c
@@ -1010,7 +1010,7 @@ nautilus_drag_selection_includes_special_link (GList *selection_list)
 	return FALSE;
 }
 
-static void
+static gboolean
 slot_proxy_drag_motion (GtkWidget          *widget,
 			GdkDragContext     *context,
 			int                 x,
@@ -1038,6 +1038,11 @@ slot_proxy_drag_motion (GtkWidget          *widget,
 
 	if (!drag_info->have_data) {
 		target = gtk_drag_dest_find_target (widget, context, NULL);
+
+		if (target == GDK_NONE) {
+			goto out;
+		}
+
 		gtk_drag_get_data (widget, context, target, time);
 	}
 
@@ -1079,6 +1084,8 @@ out:
 	}
 
 	gdk_drag_status (context, action, time);
+
+	return TRUE;
 }
 
 static void
diff --git a/src/nautilus-places-sidebar.c b/src/nautilus-places-sidebar.c
index ce1c549..4d4f76f 100644
--- a/src/nautilus-places-sidebar.c
+++ b/src/nautilus-places-sidebar.c
@@ -826,7 +826,7 @@ compute_drop_position (GtkTreeView *tree_view,
 }
 
 
-static void
+static gboolean
 get_drag_data (GtkTreeView *tree_view,
 	       GdkDragContext *context, 
 	       unsigned int time)
@@ -837,8 +837,14 @@ get_drag_data (GtkTreeView *tree_view,
 					    context, 
 					    NULL);
 
+	if (target == GDK_NONE) {
+		return FALSE;
+	}
+
 	gtk_drag_get_data (GTK_WIDGET (tree_view),
 			   context, target, time);
+
+	return TRUE;
 }
 
 static void
@@ -904,7 +910,9 @@ drag_motion_callback (GtkTreeView *tree_view,
 	char *uri;
 
 	if (!sidebar->drag_data_received) {
-		get_drag_data (tree_view, context, time);
+		if (!get_drag_data (tree_view, context, time)) {
+			return FALSE;
+		}
 	}
 
 	compute_drop_position (tree_view, x, y, &path, &pos, sidebar);
@@ -1245,10 +1253,11 @@ drag_drop_callback (GtkTreeView *tree_view,
 		    unsigned int time,
 		    NautilusPlacesSidebar *sidebar)
 {
+	gboolean retval = FALSE;
 	sidebar->drop_occured = TRUE;
-	get_drag_data (tree_view, context, time);
+	retval = get_drag_data (tree_view, context, time);
 	g_signal_stop_emission_by_name (tree_view, "drag-drop");
-	return TRUE;
+	return retval;
 }
 
 /* Callback used when the file list's popup menu is detached */



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