Fix crash on Linux when arranging

This commit is contained in:
tamasmeszaros 2018-07-02 11:22:47 +02:00
parent 86726b15b4
commit ddb4945586
2 changed files with 16 additions and 8 deletions

View File

@ -62,7 +62,7 @@ sub new {
eval { Wx::ToolTip::SetAutoPop(32767) }; eval { Wx::ToolTip::SetAutoPop(32767) };
# initialize status bar # 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->{statusbar}->SetStatusText(L("Version ").$Slic3r::VERSION.L(" - Remember to check for updates at http://github.com/prusa3d/slic3r/releases"));
$self->SetStatusBar($self->{statusbar}); $self->SetStatusBar($self->{statusbar});

View File

@ -314,20 +314,26 @@ void AppController::arrange_model()
for(auto obj : model_->objects) count += obj->instances.size(); for(auto obj : model_->objects) count += obj->instances.size();
auto pind = progress_indicator(); auto pind = progress_indicator();
auto pmax = pind->max();
float pmax = 1.0;
if(pind) {
pmax = pind->max();
// Set the range of the progress to the object count // Set the range of the progress to the object count
pind->max(count); pind->max(count);
}
auto dist = print_ctl()->config().min_object_distance(); auto dist = print_ctl()->config().min_object_distance();
BoundingBoxf bb(print_ctl()->config().bed_shape.values); BoundingBoxf bb(print_ctl()->config().bed_shape.values);
pind->update(0, "Arranging objects..."); if(pind) pind->update(0, "Arranging objects...");
try { try {
model_->arrange_objects(dist, &bb, [pind, count](unsigned rem){ 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) { } catch(std::exception& e) {
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
@ -338,8 +344,10 @@ void AppController::arrange_model()
} }
// Restore previous max value // Restore previous max value
if(pind) {
pind->max(pmax); pind->max(pmax);
pind->update(0, "Arranging done."); pind->update(0, "Arranging done.");
}
}); });
while( ftr.wait_for(std::chrono::milliseconds(10)) while( ftr.wait_for(std::chrono::milliseconds(10))