Revision: 390 Author: eht16 Date: 2006-06-02 07:04:59 -0700 (Fri, 02 Jun 2006) ViewCVS: http://svn.sourceforge.net/geany/?rev=390&view=rev
Log Message: ----------- added some sanity checks if filetype is NULL
Modified Paths: -------------- trunk/src/utils.c Modified: trunk/src/utils.c =================================================================== --- trunk/src/utils.c 2006-06-02 12:45:42 UTC (rev 389) +++ trunk/src/utils.c 2006-06-02 14:04:59 UTC (rev 390) @@ -197,7 +197,7 @@ { gboolean enable = FALSE;
- if (idx == -1) enable = FALSE; + if (idx == -1 || doc_list[idx].file_type == NULL) enable = FALSE; else if (doc_list[idx].file_type->id == GEANY_FILETYPES_C || doc_list[idx].file_type->id == GEANY_FILETYPES_CPP) { @@ -652,7 +652,7 @@ }
// make all inactive, because there is no more tab left, or something strange occured - if (idx == -1 || ! doc_list[idx].file_type->has_tags) + if (idx == -1 || doc_list[idx].file_type == NULL || ! doc_list[idx].file_type->has_tags) { gtk_widget_set_sensitive(app->tagbar, FALSE); gtk_container_add(GTK_CONTAINER(app->tagbar), app->default_tag_tree); @@ -1254,7 +1254,7 @@ gchar *ext = NULL; filetype *ft;
- if (idx == -1) + if (idx == -1 || doc_list[idx].file_type == NULL) { gtk_widget_set_sensitive(lookup_widget(app->window, "menu_build1"), FALSE); gtk_widget_set_sensitive(app->compile_button, FALSE); @@ -1972,10 +1972,16 @@
void utils_replace_filename(gint idx) { - gint pos = sci_get_current_position(doc_list[idx].sci); - gchar *filebase = g_strconcat(GEANY_STRING_UNTITLED, ".", (doc_list[idx].file_type)->extension, NULL); - gchar *filename = g_path_get_basename(doc_list[idx].file_name); + gint pos; + gchar *filebase; + gchar *filename;
+ if (idx == -1 || doc_list[idx].file_type == NULL) return; + + pos = sci_get_current_position(doc_list[idx].sci); + filebase = g_strconcat(GEANY_STRING_UNTITLED, ".", (doc_list[idx].file_type)->extension, NULL); + filename = g_path_get_basename(doc_list[idx].file_name); + sci_set_current_position(doc_list[idx].sci, 0); sci_set_search_anchor(doc_list[idx].sci); // stop if filebase was not found @@ -2283,7 +2289,9 @@ gint idx = document_get_cur_idx(); gint line = -1;
- if (string == NULL || !doc_list[app->cur_idx].is_valid) return; + if (string == NULL || ! doc_list[app->cur_idx].is_valid || + doc_list[app->cur_idx].file_type == NULL) + return;
// first get the line switch (doc_list[app->cur_idx].file_type->id)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.