]> Pileus Git - ~andy/gtk/commitdiff
Bug 660554 - gtk_tree_view_drag_begin: assertion `path != NULL' failed
authorKristian Rietveld <kris@loopnest.org>
Sun, 20 Nov 2011 17:51:14 +0000 (18:51 +0100)
committerKristian Rietveld <kris@loopnest.org>
Sun, 20 Nov 2011 19:15:39 +0000 (20:15 +0100)
Turned assertion into silent return.

This assertion is only hit when dragging from an empty tree view.  In
this case, gtk_tree_view_begin_drag() is triggered from gtkdnd.c and not
from gtk_tree_view_maybe_begin_dragging_row().  We actually want to
cancel the drag at this point, but that is not possible with the GTK+
API as far as I can see.

The alternative is to not allowing the drag to start.  This could be
done by simply unsetting the tree view as drag source when it is empty
and setting it as drag source again when rows are added.  I didn't
choose to go with this for now, since this will likely break third party
code.

gtk/gtktreeview.c

index 3f32c8780d9476a5d6c7006949c3ed9a72586b7a..e31de47d20d7e97eec82df00f185b26993dfffe0 100644 (file)
@@ -7613,7 +7613,14 @@ gtk_tree_view_drag_begin (GtkWidget      *widget,
                                  &cell_x,
                                  &cell_y);
 
-  g_return_if_fail (path != NULL);
+  /* If path is NULL, there's nothing we can drag.  For now, we silently
+   * bail out.  Actually, dragging should not be possible from an empty
+   * tree view, but there's no way we can cancel that from here.
+   * Automatically unsetting the tree view as drag source for empty models
+   * is something that would likely break other people's code ...
+   */
+  if (!path)
+    return;
 
   row_pix = gtk_tree_view_create_row_drag_icon (tree_view,
                                                 path);