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.
This commit is contained in:
Vadim Zeitlin 2018-12-06 22:55:42 +01:00
parent da612f02b5
commit dc1aa3097c

View File

@ -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