From 8f9336abef33ee4db00866ee8bacbdfb2b1054da Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Tue, 10 Nov 2009 18:37:23 +0000 Subject: [PATCH] Fix invalid tree iter access when using tv_iters.tag_other but not using tv_iters.tag_variable. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4416 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 3 +++ src/symbols.c | 28 ++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8e205d47..39a527b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ * tagmanager/perl.c: Fix Geany segfault with constant tags (#2895168). + * src/symbols.c: + Fix invalid tree iter access when using tv_iters.tag_other but not + using tv_iters.tag_variable. 2009-11-09 Enrico Tröger diff --git a/src/symbols.c b/src/symbols.c index 46a5c77c..0685ae54 100644 --- a/src/symbols.c +++ b/src/symbols.c @@ -657,7 +657,7 @@ static void add_top_level_items(GeanyDocument *doc) &(tv_iters.tag_function), _("Functions"), "classviewer-method", &(tv_iters.tag_macro), _("Labels"), NULL, &(tv_iters.tag_type), _("Constants"), NULL, - &(tv_iters.tag_other), _("Other"), NULL, + &(tv_iters.tag_other), _("Other"), "classviewer-other", NULL); break; } @@ -1061,6 +1061,21 @@ static GtkTreeIter *get_tag_type_iter(TMTagType tag_type, filetype_id ft_id) } +static GdkPixbuf *get_child_icon(GtkTreeStore *tree_store, GtkTreeIter *parent) +{ + GdkPixbuf *icon = NULL; + + if (parent == &tv_iters.tag_other) + { + return get_tag_icon("classviewer-var"); + } + /* copy parent icon */ + gtk_tree_model_get(GTK_TREE_MODEL(tree_store), parent, + SYMBOLS_COLUMN_ICON, &icon, -1); + return icon; +} + + static void add_tree_tag(GeanyDocument *doc, const TMTag *tag, GHashTable *parent_hash) { filetype_id ft_id = FILETYPE_ID(doc->file_type); @@ -1074,14 +1089,11 @@ static void add_tree_tag(GeanyDocument *doc, const TMTag *tag, GHashTable *paren const gchar *name; const gchar *parent_name = get_parent_name(tag, ft_id); GtkTreeIter iter; - GtkTreeIter *icon_iter = NULL, *child = NULL; - GdkPixbuf *icon = NULL; + GtkTreeIter *child = NULL; + GdkPixbuf *icon = NULL; - child = &iter; - icon_iter = (parent != &tv_iters.tag_other) ? parent : &tv_iters.tag_variable; - - gtk_tree_model_get(GTK_TREE_MODEL(tree_store), icon_iter, - SYMBOLS_COLUMN_ICON, &icon, -1); + child = &iter; + icon = get_child_icon(tree_store, parent); if (parent_name) {