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->VerifyControlPoints(ControlPoints);
|
||||
Piece->SetControlPoints(ControlPoints);
|
||||
|
||||
if (Piece->mPieceInfo->IsModel() && Piece->mPieceInfo->GetModel()->IncludesModel(this))
|
||||
{
|
||||
delete Piece;
|
||||
Piece = nullptr;
|
||||
continue;
|
||||
}
|
||||
|
||||
AddPiece(Piece);
|
||||
Piece = nullptr;
|
||||
}
|
||||
|
|
|
@ -400,6 +400,13 @@ bool Project::Load(const QString& FileName)
|
|||
int Pos = Model->SplitMPD(Buffer);
|
||||
|
||||
if (Models.empty() || !Model->GetFileName().isEmpty())
|
||||
{
|
||||
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));
|
||||
|
@ -408,6 +415,9 @@ bool Project::Load(const QString& FileName)
|
|||
else
|
||||
delete Model;
|
||||
}
|
||||
else
|
||||
delete Model;
|
||||
}
|
||||
|
||||
for (size_t ModelIdx = 0; ModelIdx < Models.size(); ModelIdx++)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue