QFileSystemWatcher directoryChanged signal emitted twice when file is deleted

678 Views Asked by At

I've some code to monitor a folder containing .xml files. I used a QFileSystemWatcher and connected the signal directoryChanged(const QString &path) to a slot where I implemented a small routine.

When I delete a file which is located in this monitored folder, the signal is emitted twice, and I cannot figure out why.

I've read other posts on stackoverflow, but all those I found mentioned the same issue when editing a file and not deleting it. Since I'm deleting files and not editing them, the file is not first removed and then written again by the editor.

Anyone knows why this happens and how to fix it ? I can add some code if needed.

Thanks !

EDIT : After reading this question, I added Qt::UniqueConnection to my connect to make sure it was only done once (even though I'm sure the connection is made only once with an auto connection since it's called in the constructor of the mainwindow), but the result is the same.

0

There are 0 best solutions below