0

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.

nmud
  • 175
  • 14
  • Are you sure you only connected the signal 1 time. I mean if you connect more than 1 time your signal / slot will connected will be activated more than 1 time. – drescherjm Jul 07 '17 at 16:29
  • My wild guess is that some other program is changing the folder when a file is deleted. – azalea Jul 07 '17 at 19:49
  • @drescherjm : only one time yes, in the mainwindow constructor – nmud Jul 09 '17 at 12:03
  • @azalea : some OS related program ? If it's the case do you have any idea what to look for to prevent this ? – nmud Jul 09 '17 at 12:03

0 Answers0