mirror of
https://github.com/leozide/leocad
synced 2024-12-27 21:58:37 +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->SetColorCode(ColorCode);
|
||||||
Piece->VerifyControlPoints(ControlPoints);
|
Piece->VerifyControlPoints(ControlPoints);
|
||||||
Piece->SetControlPoints(ControlPoints);
|
Piece->SetControlPoints(ControlPoints);
|
||||||
|
|
||||||
|
if (Piece->mPieceInfo->IsModel() && Piece->mPieceInfo->GetModel()->IncludesModel(this))
|
||||||
|
{
|
||||||
|
delete Piece;
|
||||||
|
Piece = nullptr;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
AddPiece(Piece);
|
AddPiece(Piece);
|
||||||
Piece = nullptr;
|
Piece = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -401,9 +401,19 @@ bool Project::Load(const QString& FileName)
|
||||||
|
|
||||||
if (Models.empty() || !Model->GetFileName().isEmpty())
|
if (Models.empty() || !Model->GetFileName().isEmpty())
|
||||||
{
|
{
|
||||||
mModels.Add(Model);
|
auto ModelCompare = [Model](const std::pair<int, lcModel*>& ModelIt)
|
||||||
Models.emplace_back(std::make_pair(Pos, Model));
|
{
|
||||||
Model->CreatePieceInfo(this);
|
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
|
else
|
||||||
delete Model;
|
delete Model;
|
||||||
|
|
Loading…
Reference in a new issue