ui: Fixed crash when changing tabs during animation (#1046)

Changing tabs during animation triggers a hover leave event on the focused node, which moves the focus to the parent node if available. This parent node however is still the old node, and deleted after the graph transition animation finishes, which leaves a dangling pointer.

closes #1021
This commit is contained in:
Eberhard Gräther
2020-06-29 01:05:53 +02:00
committed by GitHub
parent 673e26e290
commit 27558c42bb
2 changed files with 17 additions and 8 deletions
+15 -8
View File
@@ -91,19 +91,21 @@ void GraphFocusHandler::focusTokenId(
void GraphFocusHandler::refocusNode(
const std::list<QtGraphNode*>& newNodes, Id oldActiveTokenId, Id newActiveTokenId)
{
const Id lastFocusId = m_lastFocusId;
clear();
if (lastFocusId && (lastFocusId == newActiveTokenId || oldActiveTokenId == newActiveTokenId))
if (m_lastFocusId && (m_lastFocusId == newActiveTokenId || oldActiveTokenId == newActiveTokenId))
{
QtGraphNode* nodeToFocus = QtGraphNode::findNodeRecursive(newNodes, lastFocusId);
QtGraphNode* nodeToFocus = QtGraphNode::findNodeRecursive(newNodes, m_lastFocusId);
if (nodeToFocus)
{
m_focusNode = nodeToFocus;
m_lastFocusId = lastFocusId;
nodeToFocus->setIsFocused(true);
if (m_focusNode != nodeToFocus)
{
m_focusNode = nodeToFocus;
nodeToFocus->setIsFocused(true);
}
return;
}
}
clear();
}
void GraphFocusHandler::focusNext(Direction direction, bool navigateEdges)
@@ -180,6 +182,11 @@ void GraphFocusHandler::focusNode(QtGraphNode* node)
void GraphFocusHandler::defocusNode(QtGraphNode* node)
{
if (node != m_focusNode)
{
return;
}
QtGraphNode* parent = node->getParent();
while (parent && !parent->isFocusable())
{
+2
View File
@@ -937,6 +937,8 @@ void QtGraphView::updateTrailButtons()
void QtGraphView::switchToNewGraphData()
{
m_focusHandler.refocusNode(m_nodes, 0, 0);
m_oldGraph = m_graph;
for (QtGraphNode* node: m_oldNodes)