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
Ralph Little 2024-10-29 15:35:28 -07:00
rodzic 120004c6b6
commit cc564c4464
3 zmienionych plików z 19 dodań i 22 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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);
}

Wyświetl plik

@ -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,7 +682,8 @@ exit_callback (GtkWidget * widget, gpointer data)
if (dialog)
gsg_destroy_dialog (dialog);
dialog = 0;
exit (0);
xcam_exit ();
exit(0);
}
static void
@ -810,7 +809,8 @@ build_device_menu (void)
if (status != SANE_STATUS_GOOD)
{
fprintf (stderr, "%s: %s\n", prog_name, sane_strstatus (status));
exit (1);
xcam_exit();
exit(1);
}
for (i = 0; device[i]; ++i)
@ -1669,7 +1669,8 @@ main (int argc, char **argv)
{
DBG (DBG_fatal, "init: sane_main failed: %s\n",
sane_strstatus (status));
exit (1);
xcam_exit();
exit(1);
}
if (argc > 1)
@ -1681,15 +1682,18 @@ main (int argc, char **argv)
{
case 'V':
printf ("xcam (%s) %s\n", PACKAGE, VERSION);
exit (0);
xcam_exit();
exit(0);
case 'B':
win.buf_backend_size = 1024 * 1024;
break;
case 'h':
default:
usage ();
exit (0);
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;
}