[LyX/2.3.x] Fix bug #11737.

Richard Kimberly Heck rikiheck at lyx.org
Thu Feb 13 04:48:10 UTC 2020


commit 0be206c976db0aa981004dda08f038a9e40de9b0
Author: Richard Kimberly Heck <rikiheck at lyx.org>
Date:   Thu Feb 13 00:03:51 2020 -0500

    Fix bug #11737.
    
    We need to use the FileName methods when moving or removing a file,
    so that refresh() gets called.
    
    No status entry since this will be in 2.3.4.3.
    
    (cherry picked from commit d93091389896cddcd83de83dfd4ee8a9b4e9c7f1)
---
 src/support/FileName.cpp |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp
index 5f64bbf..df5b443 100644
--- a/src/support/FileName.cpp
+++ b/src/support/FileName.cpp
@@ -251,6 +251,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;
@@ -264,12 +265,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++;
 		}
 	}
@@ -277,8 +279,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;


More information about the lyx-cvs mailing list