src/ldtypes.cpp

changeset 307
c731a22899a3
parent 306
fef00a6cbff0
child 310
c62edce5668c
--- a/src/ldtypes.cpp	Thu Jun 27 14:12:12 2013 +0300
+++ b/src/ldtypes.cpp	Thu Jun 27 14:55:32 2013 +0300
@@ -76,6 +76,8 @@
 			id = obj->id() + 1;
 	
 	setID( id );
+	
+	g_LDObjects << this;
 }
 
 LDGibberish::LDGibberish () {}
@@ -215,12 +217,17 @@
 
 LDObject::~LDObject () {
 	// Remove this object from the selection array if it is there.
-	for (ulong i = 0; i < g_win->sel ().size(); ++i)
+	for (ulong i = 0; i < g_win->sel().size(); ++i)
 		if (g_win->sel ()[i] == this)
 			g_win->sel ().erase (i);
 	
 	// Delete the GL lists
-	GL::deleteLists (this);
+	GL::deleteLists( this );
+	
+	// Remove this object from the list of LDObjects
+	ulong pos = g_LDObjects.find( this );
+	if( pos < g_LDObjects.size())
+		g_LDObjects.erase( pos );
 }
 
 // =============================================================================
@@ -818,6 +825,15 @@
 	return repl;
 }
 
+LDObject* LDObject::fromID (int id) {
+	for( LDObject* obj : g_LDObjects )
+		if( obj->id() == id )
+			return obj;
+	
+	return null;
+}
+
+
 // =============================================================================
 template<class T> void changeProperty (LDObject* obj, T* ptr, const T& val) {
 	long idx;

mercurial