src/linetypes/modelobject.cpp

changeset 1290
8db26042f3d1
parent 1278
6e1ea24e5a5e
child 1297
389516787a4c
--- a/src/linetypes/modelobject.cpp	Fri Mar 16 11:55:58 2018 +0200
+++ b/src/linetypes/modelobject.cpp	Fri Mar 16 12:20:16 2018 +0200
@@ -90,7 +90,11 @@
 
 int LDSubfileReference::triangleCount(DocumentManager* context) const
 {
-	return fileInfo(context)->triangleCount();
+	LDDocument* file = fileInfo(context);
+	if (file)
+		return file->triangleCount();
+	else
+		return 0;
 }
 
 int LDObject::numVertices() const
@@ -212,15 +216,24 @@
 //
 QList<LDPolygon> LDSubfileReference::inlinePolygons(DocumentManager* context)
 {
-	QList<LDPolygon> data = fileInfo(context)->inlinePolygons();
+	LDDocument* file = fileInfo(context);
 
-	for (LDPolygon& entry : data)
+	if (file)
 	{
-		for (int i = 0; i < entry.numVertices(); ++i)
-			entry.vertices[i].transform (transformationMatrix(), position());
+		QList<LDPolygon> data = fileInfo(context)->inlinePolygons();
+
+		for (LDPolygon& entry : data)
+		{
+			for (int i = 0; i < entry.numVertices(); ++i)
+				entry.vertices[i].transform (transformationMatrix(), position());
+		}
+
+		return data;
 	}
-
-	return data;
+	else
+	{
+		return {};
+	}
 }
 
 // =============================================================================

mercurial