Mon, 10 Mar 2014 13:26:02 +0200
- hooked object compilation to low-level functions so as to remove the compileObject() crap from edit actions
--- a/src/Document.cc Mon Mar 10 01:16:00 2014 +0200 +++ b/src/Document.cc Mon Mar 10 13:26:02 2014 +0200 @@ -1143,6 +1143,7 @@ m_objects[idx]->unselect(); m_objects[idx]->setDocument (null); obj->setDocument (this); + g_win->R()->compileObject (obj); m_objects[idx] = obj; }
--- a/src/LDObject.cc Mon Mar 10 01:16:00 2014 +0200 +++ b/src/LDObject.cc Mon Mar 10 13:26:02 2014 +0200 @@ -686,6 +686,7 @@ void LDOverlay::invert() {} // ============================================================================= +// // Hook the set accessors of certain properties to this changeProperty function. // It takes care of history management so we can capture low-level changes, this // makes history stuff work out of the box. @@ -697,14 +698,17 @@ if (*ptr == val) return; - if (obj->document() && (idx = obj->lineNumber()) != -1) + if (obj->document() != null && (idx = obj->lineNumber()) != -1) { QString before = obj->asText(); *ptr = val; QString after = obj->asText(); if (before != after) + { obj->document()->addToHistory (new EditHistory (idx, before, after)); + g_win->R()->compileObject (obj); + } } else *ptr = val;
--- a/src/actions/EditActions.cc Mon Mar 10 01:16:00 2014 +0200 +++ b/src/actions/EditActions.cc Mon Mar 10 13:26:02 2014 +0200 @@ -94,7 +94,6 @@ LDObject* pasted = parseLine (line); getCurrentDocument()->insertObj (idx++, pasted); pasted->select(); - R()->compileObject (pasted); ++num; } @@ -136,7 +135,6 @@ LDObject* newobj = parseLine (line); getCurrentDocument()->insertObj (idx++, newobj); newobj->select(); - g_win->R()->compileObject (newobj); } // Delete the subfile now as it's been inlined. @@ -180,13 +178,7 @@ // after the first one. getCurrentDocument()->setObject (index, triangles[0]); getCurrentDocument()->insertObj (index + 1, triangles[1]); - - for (LDTriangle* t : triangles) - R()->compileObject (t); - - // Delete this quad now, it has been split. obj->destroy(); - num++; } @@ -216,17 +208,12 @@ ui.errorIcon->hide(); } - if (!dlg->exec()) + if (dlg->exec() == QDialog::Rejected) return; - LDObject* oldobj = obj; - // Reinterpret it from the text of the input field - obj = parseLine (ui.code->text()); - oldobj->replace (obj); - - // Refresh - R()->compileObject (obj); + LDObject* newobj = parseLine (ui.code->text()); + obj->replace (newobj); refresh(); } @@ -255,7 +242,6 @@ continue; obj->setColor (colnum); - R()->compileObject (obj); } refresh(); @@ -304,7 +290,6 @@ lines[i]->setColor (edgecolor); getCurrentDocument()->insertObj (idx, lines[i]); - R()->compileObject (lines[i]); } num += numLines; @@ -332,9 +317,7 @@ LDVertex* vert = new LDVertex; vert->pos = obj->vertex (i); vert->setColor (obj->color()); - getCurrentDocument()->insertObj (++ln, vert); - R()->compileObject (vert); ++num; } } @@ -384,15 +367,10 @@ vect[X] *= *currentGrid().confs[Grid::X]; vect[Y] *= *currentGrid().confs[Grid::Y]; vect[Z] *= *currentGrid().confs[Grid::Z]; - QTime t0 = QTime::currentTime(); for (LDObject* obj : selection()) - { obj->move (vect); - g_win->R()->compileObject (obj); - } - dprint ("Move: %1ms\n", t0.msecsTo (QTime::currentTime())); g_win->refresh(); } @@ -435,10 +413,7 @@ LDObjectList sel = selection(); for (LDObject* obj : sel) - { obj->invert(); - R()->compileObject (obj); - } refresh(); } @@ -510,8 +485,6 @@ rotateVertex (v, rotpoint, transform); vert->pos = v; } - - g_win->R()->compileObject (obj); } g_win->refresh(); @@ -587,7 +560,6 @@ roundToDecimals (v[ax], 3); obj->setVertex (i, v); - R()->compileObject (obj); num += 3; } } @@ -615,7 +587,6 @@ col = edgecolor; obj->setColor (col); - R()->compileObject (obj); num++; } @@ -667,7 +638,6 @@ } obj->setVertex (i, v); - R()->compileObject (obj); } } @@ -702,7 +672,6 @@ v[ax] *= -1; obj->setVertex (i, v); - R()->compileObject (obj); } } @@ -721,8 +690,7 @@ if (obj->type() != LDObject::ECondLine) continue; - LDLine* repl = static_cast<LDCondLine*> (obj)->demote(); - R()->compileObject (repl); + static_cast<LDCondLine*> (obj)->demote(); ++num; } @@ -762,7 +730,6 @@ continue; obj->setColor (colnum); - R()->compileObject (obj); } print (tr ("Auto-colored: new color is [%1] %2"), colnum, getColor (colnum)->name);
--- a/src/actions/MainActions.cc Mon Mar 10 01:16:00 2014 +0200 +++ b/src/actions/MainActions.cc Mon Mar 10 13:26:02 2014 +0200 @@ -35,6 +35,7 @@ #include "../Primitives.h" #include "../Widgets.h" #include "../Colors.h" +#include "../GLCompiler.h" #include "ui_newpart.h" extern_cfg (Bool, gl_wireframe); @@ -471,7 +472,6 @@ getCurrentDocument()->insertObj (idx, obj); obj->select(); - R()->compileObject (obj); idx++; } @@ -847,9 +847,7 @@ obj->destroy(); // Compile all objects in the new subfile - for (LDObject* obj : doc->objects()) - R()->compileObject (obj); - + R()->compiler()->compileDocument (doc); g_loadedFiles << doc; // Add a reference to the new subfile to where the selection was @@ -870,4 +868,4 @@ // Failed to save. delete doc; } -} \ No newline at end of file +}