SF.net SVN: geany-plugins:[936] trunk/geany-plugins/geanylua

ntrel at users.sourceforge.net ntrel at xxxxx
Wed Sep 16 11:08:45 UTC 2009


Revision: 936
          http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=936&view=rev
Author:   ntrel
Date:     2009-09-16 11:08:45 +0000 (Wed, 16 Sep 2009)

Log Message:
-----------
Fix possible memory leak; use keybindings_set_item() so we don't
leave Geany to free our memory (bad practice).

Modified Paths:
--------------
    trunk/geany-plugins/geanylua/ChangeLog
    trunk/geany-plugins/geanylua/glspi_init.c

Modified: trunk/geany-plugins/geanylua/ChangeLog
===================================================================
--- trunk/geany-plugins/geanylua/ChangeLog	2009-09-15 21:34:38 UTC (rev 935)
+++ trunk/geany-plugins/geanylua/ChangeLog	2009-09-16 11:08:45 UTC (rev 936)
@@ -1,3 +1,7 @@
+September 16, 2009 (ntrel)
+  Fix possible memory leak; use keybindings_set_item() so we don't
+  leave Geany to free our memory (bad practice).
+
 September 1, 2009 (ntrel)
   Try loading system support library if user library fails.
   Check support library ABI version matches.

Modified: trunk/geany-plugins/geanylua/glspi_init.c
===================================================================
--- trunk/geany-plugins/geanylua/glspi_init.c	2009-09-15 21:34:38 UTC (rev 935)
+++ trunk/geany-plugins/geanylua/glspi_init.c	2009-09-16 11:08:45 UTC (rev 936)
@@ -147,25 +147,24 @@
 			g_strfreev(lines);
 			KG=plugin_set_key_group(glspi_geany_plugin, "lua_scripts", n, NULL);
 			for (i=0; i<n; i++) {
-				GeanyKeyBinding *kb = keybindings_get_item(KG, i);
+				gchar *label=NULL;
+				gchar *name=NULL;
 				if (KS[i]) {
 					gchar*p=NULL;
-					kb->label=g_path_get_basename(KS[i]);
-					fixup_label(kb->label);
-					p=strchr(kb->label,'_');
+					label=g_path_get_basename(KS[i]);
+					fixup_label(label);
+					p=strchr(label,'_');
 					if (p) { *p=' ';}
-					p=strrchr(kb->label, '.');
+					p=strrchr(label, '.');
 					if (p && (strcasecmp(p, ".lua")==0)) {
 						*p='\0';
 					}
-					kb->name=g_strdup_printf("lua_script_%d", i+1);
-				} else {
-					kb->label=NULL;
+					name=g_strdup_printf("lua_script_%d", i+1);
 				}
-				kb->callback = kb_activate;
 				/* no default keycombos, just overridden by user settings */
-				kb->key = 0;
-				kb->mods = 0;
+				keybindings_set_item(KG, i, kb_activate, 0, 0, name, label, NULL);
+				g_free(label);
+				g_free(name);
 			}
 		} else {
 			if (geany->app->debug_mode) {


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



More information about the Plugins-Commits mailing list