From 8f0aab3520dbdc44f03e0a581d9179fcf77208d0 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Sun, 1 Jul 2012 00:10:48 +0200 Subject: [PATCH] Restore old configuration if configuration wizrd is cancelled --- lib/Slic3r/GUI/ConfigWizard.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm index d5354736a..aa92f7a6e 100644 --- a/lib/Slic3r/GUI/ConfigWizard.pm +++ b/lib/Slic3r/GUI/ConfigWizard.pm @@ -14,6 +14,7 @@ sub new { Wx::Bitmap->new("$Slic3r::var/Slic3r_128px.png", wxBITMAP_TYPE_PNG)); # Start from sane defaults + $self->{old} = Slic3r::Config->current; Slic3r::Config->load_hash($Slic3r::Defaults, undef, 1); $self->add_page(Slic3r::GUI::ConfigWizard::Page::Welcome->new($self)); @@ -43,13 +44,18 @@ sub add_page { sub run { my $self = shift; - my $finished = Wx::Wizard::RunWizard($self, $self->{pages}[0]); - if ($finished) { + my $modified; + if (Wx::Wizard::RunWizard($self, $self->{pages}[0])) { $_->apply for @{$self->{pages}}; + $modified = 1; + } else { + Slic3r::Config->load_hash($self->{old}, undef, 1); + $modified = 0; } + $self->Destroy; - return $finished; + return $modified; } package Slic3r::GUI::ConfigWizard::Option;