|
|
3871be |
From 2f7abcaa7ad39f118b2f49fdcba9c90b37b3d972 Mon Sep 17 00:00:00 2001
|
|
|
3871be |
From: Nils Philippsen <nils@redhat.com>
|
|
|
3871be |
Date: Fri, 5 Jul 2013 16:15:55 +0200
|
|
|
3871be |
Subject: [PATCH] patch: no-file-selected
|
|
|
3871be |
|
|
|
3871be |
Squashed commit of the following:
|
|
|
3871be |
|
|
|
3871be |
commit f887550276e324151947960292a7266c71aeb573
|
|
|
3871be |
Author: Pavel Polischouk <pavel.polischouk@gmail.com>
|
|
|
3871be |
Date: Fri Nov 25 23:55:49 2011 -0500
|
|
|
3871be |
|
|
|
3871be |
fix changing working directory (#621778)
|
|
|
3871be |
|
|
|
3871be |
The patch checks the value returned by xsane_back_gtk_get_filename. In
|
|
|
3871be |
most places it will check the result properly (taking 0 for success),
|
|
|
3871be |
except one case where it takes 0 for an error, and this happens in
|
|
|
3871be |
xsane_browse_filename_callback (xsane-front-gtk.c). The new code would
|
|
|
3871be |
abort copying the filename into preferences structure if 0 was returned,
|
|
|
3871be |
and that's the OK case. I'm very curious how wonderfully it would blow
|
|
|
3871be |
up if an actual error was returned, but that's a different story.
|
|
|
3871be |
|
|
|
3871be |
commit 2c02ddd8282fa231107d8860aee4d92bdb5cb8e8
|
|
|
3871be |
Author: Nils Philippsen <nils@redhat.com>
|
|
|
3871be |
Date: Fri Nov 19 12:25:54 2010 +0100
|
|
|
3871be |
|
|
|
3871be |
don't crash if no files are selected (#608047)
|
|
|
3871be |
---
|
|
|
3871be |
src/xsane-back-gtk.c | 20 ++++++++++++++++----
|
|
|
3871be |
src/xsane-front-gtk.c | 6 +++++-
|
|
|
3871be |
2 files changed, 21 insertions(+), 5 deletions(-)
|
|
|
3871be |
|
|
|
3871be |
diff --git a/src/xsane-back-gtk.c b/src/xsane-back-gtk.c
|
|
|
3871be |
index bca9eb2..6ef1506 100644
|
|
|
3871be |
--- a/src/xsane-back-gtk.c
|
|
|
3871be |
+++ b/src/xsane-back-gtk.c
|
|
|
3871be |
@@ -1111,6 +1111,11 @@ static void xsane_back_gtk_filetype2_callback(GtkWidget *widget, gpointer data)
|
|
|
3871be |
|
|
|
3871be |
chooser_filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filechooser));
|
|
|
3871be |
|
|
|
3871be |
+ if (!chooser_filename)
|
|
|
3871be |
+ {
|
|
|
3871be |
+ return;
|
|
|
3871be |
+ }
|
|
|
3871be |
+
|
|
|
3871be |
if ((new_filetype) && (*new_filetype))
|
|
|
3871be |
{
|
|
|
3871be |
extension = strrchr(chooser_filename, '.');
|
|
|
3871be |
@@ -1505,12 +1510,19 @@ int xsane_back_gtk_get_filename(const char *label, const char *default_name, siz
|
|
|
3871be |
#endif
|
|
|
3871be |
|
|
|
3871be |
chooser_filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filechooser));
|
|
|
3871be |
- strncpy(filename, chooser_filename, max_len - 1);
|
|
|
3871be |
- g_free(chooser_filename);
|
|
|
3871be |
+ if (chooser_filename)
|
|
|
3871be |
+ {
|
|
|
3871be |
+ strncpy(filename, chooser_filename, max_len - 1);
|
|
|
3871be |
+ g_free(chooser_filename);
|
|
|
3871be |
|
|
|
3871be |
- filename[max_len - 1] = '\0';
|
|
|
3871be |
+ filename[max_len - 1] = '\0';
|
|
|
3871be |
|
|
|
3871be |
- ok = TRUE;
|
|
|
3871be |
+ ok = TRUE;
|
|
|
3871be |
+ }
|
|
|
3871be |
+ else
|
|
|
3871be |
+ {
|
|
|
3871be |
+ ok = FALSE;
|
|
|
3871be |
+ }
|
|
|
3871be |
}
|
|
|
3871be |
|
|
|
3871be |
gtk_widget_destroy(filechooser);
|
|
|
3871be |
diff --git a/src/xsane-front-gtk.c b/src/xsane-front-gtk.c
|
|
|
3871be |
index 4c973fb..7bb49b0 100644
|
|
|
3871be |
--- a/src/xsane-front-gtk.c
|
|
|
3871be |
+++ b/src/xsane-front-gtk.c
|
|
|
3871be |
@@ -1333,7 +1333,11 @@ static void xsane_browse_filename_callback(GtkWidget *widget, gpointer data)
|
|
|
3871be |
snprintf(windowname, sizeof(windowname), "%s %s %s", xsane.prog_name, WINDOW_OUTPUT_FILENAME, xsane.device_text);
|
|
|
3871be |
|
|
|
3871be |
umask((mode_t) preferences.directory_umask); /* define new file permissions */
|
|
|
3871be |
- 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);
|
|
|
3871be |
+ 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) < 0)
|
|
|
3871be |
+ {
|
|
|
3871be |
+ xsane_set_sensitivity(TRUE);
|
|
|
3871be |
+ return;
|
|
|
3871be |
+ }
|
|
|
3871be |
umask(XSANE_DEFAULT_UMASK); /* define new file permissions */
|
|
|
3871be |
|
|
|
3871be |
if (preferences.filename)
|
|
|
3871be |
--
|
|
|
3871be |
1.8.3.1
|
|
|
3871be |
|