Commit ebf6745d authored by Stefan Tauner's avatar Stefan Tauner
Browse files

EE GUI: let the user abort without ^C

Previously, the user was asked to supply a valid FIJI config repeatedly if
none was provided. Even canceling the dialog would not end the
application.

With this patch the user is asked repeatedly only if it is not valid (throwing
errors). If the user cancels loading the config file, EE GUI aborts completely.
parent 413d322c
......@@ -390,13 +390,25 @@ sub entry_rebind($) {
sub show_warning {
my ($widget, $msg) = @_;
get_logger("")->warn($msg);
my $warn_dialog = $widget->MainWindow->FIJIModalDialog(
my $dialog = $widget->MainWindow->FIJIModalDialog(
-image => Tk::FIJIUtils::alert_image($widget->MainWindow),
-wraplength => $widget->MainWindow->screenwidth,
-text => "$msg",
-title => "Warning",
);
$warn_dialog->Show();
$dialog->Show();
}
sub show_error {
my ($widget, $msg) = @_;
get_logger("")->error($msg);
my $dialog = $widget->MainWindow->FIJIModalDialog(
-image => Tk::FIJIUtils::error_image($widget->MainWindow),
-wraplength => $widget->MainWindow->screenwidth,
-text => "$msg",
-title => "Error",
);
$dialog->Show();
}
1;
......@@ -33,6 +33,7 @@ use Tk::widgets qw(LabFrame Label Entry Button DialogBox FBox Checkbutton);
use Tk::FIJIUtils;
use Tk::FIJIModalDialog;
use Clone qw(clone);
use Scalar::Util 'blessed';
use File::Spec;
use File::Basename qw(basename);
use FIJI::Utils;
......@@ -257,17 +258,15 @@ sub main {
my $tmp_settings;
do {
$tmp_settings = $self->_load_settings_prompt($mw);
} while (!defined($tmp_settings));
if (!defined($tmp_settings)) {
Tk::FIJIUtils::show_error($mw, "A valid configuration file is required. Exiting.");
$ret = 1;
goto bailout;
}
} while (!blessed($tmp_settings) || !$tmp_settings->isa("FIJI::Settings"));
$self->{'settings'} = $tmp_settings;
}
if (!defined ${$self->{'settings_ini_name'}}) {
$logger->error("No settings file chosen");
$ret = 1;
goto bailout;
}
my $tmp_tests;
unless (defined($tests_filename) && defined ($tmp_tests = $self->_read_tests_file($tests_filename))) {
# Create one with defaults
......@@ -494,6 +493,10 @@ sub _setdir {
return File::Spec->catpath($volume, $directories, "");
}
# Returns
# - undef if the user canceled the open dialog
# - a FIJI::Settings reference in case of success
# - an error message in case of intolerable errors
sub _load_settings_prompt {
my $logger = get_logger("");
my ($self, $fr) = @_;
......@@ -513,7 +516,7 @@ sub _load_settings_prompt {
if (!defined($filename)) {
$logger->debug("User aborted open configuration action");
return;
return undef;
}
$current_dir = _setdir($filename);
......@@ -535,6 +538,7 @@ sub _load_settings_prompt {
-text => $msg,
-title => "Problems while loading settings file $filename!",);
$d->Show();
return $msg if !$tmp_settings;
}
${$self->{'settings_ini_name'}} = $filename;
return $tmp_settings;
......@@ -861,7 +865,7 @@ sub _cleanup {
# segfaults with this procedure, cf. https://rt.cpan.org/Public/Bug/Display.html?id=89621
$queue_to_worker->end();
$queue_to_gui->end();
$logger->remove_appender("queueAppender");
$logger->remove_appender("queueAppender", 0, 1);
$log_queue->end();
$worker_tid->join();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment