- if (exists)
- LYXERR(Debug::FILES,
- "Could not add path to QFileSystemWatcher: "
- << filename_);
- if (new_file || !exists)
- QTimer::singleShot(1000, this, SLOT(refreshTrue()));
- else
- QTimer::singleShot(1000, this, SLOT(refreshFalse()));
- // Better (qt>=5.4):
- /*QTimer::singleShot(1000, this, [=](){
- refresh(new_file || !exists);
- });*/
- } else if (exists && new_file)
- Q_EMIT fileChanged();
+ {
+ 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_);
+ }