fix: comprehensive boot warnings and exceptions — fixable silenced, unfixable diagnosed

Build system (5 gaps hardened):
- COOKBOOK_OFFLINE defaults to true (fork-mode)
- normalize_patch handles diff -ruN format
- New 'repo validate-patches' command (25/25 relibc patches)
- 14 patched Qt/Wayland/display recipes added to protected list
- relibc archive regenerated with current patch chain

Boot fixes (fixable):
- Full ISO EFI partition: 16 MiB → 1 MiB (matches mini, BIOS hardcoded 2 MiB offset)
- D-Bus system bus: absolute /usr/bin/dbus-daemon path (was skipped)
- redbear-sessiond: absolute /usr/bin/redbear-sessiond path (was skipped)
- daemon framework: silenced spurious INIT_NOTIFY warnings for oneshot_async services (P0-daemon-silence-init-notify.patch)
- udev-shim: demoted INIT_NOTIFY warning to INFO (expected for oneshot_async)
- relibc: comprehensive named semaphores (sem_open/close/unlink) replacing upstream todo!() stubs
- greeterd: Wayland socket timeout 15s → 30s (compositor DRM wait)
- greeter-ui: built and linked (header guard unification, sem_compat stubs removed)
- mc: un-ignored in both configs, fixed glib/libiconv/pcre2 transitive deps
- greeter config: removed stale keymapd dependency from display/greeter services
- prefix toolchain: relibc headers synced, _RELIBC_STDLIB_H guard unified

