mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 04:26:05 +08:00
Do not poll printers when window is not active.
This commit is contained in:
parent
835e6d4805
commit
3e1baf0a61
@ -272,8 +272,8 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
||||
//FIXME it seems this method is not called on application start-up, at least not on Windows. Why?
|
||||
// The same applies to wxEVT_CREATE, it is not being called on startup on Windows.
|
||||
Bind(wxEVT_ACTIVATE, [this](wxActivateEvent& event) {
|
||||
if (m_plater != nullptr && event.GetActive())
|
||||
m_plater->on_activate();
|
||||
if (m_plater != nullptr)
|
||||
m_plater->on_activate(event.GetActive());
|
||||
event.Skip();
|
||||
});
|
||||
|
||||
|
@ -6300,9 +6300,12 @@ void Plater::force_print_bed_update()
|
||||
p->config->opt_string("printer_model", true) = "\x01\x00\x01";
|
||||
}
|
||||
|
||||
void Plater::on_activate()
|
||||
void Plater::on_activate(bool active)
|
||||
{
|
||||
this->p->show_delayed_error_message();
|
||||
this->p->user_account->on_activate_window(active);
|
||||
if (active) {
|
||||
this->p->show_delayed_error_message();
|
||||
}
|
||||
}
|
||||
|
||||
// Get vector of extruder colors considering filament color, if extruder color is undefined.
|
||||
|
@ -253,7 +253,7 @@ public:
|
||||
void force_filament_cb_update();
|
||||
void force_print_bed_update();
|
||||
// On activating the parent window.
|
||||
void on_activate();
|
||||
void on_activate(bool active);
|
||||
std::vector<std::string> get_extruder_colors_from_plater_config(const GCodeProcessorResult* const result = nullptr) const;
|
||||
std::vector<std::string> get_colors_for_color_print(const GCodeProcessorResult* const result = nullptr) const;
|
||||
|
||||
|
@ -58,6 +58,8 @@ public:
|
||||
bool on_connect_printers_success(const std::string& data, AppConfig* app_config, bool& out_printers_changed);
|
||||
bool on_connect_uiid_map_success(const std::string& data, AppConfig* app_config, bool& out_printers_changed);
|
||||
|
||||
void on_activate_window(bool active) { m_communication->on_activate_window(active); }
|
||||
|
||||
std::string get_username() const { return m_username; }
|
||||
std::string get_access_token();
|
||||
std::string get_shared_session_key();
|
||||
|
@ -360,6 +360,10 @@ void UserAccountCommunication::init_session_thread()
|
||||
if (m_thread_stop)
|
||||
// Stop the worker thread.
|
||||
break;
|
||||
// Do not process_action_queue if window is not active and thread was not forced to wakeup
|
||||
if (!m_window_is_active && !m_thread_wakeup) {
|
||||
continue;
|
||||
}
|
||||
m_thread_wakeup = false;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_session_mutex);
|
||||
@ -369,6 +373,12 @@ void UserAccountCommunication::init_session_thread()
|
||||
});
|
||||
}
|
||||
|
||||
void UserAccountCommunication::on_activate_window(bool active)
|
||||
{
|
||||
std::lock_guard<std::mutex> lck(m_thread_stop_mutex);
|
||||
m_window_is_active = active;
|
||||
}
|
||||
|
||||
void UserAccountCommunication::wakeup_session_thread()
|
||||
{
|
||||
{
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
// Exchanges code for tokens and shared_session_key
|
||||
void on_login_code_recieved(const std::string& url_message);
|
||||
|
||||
void on_activate_window(bool active);
|
||||
|
||||
void set_username(const std::string& username);
|
||||
void set_remember_session(bool b);
|
||||
@ -71,6 +72,7 @@ private:
|
||||
std::condition_variable m_thread_stop_condition;
|
||||
bool m_thread_stop { false };
|
||||
bool m_thread_wakeup{ false };
|
||||
bool m_window_is_active{ true };
|
||||
std::string m_code_verifier;
|
||||
wxEvtHandler* m_evt_handler;
|
||||
AppConfig* m_app_config;
|
||||
|
Loading…
x
Reference in New Issue
Block a user