Flowgraph bug - and workaround. |
Post Reply |
Author | |
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
Posted: 03 March 2011 at 8:58pm |
I must say that the new chart material is great! You folks did a wonderful job.
The Flowgraph control was an unexpected bonus as I had an immediate use for it. While I was implementing I noticed that if you try to delete a node with CXTPFlowGraphConnections (not just CXTPFlowGraphConnectionPoints) the system goes into spasms. Before removing any node that has connection points with connections to it or any connection points with connections to it, you must remove the connections first. This is a little messy but I found the following works: // where pNode is the CXTPFlowGraphNode you want to toss for (int i = 0; i < pNode->GetConnectionPoints()->GetCount(); i++) { pConnectionPoint = pNode->GetConnectionPoints()->GetAt(i); if (pConnectionPoint->GetConnectionsCount()) { CXTPFlowGraphConnections* pConnections = pNode->GetControl()->GetActivePage()->GetConnections(); CXTPFlowGraphConnection* pConnection; for(int i = pConnections->GetCount()-1; i >= 0; i--) { pConnection = pConnections->GetAt(i); if (pConnection->GetInputPoint() == pConnectionPoint || pConnection->GetOutputPoint() == pConnectionPoint) pConnection->Remove(); } } } After that you can call RemoveAll for the connection points, and finally toss the node. Since there's no reference from the node or connection points to the connections there's no simple way to do a deep delete. There is a reference back to the connection points from the connections which is what I ended up using in this method. Unfortunately, that means you have to iterate all the connections on the control to remove the ones associated with the node which could be tedious if there were an inordinate number of them. Please, if anyone has a better way to do this let me know and it will be some more fun for the Codejock people to work on. |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hello,
Can you specify scenario when we can see problem. We remove all connections in CXTPFlowGraphNode::OnRemoved so they removed before Node deleted.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
|
The problem occurs when I remove a single CXTPFlowGraphConnectionPoint from the Node. This is likely because it's beyond the design parameters of the code, but it would be a useful function.
Removing the entire Node works perfectly. Removing a single point from the Node fails. There is another side effect I've discovered. The Node will not consistently resize properly after removing a point. Sometimes it works, sometimes it doesn't. I'm not sure why yet. The node will either retain the original size box or will shrink the y coordinate properly. This occurs using the same code example as follows: void My_View::RemoveConnectionPoint(CXTPFlowGraphConnectionPoint *point) { // kludge to remove associated connections if (point->GetConnectionsCount()) { CXTPFlowGraphConnection* pConnection = NULL; CXTPFlowGraphConnections* pConnections = GetControl()->GetActivePage()->GetConnections(); for (int i = pConnections->GetCount()-1; i >= 0; i--) { pConnection = pConnections->GetAt(i); if (pConnection->GetInputPoint() == point || pConnection->GetOutputPoint() == point) pConnection->Remove(); } } // we can now remove the Point from the Node CXTPFlowGraphNode *pNode = point->GetNode(); pNode->GetConnectionPoints()->Remove(point); // I would have expected the Node box to shrink accordingly and it does. But only sometimes. } |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hello,
Thanks, agree this one about ConnectionPoint, we added code to clean it. |
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
|
"The Node will not consistently resize properly after removing a point. Sometimes it works, sometimes it doesn't. I'm not sure why yet. The node will either retain the original size box or will shrink the y coordinate properly." Isolated this issue. The CSize m_szUserSize Node property was the culprit. if m_szUserSize.cy is anything other than 0, the Node will size to that automatically (by design). To solve, whenever I need to set a user width but not a user height, I set the cy to 0. userSize.cy = 0; pNode->SetSize(userSize); I'd say this isn't a bug but something to watch for in coding if you are using the user size options. |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |