From 292885e9d14da90bf4582e56caadb2b73d41a970 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Wed, 5 Feb 2025 13:29:00 +0100 Subject: [PATCH] Timer unique pointer --- src/slic3r/GUI/UserAccountCommunication.cpp | 9 ++------- src/slic3r/GUI/UserAccountCommunication.hpp | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/slic3r/GUI/UserAccountCommunication.cpp b/src/slic3r/GUI/UserAccountCommunication.cpp index ff386ff1a0..395986400d 100644 --- a/src/slic3r/GUI/UserAccountCommunication.cpp +++ b/src/slic3r/GUI/UserAccountCommunication.cpp @@ -177,8 +177,8 @@ UserAccountCommunication::UserAccountCommunication(wxEvtHandler* evt_handler, Ap : wxEvtHandler() , m_evt_handler(evt_handler) , m_app_config(app_config) - , m_polling_timer(new wxTimer(this)) - , m_token_timer(new wxTimer(this)) + , m_polling_timer(std::make_unique(this)) + , m_token_timer(std::make_unique(this)) { Bind(wxEVT_TIMER, &UserAccountCommunication::on_token_timer, this, m_token_timer->GetId()); Bind(wxEVT_TIMER, &UserAccountCommunication::on_polling_timer, this, m_polling_timer->GetId()); @@ -225,12 +225,7 @@ UserAccountCommunication::UserAccountCommunication(wxEvtHandler* evt_handler, Ap UserAccountCommunication::~UserAccountCommunication() { m_token_timer->Stop(); - delete m_token_timer; - m_token_timer = nullptr; - m_polling_timer->Stop(); - delete m_polling_timer; - m_polling_timer = nullptr; if (m_thread.joinable()) { // Stop the worker thread, if running. diff --git a/src/slic3r/GUI/UserAccountCommunication.hpp b/src/slic3r/GUI/UserAccountCommunication.hpp index 96904e28a5..645af09961 100644 --- a/src/slic3r/GUI/UserAccountCommunication.hpp +++ b/src/slic3r/GUI/UserAccountCommunication.hpp @@ -86,7 +86,7 @@ private: bool m_thread_stop { false }; bool m_thread_wakeup{ false }; bool m_window_is_active{ true }; - wxTimer* m_polling_timer; + std::unique_ptr m_polling_timer; std::string m_code_verifier; wxEvtHandler* m_evt_handler; @@ -95,7 +95,7 @@ private: std::string m_username; bool m_remember_session { true }; // if default is true, on every login Remember me will be checked. - wxTimer* m_token_timer; + std::unique_ptr m_token_timer; std::time_t m_next_token_refresh_at{0}; void wakeup_session_thread();