kopia lustrzana https://gitlab.com/sane-project/frontends
scanadf,xcam: remove atexit macro and call exit functions manually.
sane_exit() *must* be called on exit in every occasion otherwise there will be crashes from the cleanup of backends. Since on_exit() is not bound to be supported, we cannot rely on it being available. So the applications must ensure that the sane_exit() function is always called on all exit routes to avoid crashing at the end of session.42-gtk3-port-issues
rodzic
120004c6b6
commit
cc564c4464
|
@ -96,7 +96,7 @@ fi
|
|||
dnl Checks for library functions.
|
||||
AC_FUNC_ALLOCA
|
||||
AC_FUNC_MMAP
|
||||
AC_CHECK_FUNCS(atexit mkdir sigprocmask strdup strndup strftime strstr \
|
||||
AC_CHECK_FUNCS(mkdir sigprocmask strdup strndup strftime strstr \
|
||||
strsep strtod snprintf usleep strcasecmp strncasecmp getenv isfdtype vsyslog)
|
||||
|
||||
if test "$ac_cv_header_os2_h" = "yes" ; then
|
||||
|
|
|
@ -100,11 +100,6 @@ sane_strframe (SANE_Frame f)
|
|||
(f) == SANE_FRAME_GREEN || \
|
||||
(f) == SANE_FRAME_BLUE )
|
||||
|
||||
|
||||
#ifndef HAVE_ATEXIT
|
||||
# define atexit(func) on_exit(func, 0) /* works for SunOS, at least */
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u_char *data;
|
||||
|
@ -1419,8 +1414,6 @@ main (int argc, char **argv)
|
|||
int startNum = 1, endNum = -1; /* start/end numbers of pages to scan */
|
||||
int no_overwrite = 0;
|
||||
|
||||
atexit (sane_exit);
|
||||
|
||||
prog_name = strrchr (argv[0], '/');
|
||||
if (prog_name)
|
||||
++prog_name;
|
||||
|
@ -1477,7 +1470,7 @@ main (int argc, char **argv)
|
|||
|
||||
case 'V':
|
||||
printf ("scanadf (%s) %s\n", PACKAGE, VERSION);
|
||||
exit (0);
|
||||
scanadf_exit (0);
|
||||
|
||||
default:
|
||||
break; /* ignore device specific options for now */
|
||||
|
@ -1721,5 +1714,5 @@ List of available devices:", prog_name);
|
|||
if (scriptWait)
|
||||
while (wait(NULL) != -1);
|
||||
|
||||
return (status == SANE_STATUS_GOOD) ? 0 : 1;
|
||||
scanadf_exit((status == SANE_STATUS_GOOD) ? 0 : 1);
|
||||
}
|
||||
|
|
18
src/xcam.c
18
src/xcam.c
|
@ -65,10 +65,6 @@
|
|||
|
||||
#define MAX_LUM 64 /* how many graylevels for 8 bit displays */
|
||||
|
||||
#ifndef HAVE_ATEXIT
|
||||
# define atexit(func) on_exit(func, 0) /* works for SunOS, at least */
|
||||
#endif
|
||||
|
||||
typedef struct Canvas
|
||||
{
|
||||
GtkWidget *preview;
|
||||
|
@ -158,6 +154,8 @@ static void update_param (GSGDialog * dialog, void *arg);
|
|||
|
||||
static void load_defaults (int silent);
|
||||
|
||||
static void xcam_exit (void);
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"version", no_argument, NULL, 'V'},
|
||||
|
@ -684,6 +682,7 @@ exit_callback (GtkWidget * widget, gpointer data)
|
|||
if (dialog)
|
||||
gsg_destroy_dialog (dialog);
|
||||
dialog = 0;
|
||||
xcam_exit ();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
@ -810,6 +809,7 @@ build_device_menu (void)
|
|||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
fprintf (stderr, "%s: %s\n", prog_name, sane_strstatus (status));
|
||||
xcam_exit();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -1669,6 +1669,7 @@ main (int argc, char **argv)
|
|||
{
|
||||
DBG (DBG_fatal, "init: sane_main failed: %s\n",
|
||||
sane_strstatus (status));
|
||||
xcam_exit();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -1681,14 +1682,17 @@ main (int argc, char **argv)
|
|||
{
|
||||
case 'V':
|
||||
printf ("xcam (%s) %s\n", PACKAGE, VERSION);
|
||||
xcam_exit();
|
||||
exit(0);
|
||||
|
||||
case 'B':
|
||||
win.buf_backend_size = 1024 * 1024;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
default:
|
||||
usage ();
|
||||
xcam_exit();
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
@ -1702,8 +1706,6 @@ main (int argc, char **argv)
|
|||
gdk_set_show_events (0);
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
atexit (xcam_exit);
|
||||
|
||||
win.gdk_input_tag = -1;
|
||||
win.shell = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (win.shell), (char *) prog_name);
|
||||
|
@ -1813,7 +1815,8 @@ main (int argc, char **argv)
|
|||
" detected by sane-find-scanner (if appropriate). Please read\n"
|
||||
" the documentation which came with this software (README, FAQ,\n"
|
||||
" manpages).\n");
|
||||
atexit (xcam_exit);
|
||||
xcam_exit();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (dialog && gsg_dialog_get_device (dialog)
|
||||
|
@ -1938,5 +1941,6 @@ main (int argc, char **argv)
|
|||
pref_xcam_save ();
|
||||
|
||||
DBG (DBG_debug, "xcam main exit\n");
|
||||
xcam_exit();
|
||||
return 0;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue