]> git.lyx.org Git - lyx.git/blobdiff - src/support/FileName.cpp
Fix Qt deprecation warns for QTime
[lyx.git] / src / support / FileName.cpp
index f77ccb73a665e68c952541eb70dc057f43de1e57..179fef46ee92e2b419fd8f18e33d74b162a3472c 100644 (file)
@@ -28,7 +28,7 @@
 #include <QFileInfo>
 #include <QList>
 #include <QTemporaryFile>
-#include <QTime>
+#include <QElapsedTimer>
 
 #ifdef _WIN32
 #include <QThread>
@@ -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,19 +273,21 @@ 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.
-       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++;
+       name.refresh();
+       if (name.exists()) {
+               bool removed = name.removeFile();
+               int tries = 1;
+               while (!removed && tries < 6)   {
+                       QThread::sleep(1);
+                       removed = name.removeFile();
+                       tries++;
+               }
        }
 #else
        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;
@@ -560,7 +563,7 @@ unsigned long FileName::checksum() const
        }
 
        // This is used in the debug output at the end of the method.
-       static QTime t;
+       static QElapsedTimer t;
        if (lyxerr.debugging(Debug::FILES))
                t.restart();
 
@@ -967,10 +970,8 @@ string DocFileName::mangledFileName(string const & dir) const
                return (*it).second;
 
        string const name = absFileName();
-       // Now the real work
-       string mname = os::internal_path(name);
-       // Remove the extension.
-       mname = support::changeExtension(name, string());
+       // Now the real work. Remove the extension.
+       string mname = support::changeExtension(name, string());
        // The mangled name must be a valid LaTeX name.
        // The list of characters to keep is probably over-restrictive,
        // but it is not really a problem.