The lock file already helps to prevent rewriting current opened pattern file.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-01-22 12:54:19 +02:00
parent 8b050eee31
commit 0d34320e7d

View File

@ -2091,6 +2091,7 @@ bool MainWindow::SaveAs()
if (QFileInfo(fileName).exists())
{
// Temporary try to lock the file before saving
// Also help to rewite current read-only pattern
VLockGuard<char> tmp(fileName);
if (not tmp.IsLocked())
{
@ -2100,20 +2101,6 @@ bool MainWindow::SaveAs()
}
}
if (curFile == fileName && patternReadOnly)
{
const QString message = QString("Failed to save the pattern '%1'. Error writing. The document is read-only.")
.arg(fileName);
QMessageBox messageBox;
messageBox.setIcon(QMessageBox::Critical);
messageBox.setInformativeText(message);
messageBox.setDefaultButton(QMessageBox::Ok);
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.exec();
return false;
}
// Need for restoring previous state in case of failure
const bool wasModified = doc->IsModified(); // Need because SetReadOnly() will change internal state
const bool readOnly = doc->IsReadOnly();