diff --git a/src/librssguard/miscellaneous/autosaver.cpp b/src/librssguard/miscellaneous/autosaver.cpp index 78e1a8744..c43d09d5e 100644 --- a/src/librssguard/miscellaneous/autosaver.cpp +++ b/src/librssguard/miscellaneous/autosaver.cpp @@ -9,8 +9,11 @@ #include "definitions/definitions.h" AutoSaver::AutoSaver(QObject* parent, const QString& saving_slot, int max_wait_secs, int periodic_save_secs) - : QObject(parent), m_savingSlot(saving_slot), m_maxWaitSecs(max_wait_secs), m_periodicSaveSecs(periodic_save_secs) { + : QObject(parent), m_savingSlot(saving_slot), m_maxWaitMsecs(max_wait_secs * 1000), + m_periodicSaveMsecs(periodic_save_secs * 1000) { Q_ASSERT(parent); + + connect(&m_timer, &QTimer::timeout, this, &AutoSaver::saveIfNeccessary); } AutoSaver::~AutoSaver() { @@ -28,20 +31,11 @@ void AutoSaver::changeOccurred() { m_firstChange.start(); } - if (m_firstChange.elapsed() > m_maxWaitSecs) { + if (m_firstChange.elapsed() > m_maxWaitMsecs) { saveIfNeccessary(); } else { - m_timer.start(m_periodicSaveSecs, this); - } -} - -void AutoSaver::timerEvent(QTimerEvent* event) { - if (event->timerId() == m_timer.timerId()) { - saveIfNeccessary(); - } - else { - QObject::timerEvent(event); + m_timer.start(m_periodicSaveMsecs); } } diff --git a/src/librssguard/miscellaneous/autosaver.h b/src/librssguard/miscellaneous/autosaver.h index 1e0bf8fb2..4345b888e 100644 --- a/src/librssguard/miscellaneous/autosaver.h +++ b/src/librssguard/miscellaneous/autosaver.h @@ -7,8 +7,8 @@ #include "definitions/definitions.h" -#include #include +#include #define AUTOSAVE_IN (1000 * 3) // In seconds. #define MAX_WAIT (1000 * 15) // In seconds. @@ -23,19 +23,15 @@ class AutoSaver : public QObject { int periodic_save_secs = AUTOSAVE_IN); virtual ~AutoSaver(); - void saveIfNeccessary(); - public slots: void changeOccurred(); - - protected: - void timerEvent(QTimerEvent* event); + void saveIfNeccessary(); private: - QBasicTimer m_timer; + QTimer m_timer; QElapsedTimer m_firstChange; - int m_maxWaitSecs; - int m_periodicSaveSecs; + int m_maxWaitMsecs; + int m_periodicSaveMsecs; QString m_savingSlot; }; diff --git a/src/librssguard/network-web/cookiejar.cpp b/src/librssguard/network-web/cookiejar.cpp index ff8299d10..11a58fad0 100644 --- a/src/librssguard/network-web/cookiejar.cpp +++ b/src/librssguard/network-web/cookiejar.cpp @@ -19,7 +19,7 @@ #endif CookieJar::CookieJar(QObject* parent) - : QNetworkCookieJar(parent), m_saver(AutoSaver(this, QSL("saveCookies"), 25, 45)) { + : QNetworkCookieJar(parent), m_saver(AutoSaver(this, QSL("saveCookies"), 30, 45)) { #if defined(USE_WEBENGINE) auto* web_factory = qobject_cast(parent);