diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index d25f1a8af..8da287110 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -10,7 +10,6 @@ use Slic3r::GUI::MainFrame; use Slic3r::GUI::Plater; use Slic3r::GUI::Plater::3D; use Slic3r::GUI::Plater::3DPreview; -use Slic3r::GUI::ProgressStatusBar; use Wx::Locale gettext => 'L'; diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index e2a25a7ab..092311e75 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -114,6 +114,7 @@ sub new { # Save the slic3r.ini. Usually the ini file is saved from "on idle" callback, # but in rare cases it may not have been called yet. wxTheApp->{app_config}->save; + $self->{statusbar}->ResetCancelCallback(); $self->{plater}->{print} = undef if($self->{plater}); Slic3r::GUI::_3DScene::remove_all_canvases(); Slic3r::GUI::deregister_on_request_update_callback(); diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index d3cca7e53..3bb9e59dc 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1534,7 +1534,7 @@ sub on_process_completed { # At this point of time the thread should be either finished or canceled, # so the following call just confirms, that the produced data were consumed. $self->{background_slicing_process}->stop; - $self->statusbar->SetCancelCallback(undef); + $self->statusbar->ResetCancelCallback(); $self->statusbar->StopBusy; $self->statusbar->SetStatusText(""); diff --git a/lib/Slic3r/GUI/ProgressStatusBar.pm b/lib/Slic3r/GUI/ProgressStatusBar.pm deleted file mode 100644 index edc0c0ce3..000000000 --- a/lib/Slic3r/GUI/ProgressStatusBar.pm +++ /dev/null @@ -1,18 +0,0 @@ -# Status bar at the bottom of the main screen. -# Now it just implements cancel cb on perl side, every other functionality is -# in C++ - -package Slic3r::GUI::ProgressStatusBar; -use strict; -use warnings; - -our $cancel_cb; - -sub SetCancelCallback { - my $self = shift; - my ($cb) = @_; - $cancel_cb = $cb; - $cb ? $self->ShowCancelButton : $self->HideCancelButton; -} - -1; diff --git a/xs/src/slic3r/GUI/ProgressStatusBar.cpp b/xs/src/slic3r/GUI/ProgressStatusBar.cpp index 3c2bdee6a..67fcd1dcc 100644 --- a/xs/src/slic3r/GUI/ProgressStatusBar.cpp +++ b/xs/src/slic3r/GUI/ProgressStatusBar.cpp @@ -54,6 +54,7 @@ ProgressStatusBar::ProgressStatusBar(wxWindow *parent, int id): cancelbutton_->Bind(wxEVT_BUTTON, [this](const wxCommandEvent&) { if(cancel_cb_) cancel_cb_(); + m_perl_cancel_callback.call(); cancelbutton_->Hide(); }); } diff --git a/xs/src/slic3r/GUI/ProgressStatusBar.hpp b/xs/src/slic3r/GUI/ProgressStatusBar.hpp index a117cacfb..91c180ba6 100644 --- a/xs/src/slic3r/GUI/ProgressStatusBar.hpp +++ b/xs/src/slic3r/GUI/ProgressStatusBar.hpp @@ -4,6 +4,8 @@ #include #include +#include "../../libslic3r/Utils.hpp" + class wxTimer; class wxGauge; class wxButton; @@ -50,6 +52,7 @@ public: void show_cancel_button(); void hide_cancel_button(); + PerlCallback m_perl_cancel_callback; private: bool busy_ = false; CancelFn cancel_cb_; diff --git a/xs/xsp/ProgressStatusBar.xsp b/xs/xsp/ProgressStatusBar.xsp index 6f41b2d2b..c089cfd7c 100644 --- a/xs/xsp/ProgressStatusBar.xsp +++ b/xs/xsp/ProgressStatusBar.xsp @@ -39,10 +39,9 @@ void SetStatusText(const char *txt) %code%{ THIS->set_status_text(txt); %}; - void ShowCancelButton() - %code%{ THIS->show_cancel_button(); %}; - - void HideCancelButton() - %code%{ THIS->hide_cancel_button(); %}; + void SetCancelCallback(SV* callback) + %code%{ THIS->m_perl_cancel_callback.register_callback(callback); THIS->show_cancel_button();%}; + void ResetCancelCallback() + %code%{ THIS->m_perl_cancel_callback.deregister_callback(); THIS->hide_cancel_button(); %}; }; \ No newline at end of file