| 1 | // For license of this file, see <project-root-folder>/LICENSE.md.cxx . . $ `<file>/src/librssguard/miscellaneous/autosaver.cpp`/ |
| 2 | |
| 3 | #include "miscellaneous/autosaver.h"cxx . . $ `<file>/src/librssguard/miscellaneous/autosaver.h`/ |
| 4 | |
| 5 | #include "definitions/definitions.h"cxx . . $ `<file>/src/librssguard/definitions/definitions.h`/ |
| 6 | |
| 7 | #include <QCoreApplication> |
| 8 | #include <QDir> |
| 9 | #include <QMetaObject> |
| 10 | |
| 11 | AutoSavercxx . . $ AutoSaver#::AutoSavercxx . . $ AutoSaver#AutoSaver(dafbaae74a3bad82).(QObjectcxx . . $ QObject#* parent, const QStringcxx . . $ QString#& saving_slot, int max_wait_secs, int periodic_save_secs) |
| 12 | : QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(parent), m_maxWaitMsecscxx . . $ AutoSaver#m_maxWaitMsecs.(max_wait_secs * 1000), m_periodicSaveMsecscxx . . $ AutoSaver#m_periodicSaveMsecs.(periodic_save_secs * 1000), |
| 13 | m_savingSlotcxx . . $ AutoSaver#m_savingSlot.(saving_slot) { |
| 14 | Q_ASSERTcxx . . $ `<external>/4968608585795071363/qassert.h:29:13`!(parent); |
| 15 | |
| 16 | connectcxx . . $ QObject#connect(dad3a9587f3dce3c).(&m_timercxx . . $ AutoSaver#m_timer., &QTimercxx . . $ QTimer#::timeoutcxx . . $ QTimer#timeout(32604d697c0ceadc)., this, &AutoSavercxx . . $ AutoSaver#::saveIfNeccessarycxx . . $ AutoSaver#saveIfNeccessary(49f6e7a06ebc5aa8).); |
| 17 | } |
| 18 | |
| 19 | AutoSavercxx . . $ AutoSaver#::~cxx . . $ AutoSaver#`~AutoSaver`(ced63f7c635d850d).AutoSavercxx . . $ AutoSaver#() { |
| 20 | if (m_timercxx . . $ AutoSaver#m_timer..isActivecxx . . $ QTimer#isActive(50ce9a9e25b4a850).()) { |
| 21 | qWarningNNcxx . . $ `src/librssguard/definitions/definitions.h:417:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_COREcxx . . $ `src/librssguard/definitions/definitions.h:178:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "AutoSaver still active when destroyed, changes not saved."; |
| 22 | |
| 23 | if (parentcxx . . $ QObject#parent(2dbb680a34285c44).() != nullptr && parentcxx . . $ QObject#parent(2dbb680a34285c44).()->metaObjectcxx . . $ QObject#metaObject(216d4151dd9c9333).() != nullptr) { |
| 24 | qDebugNNcxx . . $ `src/librssguard/definitions/definitions.h:413:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_COREcxx . . $ `src/librssguard/definitions/definitions.h:178:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Should call saveIfNeccessary."; |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | void AutoSavercxx . . $ AutoSaver#::changeOccurredcxx . . $ AutoSaver#changeOccurred(49f6e7a06ebc5aa8).() { |
| 30 | if (!m_firstChangecxx . . $ AutoSaver#m_firstChange..isValidcxx . . $ QElapsedTimer#isValid(3482b152b9333168).()) { |
| 31 | m_firstChangecxx . . $ AutoSaver#m_firstChange..startcxx . . $ QElapsedTimer#start(ced63f7c635d850d).(); |
| 32 | } |
| 33 | |
| 34 | if (m_firstChangecxx . . $ AutoSaver#m_firstChange..elapsedcxx . . $ QElapsedTimer#elapsed(6b0412d51016192f).() > m_maxWaitMsecscxx . . $ AutoSaver#m_maxWaitMsecs.) { |
| 35 | saveIfNeccessarycxx . . $ AutoSaver#saveIfNeccessary(49f6e7a06ebc5aa8).(); |
| 36 | } |
| 37 | else { |
| 38 | QMetaObjectcxx . . $ QMetaObject#::invokeMethodcxx . . $ QMetaObject#invokeMethod(8b0e30ae6de741c4).(&m_timercxx . . $ AutoSaver#m_timer., "start", Qtcxx . . $ Qt/::ConnectionTypecxx . . $ Qt/ConnectionType#::AutoConnectioncxx . . $ Qt/AutoConnection., Q_ARGcxx . . $ `<external>/4766508314589701758/qobjectdefs.h:63:9`!(int, m_periodicSaveMsecs)); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | void AutoSavercxx . . $ AutoSaver#::saveIfNeccessarycxx . . $ AutoSaver#saveIfNeccessary(49f6e7a06ebc5aa8).() { |
| 43 | if (m_timercxx . . $ AutoSaver#m_timer..isActivecxx . . $ QTimer#isActive(50ce9a9e25b4a850).()) { |
| 44 | QMetaObjectcxx . . $ QMetaObject#::invokeMethodcxx . . $ QMetaObject#invokeMethod(8b0e30ae6de741c4).(&m_timercxx . . $ AutoSaver#m_timer., "stop", Qtcxx . . $ Qt/::ConnectionTypecxx . . $ Qt/ConnectionType#::AutoConnectioncxx . . $ Qt/AutoConnection.); |
| 45 | m_firstChangecxx . . $ AutoSaver#m_firstChange..invalidatecxx . . $ QElapsedTimer#invalidate(ced63f7c635d850d).(); |
| 46 | |
| 47 | if (!QMetaObjectcxx . . $ QMetaObject#::invokeMethodcxx . . $ QMetaObject#invokeMethod(8b0e30ae6de741c4).(parentcxx . . $ QObject#parent(2dbb680a34285c44).(), qPrintablecxx . . $ `<external>/13954984326995544643/qstring.h:1647:11`!(m_savingSlot), Qtcxx . . $ Qt/::ConnectionTypecxx . . $ Qt/ConnectionType#::DirectConnectioncxx . . $ Qt/DirectConnection.)) { |
| 48 | qCriticalNNcxx . . $ `src/librssguard/definitions/definitions.h:421:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_COREcxx . . $ `src/librssguard/definitions/definitions.h:178:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "AutoSaver error invoking saving slot on parent."; |
| 49 | } |
| 50 | else { |
| 51 | qDebugNNcxx . . $ `src/librssguard/definitions/definitions.h:413:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_COREcxx . . $ `src/librssguard/definitions/definitions.h:178:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Saved data with auto-saver for" |
| 52 | <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACEcxx . . $ `src/librssguard/definitions/definitions.h:432:9`!(parent()->metaObject()->className()) "and method" <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACE_DOTcxx . . $ `src/librssguard/definitions/definitions.h:430:9`!(m_savingSlot); |
| 53 | } |
| 54 | } |
| 55 | } |