From e25dfbada9342fc503ae3881860bbd71b3f54952 Mon Sep 17 00:00:00 2001 From: dismine Date: Fri, 28 Nov 2014 19:15:23 +0200 Subject: [PATCH] Do not open file if already opened in another window. --HG-- branch : develop --- src/app/mainwindow.cpp | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index c536ae6a2..2a25f54fb 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -61,6 +61,7 @@ #include #include #include +#include Q_LOGGING_CATEGORY(vMainWindow, "v.mainwindow") @@ -2294,6 +2295,25 @@ void MainWindow::LoadPattern(const QString &fileName) //We have unsaved changes or load more then one file per time OpenNewValentina(fileName); + qCDebug(vMainWindow)<<"Loking file"; + lock = new QLockFile(fileName+".lock"); + lock->setStaleLockTime(0); + if (lock->tryLock()) + { + qCDebug(vMainWindow) << "Pattern file"<error(); + if (lock->error() == QLockFile::LockFailedError) + { + qCCritical(vMainWindow) << tr("This file already opened in another window."); + Clear(); + return; + } + } + // On this stage scene empty. Fit scene size to view size VAbstractTool::NewSceneRect(sceneDraw, ui->view); VAbstractTool::NewSceneRect(sceneDetails, ui->view); @@ -2372,19 +2392,6 @@ void MainWindow::LoadPattern(const QString &fileName) ZoomFirstShow(); ui->actionDraw->setChecked(true); - - qCDebug(vMainWindow)<<"Loking file"; - lock = new QLockFile(curFile+".lock"); - lock->setStaleLockTime(0); - if (lock->tryLock()) - { - qCDebug(vMainWindow) << "Log file"<error(); - } } }