removed another LDObject::model() use

Sat, 03 Mar 2018 17:59:32 +0200

author
Santeri Piippo
date
Sat, 03 Mar 2018 17:59:32 +0200
changeset 1267
b153b6b248ce
parent 1266
eeaca12d3d76
child 1268
7cbdaefda950

removed another LDObject::model() use

src/model.h file | annotate | diff | comparison | revisions
--- a/src/model.h	Sat Mar 03 17:57:35 2018 +0200
+++ b/src/model.h	Sat Mar 03 17:59:32 2018 +0200
@@ -179,15 +179,18 @@
 template<typename T, typename... Args>
 T* Model::emplaceReplacement(LDObject* object, Args&& ...args)
 {
-	if (object->model() == this)
+	QModelIndex position = this->indexOf(object);
+
+	if (position.isValid())
 	{
-		QModelIndex position = indexOf(object);
 		T* replacement = constructObject<T>(args...);
 		setObjectAt(position.row(), replacement);
 		return replacement;
 	}
 	else
+	{
 		return nullptr;
+	}
 }
 
 /*

mercurial