Restore old configuration if configuration wizrd is cancelled

This commit is contained in:
Henrik Brix Andersen 2012-07-01 00:10:48 +02:00
parent bb193c659c
commit 8f0aab3520

View file

@ -14,6 +14,7 @@ sub new {
Wx::Bitmap->new("$Slic3r::var/Slic3r_128px.png", wxBITMAP_TYPE_PNG)); Wx::Bitmap->new("$Slic3r::var/Slic3r_128px.png", wxBITMAP_TYPE_PNG));
# Start from sane defaults # Start from sane defaults
$self->{old} = Slic3r::Config->current;
Slic3r::Config->load_hash($Slic3r::Defaults, undef, 1); Slic3r::Config->load_hash($Slic3r::Defaults, undef, 1);
$self->add_page(Slic3r::GUI::ConfigWizard::Page::Welcome->new($self)); $self->add_page(Slic3r::GUI::ConfigWizard::Page::Welcome->new($self));
@ -43,13 +44,18 @@ sub add_page {
sub run { sub run {
my $self = shift; my $self = shift;
my $finished = Wx::Wizard::RunWizard($self, $self->{pages}[0]); my $modified;
if ($finished) { if (Wx::Wizard::RunWizard($self, $self->{pages}[0])) {
$_->apply for @{$self->{pages}}; $_->apply for @{$self->{pages}};
$modified = 1;
} else {
Slic3r::Config->load_hash($self->{old}, undef, 1);
$modified = 0;
} }
$self->Destroy; $self->Destroy;
return $finished; return $modified;
} }
package Slic3r::GUI::ConfigWizard::Option; package Slic3r::GUI::ConfigWizard::Option;