]> git.lyx.org Git - lyx.git/blobdiff - src/support/FileName.cpp
Implement file locking and apply to configure
[lyx.git] / src / support / FileName.cpp
index 96317bed2798cf798906eecf010e29291438e835..f0489309d549ae44a61df42c888225eb23eadfe5 100644 (file)
@@ -131,7 +131,7 @@ FileName::FileName(string const & abs_filename)
        : d(abs_filename.empty() ? new Private : new Private(abs_filename))
 {
        //LYXERR(Debug::FILES, "FileName(" << abs_filename << ')');
-       LASSERT(empty() || isAbsolute(d->name), /**/);
+       LATTEST(empty() || isAbsolute(d->name));
 }
 
 
@@ -194,7 +194,7 @@ void FileName::set(string const & name)
        d->fi.setFile(toqstr(name));
        d->name = fromqstr(d->fi.absoluteFilePath());
        //LYXERR(Debug::FILES, "FileName::set(" << name << ')');
-       LASSERT(empty() || isAbsolute(d->name), /**/);
+       LATTEST(empty() || isAbsolute(d->name));
 }
 
 
@@ -206,7 +206,7 @@ void FileName::set(FileName const & rhs, string const & suffix)
                d->fi.setFile(QDir(rhs.d->fi.absoluteFilePath()), toqstr(suffix));
        d->name = fromqstr(d->fi.absoluteFilePath());
        //LYXERR(Debug::FILES, "FileName::set(" << d->name << ')');
-       LASSERT(empty() || isAbsolute(d->name), /**/);
+       LATTEST(empty() || isAbsolute(d->name));
 }
 
 
@@ -437,7 +437,13 @@ FileNameList FileName::dirList(string const & ext) const
 
 static string createTempFile(QString const & mask)
 {
-       QTemporaryFile qt_tmp(mask);
+       // FIXME: This is not safe. QTemporaryFile creates a file in open(),
+       //        but the file is deleted when qt_tmp goes out of scope.
+       //        Therefore the next call to createTempFile() may create the
+       //        same file again. To make this safe the QTemporaryFile object
+       //        needs to be kept for the whole life time of the temp file name.
+       //        This can be achieved by using the TempFile class.
+       QTemporaryFile qt_tmp(mask + ".XXXXXXXXXXXX");
        if (qt_tmp.open()) {
                string const temp_file = fromqstr(qt_tmp.fileName());
                LYXERR(Debug::FILES, "Temporary file `" << temp_file << "' created.");