anjuta r4422 - in branches/gnome-2-24: . plugins/file-manager



Author: sgranjoux
Date: Sat Dec  6 20:39:44 2008
New Revision: 4422
URL: http://svn.gnome.org/viewvc/anjuta?rev=4422&view=rev

Log:
	* plugins/file-manager/plugin.c,
	plugins/file-manager/file-model.c:
	Fix #560284: Crash when deleting a folder outside Anjuta


Modified:
   branches/gnome-2-24/ChangeLog
   branches/gnome-2-24/plugins/file-manager/file-model.c
   branches/gnome-2-24/plugins/file-manager/plugin.c

Modified: branches/gnome-2-24/plugins/file-manager/file-model.c
==============================================================================
--- branches/gnome-2-24/plugins/file-manager/file-model.c	(original)
+++ branches/gnome-2-24/plugins/file-manager/file-model.c	Sat Dec  6 20:39:44 2008
@@ -106,28 +106,6 @@
 }
 
 static void
-file_model_remove_file (FileModel* model, 
-						GtkTreeIter* iter)
-{
-	GFile* file;
-	GtkTreeRowReference* reference;
-	GFileMonitor* monitor;
-	
-	gtk_tree_model_get (GTK_TREE_MODEL (model), iter,
-						COLUMN_FILE, &file, -1);
-	
-	monitor = g_object_get_data (G_OBJECT(file), "file-monitor");
-	if (monitor)
-		g_object_unref (monitor);
-	
-	reference = g_object_get_data (G_OBJECT(file), "reference");
-	if (reference)
-		gtk_tree_row_reference_free(reference);
-	
-	gtk_tree_store_remove (GTK_TREE_STORE (model), iter);	
-}
-
-static void
 file_model_update_file (FileModel* model,
 						GtkTreeIter* iter,
 						GFile* file,
@@ -201,6 +179,7 @@
 	GtkTreeIter file_iter;
 	gboolean found = FALSE;
 	
+	/* reference could be invalid if the file has already been destroyed */
 	if (!gtk_tree_row_reference_valid(reference))
 		return;
 	
@@ -255,7 +234,7 @@
 		}
 		case G_FILE_MONITOR_EVENT_DELETED:
 		{
-			file_model_remove_file (model, &file_iter);
+			gtk_tree_store_remove (GTK_TREE_STORE (model), &file_iter);			
 			break;
 		}
 		default:
@@ -285,8 +264,9 @@
 	g_signal_connect (monitor, "changed", G_CALLBACK(on_file_model_changed),
 					  reference);
 	
-	g_object_set_data (G_OBJECT(file), "file-monitor", monitor);
-	g_object_set_data (G_OBJECT(file), "reference", reference);	
+	g_object_set_data_full (G_OBJECT(file), "file-monitor", monitor, (GDestroyNotify)g_object_unref);
+	/* Reference is used by monitor, should be kept it until the monitor is destroyed */
+	g_object_set_data_full (G_OBJECT(monitor), "reference", reference, (GDestroyNotify)gtk_tree_row_reference_free);
 	g_object_unref (file);
 }
 
@@ -355,7 +335,7 @@
 
 	while (gtk_tree_model_iter_children (GTK_TREE_MODEL(model), &child, &real_iter))
 	{
-		file_model_remove_file (model, &child);
+		gtk_tree_store_remove (GTK_TREE_STORE (model), &child);		
 	}
 	
 	file_model_add_dummy (model, &real_iter);

Modified: branches/gnome-2-24/plugins/file-manager/plugin.c
==============================================================================
--- branches/gnome-2-24/plugins/file-manager/plugin.c	(original)
+++ branches/gnome-2-24/plugins/file-manager/plugin.c	Sat Dec  6 20:39:44 2008
@@ -131,6 +131,7 @@
 		g_value_set_object (value, file);
 		anjuta_shell_add_value (ANJUTA_PLUGIN (file_manager)->shell,
 								IANJUTA_FILE_MANAGER_SELECTED_FILE, value, NULL);
+		g_value_unset (value);
 	}
 	else
 	{



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