From 86bf399682f58bb2d040293ec8320676d37fd84a Mon Sep 17 00:00:00 2001 From: blobfish Date: Sat, 15 Aug 2015 13:07:34 -0400 Subject: [PATCH] Core: Gui: DAGView: delay retrieval for python features. see following note. This doesn't work on document restore! --- src/Gui/DAGView/DAGModel.cpp | 19 +++++++++++++++++++ src/Gui/DAGView/DAGModel.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/src/Gui/DAGView/DAGModel.cpp b/src/Gui/DAGView/DAGModel.cpp index 45e004995..88e4f025b 100644 --- a/src/Gui/DAGView/DAGModel.cpp +++ b/src/Gui/DAGView/DAGModel.cpp @@ -248,6 +248,22 @@ void Model::slotNewObject(const ViewProviderDocumentObject &VPDObjectIn) (*theGraph)[virginVertex].text->setFont(this->font()); graphDirty = true; + + //we are here before python objects are instantiated. so at this point + //the getIcon method doesn't reflect the python override. + //so we hack in a delay to get the latest icon and set it for the graphics item. + lastAddedVertex = virginVertex; + QTimer::singleShot(0, this, SLOT(iconUpdateSlot())); +} + +void Model::iconUpdateSlot() +{ + if (lastAddedVertex == Graph::null_vertex()) + return; + const ViewProviderDocumentObject *VPDObject = findRecord(lastAddedVertex, *graphLink).VPDObject; + (*theGraph)[lastAddedVertex].icon->setPixmap(VPDObject->getIcon().pixmap(iconSize, iconSize)); + lastAddedVertex = Graph::null_vertex(); + this->invalidate(); } void Model::slotDeleteObject(const ViewProviderDocumentObject &VPDObjectIn) @@ -265,6 +281,9 @@ void Model::slotDeleteObject(const ViewProviderDocumentObject &VPDObjectIn) for (auto inEdgeIt = inRange.first; inEdgeIt != inRange.second; ++inEdgeIt) this->removeItem((*theGraph)[*inEdgeIt].connector.get()); + if (vertex == lastAddedVertex) + lastAddedVertex = Graph::null_vertex(); + //remove the actual vertex. boost::clear_vertex(vertex, *theGraph); boost::remove_vertex(vertex, *theGraph); diff --git a/src/Gui/DAGView/DAGModel.h b/src/Gui/DAGView/DAGModel.h index 635ca87fe..ae9e5f841 100644 --- a/src/Gui/DAGView/DAGModel.h +++ b/src/Gui/DAGView/DAGModel.h @@ -81,6 +81,7 @@ namespace Gui void renameRejectedSlot(); void editingStartSlot(); void editingFinishedSlot(); + void iconUpdateSlot(); //!< needed because python objects are not ready. private: Model(){} @@ -150,6 +151,7 @@ namespace Gui QPixmap passPixmap; QPixmap failPixmap; QPixmap pendingPixmap; + Vertex lastAddedVertex = Graph::null_vertex(); //!< needed because python objects are not ready. QAction *renameAction; QAction *editingFinishedAction;