mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-31 14:11:59 +08:00
Fix of waking up session thread
Polling every 5 seconds Do not switch printers on Connect webview click
This commit is contained in:
parent
93d47dd121
commit
5f48e61992
@ -154,7 +154,8 @@ UserAccountCommunication::UserAccountCommunication(wxEvtHandler* evt_handler, Ap
|
||||
do_login();
|
||||
}
|
||||
|
||||
UserAccountCommunication::~UserAccountCommunication() {
|
||||
UserAccountCommunication::~UserAccountCommunication()
|
||||
{
|
||||
if (m_thread.joinable()) {
|
||||
// Stop the worker thread, if running.
|
||||
{
|
||||
@ -343,15 +344,15 @@ void UserAccountCommunication::init_session_thread()
|
||||
{
|
||||
m_thread = std::thread([this]() {
|
||||
for (;;) {
|
||||
// Wait for 1 second
|
||||
// Cancellable.
|
||||
// Wait for 5 seconds or wakeup call
|
||||
{
|
||||
std::unique_lock<std::mutex> lck(m_thread_stop_mutex);
|
||||
m_thread_stop_condition.wait_for(lck, std::chrono::seconds(1), [this] { return m_thread_stop; });
|
||||
std::unique_lock<std::mutex> lck(m_thread_stop_mutex);
|
||||
m_thread_stop_condition.wait_for(lck, std::chrono::seconds(5), [this] { return m_thread_stop || m_thread_wakeup; });
|
||||
}
|
||||
if (m_thread_stop)
|
||||
// Stop the worker thread.
|
||||
break;
|
||||
m_thread_wakeup = false;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_session_mutex);
|
||||
m_session->process_action_queue();
|
||||
@ -362,13 +363,13 @@ void UserAccountCommunication::init_session_thread()
|
||||
|
||||
void UserAccountCommunication::wakeup_session_thread()
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lck(m_thread_stop_mutex);
|
||||
m_thread_wakeup = true;
|
||||
}
|
||||
m_thread_stop_condition.notify_all();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
std::string CodeChalengeGenerator::generate_chalenge(const std::string& verifier)
|
||||
{
|
||||
std::string code_challenge;
|
||||
|
@ -70,6 +70,7 @@ private:
|
||||
std::mutex m_thread_stop_mutex;
|
||||
std::condition_variable m_thread_stop_condition;
|
||||
bool m_thread_stop { false };
|
||||
bool m_thread_wakeup{ false };
|
||||
std::string m_code_verifier;
|
||||
wxEvtHandler* m_evt_handler;
|
||||
AppConfig* m_app_config;
|
||||
|
@ -30,7 +30,6 @@ wxDEFINE_EVENT(EVT_UA_RESET, UserAccountFailEvent);
|
||||
wxDEFINE_EVENT(EVT_UA_FAIL, UserAccountFailEvent);
|
||||
#endif // 0
|
||||
|
||||
|
||||
void UserActionPost::perform(/*UNUSED*/ wxEvtHandler* evt_handler, /*UNUSED*/ const std::string& access_token, UserActionSuccessFn success_callback, UserActionFailFn fail_callback, const std::string& input)
|
||||
{
|
||||
std::string url = m_url;
|
||||
@ -77,11 +76,12 @@ void UserAccountSession::process_action_queue()
|
||||
if (!m_proccessing_enabled)
|
||||
return;
|
||||
if (m_priority_action_queue.empty() && m_action_queue.empty()) {
|
||||
// update printers on every periodic wakeup call
|
||||
if (m_polling_enabled)
|
||||
// update printers periodically
|
||||
if (m_polling_enabled) {
|
||||
enqueue_action(UserAccountActionID::USER_ACCOUNT_ACTION_CONNECT_PRINTERS, nullptr, nullptr, {});
|
||||
else
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// priority queue works even when tokens are empty or broken
|
||||
while (!m_priority_action_queue.empty()) {
|
||||
|
@ -536,8 +536,10 @@ void ConnectWebViewPanel::on_script_message(wxWebViewEvent& evt)
|
||||
|
||||
void ConnectWebViewPanel::on_request_update_selected_printer_action()
|
||||
{
|
||||
/*
|
||||
assert(!m_message_data.empty());
|
||||
wxGetApp().handle_connect_request_printer_pick(m_message_data);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user