gthumb r2218 - in trunk: . src



Author: mjc
Date: Fri Jan 25 20:07:27 2008
New Revision: 2218
URL: http://svn.gnome.org/viewvc/gthumb?rev=2218&view=rev

Log:
2008-01-25  Michael J. Chudobiak  <mjc svn gnome org>

        * src/dlg-scripts.c: (exec_shell_script), (exec_script):
        * src/gth-browser.c: (key_press_cb):
        Free script callback data after a hot-key press, but not after
        execution from the Scripts menu. Still a small memory leak,
        but I'm not sure how to fix it.



Modified:
   trunk/ChangeLog
   trunk/src/dlg-scripts.c
   trunk/src/gth-browser.c

Modified: trunk/src/dlg-scripts.c
==============================================================================
--- trunk/src/dlg-scripts.c	(original)
+++ trunk/src/dlg-scripts.c	Fri Jan 25 20:07:27 2008
@@ -503,6 +503,9 @@
 	if ((script == NULL) || (file_list == NULL))
 		return;
 
+	if (!strcmp (script, ""))
+		return;
+
 	data = g_new0 (ProgressData, 1);
 
 	/* Add a progress indicator */
@@ -786,8 +789,6 @@
 				    name,
 				    list);
                 path_list_free (list);
-		/* We don't need the callback data anymore */
-		g_free (cb_data);
 		g_free (name);
 		g_free (command);
 	}

Modified: trunk/src/gth-browser.c
==============================================================================
--- trunk/src/gth-browser.c	(original)
+++ trunk/src/gth-browser.c	Fri Jan 25 20:07:27 2008
@@ -3052,6 +3052,7 @@
 	gboolean               sel_not_null;
 	gboolean               image_is_void;
 	GList		      *list = NULL;
+	ScriptCallbackData    *cb_data = NULL;
 
 	if (GTK_WIDGET_HAS_FOCUS (priv->preview_button_image)
 	    || GTK_WIDGET_HAS_FOCUS (priv->preview_button_data)
@@ -3107,9 +3108,6 @@
 	sel_not_null = gth_file_view_get_n_selected (priv->file_list->view) > 0;
 	image_is_void = image_viewer_is_void (IMAGE_VIEWER (priv->viewer));
 
-	ScriptCallbackData *cb_data = g_new0(ScriptCallbackData, 1);
-	cb_data->window = window;
-
 	switch (gdk_keyval_to_lower (event->keyval)) {
 		/* Hide/Show sidebar. */
 	case GDK_Return:
@@ -3262,61 +3260,90 @@
 		/* hot keys */
 	case GDK_KP_0:
 	case GDK_KP_Insert:
+	        cb_data = g_new0(ScriptCallbackData, 1);
+	        cb_data->window = window;
 		cb_data->number = 0;
 		exec_script (NULL, cb_data);
 		return TRUE;
 
 	case GDK_KP_1:
 	case GDK_KP_End:
+		cb_data = g_new0(ScriptCallbackData, 1);
+	        cb_data->window = window;
 		cb_data->number = 1;
 		exec_script (NULL, cb_data);
+		g_free (cb_data);
 		return TRUE;
 
 	case GDK_KP_2:
 	case GDK_KP_Down:
-		cb_data->number = 1;
+		cb_data = g_new0(ScriptCallbackData, 1);
+                cb_data->window = window;
+		cb_data->number = 2;
 		exec_script (NULL, cb_data);
+		g_free (cb_data);
 		return TRUE;
 
 	case GDK_KP_3:
 	case GDK_KP_Page_Down:
+		cb_data = g_new0(ScriptCallbackData, 1);
+                cb_data->window = window;
 		cb_data->number = 3;
 		exec_script (NULL, cb_data);
+		g_free (cb_data);
 		return TRUE;
 
 	case GDK_KP_4:
 	case GDK_KP_Left:
+		cb_data = g_new0(ScriptCallbackData, 1);
+                cb_data->window = window;
 		cb_data->number = 4;
 		exec_script (NULL, cb_data);
+		g_free (cb_data);
 		return TRUE;
 
 	case GDK_KP_5:
+		cb_data = g_new0(ScriptCallbackData, 1);
+                cb_data->window = window;
 		cb_data->number = 5;
 		exec_script (NULL, cb_data);
+		g_free (cb_data);
 		return TRUE;
 
 	case GDK_KP_6:
 	case GDK_KP_Right:
+		cb_data = g_new0(ScriptCallbackData, 1);
+                cb_data->window = window;
 		cb_data->number = 6;
 		exec_script (NULL, cb_data);
+		g_free (cb_data);
 		return TRUE;
 
 	case GDK_KP_7:
 	case GDK_KP_Home:
+		cb_data = g_new0(ScriptCallbackData, 1);
+                cb_data->window = window;
 		cb_data->number = 7;
 		exec_script (NULL, cb_data);
+		g_free (cb_data);
 		return TRUE;
 
 	case GDK_KP_8:
 	case GDK_KP_Up:
+		cb_data = g_new0(ScriptCallbackData, 1);
+                cb_data->window = window;
 		cb_data->number = 8;
 		exec_script (NULL, cb_data);
+		g_free (cb_data);
 		return TRUE;
 
 	case GDK_KP_9:
 	case GDK_KP_Page_Up:
+		cb_data = g_new0(ScriptCallbackData, 1);
+                cb_data->window = window;
 		cb_data->number = 9;
 		exec_script (NULL, cb_data);
+		g_free (cb_data);
 		return TRUE;
 
 



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