Skip to content

Commit 82362c5

Browse files
committed
OcdFileImport: Drop hole points before hole points
Fixes crashes in the editor when the user selects the object.
1 parent b238a09 commit 82362c5

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/fileformats/ocd_file_import.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,13 +2144,23 @@ void OcdFileImport::fillPathCoords(OcdImportedPathObject *object, bool is_area,
21442144
else if (ocd_point.y & Ocd::OcdPoint32::FlagHole)
21452145
{
21462146
Q_ASSERT(i >= 2); // implied by initialization of ignore_hole_points
2147-
// HolePoint needs to be applied to the last point of a part
2148-
object->coords[i-1].setHolePoint(true);
2147+
if (object->coords[i-2].isHolePoint())
2148+
{
2149+
// overwrite current part start (i.e. drop last point from input)
2150+
object->coords[i-1] = object->coords[i];
2151+
--i;
2152+
}
2153+
else
2154+
{
2155+
// HolePoint needs to be applied to the last point of a part
2156+
object->coords[i-1].setHolePoint(true);
2157+
}
21492158
}
21502159
}
21512160
return ++i;
21522161
});
2153-
Q_ASSERT(object->coords.size() == count);
2162+
Q_ASSERT(object->coords.size() >= count);
2163+
object->coords.resize(count);
21542164

21552165
// For path objects, create closed parts where the position of the last point is equal to that of the first point
21562166
if (object->getType() == Object::Path)

0 commit comments

Comments
 (0)