g_free ( extra );
g_free ( wi->options );
- if (!result) {
+ if (wi->w->running && !result) {
gdk_threads_enter();
gtk_label_set_text ( GTK_LABEL(wi->w->status), _("Error: acquisition failed.") );
if ( wi->creating_new_layer )
if ( wi->w->running ) {
wi->w->running = FALSE;
}
+ else {
+ g_free ( wi->w );
+ g_free ( wi );
+ wi = NULL;
+ }
g_thread_exit ( NULL );
}
g_thread_create((GThreadFunc)get_from_anything, wi, FALSE, NULL );
gtk_dialog_run ( GTK_DIALOG(dialog) );
if (w->running) {
- w->running = FALSE;
+ // Cancel and mark for thread to finish
+ w->running = FALSE;
+ // NB Thread will free memory
} else {
if ( cmd_off ) {
/* Turn off */
}
if ( extra_off )
g_free ( extra_off );
+
+ // Thread finished by normal completion - free memory
+ g_free ( w );
+ g_free ( wi );
}
}
else {
// This shouldn't happen...
gtk_label_set_text ( GTK_LABEL(w->status), _("Unable to create command\nAcquire method failed.") );
gtk_dialog_run (GTK_DIALOG (dialog));
- goto end;
}
}
else {
// Actually show it if necessary
if ( wi->w->source_interface->keep_dialog_open )
gtk_dialog_run ( GTK_DIALOG(dialog) );
+
+ g_free ( w );
+ g_free ( wi );
}
- end:
gtk_widget_destroy ( dialog );
- g_free ( w );
- g_free ( wi );
}
/**