From 690c919cb6430b756b41b0709087e27f30302ad7 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Sun, 4 Jul 2004 13:40:24 +0000 Subject: [PATCH] don't attempt to store a pointer to the last used filename in the plug-in 2004-07-04 Sven Neumann * plug-ins/common/channel_mixer.c: don't attempt to store a pointer to the last used filename in the plug-in parameter struct. Fixes bug #145380. --- ChangeLog | 6 +++ plug-ins/common/channel_mixer.c | 70 +++++++++++---------------------- 2 files changed, 28 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index 27db96efbc..704d80ba55 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-07-04 Sven Neumann + + * plug-ins/common/channel_mixer.c: don't attempt to store a + pointer to the last used filename in the plug-in parameter + struct. Fixes bug #145380. + 2004-07-04 Sven Neumann * modules/cdisplay_gamma.c diff --git a/plug-ins/common/channel_mixer.c b/plug-ins/common/channel_mixer.c index 7f1d93de53..9a7f7940a1 100644 --- a/plug-ins/common/channel_mixer.c +++ b/plug-ins/common/channel_mixer.c @@ -83,8 +83,6 @@ typedef struct CmModeType output_channel; - gchar *filename; - GtkAdjustment *red_data; GtkAdjustment *green_data; GtkAdjustment *blue_data; @@ -977,32 +975,12 @@ cm_preserve_luminosity_callback (GtkWidget *widget, } static gchar * -cm_settings_filename (CmParamsType *mix) +cm_settings_filename (void) { - gchar *filename; - - if (! mix->filename) - mix->filename = g_strdup ("settings"); - - if (! g_path_is_absolute (mix->filename)) - { - gchar *basedir; - - basedir = g_build_filename (gimp_directory (), "channel-mixer", NULL); - - if (! g_file_test (basedir, G_FILE_TEST_IS_DIR)) - mkdir (basedir, 0775); - - filename = g_build_filename (basedir, mix->filename, NULL); - - g_free (basedir); - } - else - { - filename = g_strdup (mix->filename); - } - - return filename; + return g_build_filename (gimp_directory (), + "channel-mixer", + "settings", + NULL); } static void @@ -1011,11 +989,10 @@ cm_load_file_callback (GtkWidget *widget, { static GtkWidget *dialog = NULL; - gchar *name; - if (! dialog) { GtkWidget *parent = gtk_widget_get_toplevel (widget); + gchar *name; dialog = gtk_file_chooser_dialog_new (_("Load Channel Mixer Settings"), @@ -1035,11 +1012,11 @@ cm_load_file_callback (GtkWidget *widget, g_signal_connect (dialog, "delete_event", G_CALLBACK (gtk_true), NULL); - } - name = cm_settings_filename (mix); - gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), name); - g_free (name); + name = cm_settings_filename (); + gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), name); + g_free (name); + } gtk_window_present (GTK_WINDOW (dialog)); } @@ -1053,12 +1030,11 @@ cm_load_file_response_callback (GtkWidget *dialog, if (response_id == GTK_RESPONSE_OK) { - g_free (mix->filename); + gchar *filename; - mix->filename = - gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); - fp = fopen (mix->filename, "r"); + fp = fopen (filename, "r"); if (fp) { @@ -1137,9 +1113,11 @@ cm_load_file_response_callback (GtkWidget *dialog, else { g_message (_("Could not open '%s' for reading: %s"), - gimp_filename_to_utf8 (mix->filename), + gimp_filename_to_utf8 (filename), g_strerror (errno)); } + + g_free (filename); } gtk_widget_hide (dialog); @@ -1151,11 +1129,10 @@ cm_save_file_callback (GtkWidget *widget, { static GtkWidget *dialog = NULL; - gchar *name; - if (! dialog) { GtkWidget *parent = gtk_widget_get_toplevel (widget); + gchar *name; dialog = gtk_file_chooser_dialog_new (_("Save Channel Mixer Settings"), @@ -1175,11 +1152,11 @@ cm_save_file_callback (GtkWidget *widget, g_signal_connect (dialog, "delete_event", G_CALLBACK (gtk_true), NULL); - } - name = cm_settings_filename (mix); - gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), name); - g_free (name); + name = cm_settings_filename (); + gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), name); + g_free (name); + } gtk_window_present (GTK_WINDOW (dialog)); } @@ -1219,12 +1196,9 @@ cm_save_file_response_callback (GtkWidget *dialog, return; } - g_free (mix->filename); - mix->filename = filename; - cm_save_file (mix, file); - g_message (_("Parameters were Saved to '%s'"), + g_message (_("Parameters were saved to '%s'"), gimp_filename_to_utf8 (filename)); gtk_widget_hide (dialog);