diff --git a/plugins/scanfolder/scanthread.h b/plugins/scanfolder/scanthread.h --- a/plugins/scanfolder/scanthread.h +++ b/plugins/scanfolder/scanthread.h @@ -29,6 +29,7 @@ #include #include "scanfolder.h" +#include class QDir; @@ -88,8 +89,8 @@ private: QMutex mutex; QStringList folders; - bool stop_requested; - bool recursive; + std::atomic stop_requested; + std::atomic recursive; bt::PtrMap scan_folders; }; diff --git a/plugins/scanfolder/scanthread.cpp b/plugins/scanfolder/scanthread.cpp --- a/plugins/scanfolder/scanthread.cpp +++ b/plugins/scanfolder/scanthread.cpp @@ -156,6 +156,11 @@ void ScanThread::stop() { stop_requested = true; + + // XXX seems like deleting KDirWatch object(s) created in scan_folders + // in destructor of this QThread after is has been stopped, + // casuses memory corruption, so we delete them early + scan_folders.clear(); exit(); wait(); }