Skip to content

Commit

Permalink
Core: Gui: DAGView: delay retrieval for python features. see followin…
Browse files Browse the repository at this point in the history
…g note.

    This doesn't work on document restore!
  • Loading branch information
blobfish authored and wwmayer committed May 7, 2016
1 parent 973dda6 commit 86bf399
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Gui/DAGView/DAGModel.cpp
Expand Up @@ -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)
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/Gui/DAGView/DAGModel.h
Expand Up @@ -81,6 +81,7 @@ namespace Gui
void renameRejectedSlot();
void editingStartSlot();
void editingFinishedSlot();
void iconUpdateSlot(); //!< needed because python objects are not ready.

private:
Model(){}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 86bf399

Please sign in to comment.