src/ldtypes.cpp

changeset 522
afa691788bdb
parent 521
b85554206155
child 527
47c068f2e7e3
--- a/src/ldtypes.cpp	Sat Oct 19 02:33:08 2013 +0300
+++ b/src/ldtypes.cpp	Tue Oct 22 13:40:16 2013 +0300
@@ -264,8 +264,9 @@
 // =============================================================================
 // -----------------------------------------------------------------------------
 LDObject::~LDObject()
-{	// Remove this object from the selection array if it is there.
-	g_win->sel().removeOne (this);
+{	// If this object was selected, unselect it now
+	if (selected())
+		unselect();
 
 	// Delete the GL lists
 	GL::deleteLists (this);
@@ -735,7 +736,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-void LDSharedVertex::addRef(LDObject* a)
+void LDSharedVertex::addRef (LDObject* a)
 {	m_refs << a;
 }
 
@@ -748,4 +749,24 @@
 	{	g_sharedVerts.remove (m_data);
 		delete this;
 	}
+}
+
+// =============================================================================
+// -----------------------------------------------------------------------------
+void LDObject::select()
+{	if (!file())
+	{	log ("Warning: Object #%1 cannot be selected as it is not assigned a file!\n", id());
+		return;
+	}
+
+	file()->addToSelection (this);
+}
+
+void LDObject::unselect()
+{	if (!file())
+	{	log ("Warning: Object #%1 cannot be unselected as it is not assigned a file!\n", id());
+		return;
+	}
+
+	file()->removeFromSelection (this);
 }
\ No newline at end of file

mercurial