From ddb494558628b708da5cf448f826b23bf624d550 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Mon, 2 Jul 2018 11:22:47 +0200 Subject: [PATCH] Fix crash on Linux when arranging --- lib/Slic3r/GUI/MainFrame.pm | 2 +- xs/src/slic3r/AppController.cpp | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index 2fdd7e11d..77d7956c9 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -62,7 +62,7 @@ sub new { eval { Wx::ToolTip::SetAutoPop(32767) }; # initialize status bar - $self->{statusbar} = Slic3r::GUI::ProgressStatusBar->new($self, -1); + $self->{statusbar} = Slic3r::GUI::ProgressStatusBar->new($self, Wx::NewId); $self->{statusbar}->SetStatusText(L("Version ").$Slic3r::VERSION.L(" - Remember to check for updates at http://github.com/prusa3d/slic3r/releases")); $self->SetStatusBar($self->{statusbar}); diff --git a/xs/src/slic3r/AppController.cpp b/xs/src/slic3r/AppController.cpp index 06e2cd093..77296c74b 100644 --- a/xs/src/slic3r/AppController.cpp +++ b/xs/src/slic3r/AppController.cpp @@ -314,20 +314,26 @@ void AppController::arrange_model() for(auto obj : model_->objects) count += obj->instances.size(); auto pind = progress_indicator(); - auto pmax = pind->max(); - // Set the range of the progress to the object count - pind->max(count); + float pmax = 1.0; + + if(pind) { + pmax = pind->max(); + + // Set the range of the progress to the object count + pind->max(count); + + } auto dist = print_ctl()->config().min_object_distance(); BoundingBoxf bb(print_ctl()->config().bed_shape.values); - pind->update(0, "Arranging objects..."); + if(pind) pind->update(0, "Arranging objects..."); try { model_->arrange_objects(dist, &bb, [pind, count](unsigned rem){ - pind->update(count - rem, "Arranging objects..."); + if(pind) pind->update(count - rem, "Arranging objects..."); }); } catch(std::exception& e) { std::cerr << e.what() << std::endl; @@ -338,8 +344,10 @@ void AppController::arrange_model() } // Restore previous max value - pind->max(pmax); - pind->update(0, "Arranging done."); + if(pind) { + pind->max(pmax); + pind->update(0, "Arranging done."); + } }); while( ftr.wait_for(std::chrono::milliseconds(10))