Permalink
Browse files

Fixed a crash when deleting nodes with loop edges

  • Loading branch information...
aelliott committed Apr 18, 2013
1 parent b96f0a9 commit 42cae71361bcb307fbb0c1ed88067e9e40607f36
Showing with 35 additions and 4 deletions.
  1. +26 −4 src/developer/graph.cpp
  2. +9 −0 src/developer/graphview/graphscene.cpp
View
@@ -330,10 +330,32 @@ std::vector<Edge *> Graph::edges(const QString &id) const
{
std::vector<Edge *> from = edgesFrom(id);
std::vector<Edge *> to = edgesTo(id);
for(size_t i = 0; i < from.size(); ++i)
result.push_back(from.at(i));
for(size_t i = 0; i < to.size(); ++i)
result.push_back(to.at(i));
for(edgeIter iter = from.begin(); iter != from.end(); ++iter)
{
Edge *e = *iter;
if(e == 0)
continue;
result.push_back(e);
}
for(edgeIter iter = to.begin(); iter != to.end(); ++iter)
{
Edge *e = *iter;
if(e == 0)
continue;
bool duplicate = false;
for(edgeIter fromIter = from.begin(); fromIter != from.end();
++fromIter)
{
Edge *from = *fromIter;
if(from == 0)
continue;
if(e->id() == from->id())
duplicate = true;
}
qDebug() << duplicate;
if(!duplicate)
result.push_back(e);
}
}
return result;
@@ -731,6 +731,8 @@ EdgeItem *GraphScene::edge(const QString &id) const
void GraphScene::removeEdge(EdgeItem *edge)
{
qDebug() << "Removing edge.";
qDebug() << "Edge: " << edge->id();
if(edge == 0)
{
qDebug() << "GraphScene::removeEdge() passed null pointer, ignoring";
@@ -762,10 +764,17 @@ void GraphScene::removeEdge(EdgeItem *edge)
void GraphScene::removeNode(NodeItem *node)
{
qDebug() << "Removing node.";
qDebug() << "Node: " << node->id();
if(node == 0)
{
qDebug() << "GraphScene::removeNode() passed null pointer, ignoring";
return;
}
qDebug() << "Getting edges";
std::vector<Edge *> edges = node->node()->edges();
qDebug() << "Got edges";
for(std::vector<Edge *>::iterator iter = edges.begin();
iter != edges.end(); ++iter)
{

0 comments on commit 42cae71

Please sign in to comment.