Timer unique pointer

This commit is contained in:
David Kocik 2025-02-05 13:29:00 +01:00 committed by Lukas Matena
parent f1261f8e01
commit 292885e9d1
2 changed files with 4 additions and 9 deletions

View File

@ -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<wxTimer>(this))
, m_token_timer(std::make_unique<wxTimer>(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.

View File

@ -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<wxTimer> 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<wxTimer> m_token_timer;
std::time_t m_next_token_refresh_at{0};
void wakeup_session_thread();