avoid having the null id in the selection

Sat, 08 Feb 2020 00:08:57 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sat, 08 Feb 2020 00:08:57 +0200
changeset 52
eee644f88e93
parent 51
1a9eac27698d
child 53
3af627f7a40f

avoid having the null id in the selection

src/ui/canvas.cpp file | annotate | diff | comparison | revisions
--- a/src/ui/canvas.cpp	Fri Feb 07 23:59:06 2020 +0200
+++ b/src/ui/canvas.cpp	Sat Feb 08 00:08:57 2020 +0200
@@ -13,6 +13,7 @@
 
 void Canvas::handleSelectionChange(const QSet<ldraw::Id>& selectedIds, const QSet<ldraw::Id>& deselectedIds)
 {
+	Q_ASSERT(not selectedIds.contains(ldraw::NULL_ID));
 	this->selection.subtract(deselectedIds);
 	this->selection.unite(selectedIds);
 	this->compiler->setSelectedObjects(this->selection);
@@ -40,7 +41,14 @@
 {
 	if (this->totalMouseMove < (2.0 / sqrt(2)) * 5.0)
 	{
-		this->selection = {this->highlighted};
+		if (this->highlighted == ldraw::NULL_ID)
+		{
+			this->selection = {};
+		}
+		else
+		{
+			this->selection = {this->highlighted};
+		}
 		this->compiler->setSelectedObjects(this->selection);
 		emit selectionChanged(this->selection);
 		this->update();

mercurial