Fix segfault pressing Menu key

Pierre wrote: "On my keyboard I have a key on the right side
of the space bar, between the alt+gr key and the right ctrl
which most of the time emulates the right mouse click.
If I press this button on subsurface, I end up with:

   Segmentation fault (core dumped)

This whatever the selection and nicely always reproducible."

This patch doesn't make the key work, but it fixes the segfault.

Reported-by: Pierre-Yves Chibon <pingou@pingoured.fr>
Debugged-and-acked-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Henrik Brautaset Aronsen 2013-01-29 19:06:08 +01:00 committed by Dirk Hohndel
parent 9b47dc1f59
commit 0fb1fe8c6e

View file

@ -2353,7 +2353,7 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int
int idx, previdx, nextidx;
struct dive *dive;
if (!gtk_tree_view_get_path_at_pos(tree_view, event->x, event->y, &path, NULL, NULL, NULL))
if (!event || !gtk_tree_view_get_path_at_pos(tree_view, event->x, event->y, &path, NULL, NULL, NULL))
return;
gtk_tree_model_get_iter(MODEL(dive_list), &iter, path);
gtk_tree_model_get(MODEL(dive_list), &iter, DIVE_INDEX, &idx, -1);