Do not open file twice after we restore him.

--HG--
branch : develop
This commit is contained in:
dismine 2014-10-30 12:19:17 +02:00
parent 1d8a0054ac
commit 8407f714a5
3 changed files with 5 additions and 4 deletions

View File

@ -187,12 +187,12 @@ int main(int argc, char *argv[])
parser.addVersionOption(); parser.addVersionOption();
parser.addPositionalArgument("filename", QCoreApplication::translate("main", "Pattern file.")); parser.addPositionalArgument("filename", QCoreApplication::translate("main", "Pattern file."));
parser.process(app); parser.process(app);
const QStringList args = parser.positionalArguments(); QStringList args = parser.positionalArguments();
//Before we load pattern show window. //Before we load pattern show window.
w.show(); w.show();
w.ReopenFilesAfterCrash(); w.ReopenFilesAfterCrash(args);
for (int i=0;i<args.size();++i) for (int i=0;i<args.size();++i)
{ {

View File

@ -2274,7 +2274,7 @@ void MainWindow::LoadPattern(const QString &fileName)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::ReopenFilesAfterCrash() void MainWindow::ReopenFilesAfterCrash(QStringList &args)
{ {
QStringList files = qApp->getSettings()->value("restoreFileList").toStringList(); QStringList files = qApp->getSettings()->value("restoreFileList").toStringList();
if (files.size() > 0) if (files.size() > 0)
@ -2308,6 +2308,7 @@ void MainWindow::ReopenFilesAfterCrash()
QFile autoFile(restoreFiles.at(i) +".autosave"); QFile autoFile(restoreFiles.at(i) +".autosave");
autoFile.remove(); autoFile.remove();
LoadPattern(restoreFiles.at(i)); LoadPattern(restoreFiles.at(i));
args.removeAll(restoreFiles.at(i));// Do not open file twice after we restore him.
} }
else else
{ {

View File

@ -56,7 +56,7 @@ public:
explicit MainWindow(QWidget *parent = nullptr); explicit MainWindow(QWidget *parent = nullptr);
virtual ~MainWindow(); virtual ~MainWindow();
void LoadPattern(const QString &curFile); void LoadPattern(const QString &curFile);
void ReopenFilesAfterCrash(); void ReopenFilesAfterCrash(QStringList &args);
public slots: public slots:
void mouseMove(const QPointF &scenePos); void mouseMove(const QPointF &scenePos);
void ArrowTool(); void ArrowTool();