xsane/xsane-0.997-no-file-selected.patch
2012-08-16 11:29:27 +02:00

78 lines
2.7 KiB
Diff

From 705415aeae0117a8df984701ad39606439b39a65 Mon Sep 17 00:00:00 2001
From: Nils Philippsen <nils@redhat.com>
Date: Thu, 16 Aug 2012 10:58:07 +0200
Subject: [PATCH] patch: no-file-selected
Squashed commit of the following:
commit da2140208e30e87f4779593071b60654dcc187eb
Author: Nils Philippsen <nils@redhat.com>
Date: Fri Nov 19 12:25:54 2010 +0100
don't crash if no files are selected (#608047)
---
src/xsane-back-gtk.c | 20 ++++++++++++++++----
src/xsane-front-gtk.c | 6 +++++-
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/src/xsane-back-gtk.c b/src/xsane-back-gtk.c
index 4701dc6..91b5804 100644
--- a/src/xsane-back-gtk.c
+++ b/src/xsane-back-gtk.c
@@ -1111,6 +1111,11 @@ static void xsane_back_gtk_filetype2_callback(GtkWidget *widget, gpointer data)
chooser_filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filechooser));
+ if (!chooser_filename)
+ {
+ return;
+ }
+
if ((new_filetype) && (*new_filetype))
{
extension = strrchr(chooser_filename, '.');
@@ -1501,12 +1506,19 @@ int xsane_back_gtk_get_filename(const char *label, const char *default_name, siz
#endif
chooser_filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filechooser));
- strncpy(filename, chooser_filename, max_len - 1);
- g_free(chooser_filename);
+ if (chooser_filename)
+ {
+ strncpy(filename, chooser_filename, max_len - 1);
+ g_free(chooser_filename);
- filename[max_len - 1] = '\0';
+ filename[max_len - 1] = '\0';
- ok = TRUE;
+ ok = TRUE;
+ }
+ else
+ {
+ ok = FALSE;
+ }
}
gtk_widget_destroy(filechooser);
diff --git a/src/xsane-front-gtk.c b/src/xsane-front-gtk.c
index 35aa89d..08761a0 100644
--- a/src/xsane-front-gtk.c
+++ b/src/xsane-front-gtk.c
@@ -1333,7 +1333,11 @@ static void xsane_browse_filename_callback(GtkWidget *widget, gpointer data)
snprintf(windowname, sizeof(windowname), "%s %s %s", xsane.prog_name, WINDOW_OUTPUT_FILENAME, xsane.device_text);
umask((mode_t) preferences.directory_umask); /* define new file permissions */
- xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, &preferences.filetype, &preferences.cms_function, XSANE_FILE_CHOOSER_ACTION_SELECT_SAVE, show_extra_widgets, XSANE_FILE_FILTER_ALL | XSANE_FILE_FILTER_IMAGES, XSANE_FILE_FILTER_IMAGES);
+ if (!xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, &preferences.filetype, &preferences.cms_function, XSANE_FILE_CHOOSER_ACTION_SELECT_SAVE, show_extra_widgets, XSANE_FILE_FILTER_ALL | XSANE_FILE_FILTER_IMAGES, XSANE_FILE_FILTER_IMAGES))
+ {
+ xsane_set_sensitivity(TRUE);
+ return;
+ }
umask(XSANE_DEFAULT_UMASK); /* define new file permissions */
if (preferences.filename)
--
1.7.11.4