Fix for build on drone.io.
--HG-- branch : develop
This commit is contained in:
parent
894444297b
commit
e6e8a7ff6d
|
@ -191,10 +191,9 @@ void TMainWindow::LoadFile(const QString &path)
|
|||
|
||||
VlpCreateLock(lock, QFileInfo(path).fileName()+".lock");
|
||||
|
||||
if (lock->GetLockError() == QLockFile::LockFailedError)
|
||||
if (not lock->IsLocked())
|
||||
{
|
||||
qCCritical(tMainWindow, "%s", qUtf8Printable(tr("This file already opened in another window.")));
|
||||
lock.reset();
|
||||
if (qApp->IsTestMode())
|
||||
{
|
||||
std::exit(V_EX_NOINPUT);
|
||||
|
@ -515,16 +514,13 @@ void TMainWindow::FileSaveAs()
|
|||
|
||||
if (QFileInfo(fileName).exists())
|
||||
{
|
||||
// Temporary try to lock the file before saving
|
||||
VLockGuard<char> tmp(fileName + ".lock");
|
||||
|
||||
if (not tmp.IsLocked())
|
||||
{
|
||||
if (lock->GetLockError() == QLockFile::LockFailedError)
|
||||
{
|
||||
qCCritical(tMainWindow, "%s",
|
||||
qUtf8Printable(tr("Failed to lock. This file already opened in another window.")));
|
||||
return;
|
||||
}
|
||||
qCCritical(tMainWindow, "%s",
|
||||
qUtf8Printable(tr("Failed to lock. This file already opened in another window.")));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -543,15 +539,11 @@ void TMainWindow::FileSaveAs()
|
|||
return;
|
||||
}
|
||||
|
||||
lock.reset();
|
||||
|
||||
VlpCreateLock(lock, fileName + ".lock");
|
||||
|
||||
if (lock->GetLockError() == QLockFile::LockFailedError)
|
||||
if (not lock->IsLocked())
|
||||
{
|
||||
qCCritical(tMainWindow, "%s", qUtf8Printable(tr("Failed to lock. This file already opened in another window. "
|
||||
"Expect collissions when run 2 copies of the program.")));
|
||||
lock.reset();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -952,8 +944,7 @@ void TMainWindow::ImportFromPattern()
|
|||
}
|
||||
|
||||
VLockGuard<char> tmp(QFileInfo(mPath).fileName()+".lock");
|
||||
|
||||
if (tmp.GetLockError() == QLockFile::LockFailedError)
|
||||
if (not tmp.IsLocked())
|
||||
{
|
||||
qCCritical(tMainWindow, "%s", qUtf8Printable(tr("This file already opened in another window.")));
|
||||
return;
|
||||
|
|
|
@ -1954,16 +1954,13 @@ bool MainWindow::SaveAs()
|
|||
|
||||
if (QFileInfo(fileName).exists())
|
||||
{
|
||||
// Temporary try to lock the file before saving
|
||||
VLockGuard<char> tmp(fileName + ".lock");
|
||||
|
||||
if (not tmp.IsLocked())
|
||||
{
|
||||
if (lock->GetLockError() == QLockFile::LockFailedError)
|
||||
{
|
||||
qCCritical(vMainWindow, "%s",
|
||||
qUtf8Printable(tr("Failed to lock. This file already opened in another window.")));
|
||||
return false;
|
||||
}
|
||||
qCCritical(vMainWindow, "%s",
|
||||
qUtf8Printable(tr("Failed to lock. This file already opened in another window.")));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1982,9 +1979,6 @@ bool MainWindow::SaveAs()
|
|||
return result;
|
||||
}
|
||||
|
||||
qCDebug(vMainWindow, "Unlock old file");
|
||||
lock.reset();
|
||||
|
||||
qCDebug(vMainWindow, "Locking file");
|
||||
VlpCreateLock(lock, fileName+".lock");
|
||||
|
||||
|
@ -1996,13 +1990,9 @@ bool MainWindow::SaveAs()
|
|||
{
|
||||
qCDebug(vMainWindow, "Failed to lock %s", qUtf8Printable(fileName));
|
||||
qCDebug(vMainWindow, "Error type: %d", lock->GetLockError());
|
||||
if (lock->GetLockError() == QLockFile::LockFailedError)
|
||||
{
|
||||
qCCritical(vMainWindow, "%s",
|
||||
qUtf8Printable(tr("Failed to lock. This file already opened in another window. Expect "
|
||||
"collissions when run 2 copies of the program.")));
|
||||
lock.reset();
|
||||
}
|
||||
qCCritical(vMainWindow, "%s",
|
||||
qUtf8Printable(tr("Failed to lock. This file already opened in another window. Expect "
|
||||
"collissions when run 2 copies of the program.")));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -3310,18 +3300,15 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
|
|||
{
|
||||
qCDebug(vMainWindow, "Failed to lock %s", qUtf8Printable(fileName));
|
||||
qCDebug(vMainWindow, "Error type: %d", lock->GetLockError());
|
||||
if (lock->GetLockError() == QLockFile::LockFailedError)
|
||||
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("This file already opened in another window.")));
|
||||
Clear();
|
||||
if (VApplication::CheckGUI())
|
||||
{
|
||||
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("This file already opened in another window.")));
|
||||
Clear();
|
||||
if (VApplication::CheckGUI())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::exit(V_EX_NOINPUT);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::exit(V_EX_NOINPUT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -145,21 +145,14 @@ bool VLockGuard<Guarded>::TryLock(const QString &lockName, int stale, int timeou
|
|||
lock.reset(new QLockFile(lockName));
|
||||
lock->setStaleLockTime(stale);
|
||||
|
||||
for (int i = 0; i < 2 && !lock->tryLock(timeout); i++)
|
||||
if (QLockFile::LockFailedError == lock->error())
|
||||
{
|
||||
if (QLockFile::LockFailedError != lock->error())
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// This happens if a stale lock file exists and another process uses that PID.
|
||||
// Try removing the stale file, which will fail if a real process is holding a
|
||||
// file-level lock. A false error is more problematic than not locking properly
|
||||
// on corner-case systems.
|
||||
lock->removeStaleLockFile();
|
||||
lock->tryLock(timeout);
|
||||
}
|
||||
// This happens if a stale lock file exists and another process uses that PID.
|
||||
// Try removing the stale file, which will fail if a real process is holding a
|
||||
// file-level lock. A false error is more problematic than not locking properly
|
||||
// on corner-case systems.
|
||||
lock->removeStaleLockFile();
|
||||
lock->tryLock(timeout);
|
||||
}
|
||||
res = QLockFile::NoError == (lockError = lock->error());
|
||||
if (!res)
|
||||
|
|
Loading…
Reference in New Issue
Block a user