mirror of
https://github.com/leozide/leocad
synced 2024-12-26 21:58:44 +01:00
Handle some malformed mpd files. Fixes #533.
- Skip duplicate submodels - Skip recursive includes
This commit is contained in:
parent
f386de205d
commit
462897caf7
2 changed files with 21 additions and 3 deletions
|
@ -734,6 +734,14 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project)
|
|||
Piece->SetColorCode(ColorCode);
|
||||
Piece->VerifyControlPoints(ControlPoints);
|
||||
Piece->SetControlPoints(ControlPoints);
|
||||
|
||||
if (Piece->mPieceInfo->IsModel() && Piece->mPieceInfo->GetModel()->IncludesModel(this))
|
||||
{
|
||||
delete Piece;
|
||||
Piece = nullptr;
|
||||
continue;
|
||||
}
|
||||
|
||||
AddPiece(Piece);
|
||||
Piece = nullptr;
|
||||
}
|
||||
|
|
|
@ -401,9 +401,19 @@ bool Project::Load(const QString& FileName)
|
|||
|
||||
if (Models.empty() || !Model->GetFileName().isEmpty())
|
||||
{
|
||||
mModels.Add(Model);
|
||||
Models.emplace_back(std::make_pair(Pos, Model));
|
||||
Model->CreatePieceInfo(this);
|
||||
auto ModelCompare = [Model](const std::pair<int, lcModel*>& ModelIt)
|
||||
{
|
||||
return ModelIt.second->GetFileName() == Model->GetFileName();
|
||||
};
|
||||
|
||||
if (std::find_if(Models.begin(), Models.end(), ModelCompare) == Models.end())
|
||||
{
|
||||
mModels.Add(Model);
|
||||
Models.emplace_back(std::make_pair(Pos, Model));
|
||||
Model->CreatePieceInfo(this);
|
||||
}
|
||||
else
|
||||
delete Model;
|
||||
}
|
||||
else
|
||||
delete Model;
|
||||
|
|
Loading…
Reference in a new issue