← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~linuxdcpp-team/linuxdcpp/trunk] Rev 399: Fix manual removing of search results

 

Merge authors:
  Razzloss (razzloss)
------------------------------------------------------------
revno: 399 [merge]
fixes bug(s): https://launchpad.net/bugs/667491
committer: Razzloss <razzloss@xxxxxxxxx>
branch nick: master
timestamp: Fri 2010-10-29 22:45:13 +0300
message:
  Fix manual removing of search results
modified:
  linux/search.cc


--
lp:linuxdcpp
https://code.launchpad.net/~linuxdcpp-team/linuxdcpp/trunk

Your team LinuxDC++ Team is subscribed to branch lp:linuxdcpp.
To unsubscribe from this branch go to https://code.launchpad.net/~linuxdcpp-team/linuxdcpp/trunk/+edit-subscription
=== modified file 'linux/search.cc'
--- linux/search.cc	2010-10-14 03:51:12 +0000
+++ linux/search.cc	2010-10-29 19:44:50 +0000
@@ -1451,20 +1451,34 @@
 		GtkTreeIter filterIter;
 		GtkTreePath *path;
 		GList *list = gtk_tree_selection_get_selected_rows(s->selection, NULL);
+		GList *refList = NULL;
 
+		// Convert it to list of GtkTreeRowReferences since modifying the model with a list of Paths is bad.
 		for (GList *i = list; i; i = i->next)
 		{
 			path = (GtkTreePath *)i->data;
-			if (gtk_tree_model_get_iter(s->sortedFilterModel, &iter, path))
+			refList = g_list_append(refList, gtk_tree_row_reference_new(s->sortedFilterModel, path));
+			gtk_tree_path_free(path);
+		}
+		g_list_free(list);
+
+		for (GList *i = refList; i; i = i->next)
+		{
+			path = gtk_tree_row_reference_get_path((GtkTreeRowReference*)i->data);	
+			if (path != NULL)
 			{
-				// Remove the top-level node and it will remove any children nodes (if applicable)
-				gtk_tree_model_sort_convert_iter_to_child_iter(GTK_TREE_MODEL_SORT(s->sortedFilterModel), &filterIter, &iter);
-				gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(s->searchFilterModel), &iter, &filterIter);
-				gtk_tree_store_remove(s->resultStore, &iter);
+				if (gtk_tree_model_get_iter(s->sortedFilterModel, &iter, path))
+				{
+					// Remove the top-level node and it will remove any children nodes (if applicable)
+					gtk_tree_model_sort_convert_iter_to_child_iter(GTK_TREE_MODEL_SORT(s->sortedFilterModel), &filterIter, &iter);
+					gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(s->searchFilterModel), &iter, &filterIter);
+					gtk_tree_store_remove(s->resultStore, &iter);
+				}
+				gtk_tree_path_free(path);
 			}
-			gtk_tree_path_free(path);
+			gtk_tree_row_reference_free((GtkTreeRowReference*)i->data);
 		}
-		g_list_free(list);
+		g_list_free(refList);
 	}
 }
 
@@ -1538,7 +1552,7 @@
 	}
 	else
 	{
-	 	string path = WulforUtil::linuxSeparator(result->getFile());
+		string path = WulforUtil::linuxSeparator(result->getFile());
 		resultMap["Filename"] = WulforUtil::linuxSeparator(result->getFileName());
 		resultMap["Path"] = Util::getFilePath(path.substr(0, path.length() - 1)); // getFilePath just returns path unless we chop the last / off
 		if (resultMap["Path"].find("/") == string::npos)