]> Pileus Git - ~andy/gtk/commitdiff
Don't call scroll to cell if the tree view is empty
authorKristian Rietveld <kris@loopnest.org>
Sun, 20 Nov 2011 17:54:20 +0000 (18:54 +0100)
committerKristian Rietveld <kris@loopnest.org>
Sun, 20 Nov 2011 19:15:48 +0000 (20:15 +0100)
Account for the case when gtk_drag_finish() didn't actually add a row
(can happen when dragging from an empty tree view to itself ...).

gtk/gtktreeview.c

index e31de47d20d7e97eec82df00f185b26993dfffe0..1bc347df1b87cdbf052de40338ddfd3f5926b513 100644 (file)
@@ -7988,8 +7988,9 @@ gtk_tree_view_drag_data_received (GtkWidget        *widget,
                    (gdk_drag_context_get_selected_action (context) == GDK_ACTION_MOVE),
                    time);
 
-  if (gtk_tree_path_get_depth (dest_row) == 1
-      && gtk_tree_path_get_indices (dest_row)[0] == 0)
+  if (gtk_tree_path_get_depth (dest_row) == 1 &&
+      gtk_tree_path_get_indices (dest_row)[0] == 0 &&
+      gtk_tree_model_iter_n_children (tree_view->priv->model, NULL) != 0)
     {
       /* special special case drag to "0", scroll to first item */
       if (!tree_view->priv->scroll_to_path)