Fix crash if OB setup druid gets closed while waiting for the wizard. #409319.

In the online banking setup druid the process is forked for executing
the AqBanking Qt wizard. While waiting for it, the user can cancel the
druid in an inner main loop, but the code once returned does not know
that and crashes. Patch by cstim.

BP


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15623 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Andreas Köhler 2007-02-19 17:41:41 +00:00
parent 1a83d79a2c
commit d61475601d

View File

@ -87,6 +87,11 @@ struct _hbciinitialinfo
}; };
/* Is TRUE as long as the druid is opened and running. Is being
used to catch a window close event during waiting for a child
process. */
static gboolean hbci_druid_is_active = FALSE;
static void static void
reset_initial_info (HBCIInitialInfo *info) reset_initial_info (HBCIInitialInfo *info)
{ {
@ -115,6 +120,7 @@ delete_initial_druid (HBCIInitialInfo *info)
if (info->window != NULL) if (info->window != NULL)
gtk_widget_destroy (info->window); gtk_widget_destroy (info->window);
hbci_druid_is_active = FALSE;
g_free (info); g_free (info);
} }
@ -585,6 +591,7 @@ on_aqhbci_button (GtkButton *button,
default: /* parent */ default: /* parent */
res = 0; res = 0;
/* wait until child is finished */ /* wait until child is finished */
hbci_druid_is_active = TRUE;
while (wait_result == 0) { while (wait_result == 0) {
gtk_main_iteration(); gtk_main_iteration();
wait_result = waitpid(pid, &wait_status, WNOHANG); wait_result = waitpid(pid, &wait_status, WNOHANG);
@ -593,6 +600,12 @@ on_aqhbci_button (GtkButton *button,
else else
res = -8; res = -8;
} }
if (!hbci_druid_is_active) {
/* Just in case the druid has been canceled in the meantime. */
g_free (backend_name);
GWEN_Buffer_free(buf);
return;
}
AB_Banking_Init (info->api); AB_Banking_Init (info->api);
} }
} }