gedit r6638 - in trunk: . gedit plugin-loaders/c



Author: pborelli
Date: Sun Nov 30 13:48:44 2008
New Revision: 6638
URL: http://svn.gnome.org/viewvc/gedit?rev=6638&view=rev

Log:
2008-11-30  Paolo Borelli  <pborelli katamail com>

	* gedit/gedit-plugins-engine.c:
	* plugin-loaders/c/plugin-loader-c.c:
	Plug some minor memory leaks.



Modified:
   trunk/ChangeLog
   trunk/gedit/gedit-plugins-engine.c
   trunk/plugin-loaders/c/gedit-plugin-loader-c.c

Modified: trunk/gedit/gedit-plugins-engine.c
==============================================================================
--- trunk/gedit/gedit-plugins-engine.c	(original)
+++ trunk/gedit/gedit-plugins-engine.c	Sun Nov 30 13:48:44 2008
@@ -110,7 +110,6 @@
 	gedit_debug_message (DEBUG_PLUGINS, "DIR: %s", dir);
 
 	d = g_dir_open (dir, 0, &error);
-
 	if (!d)
 	{
 		g_warning ("%s", error->message);
@@ -121,18 +120,20 @@
 	while ((dirent = g_dir_read_name (d)))
 	{
 		gchar *filename;
-		
+
 		if (!g_str_has_suffix (dirent, suffix))
 			continue;
-		
+
 		filename = g_build_filename (dir, dirent, NULL);
 
 		ret = callback (engine, filename, userdata);
-		
+
+		g_free (filename);
+
 		if (!ret)
 			break;
 	}
-	
+
 	g_dir_close (d);
 	return ret;
 }
@@ -736,6 +737,7 @@
 	
 	if (engine->priv->activate_from_gconf)
 	{
+		g_slist_foreach (active_plugins, (GFunc) g_free, NULL);
 		g_slist_free (active_plugins);
 		engine->priv->activate_from_gconf = FALSE;
 	}

Modified: trunk/plugin-loaders/c/gedit-plugin-loader-c.c
==============================================================================
--- trunk/plugin-loaders/c/gedit-plugin-loader-c.c	(original)
+++ trunk/plugin-loaders/c/gedit-plugin-loader-c.c	Sun Nov 30 13:48:44 2008
@@ -57,6 +57,10 @@
 		module = gedit_object_module_new (gedit_plugin_info_get_module_name (info),
 						  path,
 						  "register_gedit_plugin");
+
+		/* Infos are available for all the lifetime of the loader.
+		 * If this changes, we should use weak refs or something */
+
 		g_hash_table_insert (cloader->priv->loaded_plugins, info, module);
 	}
 
@@ -112,19 +116,24 @@
 	GList *infos;
 	GList *item;
 
+	/* FIXME: this sanity check it's not efficient. Let's remove it
+	 * once we are confident with the code */
+
 	infos = g_hash_table_get_keys (cloader->priv->loaded_plugins);
 	
 	for (item = infos; item; item = item->next)
 	{
 		GeditPluginInfo *info = (GeditPluginInfo *)item->data;
-		
+
 		if (gedit_plugin_info_is_active (info))
 		{
 			g_warning ("There are still C plugins loaded during destruction");
 			break;
 		}
 	}
-	
+
+	g_list_free (infos);	
+
 	g_hash_table_destroy (cloader->priv->loaded_plugins);
 	
 	G_OBJECT_CLASS (gedit_plugin_loader_c_parent_class)->finalize (object);



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