diff --git a/src/blackmisc/threadedreader.cpp b/src/blackmisc/threadedreader.cpp index 3589d675e..9524ff021 100644 --- a/src/blackmisc/threadedreader.cpp +++ b/src/blackmisc/threadedreader.cpp @@ -34,6 +34,12 @@ namespace BlackMisc QMetaObject::invokeMethod(m_updateTimer, "stop"); } + void CThreadedReader::gracefulShutdown() + { + this->m_shutdown = true; + this->requestStop(); + } + CThreadedReader::~CThreadedReader() { cleanup(); diff --git a/src/blackmisc/threadedreader.h b/src/blackmisc/threadedreader.h index 7b70882b8..f7cb2d1ea 100644 --- a/src/blackmisc/threadedreader.h +++ b/src/blackmisc/threadedreader.h @@ -54,11 +54,16 @@ namespace BlackMisc //! \threadsafe int interval() const; + //! Graceful shutdown + void gracefulShutdown(); + protected: //! Constructor CThreadedReader(QObject *owner, const QString &name); - QTimer *m_updateTimer = nullptr; //!< update timer + QTimer *m_updateTimer = nullptr; //!< update timer + bool m_shutdown = false; //!< in shutdown process + mutable QReadWriteLock m_lock {QReadWriteLock::Recursive}; //!< lock //! Make sure everthing runs correctly in own thread