Revision: 516 Author: ntrel Date: 2006-07-01 06:16:52 -0700 (Sat, 01 Jul 2006) ViewCVS: http://svn.sourceforge.net/geany/?rev=516&view=rev
Log Message: ----------- Fix a segfault on Go to tag defn/decl if no files have tags. Add utils_find_tm_tag
Modified Paths: -------------- trunk/ChangeLog trunk/src/callbacks.c trunk/src/utils.c trunk/src/utils.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-07-01 12:02:30 UTC (rev 515) +++ trunk/ChangeLog 2006-07-01 13:16:52 UTC (rev 516) @@ -5,6 +5,9 @@ * src/callbacks.c: Prevent a segfault if the VTE has not been loaded. * src/utils.c, src/utils.h, src/msgwindow.c: 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
Modified: trunk/src/callbacks.c =================================================================== --- trunk/src/callbacks.c 2006-07-01 12:02:30 UTC (rev 515) +++ trunk/src/callbacks.c 2006-07-01 13:16:52 UTC (rev 516) @@ -1340,39 +1340,40 @@ gpointer user_data) { gint type; - guint i, j; + guint j; const GPtrArray *tags; + TMTag *tmtag;
if (menuitem == GTK_MENU_ITEM(lookup_widget(app->popup_menu, "goto_tag_definition1"))) type = tm_tag_function_t; else 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); - if (tags) + for (j = 0; j < app->tm_workspace->work_objects->len; j++) { - 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( - TM_TAG(tags->pdata[i])->atts.entry.file->work_object.file_name, - 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 (! utils_goto_file_line( + tmtag->atts.entry.file->work_object.file_name, + TRUE, tmtag->atts.entry.line)) break; + return; } } } // if we are here, there was no match and we are beeping ;-) 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); }
Modified: trunk/src/utils.c =================================================================== --- trunk/src/utils.c 2006-07-01 12:02:30 UTC (rev 515) +++ trunk/src/utils.c 2006-07-01 13:16:52 UTC (rev 516) @@ -2496,3 +2496,17 @@ }
+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; +} + +
Modified: trunk/src/utils.h =================================================================== --- trunk/src/utils.h 2006-07-01 12:02:30 UTC (rev 515) +++ trunk/src/utils.h 2006-07-01 13:16:52 UTC (rev 516) @@ -220,4 +220,6 @@ // returned string must be freed. gchar *utils_get_current_time_string();
+TMTag *utils_find_tm_tag(const GPtrArray *tags, const gchar *tag_name); + #endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.