- if (exists)
- LYXERR(Debug::FILES,
- "Could not add path to QFileSystemWatcher: "
- << filename_);
- QTimer::singleShot(2000, this, SLOT(refresh()));
- } else if (exists && !exists_)
- Q_EMIT fileChanged();
- setExists(exists);
+ {
+ LYXERR(Debug::FILES,
+ "Could not add path to QFileSystemWatcher: " << filename_);
+ QTimer::singleShot(5000, this, SLOT(refresh()));
+ } else {
+ if (!exists_)
+ // The standard way to overwrite a file is to delete it and
+ // create a new file with the same name. Therefore if the file
+ // has just been deleted, it is smart to check not too long
+ // after whether it has been recreated.
+ QTimer::singleShot(existed ? 100 : 2000, this, SLOT(refresh()));
+ if (existed != exists_ && emit)
+ Q_EMIT fileChanged(exists_);
+ }