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