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");
|
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.")));
|
qCCritical(tMainWindow, "%s", qUtf8Printable(tr("This file already opened in another window.")));
|
||||||
lock.reset();
|
|
||||||
if (qApp->IsTestMode())
|
if (qApp->IsTestMode())
|
||||||
{
|
{
|
||||||
std::exit(V_EX_NOINPUT);
|
std::exit(V_EX_NOINPUT);
|
||||||
|
@ -515,18 +514,15 @@ void TMainWindow::FileSaveAs()
|
||||||
|
|
||||||
if (QFileInfo(fileName).exists())
|
if (QFileInfo(fileName).exists())
|
||||||
{
|
{
|
||||||
|
// Temporary try to lock the file before saving
|
||||||
VLockGuard<char> tmp(fileName + ".lock");
|
VLockGuard<char> tmp(fileName + ".lock");
|
||||||
|
|
||||||
if (not tmp.IsLocked())
|
if (not tmp.IsLocked())
|
||||||
{
|
|
||||||
if (lock->GetLockError() == QLockFile::LockFailedError)
|
|
||||||
{
|
{
|
||||||
qCCritical(tMainWindow, "%s",
|
qCCritical(tMainWindow, "%s",
|
||||||
qUtf8Printable(tr("Failed to lock. This file already opened in another window.")));
|
qUtf8Printable(tr("Failed to lock. This file already opened in another window.")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
QString error;
|
QString error;
|
||||||
bool result = SaveMeasurements(fileName, error);
|
bool result = SaveMeasurements(fileName, error);
|
||||||
|
@ -543,15 +539,11 @@ void TMainWindow::FileSaveAs()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lock.reset();
|
|
||||||
|
|
||||||
VlpCreateLock(lock, fileName + ".lock");
|
VlpCreateLock(lock, fileName + ".lock");
|
||||||
|
if (not lock->IsLocked())
|
||||||
if (lock->GetLockError() == QLockFile::LockFailedError)
|
|
||||||
{
|
{
|
||||||
qCCritical(tMainWindow, "%s", qUtf8Printable(tr("Failed to lock. This file already opened in another window. "
|
qCCritical(tMainWindow, "%s", qUtf8Printable(tr("Failed to lock. This file already opened in another window. "
|
||||||
"Expect collissions when run 2 copies of the program.")));
|
"Expect collissions when run 2 copies of the program.")));
|
||||||
lock.reset();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -952,8 +944,7 @@ void TMainWindow::ImportFromPattern()
|
||||||
}
|
}
|
||||||
|
|
||||||
VLockGuard<char> tmp(QFileInfo(mPath).fileName()+".lock");
|
VLockGuard<char> tmp(QFileInfo(mPath).fileName()+".lock");
|
||||||
|
if (not tmp.IsLocked())
|
||||||
if (tmp.GetLockError() == QLockFile::LockFailedError)
|
|
||||||
{
|
{
|
||||||
qCCritical(tMainWindow, "%s", qUtf8Printable(tr("This file already opened in another window.")));
|
qCCritical(tMainWindow, "%s", qUtf8Printable(tr("This file already opened in another window.")));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1954,18 +1954,15 @@ bool MainWindow::SaveAs()
|
||||||
|
|
||||||
if (QFileInfo(fileName).exists())
|
if (QFileInfo(fileName).exists())
|
||||||
{
|
{
|
||||||
|
// Temporary try to lock the file before saving
|
||||||
VLockGuard<char> tmp(fileName + ".lock");
|
VLockGuard<char> tmp(fileName + ".lock");
|
||||||
|
|
||||||
if (not tmp.IsLocked())
|
if (not tmp.IsLocked())
|
||||||
{
|
|
||||||
if (lock->GetLockError() == QLockFile::LockFailedError)
|
|
||||||
{
|
{
|
||||||
qCCritical(vMainWindow, "%s",
|
qCCritical(vMainWindow, "%s",
|
||||||
qUtf8Printable(tr("Failed to lock. This file already opened in another window.")));
|
qUtf8Printable(tr("Failed to lock. This file already opened in another window.")));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
QString error;
|
QString error;
|
||||||
const bool result = SavePattern(fileName, error);
|
const bool result = SavePattern(fileName, error);
|
||||||
|
@ -1982,9 +1979,6 @@ bool MainWindow::SaveAs()
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
qCDebug(vMainWindow, "Unlock old file");
|
|
||||||
lock.reset();
|
|
||||||
|
|
||||||
qCDebug(vMainWindow, "Locking file");
|
qCDebug(vMainWindow, "Locking file");
|
||||||
VlpCreateLock(lock, fileName+".lock");
|
VlpCreateLock(lock, fileName+".lock");
|
||||||
|
|
||||||
|
@ -1996,13 +1990,9 @@ bool MainWindow::SaveAs()
|
||||||
{
|
{
|
||||||
qCDebug(vMainWindow, "Failed to lock %s", qUtf8Printable(fileName));
|
qCDebug(vMainWindow, "Failed to lock %s", qUtf8Printable(fileName));
|
||||||
qCDebug(vMainWindow, "Error type: %d", lock->GetLockError());
|
qCDebug(vMainWindow, "Error type: %d", lock->GetLockError());
|
||||||
if (lock->GetLockError() == QLockFile::LockFailedError)
|
|
||||||
{
|
|
||||||
qCCritical(vMainWindow, "%s",
|
qCCritical(vMainWindow, "%s",
|
||||||
qUtf8Printable(tr("Failed to lock. This file already opened in another window. Expect "
|
qUtf8Printable(tr("Failed to lock. This file already opened in another window. Expect "
|
||||||
"collissions when run 2 copies of the program.")));
|
"collissions when run 2 copies of the program.")));
|
||||||
lock.reset();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -3310,8 +3300,6 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
|
||||||
{
|
{
|
||||||
qCDebug(vMainWindow, "Failed to lock %s", qUtf8Printable(fileName));
|
qCDebug(vMainWindow, "Failed to lock %s", qUtf8Printable(fileName));
|
||||||
qCDebug(vMainWindow, "Error type: %d", lock->GetLockError());
|
qCDebug(vMainWindow, "Error type: %d", lock->GetLockError());
|
||||||
if (lock->GetLockError() == QLockFile::LockFailedError)
|
|
||||||
{
|
|
||||||
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("This file already opened in another window.")));
|
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("This file already opened in another window.")));
|
||||||
Clear();
|
Clear();
|
||||||
if (VApplication::CheckGUI())
|
if (VApplication::CheckGUI())
|
||||||
|
@ -3323,7 +3311,6 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
|
||||||
std::exit(V_EX_NOINPUT);
|
std::exit(V_EX_NOINPUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// On this stage scene empty. Fit scene size to view size
|
// On this stage scene empty. Fit scene size to view size
|
||||||
VMainGraphicsView::NewSceneRect(sceneDraw, ui->view);
|
VMainGraphicsView::NewSceneRect(sceneDraw, ui->view);
|
||||||
|
|
|
@ -145,13 +145,7 @@ bool VLockGuard<Guarded>::TryLock(const QString &lockName, int stale, int timeou
|
||||||
lock.reset(new QLockFile(lockName));
|
lock.reset(new QLockFile(lockName));
|
||||||
lock->setStaleLockTime(stale);
|
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.
|
// 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
|
// Try removing the stale file, which will fail if a real process is holding a
|
||||||
|
@ -160,7 +154,6 @@ bool VLockGuard<Guarded>::TryLock(const QString &lockName, int stale, int timeou
|
||||||
lock->removeStaleLockFile();
|
lock->removeStaleLockFile();
|
||||||
lock->tryLock(timeout);
|
lock->tryLock(timeout);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
res = QLockFile::NoError == (lockError = lock->error());
|
res = QLockFile::NoError == (lockError = lock->error());
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user