# HG changeset patch # User Teemu Piippo # Date 1440240680 -10800 # Node ID af81220741d94fd1cfe2c84eaeb9521c1e3bc239 # Parent 147497785496fce7edfb4818772e4ada23e97766 Commit work done on code cleanup diff -r 147497785496 -r af81220741d9 src/actions.cc --- a/src/actions.cc Mon Dec 01 05:10:22 2014 +0200 +++ b/src/actions.cc Sat Aug 22 13:51:20 2015 +0300 @@ -179,56 +179,56 @@ // void MainWindow::slot_actionNewSubfile() { - AddObjectDialog::staticDialog (OBJ_Subfile, LDObjectPtr()); + AddObjectDialog::staticDialog (OBJ_Subfile, nullptr); } // ============================================================================= // void MainWindow::slot_actionNewLine() { - AddObjectDialog::staticDialog (OBJ_Line, LDObjectPtr()); + AddObjectDialog::staticDialog (OBJ_Line, nullptr); } // ============================================================================= // void MainWindow::slot_actionNewTriangle() { - AddObjectDialog::staticDialog (OBJ_Triangle, LDObjectPtr()); + AddObjectDialog::staticDialog (OBJ_Triangle, nullptr); } // ============================================================================= // void MainWindow::slot_actionNewQuad() { - AddObjectDialog::staticDialog (OBJ_Quad, LDObjectPtr()); + AddObjectDialog::staticDialog (OBJ_Quad, nullptr); } // ============================================================================= // void MainWindow::slot_actionNewCLine() { - AddObjectDialog::staticDialog (OBJ_CondLine, LDObjectPtr()); + AddObjectDialog::staticDialog (OBJ_CondLine, nullptr); } // ============================================================================= // void MainWindow::slot_actionNewComment() { - AddObjectDialog::staticDialog (OBJ_Comment, LDObjectPtr()); + AddObjectDialog::staticDialog (OBJ_Comment, nullptr); } // ============================================================================= // void MainWindow::slot_actionNewBFC() { - AddObjectDialog::staticDialog (OBJ_BFC, LDObjectPtr()); + AddObjectDialog::staticDialog (OBJ_BFC, nullptr); } // ============================================================================= // void MainWindow::slot_actionNewVertex() { - AddObjectDialog::staticDialog (OBJ_Vertex, LDObjectPtr()); + AddObjectDialog::staticDialog (OBJ_Vertex, nullptr); } // ============================================================================= diff -r 147497785496 -r af81220741d9 src/editHistory.cc --- a/src/editHistory.cc Mon Dec 01 05:10:22 2014 +0200 +++ b/src/editHistory.cc Sat Aug 22 13:51:20 2015 +0300 @@ -131,7 +131,7 @@ // void AddHistory::undo() const { - LDObjectPtr obj = parent()->document().toStrongRef()->getObject (index()); + LDObjectPtr obj = parent()->document()->getObject (index()); obj->destroy(); } @@ -140,7 +140,7 @@ void AddHistory::redo() const { LDObjectPtr obj = ParseLine (code()); - parent()->document().toStrongRef()->insertObj (index(), obj); + parent()->document()->insertObj (index(), obj); g_win->R()->compileObject (obj); } @@ -156,7 +156,7 @@ void DelHistory::undo() const { LDObjectPtr obj = ParseLine (code()); - parent()->document().toStrongRef()->insertObj (index(), obj); + parent()->document()->insertObj (index(), obj); g_win->R()->compileObject (obj); } @@ -164,7 +164,7 @@ // void DelHistory::redo() const { - LDObjectPtr obj = parent()->document().toStrongRef()->getObject (index()); + LDObjectPtr obj = parent()->document()->getObject (index()); obj->destroy(); } diff -r 147497785496 -r af81220741d9 src/glCompiler.cc --- a/src/glCompiler.cc Mon Dec 01 05:10:22 2014 +0200 +++ b/src/glCompiler.cc Sat Aug 22 13:51:20 2015 +0300 @@ -235,14 +235,14 @@ obj->document()->getDisplayName(), obj->lineNumber(), obj->typeName()); */ - m_staged << LDObjectWeakPtr (obj); + m_staged << obj; } // ============================================================================= // void GLCompiler::unstage (LDObjectPtr obj) { - m_staged.removeOne (LDObjectWeakPtr (obj)); + m_staged.removeOne (obj); } // ============================================================================= @@ -293,8 +293,8 @@ continue; } - if (it.key().toStrongRef()->document() == CurrentDocument() - and not it.key().toStrongRef()->isHidden()) + if (it.key()->document() == CurrentDocument() + and not it.key()->isHidden()) { vbodata += it->data[vbonum]; } @@ -331,7 +331,7 @@ { // print ("Compile %1\n", g_objectOrigins[obj]); - if (obj == null or obj->document() == null or obj->document().toStrongRef()->isImplicit()) + if (obj == null or obj->document() == null or obj->document()->isImplicit()) return; ObjectVBOInfo info; diff -r 147497785496 -r af81220741d9 src/glRenderer.cc --- a/src/glRenderer.cc Mon Dec 01 05:10:22 2014 +0200 +++ b/src/glRenderer.cc Sat Aug 22 13:51:20 2015 +0300 @@ -1553,7 +1553,7 @@ newIndex = pixel[0] * 0x10000 | pixel[1] * 0x100 | pixel[2]; } - if (newIndex != (oldObject != null ? oldObject.toStrongRef()->id() : 0)) + if (newIndex != (oldObject != null ? oldObject->id() : 0)) { if (newIndex != 0) newObject = LDObject::fromID (newIndex); diff -r 147497785496 -r af81220741d9 src/ldDocument.cc --- a/src/ldDocument.cc Mon Dec 01 05:10:22 2014 +0200 +++ b/src/ldDocument.cc Sat Aug 22 13:51:20 2015 +0300 @@ -160,7 +160,7 @@ if (IsExiting()) return; - g_allDocuments.removeOne (self()); + g_allDocuments.removeOne (this); m_flags |= DOCF_IsBeingDestroyed; delete m_history; delete m_gldata; @@ -176,17 +176,17 @@ if (a == false) { - g_explicitDocuments << self().toStrongRef(); + g_explicitDocuments << this; print ("Opened %1", name()); // Implicit files are not compiled by the GL renderer. Now that this // part is no longer implicit, it needs to be compiled. if (g_win != null) - g_win->R()->compiler()->compileDocument (self()); + g_win->R()->compiler()->compileDocument (this); } else { - g_explicitDocuments.removeOne (self().toStrongRef()); + g_explicitDocuments.removeOne (this); print ("Closed %1", name()); } @@ -195,7 +195,7 @@ // If the current document just became implicit (e.g. it was 'closed'), // we need to get a new current document. - if (current() == self() and isImplicit()) + if (current() == this and isImplicit()) { if (explicitDocuments().isEmpty()) newFile(); @@ -221,7 +221,7 @@ if (weakfile == null) continue; - LDDocumentPtr file (weakfile.toStrongRef()); + LDDocumentPtr file (weakfile); if (Eq (name, file->name(), file->defaultName())) return file; @@ -281,7 +281,7 @@ if (doc == null) continue; - QString partpath = format ("%1/%2", Dirname (doc.toStrongRef()->fullPath()), relpath); + QString partpath = format ("%1/%2", Dirname (doc->fullPath()), relpath); QFile f (partpath); if (f.exists()) @@ -582,7 +582,8 @@ // If we have unsaved changes, warn and give the option of saving. if (hasUnsavedChanges()) { - QString message = format (QObject::tr ("There are unsaved changes to %1. Should it be saved?"), getDisplayName()); + QString message = format (QObject::tr ("There are unsaved changes to %1. Should it be saved?"), +getDisplayName()); int button = msgbox::question (g_win, QObject::tr ("Unsaved Changes"), message, (msgbox::Yes | msgbox::No | msgbox::Cancel), msgbox::Cancel); @@ -690,7 +691,7 @@ for (LDDocumentWeakPtr doc : g_allDocuments) { - if (doc != null and doc.toStrongRef()->name() == shortName) + if (doc != null and doc->name() == shortName) { documentToReplace = doc; break; @@ -826,7 +827,7 @@ setFullPath (path); setName (shortenName (path)); - g_win->updateDocumentListItem (self().toStrongRef()); + g_win->updateDocumentListItem (this); g_win->updateTitle(); return true; } @@ -1138,7 +1139,7 @@ m_needsReCache = true; - if (self() == CurrentDocument()) + if (this == CurrentDocument()) g_win->buildObjList(); } @@ -1149,7 +1150,7 @@ history()->add (new AddHistory (objects().size(), obj)); m_objects << obj; addKnownVertices (obj); - obj->setDocument (self()); + obj->setDocument (this); g_win->R()->compileObject (obj); return getObjectCount() - 1; } @@ -1171,7 +1172,7 @@ { history()->add (new AddHistory (pos, obj)); m_objects.insert (pos, obj); - obj->setDocument (self()); + obj->setDocument (this); g_win->R()->compileObject (obj); @@ -1244,7 +1245,7 @@ m_objectVertices.remove (m_objects[idx]); m_objects[idx]->deselect(); m_objects[idx]->setDocument (LDDocumentPtr()); - obj->setDocument (self()); + obj->setDocument (this); addKnownVertices (obj); g_win->R()->compileObject (obj); m_objects[idx] = obj; @@ -1255,10 +1256,10 @@ // LDObjectPtr LDDocument::getObject (int pos) const { - if (m_objects.size() <= pos) - return LDObjectPtr(); - - return m_objects[pos]; + if (pos < m_objects.size()) + return m_objects[pos]; + else + return nullptr; } // ============================================================================= @@ -1472,7 +1473,7 @@ if (obj->isSelected()) return; - assert (obj->document() == self()); + assert (obj->document() == this); m_sel << obj; g_win->R()->compileObject (obj); obj->setSelected (true); @@ -1485,7 +1486,7 @@ if (not obj->isSelected()) return; - assert (obj->document() == self()); + assert (obj->document() == this); m_sel.removeOne (obj); g_win->R()->compileObject (obj); obj->setSelected (false); diff -r 147497785496 -r af81220741d9 src/ldObject.cc --- a/src/ldObject.cc Mon Dec 01 05:10:22 2014 +0200 +++ b/src/ldObject.cc Sat Aug 22 13:51:20 2015 +0300 @@ -32,33 +32,38 @@ CFGENTRY (Bool, UseCALicense, true) // List of all LDObjects -QMap g_allObjects; -static int32 g_idcursor = 1; // 0 shalt be null -static constexpr int32 g_maxID = (1 << 24); +QMap g_allObjects; +static int32 g_idcursor = 1; // 0 shalt be null + +enum { MAX_LDOBJECT_IDS = (1 << 24) }; #define LDOBJ_DEFAULT_CTOR(T,BASE) \ - T :: T (LDObjectPtr* selfptr) : \ - BASE (selfptr) {} + T :: T (LDDocument* document) : \ + BASE (document) {} // ============================================================================= // LDObject constructors // -LDObject::LDObject (LDObjectPtr* selfptr) : +LDObject::LDObject (LDDocument* document) : m_isHidden (false), m_isSelected (false), m_isDestructed (false), qObjListEntry (null) { - *selfptr = LDObjectPtr (this, [](LDObject* obj){ obj->finalDelete(); }); + if (document) + document->addObject (this); + memset (m_coords, 0, sizeof m_coords); - m_self = selfptr->toWeakRef(); chooseID(); - g_allObjects[id()] = self(); + + if (id() != 0) + g_allObjects[id()] = this; + setRandomColor (QColor::fromHsv (rand() % 360, rand() % 256, rand() % 96 + 128)); } -LDSubfile::LDSubfile (LDObjectPtr* selfptr) : - LDMatrixObject (selfptr) {} +LDSubfile::LDSubfile (LDDocument* document) : + LDMatrixObject (document) {} LDOBJ_DEFAULT_CTOR (LDEmpty, LDObject) LDOBJ_DEFAULT_CTOR (LDError, LDObject) @@ -75,21 +80,11 @@ // void LDObject::chooseID() { - // If this is the first pass we can just use a global ID counter for each - // unique object. Let's hope that nobody goes to create 17 million objects - // anytime soon. - if (g_idcursor < g_maxID) - { + // Let's hope that nobody goes to create 17 million objects anytime soon... + if (g_idcursor < MAX_LDOBJECT_IDS) setID (g_idcursor++); - return; - } - - // In case someone does, we cannot really continue execution. We must abort, - // give the user a chance to save their documents though. - Critical ("Created too many objects. Execution cannot continue. You have a " - "chance to save any changes to documents, then restart."); - (void) IsSafeToCloseAll(); - Exit(); + else + setID (0); } // ============================================================================= @@ -220,8 +215,8 @@ // | | ==> | / / | // | | |/ / | // 1---2 1 1---2 - LDTrianglePtr tri1 (LDSpawn (vertex (0), vertex (1), vertex (3))); - LDTrianglePtr tri2 (LDSpawn (vertex (1), vertex (2), vertex (3))); + LDTrianglePtr tri1 (new LDTriangle (vertex (0), vertex (1), vertex (3))); + LDTrianglePtr tri2 (new LDTriangle (vertex (1), vertex (2), vertex (3))); // The triangles also inherit the quad's color tri1->setColor (color()); @@ -234,14 +229,16 @@ // void LDObject::replace (LDObjectPtr other) { - long idx = lineNumber(); - assert (idx != -1); + int idx = lineNumber(); - // Replace the instance of the old object with the new object - document().toStrongRef()->setObject (idx, other); + if (idx != -1) + { + // Replace the instance of the old object with the new object + document()->setObject (idx, other); - // Remove the old object - destroy(); + // Remove the old object + destroy(); + } } // ============================================================================= @@ -249,13 +246,13 @@ void LDObject::swap (LDObjectPtr other) { assert (document() == other->document()); - document().toStrongRef()->swapObjects (self(), other); + document()->swapObjects (self(), other); } // ============================================================================= // -LDLine::LDLine (LDObjectPtr* selfptr, Vertex v1, Vertex v2) : - LDObject (selfptr) +LDLine::LDLine (Vertex v1, Vertex v2, LDDocument* document) : + LDObject (document) { setVertex (0, v1); setVertex (1, v2); @@ -263,8 +260,8 @@ // ============================================================================= // -LDTriangle::LDTriangle (LDObjectPtr* selfptr, const Vertex& v1, const Vertex& v2, const Vertex& v3) : - LDObject (selfptr) +LDTriangle::LDTriangle (const Vertex& v1, const Vertex& v2, const Vertex& v3, LDDocument* document) : + LDObject (document) { setVertex (0, v1); setVertex (1, v2); @@ -273,9 +270,8 @@ // ============================================================================= // -LDQuad::LDQuad (LDObjectPtr* selfptr, const Vertex& v1, const Vertex& v2, - const Vertex& v3, const Vertex& v4) : - LDObject (selfptr) +LDQuad::LDQuad (const Vertex& v1, const Vertex& v2, const Vertex& v3, const Vertex& v4, LDDocument* document) : + LDObject (document) { setVertex (0, v1); setVertex (1, v2); @@ -285,9 +281,8 @@ // ============================================================================= // -LDCondLine::LDCondLine (LDObjectPtr* selfptr, const Vertex& v0, const Vertex& v1, - const Vertex& v2, const Vertex& v3) : - LDLine (selfptr) +LDCondLine::LDCondLine (const Vertex& v0, const Vertex& v1, const Vertex& v2, const Vertex& v3, LDDocument* document) : + LDLine (document) { setVertex (0, v0); setVertex (1, v1); @@ -313,7 +308,7 @@ // If this object was associated to a file, remove it off it now if (document() != null) - document().toStrongRef()->forgetObject (self()); + document()->forgetObject (self()); // Delete the GL lists if (g_win != null) @@ -337,7 +332,7 @@ // ============================================================================= // -void LDObject::setDocument (const LDDocumentWeakPtr& a) +void LDObject::setDocument (LDDocument* a) { m_document = a; @@ -447,9 +442,9 @@ { assert (document() != null); - for (int i = 0; i < document().toStrongRef()->getObjectCount(); ++i) + for (int i = 0; i < document()->getObjectCount(); ++i) { - if (document().toStrongRef()->getObject (i) == this) + if (document()->getObject (i) == this) return i; } @@ -548,53 +543,49 @@ // LDObjectPtr LDObject::topLevelParent() { - if (parent() == null) - return self(); - - LDObjectWeakPtr it (self()); + LDObject* it; + + for (it = self(); it->parent(); it = it->parent()) + ; - while (it.toStrongRef()->parent() != null) - it = it.toStrongRef()->parent(); - - return it.toStrongRef(); + return it; } // ============================================================================= // LDObjectPtr LDObject::next() const { - long idx = lineNumber(); + int idx = lineNumber(); assert (idx != -1); - if (idx == (long) document().toStrongRef()->getObjectCount() - 1) - return LDObjectPtr(); + if (idx == document()->getObjectCount() - 1) + return nullptr; - return document().toStrongRef()->getObject (idx + 1); + return document()->getObject (idx + 1); } // ============================================================================= // LDObjectPtr LDObject::previous() const { - long idx = lineNumber(); + int idx = lineNumber(); assert (idx != -1); if (idx == 0) - return LDObjectPtr(); + return nullptr; - return document().toStrongRef()->getObject (idx - 1); + return document()->getObject (idx - 1); } // ============================================================================= // -bool LDObject::previousIsInvertnext (LDBFCPtr& ptr) +bool LDObject::previousIsInvertnext (LDBFC*& ptr) { - LDObjectPtr prev (previous()); + LDObject* prev = previous(); - if (prev != null and prev->type() == OBJ_BFC and - prev.staticCast()->statement() == BFCStatement::InvertNext) + if (prev and prev->type() == OBJ_BFC and static_cast (prev)->statement() == BFCStatement::InvertNext) { - ptr = prev.staticCast(); + ptr = static_cast (prev); return true; } @@ -607,13 +598,13 @@ { if (hasMatrix()) { - LDMatrixObjectPtr mo = self().toStrongRef().dynamicCast(); + LDMatrixObject* mo = static_cast (this); mo->setPosition (mo->position() + vect); } - elif (type() == OBJ_Vertex) + else if (type() == OBJ_Vertex) { // ugh - self().toStrongRef().staticCast()->pos += vect; + static_cast (self)->pos += vect; } else { @@ -641,7 +632,7 @@ case OBJ_Overlay: return LDSpawn(); case OBJ_NumTypes: assert (false); } - return LDObjectPtr(); + return nullptr; } // ============================================================================= @@ -669,8 +660,8 @@ // void LDQuad::invert() { - // Quad: 0 -> 1 -> 2 -> 3 - // rev: 0 -> 3 -> 2 -> 1 + // Quad: 0 -> 1 -> 2 -> 3 + // reversed: 0 -> 3 -> 2 -> 1 // Thus, we swap 1 and 3. Vertex tmp = vertex (1); setVertex (1, vertex (3)); @@ -681,7 +672,7 @@ // void LDSubfile::invert() { - if (document() == null) + if (document() == nullptr) return; // Check whether subfile is flat @@ -743,7 +734,7 @@ } // Not inverted, thus prefix it with a new invertnext. - document().toStrongRef()->insertObj (idx, LDSpawn (BFCStatement::InvertNext)); + document->insertObj (idx, new LDBFC (BFCStatement::InvertNext)); } // ============================================================================= @@ -760,8 +751,7 @@ // void LDCondLine::invert() { - // I don't think that a conditional line's control points need to be - // swapped, do they? + // I don't think that a conditional line's control points need to be swapped, do they? Vertex tmp = vertex (0); setVertex (0, vertex (1)); setVertex (1, tmp); @@ -771,15 +761,14 @@ // ============================================================================= // -LDLinePtr LDCondLine::toEdgeLine() +LDLine* LDCondLine::toEdgeLine() { - LDLinePtr replacement (LDSpawn()); + LDLine* replacement = new LDLine; for (int i = 0; i < replacement->numVertices(); ++i) replacement->setVertex (i, vertex (i)); replacement->setColor (color()); - replace (replacement); return replacement; } @@ -793,7 +782,7 @@ if (it != g_allObjects.end()) return *it; - return LDObjectPtr(); + return nullptr; } // ============================================================================= @@ -815,12 +804,12 @@ template static void changeProperty (LDObjectPtr obj, T* ptr, const T& val) { - long idx; + int idx; if (*ptr == val) return; - if (obj->document() != null and (idx = obj->lineNumber()) != -1) + if (obj->document() and (idx = obj->lineNumber()) != -1) { QString before = obj->asText(); *ptr = val; @@ -828,13 +817,15 @@ if (before != after) { - obj->document().toStrongRef()->addToHistory (new EditHistory (idx, before, after)); + obj->document()->addToHistory (new EditHistory (idx, before, after)); g_win->R()->compileObject (obj); CurrentDocument()->redoVertices(); } } else + { *ptr = val; + } } // ============================================================================= @@ -876,30 +867,24 @@ // void LDObject::select() { - assert (document() != null); - document().toStrongRef()->addToSelection (self()); - - // If this object is inverted with INVERTNEXT, pick the INVERTNEXT as well. - /* - LDBFCPtr invertnext; - - if (previousIsInvertnext (invertnext)) - invertnext->select(); - */ + if (document() != null) + document()->addToSelection (self()); } // ============================================================================= // void LDObject::deselect() { - assert (document() != null); - document().toStrongRef()->removeFromSelection (self()); + if (document() != null) + { + document()->removeFromSelection (self()); - // If this object is inverted with INVERTNEXT, deselect the INVERTNEXT as well. - LDBFCPtr invertnext; + // If this object is inverted with INVERTNEXT, deselect the INVERTNEXT as well. + LDBFCPtr invertnext; - if (previousIsInvertnext (invertnext)) - invertnext->deselect(); + if (previousIsInvertnext (invertnext)) + invertnext->deselect(); + } } // ============================================================================= diff -r 147497785496 -r af81220741d9 src/ldObject.h --- a/src/ldObject.h Mon Dec 01 05:10:22 2014 +0200 +++ b/src/ldObject.h Sat Aug 22 13:51:20 2015 +0300 @@ -94,15 +94,15 @@ PROPERTY (public, bool, isHidden, setHidden, STOCK_WRITE) PROPERTY (public, bool, isSelected, setSelected, STOCK_WRITE) PROPERTY (public, bool, isDestructed, setDestructed, STOCK_WRITE) - PROPERTY (public, LDObjectWeakPtr, parent, setParent, STOCK_WRITE) - PROPERTY (public, LDDocumentWeakPtr, document, setDocument, CUSTOM_WRITE) + PROPERTY (public, LDObject*, parent, setParent, STOCK_WRITE) + PROPERTY (public, LDDocument*, document, setDocument, CUSTOM_WRITE) PROPERTY (private, int32, id, setID, STOCK_WRITE) PROPERTY (public, LDColor, color, setColor, CUSTOM_WRITE) PROPERTY (private, QColor, randomColor, setRandomColor, STOCK_WRITE) PROPERTY (private, LDObjectWeakPtr, self, setSelf, STOCK_WRITE) public: - LDObject (LDObjectPtr* selfptr); + LDObject (LDDocument* document = nullptr); // This object as LDraw code virtual QString asText() const = 0; @@ -218,18 +218,18 @@ // deleter so that all deletions go through finalDelete(); // template -inline QSharedPointer LDSpawn (Args... args) +T* LDSpawn (Args... args) { static_assert (std::is_base_of::value, "spawn may only be used with LDObject-derivatives"); - LDObjectPtr ptr; - new T (&ptr, args...); + T* result = new T (args..., nullptr); // Set default color. Relying on virtual functions, this cannot be done in the c-tor. - if (ptr->isColored()) - ptr->setColor (ptr->defaultColor()); + // TODO: store -1 as the default color + if (result->isColored()) + result->setColor (ptr->defaultColor()); - return ptr.staticCast(); + return result; } // @@ -258,12 +258,12 @@ Vertex m_position; public: - LDMatrixObject (LDObjectPtr* selfptr) : - LDObject (selfptr), + LDMatrixObject (LDDocument* document = nullptr) : + LDObject (documemnt), m_position (Origin) {} - LDMatrixObject (LDObjectPtr* selfptr, const Matrix& transform, const Vertex& pos) : - LDObject (selfptr), + LDMatrixObject (const Matrix& transform, const Vertex& pos, LDDocument* document = nullptr) : + LDObject (documemnt), m_transform (transform), m_position (pos) {} @@ -311,8 +311,8 @@ PROPERTY (private, QString, reason, setReason, STOCK_WRITE) public: - LDError (LDObjectPtr* selfptr, QString contents, QString reason) : - LDObject (selfptr), + LDError (QString contents, QString reason, LDDocument* document = nullptr) : + LDObject (document), m_contents (contents), m_reason (reason) {} }; @@ -352,8 +352,8 @@ LDOBJ_NO_MATRIX public: - LDComment (LDObjectPtr* selfptr, QString text) : - LDObject (selfptr), + LDComment (QString text, LDDocument* document = nullptr) : + LDObject (document), m_text (text) {} }; @@ -393,8 +393,8 @@ PROPERTY (public, BFCStatement, statement, setStatement, STOCK_WRITE) public: - LDBFC (LDObjectPtr* selfptr, const BFCStatement type) : - LDObject (selfptr), + LDBFC (const BFCStatement type, LDDocument* document = nullptr) : + LDObject (document), m_statement (type) {} // Statement strings @@ -457,7 +457,7 @@ LDOBJ_NO_MATRIX public: - LDLine (LDObjectPtr* selfptr, Vertex v1, Vertex v2); + LDLine (Vertex v1, Vertex v2, LDDocument* document = nullptr); }; using LDLinePtr = QSharedPointer; @@ -479,8 +479,7 @@ LDOBJ_NO_MATRIX public: - LDCondLine (LDObjectPtr* selfptr, const Vertex& v0, const Vertex& v1, - const Vertex& v2, const Vertex& v3); + LDCondLine (const Vertex& v0, const Vertex& v1, const Vertex& v2, const Vertex& v3, LDDocument* document = nullptr); LDLinePtr toEdgeLine(); }; @@ -505,8 +504,7 @@ LDOBJ_NO_MATRIX public: - LDTriangle (LDObjectPtr* selfptr, Vertex const& v1, - Vertex const& v2, Vertex const& v3); + LDTriangle (Vertex const& v1, Vertex const& v2, Vertex const& v3, LDDocument* document = nullptr); }; using LDTrianglePtr = QSharedPointer; @@ -529,8 +527,7 @@ LDOBJ_NO_MATRIX public: - LDQuad (LDObjectPtr* selfptr, const Vertex& v1, const Vertex& v2, - const Vertex& v3, const Vertex& v4); + LDQuad (const Vertex& v1, const Vertex& v2, const Vertex& v3, const Vertex& v4, LDDocument* document = nullptr); // Split this quad into two triangles QList splitToTriangles(); diff -r 147497785496 -r af81220741d9 src/mainWindow.cc --- a/src/mainWindow.cc Mon Dec 01 05:10:22 2014 +0200 +++ b/src/mainWindow.cc Sat Aug 22 13:51:20 2015 +0300 @@ -660,7 +660,7 @@ void MainWindow::spawnContextMenu (const QPoint pos) { const bool single = (Selection().size() == 1); - LDObjectPtr singleObj = single ? Selection().first() : LDObjectPtr(); + LDObjectPtr singleObj = single ? Selection().first() : nullptr; bool hasSubfiles = false;