Mon, 05 Mar 2018 22:42:54 +0200
Finally removed the cancer that is the LDObject::model pointer
--- a/src/linetypes/modelobject.cpp Mon Mar 05 22:40:34 2018 +0200 +++ b/src/linetypes/modelobject.cpp Mon Mar 05 22:42:54 2018 +0200 @@ -131,13 +131,6 @@ // ============================================================================= // -void LDObject::setDocument (Model* model) -{ - _model = model; -} - -// ============================================================================= -// static void TransformObject (LDObject* obj, Matrix transform, Vertex pos, LDColor parentcolor) { switch (obj->type()) @@ -290,11 +283,6 @@ return m_randomColor; } -Model* LDObject::model() const -{ - return _model; -} - // ============================================================================= // LDObject* LDObject::fromID(qint32 id)
--- a/src/linetypes/modelobject.h Mon Mar 05 22:40:34 2018 +0200 +++ b/src/linetypes/modelobject.h Mon Mar 05 22:42:54 2018 +0200 @@ -68,7 +68,6 @@ virtual QString asText() const = 0; // This object as LDraw code LDColor color() const; virtual LDColor defaultColor() const; // What color does the object default to? - Model* model() const; LDPolygon* getPolygon(); virtual void getVertices (DocumentManager *context, QSet<Vertex>& verts) const; virtual bool hasMatrix() const; // Does this object have a matrix and position? (see LDMatrixObject) @@ -99,15 +98,12 @@ void codeChanged(const LDObjectState& before, const LDObjectState& after); protected: - void setDocument(Model* model); - template<typename T> void changeProperty(T* property, const T& value); private: bool m_hasInvertNext = false; bool m_isHidden; - Model* _model; qint32 m_id; LDColor m_color; QColor m_randomColor;
--- a/src/toolsets/movetoolset.cpp Mon Mar 05 22:40:34 2018 +0200 +++ b/src/toolsets/movetoolset.cpp Mon Mar 05 22:42:54 2018 +0200 @@ -40,16 +40,15 @@ int start = up ? 0 : (countof(objs) - 1); int end = up ? countof(objs) : -1; int increment = up ? 1 : -1; - Model* model = (*objs.begin())->model(); for (int i = start; i != end; i += increment) { LDObject* obj = objs[i]; - int idx = model->indexOf(obj).row(); + int idx = currentDocument()->indexOf(obj).row(); int target = idx + (up ? -1 : 1); - if ((up and idx == 0) or (not up and idx == countof(model->objects()) - 1)) + if ((up and idx == 0) or (not up and idx == countof(currentDocument()->objects()) - 1)) { // One of the objects hit the extrema. If this happens, this should be the first // object to be iterated on. Thus, nothing has changed yet and it's safe to just @@ -57,7 +56,7 @@ return; } - model->swapObjects(obj, model->getObject(target)); + currentDocument()->swapObjects(obj, currentDocument()->getObject(target)); } }