mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-03 04:50:36 +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();
|
do_login();
|
||||||
}
|
}
|
||||||
|
|
||||||
UserAccountCommunication::~UserAccountCommunication() {
|
UserAccountCommunication::~UserAccountCommunication()
|
||||||
|
{
|
||||||
if (m_thread.joinable()) {
|
if (m_thread.joinable()) {
|
||||||
// Stop the worker thread, if running.
|
// Stop the worker thread, if running.
|
||||||
{
|
{
|
||||||
@ -343,15 +344,15 @@ void UserAccountCommunication::init_session_thread()
|
|||||||
{
|
{
|
||||||
m_thread = std::thread([this]() {
|
m_thread = std::thread([this]() {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// Wait for 1 second
|
// Wait for 5 seconds or wakeup call
|
||||||
// Cancellable.
|
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lck(m_thread_stop_mutex);
|
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; });
|
m_thread_stop_condition.wait_for(lck, std::chrono::seconds(5), [this] { return m_thread_stop || m_thread_wakeup; });
|
||||||
}
|
}
|
||||||
if (m_thread_stop)
|
if (m_thread_stop)
|
||||||
// Stop the worker thread.
|
// Stop the worker thread.
|
||||||
break;
|
break;
|
||||||
|
m_thread_wakeup = false;
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_session_mutex);
|
std::lock_guard<std::mutex> lock(m_session_mutex);
|
||||||
m_session->process_action_queue();
|
m_session->process_action_queue();
|
||||||
@ -362,13 +363,13 @@ void UserAccountCommunication::init_session_thread()
|
|||||||
|
|
||||||
void UserAccountCommunication::wakeup_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();
|
m_thread_stop_condition.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::string CodeChalengeGenerator::generate_chalenge(const std::string& verifier)
|
std::string CodeChalengeGenerator::generate_chalenge(const std::string& verifier)
|
||||||
{
|
{
|
||||||
std::string code_challenge;
|
std::string code_challenge;
|
||||||
|
@ -70,6 +70,7 @@ private:
|
|||||||
std::mutex m_thread_stop_mutex;
|
std::mutex m_thread_stop_mutex;
|
||||||
std::condition_variable m_thread_stop_condition;
|
std::condition_variable m_thread_stop_condition;
|
||||||
bool m_thread_stop { false };
|
bool m_thread_stop { false };
|
||||||
|
bool m_thread_wakeup{ false };
|
||||||
std::string m_code_verifier;
|
std::string m_code_verifier;
|
||||||
wxEvtHandler* m_evt_handler;
|
wxEvtHandler* m_evt_handler;
|
||||||
AppConfig* m_app_config;
|
AppConfig* m_app_config;
|
||||||
|
@ -30,7 +30,6 @@ wxDEFINE_EVENT(EVT_UA_RESET, UserAccountFailEvent);
|
|||||||
wxDEFINE_EVENT(EVT_UA_FAIL, UserAccountFailEvent);
|
wxDEFINE_EVENT(EVT_UA_FAIL, UserAccountFailEvent);
|
||||||
#endif // 0
|
#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)
|
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;
|
std::string url = m_url;
|
||||||
@ -77,12 +76,13 @@ void UserAccountSession::process_action_queue()
|
|||||||
if (!m_proccessing_enabled)
|
if (!m_proccessing_enabled)
|
||||||
return;
|
return;
|
||||||
if (m_priority_action_queue.empty() && m_action_queue.empty()) {
|
if (m_priority_action_queue.empty() && m_action_queue.empty()) {
|
||||||
// update printers on every periodic wakeup call
|
// update printers periodically
|
||||||
if (m_polling_enabled)
|
if (m_polling_enabled) {
|
||||||
enqueue_action(UserAccountActionID::USER_ACCOUNT_ACTION_CONNECT_PRINTERS, nullptr, nullptr, {});
|
enqueue_action(UserAccountActionID::USER_ACCOUNT_ACTION_CONNECT_PRINTERS, nullptr, nullptr, {});
|
||||||
else
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// priority queue works even when tokens are empty or broken
|
// priority queue works even when tokens are empty or broken
|
||||||
while (!m_priority_action_queue.empty()) {
|
while (!m_priority_action_queue.empty()) {
|
||||||
m_actions[m_priority_action_queue.front().action_id]->perform(p_evt_handler, m_access_token, m_priority_action_queue.front().success_callback, m_priority_action_queue.front().fail_callback, m_priority_action_queue.front().input);
|
m_actions[m_priority_action_queue.front().action_id]->perform(p_evt_handler, m_access_token, m_priority_action_queue.front().success_callback, m_priority_action_queue.front().fail_callback, m_priority_action_queue.front().input);
|
||||||
|
@ -536,8 +536,10 @@ void ConnectWebViewPanel::on_script_message(wxWebViewEvent& evt)
|
|||||||
|
|
||||||
void ConnectWebViewPanel::on_request_update_selected_printer_action()
|
void ConnectWebViewPanel::on_request_update_selected_printer_action()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
assert(!m_message_data.empty());
|
assert(!m_message_data.empty());
|
||||||
wxGetApp().handle_connect_request_printer_pick(m_message_data);
|
wxGetApp().handle_connect_request_printer_pick(m_message_data);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user