-
Bug
-
Resolution: Invalid
-
P3: Somewhat important
-
6.11
-
None
In https://codereview.qt-project.org/c/qt/qtdeclarative/+/638956 we have this code:
void QQuickDeleteAction::componentComplete() { connect(this, &QQuickAction::triggered, [this]() { QQuickItem *editor = d_func()->editor; const int selectionStart = editor->property("selectionStart").value<int>(); const int selectionEnd = editor->property("selectionEnd").value<int>(); QMetaObject::invokeMethod(editor, "remove", selectionStart, selectionEnd); }); #if !QT_CONFIG(clipboard) setEnabled(false); return; #endif const QString enabledPropertyName = "enabled"_L1; auto *ourQmlContext = qmlContext(this); const QQmlProperty enabledProperty(this, enabledPropertyName, ourQmlContext); // Only install our binding if the user hasn't set one. if (QQmlPropertyPrivate::binding(enabledProperty)) return; // Bind the enabled property to the following QML expression: const QString expression = "editor ? !editor.readOnly && editor.selectedText.length > 0 : false"_L1; const QQmlScriptString scriptString = QQmlScriptStringPrivate::create(expression, ourQmlContext, this); auto newBinding = QQmlAnyBinding::createFromScriptString( enabledProperty, scriptString, this, ourQmlContext); newBinding.installOn(enabledProperty); }
The resultant binding is evaluated on all platforms except QNX, leading to this failure:
agent:2025/09/02 11:10:11 build.go:413: FAIL! : tst_QQuickTextArea::Basic::contextMenuDelete() 'deleteMenuItem->isEnabled()' returned FALSE. (Expected deleteMenuItem to be enabled; editor.readOnly: 0 editor.selectedText: " mori") agent:2025/09/02 11:10:11 build.go:413: Loc: [/home/qt/work/qt/qtdeclarative/tests/auto/quickcontrols/qquicktextarea/tst_qquicktextarea.cpp(421)]
In https://codereview.qt-project.org/c/qt/qtdeclarative/+/638956/62/src/quicktemplates/qquickdeleteaction.cpp#50, I added debugging code to verify this:
const QString expression = "(() => { print('@@@ editor', editor); return editor ? !editor.readOnly && editor.selectedText.length > 0 : false })()"_L1;
It doesn't show up in the output.