[Interest] QLockFile

Graham Labdon Graham.Labdon at avalonsciences.com
Mon Feb 23 10:48:57 CET 2015


Hi

I am trying to use QLockFile in a function that receives a file path as a QString.

When I pass the string directly to the constructor of QLockFile and the call tryLock it always fails.

However, if I hard code the string the lock succeeds (although I get compiler warnings about unknown escape sequences)

If I user the toNativeSeparators method of QDir on my file path the call to tryLock fails although in the debugger the value of the converted string appears to the same as the hard coded value.

I would be grateful if someone could explain this behaviour

FileDestination::FileDestination(const QString& filePath)
{
    QLockFile lockFile(filePath); // tryLock fails

    QString s = QDir::toNativeSeparators(filePath)
    QLockFile lockFile2(s); // tryLock fails

    QLockFile lockFile3("C:\jobs\Myjob.txt"); // tryLock succeeds bu get compiler warnings for unknown escape sequences
}



More information about the Interest mailing list