From 6ec68ca98a0b935b2f87add132f6552e0dd5fb5e Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Mon, 11 Sep 2023 12:58:03 +0200 Subject: [PATCH] QmlDesigner: Properly handle empty source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I46550e4210b966db26e719f6eec10d0eb3243d91 Reviewed-by: Henning Gründl --- .../connectioneditor/connectionmodel.cpp | 50 +++++++++++-------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp index 693829973aa..09ea8f70d88 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp @@ -737,6 +737,8 @@ int ConnectionModelBackendDelegate::currentRow() const QString removeOnFromSignalName(const QString &signal) { + if (signal.isEmpty()) + return {}; QString ret = signal; ret.remove(0, 2); ret[0] = ret.at(0).toLower(); @@ -903,29 +905,35 @@ void ConnectionModelBackendDelegate::setupHandlerAndStatements() QTC_ASSERT(model, return ); SignalHandlerProperty signalHandlerProperty = model->signalHandlerPropertyForRow(currentRow()); - m_handler = ConnectionEditorEvaluator::parseStatement(signalHandlerProperty.source()); - - const QString statementType = QmlDesigner::ConnectionEditorStatements::toDisplayName(m_handler); - - if (statementType == ConnectionEditorStatements::EMPTY_DISPLAY_NAME) { + if (signalHandlerProperty.source().isEmpty()) { m_actionType = ConnectionModelStatementDelegate::Custom; - } else if (statementType == ConnectionEditorStatements::ASSIGNMENT_DISPLAY_NAME) { - m_actionType = ConnectionModelStatementDelegate::Assign; - //setupAssignment(); - } else if (statementType == ConnectionEditorStatements::SETPROPERTY_DISPLAY_NAME) { - m_actionType = ConnectionModelStatementDelegate::SetProperty; - //setupSetProperty(); - } else if (statementType == ConnectionEditorStatements::FUNCTION_DISPLAY_NAME) { - m_actionType = ConnectionModelStatementDelegate::CallFunction; - //setupCallFunction(); - } else if (statementType == ConnectionEditorStatements::SETSTATE_DISPLAY_NAME) { - m_actionType = ConnectionModelStatementDelegate::ChangeState; - //setupChangeState(); - } else if (statementType == ConnectionEditorStatements::LOG_DISPLAY_NAME) { - m_actionType = ConnectionModelStatementDelegate::PrintMessage; - //setupPrintMessage(); + m_handler = ConnectionEditorStatements::EmptyBlock(); } else { - m_actionType = ConnectionModelStatementDelegate::Custom; + m_handler = ConnectionEditorEvaluator::parseStatement(signalHandlerProperty.source()); + + const QString statementType = QmlDesigner::ConnectionEditorStatements::toDisplayName( + m_handler); + + if (statementType == ConnectionEditorStatements::EMPTY_DISPLAY_NAME) { + m_actionType = ConnectionModelStatementDelegate::Custom; + } else if (statementType == ConnectionEditorStatements::ASSIGNMENT_DISPLAY_NAME) { + m_actionType = ConnectionModelStatementDelegate::Assign; + //setupAssignment(); + } else if (statementType == ConnectionEditorStatements::SETPROPERTY_DISPLAY_NAME) { + m_actionType = ConnectionModelStatementDelegate::SetProperty; + //setupSetProperty(); + } else if (statementType == ConnectionEditorStatements::FUNCTION_DISPLAY_NAME) { + m_actionType = ConnectionModelStatementDelegate::CallFunction; + //setupCallFunction(); + } else if (statementType == ConnectionEditorStatements::SETSTATE_DISPLAY_NAME) { + m_actionType = ConnectionModelStatementDelegate::ChangeState; + //setupChangeState(); + } else if (statementType == ConnectionEditorStatements::LOG_DISPLAY_NAME) { + m_actionType = ConnectionModelStatementDelegate::PrintMessage; + //setupPrintMessage(); + } else { + m_actionType = ConnectionModelStatementDelegate::Custom; + } } ConnectionEditorStatements::MatchedStatement &okStatement