From ad4215e462fa24af065c29cb32c86c7cc19b3b33 Mon Sep 17 00:00:00 2001 From: Richard Kimberly Heck Date: Sun, 7 Jul 2019 13:13:52 -0400 Subject: [PATCH] Fix bug #10091. 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 | 19 ++++++++++++++++++- status.23x | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp index 9d00de3d44..e30609fe92 100644 --- a/src/support/FileName.cpp +++ b/src/support/FileName.cpp @@ -30,6 +30,10 @@ #include #include +#ifdef _WIN32 +#include +#endif + #include #include @@ -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); diff --git a/status.23x b/status.23x index 316cce0eb9..5580debeca 100644 --- a/status.23x +++ b/status.23x @@ -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 -- 2.39.5