fix crash when loading a file

Sat, 05 Mar 2022 12:47:10 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sat, 05 Mar 2022 12:47:10 +0200
changeset 159
1a04364d20b5
parent 158
5bd755eaa5a8
child 160
536efae7137e

fix crash when loading a file
`object` is moved so we cannot access it after moving

src/model.cpp file | annotate | diff | comparison | revisions
--- a/src/model.cpp	Sat Mar 05 12:42:14 2022 +0200
+++ b/src/model.cpp	Sat Mar 05 12:47:10 2022 +0200
@@ -158,8 +158,9 @@
 	Q_EMIT this->beginInsertRows({}, position, position);
 	this->body.push_back(std::move(object));
 	Q_EMIT this->endInsertRows();
-	this->objectsById[object->id] = object.get();
-	return object->id;
+	const ldraw::id_t id = this->body.back()->id;
+	this->objectsById[id] = this->body.back().get();
+	return id;
 }
 
 /**

mercurial