Fixed small leak merging files. Fixes #276.

This commit is contained in:
Leonardo Zide 2018-10-31 16:16:45 -07:00
parent b77b9aac5c
commit 8f04ccbec7
2 changed files with 5 additions and 6 deletions

View file

@ -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()

View file

@ -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;
}