Fixed crashing

Fri, 16 Mar 2018 12:20:16 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Fri, 16 Mar 2018 12:20:16 +0200
changeset 1290
8db26042f3d1
parent 1289
ec5a38d19cf5
child 1291
9c570a30c98a

Fixed crashing

src/linetypes/modelobject.cpp file | annotate | diff | comparison | revisions
--- 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