]> git.lyx.org Git - features.git/commitdiff
Fix bug #10091.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Sun, 7 Jul 2019 17:13:52 +0000 (13:13 -0400)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Sun, 7 Jul 2019 17:15:27 +0000 (13:15 -0400)
See the discussion. The decision was just to keep re-trying for a
bit, since the lock preventing us from removing the old file seems
to clear after a bit.

(cherry picked from commit d96a9aa37feaff170095f34a682ab0b2788f3671)

src/support/FileName.cpp
status.23x

index 9d00de3d443f862f9c3eec69d78c1df79002b647..e30609fe923c7b8d1b6070e1b42fa0d461845c6c 100644 (file)
 #include <QTemporaryFile>
 #include <QTime>
 
+#ifdef _WIN32
+#include <QThread>
+#endif
+
 #include <boost/crc.hpp>
 
 #include <algorithm>
@@ -256,9 +260,22 @@ bool FileName::renameTo(FileName const & name) const
 bool FileName::moveTo(FileName const & name) const
 {
        LYXERR(Debug::FILES, "Moving " << *this << " to " << name);
+#ifdef _WIN32
+       // there's a locking problem on Windows sometimes, so
+       // we will keep trying for five seconds, in the hope
+       // that clears.
+       bool removed = QFile::remove(name.d->fi.absoluteFilePath());
+       int tries = 1;
+       while (!removed && tries < 6)   {
+               QThread::sleep(1);
+               removed = QFile::remove(name.d->fi.absoluteFilePath());
+               tries++;
+       }
+#else
        QFile::remove(name.d->fi.absoluteFilePath());
+#endif
 
-       bool success = QFile::rename(d->fi.absoluteFilePath(),
+       bool const success = QFile::rename(d->fi.absoluteFilePath(),
                name.d->fi.absoluteFilePath());
        if (!success)
                LYXERR0("Could not move file " << *this << " to " << name);
index 316cce0eb9e50ca5dde95adc25239b8f4929aed8..5580debeca004bac4af5f69ba5990fa571bf82f0 100644 (file)
@@ -63,6 +63,8 @@ Avoid using text mode for unicode symbols representable in math mode (bug 9616).
 
 - Fix nomenclature processing with LuaTeX (bug 11571).
 
+- Fix problem on Windows with saving files in Dropbox folders (bug 10091).
+
 
 * USER INTERFACE