gui_editactions.cpp

changeset 93
92682e6369e9
parent 92
586d294ca83f
child 94
a9e67f6e610e
--- a/gui_editactions.cpp	Wed Apr 10 04:34:19 2013 +0300
+++ b/gui_editactions.cpp	Wed Apr 10 13:24:35 2013 +0300
@@ -151,6 +151,18 @@
 ACTION (splitQuads, "Split Quads", "quad-split", "Split quads into triangles.", (0)) {
 	vector<LDObject*> objs = g_ForgeWindow->getSelectedObjects ();
 	
+	vector<ulong> ulaIndices;
+	vector<LDQuad*> paCopies;
+	
+	// Store stuff first for history archival
+	for (LDObject* obj : objs) {
+		if (obj->getType() != OBJ_Quad)
+			continue;
+		
+		ulaIndices.push_back (obj->getIndex (g_CurrentFile));
+		paCopies.push_back (static_cast<LDQuad*> (obj)->clone ());
+	}
+	
 	for (LDObject* obj : objs) {
 		if (obj->getType() != OBJ_Quad)
 			continue;
@@ -158,12 +170,8 @@
 		// Find the index of this quad
 		long lIndex = obj->getIndex (g_CurrentFile);
 		
-		if (lIndex == -1) {
-			// couldn't find it?
-			logf (LOG_Error, "Couldn't find quad %p in "
-				"current object list!!\n", obj);
+		if (lIndex == -1)
 			return;
-		}
 		
 		std::vector<LDTriangle*> triangles = static_cast<LDQuad*> (obj)->splitToTriangles ();
 		
@@ -176,6 +184,7 @@
 		delete obj;
 	}
 	
+	History::addEntry (new QuadSplitHistory (ulaIndices, paCopies));
 	g_ForgeWindow->refresh ();
 }
 

mercurial