SF.net SVN: geany: [2619] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Tue May 27 15:10:09 UTC 2008


Revision: 2619
          http://geany.svn.sourceforge.net/geany/?rev=2619&view=rev
Author:   ntrel
Date:     2008-05-27 08:10:08 -0700 (Tue, 27 May 2008)

Log Message:
-----------
Make plugin_free() act like a destructor only, let
pm_dialog_response() call a separate function to only free non-active
plugins.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/plugins.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-05-27 14:47:38 UTC (rev 2618)
+++ trunk/ChangeLog	2008-05-27 15:10:08 UTC (rev 2619)
@@ -2,6 +2,10 @@
 
  * src/plugins.c:
    Fail to load a plugin if it has no plugin_init() function.
+ * src/plugins.c:
+   Make plugin_free() act like a destructor only, let
+   pm_dialog_response() call a separate function to only free non-active
+   plugins.
 
 
 2008-05-26  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c	2008-05-27 14:47:38 UTC (rev 2618)
+++ trunk/src/plugins.c	2008-05-27 15:10:08 UTC (rev 2619)
@@ -93,13 +93,6 @@
 static void pm_show_dialog(GtkMenuItem *menuitem, gpointer user_data);
 
 
-enum
-{
-	PLUGIN_FREE_NON_ACTIVE,
-	PLUGIN_FREE_ALL
-};
-
-
 static DocumentFuncs doc_funcs = {
 	&document_new_file,
 	&document_get_cur_idx,
@@ -651,15 +644,11 @@
 
 
 static void
-plugin_free(Plugin *plugin, gpointer data)
+plugin_free(Plugin *plugin)
 {
 	g_return_if_fail(plugin);
 	g_return_if_fail(plugin->module);
 
-	/* don't do anything when closing the plugin manager and it is an active plugin */
-	if (GPOINTER_TO_INT(data) == PLUGIN_FREE_NON_ACTIVE && is_active_plugin(plugin))
-		return;
-
 	plugin_unload(plugin);
 
 	if (plugin->module != NULL && ! g_module_close(plugin->module))
@@ -844,7 +833,7 @@
 	}
 	if (active_plugin_list != NULL)
 	{
-		g_list_foreach(active_plugin_list, (GFunc) plugin_free,	GINT_TO_POINTER(PLUGIN_FREE_ALL));
+		g_list_foreach(active_plugin_list, (GFunc) plugin_free,	NULL);
 		g_list_free(active_plugin_list);
 	}
 	g_strfreev(active_plugins_pref);
@@ -965,7 +954,7 @@
 	/* unload plugin module */
 	if (!state)
 		keybindings_write_to_file();	/* save shortcuts (only need this group, but it doesn't take long) */
-	plugin_free(p, GINT_TO_POINTER(PLUGIN_FREE_ALL));
+	plugin_free(p);
 
 	/* reload plugin module and initialize it if item is checked */
 	p = plugin_new(file_name, state, TRUE);
@@ -1067,12 +1056,25 @@
 }
 
 
+static void
+free_non_active_plugin(gpointer data, gpointer user_data)
+{
+	Plugin *plugin = data;
+
+	/* don't do anything when closing the plugin manager and it is an active plugin */
+	if (is_active_plugin(plugin))
+		return;
+
+	plugin_free(plugin);
+}
+
+
 static void pm_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
 {
 	if (plugin_list != NULL)
 	{
 		/* remove all non-active plugins from the list */
-		g_list_foreach(plugin_list, (GFunc) plugin_free, GINT_TO_POINTER(PLUGIN_FREE_NON_ACTIVE));
+		g_list_foreach(plugin_list, free_non_active_plugin, NULL);
 		g_list_free(plugin_list);
 		plugin_list = NULL;
 	}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list