SF.net SVN: geany:[3182] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Thu Nov 6 17:26:29 UTC 2008


Revision: 3182
          http://geany.svn.sourceforge.net/geany/?rev=3182&view=rev
Author:   ntrel
Date:     2008-11-06 17:26:29 +0000 (Thu, 06 Nov 2008)

Log Message:
-----------
Fix segfault when showing Find in Files dialog when no documents are
open (r2998, #2228544).
Fix segfault for FIF from last commit (oops).

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/search.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-11-06 17:13:18 UTC (rev 3181)
+++ trunk/ChangeLog	2008-11-06 17:26:29 UTC (rev 3182)
@@ -2,6 +2,10 @@
 
  * src/search.c:
    Refactor search_show_find_in_files_dialog().
+ * src/search.c:
+   Fix segfault when showing Find in Files dialog when no documents are
+   open (r2998, #2228544).
+   Fix segfault for FIF from last commit (oops).
 
 
 2008-11-04  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/src/search.c
===================================================================
--- trunk/src/search.c	2008-11-06 17:13:18 UTC (rev 3181)
+++ trunk/src/search.c	2008-11-06 17:26:29 UTC (rev 3182)
@@ -716,18 +716,20 @@
 {
 	GtkWidget *entry; /* for child GtkEntry of a GtkComboBoxEntry */
 	GeanyDocument *doc = document_get_current();
+	GeanyEditor *editor = doc ? doc->editor : NULL;
 	gchar *sel = NULL;
 	gchar *cur_dir = NULL;
 
 	if (widgets.find_in_files_dialog == NULL)
 	{
 		create_fif_dialog();
-		sel = editor_get_default_selection(doc->editor, search_prefs.use_current_word, NULL);
+		sel = editor_get_default_selection(editor, search_prefs.use_current_word, NULL);
 	}
-	entry = GTK_BIN(find_in_files.search_combo)->child;
 	/* only set selection if the dialog is not already visible, or has just been created */
 	if (! sel && ! GTK_WIDGET_VISIBLE(widgets.find_in_files_dialog))
-		sel = editor_get_default_selection(doc->editor, search_prefs.use_current_word, NULL);
+		sel = editor_get_default_selection(editor, search_prefs.use_current_word, NULL);
+
+	entry = GTK_BIN(find_in_files.search_combo)->child;
 	if (sel)
 		gtk_entry_set_text(GTK_ENTRY(entry), sel);
 	g_free(sel);
@@ -1131,9 +1133,9 @@
 {
 	if (response == GTK_RESPONSE_ACCEPT)
 	{
+		GtkWidget *search_combo = find_in_files.search_combo;
 		const gchar *search_text =
-			gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(
-				GTK_BIN(find_in_files.search_combo))));
+			gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(search_combo))));
 		GtkWidget *dir_combo = find_in_files.dir_combo;
 		const gchar *utf8_dir =
 			gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(dir_combo))));
@@ -1154,7 +1156,7 @@
 
 			if (search_find_in_files(search_text, locale_dir, opts->str))
 			{
-				ui_combo_box_add_to_history(GTK_COMBO_BOX(user_data), search_text);
+				ui_combo_box_add_to_history(GTK_COMBO_BOX(search_combo), search_text);
 				ui_combo_box_add_to_history(GTK_COMBO_BOX(dir_combo), utf8_dir);
 				gtk_widget_hide(widgets.find_in_files_dialog);
 			}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list