Fix of gcode viewer crash.

Bind Account events only if editor.
This commit is contained in:
David Kocik 2024-04-19 16:34:00 +02:00
parent 63e25828ae
commit 72fa3da675
2 changed files with 99 additions and 99 deletions

View File

@ -3801,10 +3801,10 @@ void GUI_App::handle_connect_request_printer_pick(const std::string& msg)
// return to plater
this->mainframe->select_tab(size_t(0));
//if (!select_printer_from_connect(msg)) {
// // If printer was not selected, do not select filament.
// return;
//}
if (!select_printer_from_connect(msg)) {
// If printer was not selected, do not select filament.
return;
}
// TODO: Selecting SLA material
if (Preset::printer_technology(preset_bundle->printers.get_selected_preset().config) != ptFFF) {
return;

View File

@ -847,33 +847,32 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
wxGetApp().mainframe->Raise();
this->q->load_files(input_files);
});
this->q->Bind(EVT_INSTANCE_GO_TO_FRONT, [this](InstanceGoToFrontEvent&) {
bring_instance_forward();
});
// Downloader and USerAccount Events doesnt need to be binded in viewer.
// Not binding Account events prevents it from loging in.
if (wxGetApp().is_editor()) {
this->q->Bind(EVT_START_DOWNLOAD_OTHER_INSTANCE, [](StartDownloadOtherInstanceEvent& evt) {
BOOST_LOG_TRIVIAL(trace) << "Received url from other instance event.";
wxGetApp().mainframe->Raise();
for (size_t i = 0; i < evt.data.size(); ++i) {
wxGetApp().start_download(evt.data[i]);
}
});
this->q->Bind(EVT_LOGIN_OTHER_INSTANCE, [this](LoginOtherInstanceEvent& evt) {
BOOST_LOG_TRIVIAL(trace) << "Received login from other instance event.";
user_account->on_login_code_recieved(evt.data);
});
this->q->Bind(EVT_INSTANCE_GO_TO_FRONT, [this](InstanceGoToFrontEvent &) {
bring_instance_forward();
});
this->q->Bind(EVT_OPEN_PRUSAAUTH, [](OpenPrusaAuthEvent& evt) {
BOOST_LOG_TRIVIAL(info) << "open browser: " << evt.data;
// first register url to be sure to get the code back
//auto downloader_worker = new DownloaderUtils::Worker(nullptr);
DownloaderUtils::Worker::perform_register(wxGetApp().app_config->get("url_downloader_dest"));
#ifdef __linux__
#ifdef __linux__
if (DownloaderUtils::Worker::perform_registration_linux)
DesktopIntegrationDialog::perform_downloader_desktop_integration();
#endif // __linux__
#endif // __linux__
// than open url
wxGetApp().open_login_browser_with_dialog(evt.data);
});
@ -961,6 +960,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
wxGetApp().update_login_dialog();
#endif // 0
});
}
wxGetApp().other_instance_message_handler()->init(this->q);