[gtk+/gtk-3-2] Bug 660554 - gtk_tree_view_drag_begin: assertion `path != NULL' failed



commit 895eb184128960b61310b2f8cec3771c98685d05
Author: Kristian Rietveld <kris loopnest org>
Date:   Sun Nov 20 18:51:14 2011 +0100

    Bug 660554 - gtk_tree_view_drag_begin: assertion `path != NULL' failed
    
    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 |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 0305fbe..6e5f71b 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -7594,7 +7594,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);



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