From 8f04ccbec7f74a772e3c0fb184b82f448ddb627f Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Wed, 31 Oct 2018 16:16:45 -0700 Subject: [PATCH] Fixed small leak merging files. Fixes #276. --- common/lc_mainwindow.cpp | 7 +++---- common/project.cpp | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/common/lc_mainwindow.cpp b/common/lc_mainwindow.cpp index 819c313a..65244ae9 100644 --- a/common/lc_mainwindow.cpp +++ b/common/lc_mainwindow.cpp @@ -938,7 +938,7 @@ void lcMainWindow::ProjectFileChanged(const QString& Path) { PieceInfo* Info = lcGetPiecesLibrary()->FindPiece(FileInfo.fileName().toLatin1(), CurrentProject, false, true); - if (Info) + if (Info && Info->IsProject()) Info->GetProject()->Load(Path); } } @@ -2211,10 +2211,9 @@ void lcMainWindow::MergeProject() UpdateModels(); } else - { QMessageBox::information(this, tr("LeoCAD"), tr("Error loading '%1'.").arg(LoadFileName)); - delete NewProject; - } + + delete NewProject; } void lcMainWindow::ImportLDD() diff --git a/common/project.cpp b/common/project.cpp index ad65d7e6..5652a814 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -494,9 +494,8 @@ bool Project::Save(QTextStream& Stream) void Project::Merge(Project* Other) { - for (int ModelIdx = 0; ModelIdx < Other->mModels.GetSize(); ModelIdx++) + for (lcModel* Model : Other->mModels) { - lcModel* Model = Other->mModels[ModelIdx]; QString Name = Model->GetProperties().mName; for (;;) @@ -522,6 +521,7 @@ void Project::Merge(Project* Other) mModels.Add(Model); } + Other->mModels.RemoveAll(); mModified = true; }