[PATCH 1/2] divelist.c:icon_click_cb(): check if a GtkTreePath is found
Lubomir I. Ivanov
neolit123 at gmail.com
Wed Jan 23 07:48:59 PST 2013
From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
In icon_click_cb() we need to check if a correct GtkTreePath is found
(using gtk_tree_view_get_path_at_pos()) before requesting a GtkTreeIter
for it.
Without this patch a bug is reproducible, where the user may click
outside of the GtkTreeView entries, but still in the GtkTreeView -
e.g. when only one entry is available.
Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
divelist.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/divelist.c b/divelist.c
index d033f93..bd3897d 100644
--- a/divelist.c
+++ b/divelist.c
@@ -1700,15 +1700,15 @@ static void show_gps_location_cb(GtkWidget *menuitem, struct dive *dive)
gboolean icon_click_cb(GtkWidget *w, GdkEventButton *event, gpointer data)
{
#if HAVE_OSM_GPS_MAP
- GtkTreePath *path;
+ GtkTreePath *path = NULL;
GtkTreeIter iter;
GtkTreeViewColumn *col;
int idx;
struct dive *dive;
/* left click ? */
- if (event->button == 1) {
- gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(dive_list.tree_view), event->x, event->y, &path, &col, NULL, NULL);
+ if (event->button == 1 &&
+ gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(dive_list.tree_view), event->x, event->y, &path, &col, NULL, NULL)) {
/* is it the icon column ? (we passed the correct column in when registering the callback) */
if (col == data) {
gtk_tree_model_get_iter(MODEL(dive_list), &iter, path);
@@ -1717,7 +1717,8 @@ gboolean icon_click_cb(GtkWidget *w, GdkEventButton *event, gpointer data)
if (dive && dive_has_location(dive))
show_gps_location(dive);
}
- gtk_tree_path_free(path);
+ if (path)
+ gtk_tree_path_free(path);
}
#endif
/* keep processing the click */
--
1.7.11.msysgit.0
More information about the subsurface
mailing list