Commit 3282261c authored by Sebastien Granjoux's avatar Sebastien Granjoux

Fix #570223 – Replace all in open buffers crashes

	* plugins/search/search-replace.c,
	plugins/search/search-replace_backend.c,
	plugins/search/search-replace_backend.h:
	Fix #570223 – Replace all in open buffers crashes

svn path=/trunk/; revision=4689
parent d4961cc8
2009-02-02 Sébastien Granjoux <seb.sfo@free.fr>
* plugins/search/search-replace.c,
plugins/search/search-replace_backend.c,
plugins/search/search-replace_backend.h:
Fix #570223 – Replace all in open buffers crashes
2009-02-02 Sébastien Granjoux <seb.sfo@free.fr>
* plugins/scintilla/text_editor.c,
......@@ -589,8 +589,6 @@ search_and_replace (void)
}
file_buffer_free (fb);
g_free (se->path);
g_free (se);
if (SA_SELECT == s->action && nb_results > 0)
break;
......@@ -602,8 +600,7 @@ search_and_replace (void)
s->range.type == SR_SELECTION)
flag_select = TRUE;
if (entries)
g_list_free (entries);
free_search_entries (entries);
if (s->action == SA_FIND_PANE)
{
......
......@@ -669,7 +669,13 @@ static gint search_entry_compare(gconstpointer a, gconstpointer b)
{
gchar* a_path = ((SearchEntry *) a)->path;
gchar* b_path = ((SearchEntry *) b)->path;
return strcmp(a_path, b_path);
return g_strcmp0(a_path, b_path);
}
static void search_entry_free (gpointer data, gpointer user_data)
{
g_free (((SearchEntry *)data)->path);
g_free (data);
}
/* Create list of search entries */
......@@ -808,14 +814,28 @@ create_search_entries (Search *s)
{
if (IANJUTA_IS_EDITOR (tmp->data))
{
gchar *path = NULL;
if (IANJUTA_IS_FILE (tmp->data))
{
GFile *file = ianjuta_file_get_file (IANJUTA_FILE (tmp->data), NULL);
if (file != NULL)
{
path = g_file_get_path (file);
g_object_unref (file);
}
}
se = g_new0 (SearchEntry, 1);
se->type = SE_BUFFER;
se->type = SE_BUFFER;
se->te = IANJUTA_EDITOR (tmp->data);
se->direction = SD_FORWARD;
se->start_pos = 0;
se->end_pos = -1;
entries = g_list_prepend(entries, se);
}
se->path = path;
se->direction = SD_FORWARD;
se->start_pos = 0;
se->end_pos = -1;
entries = g_list_prepend(entries, se);
}
}
entries = g_list_sort(entries, search_entry_compare);
g_list_free (editors);
......@@ -867,6 +887,12 @@ create_search_entries (Search *s)
return entries;
}
void free_search_entries (GList *entries)
{
g_list_foreach (entries, search_entry_free, NULL);
g_list_free (entries);
}
gchar *
regex_backref (MatchInfo *mi, FileBuffer *fb)
{
......
......@@ -198,6 +198,8 @@ void function_select (IAnjutaEditor *te);
GList *create_search_entries(Search *s);
void free_search_entries (GList *entries);
FileBuffer *file_buffer_new_from_te (IAnjutaEditor *te);
FileBuffer *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment