[anjuta] document-manager: Fix one string and two memory leaks in inline search code.



commit 672e9b895af0424aa47826da4350002c964b8e27
Author: Johannes Schmid <jhs gnome org>
Date:   Mon Mar 7 19:20:56 2011 +0100

    document-manager: Fix one string and two memory leaks in inline search code.

 plugins/document-manager/plugin.c     |    4 ++--
 plugins/document-manager/search-box.c |   17 +++++++++++------
 2 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/plugins/document-manager/plugin.c b/plugins/document-manager/plugin.c
index 16f45c7..1e0f2f1 100644
--- a/plugins/document-manager/plugin.c
+++ b/plugins/document-manager/plugin.c
@@ -291,8 +291,8 @@ static GtkToggleActionEntry actions_searchbox_popup[] = {
     N_("Highlight all occurrences"),
 	G_CALLBACK (on_search_popup_highlight_toggle)},
   { "ActionSearchboxRegexSearch", GTK_STOCK_FIND,
-	N_("Regular Expression Search"), NULL,
-	N_("Regular Expression search"),
+	N_("Regular Expression"), NULL,
+	N_("Search using regular expressions"),
 	G_CALLBACK (on_search_popup_regex_search)}
 };
 
diff --git a/plugins/document-manager/search-box.c b/plugins/document-manager/search-box.c
index c049434..8d24356 100644
--- a/plugins/document-manager/search-box.c
+++ b/plugins/document-manager/search-box.c
@@ -389,6 +389,7 @@ search_box_incremental_search (SearchBox* search_box, gboolean search_forward)
 			}
 			g_free (selected_text);
 		}
+		g_object_unref (selection_start);
 	}
 
 	if (private->regex_mode)
@@ -675,8 +676,7 @@ search_box_toggle_regex (SearchBox * search_box, gboolean status)
 static void
 search_box_search_highlight_all (SearchBox * search_box, gboolean search_forward)
 {
-
-	IAnjutaEditorCell * result_begin, * result_end, * highlight_start;
+	IAnjutaEditorCell * highlight_start;
 	IAnjutaEditorSelection * selection;
 	gboolean entry_found;
 
@@ -688,7 +688,7 @@ search_box_search_highlight_all (SearchBox * search_box, gboolean search_forward
 	/* Search through editor and highlight instances of search_entry */
 	while ((entry_found = search_box_incremental_search (search_box, search_forward)) == TRUE)
 	{
-
+		IAnjutaEditorCell * result_begin, * result_end;
 		selection = IANJUTA_EDITOR_SELECTION (private->current_editor);
 
 		result_begin = 
@@ -704,16 +704,21 @@ search_box_search_highlight_all (SearchBox * search_box, gboolean search_forward
 		else if (ianjuta_iterable_compare (IANJUTA_ITERABLE (result_begin),
 											IANJUTA_ITERABLE (highlight_start), NULL) == 0)
 		{
-			private->highlight_complete = TRUE;
-			return; 
+			g_object_unref (result_begin);
+			g_object_unref (result_end);
+			g_object_unref (highlight_start);
+			break;
 		}
 
 		ianjuta_indicable_set(IANJUTA_INDICABLE(private->current_editor), 
 								IANJUTA_ITERABLE (result_begin), 
 								IANJUTA_ITERABLE (result_end),
 								IANJUTA_INDICABLE_IMPORTANT, NULL);
+		g_object_unref (result_begin);
+		g_object_unref (result_end);
 	}
-
+	if (highlight_start)
+		g_object_unref (highlight_start);
 	private->highlight_complete = TRUE;
 
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]