From dc1aa3097c15868d124b947fae7b5dc91f350edc Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 6 Dec 2018 22:55:42 +0100 Subject: [PATCH] Avoid warnings on right click in GTK wxDataViewCtrl while editing The code handling right button click used the path of the item under mouse without checking if there was any item, resulting in GTK+ warnings due to the use of an invalid item. Simply add a check for the item validity: we definitely don't want to select it if it's invalid anyhow. --- src/gtk/dataview.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index d2c1abf352..6a7811cf1d 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -4591,11 +4591,14 @@ gtk_dataview_button_press_callback( GtkWidget *WXUNUSED(widget), // If the right click is on an item that isn't selected, select it, as is // commonly done. Do not do it if the item under mouse is already selected, // because it could be a part of multi-item selection. - GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dv->GtkGetTreeView())); - if ( !gtk_tree_selection_path_is_selected(selection, path) ) + if ( path ) { - gtk_tree_selection_unselect_all(selection); - gtk_tree_selection_select_path(selection, path); + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dv->GtkGetTreeView())); + if ( !gtk_tree_selection_path_is_selected(selection, path) ) + { + gtk_tree_selection_unselect_all(selection); + gtk_tree_selection_select_path(selection, path); + } } wxDataViewEvent