Fix a segfault on Go to tag defn/decl if no files have tags. Add utils_find_tm_tag

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@516 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2006-07-01 13:16:52 +00:00
parent 2aa7ae45a2
commit cee4ebf37c
4 changed files with 38 additions and 18 deletions

View File

@ -5,6 +5,9 @@
* src/callbacks.c: Prevent a segfault if the VTE has not been loaded. * src/callbacks.c: Prevent a segfault if the VTE has not been loaded.
* src/utils.c, src/utils.h, src/msgwindow.c: * src/utils.c, src/utils.h, src/msgwindow.c:
Add utils_get_current_time_string and fix getting the time string. Add utils_get_current_time_string and fix getting the time string.
* src/utils.c, src/utils.h, src/callbacks.c:
Fix a segfault on Go to tag defn/decl if no files have tags.
Add utils_find_tm_tag.
2006-06-30 Enrico Tröger <enrico.troeger@uvena.de> 2006-06-30 Enrico Tröger <enrico.troeger@uvena.de>

View File

@ -1340,39 +1340,40 @@ on_goto_tag_activate (GtkMenuItem *menuitem,
gpointer user_data) gpointer user_data)
{ {
gint type; gint type;
guint i, j; guint j;
const GPtrArray *tags; const GPtrArray *tags;
TMTag *tmtag;
if (menuitem == GTK_MENU_ITEM(lookup_widget(app->popup_menu, "goto_tag_definition1"))) if (menuitem == GTK_MENU_ITEM(lookup_widget(app->popup_menu, "goto_tag_definition1")))
type = tm_tag_function_t; type = tm_tag_function_t;
else else
type = tm_tag_prototype_t; type = tm_tag_prototype_t;
for (j = 0; j < app->tm_workspace->work_objects->len; j++) if (app->tm_workspace->work_objects != NULL)
{ {
tags = tm_tags_extract(TM_WORK_OBJECT(app->tm_workspace->work_objects->pdata[j])->tags_array, type); for (j = 0; j < app->tm_workspace->work_objects->len; j++)
if (tags)
{ {
for (i = 0; i < tags->len; ++i) tags = tm_tags_extract(
TM_WORK_OBJECT(app->tm_workspace->work_objects->pdata[j])->tags_array,
type);
if (tags == NULL) continue;
tmtag = utils_find_tm_tag(tags, current_word);
if (tmtag != NULL)
{ {
if (utils_strcmp(TM_TAG(tags->pdata[i])->name, current_word)) if (! utils_goto_file_line(
{ tmtag->atts.entry.file->work_object.file_name,
if (! utils_goto_file_line( TRUE, tmtag->atts.entry.line)) break;
TM_TAG(tags->pdata[i])->atts.entry.file->work_object.file_name, return;
TRUE,
TM_TAG(tags->pdata[i])->atts.entry.line))
{
utils_beep();
msgwin_status_add(_("Declaration or definition of \"%s()\" not found"), current_word);
}
return;
}
} }
} }
} }
// if we are here, there was no match and we are beeping ;-) // if we are here, there was no match and we are beeping ;-)
utils_beep(); utils_beep();
msgwin_status_add(_("Declaration or definition of \"%s()\" not found"), current_word); if (type == tm_tag_prototype_t)
msgwin_status_add(_("Declaration of \"%s()\" not found"), current_word);
else
msgwin_status_add(_("Definition of \"%s()\" not found"), current_word);
} }

View File

@ -2496,3 +2496,17 @@ gchar *utils_get_current_time_string()
} }
TMTag *utils_find_tm_tag(const GPtrArray *tags, const gchar *tag_name)
{
guint i;
g_return_val_if_fail(tags != NULL, NULL);
for (i = 0; i < tags->len; ++i)
{
if (utils_strcmp(TM_TAG(tags->pdata[i])->name, tag_name))
return TM_TAG(tags->pdata[i]);
}
return NULL;
}

View File

@ -220,4 +220,6 @@ void utils_parse_compiler_error_line(const gchar *string, gchar **filename, gint
// returned string must be freed. // returned string must be freed.
gchar *utils_get_current_time_string(); gchar *utils_get_current_time_string();
TMTag *utils_find_tm_tag(const GPtrArray *tags, const gchar *tag_name);
#endif #endif