EMotion FX: Keyboard hotkeys can be used while creating a transition in Anim Graph after pressing the RMB which may lead to a crash (#4728)

Resolves #2934

Signed-off-by: Benjamin Jillich <jillich@amazon.com>
This commit is contained in:
Benjamin Jillich
2021-10-18 09:58:53 +02:00
committed by GitHub
parent b58ae15d83
commit bc29e57bbd
3 changed files with 30 additions and 20 deletions
@@ -1061,12 +1061,8 @@ namespace EMStudio
return true;
}
if (m_activeGraph->GetCreateConnectionNode()->GetType() == StateGraphNode::TYPE_ID)
{
return false;
}
return true;
const GraphNode* graphNode = m_activeGraph->GetCreateConnectionNode();
return graphNode && graphNode->GetType() != StateGraphNode::TYPE_ID;
}
@@ -57,7 +57,6 @@ namespace EMStudio
m_conEndOffset = QPoint(0, 0);
m_conPortNr = InvalidIndex16;
m_conIsInputPort = true;
m_conNode = nullptr; // nullptr when no connection is being created
m_conPort = nullptr;
m_conIsValid = false;
m_targetPort = nullptr;
@@ -151,6 +150,16 @@ namespace EMStudio
return connections;
}
bool NodeGraph::GetIsCreatingConnection() const
{
return (GetCreateConnectionNode() && !m_relinkConnection);
}
bool NodeGraph::GetIsRelinkingConnection() const
{
return (GetCreateConnectionNode() && m_relinkConnection);
}
void NodeGraph::DrawOverlay(QPainter& painter)
{
EMotionFX::AnimGraphInstance* animGraphInstance = m_currentModelIndex.data(AnimGraphModel::ROLE_ANIM_GRAPH_INSTANCE).value<EMotionFX::AnimGraphInstance*>();
@@ -1495,7 +1504,7 @@ namespace EMStudio
{
m_conPortNr = portNr;
m_conIsInputPort = isInputPort;
m_conNode = portNode;
m_conNodeIndex = portNode->GetModelIndex();
m_conPort = port;
m_conStartOffset = startOffset;
}
@@ -1505,7 +1514,7 @@ namespace EMStudio
void NodeGraph::StartRelinkConnection(NodeConnection* connection, AZ::u16 portNr, GraphNode* node)
{
m_conPortNr = portNr;
m_conNode = node;
m_conNodeIndex = node->GetModelIndex();
m_relinkConnection = connection;
//MCore::LogInfo( "StartRelinkConnection: Connection=(%s->%s) portNr=%i, graphNode=%s", connection->GetSourceNode()->GetName(), connection->GetTargetNode()->GetName(), portNr, node->GetName() );
@@ -1563,32 +1572,27 @@ namespace EMStudio
m_replaceTransitionTail = nullptr;
}
// reset members
void NodeGraph::StopRelinkConnection()
{
m_conPortNr = InvalidIndex16;
m_conNode = nullptr;
m_conNodeIndex = {};
m_relinkConnection = nullptr;
m_conIsValid = false;
m_targetPort = nullptr;
}
// reset members
void NodeGraph::StopCreateConnection()
{
m_conPortNr = InvalidIndex16;
m_conIsInputPort = true;
m_conNode = nullptr; // nullptr when no connection is being created
m_conNodeIndex = {};
m_conPort = nullptr;
m_targetPort = nullptr;
m_conIsValid = false;
}
// render the connection we're creating, if any
void NodeGraph::RenderReplaceTransition(QPainter& painter)
{
@@ -1628,6 +1632,16 @@ namespace EMStudio
}
}
GraphNode* NodeGraph::GetCreateConnectionNode() const
{
NodeGraph* activeGraph = m_graphWidget->GetActiveGraph();
if (!activeGraph)
{
return nullptr;
}
return activeGraph->FindGraphNode(m_conNodeIndex);
}
// render the connection we're creating, if any
void NodeGraph::RenderCreateConnection(QPainter& painter)
@@ -56,8 +56,8 @@ namespace EMStudio
void SetScrollOffset(const QPoint& offset) { m_scrollOffset = offset; }
void SetScalePivot(const QPoint& pivot) { m_scalePivot = pivot; }
float GetLowestScale() const { return sLowestScale; }
bool GetIsCreatingConnection() const { return (m_conNode && m_relinkConnection == nullptr); }
bool GetIsRelinkingConnection() const { return (m_conNode && m_relinkConnection); }
bool GetIsCreatingConnection() const;
bool GetIsRelinkingConnection() const;
void SetCreateConnectionIsValid(bool isValid) { m_conIsValid = isValid; }
bool GetIsCreateConnectionValid() const { return m_conIsValid; }
void SetTargetPort(NodePort* port) { m_targetPort = port; }
@@ -79,7 +79,7 @@ namespace EMStudio
bool GetReplaceTransitionValid() const { return m_replaceTransitionValid; }
void RenderReplaceTransition(QPainter& painter);
GraphNode* GetCreateConnectionNode() { return m_conNode; }
GraphNode* GetCreateConnectionNode() const;
NodeConnection* GetRelinkConnection() { return m_relinkConnection; }
AZ::u16 GetCreateConnectionPortNr() const { return m_conPortNr; }
bool GetCreateConnectionIsInputPort() const { return m_conIsInputPort; }
@@ -199,7 +199,7 @@ namespace EMStudio
QPoint m_conEndOffset;
AZ::u16 m_conPortNr;
bool m_conIsInputPort;
GraphNode* m_conNode; // nullptr when no connection is being created
QModelIndex m_conNodeIndex;
NodeConnection* m_relinkConnection; // nullptr when not relinking a connection
NodePort* m_conPort;
NodePort* m_targetPort;