Allow user to ignore warning "This file already opened in another window".
--HG-- branch : develop
This commit is contained in:
parent
d227ce68c2
commit
4d3aeaca08
|
@ -233,12 +233,10 @@ bool TMainWindow::LoadFile(const QString &path)
|
||||||
|
|
||||||
if (not lock->IsLocked())
|
if (not lock->IsLocked())
|
||||||
{
|
{
|
||||||
qCCritical(tMainWindow, "%s", qUtf8Printable(tr("This file already opened in another window.")));
|
if (not IgnoreLocking(lock->GetLockError(), path))
|
||||||
if (qApp->IsTestMode())
|
|
||||||
{
|
{
|
||||||
qApp->exit(V_EX_NOINPUT);
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -2599,12 +2597,10 @@ bool TMainWindow::LoadFromExistingFile(const QString &path)
|
||||||
|
|
||||||
if (not lock->IsLocked())
|
if (not lock->IsLocked())
|
||||||
{
|
{
|
||||||
qCCritical(tMainWindow, "%s", qUtf8Printable(tr("This file already opened in another window.")));
|
if (not IgnoreLocking(lock->GetLockError(), path))
|
||||||
if (qApp->IsTestMode())
|
|
||||||
{
|
{
|
||||||
qApp->exit(V_EX_NOINPUT);
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -2726,6 +2722,72 @@ void TMainWindow::CreateWindowMenu(QMenu *menu)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool TMainWindow::IgnoreLocking(int error, const QString &path)
|
||||||
|
{
|
||||||
|
QMessageBox::StandardButton answer = QMessageBox::Abort;
|
||||||
|
if (not qApp->IsTestMode())
|
||||||
|
{
|
||||||
|
switch(error)
|
||||||
|
{
|
||||||
|
case QLockFile::LockFailedError:
|
||||||
|
answer = QMessageBox::warning(this, tr("Locking file"),
|
||||||
|
tr("This file already opened in another window. Ignore if you want "
|
||||||
|
"to continue (not recommended, can cause a data corruption)."),
|
||||||
|
QMessageBox::Abort|QMessageBox::Ignore, QMessageBox::Abort);
|
||||||
|
break;
|
||||||
|
case QLockFile::PermissionError:
|
||||||
|
answer = QMessageBox::question(this, tr("Locking file"),
|
||||||
|
tr("The lock file could not be created, for lack of permissions. "
|
||||||
|
"Ignore if you want to continue (not recommended, can cause "
|
||||||
|
"a data corruption)."),
|
||||||
|
QMessageBox::Abort|QMessageBox::Ignore, QMessageBox::Abort);
|
||||||
|
break;
|
||||||
|
case QLockFile::UnknownError:
|
||||||
|
answer = QMessageBox::question(this, tr("Locking file"),
|
||||||
|
tr("Unknown error happened, for instance a full partition "
|
||||||
|
"prevented writing out the lock file. Ignore if you want to "
|
||||||
|
"continue (not recommended, can cause a data corruption)."),
|
||||||
|
QMessageBox::Abort|QMessageBox::Ignore, QMessageBox::Abort);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
answer = QMessageBox::Abort;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (answer == QMessageBox::Abort)
|
||||||
|
{
|
||||||
|
qCDebug(tMainWindow, "Failed to lock %s", qUtf8Printable(path));
|
||||||
|
qCDebug(tMainWindow, "Error type: %d", error);
|
||||||
|
if (qApp->IsTestMode())
|
||||||
|
{
|
||||||
|
switch(error)
|
||||||
|
{
|
||||||
|
case QLockFile::LockFailedError:
|
||||||
|
qCCritical(tMainWindow, "%s",
|
||||||
|
qUtf8Printable(tr("This file already opened in another window.")));
|
||||||
|
break;
|
||||||
|
case QLockFile::PermissionError:
|
||||||
|
qCCritical(tMainWindow, "%s",
|
||||||
|
qUtf8Printable(tr("The lock file could not be created, for lack of permissions.")));
|
||||||
|
break;
|
||||||
|
case QLockFile::UnknownError:
|
||||||
|
qCCritical(tMainWindow, "%s",
|
||||||
|
qUtf8Printable(tr("Unknown error happened, for instance a full partition "
|
||||||
|
"prevented writing out the lock file.")));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
qApp->exit(V_EX_NOINPUT);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TMainWindow::SetDecimals()
|
void TMainWindow::SetDecimals()
|
||||||
{
|
{
|
||||||
|
|
|
@ -200,6 +200,8 @@ private:
|
||||||
bool LoadFromExistingFile(const QString &path);
|
bool LoadFromExistingFile(const QString &path);
|
||||||
|
|
||||||
void CreateWindowMenu(QMenu *menu);
|
void CreateWindowMenu(QMenu *menu);
|
||||||
|
|
||||||
|
bool IgnoreLocking(int error, const QString &path);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TMAINWINDOW_H
|
#endif // TMAINWINDOW_H
|
||||||
|
|
|
@ -3444,15 +3444,10 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qCDebug(vMainWindow, "Failed to lock %s", qUtf8Printable(fileName));
|
if (not IgnoreLocking(lock->GetLockError(), fileName))
|
||||||
qCDebug(vMainWindow, "Error type: %d", lock->GetLockError());
|
|
||||||
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("This file already opened in another window.")));
|
|
||||||
Clear();
|
|
||||||
if (not VApplication::IsGUIMode())
|
|
||||||
{
|
{
|
||||||
qApp->exit(V_EX_NOINPUT);
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// On this stage scene empty. Fit scene size to view size
|
// On this stage scene empty. Fit scene size to view size
|
||||||
|
@ -4141,3 +4136,70 @@ void MainWindow::UpdateWindowTitle()
|
||||||
setWindowIcon(icon);
|
setWindowIcon(icon);
|
||||||
#endif //defined(Q_OS_MAC)
|
#endif //defined(Q_OS_MAC)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool MainWindow::IgnoreLocking(int error, const QString &path)
|
||||||
|
{
|
||||||
|
QMessageBox::StandardButton answer = QMessageBox::Abort;
|
||||||
|
if (VApplication::IsGUIMode())
|
||||||
|
{
|
||||||
|
switch(error)
|
||||||
|
{
|
||||||
|
case QLockFile::LockFailedError:
|
||||||
|
answer = QMessageBox::warning(this, tr("Locking file"),
|
||||||
|
tr("This file already opened in another window. Ignore if you want "
|
||||||
|
"to continue (not recommended, can cause a data corruption)."),
|
||||||
|
QMessageBox::Abort|QMessageBox::Ignore, QMessageBox::Abort);
|
||||||
|
break;
|
||||||
|
case QLockFile::PermissionError:
|
||||||
|
answer = QMessageBox::question(this, tr("Locking file"),
|
||||||
|
tr("The lock file could not be created, for lack of permissions. "
|
||||||
|
"Ignore if you want to continue (not recommended, can cause "
|
||||||
|
"a data corruption)."),
|
||||||
|
QMessageBox::Abort|QMessageBox::Ignore, QMessageBox::Abort);
|
||||||
|
break;
|
||||||
|
case QLockFile::UnknownError:
|
||||||
|
answer = QMessageBox::question(this, tr("Locking file"),
|
||||||
|
tr("Unknown error happened, for instance a full partition prevented "
|
||||||
|
"writing out the lock file. Ignore if you want to continue (not "
|
||||||
|
"recommended, can cause a data corruption)."),
|
||||||
|
QMessageBox::Abort|QMessageBox::Ignore, QMessageBox::Abort);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
answer = QMessageBox::Abort;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (answer == QMessageBox::Abort)
|
||||||
|
{
|
||||||
|
qCDebug(vMainWindow, "Failed to lock %s", qUtf8Printable(path));
|
||||||
|
qCDebug(vMainWindow, "Error type: %d", error);
|
||||||
|
Clear();
|
||||||
|
if (not VApplication::IsGUIMode())
|
||||||
|
{
|
||||||
|
switch(error)
|
||||||
|
{
|
||||||
|
case QLockFile::LockFailedError:
|
||||||
|
qCCritical(vMainWindow, "%s",
|
||||||
|
qUtf8Printable(tr("This file already opened in another window.")));
|
||||||
|
break;
|
||||||
|
case QLockFile::PermissionError:
|
||||||
|
qCCritical(vMainWindow, "%s",
|
||||||
|
qUtf8Printable(tr("The lock file could not be created, for lack of permissions.")));
|
||||||
|
break;
|
||||||
|
case QLockFile::UnknownError:
|
||||||
|
qCCritical(vMainWindow, "%s",
|
||||||
|
qUtf8Printable(tr("Unknown error happened, for instance a full partition prevented "
|
||||||
|
"writing out the lock file.")));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
qApp->exit(V_EX_NOINPUT);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -322,6 +322,8 @@ private:
|
||||||
QString GetMeasurementFileName();
|
QString GetMeasurementFileName();
|
||||||
|
|
||||||
void UpdateWindowTitle();
|
void UpdateWindowTitle();
|
||||||
|
|
||||||
|
bool IgnoreLocking(int error, const QString &path);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user