Fix memory corruption in ScanFolder plugin
Summary:
Reasoning behind this patch is kinda dubious because I don't fully understand what happens, but it shouldn't make the matters worse either
Seems like deletion of KDirWatch objects from scan_folder in ~ScanThread(), after said QThread has been stopped, causes memory corruption.
Preemptively deleting scan_folder contents before we stop the thread resolves this.
also mark booleans shared across main thread and KDirWatch callbacks as atomic
Test Plan:
Without this patch unloading ScanFolder plugin sometimes crashes ktorrent, including unloading on exit
Doesn't happen anymore with this patch
Reviewers: stikonas
Reviewed By: stikonas
Differential Revision: https://phabricator.kde.org/D15265