]> git.lyx.org Git - features.git/commitdiff
Fix bug #11737.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Thu, 13 Feb 2020 05:03:51 +0000 (00:03 -0500)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Thu, 13 Feb 2020 05:11:23 +0000 (00:11 -0500)
We need to use the FileName methods when moving or removing a file,
so that refresh() gets called.

(cherry picked from commit d93091389896cddcd83de83dfd4ee8a9b4e9c7f1)

src/support/FileName.cpp

index 5579446704d5e2c803f44c8c5aa4fdadf01aadb5..505b485d7f1f7fe2871e54ffe9ebc1b1c57dd45b 100644 (file)
@@ -259,6 +259,7 @@ bool FileName::renameTo(FileName const & name) const
 {
        LYXERR(Debug::FILES, "Renaming " << name << " as " << *this);
        bool success = QFile::rename(d->fi.absoluteFilePath(), name.d->fi.absoluteFilePath());
+       d->refresh();
        if (!success)
                LYXERR0("Could not rename file " << *this << " to " << name);
        return success;
@@ -272,12 +273,13 @@ bool FileName::moveTo(FileName const & name) const
        // there's a locking problem on Windows sometimes, so
        // we will keep trying for five seconds, in the hope
        // that clears.
+       name.refresh();
        if (name.exists()) {
-               bool removed = QFile::remove(name.d->fi.absoluteFilePath());
+               bool removed = name.removeFile();
                int tries = 1;
                while (!removed && tries < 6)   {
                        QThread::sleep(1);
-                       removed = QFile::remove(name.d->fi.absoluteFilePath());
+                       removed = name.removeFile();
                        tries++;
                }
        }
@@ -285,8 +287,7 @@ bool FileName::moveTo(FileName const & name) const
        QFile::remove(name.d->fi.absoluteFilePath());
 #endif
 
-       bool const success = QFile::rename(d->fi.absoluteFilePath(),
-               name.d->fi.absoluteFilePath());
+       bool const success = renameTo(name);
        if (!success)
                LYXERR0("Could not move file " << *this << " to " << name);
        return success;