Unfixable (diagnosed, upstream):
- i2c-hidd: abort on no-I2C-hardware (QEMU) — process::exit → relibc abort
- kded6/greeter-ui: page fault 0x8 — Qt library null deref
- Thread panics fd != -1 — Rust std library on Redox
- DHCP timeout / eth0 MAC — QEMU user-mode networking
- hwrngd/thermald — no hardware RNG/thermal in VM
- live preload allocation — BIOS memory fragmentation, continues on demand
This commit is contained in:
2026-05-05 20:20:37 +01:00
parent a5f97b6632
commit f31522130f
81834 changed files with 11051982 additions and 108 deletions
@@ -0,0 +1,54 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
cmake_minimum_required(VERSION 3.16)
project(tst_qmlcppcodegen LANGUAGES CXX)
find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
endif()
add_subdirectory(data)
qt_internal_add_test(tst_qmlcppcodegen
SOURCES
tst_qmlcppcodegen.cpp
LIBRARIES
Qt::Qml
Qt::QmlPrivate
Qt::QmlMetaPrivate
Qt::GuiPrivate
codegen_test_module
codegen_test_moduleplugin
codegen_test_hidden
codegen_test_hiddenplugin
codegen_test_stringbuilder
codegen_test_stringbuilderplugin
confused_test_module
confused_test_moduleplugin
with_subdir_test_module
with_subdir_test_moduleplugin
DEFINES
QT_NO_CAST_FROM_ASCII
)
qt_internal_add_test(tst_qmlcppcodegen_interpreted
SOURCES
tst_qmlcppcodegen.cpp
LIBRARIES
Qt::Qml
Qt::QmlPrivate
Qt::QmlMetaPrivate
Qt::GuiPrivate
codegen_test_module
codegen_test_moduleplugin
codegen_test_hidden
codegen_test_hiddenplugin
codegen_test_stringbuilder
codegen_test_stringbuilderplugin
confused_test_module
confused_test_moduleplugin
with_subdir_test_module
with_subdir_test_moduleplugin
DEFINES
QT_TEST_FORCE_INTERPRETER
)
@@ -0,0 +1,29 @@
// Copyright (C) 2020 The Qt Company Ltd.
import QtQuick 2.15
Item {
property real cost1: fruitModel.get(1).cost
property string name1: fruitModel.get(1).name
property real cost2: fruitModel.get(2).cost
property string name2: fruitModel.get(2).name
ListModel {
id: fruitModel
ListElement {
name: "Apple"
cost: 2.2
}
ListElement {
name: "Orange"
cost: 3
}
ListElement {
name: "Banana"
cost: 1.95
}
}
Component.onCompleted: {
console.log(fruitModel.data(fruitModel.index(1, 0), 0))
console.log(fruitModel.get(0).name)
}
}
@@ -0,0 +1,7 @@
import QtQuick
import QtQuick.Controls as QQC2
import QtQuick.Templates as T
QQC2.Action {
property bool visible: true
}
@@ -0,0 +1,11 @@
import QtQml
QtObject {
property alias theInner: anonymous
property QtObject inner: QtObject {
id: anonymous
property int a: 5
}
}
@@ -0,0 +1,19 @@
import QtQuick
import QtQml
Item {
id: container
transitions: [
// transition for global
Transition {
enabled: !container.animates
from: ""
to: "open"
ScriptAction {
script: container.isOpen = true
}
}
]
Keys.onPressed: a_event => {}
}
@@ -0,0 +1,24 @@
import QtQml
import TestTypes
QtObject {
property var seq: SequenceTypeExample {
id: mySequence
}
property int length: mySequence.qrealListProperty.length
function goodSequenceWrite() {
var someData = [1.1, 2.2, 3.3]
someData.length = 100;
for (var i = 0; i < 5; ++i) {
for (var j = 0; j < 100; ++j) {
someData[j] = j;
}
//Modifies entire sequence at once by copying a temp variable
mySequence.qrealListProperty = someData;
}
}
Component.onCompleted: goodSequenceWrite()
}
@@ -0,0 +1,5 @@
import QtQml
QtObject {
property rect r
}
@@ -0,0 +1,7 @@
import QtQuick
Item {
required property OkType picker
property bool useListDelegate: false
onUseListDelegateChanged: if (picker) picker.useListDelegate = useListDelegate
}
@@ -0,0 +1,9 @@
pragma Strict
import QtQml
QtObject {
property int satisfaction: Satisfaction.NONE
property QtObject output
function inputsKnown(mark: int) : bool { return true }
}
@@ -0,0 +1,9 @@
pragma Strict
import QtQml
QtObject {
id: self
property int ppp: 3
property int ppp2: ppp * 3
property int ppp3: self.ppp * 4
}
@@ -0,0 +1,40 @@
// Copyright (C) 2020 The Qt Company Ltd.
import QtQuick 2.15
Dummy {
id: root
y : 10;
width : 200;
height : root.width;
Dummy {
id: child;
height: 100;
y: root.y + (root.height - child.height) / 2;
}
property string mass: {
var result = "nothing";
if (child.y > 100)
result = "heavy";
else
result = "light";
return result;
}
property real test_division: width / 1000 + 50;
property real test_ternary: false ? 1 : true ? 2.2 : 1; // the type must be real
property int test_switch: {
switch (width % 3) {
case 0:
return 130;
case 1:
return 380;
case 2:
return 630;
}
}
}
@@ -0,0 +1,28 @@
pragma Strict
import QtQuick
Item {
id: root
height: 300
property bool c: false
Rectangle {
id: top
objectName: "top"
anchors.top: root.top
anchors.bottom: bottom.top
}
Rectangle {
id: bottom
objectName: "bottom"
anchors.top: root.verticalCenter
anchors.bottom: root.bottom
}
states: State {
when: root.c
AnchorChanges {
target: bottom
anchors.top: root.bottom
}
}
}
@@ -0,0 +1,597 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(Confused)
add_subdirectory(WithSubDir)
set(cpp_sources
ambiguous.h
birthdayparty.cpp birthdayparty.h
collector.h
convertQJSPrimitiveValueToIntegral.h
cppbaseclass.h
cppobj.h
detachedreferences.h
druggeljug.h
dummyobjekt.h
dynamicmeta.h
enumproblems.h
enumProperty.h
getOptionalLookup.h
gadgetwithenum.h
invisible.h
largeValueType.h
listprovider.h
listsingleton.h
multiforeign.h
objectwithmethod.h
person.cpp person.h
propertymap.h
qmlusing.h
recursiveObject.h
refuseWrite.h
resettable.h
scriptstringholder.h
sequenceToIterable.h
sequencetypeexample.cpp sequencetypeexample.h
shadowingSingleton.h
state.h
takenumber.cpp takenumber.h
theme.cpp theme.h
timelinetheme.cpp timelinetheme.h
variantMapLookup.h
variantreturn.h
weathermoduleurl.h
wrapwithvariant.h
withlength.h
)
set(qml_files
AccessModelMethodsFromOutside.qml
Action.qml
AnonymousComposite.qml
AnotherScriptString.qml
ArraySequenceLengthInterop.qml
B.qml
BadType.qml
BaseConstraint.qml
BaseMember.qml
BindingExpression.qml
BindingToScriptStringProperty.qml
Categorizer.qml
CategorizerBase.qml
CxxTypeFromDir.qml
CxxTypeFromImplicit.qml
Cycle1.qml
Cycle2.qml
Cycle3.qml
CppMethodListReturnType.qml
DeduplicateConversionOrigins.qml
Dummy.qml
Dummy2.qml
EditConstraint.qml
Enums.qml
FinalProperty.qml
Foozle.qml
GetOptionalLookupNonVoidableBase.qml
GetOptionalLookupOnQJSValueNonStrict.qml
GetOptionalLookupShadowed.qml
Loopy.qml
MyObject.qml
NotificationItem.qml
NotificationsUtils.js
OkType.qml
Panel.qml
Planner.qml
ProgressBar/Keyframe.qml
ProgressBar/KeyframeGroup.qml
ProgressBar/ProgressBar.ui.qml
ProgressBar/Root.qml
ProgressBar/Timeline.qml
ProgressBar/TimelineAnimation.qml
RootWithoutId.qml
Satisfaction.qml
SelectionRectangle.qml
ShadowedObjectName.qml
ShadowedObjectNameDerived.qml
StoreMetaEnum.qml
Test.qml
TestCase.qml
ValueTypeArgument.qml
Variable.qml
WindowDerived.qml
aliasLookup.qml
aliasToAliasResolutionSkipCorruption.qml
aliasToLocalAlias.qml
ambiguous1/Ambiguous.qml
ambiguous2/Ambiguous.qml
ambiguousAs.qml
ambiguousSignals.qml
anchorsFill.qml
anonymousCompositeUser.qml
argumentConversion.qml
array.qml
arrayCtor.qml
asCast.qml
attachedBaseEnum.qml
badSequence.qml
basicBlocksWithBackJump.qml
basicBlocksWithBackJump_infinite.qml
basicDTZ.qml
bindToValueType.qml
blockComments.qml
boolCoercions.qml
boolPointerMerge.qml
brokenAs.qml
boundComponents.qml
callContextPropertyLookupResult.qml
callFactory.qml
callObjectLookupOnNull.qml
callWithSpread.qml
childobject.qml
collector.qml
colorAsVariant.qml
colorString.qml
compareOriginals.qml
comparisonTypes.qml
componentReturnType.qml
compositeTypeMethod.qml
compositesingleton.qml
conditionalEval.qml
consoleObject.qml
consoleTrace.qml
construct.qml
contextParam.qml
conversionDecrement.qml
conversionInDeadCode.qml
conversions.qml
conversions2.qml
convertPrimitiveToVar.qml
convertQJSPrimitiveValueToIntegral.qml
convertToOriginalReadAcumulatorForUnaryOperators.qml
curlygrouped.qml
cycleHead.qml
dateConstruction.qml
dateConversions.qml
deadContext.qml
deadContext2.qml
deadContext3.qml
deadShoeSize.qml
deadStoreLoop.qml
destroyAndToString.qml
detachOnAssignment.qml
detachedListAssignment.qml
detachedreferences.qml
dialog.qml
dialogButtonBox.qml
disappearingArrowFunction.qml
dynamicObjectProperty.qml
dynamicscene.qml
enforceSignature.qml
enumConversion.qml
enumFromBadSingleton.qml
enumInvalid.qml
enumLookup.qml
enumMarkedAsFlag.qml
enumProblems.qml
enumScope.qml
enumsInOtherObject.qml
enumsUser.qml
equalityQObjects.qml
equalityQUrl.qml
equalityTestsWithNullOrUndefined.qml
equalityVarAndNonStorable.qml
equalityVarWithOutConversion.qml
equalsUndefined.qml
exceptionFromInner.qml
excessiveParameters.qml
extendedTypes.qml
extra/extra.qml
failures.qml
fallbacklookups.qml
fallbackresettable.qml
finalUser.qml
flagEnum.qml
fromBoolValue.qml
funcWithParams.qml
functionCallInitCrash.qml
functionLookup.qml
functionReturningVoid.qml
functionTakingVar.qml
getOptionalLookup.qml
globals.qml
idAccess.qml
idVsMember.qml
ignoredFunctionReturn.qml
immediateQuit.qml
imports/QmlBench/Globals.qml
importsFromImportPath.qml
indirectlyShadowable.qml
infinities.qml
infinitiesToInt.qml
insertContextOnInvalidType.qml
intEnumCompare.qml
intOverflow.qml
intToEnum.qml
interactive.qml
interceptor.qml
internalConversion.qml
invalidateCompositeType.qml
invisibleBase.qml
invisibleListElementType.qml
invisibleTypes.qml
isnan.qml
iterateUnknownValue.qml
iteration.qml
javaScriptArgument.qml
jsArrayMethods.qml
jsArrayMethodsUntyped.qml
jsArrayMethodsWithParams.qml
jsArrayMethodsWithParamsUntyped.qml
jsMathObject.qml
jsimport.qml
jsmoduleimport.qml
jsonArrayToStringList.qml
layouts.qml
letAndConst.qml
library.js
listAsArgument.qml
listConversion.qml
listIndices.qml
listOfInvisible.qml
listPropertyAsModel.qml
listToString.qml
listlength.qml
markJSValue.qml
markRecursive.qml
math.qml
mathMinMax.qml
mathOperations.qml
mathStaticProperties.qml
mergeSideEffects.qml
mergedObjectRead.qml
mergedObjectWrite.qml
methodOnListLookup.qml
methods.qml
modulePrefix.qml
moveAliasedRegister.qml
moveRegVoid.qml
multiAdjust.qml
multiRedirect.qml
multiforeign.qml
multipleCtors.qml
namespaceWithEnum.qml
noBindingLoop.qml
noBuiltinsImport.qml
noQQmlData.qml
nonNotifyable.qml
noscope.qml
notEqualsInt.qml
notNotString.qml
nullAccess.qml
nullAccessInsideSignalHandler.qml
nullComparison.qml
nullishCoalescing.qml
numbersInJsPrimitive.qml
objectInVar.qml
objectLookupOnListElement.qml
objectWithStringListMethod.qml
oldEnum.qml
optionalComparison.qml
outOfBounds.qml
overriddenMember.qml
ownProperty.qml
page.qml
parentProp.qml
popContextAfterRet.qml
prefixedMetaType.qml
pressAndHoldButton.qml
propertyMap.qml
qmlUsing.qml
qtbug113150.qml
qtfont.qml
reduceWithNullThis.qml
readEnumFromInstance.qml
readonlyListProperty.qml
registerPropagation.qml
registerelimination.qml
renameAdjust.qml
resettable.qml
returnAfterReject.qml
revisions.qml
scopeIdLookup.qml
scopeVsObject.qml
scopedEnum.qml
script.js
script.mjs
sequenceToIterable.qml
sequenceToIterable2.qml
setLookupConversion.qml
setLookupOriginalScope.qml
shadowedAsCasts.qml
shadowedMethod.qml
shadowedPrimitiveCmpEqNull.qml
shadowingSingleton.qml
shared/Slider.qml
shifts.qml
sideEffectOnArgument.qml
signal.qml
signalHandler.qml
signalIndexMismatch.qml
signalsWithLists.qml
signatureIgnored.qml
specificParent.qml
splice.qml
storeElementSideEffects.qml
stringArg.qml
stringLength.qml
stringToByteArray.qml
structuredValueType.qml
multiEnginePropertyCache.qml
takenumber.qml
testlogger.js
text.qml
themerbad.qml
themergood.qml
thisObject.qml
throwObjectName.qml
toString.qml
topLevelComponent.qml
translation.qml
trigraphs.qml
trivialSignalHandler.qml
typePropagationLoop.qml
typePropertyClash.qml
typedArray.qml
unclearComponentBoundaries.qml
undefinedResets.qml
undefinedToDouble.qml
unknownAttached.qml
unknownParameter.qml
unknownUnderlyingType.qml
unstoredUndefined.qml
unusedAttached.qml
urlString.qml
usingCxxTypesFromFileImports.qml
valueTypeCast.qml
valueTypeCopy.qml
valueTypeDefault.qml
valueTypeLists.qml
valueTypeProperty.qml
valueTypeReference.qml
variantMap.qml
variantMapLookup.qml
variantReturn.qml
variantlist.qml
versionmismatch.qml
voidConversion.qml
voidfunction.qml
writeBackReferenceObject.qml
writeback.qml
)
if(QT_FEATURE_qml_labs)
list(APPEND qml_files
fileDialog.qml
dummy_imports.qml
)
endif()
set(resource_files
ProgressBar/built-with-Qt_Large.png
imports/QmlBench/qmldir
)
set_source_files_properties("shared/Slider.qml"
PROPERTIES QT_RESOURCE_ALIAS "Slider.qml"
)
set_source_files_properties("hidden/Style.qml"
PROPERTIES QT_QML_SINGLETON_TYPE TRUE)
# Do re-evaluate on each import, please
set_source_files_properties("NotificationsUtils.js"
PROPERTIES QT_QML_SKIP_QMLDIR_ENTRY FALSE)
qt_policy(SET QTP0001 NEW)
qt_policy(SET QTP0004 NEW)
qt_add_library(codegen_test_hidden STATIC)
qt_autogen_tools_initial_setup(codegen_test_hidden)
set_target_properties(codegen_test_hidden PROPERTIES
# We really want qmlcachegen here, even if qmlsc is available
QT_QMLCACHEGEN_EXECUTABLE qmlcachegen
QT_QMLCACHEGEN_ARGUMENTS --validate-basic-blocks
)
target_compile_definitions(codegen_test_hidden PUBLIC
-DGENERATED_CPP_FOLDER="${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache"
)
qt6_add_qml_module(codegen_test_hidden
URI HiddenTestTypes
QML_FILES
hidden/Main.qml
hidden/Style.qml
OUTPUT_DIRECTORY HiddenTestTypes
__QT_INTERNAL_DISAMBIGUATE_QMLDIR_RESOURCE
# Don't add a qmldir in "hidden". That would defeat the purpose.
NO_GENERATE_EXTRA_QMLDIRS
)
add_dependencies(codegen_test_hidden Qt::Quick)
qt_autogen_tools_initial_setup(codegen_test_hiddenplugin)
qt_add_library(codegen_test_stringbuilder STATIC)
qt_autogen_tools_initial_setup(codegen_test_stringbuilder)
set_target_properties(codegen_test_stringbuilder PROPERTIES
# We really want qmlcachegen here, even if qmlsc is available
QT_QMLCACHEGEN_EXECUTABLE qmlcachegen
QT_QMLCACHEGEN_ARGUMENTS --validate-basic-blocks
)
target_compile_definitions(codegen_test_stringbuilder PRIVATE
-DGENERATED_CPP_FOLDER="${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache"
QT_USE_QSTRINGBUILDER
)
qt6_add_qml_module(codegen_test_stringbuilder
URI StringBuilderTestTypes
SOURCES
writableVariantMap.h
QML_FILES
writeVariantMap.qml
OUTPUT_DIRECTORY StringBuilderTestTypes
__QT_INTERNAL_DISAMBIGUATE_QMLDIR_RESOURCE
)
qt_autogen_tools_initial_setup(codegen_test_stringbuilderplugin)
qt_add_library(codegen_test_module STATIC)
qt_autogen_tools_initial_setup(codegen_test_module)
set_target_properties(codegen_test_module PROPERTIES
# We really want qmlcachegen here, even if qmlsc is available
QT_QMLCACHEGEN_EXECUTABLE qmlcachegen
QT_QMLCACHEGEN_ARGUMENTS --validate-basic-blocks
)
target_compile_definitions(codegen_test_module PUBLIC
-DGENERATED_CPP_FOLDER="${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache"
-DQT_NO_CAST_FROM_ASCII
)
qt6_add_qml_module(codegen_test_module
VERSION 1.5
URI TestTypes
IMPORT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/imports/"
DEPENDENCIES
QtQuick
QtQuick.Controls
QtQuick.Templates
QtQuick.Shapes
SOURCES
${cpp_sources}
QML_FILES
${qml_files}
RESOURCES
${resource_files}
OUTPUT_DIRECTORY TestTypes # Make sure tst_qmlcachegen doesn't see our output
__QT_INTERNAL_DISAMBIGUATE_QMLDIR_RESOURCE
)
# we want the generated C++ code to be warning free
if(MSVC)
# intentionally empty, no easy way to have a higher warning level
# without causing a warning about overriding the level
else()
# assumption: everything that's not MSVC handles Wall and Wextra
target_compile_options(codegen_test_module PRIVATE -Wall -Wextra)
# TODO: this should be enabled everywhere, but MSVC in CI seems to ignore the pragma
# which silences divide by 0 warnings...
set_property(TARGET codegen_test_module
PROPERTY COMPILE_WARNING_AS_ERROR ON
)
endif()
target_link_libraries(codegen_test_module PRIVATE Qt6::QmlPrivate)
if(${CMAKE_VERSION} GREATER_EQUAL "3.19.0")
qt_target_qml_sources(codegen_test_module
QML_FILES extra2/extra.qml
)
else()
target_compile_definitions(codegen_test_module PUBLIC
-DVERY_OLD_CMAKE=1
)
endif()
add_dependencies(codegen_test_module Qt::Quick Qt::QuickTemplates2 Qt::QuickShapesPrivate)
qt_autogen_tools_initial_setup(codegen_test_moduleplugin)
qt_add_library(codegen_test_module_verify STATIC)
qt_autogen_tools_initial_setup(codegen_test_module_verify)
set_target_properties(codegen_test_module_verify PROPERTIES
# We really want qmlcachegen here, even if qmlsc is available
QT_QMLCACHEGEN_EXECUTABLE qmlcachegen
QT_QMLCACHEGEN_ARGUMENTS --validate-basic-blocks
)
qt6_add_qml_module(codegen_test_module_verify
VERSION 1.5
URI TestTypes
IMPORT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/imports/"
DEPENDENCIES
QtQuick
QtQuick.Controls
QtQuick.Templates
QtQuick.Shapes
SOURCES
${cpp_sources}
QML_FILES
${qml_files}
RESOURCES
${resource_files}
OUTPUT_DIRECTORY verify/TestTypes # Make sure tst_qmlcachegen doesn't see our output
TARGET_PATH verify/TestTypes # Different target path to avoid resource file name clashes
__QT_INTERNAL_DISAMBIGUATE_QMLDIR_RESOURCE
)
target_link_libraries(codegen_test_module_verify PRIVATE Qt::QmlPrivate)
add_dependencies(codegen_test_module_verify Qt::Quick Qt::QuickTemplates2 Qt::QuickShapesPrivate)
qt_autogen_tools_initial_setup(codegen_test_module_verifyplugin)
qt_internal_add_test(tst_qmlcppcodegen_verify
SOURCES
tst_qmlcppcodegen_verify.cpp
)
add_dependencies(tst_qmlcppcodegen_verify codegen_test_module codegen_test_module_verify)
set(a_files "")
set(b_files "")
foreach(qml_file IN LISTS qml_files)
string(REGEX REPLACE "\\.(js|mjs|qml)$" "_\\1" compiled_file ${qml_file})
string(REGEX REPLACE "[$#?]+" "_" compiled_file ${compiled_file})
list(APPEND
a_files
"${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache/codegen_test_module_${compiled_file}.cpp")
list(APPEND
b_files
"${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache/codegen_test_module_verify_${compiled_file}.cpp")
endforeach()
qt_add_resources(tst_qmlcppcodegen_verify "a"
PREFIX
"/a"
FILES
${a_files}
BASE
"${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache/"
)
qt_add_resources(tst_qmlcppcodegen_verify "b"
PREFIX
"/b"
FILES
${b_files}
BASE
"${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache/"
)
@@ -0,0 +1,36 @@
pragma Strict
import QtQml
CategorizerBase {
id: root
property list<double> nnn: {
var result = [];
result[0] = 10;
return result;
}
function sum() : list<double> {
var numbers = root.numbers;
var cat1Sum = 0;
var cat2Sum = 0;
var cat3Sum = 0;
var huge = 0;
for (var i = 0; i < CategorizerBase.Iterations; ++i) {
for (var j = 0; j < CategorizerBase.Length; ++j) {
var num = numbers[j] & CategorizerBase.Mask;
if (num < CategorizerBase.Category0)
cat1Sum += num;
else if (num < CategorizerBase.Category1)
cat2Sum += num;
else if (num < CategorizerBase.Category2)
cat3Sum += num;
else
huge += num;
}
}
return [cat1Sum, cat2Sum, cat3Sum, huge];
}
}
@@ -0,0 +1,25 @@
import QtQml
QtObject {
enum Parameters {
Length = 32,
Iterations = 2,
Category0 = 0xf0f,
Category1 = 0xf0f0,
Category2 = 0xf0f0f,
Maximum = 0xf0f0f0,
Mask = 0xabcdef
}
function randomNumber() : int {
return (Math.random() * CategorizerBase.Maximum);
}
property list<double> numbers: {
var result = [];
for (var i = 0; i < CategorizerBase.Length; ++i)
result[i] = randomNumber();
return result;
}
}
@@ -0,0 +1,28 @@
qt_add_library(confused_test_module STATIC)
qt_autogen_tools_initial_setup(confused_test_module)
qt_policy(SET QTP0001 NEW)
# Not QTP0004, since we have a manually written qmldir in a strange place
set_source_files_properties("Test/broken.js"
PROPERTIES QT_RESOURCE_ALIAS "Test/broken.qml"
)
qt_add_qml_module(confused_test_module
URI Confused
VERSION 1.0
QML_FILES
Main.qml
Main2.qml
Test/test.js
Test/broken.js
NO_GENERATE_EXTRA_QMLDIRS # Avoid QTP0004 warning
RESOURCES
Test/qmldir
)
target_link_libraries(confused_test_module
PRIVATE Qt6::Qml
)
qt_autogen_tools_initial_setup(confused_test_moduleplugin)
@@ -0,0 +1,6 @@
import QtQml
import "Test" as T
QtObject {
Component.onCompleted: T.Test.Print()
}
@@ -0,0 +1,6 @@
import QtQml
import "Test" as T
QtObject {
Component.onCompleted: T.Broken.Print()
}
@@ -0,0 +1,3 @@
.pragma library
function Print() { console.log("Hello from Broken") }
@@ -0,0 +1,2 @@
Test test.js
Broken broken.qml
@@ -0,0 +1,3 @@
.pragma library
function Print() { console.log("Hello from Test") }
@@ -0,0 +1,12 @@
pragma Strict
import QtQuick
import TestTypes
Item {
ListProvider {
id: listProvider
}
property var list: listProvider.intList()
}
@@ -0,0 +1,11 @@
pragma Strict
import QtQml
import "."
QtObject {
objectName: p.name
property Person p: Person {
id: p
name: "horst"
}
}
@@ -0,0 +1,10 @@
pragma Strict
import QtQml
QtObject {
objectName: p.name
property Person p: Person {
id: p
name: "guenther"
}
}
@@ -0,0 +1,3 @@
import QtQml
MenuItem {}
@@ -0,0 +1,3 @@
module Cycle
MenuItem 1.0 MenuItem.qml
@@ -0,0 +1,7 @@
import QtQml 2.0
Cycle2 {
id: itt
QtObject {
property var thing: itt
}
}
@@ -0,0 +1,2 @@
import QtQml 2.0
Cycle3 {}
@@ -0,0 +1,2 @@
import QtQml 2.0
Cycle1 {}
@@ -0,0 +1,9 @@
import QtQml
QtObject {
function yep() {
try { }
catch (e) { replace(/()/, ""); }
for (let i = 0; i < 1; ++i) { }
}
}
@@ -0,0 +1,26 @@
// Copyright (C) 2020 The Qt Company Ltd.
import QtQuick
Item {
enum DummyEnum { DummyValue1, DummyValue2, DummyValue3 = 33 }
property int value
property Dummy child
property Dummy2 child2 : Dummy2 {}
property int dummyEnum
component Group: QtObject {
property Item item;
}
property Group group
signal triggered()
signal signalWithArg(int one, bool two)
property real onValue
property real offValue
function someFunction(a: int, b: bool, c: Dummy, d: real, e: int) : int { return 42 }
property string strProp
function concat(a: string, b: string) : string { return a + b }
}
@@ -0,0 +1,18 @@
// Copyright (C) 2020 The Qt Company Ltd.
import QtQml
QtObject {
property int value
property Dummy2 child
property int dummyEnum
signal triggered()
signal signalWithArg(int one, bool two)
property real onValue
property real offValue
function someFunction(a: int, b: bool, c: Dummy2, d: real, e: int) : int { return 42 }
property string strProp
function concat(a: string, b: string) : string { return a + b }
}
@@ -0,0 +1,6 @@
pragma Strict
import QtQml
QtObject {
property Variable myOutput
}
@@ -0,0 +1,29 @@
import QtQml
import QtQuick.Layouts
QtObject {
id: root
property int appState: Enums.AppState.Blue
property string color: "blue"
enum AppState {
Red,
Green,
Blue
}
onAppStateChanged: {
if (appState === Enums.AppState.Green)
root.color = "green"
else if (appState === Enums.AppState.Red)
root.color = "red"
}
property Timer timer: Timer {
onTriggered: root.appState = Enums.AppState.Green
running: true
interval: 100
}
Layout.alignment: Qt.AlignCenter
}
@@ -0,0 +1,5 @@
import QtQml
QtObject {
final property int f: 12
}
@@ -0,0 +1,3 @@
import QtQml
Barzle {}
@@ -0,0 +1,6 @@
import QtQml
QtObject {
property url foo
property bool b: foo?.toString()
}
@@ -0,0 +1,7 @@
import QtQml
import TestTypes
QtObject {
property Action action: Action { }
property bool b: action?.visible
}
@@ -0,0 +1,19 @@
pragma Strict
import QtQml
import QtQuick
QtObject {
id: root
component Base : QtObject {
property int i: 1
}
component Derived : Base {
property string i: "a"
}
property Base base: Derived { }
property var res: root.base?.i
}
@@ -0,0 +1,27 @@
import QtQuick
Item {
id: root
property real radius: Math.floor(samples / 2);
property int samples: 9
property real deviation: (radius + 1.0) / 3.3333
property int kernelRadius: Math.max(0, samples / 2);
onSamplesChanged: rebuildStash();
onDeviationChanged: rebuildStash();
Component.onCompleted: rebuildStash();
function rebuildStash() {
var params = {
radius: kernelRadius,
deviation: Math.max(0.00001, deviation),
fallback: root.radius != kernelRadius
}
stash = params
}
property var stash
}
@@ -0,0 +1,5 @@
import QtQuick
QtObject {
property var foo: "bla"
}
@@ -0,0 +1,7 @@
import QtQml
import TestTypes as MobileShell
QtObject {
id: notificationItem
objectName: MobileShell.NotificationsUtils.determineNotificationHeadingText(notificationItem)
}
@@ -0,0 +1,3 @@
function determineNotificationHeadingText(notificationItem) {
return "heading";
}
@@ -0,0 +1,10 @@
import QtQuick
import App
Item {
property alias useListDelegate: inner.useListDelegate
MyCppType {
id: inner
}
}
@@ -0,0 +1,109 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick 2.0
Item {
property string name
property var notes
property real horizontalVelocity: 0
id: page
Image {
fillMode: Image.PreserveAspectCrop
clip: true
}
MouseArea {
anchors.fill: parent
onClicked: page.focus = false;
}
Item {
property font font
property color color
property int style
property color styleColor
objectName: page.name; x: 15; y: 8; height: 40; width: 370
font.pixelSize: 18; font.bold: true; color: "white"
style: Text.Outline; styleColor: "black"
}
Repeater {
model: page.notes
Item {
id: stickyPage
required property string noteText
property int randomX: Math.random() * (page.ListView.view.width-0.5*stickyImage.width) +100
property int randomY: Math.random() * (page.ListView.view.height-0.5*stickyImage.height) +50
x: randomX; y: randomY
rotation: -page.horizontalVelocity / 100
Behavior on rotation {
SpringAnimation { spring: 2.0; damping: 0.15 }
}
Item {
id: sticky
scale: 0.7
Image {
id: stickyImage
x: 8 + -width * 0.6 / 2; y: -20
source: "note-yellow.png"
scale: 0.6; transformOrigin: Item.TopLeft
}
Item {
property font font
property bool readOnly
property string text
id: myText
x: -104; y: 36; width: 215; height: 200
font.pixelSize: 24
readOnly: false
rotation: -8
text: stickyPage.noteText
}
Item {
x: stickyImage.x; y: -20
width: stickyImage.width * stickyImage.scale
height: stickyImage.height * stickyImage.scale
MouseArea {
id: mouse
anchors.fill: parent
drag.target: stickyPage
drag.minimumY: 0
drag.maximumY: page.height - 80
drag.minimumX: 100
drag.maximumX: page.width - 140
onClicked: myText.forceActiveFocus()
}
}
}
Image {
x: -width / 2; y: -height * 0.5 / 2
source: "tack.png"
scale: 0.7; transformOrigin: Item.TopLeft
}
states: State {
name: "pressed"
when: mouse.pressed
PropertyChanges { target: sticky; rotation: 8; scale: 1 }
PropertyChanges { target: page; z: 8 }
}
transitions: Transition {
NumberAnimation { properties: "rotation,scale"; duration: 200 }
}
}
}
}
@@ -0,0 +1,50 @@
pragma Strict
import QtQml
QtObject {
id: planner
property Variable last: Variable { value: 10 }
function newMark() : int {
return 5;
}
function addPropagate(i: int) : bool {
return false;
}
function typeErasedRemoveOne(v: QtObject) { removeOne(v as Variable) }
// Work with various shadowable members and return values.
function removeOne(v: Variable) {
let vDeterminedBy = v.determinedBy;
for (let i = 0, length = v.length(); i < length; ++i) {
let next = v.constraint(i) as BaseConstraint;
if (next.satisfaction === Satisfaction.NONE)
objectName += "n"
else if (next !== vDeterminedBy)
objectName += "d"
else
objectName += "x"
}
}
function typeErasedRun(c: QtObject) { run(c as BaseConstraint) }
function run(initial: BaseConstraint) {
let mark = planner.newMark();
let c = initial;
let output = c.output as Variable;
if (output.mark !== mark && c.inputsKnown(mark)) {
output.mark = mark;
}
}
function verify(i: int) {
if (last.value !== i)
console.error("failed", last.value, i);
else
console.log("success")
}
}
@@ -0,0 +1,6 @@
import QtQuick
UniformAnimator {
property real frame
property var value
}
@@ -0,0 +1,8 @@
import QtQml
QtObject {
property QtObject target
property string property
default property list<Keyframe> keyframes
property url keyframeSource
}
@@ -0,0 +1,128 @@
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick 2.9
import QtQuick.Window 2.3
import QtQuick.Layouts 1.0
import QtQuick.Controls 2.3
Rectangle {
visible: true
width: 640
height: 480
color: "#242424"
ColumnLayout {
x: 20
y: 152
spacing: 20
Root {
id: root
}
Root {
id: root1
}
Root {
id: root2
}
}
Timeline {
id: timeline
enabled: true
endFrame: 4000
startFrame: 0
KeyframeGroup {
target: root
property: "progress"
Keyframe {
value: 10
frame: 0
}
Keyframe {
easing.bezierCurve: [0.86, 0.00, 0.07, 1.00, 1, 1]
value: 90
frame: 2000
}
Keyframe {
easing.bezierCurve: [0.86, 0.00, 0.07, 1.00, 1, 1]
value: 10
frame: 4000
}
}
KeyframeGroup {
target: root1
property: "progress"
Keyframe {
easing.bezierCurve: [0.17, 0.84, 0.44, 1.00, 1, 1]
value: 90
frame: 4000
}
Keyframe {
easing.bezierCurve: [0.17, 0.84, 0.44, 1.00, 1, 1]
value: 20
frame: 2000
}
Keyframe {
value: 90
frame: 0
}
}
KeyframeGroup {
target: root2
property: "progress"
Keyframe {
value: 15
frame: 0
}
Keyframe {
easing.bezierCurve: [0.79, 0.14, 0.15, 0.86, 1, 1]
value: 85
frame: 2000
}
Keyframe {
easing.bezierCurve: [0.79, 0.14, 0.15, 0.86, 1, 1]
value: 15
frame: 4000
}
}
animations: [
TimelineAnimation {
id: propertyAnimation
target: timeline
property: "currentFrame"
running: true
to: timeline.endFrame
from: timeline.startFrame
loops: -1
duration: 1000
}
]
}
Image {
id: image
x: 518
y: 0
width: 102
height: 137
fillMode: Image.PreserveAspectFit
source: "built-with-Qt_Large.png"
}
}
@@ -0,0 +1,105 @@
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick 2.9
Item {
id: root
width: 600
height: 65
property alias progress: timeline.currentFrame
Rectangle {
id: pb_back
color: "#9f9f9f"
radius: 4
anchors.right: parent.right
anchors.rightMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
anchors.top: parent.top
anchors.topMargin: 30
Rectangle {
id: pb_front
width: 200
color: "#ffffff"
anchors.bottomMargin: 5
anchors.left: parent.left
anchors.leftMargin: 5
anchors.bottom: parent.bottom
anchors.top: parent.top
anchors.topMargin: 5
}
}
Text {
id: text1
color: "#ffffff"
text: Math.round(root.progress)
font.pixelSize: 18
}
Timeline {
id: timeline
enabled: true
startFrame: 0
endFrame: 100
KeyframeGroup {
target: text1
property: "color"
Keyframe {
value: "#8de98d"
frame: 0
}
Keyframe {
value: "#de4f4f"
frame: 50
}
Keyframe {
value: "#f0c861"
frame: 100
}
}
KeyframeGroup {
target: pb_front
property: "width"
Keyframe {
value: 0
frame: 0
}
Keyframe {
value: 590
frame: 100
}
}
KeyframeGroup {
target: pb_front
property: "color"
Keyframe {
value: "#8de98d"
frame: 0
}
Keyframe {
value: "#de4f4f"
frame: 50
}
Keyframe {
value: "#f0c861"
frame: 100
}
}
}
}
@@ -0,0 +1,10 @@
import QtQml
QtObject {
property real startFrame
property real endFrame
property real currentFrame
default property list<KeyframeGroup> keyframeGroupes
property list<TimelineAnimation> animations
property bool enabled
}
@@ -0,0 +1,6 @@
import QtQuick
NumberAnimation {
property bool pingPong
signal finishedEvil()
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

@@ -0,0 +1,14 @@
// Copyright (C) 2020 The Qt Company Ltd.
import QtQuick 2.15
Item {
property bool foo: false
property alias bar: item.visible
Item {
id: item
visible: parent.foo
}
}
@@ -0,0 +1,10 @@
pragma Strict
import QtQml
QtObject {
enum Value {
NONE = 0,
FORWARD = 1,
BACKWARD = 2
}
}
@@ -0,0 +1,11 @@
pragma Strict
import QtQml
import QtQuick.Templates as T
T.SelectionRectangle {
component Handle : QtObject {
property QtObject rect: SelectionRectangle
}
property QtObject aa: Handle {}
}
@@ -0,0 +1,6 @@
pragma Strict
import QtQml
QtObject {
property int objectName: 12
}
@@ -0,0 +1,6 @@
pragma Strict
import QtQml
ShadowedObjectName {
property double objectName: 17.4
}
@@ -0,0 +1,12 @@
import QtQml
QtObject {
enum Foo {
Bar,
Baz
}
property var eF: StoreMetaEnum.Foo
property int bar: eF.Bar
property int baz: eF.Baz
}
@@ -0,0 +1,30 @@
pragma Strict
import TestTypes 1.0
CppBaseClass {
id: self
enum EE {
AA, BB, CC
}
property int foo: 1 + 2
property int ppp: 4
// constant, binding will be removed.
cppProp: 3 + 4
// An actual binding. Can't be removed because cppProp may be manually set.
cppProp2: cppProp * 2
property int a: boo[0]
function incA() : void {
self.a = self.boo[1];
}
property real b: hoo[0]
function incB() : void {
self.b = self.hoo[1];
}
}
@@ -0,0 +1,21 @@
pragma Strict
import QtQml
import TestTypes
QtObject {
id: root
property largeValueType l
function callee(l: largeValueType) : void {
console.log("Reading l.i=" + l.i)
}
function caller() : void {
callee(root.l)
}
Component.onCompleted: {
caller()
}
}
@@ -0,0 +1,22 @@
pragma Strict
import QtQml
QtObject {
id: variable
property int value: 0
property int mark: 0
property BaseConstraint determinedBy: null
property list<BaseConstraint> constraints: [
BaseConstraint {
satisfaction: variable.value == 0 ? Satisfaction.NONE : Satisfaction.FORWARD
}
]
function length(): int {
return constraints.length
}
function constraint(i: int) : BaseConstraint {
return constraints[i];
}
}
@@ -0,0 +1,3 @@
import TestTypes as Test
Test.WindowInstance {}
@@ -0,0 +1,26 @@
qt_add_library(with_subdir_test_module STATIC)
qt_autogen_tools_initial_setup(with_subdir_test_module)
qt_policy(SET QTP0001 NEW)
qt_policy(SET QTP0004 NEW)
qt_add_qml_module(with_subdir_test_module
URI WithSubDir
QML_FILES
qml/GreenRect.qml
qml/MyScript.js
# Hide it at compile time. Otherwise the "TestTypes" module may see it,
# but the "verify" module won't.
OUTPUT_DIRECTORY HiddenWithSubdir
# Don't complain about mismatched target paths
NO_LINT
__QT_INTERNAL_NO_GENERATE_QMLLS_BUILD_INI
)
target_link_libraries(with_subdir_test_module
PRIVATE Qt6::Qml
)
qt_autogen_tools_initial_setup(with_subdir_test_moduleplugin)
@@ -0,0 +1,6 @@
import QtQml
import WithSubDir
QtObject {
objectName: "green"
}
@@ -0,0 +1,2 @@
.pragma library
function hello() { console.log("World") }
@@ -0,0 +1,8 @@
import QtQml
QtObject {
id: self
property real foo: 12.3
property alias a: self.foo
property string t: Math.round(self.a)
}
@@ -0,0 +1,14 @@
import QtQuick
Item {
property alias dummy: inner.i
property alias aai: middle.ai
Item {
id: middle
property alias ai: inner.i
Item {
id: inner
property int i: 0
}
}
}
@@ -0,0 +1,11 @@
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
pragma Strict
import QtQml
QtObject {
id: option
property alias label: option.description
property alias description: option.objectName
}
@@ -0,0 +1,23 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef AMBIGUOUS_H
#define AMBIGUOUS_H
#include <QtCore/qobject.h>
#include <QtQmlIntegration/qqmlintegration.h>
class Ambiguous : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_ADDED_IN_VERSION(1, 2)
public:
Ambiguous(QObject *parent = nullptr) : QObject(parent)
{
setObjectName(QStringLiteral("Ambiguous"));
}
};
#endif // AMBIGUOUS_H
@@ -0,0 +1,9 @@
pragma Strict
// Import the latest version of Ambiguous, which is the C++ type added in version 1.2, not this one.
import TestTypes as Test
// Not an inheritance cycle, and also not an ambiguous type.
Test.Ambiguous {
property string i: objectName + 1
}
@@ -0,0 +1,9 @@
pragma Strict
// Import the latest version of Ambiguous, which is the C++ type added in version 1.2, not this one.
import TestTypes as Test
// Not an inheritance cycle, and also not an ambiguous type.
Test.Ambiguous {
property string i: objectName + 2
}
@@ -0,0 +1,15 @@
pragma Strict
import QtQml
QtObject {
id: self
property bool useSelf: true
property QtObject other: {
var a;
if (useSelf)
a = self
else
a = 15
return a as QtObject
}
}
@@ -0,0 +1,7 @@
pragma Strict
import TestTypes
Person {
objectName: "tomorrow"
onAmbiguous: function(a) { objectName = a + "foo" }
}
@@ -0,0 +1,12 @@
import QtQuick
Item {
width: 234
Item {
anchors.fill: parent
}
Item {
width: 47
}
}
@@ -0,0 +1,6 @@
import QtQml
QtObject {
property AnonymousComposite a: AnonymousComposite { id: aa }
property int b: aa.theInner.a
}
@@ -0,0 +1,15 @@
pragma Strict
import QML
QtObject {
function coerceToNumber(a: var) : real {
return a - 1;
}
property real a: coerceToNumber("true")
property real b: coerceToNumber("false")
property real c: coerceToNumber(4)
property real d: coerceToNumber(null)
property real e: coerceToNumber(undefined)
property real f: coerceToNumber("11")
}
@@ -0,0 +1,6 @@
import QML
QtObject {
property var values1: [1, 2, 3]
property var values2: []
}
@@ -0,0 +1,11 @@
pragma Strict
import QML
QtObject {
property list<int> defaultCtor: new Array()
property list<int> oneArgCtor: new Array(5)
property list<int> multiArgCtor: new Array(2, 3, 3, 4)
property list<bool> arrayTrue: new Array(true)
property list<bool> arrayFalse: new Array(false)
property list<real> arrayNegative: new Array(-14)
}
@@ -0,0 +1,52 @@
// Copyright (C) 2021 The Qt Company Ltd.
pragma Strict
pragma ValueTypeBehavior: Assertable
import QtQuick
import QtQml as QQ
Item {
QtObject { id: object }
Item { id: item }
Rectangle { id: rectangle }
Dummy { id: dummy }
property string string: "a"
property url url: "http://example.com"
property date date: new Date(1996, 2, 3)
property QtObject objectAsObject: object as QtObject
property QtObject objectAsItem: object as Item
property QtObject objectAsRectangle: object as Rectangle
property QtObject objectAsDummy: object as Dummy
property QtObject itemAsObject: item as QtObject
property QtObject itemAsItem: item as Item
property QtObject itemAsRectangle: item as Rectangle
property QtObject itemAsDummy: item as Dummy
property QtObject rectangleAsObject: rectangle as QtObject
property QtObject rectangleAsItem: rectangle as Item
property QtObject rectangleAsRectangle: rectangle as Rectangle
property QtObject rectangleAsDummy: rectangle as Dummy
property QtObject dummyAsObject: dummy as QtObject
property QtObject dummyAsItem: dummy as Item
property QtObject dummyAsRectangle: dummy as Rectangle
property QtObject dummyAsDummy: dummy as Dummy
property QtObject nullAsObject: null as QtObject
property QtObject nullAsItem: null as Item
property QtObject nullAsRectangle: null as Rectangle
property QtObject nullAsDummy: null as Dummy
property QtObject undefinedAsObject: undefined as QtObject
property QtObject undefinedAsItem: undefined as Item
property QtObject undefinedAsRectangle: undefined as Rectangle
property QtObject undefinedAsDummy: undefined as Dummy
property var stringAsString: string as QQ.string
property var urlAsUrl: url as QQ.url
property var dateAsDate: date as QQ.date
}
@@ -0,0 +1,5 @@
import QtQuick
MouseArea {
drag.axis: Drag.YAxis
}
@@ -0,0 +1,24 @@
import TestTypes
Person {
id: self
property Person other: Person { id: oo }
barzles: oo.barzles
cousins: oo.cousins
property int l: oo.barzles.length
property int m: oo.cousins.length
property list<Person> others: cousins
property Person mom: Person {
id: mm
cousins: self.others
}
property list<Person> momsCousins: mm.cousins
property Person dad: Person {
id: dd
cousins: oo
}
property list<Person> dadsCousins: dd.cousins
}
@@ -0,0 +1,33 @@
pragma Strict
import QtQml
QtObject {
function t1() {
let i = 0
let foo = false
if (true) {
for (i = 0; i < 42 ; ++i) {}
} else {
console.log(foo)
}
}
function t2() {
let foo = false
if (false) {
while(Math.random() < 0.5) {}
} else {
console.log(foo)
}
}
function t3() {
let foo = false
if (Math.random() < 0.5) {
console.log(foo)
} else {
while(Math.random() < 0.5) {}
console.log(foo)
}
}
}
@@ -0,0 +1,13 @@
pragma Strict
import QtQml
QtObject {
function infinite() {
let foo = false
if (true) {
while (true) {}
} else {
console.log(foo)
}
}
}
@@ -0,0 +1,40 @@
pragma Strict
import QtQml
QtObject {
id: win
property real width: 640
property real height: 480
property string title: "none"
function t1(): void {
const w = win.width
const h = win.height
if (w > 0 && h > 0) {
const wByH = h / 3.0 * 4.0
}
}
function t2(): void {
let i = 42
win.title = "Foo " + i
for (let j = 0; j < 10; j++) {
win.title = "Bar " + j
}
for (let k = 0; k < i; k++) {
win.title = "Baz " + k
}
}
function t3(): void {
let v1 = 1
let v2 = 2
if (true) {
v1 = v2
}
}
}
@@ -0,0 +1,9 @@
pragma Strict
import QtQuick
import QtQuick.Templates as T
T.Button {
icon.color: "green"
property color a: icon.color
}
@@ -0,0 +1,86 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "birthdayparty.h"
BirthdayParty::BirthdayParty(QObject *parent)
: QObject(parent), m_host(nullptr)
{
}
Person *BirthdayParty::host() const
{
return m_host;
}
void BirthdayParty::setHost(Person *c)
{
if (c != m_host) {
m_host = c;
emit hostChanged();
}
}
QQmlListProperty<Person> BirthdayParty::guests()
{
return {this, &m_guests};
}
int BirthdayParty::guestCount() const
{
return m_guests.size();
}
Person *BirthdayParty::guest(int index) const
{
return m_guests.at(index);
}
QStringList BirthdayParty::guestNames() const
{
QStringList names;
for (Person *guest: m_guests)
names.append(guest->name());
return names;
}
QVariantList BirthdayParty::stuffs() const
{
return QVariantList({
QVariant::fromValue(objectName()),
QVariant::fromValue(m_guests.size()),
QVariant::fromValue(m_host)
});
}
void BirthdayParty::invite(const QString &name)
{
auto *person = new Person(this);
person->setName(name);
m_guests.append(person);
}
BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object)
{
return new BirthdayPartyAttached(object);
}
BirthdayPartyAttached::BirthdayPartyAttached(QObject *parent)
: QObject(parent), m_rsvp(QDateTime(QDate(1911, 3, 4), QTime()))
{
}
QDateTime BirthdayPartyAttached::rsvp() const
{
return m_rsvp.value();
}
void BirthdayPartyAttached::setRsvp(const QDateTime &rsvp)
{
m_rsvp.setValue(rsvp);
}
QBindable<QDateTime> BirthdayPartyAttached::rsvpBindable()
{
return QBindable<QDateTime>(&m_rsvp);
}
@@ -0,0 +1,109 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef BIRTHDAYPARTY_H
#define BIRTHDAYPARTY_H
#include <QObject>
#include <QQmlListProperty>
#include <QProperty>
#include <QBindable>
#include <QDateTime>
#include "person.h"
class BirthdayPartyAttached : public QObject
{
Q_OBJECT
Q_PROPERTY(QDateTime rsvp READ rsvp WRITE setRsvp BINDABLE rsvpBindable)
QML_ANONYMOUS
public:
BirthdayPartyAttached(QObject *parent);
QDateTime rsvp() const;
void setRsvp(const QDateTime &rsvp);
QBindable<QDateTime> rsvpBindable();
private:
QProperty<QDateTime> m_rsvp;
};
class BirthDayPartyExtended : public QObject
{
Q_OBJECT
Q_PROPERTY(int eee READ eee WRITE setEee NOTIFY eeeChanged)
public:
BirthDayPartyExtended(QObject *parent) : QObject(parent) {}
int eee() const { return m_eee; }
void setEee(int eee)
{
if (eee != m_eee) {
m_eee = eee;
emit eeeChanged();
}
}
signals:
void eeeChanged();
private:
int m_eee = 25;
};
struct Foozle {
int foo = 1;
};
class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *host READ host WRITE setHost NOTIFY hostChanged FINAL)
Q_PROPERTY(QQmlListProperty<Person> guests READ guests)
Q_PROPERTY(QStringList guestNames READ guestNames FINAL)
Q_PROPERTY(QVariantList stuffs READ stuffs FINAL)
QML_ELEMENT
QML_ATTACHED(BirthdayPartyAttached)
QML_EXTENDED(BirthDayPartyExtended)
public:
BirthdayParty(QObject *parent = nullptr);
Person *host() const;
void setHost(Person *);
QQmlListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
QStringList guestNames() const;
QVariantList stuffs() const;
Q_INVOKABLE void invite(const QString &name);
static BirthdayPartyAttached *qmlAttachedProperties(QObject *object);
signals:
void hostChanged();
void partyStarted(Foozle foozle);
private:
Person *m_host;
QList<Person *> m_guests;
};
class NastyBase : public QObject {
public:
NastyBase(QObject *parent) : QObject(parent) {}
};
class Nasty : public NastyBase
{
Q_OBJECT
QML_ELEMENT
QML_ATTACHED(Nasty)
public:
Nasty(QObject *parent = nullptr) : NastyBase(parent) {}
static Nasty *qmlAttachedProperties(QObject *object) { return new Nasty(object); }
};
#endif // BIRTHDAYPARTY_H
@@ -0,0 +1,10 @@
pragma Strict
import QtQml
QtObject {
property real implicitHeight: {
return /*+ (control.implicitHeaderHeight > 0
? control.implicitHeaderHeight + control.spacing
: 0)*/ 8;
}
}
@@ -0,0 +1,45 @@
pragma Strict
import QtQml
QtObject {
property rect a
property bool t1: a
property int c: 1
property bool t2: c
property url e: "qrc:/ab/c.txt"
property bool t3: e
property string f: "a"
property bool t4: f
property var j: 1
property bool t5: j
id: k
property bool t6: k
property date l
property bool t7: l
property url m
property bool t8: m
property int b: 0
property bool f1: b
property QtObject d: null
property bool f2: d
property string g
property bool f3: g
property var h: undefined
property bool f4: h
property var i: null
property bool f5: i
}
@@ -0,0 +1,15 @@
pragma Strict
import TestTypes
import QtQuick
Loader {
id: self
source: "BaseMember.qml"
property int ppp: -99
onItemChanged: {
var base = item as BaseMember;
if (base)
base.ppp = ppp
}
}
@@ -0,0 +1,24 @@
pragma Strict
pragma ComponentBehavior: Bound
import QtQml
QtObject {
id: root
property string foo: "bar"
property Component c1: Component {
QtObject {
id: c1
objectName: root.foo
property int i: 12
property Component c2: Component {
QtObject {
objectName: root.foo + c1.i
}
}
property QtObject o: c2.createObject()
}
}
property QtObject o: c1.createObject()
}
@@ -0,0 +1,6 @@
import QtQml
QtObject {
property QtObject a: QtObject {}
property QtObject b: a as SomethingElse
}
@@ -0,0 +1,5 @@
import QtQml
QtObject {
property Component c: Qt.createComponent("Dummy.qml")
}
@@ -0,0 +1,10 @@
pragma Strict
import QtQml
import TestTypes
QtObject {
Component.onCompleted: {
// Call the factory function and then forget the object
const orphanedObj = CppBridge.singleObj(0)
}
}
@@ -0,0 +1,6 @@
import QtQml
QtObject {
property Person person: Person { name: "horst" }
objectName: person.getName()
}
@@ -0,0 +1,9 @@
import QtQml
QtObject {
Component.onCompleted: {
let f = console.error;
const data = [f, ["That is great!"]]
data[0](...data[1]);
}
}
@@ -0,0 +1,28 @@
import QtQml
import TestTypes
QtObject {
property ObjectWithMethod child: ObjectWithMethod {
objectName: "kraut"
function doString() { overloaded("string"); }
function doNumber() { overloaded(5.2); }
function doArray() { overloaded({a: 2, b: 3, c: 3}); }
function doString2() { overloaded2("string"); }
function doNumber2() { overloaded2(5.2); }
// Artificially pass an extra argument to avoid choosing the "string" overload.
// Unfortunately this is still order-dependent on the metaobject level.
function doArray2() { overloaded2({a: 2, b: 3, c: 3}, 1); }
function doFoo() { foo(this); }
}
objectName: child.objectName
property int doneThing: child.doThing()
property int usingFinal: child.fff
function setChildObjectName(name: string) {
child.objectName = name
}
}
@@ -0,0 +1,25 @@
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef COLLECTOR_H
#define COLLECTOR_H
#include <QtCore/qobject.h>
#include <QtQmlIntegration/qqmlintegration.h>
#include <QtQml/qjsengine.h>
class Collector : public QObject
{
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(int gc READ gc CONSTANT)
public:
int gc() const
{
qjsEngine(this)->collectGarbage();
return 1;
}
};
#endif // COLLECTOR_H

Some files were not shown because too many files have changed in this diff Show More