aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/imports/folderlistmodel/folderlistmodel.pro2
-rw-r--r--src/imports/folderlistmodel/plugin.cpp9
-rw-r--r--src/imports/folderlistmodel/qquickfolderlistmodel.h15
-rw-r--r--src/imports/labsanimation/labsanimation.pro2
-rw-r--r--src/imports/labsanimation/plugin.cpp8
-rw-r--r--src/imports/labsanimation/qquickboundaryrule_p.h1
-rw-r--r--src/imports/labsmodels/labsmodels.pro2
-rw-r--r--src/imports/labsmodels/plugin.cpp8
-rw-r--r--src/imports/labsmodels/qqmldelegatecomponent.cpp24
-rw-r--r--src/imports/labsmodels/qqmldelegatecomponent_p.h5
-rw-r--r--src/imports/labsmodels/qqmltablemodel.cpp17
-rw-r--r--src/imports/labsmodels/qqmltablemodel_p.h3
-rw-r--r--src/imports/labsmodels/qqmltablemodelcolumn_p.h1
-rw-r--r--src/imports/layouts/layouts.pro2
-rw-r--r--src/imports/layouts/plugin.cpp4
-rw-r--r--src/imports/layouts/qquicklayout.cpp21
-rw-r--r--src/imports/layouts/qquicklayout_p.h5
-rw-r--r--src/imports/layouts/qquicklinearlayout.cpp10
-rw-r--r--src/imports/layouts/qquicklinearlayout_p.h14
-rw-r--r--src/imports/layouts/qquickstacklayout_p.h2
-rw-r--r--src/imports/localstorage/localstorage.pro2
-rw-r--r--src/imports/localstorage/plugin.cpp4
-rw-r--r--src/imports/localstorage/qquicklocalstorage_p.h1
-rw-r--r--src/imports/models/models.pro2
-rw-r--r--src/imports/models/plugin.cpp17
-rw-r--r--src/imports/particles/particles.pro2
-rw-r--r--src/imports/particles/plugin.cpp7
-rw-r--r--src/imports/qtqml/plugin.cpp10
-rw-r--r--src/imports/qtqml/qtqml.pro2
-rw-r--r--src/imports/qtquick2/plugin.cpp10
-rw-r--r--src/imports/qtquick2/qtquick2.pro2
-rw-r--r--src/imports/settings/plugin.cpp8
-rw-r--r--src/imports/settings/qqmlsettings_p.h1
-rw-r--r--src/imports/settings/settings.pro2
-rw-r--r--src/imports/shapes/plugin.cpp2
-rw-r--r--src/imports/shapes/shapes.pro2
-rw-r--r--src/imports/sharedimage/plugin.cpp8
-rw-r--r--src/imports/sharedimage/qsharedimageloader_p.h5
-rw-r--r--src/imports/sharedimage/sharedimage.pro2
-rw-r--r--src/imports/statemachine/childrenprivate.h138
-rw-r--r--src/imports/statemachine/finalstate.cpp4
-rw-r--r--src/imports/statemachine/finalstate.h3
-rw-r--r--src/imports/statemachine/plugin.cpp8
-rw-r--r--src/imports/statemachine/signaltransition.h1
-rw-r--r--src/imports/statemachine/state.cpp4
-rw-r--r--src/imports/statemachine/state.h3
-rw-r--r--src/imports/statemachine/statemachine.cpp4
-rw-r--r--src/imports/statemachine/statemachine.h3
-rw-r--r--src/imports/statemachine/statemachine.pro2
-rw-r--r--src/imports/statemachine/statemachineforeign.h4
-rw-r--r--src/imports/statemachine/timeouttransition.h1
-rw-r--r--src/imports/testlib/TestCase.qml17
-rw-r--r--src/imports/testlib/dependencies.json (renamed from src/qmltest/dependencies.json)0
-rw-r--r--src/imports/testlib/main.cpp8
-rw-r--r--src/imports/testlib/quicktestevent_p.h4
-rw-r--r--src/imports/testlib/quicktestresultforeign_p.h1
-rw-r--r--src/imports/testlib/quicktestutil_p.h1
-rw-r--r--src/imports/testlib/testlib.pro2
-rw-r--r--src/imports/wavefrontmesh/plugin.cpp4
-rw-r--r--src/imports/wavefrontmesh/qwavefrontmesh.cpp10
-rw-r--r--src/imports/wavefrontmesh/qwavefrontmesh.h1
-rw-r--r--src/imports/wavefrontmesh/wavefrontmesh.pro2
-rw-r--r--src/imports/window/plugin.cpp8
-rw-r--r--src/imports/window/plugin.h20
-rw-r--r--src/imports/window/window.pro2
-rw-r--r--src/imports/workerscript/plugin.cpp17
-rw-r--r--src/imports/workerscript/workerscript.pro2
-rw-r--r--src/particles/particles.pro2
-rw-r--r--src/particles/qquickage_p.h1
-rw-r--r--src/particles/qquickangledirection_p.h1
-rw-r--r--src/particles/qquickcumulativedirection_p.h1
-rw-r--r--src/particles/qquickcustomaffector_p.h1
-rw-r--r--src/particles/qquickcustomparticle.cpp2
-rw-r--r--src/particles/qquickcustomparticle_p.h1
-rw-r--r--src/particles/qquickdirection_p.h1
-rw-r--r--src/particles/qquickellipseextruder_p.h1
-rw-r--r--src/particles/qquickfriction_p.h1
-rw-r--r--src/particles/qquickgravity_p.h1
-rw-r--r--src/particles/qquickgroupgoal_p.h1
-rw-r--r--src/particles/qquickimageparticle.cpp18
-rw-r--r--src/particles/qquickimageparticle_p.h1
-rw-r--r--src/particles/qquickitemparticle_p.h1
-rw-r--r--src/particles/qquicklineextruder_p.h1
-rw-r--r--src/particles/qquickmaskextruder_p.h1
-rw-r--r--src/particles/qquickparticleaffector_p.h1
-rw-r--r--src/particles/qquickparticleemitter_p.h1
-rw-r--r--src/particles/qquickparticleextruder_p.h1
-rw-r--r--src/particles/qquickparticlegroup.cpp13
-rw-r--r--src/particles/qquickparticlegroup_p.h1
-rw-r--r--src/particles/qquickparticlepainter_p.h1
-rw-r--r--src/particles/qquickparticlesystem_p.h1
-rw-r--r--src/particles/qquickpointattractor_p.h1
-rw-r--r--src/particles/qquickpointdirection_p.h1
-rw-r--r--src/particles/qquickrectangleextruder_p.h1
-rw-r--r--src/particles/qquickspritegoal_p.h1
-rw-r--r--src/particles/qquicktargetdirection_p.h1
-rw-r--r--src/particles/qquicktrailemitter_p.h1
-rw-r--r--src/particles/qquickturbulence_p.h1
-rw-r--r--src/particles/qquickwander_p.h1
-rw-r--r--src/particles/qtquickparticlesglobal_p.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp5
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp8
-rw-r--r--src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qmldbg_preview.pro2
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmldebugtranslationservice.cpp68
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmldebugtranslationservice.h87
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.json2
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservicefactory.cpp8
-rw-r--r--src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp7
-rw-r--r--src/plugins/qmltooling/qmltooling.pro2
-rw-r--r--src/qml/common/common.pri1
-rw-r--r--src/qml/common/qqmlapiversion_p.h2
-rw-r--r--src/qml/common/qqmljsdiagnosticmessage_p.h5
-rw-r--r--src/qml/common/qqmljssourcelocation_p.h (renamed from src/qml/parser/qqmljssourcelocation_p.h)6
-rw-r--r--src/qml/common/qv4compileddata_p.h43
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp155
-rw-r--r--src/qml/compiler/qqmlirbuilder_p.h45
-rw-r--r--src/qml/compiler/qv4bytecodegenerator.cpp2
-rw-r--r--src/qml/compiler/qv4bytecodegenerator_p.h4
-rw-r--r--src/qml/compiler/qv4codegen.cpp5
-rw-r--r--src/qml/compiler/qv4codegen_p.h12
-rw-r--r--src/qml/compiler/qv4compilercontext.cpp5
-rw-r--r--src/qml/compiler/qv4compilercontext_p.h12
-rw-r--r--src/qml/compiler/qv4compilerscanfunctions.cpp6
-rw-r--r--src/qml/compiler/qv4compilerscanfunctions_p.h2
-rw-r--r--src/qml/debugger/qqmldebugserviceinterfaces.cpp1
-rw-r--r--src/qml/debugger/qqmldebugserviceinterfaces_p.h22
-rw-r--r--src/qml/doc/snippets/code/backend/backend.h2
-rw-r--r--src/qml/doc/snippets/code/backend/backend.pro17
-rw-r--r--src/qml/doc/snippets/code/backend/main.cpp4
-rw-r--r--src/qml/doc/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp144
-rw-r--r--src/qml/doc/snippets/qml/integrating-javascript/scarceresources/avatarExample.h3
-rw-r--r--src/qml/doc/snippets/qml/integrating-javascript/scarceresources/scarceresources.pro22
-rw-r--r--src/qml/doc/snippets/qml/qml-documents/A.qml61
-rw-r--r--src/qml/doc/snippets/qml/qml-documents/B.qml58
-rw-r--r--src/qml/doc/snippets/qml/qml-documents/Images.qml84
-rw-r--r--src/qml/doc/snippets/qml/qml-documents/LabeledImageBox.qml64
-rw-r--r--src/qml/doc/src/cppintegration/data.qdoc21
-rw-r--r--src/qml/doc/src/cppintegration/definetypes.qdoc136
-rw-r--r--src/qml/doc/src/cppintegration/extending-tutorial.qdoc29
-rw-r--r--src/qml/doc/src/cppintegration/topic.qdoc18
-rw-r--r--src/qml/doc/src/javascript/expressions.qdoc4
-rw-r--r--src/qml/doc/src/javascript/imports.qdoc2
-rw-r--r--src/qml/doc/src/qmlfunctions.qdoc305
-rw-r--r--src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc114
-rw-r--r--src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc43
-rw-r--r--src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc49
-rw-r--r--src/qml/doc/src/qmllanguageref/syntax/imports.qdoc12
-rw-r--r--src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc52
-rw-r--r--src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc33
-rw-r--r--src/qml/jsapi/qjsengine_p.h12
-rw-r--r--src/qml/jsruntime/qv4arrayobject.cpp8
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp8
-rw-r--r--src/qml/jsruntime/qv4engine.cpp52
-rw-r--r--src/qml/jsruntime/qv4engine_p.h6
-rw-r--r--src/qml/jsruntime/qv4executablecompilationunit.cpp2
-rw-r--r--src/qml/jsruntime/qv4executablecompilationunit_p.h12
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp19
-rw-r--r--src/qml/jsruntime/qv4functionobject_p.h4
-rw-r--r--src/qml/jsruntime/qv4include.cpp2
-rw-r--r--src/qml/jsruntime/qv4jsonobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4lookup.cpp15
-rw-r--r--src/qml/jsruntime/qv4object.cpp2
-rw-r--r--src/qml/jsruntime/qv4objectproto.cpp2
-rw-r--r--src/qml/jsruntime/qv4persistent.cpp1
-rw-r--r--src/qml/jsruntime/qv4promiseobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4proxy.cpp24
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp7
-rw-r--r--src/qml/jsruntime/qv4reflect.cpp3
-rw-r--r--src/qml/jsruntime/qv4regexpobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp35
-rw-r--r--src/qml/jsruntime/qv4runtimecodegen.cpp4
-rw-r--r--src/qml/jsruntime/qv4runtimecodegen_p.h4
-rw-r--r--src/qml/jsruntime/qv4script.cpp9
-rw-r--r--src/qml/jsruntime/qv4stringobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4typedarray.cpp6
-rw-r--r--src/qml/jsruntime/qv4value.cpp4
-rw-r--r--src/qml/jsruntime/qv4value_p.h25
-rw-r--r--src/qml/memory/qv4mm.cpp21
-rw-r--r--src/qml/memory/qv4mmdefs_p.h42
-rw-r--r--src/qml/parser/parser.pri4
-rw-r--r--src/qml/parser/qqmljs.g186
-rw-r--r--src/qml/parser/qqmljsast.cpp263
-rw-r--r--src/qml/parser/qqmljsast_p.h343
-rw-r--r--src/qml/parser/qqmljsastfwd_p.h7
-rw-r--r--src/qml/parser/qqmljsastvisitor.cpp6
-rw-r--r--src/qml/parser/qqmljsastvisitor_p.h802
-rw-r--r--src/qml/parser/qqmljsengine_p.cpp4
-rw-r--r--src/qml/parser/qqmljsengine_p.h6
-rw-r--r--src/qml/parser/qqmljslexer.cpp10
-rw-r--r--src/qml/qml.pro2
-rw-r--r--src/qml/qml/ftw/qqmlthread.cpp22
-rw-r--r--src/qml/qml/qqml.cpp158
-rw-r--r--src/qml/qml/qqml.h269
-rw-r--r--src/qml/qml/qqmlbinding.cpp9
-rw-r--r--src/qml/qml/qqmlcomponent.cpp5
-rw-r--r--src/qml/qml/qqmlcomponent.h1
-rw-r--r--src/qml/qml/qqmlcomponentattached_p.h1
-rw-r--r--src/qml/qml/qqmlcustomparser.cpp40
-rw-r--r--src/qml/qml/qqmlcustomparser_p.h9
-rw-r--r--src/qml/qml/qqmldatablob.cpp33
-rw-r--r--src/qml/qml/qqmldatablob_p.h1
-rw-r--r--src/qml/qml/qqmlengine.cpp172
-rw-r--r--src/qml/qml/qqmlengine.h4
-rw-r--r--src/qml/qml/qqmlengine_p.h31
-rw-r--r--src/qml/qml/qqmlerror.cpp15
-rw-r--r--src/qml/qml/qqmlextensionplugin.cpp10
-rw-r--r--src/qml/qml/qqmlextensionplugin.h1
-rw-r--r--src/qml/qml/qqmlfile.cpp2
-rw-r--r--src/qml/qml/qqmlimport.cpp389
-rw-r--r--src/qml/qml/qqmlimport_p.h40
-rw-r--r--src/qml/qml/qqmlincubator.cpp4
-rw-r--r--src/qml/qml/qqmlincubator_p.h4
-rw-r--r--src/qml/qml/qqmlinfo.cpp5
-rw-r--r--src/qml/qml/qqmlirloader.cpp6
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp5
-rw-r--r--src/qml/qml/qqmllocale.cpp4
-rw-r--r--src/qml/qml/qqmllocale_p.h2
-rw-r--r--src/qml/qml/qqmlloggingcategory_p.h4
-rw-r--r--src/qml/qml/qqmlmetatype.cpp301
-rw-r--r--src/qml/qml/qqmlmetatype_p.h46
-rw-r--r--src/qml/qml/qqmlmetatypedata.cpp55
-rw-r--r--src/qml/qml/qqmlmetatypedata_p.h32
-rw-r--r--src/qml/qml/qqmlmoduleregistration.cpp20
-rw-r--r--src/qml/qml/qqmlmoduleregistration.h7
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp61
-rw-r--r--src/qml/qml/qqmlobjectcreator_p.h3
-rw-r--r--src/qml/qml/qqmlprivate.h104
-rw-r--r--src/qml/qml/qqmlproperty.cpp47
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp69
-rw-r--r--src/qml/qml/qqmlpropertycache_p.h22
-rw-r--r--src/qml/qml/qqmlpropertycachecreator.cpp7
-rw-r--r--src/qml/qml/qqmlpropertycachecreator_p.h105
-rw-r--r--src/qml/qml/qqmlpropertydata_p.h45
-rw-r--r--src/qml/qml/qqmlpropertyvalidator.cpp49
-rw-r--r--src/qml/qml/qqmlpropertyvalidator_p.h13
-rw-r--r--src/qml/qml/qqmlscriptblob.cpp5
-rw-r--r--src/qml/qml/qqmltype.cpp50
-rw-r--r--src/qml/qml/qqmltype_p.h14
-rw-r--r--src/qml/qml/qqmltype_p_p.h9
-rw-r--r--src/qml/qml/qqmltypecompiler.cpp51
-rw-r--r--src/qml/qml/qqmltypecompiler_p.h9
-rw-r--r--src/qml/qml/qqmltypedata.cpp95
-rw-r--r--src/qml/qml/qqmltypedata_p.h9
-rw-r--r--src/qml/qml/qqmltypeloader.cpp112
-rw-r--r--src/qml/qml/qqmltypeloader_p.h3
-rw-r--r--src/qml/qml/qqmltypeloaderqmldircontent.cpp9
-rw-r--r--src/qml/qml/qqmltypemodule.cpp24
-rw-r--r--src/qml/qml/qqmltypemodule_p.h15
-rw-r--r--src/qml/qml/qqmltypemodule_p_p.h6
-rw-r--r--src/qml/qml/qqmltypemoduleversion.cpp20
-rw-r--r--src/qml/qml/qqmltypemoduleversion_p.h8
-rw-r--r--src/qml/qml/qqmltypenamecache.cpp8
-rw-r--r--src/qml/qml/qqmltypenotavailable.cpp2
-rw-r--r--src/qml/qml/qqmltypenotavailable_p.h5
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp8
-rw-r--r--src/qml/qml/qqmlvaluetype.cpp92
-rw-r--r--src/qml/qml/qqmlvaluetype_p.h60
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp78
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp24
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp179
-rw-r--r--src/qml/qmldirparser/qqmldirparser.cpp54
-rw-r--r--src/qml/qmldirparser/qqmldirparser_p.h15
-rw-r--r--src/qml/qtqmlglobal_p.h2
-rw-r--r--src/qml/types/qqmlbind_p.h5
-rw-r--r--src/qml/types/qqmlconnections.cpp3
-rw-r--r--src/qml/types/qqmlconnections_p.h5
-rw-r--r--src/qml/types/qqmltimer_p.h1
-rw-r--r--src/qmldebug/qmldebug.pro4
-rw-r--r--src/qmldebug/qqmldebugtranslationclient.cpp76
-rw-r--r--src/qmldebug/qqmldebugtranslationclient_p.h81
-rw-r--r--src/qmlmodels/dependencies.json (renamed from src/imports/models/dependencies.json)0
-rw-r--r--src/qmlmodels/qmlmodels.pro2
-rw-r--r--src/qmlmodels/qqmlabstractdelegatecomponent_p.h1
-rw-r--r--src/qmlmodels/qqmladaptormodel.cpp29
-rw-r--r--src/qmlmodels/qqmladaptormodel_p.h18
-rw-r--r--src/qmlmodels/qqmldelegatemodel.cpp24
-rw-r--r--src/qmlmodels/qqmldelegatemodel_p.h6
-rw-r--r--src/qmlmodels/qqmldelegatemodel_p_p.h12
-rw-r--r--src/qmlmodels/qqmlinstantiator_p.h2
-rw-r--r--src/qmlmodels/qqmllistaccessor.cpp6
-rw-r--r--src/qmlmodels/qqmllistaccessor_p.h2
-rw-r--r--src/qmlmodels/qqmllistmodel.cpp8
-rw-r--r--src/qmlmodels/qqmllistmodel_p.h4
-rw-r--r--src/qmlmodels/qqmllistmodelworkeragent_p.h1
-rw-r--r--src/qmlmodels/qqmlmodelsmodule_p.h2
-rw-r--r--src/qmlmodels/qqmlobjectmodel.cpp34
-rw-r--r--src/qmlmodels/qqmlobjectmodel_p.h17
-rw-r--r--src/qmlmodels/qqmltableinstancemodel.cpp28
-rw-r--r--src/qmlmodels/qqmltableinstancemodel_p.h9
-rw-r--r--src/qmlmodels/qquickpackage.cpp19
-rw-r--r--src/qmlmodels/qquickpackage_p.h1
-rw-r--r--src/qmlmodels/qtqmlmodelsglobal_p.h2
-rw-r--r--src/qmltest/quicktest.cpp2
-rw-r--r--src/qmltest/quicktestresult_p.h6
-rw-r--r--src/qmltyperegistrar/qmltyperegistrar.cpp53
-rw-r--r--src/qmltyperegistrar/qmltypesclassdescription.cpp84
-rw-r--r--src/qmltyperegistrar/qmltypesclassdescription.h18
-rw-r--r--src/qmltyperegistrar/qmltypescreator.cpp28
-rw-r--r--src/qmltyperegistrar/qmltypescreator.h4
-rw-r--r--src/qmlworkerscript/dependencies.json (renamed from src/imports/workerscript/dependencies.json)0
-rw-r--r--src/qmlworkerscript/qmlworkerscript.pro2
-rw-r--r--src/qmlworkerscript/qquickworkerscript.cpp4
-rw-r--r--src/qmlworkerscript/qquickworkerscript_p.h7
-rw-r--r--src/qmlworkerscript/qtqmlworkerscriptglobal_p.h2
-rw-r--r--src/quick/accessible/qaccessiblequickview.cpp8
-rw-r--r--src/quick/designer/qquickdesignersupportitems.cpp7
-rw-r--r--src/quick/designer/qquickdesignersupportitems_p.h3
-rw-r--r--src/quick/designer/qquickdesignersupportproperties.cpp8
-rw-r--r--src/quick/doc/snippets/qml/qml-data-models/listmodel-listview-required.qml81
-rw-r--r--src/quick/doc/snippets/qml/tableview/cpp-tablemodel.cpp47
-rw-r--r--src/quick/doc/snippets/qml/tableview/cpp-tablemodel.h94
-rw-r--r--src/quick/doc/snippets/qml/tableview/tableview.pro20
-rw-r--r--src/quick/doc/snippets/qml/xmlrole.xml20
-rw-r--r--src/quick/doc/src/concepts/modelviewsdata/modelview.qdoc20
-rw-r--r--src/quick/doc/src/qmltypereference.qdoc1
-rw-r--r--src/quick/handlers/qquickdragaxis_p.h2
-rw-r--r--src/quick/handlers/qquickdraghandler_p.h6
-rw-r--r--src/quick/handlers/qquickhandlerpoint.cpp7
-rw-r--r--src/quick/handlers/qquickhoverhandler.cpp70
-rw-r--r--src/quick/handlers/qquickhoverhandler_p.h3
-rw-r--r--src/quick/handlers/qquickpinchhandler.cpp43
-rw-r--r--src/quick/handlers/qquickpinchhandler_p.h28
-rw-r--r--src/quick/handlers/qquickpointerhandler.cpp84
-rw-r--r--src/quick/handlers/qquickpointerhandler_p.h19
-rw-r--r--src/quick/handlers/qquickpointerhandler_p_p.h2
-rw-r--r--src/quick/handlers/qquickpointhandler_p.h2
-rw-r--r--src/quick/handlers/qquicktaphandler_p.h2
-rw-r--r--src/quick/handlers/qquickwheelhandler_p.h2
-rw-r--r--src/quick/items/context2d/qquickcanvasitem_p.h1
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp4
-rw-r--r--src/quick/items/qquickaccessibleattached_p.h1
-rw-r--r--src/quick/items/qquickanchors_p.h1
-rw-r--r--src/quick/items/qquickanimatedimage.cpp2
-rw-r--r--src/quick/items/qquickanimatedimage_p.h5
-rw-r--r--src/quick/items/qquickanimatedsprite_p.h9
-rw-r--r--src/quick/items/qquickborderimage.cpp2
-rw-r--r--src/quick/items/qquickborderimage_p.h1
-rw-r--r--src/quick/items/qquickdrag.cpp1
-rw-r--r--src/quick/items/qquickdrag_p.h2
-rw-r--r--src/quick/items/qquickdroparea_p.h3
-rw-r--r--src/quick/items/qquickevents.cpp166
-rw-r--r--src/quick/items/qquickevents_p_p.h103
-rw-r--r--src/quick/items/qquickflickable.cpp19
-rw-r--r--src/quick/items/qquickflickable_p.h19
-rw-r--r--src/quick/items/qquickflickable_p_p.h3
-rw-r--r--src/quick/items/qquickflipable_p.h1
-rw-r--r--src/quick/items/qquickfocusscope_p.h1
-rw-r--r--src/quick/items/qquickgraphicsinfo.cpp2
-rw-r--r--src/quick/items/qquickgraphicsinfo_p.h2
-rw-r--r--src/quick/items/qquickgridview_p.h1
-rw-r--r--src/quick/items/qquickimage.cpp54
-rw-r--r--src/quick/items/qquickimage_p.h10
-rw-r--r--src/quick/items/qquickimagebase.cpp44
-rw-r--r--src/quick/items/qquickimagebase_p.h21
-rw-r--r--src/quick/items/qquickimagebase_p_p.h2
-rw-r--r--src/quick/items/qquickitem.cpp90
-rw-r--r--src/quick/items/qquickitem.h20
-rw-r--r--src/quick/items/qquickitem_p.h11
-rw-r--r--src/quick/items/qquickitemanimation_p.h3
-rw-r--r--src/quick/items/qquickitemgrabresult.cpp2
-rw-r--r--src/quick/items/qquickitemgrabresult.h6
-rw-r--r--src/quick/items/qquickitemsmodule.cpp7
-rw-r--r--src/quick/items/qquickitemsmodule_p.h14
-rw-r--r--src/quick/items/qquickitemview.cpp12
-rw-r--r--src/quick/items/qquickitemview_p.h22
-rw-r--r--src/quick/items/qquickitemviewtransition_p.h1
-rw-r--r--src/quick/items/qquicklistview.cpp168
-rw-r--r--src/quick/items/qquicklistview_p.h10
-rw-r--r--src/quick/items/qquickloader.cpp93
-rw-r--r--src/quick/items/qquickloader_p.h1
-rw-r--r--src/quick/items/qquickloader_p_p.h7
-rw-r--r--src/quick/items/qquickmousearea_p.h13
-rw-r--r--src/quick/items/qquickmultipointtoucharea.cpp28
-rw-r--r--src/quick/items/qquickmultipointtoucharea_p.h19
-rw-r--r--src/quick/items/qquickopenglinfo_p.h2
-rw-r--r--src/quick/items/qquickopenglshadereffect.cpp3
-rw-r--r--src/quick/items/qquickopenglshadereffectnode.cpp2
-rw-r--r--src/quick/items/qquickpainteditem.cpp3
-rw-r--r--src/quick/items/qquickpainteditem.h1
-rw-r--r--src/quick/items/qquickpathview_p.h7
-rw-r--r--src/quick/items/qquickpincharea_p.h5
-rw-r--r--src/quick/items/qquickpositioners.cpp1
-rw-r--r--src/quick/items/qquickpositioners_p.h41
-rw-r--r--src/quick/items/qquickrectangle_p.h6
-rw-r--r--src/quick/items/qquickrendercontrol.cpp2
-rw-r--r--src/quick/items/qquickrepeater_p.h1
-rw-r--r--src/quick/items/qquickscalegrid_p_p.h1
-rw-r--r--src/quick/items/qquickscreen_p.h20
-rw-r--r--src/quick/items/qquickshadereffect_p.h3
-rw-r--r--src/quick/items/qquickshadereffectmesh_p.h4
-rw-r--r--src/quick/items/qquickshadereffectsource.cpp4
-rw-r--r--src/quick/items/qquickshadereffectsource_p.h5
-rw-r--r--src/quick/items/qquicksprite_p.h1
-rw-r--r--src/quick/items/qquickspriteengine.cpp2
-rw-r--r--src/quick/items/qquickspriteengine_p.h12
-rw-r--r--src/quick/items/qquickspritesequence.cpp4
-rw-r--r--src/quick/items/qquickspritesequence_p.h1
-rw-r--r--src/quick/items/qquickstateoperations_p.h3
-rw-r--r--src/quick/items/qquicktableview.cpp41
-rw-r--r--src/quick/items/qquicktableview_p.h10
-rw-r--r--src/quick/items/qquicktableview_p_p.h4
-rw-r--r--src/quick/items/qquicktext.cpp19
-rw-r--r--src/quick/items/qquicktext_p.h49
-rw-r--r--src/quick/items/qquicktextdocument.h1
-rw-r--r--src/quick/items/qquicktextedit_p.h51
-rw-r--r--src/quick/items/qquicktextinput.cpp12
-rw-r--r--src/quick/items/qquicktextinput_p.h41
-rw-r--r--src/quick/items/qquicktranslate_p.h5
-rw-r--r--src/quick/items/qquickwindow.cpp117
-rw-r--r--src/quick/items/qquickwindow.h30
-rw-r--r--src/quick/items/qquickwindow_p.h10
-rw-r--r--src/quick/items/qquickwindowmodule_p.h4
-rw-r--r--src/quick/qtquickglobal_p.h2
-rw-r--r--src/quick/quick.pro11
-rw-r--r--src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp12
-rw-r--r--src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture_p.h2
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp3
-rw-r--r--src/quick/scenegraph/coreapi/qsggeometry.h2
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterialshader.cpp4
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterialshader.h2
-rw-r--r--src/quick/scenegraph/coreapi/qsgrenderer.cpp6
-rw-r--r--src/quick/scenegraph/coreapi/qsgtexture.cpp4
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer.cpp2
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.h1
-rw-r--r--src/quick/scenegraph/qsgdefaultinternalimagenode.cpp2
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp2
-rw-r--r--src/quick/scenegraph/qsgopengldistancefieldglyphcache.cpp2
-rw-r--r--src/quick/scenegraph/qsgopengldistancefieldglyphcache_p.h2
-rw-r--r--src/quick/scenegraph/qsgrhisupport.cpp2
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop.cpp16
-rw-r--r--src/quick/scenegraph/util/qsgengine.cpp2
-rw-r--r--src/quick/scenegraph/util/qsgopenglatlastexture_p.h2
-rw-r--r--src/quick/scenegraph/util/qsgshadersourcebuilder.cpp4
-rw-r--r--src/quick/scenegraph/util/qsgtexturematerial.cpp4
-rw-r--r--src/quick/util/qquickanimation_p.h13
-rw-r--r--src/quick/util/qquickanimationcontroller_p.h1
-rw-r--r--src/quick/util/qquickanimator_p.h14
-rw-r--r--src/quick/util/qquickanimatorjob.cpp1
-rw-r--r--src/quick/util/qquickapplication_p.h1
-rw-r--r--src/quick/util/qquickbehavior.cpp76
-rw-r--r--src/quick/util/qquickbehavior_p.h7
-rw-r--r--src/quick/util/qquickfontloader.cpp2
-rw-r--r--src/quick/util/qquickfontloader_p.h1
-rw-r--r--src/quick/util/qquickfontmetrics_p.h2
-rw-r--r--src/quick/util/qquickforeignutils_p.h7
-rw-r--r--src/quick/util/qquickglobal.cpp60
-rw-r--r--src/quick/util/qquickimageprovider.cpp18
-rw-r--r--src/quick/util/qquickpath.cpp4
-rw-r--r--src/quick/util/qquickpath_p.h31
-rw-r--r--src/quick/util/qquickpathinterpolator_p.h1
-rw-r--r--src/quick/util/qquickpixmapcache.cpp149
-rw-r--r--src/quick/util/qquickpixmapcache_p.h18
-rw-r--r--src/quick/util/qquickpropertychanges_p.h1
-rw-r--r--src/quick/util/qquickshortcut_p.h10
-rw-r--r--src/quick/util/qquicksmoothedanimation_p.h1
-rw-r--r--src/quick/util/qquickspringanimation_p.h1
-rw-r--r--src/quick/util/qquickstate.cpp10
-rw-r--r--src/quick/util/qquickstate_p.h2
-rw-r--r--src/quick/util/qquickstate_p_p.h17
-rw-r--r--src/quick/util/qquickstatechangescript_p.h1
-rw-r--r--src/quick/util/qquickstategroup.cpp36
-rw-r--r--src/quick/util/qquickstategroup_p.h1
-rw-r--r--src/quick/util/qquickstyledtext.cpp2
-rw-r--r--src/quick/util/qquicksystempalette_p.h1
-rw-r--r--src/quick/util/qquicktextmetrics_p.h2
-rw-r--r--src/quick/util/qquicktimeline_p_p.h3
-rw-r--r--src/quick/util/qquicktransition_p.h1
-rw-r--r--src/quick/util/qquickvalidator_p.h2
-rw-r--r--src/quick/util/qquickvaluetypes.cpp42
-rw-r--r--src/quick/util/qquickvaluetypes_p.h54
-rw-r--r--src/quickshapes/qquickshape_p.h12
-rw-r--r--src/quickshapes/qquickshapesglobal_p.h1
-rw-r--r--src/quickshapes/quickshapes.pro2
-rw-r--r--src/quickwidgets/qquickwidget.cpp4
-rw-r--r--src/src.pro3
476 files changed, 7599 insertions, 3384 deletions
diff --git a/src/imports/folderlistmodel/folderlistmodel.pro b/src/imports/folderlistmodel/folderlistmodel.pro
index 8eaf9de6b9..c95a88430d 100644
--- a/src/imports/folderlistmodel/folderlistmodel.pro
+++ b/src/imports/folderlistmodel/folderlistmodel.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = qmlfolderlistmodelplugin
TARGETPATH = Qt/labs/folderlistmodel
-IMPORT_VERSION = 2.15
+QML_IMPORT_VERSION = $$QT_VERSION
QT = core-private qml-private
diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp
index 28837655ef..7a38769b77 100644
--- a/src/imports/folderlistmodel/plugin.cpp
+++ b/src/imports/folderlistmodel/plugin.cpp
@@ -42,6 +42,8 @@
#include "qquickfolderlistmodel.h"
+extern void qml_register_types_Qt_labs_folderlistmodel();
+
QT_BEGIN_NAMESPACE
//![class decl]
@@ -51,7 +53,12 @@ class QmlFolderListModelPlugin : public QQmlExtensionPlugin
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
- QmlFolderListModelPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { }
+ QmlFolderListModelPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent)
+ {
+ volatile auto registration = &qml_register_types_Qt_labs_folderlistmodel;
+ Q_UNUSED(registration);
+ }
+
void registerTypes(const char *uri) override
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.folderlistmodel"));
diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.h b/src/imports/folderlistmodel/qquickfolderlistmodel.h
index 5897bd2e0f..d7429efeda 100644
--- a/src/imports/folderlistmodel/qquickfolderlistmodel.h
+++ b/src/imports/folderlistmodel/qquickfolderlistmodel.h
@@ -67,19 +67,20 @@ class QQuickFolderListModel : public QAbstractListModel, public QQmlParserStatus
Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters)
Q_PROPERTY(SortField sortField READ sortField WRITE setSortField)
Q_PROPERTY(bool sortReversed READ sortReversed WRITE setSortReversed)
- Q_PROPERTY(bool showFiles READ showFiles WRITE setShowFiles REVISION 1)
+ Q_PROPERTY(bool showFiles READ showFiles WRITE setShowFiles REVISION(2, 1))
Q_PROPERTY(bool showDirs READ showDirs WRITE setShowDirs)
Q_PROPERTY(bool showDirsFirst READ showDirsFirst WRITE setShowDirsFirst)
Q_PROPERTY(bool showDotAndDotDot READ showDotAndDotDot WRITE setShowDotAndDotDot)
- Q_PROPERTY(bool showHidden READ showHidden WRITE setShowHidden REVISION 1)
+ Q_PROPERTY(bool showHidden READ showHidden WRITE setShowHidden REVISION(2, 1))
Q_PROPERTY(bool showOnlyReadable READ showOnlyReadable WRITE setShowOnlyReadable)
- Q_PROPERTY(bool caseSensitive READ caseSensitive WRITE setCaseSensitive REVISION 2)
+ Q_PROPERTY(bool caseSensitive READ caseSensitive WRITE setCaseSensitive REVISION(2, 2))
Q_PROPERTY(int count READ count NOTIFY countChanged)
- Q_PROPERTY(Status status READ status NOTIFY statusChanged REVISION 11)
- Q_PROPERTY(bool sortCaseSensitive READ sortCaseSensitive WRITE setSortCaseSensitive REVISION 12)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged REVISION(2, 11))
+ Q_PROPERTY(bool sortCaseSensitive READ sortCaseSensitive WRITE setSortCaseSensitive REVISION(2, 12))
//![class props]
QML_NAMED_ELEMENT(FolderListModel)
+ QML_ADDED_IN_VERSION(2, 0)
//![abslistmodel]
public:
QQuickFolderListModel(QObject *parent = nullptr);
@@ -163,8 +164,8 @@ public:
Q_SIGNALS:
void folderChanged();
void rowCountChanged() const;
- Q_REVISION(1) void countChanged() const;
- Q_REVISION(11) void statusChanged();
+ Q_REVISION(2, 1) void countChanged() const;
+ Q_REVISION(2, 11) void statusChanged();
//![notifier]
//![class end]
diff --git a/src/imports/labsanimation/labsanimation.pro b/src/imports/labsanimation/labsanimation.pro
index f64ae775c6..5fd8ff25a7 100644
--- a/src/imports/labsanimation/labsanimation.pro
+++ b/src/imports/labsanimation/labsanimation.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = labsanimationplugin
TARGETPATH = Qt/labs/animation
-IMPORT_VERSION = 1.0
+QML_IMPORT_VERSION = $$QT_VERSION
SOURCES += \
qquickboundaryrule.cpp \
diff --git a/src/imports/labsanimation/plugin.cpp b/src/imports/labsanimation/plugin.cpp
index bd732a6aba..9c985f0dcf 100644
--- a/src/imports/labsanimation/plugin.cpp
+++ b/src/imports/labsanimation/plugin.cpp
@@ -42,6 +42,8 @@
#include "qquickboundaryrule_p.h"
+extern void qml_register_types_Qt_labs_animation();
+
QT_BEGIN_NAMESPACE
/*!
@@ -66,7 +68,11 @@ class QtLabsAnimationPlugin : public QQmlEngineExtensionPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid)
public:
- QtLabsAnimationPlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent) { }
+ QtLabsAnimationPlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent)
+ {
+ volatile auto registration = &qml_register_types_Qt_labs_animation;
+ Q_UNUSED(registration);
+ }
};
//![class decl]
diff --git a/src/imports/labsanimation/qquickboundaryrule_p.h b/src/imports/labsanimation/qquickboundaryrule_p.h
index 1681558304..33cf0bb094 100644
--- a/src/imports/labsanimation/qquickboundaryrule_p.h
+++ b/src/imports/labsanimation/qquickboundaryrule_p.h
@@ -78,6 +78,7 @@ class QQuickBoundaryRule : public QObject, public QQmlPropertyValueInterceptor
Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
Q_PROPERTY(int returnDuration READ returnDuration WRITE setReturnDuration NOTIFY returnDurationChanged)
QML_NAMED_ELEMENT(BoundaryRule)
+ QML_ADDED_IN_VERSION(1, 0)
public:
enum OvershootFilter {
diff --git a/src/imports/labsmodels/labsmodels.pro b/src/imports/labsmodels/labsmodels.pro
index 13468348cb..9fc52ce9cc 100644
--- a/src/imports/labsmodels/labsmodels.pro
+++ b/src/imports/labsmodels/labsmodels.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = labsmodelsplugin
TARGETPATH = Qt/labs/qmlmodels
-IMPORT_VERSION = 1.0
+QML_IMPORT_VERSION = $$QT_VERSION
QT = qml-private qmlmodels-private
diff --git a/src/imports/labsmodels/plugin.cpp b/src/imports/labsmodels/plugin.cpp
index feb4f3ba0a..ab5e0023a6 100644
--- a/src/imports/labsmodels/plugin.cpp
+++ b/src/imports/labsmodels/plugin.cpp
@@ -50,6 +50,8 @@
#include "qqmldelegatecomponent_p.h"
#endif
+extern void qml_register_types_Qt_labs_qmlmodels();
+
QT_BEGIN_NAMESPACE
/*!
@@ -74,7 +76,11 @@ class QtQmlLabsModelsPlugin : public QQmlEngineExtensionPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid)
public:
- QtQmlLabsModelsPlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent) { }
+ QtQmlLabsModelsPlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent)
+ {
+ volatile auto registration = &qml_register_types_Qt_labs_qmlmodels;
+ Q_UNUSED(registration);
+ }
};
//![class decl]
diff --git a/src/imports/labsmodels/qqmldelegatecomponent.cpp b/src/imports/labsmodels/qqmldelegatecomponent.cpp
index aaf3fea5da..b8eb8049b3 100644
--- a/src/imports/labsmodels/qqmldelegatecomponent.cpp
+++ b/src/imports/labsmodels/qqmldelegatecomponent.cpp
@@ -250,7 +250,9 @@ QQmlListProperty<QQmlDelegateChoice> QQmlDelegateChooser::choices()
QQmlDelegateChooser::choices_append,
QQmlDelegateChooser::choices_count,
QQmlDelegateChooser::choices_at,
- QQmlDelegateChooser::choices_clear);
+ QQmlDelegateChooser::choices_clear,
+ QQmlDelegateChooser::choices_replace,
+ QQmlDelegateChooser::choices_removeLast);
}
void QQmlDelegateChooser::choices_append(QQmlListProperty<QQmlDelegateChoice> *prop, QQmlDelegateChoice *choice)
@@ -282,6 +284,26 @@ void QQmlDelegateChooser::choices_clear(QQmlListProperty<QQmlDelegateChoice> *pr
q->delegateChanged();
}
+void QQmlDelegateChooser::choices_replace(QQmlListProperty<QQmlDelegateChoice> *prop, int index,
+ QQmlDelegateChoice *choice)
+{
+ QQmlDelegateChooser *q = static_cast<QQmlDelegateChooser *>(prop->object);
+ disconnect(q->m_choices[index], &QQmlDelegateChoice::changed,
+ q, &QQmlAbstractDelegateComponent::delegateChanged);
+ q->m_choices[index] = choice;
+ connect(choice, &QQmlDelegateChoice::changed, q,
+ &QQmlAbstractDelegateComponent::delegateChanged);
+ q->delegateChanged();
+}
+
+void QQmlDelegateChooser::choices_removeLast(QQmlListProperty<QQmlDelegateChoice> *prop)
+{
+ QQmlDelegateChooser *q = static_cast<QQmlDelegateChooser *>(prop->object);
+ disconnect(q->m_choices.takeLast(), &QQmlDelegateChoice::changed,
+ q, &QQmlAbstractDelegateComponent::delegateChanged);
+ q->delegateChanged();
+}
+
QQmlComponent *QQmlDelegateChooser::delegate(QQmlAdaptorModel *adaptorModel, int row, int column) const
{
QVariant v;
diff --git a/src/imports/labsmodels/qqmldelegatecomponent_p.h b/src/imports/labsmodels/qqmldelegatecomponent_p.h
index 4c39dc0d0a..9655d1baf9 100644
--- a/src/imports/labsmodels/qqmldelegatecomponent_p.h
+++ b/src/imports/labsmodels/qqmldelegatecomponent_p.h
@@ -69,6 +69,8 @@ class QQmlDelegateChoice : public QObject
Q_PROPERTY(QQmlComponent* delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_CLASSINFO("DefaultProperty", "delegate")
QML_NAMED_ELEMENT(DelegateChoice)
+ QML_ADDED_IN_VERSION(1, 0)
+
public:
QVariant roleValue() const;
void setRoleValue(const QVariant &roleValue);
@@ -106,6 +108,7 @@ class QQmlDelegateChooser : public QQmlAbstractDelegateComponent
Q_PROPERTY(QQmlListProperty<QQmlDelegateChoice> choices READ choices CONSTANT)
Q_CLASSINFO("DefaultProperty", "choices")
QML_NAMED_ELEMENT(DelegateChooser)
+ QML_ADDED_IN_VERSION(1, 0)
public:
QString role() const { return m_role; }
@@ -116,6 +119,8 @@ public:
static int choices_count(QQmlListProperty<QQmlDelegateChoice> *);
static QQmlDelegateChoice *choices_at(QQmlListProperty<QQmlDelegateChoice> *, int);
static void choices_clear(QQmlListProperty<QQmlDelegateChoice> *);
+ static void choices_replace(QQmlListProperty<QQmlDelegateChoice> *, int, QQmlDelegateChoice *);
+ static void choices_removeLast(QQmlListProperty<QQmlDelegateChoice> *);
QQmlComponent *delegate(QQmlAdaptorModel *adaptorModel, int row, int column = -1) const override;
diff --git a/src/imports/labsmodels/qqmltablemodel.cpp b/src/imports/labsmodels/qqmltablemodel.cpp
index b6468d760f..6ba2cecf19 100644
--- a/src/imports/labsmodels/qqmltablemodel.cpp
+++ b/src/imports/labsmodels/qqmltablemodel.cpp
@@ -644,7 +644,9 @@ QQmlListProperty<QQmlTableModelColumn> QQmlTableModel::columns()
&QQmlTableModel::columns_append,
&QQmlTableModel::columns_count,
&QQmlTableModel::columns_at,
- &QQmlTableModel::columns_clear);
+ &QQmlTableModel::columns_clear,
+ &QQmlTableModel::columns_replace,
+ &QQmlTableModel::columns_removeLast);
}
void QQmlTableModel::columns_append(QQmlListProperty<QQmlTableModelColumn> *property,
@@ -674,6 +676,19 @@ void QQmlTableModel::columns_clear(QQmlListProperty<QQmlTableModelColumn> *prope
return model->mColumns.clear();
}
+void QQmlTableModel::columns_replace(QQmlListProperty<QQmlTableModelColumn> *property, int index, QQmlTableModelColumn *value)
+{
+ QQmlTableModel *model = static_cast<QQmlTableModel*>(property->object);
+ if (QQmlTableModelColumn *column = qobject_cast<QQmlTableModelColumn*>(value))
+ return model->mColumns.replace(index, column);
+}
+
+void QQmlTableModel::columns_removeLast(QQmlListProperty<QQmlTableModelColumn> *property)
+{
+ QQmlTableModel *model = static_cast<QQmlTableModel*>(property->object);
+ model->mColumns.removeLast();
+}
+
/*!
\qmlmethod QModelIndex TableModel::index(int row, int column)
diff --git a/src/imports/labsmodels/qqmltablemodel_p.h b/src/imports/labsmodels/qqmltablemodel_p.h
index d6e982d19a..ae46cbe35c 100644
--- a/src/imports/labsmodels/qqmltablemodel_p.h
+++ b/src/imports/labsmodels/qqmltablemodel_p.h
@@ -74,6 +74,7 @@ class QQmlTableModel : public QAbstractTableModel, public QQmlParserStatus
Q_INTERFACES(QQmlParserStatus)
Q_CLASSINFO("DefaultProperty", "columns")
QML_NAMED_ELEMENT(TableModel)
+ QML_ADDED_IN_VERSION(1, 0)
public:
QQmlTableModel(QObject *parent = nullptr);
@@ -96,6 +97,8 @@ public:
static int columns_count(QQmlListProperty<QQmlTableModelColumn> *property);
static QQmlTableModelColumn *columns_at(QQmlListProperty<QQmlTableModelColumn> *property, int index);
static void columns_clear(QQmlListProperty<QQmlTableModelColumn> *property);
+ static void columns_replace(QQmlListProperty<QQmlTableModelColumn> *property, int index, QQmlTableModelColumn *value);
+ static void columns_removeLast(QQmlListProperty<QQmlTableModelColumn> *property);
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
diff --git a/src/imports/labsmodels/qqmltablemodelcolumn_p.h b/src/imports/labsmodels/qqmltablemodelcolumn_p.h
index a18f21ab4f..2860a915cc 100644
--- a/src/imports/labsmodels/qqmltablemodelcolumn_p.h
+++ b/src/imports/labsmodels/qqmltablemodelcolumn_p.h
@@ -97,6 +97,7 @@ class QQmlTableModelColumn : public QObject
Q_PROPERTY(QJSValue sizeHint READ sizeHint WRITE setSizeHint NOTIFY sizeHintChanged FINAL)
Q_PROPERTY(QJSValue setSizeHint READ getSetSizeHint WRITE setSetSizeHint NOTIFY setSizeHintChanged FINAL)
QML_NAMED_ELEMENT(TableModelColumn)
+ QML_ADDED_IN_VERSION(1, 0)
public:
QQmlTableModelColumn(QObject *parent = nullptr);
diff --git a/src/imports/layouts/layouts.pro b/src/imports/layouts/layouts.pro
index c52046094e..1ae269da32 100644
--- a/src/imports/layouts/layouts.pro
+++ b/src/imports/layouts/layouts.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = qquicklayoutsplugin
TARGETPATH = QtQuick/Layouts
-IMPORT_VERSION = 1.15
+QML_IMPORT_VERSION = $$QT_VERSION
QT *= qml-private quick-private gui-private core-private
diff --git a/src/imports/layouts/plugin.cpp b/src/imports/layouts/plugin.cpp
index c302b79164..af270c1732 100644
--- a/src/imports/layouts/plugin.cpp
+++ b/src/imports/layouts/plugin.cpp
@@ -42,6 +42,8 @@
#include "qquicklinearlayout_p.h"
#include "qquickstacklayout_p.h"
+extern void qml_register_types_QtQuick_Layouts();
+
QT_BEGIN_NAMESPACE
//![class decl]
@@ -52,6 +54,8 @@ class QtQuickLayoutsPlugin : public QQmlEngineExtensionPlugin
public:
QtQuickLayoutsPlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent)
{
+ volatile auto registration = &qml_register_types_QtQuick_Layouts;
+ Q_UNUSED(registration);
}
};
//![class decl]
diff --git a/src/imports/layouts/qquicklayout.cpp b/src/imports/layouts/qquicklayout.cpp
index 1ca4056ba9..33c27bd928 100644
--- a/src/imports/layouts/qquicklayout.cpp
+++ b/src/imports/layouts/qquicklayout.cpp
@@ -700,8 +700,10 @@ QQuickItem *QQuickLayoutAttached::item() const
QQuickLayout::QQuickLayout(QQuickLayoutPrivate &dd, QQuickItem *parent)
- : QQuickItem(dd, parent),
- m_dirty(false)
+ : QQuickItem(dd, parent)
+ , m_dirty(false)
+ , m_inUpdatePolish(false)
+ , m_polishInsideUpdatePolish(0)
{
}
@@ -728,7 +730,9 @@ QQuickLayoutAttached *QQuickLayout::qmlAttachedProperties(QObject *object)
void QQuickLayout::updatePolish()
{
+ m_inUpdatePolish = true;
rearrange(QSizeF(width(), height()));
+ m_inUpdatePolish = false;
}
void QQuickLayout::componentComplete()
@@ -749,7 +753,18 @@ void QQuickLayout::invalidate(QQuickItem * /*childItem*/)
if (!qobject_cast<QQuickLayout *>(parentItem())) {
quickLayoutDebug() << "QQuickLayout::invalidate(), polish()";
- polish();
+
+ if (m_inUpdatePolish)
+ ++m_polishInsideUpdatePolish;
+ else
+ m_polishInsideUpdatePolish = 0;
+
+ if (m_polishInsideUpdatePolish <= 2)
+ // allow at most two consecutive loops in order to respond to height-for-width
+ // (e.g QQuickText changes implicitHeight when its width gets changed)
+ polish();
+ else
+ qWarning() << "Qt Quick Layouts: Polish loop detected. Aborting after two iterations.";
}
}
diff --git a/src/imports/layouts/qquicklayout_p.h b/src/imports/layouts/qquicklayout_p.h
index cb46c41e6c..a2594f4274 100644
--- a/src/imports/layouts/qquicklayout_p.h
+++ b/src/imports/layouts/qquicklayout_p.h
@@ -62,6 +62,7 @@ class QQuickLayout : public QQuickItem, public QQuickItemChangeListener
{
Q_OBJECT
QML_NAMED_ELEMENT(Layout)
+ QML_ADDED_IN_VERSION(1, 0)
QML_UNCREATABLE("Do not create objects of type Layout.")
QML_ATTACHED(QQuickLayoutAttached)
@@ -123,7 +124,9 @@ protected slots:
void invalidateSenderItem();
private:
- bool m_dirty;
+ unsigned m_dirty : 1;
+ unsigned m_inUpdatePolish : 1;
+ unsigned m_polishInsideUpdatePolish : 2;
Q_DECLARE_PRIVATE(QQuickLayout)
diff --git a/src/imports/layouts/qquicklinearlayout.cpp b/src/imports/layouts/qquicklinearlayout.cpp
index 344ea7237c..e47eba4164 100644
--- a/src/imports/layouts/qquicklinearlayout.cpp
+++ b/src/imports/layouts/qquicklinearlayout.cpp
@@ -469,6 +469,16 @@ void QQuickGridLayoutBase::rearrange(const QSizeF &size)
if (!isReady())
return;
+ const auto refCounter = qScopeGuard([&d] {
+ --(d->m_recurRearrangeCounter);
+ });
+ if (d->m_recurRearrangeCounter++ == 2) {
+ // allow a recursive depth of two in order to respond to height-for-width
+ // (e.g QQuickText changes implicitHeight when its width gets changed)
+ qWarning() << "Qt Quick Layouts: Detected recursive rearrange. Aborting after two iterations.";
+ return;
+ }
+
d->m_rearranging = true;
quickLayoutDebug() << objectName() << "QQuickGridLayoutBase::rearrange()" << size;
Qt::LayoutDirection visualDir = effectiveLayoutDirection();
diff --git a/src/imports/layouts/qquicklinearlayout_p.h b/src/imports/layouts/qquicklinearlayout_p.h
index 634e51a048..1780ba8807 100644
--- a/src/imports/layouts/qquicklinearlayout_p.h
+++ b/src/imports/layouts/qquicklinearlayout_p.h
@@ -56,9 +56,10 @@ class QQuickGridLayoutBase : public QQuickLayout
{
Q_OBJECT
- Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1)
+ Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection
+ NOTIFY layoutDirectionChanged REVISION(1, 1))
QML_ANONYMOUS
- QML_ADDED_IN_MINOR_VERSION(1)
+ QML_ADDED_IN_VERSION(1, 1)
public:
@@ -92,7 +93,7 @@ protected:
virtual void insertLayoutItems() {}
signals:
- Q_REVISION(1) void layoutDirectionChanged();
+ Q_REVISION(1, 1) void layoutDirectionChanged();
private:
void removeGridItem(QGridLayoutItem *gridItem);
@@ -106,7 +107,8 @@ class QQuickGridLayoutBasePrivate : public QQuickLayoutPrivate
Q_DECLARE_PUBLIC(QQuickGridLayoutBase)
public:
- QQuickGridLayoutBasePrivate() : m_rearranging(false)
+ QQuickGridLayoutBasePrivate() : m_recurRearrangeCounter(0)
+ , m_rearranging(false)
, m_updateAfterRearrange(false)
, m_layoutDirection(Qt::LeftToRight)
{}
@@ -119,6 +121,7 @@ public:
QQuickGridLayoutEngine engine;
Qt::Orientation orientation;
+ unsigned m_recurRearrangeCounter : 2;
unsigned m_rearranging : 1;
unsigned m_updateAfterRearrange : 1;
QVector<QQuickItem *> m_invalidateAfterRearrange;
@@ -143,6 +146,7 @@ class QQuickGridLayout : public QQuickGridLayoutBase
Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowsChanged)
Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
QML_NAMED_ELEMENT(GridLayout)
+ QML_ADDED_IN_VERSION(1, 0)
public:
explicit QQuickGridLayout(QQuickItem *parent = 0);
qreal columnSpacing() const;
@@ -227,6 +231,7 @@ class QQuickRowLayout : public QQuickLinearLayout
{
Q_OBJECT
QML_NAMED_ELEMENT(RowLayout)
+ QML_ADDED_IN_VERSION(1, 0)
public:
explicit QQuickRowLayout(QQuickItem *parent = 0)
@@ -243,6 +248,7 @@ class QQuickColumnLayout : public QQuickLinearLayout
{
Q_OBJECT
QML_NAMED_ELEMENT(ColumnLayout)
+ QML_ADDED_IN_VERSION(1, 0)
public:
explicit QQuickColumnLayout(QQuickItem *parent = 0)
diff --git a/src/imports/layouts/qquickstacklayout_p.h b/src/imports/layouts/qquickstacklayout_p.h
index 537d54900f..07f9e48178 100644
--- a/src/imports/layouts/qquickstacklayout_p.h
+++ b/src/imports/layouts/qquickstacklayout_p.h
@@ -52,7 +52,7 @@ class QQuickStackLayout : public QQuickLayout
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
QML_NAMED_ELEMENT(StackLayout)
- QML_ADDED_IN_MINOR_VERSION(3)
+ QML_ADDED_IN_VERSION(1, 3)
public:
explicit QQuickStackLayout(QQuickItem *parent = 0);
diff --git a/src/imports/localstorage/localstorage.pro b/src/imports/localstorage/localstorage.pro
index d189808f49..6dff4862c7 100644
--- a/src/imports/localstorage/localstorage.pro
+++ b/src/imports/localstorage/localstorage.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = qmllocalstorageplugin
TARGETPATH = QtQuick/LocalStorage
-IMPORT_VERSION = 2.15
+QML_IMPORT_VERSION = $$QT_VERSION
QT = sql qml-private core-private
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
index ae9f37784d..e488b3d43c 100644
--- a/src/imports/localstorage/plugin.cpp
+++ b/src/imports/localstorage/plugin.cpp
@@ -42,6 +42,8 @@
#include <QtQml/qqmlextensionplugin.h>
#include <QtQml/qqml.h>
+extern void qml_register_types_QtQuick_LocalStorage();
+
QT_BEGIN_NAMESPACE
class QQmlLocalStoragePlugin : public QQmlEngineExtensionPlugin
@@ -52,6 +54,8 @@ class QQmlLocalStoragePlugin : public QQmlEngineExtensionPlugin
public:
QQmlLocalStoragePlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent)
{
+ volatile auto registration = &qml_register_types_QtQuick_LocalStorage;
+ Q_UNUSED(registration);
}
};
diff --git a/src/imports/localstorage/qquicklocalstorage_p.h b/src/imports/localstorage/qquicklocalstorage_p.h
index d2ebc85ce9..f90d6bad28 100644
--- a/src/imports/localstorage/qquicklocalstorage_p.h
+++ b/src/imports/localstorage/qquicklocalstorage_p.h
@@ -61,6 +61,7 @@ class QQuickLocalStorage : public QObject
{
Q_OBJECT
QML_NAMED_ELEMENT(LocalStorage)
+ QML_ADDED_IN_VERSION(2, 0)
QML_SINGLETON
public:
diff --git a/src/imports/models/models.pro b/src/imports/models/models.pro
index ab3f4e3e15..9a22049068 100644
--- a/src/imports/models/models.pro
+++ b/src/imports/models/models.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = modelsplugin
TARGETPATH = QtQml/Models
-IMPORT_VERSION = 2.15
+QML_IMPORT_VERSION = $$QT_VERSION
SOURCES += \
plugin.cpp
diff --git a/src/imports/models/plugin.cpp b/src/imports/models/plugin.cpp
index 4aa9f27766..c15866cf05 100644
--- a/src/imports/models/plugin.cpp
+++ b/src/imports/models/plugin.cpp
@@ -37,17 +37,11 @@
**
****************************************************************************/
-#include <QtQmlModels/private/qqmlobjectmodel_p.h>
-
+#include <QtQmlModels/private/qtqmlmodelsglobal_p.h>
#include <QtQml/qqmlextensionplugin.h>
-#include <QtQml/qqml.h>
-
-#include <QtCore/qloggingcategory.h>
QT_BEGIN_NAMESPACE
-Q_LOGGING_CATEGORY(qmlModelsPlugin, "qt.qmlModelsPlugin")
-
/*!
\qmlmodule QtQml.Models 2.\QtMinorVersion
\title Qt QML Models QML Types
@@ -92,13 +86,8 @@ class QtQmlModelsPlugin : public QQmlEngineExtensionPlugin
public:
QtQmlModelsPlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent)
{
- if (qmlModelsPlugin().isDebugEnabled()) {
- // Superficial debug message that causes the dependency between QtQmlWorkerScript
- // and the workerscript plugin to be retained.
- // As qCDebug() can be a noop, retrieve the className in a separate step.
- const QString className = QQmlObjectModel::staticMetaObject.className();
- qCDebug(qmlModelsPlugin) << "Loading QmlModels plugin:" << className;
- }
+ volatile auto registration = &qml_register_types_QtQml_Models;
+ Q_UNUSED(registration);
}
};
//![class decl]
diff --git a/src/imports/particles/particles.pro b/src/imports/particles/particles.pro
index 50e1837544..c0f2f990b5 100644
--- a/src/imports/particles/particles.pro
+++ b/src/imports/particles/particles.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = particlesplugin
TARGETPATH = QtQuick/Particles
-IMPORT_VERSION = 2.15
+QML_IMPORT_VERSION = $$QT_VERSION
SOURCES += \
plugin.cpp
diff --git a/src/imports/particles/plugin.cpp b/src/imports/particles/plugin.cpp
index 4f319db9f1..6629a660af 100644
--- a/src/imports/particles/plugin.cpp
+++ b/src/imports/particles/plugin.cpp
@@ -50,7 +50,12 @@ class QtQuick2ParticlesPlugin : public QQmlExtensionPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
- QtQuick2ParticlesPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { }
+ QtQuick2ParticlesPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent)
+ {
+ volatile auto registration = &qml_register_types_QtQuick_Particles;
+ Q_UNUSED(registration);
+ }
+
void registerTypes(const char *uri) override
{
Q_UNUSED(uri);
diff --git a/src/imports/qtqml/plugin.cpp b/src/imports/qtqml/plugin.cpp
index ec08992355..a32d86eeb1 100644
--- a/src/imports/qtqml/plugin.cpp
+++ b/src/imports/qtqml/plugin.cpp
@@ -37,10 +37,8 @@
**
****************************************************************************/
+#include <QtQml/private/qtqmlglobal_p.h>
#include <QtQml/qqmlextensionplugin.h>
-#include <QtQml/private/qqmlengine_p.h>
-#include <QtQml/private/qqmlcomponentattached_p.h>
-#include <QtQml/private/qqmlbind_p.h>
QT_BEGIN_NAMESPACE
@@ -66,7 +64,11 @@ class QtQmlPlugin : public QQmlEngineExtensionPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid)
public:
- QtQmlPlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent) {}
+ QtQmlPlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent)
+ {
+ volatile auto registration = &qml_register_types_QtQml;
+ Q_UNUSED(registration);
+ }
};
//![class decl]
diff --git a/src/imports/qtqml/qtqml.pro b/src/imports/qtqml/qtqml.pro
index 0211844b14..eac19954b6 100644
--- a/src/imports/qtqml/qtqml.pro
+++ b/src/imports/qtqml/qtqml.pro
@@ -1,7 +1,7 @@
TARGETPATH = QtQml
CXX_MODULE = qml
TARGET = qmlplugin
-IMPORT_VERSION = 2.15
+QML_IMPORT_VERSION = $$QT_VERSION
SOURCES += \
plugin.cpp
diff --git a/src/imports/qtquick2/plugin.cpp b/src/imports/qtquick2/plugin.cpp
index 98056aa551..dde0b7207a 100644
--- a/src/imports/qtquick2/plugin.cpp
+++ b/src/imports/qtquick2/plugin.cpp
@@ -50,7 +50,12 @@ class QtQuick2Plugin : public QQmlExtensionPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
- QtQuick2Plugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { }
+ QtQuick2Plugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent)
+ {
+ volatile auto registration = &qml_register_types_QtQuick;
+ Q_UNUSED(registration);
+ }
+
void registerTypes(const char *uri) override
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick"));
@@ -59,10 +64,11 @@ public:
QQmlQtQuick2Module::defineModule();
}
- ~QtQuick2Plugin() override
+ void unregisterTypes() override
{
if (moduleDefined)
QQmlQtQuick2Module::undefineModule();
+ moduleDefined = false;
}
bool moduleDefined = false;
diff --git a/src/imports/qtquick2/qtquick2.pro b/src/imports/qtquick2/qtquick2.pro
index f89518c054..35430d0638 100644
--- a/src/imports/qtquick2/qtquick2.pro
+++ b/src/imports/qtquick2/qtquick2.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = qtquick2plugin
TARGETPATH = QtQuick
-IMPORT_VERSION = 2.15
+QML_IMPORT_VERSION = $$QT_VERSION
SOURCES += \
plugin.cpp
diff --git a/src/imports/settings/plugin.cpp b/src/imports/settings/plugin.cpp
index 24ff43ea6f..e8e640412b 100644
--- a/src/imports/settings/plugin.cpp
+++ b/src/imports/settings/plugin.cpp
@@ -42,6 +42,8 @@
#include "qqmlsettings_p.h"
+extern void qml_register_types_Qt_labs_settings();
+
QT_BEGIN_NAMESPACE
class QmlSettingsPlugin : public QQmlEngineExtensionPlugin
@@ -50,7 +52,11 @@ class QmlSettingsPlugin : public QQmlEngineExtensionPlugin
Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid)
public:
- QmlSettingsPlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent) {}
+ QmlSettingsPlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent)
+ {
+ volatile auto registration = &qml_register_types_Qt_labs_settings;
+ Q_UNUSED(registration);
+ }
};
QT_END_NAMESPACE
diff --git a/src/imports/settings/qqmlsettings_p.h b/src/imports/settings/qqmlsettings_p.h
index 3f1b83f541..100d0136ff 100644
--- a/src/imports/settings/qqmlsettings_p.h
+++ b/src/imports/settings/qqmlsettings_p.h
@@ -67,6 +67,7 @@ class QQmlSettings : public QObject, public QQmlParserStatus
Q_PROPERTY(QString category READ category WRITE setCategory FINAL)
Q_PROPERTY(QString fileName READ fileName WRITE setFileName FINAL)
QML_NAMED_ELEMENT(Settings)
+ QML_ADDED_IN_VERSION(1, 0)
public:
explicit QQmlSettings(QObject *parent = 0);
diff --git a/src/imports/settings/settings.pro b/src/imports/settings/settings.pro
index d8062a2e55..6fd8b8cddd 100644
--- a/src/imports/settings/settings.pro
+++ b/src/imports/settings/settings.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = qmlsettingsplugin
TARGETPATH = Qt/labs/settings
-IMPORT_VERSION = 1.1
+QML_IMPORT_VERSION = $$QT_VERSION
QT = core qml
diff --git a/src/imports/shapes/plugin.cpp b/src/imports/shapes/plugin.cpp
index 3855a93fc7..48eecbd8f1 100644
--- a/src/imports/shapes/plugin.cpp
+++ b/src/imports/shapes/plugin.cpp
@@ -52,6 +52,8 @@ public:
QmlShapesPlugin(QObject *parent = nullptr)
: QQmlExtensionPlugin(parent)
{
+ volatile auto registration = &qml_register_types_QtQuick_Shapes;
+ Q_UNUSED(registration);
}
void registerTypes(const char *uri) override
diff --git a/src/imports/shapes/shapes.pro b/src/imports/shapes/shapes.pro
index bb02dbf08f..b5f75343d7 100644
--- a/src/imports/shapes/shapes.pro
+++ b/src/imports/shapes/shapes.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = qmlshapesplugin
TARGETPATH = QtQuick/Shapes
-IMPORT_VERSION = 1.15
+QML_IMPORT_VERSION = $$QT_VERSION
QT = core gui-private qml quick-private quickshapes-private
diff --git a/src/imports/sharedimage/plugin.cpp b/src/imports/sharedimage/plugin.cpp
index 237fa64c61..d7c2ef8d17 100644
--- a/src/imports/sharedimage/plugin.cpp
+++ b/src/imports/sharedimage/plugin.cpp
@@ -99,6 +99,8 @@
The shared image module does not provide any directly usable QML types.
*/
+extern void qml_register_types_Qt_labs_sharedimage();
+
QT_BEGIN_NAMESPACE
class QtQuickSharedImagePlugin : public QQmlEngineExtensionPlugin
@@ -106,7 +108,11 @@ class QtQuickSharedImagePlugin : public QQmlEngineExtensionPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid)
public:
- QtQuickSharedImagePlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent) {}
+ QtQuickSharedImagePlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent)
+ {
+ volatile auto registration = &qml_register_types_Qt_labs_sharedimage;
+ Q_UNUSED(registration);
+ }
void initializeEngine(QQmlEngine *engine, const char *uri) override
{
diff --git a/src/imports/sharedimage/qsharedimageloader_p.h b/src/imports/sharedimage/qsharedimageloader_p.h
index 4b0e989c29..ce10d0d72c 100644
--- a/src/imports/sharedimage/qsharedimageloader_p.h
+++ b/src/imports/sharedimage/qsharedimageloader_p.h
@@ -43,6 +43,7 @@
#include <QImage>
#include <QVariant>
#include <QLoggingCategory>
+#include <qqml.h>
QT_BEGIN_NAMESPACE
@@ -55,6 +56,10 @@ class QSharedImageLoader : public QObject
Q_OBJECT
Q_DECLARE_PRIVATE(QSharedImageLoader)
+ // We need to provide some type, in order to mention the 1.0 version.
+ QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(1, 0)
+
public:
typedef QVector<QVariant> ImageParameters;
diff --git a/src/imports/sharedimage/sharedimage.pro b/src/imports/sharedimage/sharedimage.pro
index 8ab4f10405..cee4c3465e 100644
--- a/src/imports/sharedimage/sharedimage.pro
+++ b/src/imports/sharedimage/sharedimage.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = sharedimageplugin
TARGETPATH = Qt/labs/sharedimage
-IMPORT_VERSION = 1.0
+QML_IMPORT_VERSION = $$QT_VERSION
QT *= quick-private qml gui-private core-private
diff --git a/src/imports/statemachine/childrenprivate.h b/src/imports/statemachine/childrenprivate.h
index 57cda1c796..2dcecd6531 100644
--- a/src/imports/statemachine/childrenprivate.h
+++ b/src/imports/statemachine/childrenprivate.h
@@ -46,54 +46,142 @@
#include <QQmlInfo>
#include <QQmlListProperty>
-template <class T>
-class ChildrenPrivate
+enum class ChildrenMode {
+ None = 0x0,
+ State = 0x1,
+ Transition = 0x2,
+ StateOrTransition = State | Transition
+};
+
+template<typename T>
+static T *parentObject(QQmlListProperty<QObject> *prop) { return static_cast<T *>(prop->object); }
+
+template<class T, ChildrenMode Mode>
+struct ParentHandler
{
-public:
- ChildrenPrivate()
- {}
+ static bool unparentItem(QQmlListProperty<QObject> *prop, QObject *oldItem);
+ static bool parentItem(QQmlListProperty<QObject> *prop, QObject *item);
+};
- static void append(QQmlListProperty<QObject> *prop, QObject *item)
+template<class T>
+struct ParentHandler<T, ChildrenMode::None>
+{
+ static bool unparentItem(QQmlListProperty<QObject> *, QObject *) { return true; }
+ static bool parentItem(QQmlListProperty<QObject> *, QObject *) { return true; }
+};
+
+template<class T>
+struct ParentHandler<T, ChildrenMode::State>
+{
+ static bool parentItem(QQmlListProperty<QObject> *prop, QObject *item)
+ {
+ if (QAbstractState *state = qobject_cast<QAbstractState *>(item)) {
+ state->setParent(parentObject<T>(prop));
+ return true;
+ }
+ return false;
+ }
+
+ static bool unparentItem(QQmlListProperty<QObject> *, QObject *oldItem)
+ {
+ if (QAbstractState *state = qobject_cast<QAbstractState *>(oldItem)) {
+ state->setParent(nullptr);
+ return true;
+ }
+ return false;
+ }
+};
+
+template<class T>
+struct ParentHandler<T, ChildrenMode::Transition>
+{
+ static bool parentItem(QQmlListProperty<QObject> *prop, QObject *item)
{
- QAbstractState *state = qobject_cast<QAbstractState*>(item);
- if (state) {
- item->setParent(prop->object);
- } else {
- QAbstractTransition *trans = qobject_cast<QAbstractTransition*>(item);
- if (trans)
- static_cast<T *>(prop->object)->addTransition(trans);
+ if (QAbstractTransition *trans = qobject_cast<QAbstractTransition *>(item)) {
+ parentObject<T>(prop)->addTransition(trans);
+ return true;
}
- static_cast<ChildrenPrivate<T>*>(prop->data)->children.append(item);
- emit static_cast<T *>(prop->object)->childrenChanged();
+ return false;
}
- static void appendNoTransition(QQmlListProperty<QObject> *prop, QObject *item)
+ static bool unparentItem(QQmlListProperty<QObject> *prop, QObject *oldItem)
{
- QAbstractState *state = qobject_cast<QAbstractState*>(item);
- if (state) {
- item->setParent(prop->object);
+ if (QAbstractTransition *trans = qobject_cast<QAbstractTransition *>(oldItem)) {
+ parentObject<T>(prop)->removeTransition(trans);
+ return true;
}
- static_cast<ChildrenPrivate<T>*>(prop->data)->children.append(item);
- emit static_cast<T *>(prop->object)->childrenChanged();
+ return false;
+ }
+};
+
+template<class T>
+struct ParentHandler<T, ChildrenMode::StateOrTransition>
+{
+ static bool parentItem(QQmlListProperty<QObject> *prop, QObject *oldItem)
+ {
+ return ParentHandler<T, ChildrenMode::State>::parentItem(prop, oldItem)
+ || ParentHandler<T, ChildrenMode::Transition>::parentItem(prop, oldItem);
+ }
+
+ static bool unparentItem(QQmlListProperty<QObject> *prop, QObject *oldItem)
+ {
+ return ParentHandler<T, ChildrenMode::State>::unparentItem(prop, oldItem)
+ || ParentHandler<T, ChildrenMode::Transition>::unparentItem(prop, oldItem);
+ }
+};
+
+template <class T, ChildrenMode Mode>
+class ChildrenPrivate
+{
+public:
+ static void append(QQmlListProperty<QObject> *prop, QObject *item)
+ {
+ Handler::parentItem(prop, item);
+ static_cast<Self *>(prop->data)->children.append(item);
+ emit parentObject<T>(prop)->childrenChanged();
}
static int count(QQmlListProperty<QObject> *prop)
{
- return static_cast<ChildrenPrivate<T>*>(prop->data)->children.count();
+ return static_cast<Self *>(prop->data)->children.count();
}
static QObject *at(QQmlListProperty<QObject> *prop, int index)
{
- return static_cast<ChildrenPrivate<T>*>(prop->data)->children.at(index);
+ return static_cast<Self *>(prop->data)->children.at(index);
}
static void clear(QQmlListProperty<QObject> *prop)
{
- static_cast<ChildrenPrivate<T>*>(prop->data)->children.clear();
- emit static_cast<T *>(prop->object)->childrenChanged();
+ auto &children = static_cast<Self *>(prop->data)->children;
+ for (QObject *oldItem : qAsConst(children))
+ Handler::unparentItem(prop, oldItem);
+
+ children.clear();
+ emit parentObject<T>(prop)->childrenChanged();
+ }
+
+ static void replace(QQmlListProperty<QObject> *prop, int index, QObject *item)
+ {
+ auto &children = static_cast<Self *>(prop->data)->children;
+
+ Handler::unparentItem(prop, children.at(index));
+ Handler::parentItem(prop, item);
+
+ children.replace(index, item);
+ emit parentObject<T>(prop)->childrenChanged();
+ }
+
+ static void removeLast(QQmlListProperty<QObject> *prop)
+ {
+ Handler::unparentItem(prop, static_cast<Self *>(prop->data)->children.takeLast());
+ emit parentObject<T>(prop)->childrenChanged();
}
private:
+ using Self = ChildrenPrivate<T, Mode>;
+ using Handler = ParentHandler<T, Mode>;
+
QList<QObject *> children;
};
diff --git a/src/imports/statemachine/finalstate.cpp b/src/imports/statemachine/finalstate.cpp
index 54dcc82bae..4d4c6b2cc7 100644
--- a/src/imports/statemachine/finalstate.cpp
+++ b/src/imports/statemachine/finalstate.cpp
@@ -50,7 +50,9 @@ FinalState::FinalState(QState *parent)
QQmlListProperty<QObject> FinalState::children()
{
- return QQmlListProperty<QObject>(this, &m_children, m_children.appendNoTransition, m_children.count, m_children.at, m_children.clear);
+ return QQmlListProperty<QObject>(this, &m_children,
+ m_children.append, m_children.count, m_children.at,
+ m_children.clear, m_children.replace, m_children.removeLast);
}
/*!
diff --git a/src/imports/statemachine/finalstate.h b/src/imports/statemachine/finalstate.h
index 9cdbb51584..fef0e9c092 100644
--- a/src/imports/statemachine/finalstate.h
+++ b/src/imports/statemachine/finalstate.h
@@ -56,6 +56,7 @@ class FinalState : public QFinalState
Q_PROPERTY(QQmlListProperty<QObject> children READ children NOTIFY childrenChanged)
Q_CLASSINFO("DefaultProperty", "children")
QML_ELEMENT
+ QML_ADDED_IN_VERSION(1, 0)
public:
explicit FinalState(QState *parent = 0);
@@ -66,7 +67,7 @@ Q_SIGNALS:
void childrenChanged();
private:
- ChildrenPrivate<FinalState> m_children;
+ ChildrenPrivate<FinalState, ChildrenMode::State> m_children;
};
QT_END_NAMESPACE
diff --git a/src/imports/statemachine/plugin.cpp b/src/imports/statemachine/plugin.cpp
index 4c991994f3..c370504029 100644
--- a/src/imports/statemachine/plugin.cpp
+++ b/src/imports/statemachine/plugin.cpp
@@ -48,6 +48,8 @@
#include <QQmlExtensionPlugin>
#include <qqml.h>
+extern void qml_register_types_QtQml_StateMachine();
+
QT_BEGIN_NAMESPACE
class QtQmlStateMachinePlugin : public QQmlEngineExtensionPlugin
@@ -56,7 +58,11 @@ class QtQmlStateMachinePlugin : public QQmlEngineExtensionPlugin
Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid)
public:
- QtQmlStateMachinePlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent) { }
+ QtQmlStateMachinePlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent)
+ {
+ volatile auto registration = &qml_register_types_QtQml_StateMachine;
+ Q_UNUSED(registration);
+ }
};
QT_END_NAMESPACE
diff --git a/src/imports/statemachine/signaltransition.h b/src/imports/statemachine/signaltransition.h
index 748e230b3e..4d73368eb0 100644
--- a/src/imports/statemachine/signaltransition.h
+++ b/src/imports/statemachine/signaltransition.h
@@ -58,6 +58,7 @@ class SignalTransition : public QSignalTransition, public QQmlParserStatus
Q_PROPERTY(QJSValue signal READ signal WRITE setSignal NOTIFY qmlSignalChanged)
Q_PROPERTY(QQmlScriptString guard READ guard WRITE setGuard NOTIFY guardChanged)
QML_ELEMENT
+ QML_ADDED_IN_VERSION(1, 0)
public:
explicit SignalTransition(QState *parent = nullptr);
diff --git a/src/imports/statemachine/state.cpp b/src/imports/statemachine/state.cpp
index af76087256..10530c2985 100644
--- a/src/imports/statemachine/state.cpp
+++ b/src/imports/statemachine/state.cpp
@@ -61,7 +61,9 @@ void State::componentComplete()
QQmlListProperty<QObject> State::children()
{
- return QQmlListProperty<QObject>(this, &m_children, m_children.append, m_children.count, m_children.at, m_children.clear);
+ return QQmlListProperty<QObject>(this, &m_children,
+ m_children.append, m_children.count, m_children.at,
+ m_children.clear, m_children.replace, m_children.removeLast);
}
/*!
diff --git a/src/imports/statemachine/state.h b/src/imports/statemachine/state.h
index 4b17ea0e5f..8cb454f3cf 100644
--- a/src/imports/statemachine/state.h
+++ b/src/imports/statemachine/state.h
@@ -56,6 +56,7 @@ class State : public QState, public QQmlParserStatus
Q_PROPERTY(QQmlListProperty<QObject> children READ children NOTIFY childrenChanged)
Q_CLASSINFO("DefaultProperty", "children")
QML_ELEMENT
+ QML_ADDED_IN_VERSION(1, 0)
public:
explicit State(QState *parent = 0);
@@ -69,7 +70,7 @@ Q_SIGNALS:
void childrenChanged();
private:
- ChildrenPrivate<State> m_children;
+ ChildrenPrivate<State, ChildrenMode::StateOrTransition> m_children;
};
QT_END_NAMESPACE
diff --git a/src/imports/statemachine/statemachine.cpp b/src/imports/statemachine/statemachine.cpp
index a983644018..bdad2e6bde 100644
--- a/src/imports/statemachine/statemachine.cpp
+++ b/src/imports/statemachine/statemachine.cpp
@@ -90,7 +90,9 @@ void StateMachine::componentComplete()
QQmlListProperty<QObject> StateMachine::children()
{
- return QQmlListProperty<QObject>(this, &m_children, m_children.append, m_children.count, m_children.at, m_children.clear);
+ return QQmlListProperty<QObject>(this, &m_children,
+ m_children.append, m_children.count, m_children.at,
+ m_children.clear, m_children.replace, m_children.removeLast);
}
/*!
diff --git a/src/imports/statemachine/statemachine.h b/src/imports/statemachine/statemachine.h
index 04894477b3..85ac4cf26b 100644
--- a/src/imports/statemachine/statemachine.h
+++ b/src/imports/statemachine/statemachine.h
@@ -60,6 +60,7 @@ class StateMachine : public QStateMachine, public QQmlParserStatus
Q_CLASSINFO("DefaultProperty", "children")
QML_ELEMENT
+ QML_ADDED_IN_VERSION(1, 0)
public:
explicit StateMachine(QObject *parent = 0);
@@ -82,7 +83,7 @@ Q_SIGNALS:
void qmlRunningChanged();
private:
- ChildrenPrivate<StateMachine> m_children;
+ ChildrenPrivate<StateMachine, ChildrenMode::StateOrTransition> m_children;
bool m_completed;
bool m_running;
};
diff --git a/src/imports/statemachine/statemachine.pro b/src/imports/statemachine/statemachine.pro
index b17ec6140d..cff81c2416 100644
--- a/src/imports/statemachine/statemachine.pro
+++ b/src/imports/statemachine/statemachine.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = qtqmlstatemachine
TARGETPATH = QtQml/StateMachine
-IMPORT_VERSION = 1.15
+QML_IMPORT_VERSION = $$QT_VERSION
QT = core-private qml-private
diff --git a/src/imports/statemachine/statemachineforeign.h b/src/imports/statemachine/statemachineforeign.h
index 363c9d0e31..7543d55fdf 100644
--- a/src/imports/statemachine/statemachineforeign.h
+++ b/src/imports/statemachine/statemachineforeign.h
@@ -51,6 +51,7 @@ struct QHistoryStateForeign
Q_GADGET
QML_FOREIGN(QHistoryState)
QML_NAMED_ELEMENT(HistoryState)
+ QML_ADDED_IN_VERSION(1, 0)
};
struct QStateForeign
@@ -58,6 +59,7 @@ struct QStateForeign
Q_GADGET
QML_FOREIGN(QState)
QML_NAMED_ELEMENT(QState)
+ QML_ADDED_IN_VERSION(1, 0)
QML_UNCREATABLE("Don't use this, use State instead.")
};
@@ -66,6 +68,7 @@ struct QAbstractStateForeign
Q_GADGET
QML_FOREIGN(QAbstractState)
QML_NAMED_ELEMENT(QAbstractState)
+ QML_ADDED_IN_VERSION(1, 0)
QML_UNCREATABLE("Don't use this, use State instead.")
};
@@ -74,6 +77,7 @@ struct QSignalTransitionForeign
Q_GADGET
QML_FOREIGN(QSignalTransition)
QML_NAMED_ELEMENT(QSignalTransition)
+ QML_ADDED_IN_VERSION(1, 0)
QML_UNCREATABLE("Don't use this, use SignalTransition instead.")
};
diff --git a/src/imports/statemachine/timeouttransition.h b/src/imports/statemachine/timeouttransition.h
index cc3a22e0e5..3d056b5e41 100644
--- a/src/imports/statemachine/timeouttransition.h
+++ b/src/imports/statemachine/timeouttransition.h
@@ -53,6 +53,7 @@ class TimeoutTransition : public QSignalTransition, public QQmlParserStatus
Q_PROPERTY(int timeout READ timeout WRITE setTimeout NOTIFY timeoutChanged)
Q_INTERFACES(QQmlParserStatus)
QML_ELEMENT
+ QML_ADDED_IN_VERSION(1, 0)
public:
TimeoutTransition(QState *parent = nullptr);
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml
index 20c5ce6418..380b7e38d7 100644
--- a/src/imports/testlib/TestCase.qml
+++ b/src/imports/testlib/TestCase.qml
@@ -198,7 +198,7 @@ import Qt.test.qtestroot 1.0
}
\endcode
- The mousePress(), mouseRelease(), mouseClick(), mouseDoubleClick(), mouseDoubleClickSequence()
+ The mousePress(), mouseRelease(), mouseClick(), mouseDoubleClickSequence()
and mouseMove() methods can be used to simulate mouse events in a
similar fashion.
@@ -1331,7 +1331,7 @@ Item {
If \a item is obscured by another item, or a child of \a item occupies
that position, then the event will be delivered to the other item instead.
- \sa mouseRelease(), mouseClick(), mouseDoubleClick(), mouseDoubleClickSequence(), mouseMove(), mouseDrag(), mouseWheel()
+ \sa mouseRelease(), mouseClick(), mouseDoubleClickSequence(), mouseMove(), mouseDrag(), mouseWheel()
*/
function mousePress(item, x, y, button, modifiers, delay) {
if (!qtest_verifyItem(item, "mousePress"))
@@ -1365,7 +1365,7 @@ Item {
If \a item is obscured by another item, or a child of \a item occupies
that position, then the event will be delivered to the other item instead.
- \sa mousePress(), mouseClick(), mouseDoubleClick(), mouseDoubleClickSequence(), mouseMove(), mouseDrag(), mouseWheel()
+ \sa mousePress(), mouseClick(), mouseDoubleClickSequence(), mouseMove(), mouseDrag(), mouseWheel()
*/
function mouseRelease(item, x, y, button, modifiers, delay) {
if (!qtest_verifyItem(item, "mouseRelease"))
@@ -1398,7 +1398,7 @@ Item {
If \a item is obscured by another item, or a child of \a item occupies
that position, then the event will be delivered to the other item instead.
- \sa mousePress(), mouseClick(), mouseDoubleClick(), mouseDoubleClickSequence(), mouseMove(), mouseRelease(), mouseWheel()
+ \sa mousePress(), mouseClick(), mouseDoubleClickSequence(), mouseMove(), mouseRelease(), mouseWheel()
*/
function mouseDrag(item, x, y, dx, dy, button, modifiers, delay) {
if (!qtest_verifyItem(item, "mouseDrag"))
@@ -1453,7 +1453,7 @@ Item {
If \a item is obscured by another item, or a child of \a item occupies
that position, then the event will be delivered to the other item instead.
- \sa mousePress(), mouseRelease(), mouseDoubleClick(), mouseDoubleClickSequence(), mouseMove(), mouseDrag(), mouseWheel()
+ \sa mousePress(), mouseRelease(), mouseDoubleClickSequence(), mouseMove(), mouseDrag(), mouseWheel()
*/
function mouseClick(item, x, y, button, modifiers, delay) {
if (!qtest_verifyItem(item, "mouseClick"))
@@ -1475,6 +1475,7 @@ Item {
/*!
\qmlmethod TestCase::mouseDoubleClick(item, x = item.width / 2, y = item.height / 2, button = Qt.LeftButton, modifiers = Qt.NoModifier, delay = -1)
+ \deprecated
Simulates double-clicking a mouse \a button with optional \a modifiers
on an \a item. The position of the click is defined by \a x and \a y.
@@ -1528,7 +1529,7 @@ Item {
This QML method was introduced in Qt 5.5.
- \sa mouseDoubleClick(), mousePress(), mouseRelease(), mouseClick(), mouseMove(), mouseDrag(), mouseWheel()
+ \sa mousePress(), mouseRelease(), mouseClick(), mouseMove(), mouseDrag(), mouseWheel()
*/
function mouseDoubleClickSequence(item, x, y, button, modifiers, delay) {
if (!qtest_verifyItem(item, "mouseDoubleClickSequence"))
@@ -1560,7 +1561,7 @@ Item {
If \a item is obscured by another item, or a child of \a item occupies
that position, then the event will be delivered to the other item instead.
- \sa mousePress(), mouseRelease(), mouseClick(), mouseDoubleClick(), mouseDoubleClickSequence(), mouseDrag(), mouseWheel()
+ \sa mousePress(), mouseRelease(), mouseClick(), mouseDoubleClickSequence(), mouseDrag(), mouseWheel()
*/
function mouseMove(item, x, y, delay, buttons) {
if (!qtest_verifyItem(item, "mouseMove"))
@@ -1588,7 +1589,7 @@ Item {
The \a xDelta and \a yDelta contain the wheel rotation distance in eighths of a degree. see \l QWheelEvent::angleDelta() for more details.
- \sa mousePress(), mouseClick(), mouseDoubleClick(), mouseDoubleClickSequence(), mouseMove(), mouseRelease(), mouseDrag(), QWheelEvent::angleDelta()
+ \sa mousePress(), mouseClick(), mouseDoubleClickSequence(), mouseMove(), mouseRelease(), mouseDrag(), QWheelEvent::angleDelta()
*/
function mouseWheel(item, x, y, xDelta, yDelta, buttons, modifiers, delay) {
if (!qtest_verifyItem(item, "mouseWheel"))
diff --git a/src/qmltest/dependencies.json b/src/imports/testlib/dependencies.json
index b2c4125178..b2c4125178 100644
--- a/src/qmltest/dependencies.json
+++ b/src/imports/testlib/dependencies.json
diff --git a/src/imports/testlib/main.cpp b/src/imports/testlib/main.cpp
index 1914c02dd0..83fc150e6c 100644
--- a/src/imports/testlib/main.cpp
+++ b/src/imports/testlib/main.cpp
@@ -50,6 +50,8 @@ QML_DECLARE_TYPE(QuickTestResult)
QML_DECLARE_TYPE(QuickTestEvent)
QML_DECLARE_TYPE(QuickTestUtil)
+extern void qml_register_types_QtTest();
+
QT_BEGIN_NAMESPACE
class QTestQmlModule : public QQmlEngineExtensionPlugin
@@ -58,7 +60,11 @@ class QTestQmlModule : public QQmlEngineExtensionPlugin
Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid)
public:
- QTestQmlModule(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent) { }
+ QTestQmlModule(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent)
+ {
+ volatile auto registration = &qml_register_types_QtTest;
+ Q_UNUSED(registration);
+ }
};
QT_END_NAMESPACE
diff --git a/src/imports/testlib/quicktestevent_p.h b/src/imports/testlib/quicktestevent_p.h
index f452e4ff82..0bbae8434f 100644
--- a/src/imports/testlib/quicktestevent_p.h
+++ b/src/imports/testlib/quicktestevent_p.h
@@ -63,6 +63,7 @@ class QQuickTouchEventSequence : public QObject
{
Q_OBJECT
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(1, 0)
public:
explicit QQuickTouchEventSequence(QuickTestEvent *testEvent, QObject *item = nullptr);
@@ -83,6 +84,7 @@ class QuickTestEvent : public QObject
Q_OBJECT
Q_PROPERTY(int defaultMouseDelay READ defaultMouseDelay FINAL)
QML_NAMED_ELEMENT(TestEvent)
+ QML_ADDED_IN_VERSION(1, 0)
public:
QuickTestEvent(QObject *parent = nullptr);
~QuickTestEvent() override;
@@ -97,7 +99,7 @@ public Q_SLOTS:
bool keyReleaseChar(const QString &character, int modifiers, int delay);
bool keyClickChar(const QString &character, int modifiers, int delay);
- Q_REVISION(2) bool keySequence(const QVariant &keySequence);
+ Q_REVISION(1, 2) bool keySequence(const QVariant &keySequence);
bool mousePress(QObject *item, qreal x, qreal y, int button,
int modifiers, int delay);
diff --git a/src/imports/testlib/quicktestresultforeign_p.h b/src/imports/testlib/quicktestresultforeign_p.h
index 92ff8e8a5a..e9dd12fa93 100644
--- a/src/imports/testlib/quicktestresultforeign_p.h
+++ b/src/imports/testlib/quicktestresultforeign_p.h
@@ -61,6 +61,7 @@ struct QuickTestResultForeign
Q_GADGET
QML_FOREIGN(QuickTestResult)
QML_NAMED_ELEMENT(TestResult)
+ QML_ADDED_IN_VERSION(1, 0)
};
QT_END_NAMESPACE
diff --git a/src/imports/testlib/quicktestutil_p.h b/src/imports/testlib/quicktestutil_p.h
index 2456bf88a7..7e90c1cd1d 100644
--- a/src/imports/testlib/quicktestutil_p.h
+++ b/src/imports/testlib/quicktestutil_p.h
@@ -63,6 +63,7 @@ class QuickTestUtil : public QObject
Q_PROPERTY(bool printAvailableFunctions READ printAvailableFunctions NOTIFY printAvailableFunctionsChanged)
Q_PROPERTY(int dragThreshold READ dragThreshold NOTIFY dragThresholdChanged)
QML_NAMED_ELEMENT(TestUtil)
+ QML_ADDED_IN_VERSION(1, 0)
public:
QuickTestUtil(QObject *parent = nullptr) :QObject(parent) {}
~QuickTestUtil() override {}
diff --git a/src/imports/testlib/testlib.pro b/src/imports/testlib/testlib.pro
index de6453eeab..2a97213e29 100644
--- a/src/imports/testlib/testlib.pro
+++ b/src/imports/testlib/testlib.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = qmltestplugin
TARGETPATH = QtTest
-IMPORT_VERSION = 1.15
+QML_IMPORT_VERSION = $$QT_VERSION
QT += quick qmltest-private qml-private core-private testlib gui-private
diff --git a/src/imports/wavefrontmesh/plugin.cpp b/src/imports/wavefrontmesh/plugin.cpp
index 9bb7a45b2f..eea0db19db 100644
--- a/src/imports/wavefrontmesh/plugin.cpp
+++ b/src/imports/wavefrontmesh/plugin.cpp
@@ -42,6 +42,8 @@
#include "qwavefrontmesh.h"
+extern void qml_register_types_Qt_labs_wavefrontmesh();
+
QT_BEGIN_NAMESPACE
class QmlWavefrontMeshPlugin : public QQmlEngineExtensionPlugin
@@ -52,6 +54,8 @@ public:
QmlWavefrontMeshPlugin(QObject *parent = nullptr)
: QQmlEngineExtensionPlugin(parent)
{
+ volatile auto registration = &qml_register_types_Qt_labs_wavefrontmesh;
+ Q_UNUSED(registration);
}
};
diff --git a/src/imports/wavefrontmesh/qwavefrontmesh.cpp b/src/imports/wavefrontmesh/qwavefrontmesh.cpp
index e973ef0103..1772c40c50 100644
--- a/src/imports/wavefrontmesh/qwavefrontmesh.cpp
+++ b/src/imports/wavefrontmesh/qwavefrontmesh.cpp
@@ -257,7 +257,7 @@ void QWavefrontMesh::readData()
while (!stream.atEnd()) {
stream.readLineInto(&buffer);
- QVector<QStringRef> tokens = buffer.splitRef(space, QString::SkipEmptyParts);
+ QVector<QStringRef> tokens = buffer.splitRef(space, Qt::SkipEmptyParts);
if (tokens.size() < 2)
continue;
@@ -316,7 +316,7 @@ void QWavefrontMesh::readData()
if (tokens.size() >= 4 && tokens.size() <= 5) {
{
bool ok;
- QVector<QStringRef> faceTokens = tokens.at(1).split(slash, QString::SkipEmptyParts);
+ QVector<QStringRef> faceTokens = tokens.at(1).split(slash, Qt::SkipEmptyParts);
Q_ASSERT(!faceTokens.isEmpty());
p1 = faceTokens.at(0).toInt(&ok) - 1;
@@ -336,7 +336,7 @@ void QWavefrontMesh::readData()
{
bool ok;
- QVector<QStringRef> faceTokens = tokens.at(2).split(slash, QString::SkipEmptyParts);
+ QVector<QStringRef> faceTokens = tokens.at(2).split(slash, Qt::SkipEmptyParts);
Q_ASSERT(!faceTokens.isEmpty());
p2 = faceTokens.at(0).toInt(&ok) - 1;
@@ -356,7 +356,7 @@ void QWavefrontMesh::readData()
{
bool ok;
- QVector<QStringRef> faceTokens = tokens.at(3).split(slash, QString::SkipEmptyParts);
+ QVector<QStringRef> faceTokens = tokens.at(3).split(slash, Qt::SkipEmptyParts);
Q_ASSERT(!faceTokens.isEmpty());
p3 = faceTokens.at(0).toInt(&ok) - 1;
@@ -394,7 +394,7 @@ void QWavefrontMesh::readData()
if (tokens.size() == 5) {
bool ok;
- QVector<QStringRef> faceTokens = tokens.at(4).split(slash, QString::SkipEmptyParts);
+ QVector<QStringRef> faceTokens = tokens.at(4).split(slash, Qt::SkipEmptyParts);
Q_ASSERT(!faceTokens.isEmpty());
int p4 = faceTokens.at(0).toInt(&ok) - 1;
diff --git a/src/imports/wavefrontmesh/qwavefrontmesh.h b/src/imports/wavefrontmesh/qwavefrontmesh.h
index a8a40c1a6a..67e0527e5d 100644
--- a/src/imports/wavefrontmesh/qwavefrontmesh.h
+++ b/src/imports/wavefrontmesh/qwavefrontmesh.h
@@ -56,6 +56,7 @@ class QWavefrontMesh : public QQuickShaderEffectMesh
Q_PROPERTY(QVector3D projectionPlaneV READ projectionPlaneV WRITE setProjectionPlaneV NOTIFY projectionPlaneVChanged)
Q_PROPERTY(QVector3D projectionPlaneW READ projectionPlaneW WRITE setProjectionPlaneW NOTIFY projectionPlaneWChanged)
QML_NAMED_ELEMENT(WavefrontMesh)
+ QML_ADDED_IN_VERSION(1, 0)
public:
enum Error {
diff --git a/src/imports/wavefrontmesh/wavefrontmesh.pro b/src/imports/wavefrontmesh/wavefrontmesh.pro
index f6d93b867d..4aa06b97bf 100644
--- a/src/imports/wavefrontmesh/wavefrontmesh.pro
+++ b/src/imports/wavefrontmesh/wavefrontmesh.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = qmlwavefrontmeshplugin
TARGETPATH = Qt/labs/wavefrontmesh
-IMPORT_VERSION = 1.15
+QML_IMPORT_VERSION = $$QT_VERSION
QT = core-private qml-private quick-private
diff --git a/src/imports/window/plugin.cpp b/src/imports/window/plugin.cpp
index ec4f2c5d2a..5152fa02ec 100644
--- a/src/imports/window/plugin.cpp
+++ b/src/imports/window/plugin.cpp
@@ -41,6 +41,8 @@
#include "plugin.h"
+extern void qml_register_types_QtQuick_Window();
+
QT_BEGIN_NAMESPACE
/*!
@@ -64,7 +66,11 @@ class QtQuick2WindowPlugin : public QQmlEngineExtensionPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid)
public:
- QtQuick2WindowPlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent) { }
+ QtQuick2WindowPlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent)
+ {
+ volatile auto registration = &qml_register_types_QtQuick_Window;
+ Q_UNUSED(registration);
+ }
};
//![class decl]
diff --git a/src/imports/window/plugin.h b/src/imports/window/plugin.h
index 9f58ca9ac7..625a77b12c 100644
--- a/src/imports/window/plugin.h
+++ b/src/imports/window/plugin.h
@@ -65,7 +65,7 @@ struct QWindowForeign
Q_GADGET
QML_FOREIGN(QWindow)
QML_ANONYMOUS
- QML_ADDED_IN_MINOR_VERSION(1)
+ QML_ADDED_IN_VERSION(2, 1)
};
struct QQuickWindowForeign
@@ -73,8 +73,8 @@ struct QQuickWindowForeign
Q_GADGET
QML_FOREIGN(QQuickWindow)
QML_NAMED_ELEMENT(Window)
- QML_ADDED_IN_MINOR_VERSION(0)
- QML_REMOVED_IN_MINOR_VERSION(1)
+ QML_ADDED_IN_VERSION(2, 0)
+ QML_REMOVED_IN_VERSION(2, 1)
};
struct QQuickWindowForeignAttached
@@ -82,6 +82,7 @@ struct QQuickWindowForeignAttached
Q_GADGET
QML_FOREIGN(QQuickWindowAttached)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
};
struct QQuickScreenInfoForeign
@@ -89,7 +90,7 @@ struct QQuickScreenInfoForeign
Q_GADGET
QML_FOREIGN(QQuickScreenInfo)
QML_NAMED_ELEMENT(ScreenInfo)
- QML_ADDED_IN_MINOR_VERSION(3)
+ QML_ADDED_IN_VERSION(2, 3)
QML_UNCREATABLE("ScreenInfo can only be used via the attached property.")
};
@@ -98,6 +99,7 @@ struct QQuickScreenForeignAttached
Q_GADGET
QML_FOREIGN(QQuickScreenAttached)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
};
struct QQuickScreenForeign
@@ -105,6 +107,7 @@ struct QQuickScreenForeign
Q_GADGET
QML_FOREIGN(QQuickScreen)
QML_NAMED_ELEMENT(Screen)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("Screen can only be used via the attached property.")
};
@@ -113,7 +116,14 @@ struct QQuickWindowQmlImplForeign
Q_GADGET
QML_FOREIGN(QQuickWindowQmlImpl)
QML_NAMED_ELEMENT(Window)
- QML_ADDED_IN_MINOR_VERSION(1)
+ QML_ADDED_IN_VERSION(2, 1)
+};
+
+struct QQuickRootItemForeign
+{
+ Q_GADGET
+ QML_FOREIGN(QQuickRootItem)
+ QML_ANONYMOUS
};
QT_END_NAMESPACE
diff --git a/src/imports/window/window.pro b/src/imports/window/window.pro
index 70af305937..d8f9b16df4 100644
--- a/src/imports/window/window.pro
+++ b/src/imports/window/window.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = windowplugin
TARGETPATH = QtQuick/Window
-IMPORT_VERSION = 2.15
+QML_IMPORT_VERSION = $$QT_VERSION
SOURCES += \
plugin.cpp
diff --git a/src/imports/workerscript/plugin.cpp b/src/imports/workerscript/plugin.cpp
index 0961979c53..1323b17ef4 100644
--- a/src/imports/workerscript/plugin.cpp
+++ b/src/imports/workerscript/plugin.cpp
@@ -37,17 +37,11 @@
**
****************************************************************************/
-#include <QtQmlWorkerScript/private/qquickworkerscript_p.h>
-
+#include <QtQmlWorkerScript/private/qtqmlworkerscriptglobal_p.h>
#include <QtQml/qqmlextensionplugin.h>
-#include <QtQml/qqml.h>
-
-#include <QtCore/qloggingcategory.h>
QT_BEGIN_NAMESPACE
-Q_LOGGING_CATEGORY(workerScriptPlugin, "qt.workerScriptPlugin")
-
/*!
\qmlmodule QtQml.WorkerScript 2.\QtMinorVersion
\title Qt QML WorkerScript QML Types
@@ -71,13 +65,8 @@ class QtQmlWorkerScriptPlugin : public QQmlEngineExtensionPlugin
public:
QtQmlWorkerScriptPlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent)
{
- if (workerScriptPlugin().isDebugEnabled()) {
- // Superficial debug message that causes the dependency between QtQmlWorkerScript
- // and the workerscript plugin to be retained.
- // As qCDebug() can be a noop, retrieve the className in a separate step.
- const QString className = QQuickWorkerScript::staticMetaObject.className();
- qCDebug(workerScriptPlugin) << "Loading WorkerScript plugin:" << className;
- }
+ volatile auto registration = &qml_register_types_QtQml_WorkerScript;
+ Q_UNUSED(registration);
}
};
diff --git a/src/imports/workerscript/workerscript.pro b/src/imports/workerscript/workerscript.pro
index 101442c3f3..9c6a65eb05 100644
--- a/src/imports/workerscript/workerscript.pro
+++ b/src/imports/workerscript/workerscript.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = workerscriptplugin
TARGETPATH = QtQml/WorkerScript
-IMPORT_VERSION = 2.15
+QML_IMPORT_VERSION = $$QT_VERSION
SOURCES += \
plugin.cpp
diff --git a/src/particles/particles.pro b/src/particles/particles.pro
index 83f6f1c83e..6a117c65fe 100644
--- a/src/particles/particles.pro
+++ b/src/particles/particles.pro
@@ -19,7 +19,7 @@ include(particles.pri)
QMLTYPES_FILENAME = plugins.qmltypes
QMLTYPES_INSTALL_DIR = $$[QT_INSTALL_QML]/QtQuick/Particles
QML_IMPORT_NAME = QtQuick.Particles
-IMPORT_VERSION = 2.15
+QML_IMPORT_VERSION = $$QT_VERSION
CONFIG += qmltypes install_qmltypes install_metatypes
load(qt_module)
diff --git a/src/particles/qquickage_p.h b/src/particles/qquickage_p.h
index 890c6a63c1..1730c25c28 100644
--- a/src/particles/qquickage_p.h
+++ b/src/particles/qquickage_p.h
@@ -60,6 +60,7 @@ class QQuickAgeAffector : public QQuickParticleAffector
Q_PROPERTY(int lifeLeft READ lifeLeft WRITE setLifeLeft NOTIFY lifeLeftChanged)
Q_PROPERTY(bool advancePosition READ advancePosition WRITE setAdvancePosition NOTIFY advancePositionChanged)
QML_NAMED_ELEMENT(Age)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickAgeAffector(QQuickItem *parent = 0);
diff --git a/src/particles/qquickangledirection_p.h b/src/particles/qquickangledirection_p.h
index d0fdf5a68c..9ec9e49d1a 100644
--- a/src/particles/qquickangledirection_p.h
+++ b/src/particles/qquickangledirection_p.h
@@ -63,6 +63,7 @@ class QQuickAngleDirection : public QQuickDirection
Q_PROPERTY(qreal angleVariation READ angleVariation WRITE setAngleVariation NOTIFY angleVariationChanged)
Q_PROPERTY(qreal magnitudeVariation READ magnitudeVariation WRITE setMagnitudeVariation NOTIFY magnitudeVariationChanged)
QML_NAMED_ELEMENT(AngleDirection)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickAngleDirection(QObject *parent = 0);
QPointF sample(const QPointF &from) override;
diff --git a/src/particles/qquickcumulativedirection_p.h b/src/particles/qquickcumulativedirection_p.h
index 5160d8f09a..0a54d5dd22 100644
--- a/src/particles/qquickcumulativedirection_p.h
+++ b/src/particles/qquickcumulativedirection_p.h
@@ -62,6 +62,7 @@ class QQuickCumulativeDirection : public QQuickDirection
Q_PROPERTY(QQmlListProperty<QQuickDirection> directions READ directions)
Q_CLASSINFO("DefaultProperty", "directions")
QML_NAMED_ELEMENT(CumulativeDirection)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickCumulativeDirection(QObject *parent = 0);
QQmlListProperty<QQuickDirection> directions();
diff --git a/src/particles/qquickcustomaffector_p.h b/src/particles/qquickcustomaffector_p.h
index 5e8671514d..4506ae9d62 100644
--- a/src/particles/qquickcustomaffector_p.h
+++ b/src/particles/qquickcustomaffector_p.h
@@ -68,6 +68,7 @@ class QQuickCustomAffector : public QQuickParticleAffector
Q_PROPERTY(QQuickDirection *velocity READ velocity WRITE setVelocity NOTIFY velocityChanged RESET velocityReset)
Q_PROPERTY(QQuickDirection *acceleration READ acceleration WRITE setAcceleration NOTIFY accelerationChanged RESET accelerationReset)
QML_NAMED_ELEMENT(Affector)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickCustomAffector(QQuickItem *parent = 0);
diff --git a/src/particles/qquickcustomparticle.cpp b/src/particles/qquickcustomparticle.cpp
index 91fd63302a..ecb71cb913 100644
--- a/src/particles/qquickcustomparticle.cpp
+++ b/src/particles/qquickcustomparticle.cpp
@@ -39,7 +39,7 @@
#include "qquickcustomparticle_p.h"
#include <QtCore/qrandom.h>
-#include <QtGui/qopenglcontext.h>
+#include <qopenglcontext.h>
#include <QtQuick/private/qquickshadereffectmesh_p.h>
#include <QtQuick/private/qsgshadersourcebuilder_p.h>
#include <QtQml/qqmlinfo.h>
diff --git a/src/particles/qquickcustomparticle_p.h b/src/particles/qquickcustomparticle_p.h
index 444f7ad215..90643fe3e4 100644
--- a/src/particles/qquickcustomparticle_p.h
+++ b/src/particles/qquickcustomparticle_p.h
@@ -68,6 +68,7 @@ class QQuickCustomParticle : public QQuickParticlePainter
Q_PROPERTY(QByteArray fragmentShader READ fragmentShader WRITE setFragmentShader NOTIFY fragmentShaderChanged)
Q_PROPERTY(QByteArray vertexShader READ vertexShader WRITE setVertexShader NOTIFY vertexShaderChanged)
QML_NAMED_ELEMENT(CustomParticle)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickCustomParticle(QQuickItem* parent=0);
diff --git a/src/particles/qquickdirection_p.h b/src/particles/qquickdirection_p.h
index 60b4d8eb1d..e671868ed2 100644
--- a/src/particles/qquickdirection_p.h
+++ b/src/particles/qquickdirection_p.h
@@ -61,6 +61,7 @@ class QQuickDirection : public QObject
{
Q_OBJECT
QML_NAMED_ELEMENT(NullVector)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("Abstract type. Use one of the inheriting types instead.")
public:
diff --git a/src/particles/qquickellipseextruder_p.h b/src/particles/qquickellipseextruder_p.h
index c92443fedf..3268923480 100644
--- a/src/particles/qquickellipseextruder_p.h
+++ b/src/particles/qquickellipseextruder_p.h
@@ -59,6 +59,7 @@ class QQuickEllipseExtruder : public QQuickParticleExtruder
Q_OBJECT
Q_PROPERTY(bool fill READ fill WRITE setFill NOTIFY fillChanged)//###Use base class? If it's still box
QML_NAMED_ELEMENT(EllipseShape)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickEllipseExtruder(QObject *parent = 0);
QPointF extrude(const QRectF &) override;
diff --git a/src/particles/qquickfriction_p.h b/src/particles/qquickfriction_p.h
index 5686bb37d5..952f47b141 100644
--- a/src/particles/qquickfriction_p.h
+++ b/src/particles/qquickfriction_p.h
@@ -60,6 +60,7 @@ class QQuickFrictionAffector : public QQuickParticleAffector
Q_PROPERTY(qreal factor READ factor WRITE setFactor NOTIFY factorChanged)
Q_PROPERTY(qreal threshold READ threshold WRITE setThreshold NOTIFY thresholdChanged)
QML_NAMED_ELEMENT(Friction)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickFrictionAffector(QQuickItem *parent = 0);
diff --git a/src/particles/qquickgravity_p.h b/src/particles/qquickgravity_p.h
index ef7cc770b7..351cbb93b1 100644
--- a/src/particles/qquickgravity_p.h
+++ b/src/particles/qquickgravity_p.h
@@ -62,6 +62,7 @@ class QQuickGravityAffector : public QQuickParticleAffector
Q_PROPERTY(qreal acceleration READ magnitude WRITE setAcceleration NOTIFY magnitudeChanged)
Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged)
QML_NAMED_ELEMENT(Gravity)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickGravityAffector(QQuickItem *parent = 0);
qreal magnitude() const;
diff --git a/src/particles/qquickgroupgoal_p.h b/src/particles/qquickgroupgoal_p.h
index 022b244ed7..5589483aa6 100644
--- a/src/particles/qquickgroupgoal_p.h
+++ b/src/particles/qquickgroupgoal_p.h
@@ -62,6 +62,7 @@ class QQuickGroupGoalAffector : public QQuickParticleAffector
Q_PROPERTY(QString goalState READ goalState WRITE setGoalState NOTIFY goalStateChanged)
Q_PROPERTY(bool jump READ jump WRITE setJump NOTIFY jumpChanged)
QML_NAMED_ELEMENT(GroupGoal)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickGroupGoalAffector(QQuickItem *parent = 0);
diff --git a/src/particles/qquickimageparticle.cpp b/src/particles/qquickimageparticle.cpp
index 4ce8186c7c..4d67691771 100644
--- a/src/particles/qquickimageparticle.cpp
+++ b/src/particles/qquickimageparticle.cpp
@@ -1,4 +1,4 @@
-/****************************************************************************
+/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
@@ -389,10 +389,10 @@ private:
QSGMaterialType DeformableMaterial::m_type;
-class SpriteMaterialShader : public QSGMaterialShader
+class ParticleSpriteMaterialShader : public QSGMaterialShader
{
public:
- SpriteMaterialShader()
+ ParticleSpriteMaterialShader()
{
QSGShaderSourceBuilder builder;
const bool isES = QOpenGLContext::currentContext()->isOpenGLES();
@@ -478,10 +478,10 @@ public:
QOpenGLFunctions* glFuncs;
};
-class SpriteMaterialRhiShader : public QSGMaterialRhiShader
+class ParticleSpriteMaterialRhiShader : public QSGMaterialRhiShader
{
public:
- SpriteMaterialRhiShader()
+ ParticleSpriteMaterialRhiShader()
{
setShaderFileName(VertexStage, QStringLiteral(":/particles/shaders_ng/imageparticle_sprite.vert.qsb"));
setShaderFileName(FragmentStage, QStringLiteral(":/particles/shaders_ng/imageparticle_sprite.frag.qsb"));
@@ -544,9 +544,9 @@ public:
SpriteMaterial() { setFlag(SupportsRhiShader, true); }
QSGMaterialShader *createShader() const override {
if (flags().testFlag(RhiShaderWanted))
- return new SpriteMaterialRhiShader;
+ return new ParticleSpriteMaterialRhiShader;
else
- return new SpriteMaterialShader;
+ return new ParticleSpriteMaterialShader;
}
QSGMaterialType *type() const override { return &m_type; }
@@ -1143,7 +1143,9 @@ QQuickImageParticle::~QQuickImageParticle()
QQmlListProperty<QQuickSprite> QQuickImageParticle::sprites()
{
- return QQmlListProperty<QQuickSprite>(this, &m_sprites, spriteAppend, spriteCount, spriteAt, spriteClear);
+ return QQmlListProperty<QQuickSprite>(this, &m_sprites,
+ spriteAppend, spriteCount, spriteAt,
+ spriteClear, spriteReplace, spriteRemoveLast);
}
void QQuickImageParticle::sceneGraphInvalidated()
diff --git a/src/particles/qquickimageparticle_p.h b/src/particles/qquickimageparticle_p.h
index fdb404861c..266054f28e 100644
--- a/src/particles/qquickimageparticle_p.h
+++ b/src/particles/qquickimageparticle_p.h
@@ -203,6 +203,7 @@ class QQuickImageParticle : public QQuickParticlePainter
Q_PROPERTY(EntryEffect entryEffect READ entryEffect WRITE setEntryEffect NOTIFY entryEffectChanged)
QML_NAMED_ELEMENT(ImageParticle)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickImageParticle(QQuickItem *parent = 0);
virtual ~QQuickImageParticle();
diff --git a/src/particles/qquickitemparticle_p.h b/src/particles/qquickitemparticle_p.h
index 32c9881691..fce9e95548 100644
--- a/src/particles/qquickitemparticle_p.h
+++ b/src/particles/qquickitemparticle_p.h
@@ -64,6 +64,7 @@ class QQuickItemParticle : public QQuickParticlePainter
Q_PROPERTY(bool fade READ fade WRITE setFade NOTIFY fadeChanged)
Q_PROPERTY(QQmlComponent* delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
QML_NAMED_ELEMENT(ItemParticle)
+ QML_ADDED_IN_VERSION(2, 0)
QML_ATTACHED(QQuickItemParticleAttached)
public:
explicit QQuickItemParticle(QQuickItem *parent = 0);
diff --git a/src/particles/qquicklineextruder_p.h b/src/particles/qquicklineextruder_p.h
index 76ac5aaf11..a337324c6a 100644
--- a/src/particles/qquicklineextruder_p.h
+++ b/src/particles/qquicklineextruder_p.h
@@ -58,6 +58,7 @@ class QQuickLineExtruder : public QQuickParticleExtruder
//Default is topleft to bottom right. Flipped makes it topright to bottom left
Q_PROPERTY(bool mirrored READ mirrored WRITE setMirrored NOTIFY mirroredChanged)
QML_NAMED_ELEMENT(LineShape)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickLineExtruder(QObject *parent = 0);
diff --git a/src/particles/qquickmaskextruder_p.h b/src/particles/qquickmaskextruder_p.h
index 419d162811..0d3fa9c15a 100644
--- a/src/particles/qquickmaskextruder_p.h
+++ b/src/particles/qquickmaskextruder_p.h
@@ -62,6 +62,7 @@ class QQuickMaskExtruder : public QQuickParticleExtruder
Q_OBJECT
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
QML_NAMED_ELEMENT(MaskShape)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickMaskExtruder(QObject *parent = 0);
QPointF extrude(const QRectF &) override;
diff --git a/src/particles/qquickparticleaffector_p.h b/src/particles/qquickparticleaffector_p.h
index fd4887333e..22cebbead1 100644
--- a/src/particles/qquickparticleaffector_p.h
+++ b/src/particles/qquickparticleaffector_p.h
@@ -69,6 +69,7 @@ class Q_QUICKPARTICLES_PRIVATE_EXPORT QQuickParticleAffector : public QQuickItem
Q_PROPERTY(QQuickParticleExtruder* shape READ shape WRITE setShape NOTIFY shapeChanged)
QML_NAMED_ELEMENT(ParticleAffector)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("Abstract type. Use one of the inheriting types instead.")
public:
diff --git a/src/particles/qquickparticleemitter_p.h b/src/particles/qquickparticleemitter_p.h
index b97d3f812a..8c9ca622fb 100644
--- a/src/particles/qquickparticleemitter_p.h
+++ b/src/particles/qquickparticleemitter_p.h
@@ -84,6 +84,7 @@ class Q_QUICKPARTICLES_PRIVATE_EXPORT QQuickParticleEmitter : public QQuickItem
Q_PROPERTY(QQuickDirection *acceleration READ acceleration WRITE setAcceleration NOTIFY accelerationChanged)
Q_PROPERTY(qreal velocityFromMovement READ velocityFromMovement WRITE setVelocityFromMovement NOTIFY velocityFromMovementChanged)
QML_NAMED_ELEMENT(Emitter)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickParticleEmitter(QQuickItem *parent = 0);
diff --git a/src/particles/qquickparticleextruder_p.h b/src/particles/qquickparticleextruder_p.h
index 24f7a0a2fa..7be0ead245 100644
--- a/src/particles/qquickparticleextruder_p.h
+++ b/src/particles/qquickparticleextruder_p.h
@@ -63,6 +63,7 @@ class QQuickParticleExtruder : public QObject
Q_OBJECT
QML_NAMED_ELEMENT(ParticleExtruder)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("Abstract type. Use one of the inheriting types instead.")
public:
diff --git a/src/particles/qquickparticlegroup.cpp b/src/particles/qquickparticlegroup.cpp
index 052fda6eff..902c23331d 100644
--- a/src/particles/qquickparticlegroup.cpp
+++ b/src/particles/qquickparticlegroup.cpp
@@ -106,10 +106,15 @@ void delayedRedirect(QQmlListProperty<QObject> *prop, QObject *value)
QQmlListProperty<QObject> QQuickParticleGroup::particleChildren()
{
QQuickParticleSystem* system = qobject_cast<QQuickParticleSystem*>(parent());
- if (system)
- return QQmlListProperty<QObject>(this, nullptr, &QQuickParticleSystem::statePropertyRedirect, nullptr, nullptr, nullptr);
- else
- return QQmlListProperty<QObject>(this, nullptr, &delayedRedirect, nullptr, nullptr, nullptr);
+ if (system) {
+ return QQmlListProperty<QObject>(this, nullptr,
+ &QQuickParticleSystem::statePropertyRedirect, nullptr,
+ nullptr, nullptr, nullptr, nullptr);
+ } else {
+ return QQmlListProperty<QObject>(this, nullptr,
+ &delayedRedirect, nullptr, nullptr,
+ nullptr, nullptr, nullptr);
+ }
}
void QQuickParticleGroup::setSystem(QQuickParticleSystem* arg)
diff --git a/src/particles/qquickparticlegroup_p.h b/src/particles/qquickparticlegroup_p.h
index 8d068fbe9c..9b13153a95 100644
--- a/src/particles/qquickparticlegroup_p.h
+++ b/src/particles/qquickparticlegroup_p.h
@@ -67,6 +67,7 @@ class QQuickParticleGroup : public QQuickStochasticState, public QQmlParserStatu
Q_PROPERTY(QQmlListProperty<QObject> particleChildren READ particleChildren DESIGNABLE false)//### Hidden property for in-state system definitions - ought not to be used in actual "Sprite" states
Q_CLASSINFO("DefaultProperty", "particleChildren")
QML_NAMED_ELEMENT(ParticleGroup)
+ QML_ADDED_IN_VERSION(2, 0)
Q_INTERFACES(QQmlParserStatus)
public:
diff --git a/src/particles/qquickparticlepainter_p.h b/src/particles/qquickparticlepainter_p.h
index e3d13b8a21..5236bb6569 100644
--- a/src/particles/qquickparticlepainter_p.h
+++ b/src/particles/qquickparticlepainter_p.h
@@ -65,6 +65,7 @@ class QQuickParticlePainter : public QQuickItem
Q_PROPERTY(QStringList groups READ groups WRITE setGroups NOTIFY groupsChanged)
QML_NAMED_ELEMENT(ParticlePainter)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("Abstract type. Use one of the inheriting types instead.")
public: // data
diff --git a/src/particles/qquickparticlesystem_p.h b/src/particles/qquickparticlesystem_p.h
index 7c0a1ffd7d..b7812c6ea5 100644
--- a/src/particles/qquickparticlesystem_p.h
+++ b/src/particles/qquickparticlesystem_p.h
@@ -352,6 +352,7 @@ class Q_QUICKPARTICLES_PRIVATE_EXPORT QQuickParticleSystem : public QQuickItem
Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged)
QML_NAMED_ELEMENT(ParticleSystem)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickParticleSystem(QQuickItem *parent = nullptr);
diff --git a/src/particles/qquickpointattractor_p.h b/src/particles/qquickpointattractor_p.h
index 28bbaaa84f..b3314f1a96 100644
--- a/src/particles/qquickpointattractor_p.h
+++ b/src/particles/qquickpointattractor_p.h
@@ -63,6 +63,7 @@ class QQuickAttractorAffector : public QQuickParticleAffector
Q_PROPERTY(AffectableParameters affectedParameter READ affectedParameter WRITE setAffectedParameter NOTIFY affectedParameterChanged)
Q_PROPERTY(Proportion proportionalToDistance READ proportionalToDistance WRITE setProportionalToDistance NOTIFY proportionalToDistanceChanged)
QML_NAMED_ELEMENT(Attractor)
+ QML_ADDED_IN_VERSION(2, 0)
public:
enum Proportion{
diff --git a/src/particles/qquickpointdirection_p.h b/src/particles/qquickpointdirection_p.h
index 9103a570c9..39109d8331 100644
--- a/src/particles/qquickpointdirection_p.h
+++ b/src/particles/qquickpointdirection_p.h
@@ -62,6 +62,7 @@ class QQuickPointDirection : public QQuickDirection
Q_PROPERTY(qreal xVariation READ xVariation WRITE setXVariation NOTIFY xVariationChanged)
Q_PROPERTY(qreal yVariation READ yVariation WRITE setYVariation NOTIFY yVariationChanged)
QML_NAMED_ELEMENT(PointDirection)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickPointDirection(QObject *parent = 0);
QPointF sample(const QPointF &from) override;
diff --git a/src/particles/qquickrectangleextruder_p.h b/src/particles/qquickrectangleextruder_p.h
index 7c0a6c2bf1..f6f39579c4 100644
--- a/src/particles/qquickrectangleextruder_p.h
+++ b/src/particles/qquickrectangleextruder_p.h
@@ -60,6 +60,7 @@ class QQuickRectangleExtruder : public QQuickParticleExtruder
Q_OBJECT
Q_PROPERTY(bool fill READ fill WRITE setFill NOTIFY fillChanged)
QML_NAMED_ELEMENT(RectangleShape)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickRectangleExtruder(QObject *parent = 0);
diff --git a/src/particles/qquickspritegoal_p.h b/src/particles/qquickspritegoal_p.h
index d5f9bb88ae..efd9b1ab39 100644
--- a/src/particles/qquickspritegoal_p.h
+++ b/src/particles/qquickspritegoal_p.h
@@ -64,6 +64,7 @@ class QQuickSpriteGoalAffector : public QQuickParticleAffector
Q_PROPERTY(bool jump READ jump WRITE setJump NOTIFY jumpChanged)
Q_PROPERTY(bool systemStates READ systemStates WRITE setSystemStates NOTIFY systemStatesChanged)
QML_NAMED_ELEMENT(SpriteGoal)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickSpriteGoalAffector(QQuickItem *parent = 0);
diff --git a/src/particles/qquicktargetdirection_p.h b/src/particles/qquicktargetdirection_p.h
index 232d375d8c..ea6ac24893 100644
--- a/src/particles/qquicktargetdirection_p.h
+++ b/src/particles/qquicktargetdirection_p.h
@@ -71,6 +71,7 @@ class QQuickTargetDirection : public QQuickDirection
Q_PROPERTY(qreal magnitude READ magnitude WRITE setMagnitude NOTIFY magnitudeChanged)
Q_PROPERTY(qreal magnitudeVariation READ magnitudeVariation WRITE setMagnitudeVariation NOTIFY magnitudeVariationChanged)
QML_NAMED_ELEMENT(TargetDirection)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickTargetDirection(QObject *parent = 0);
diff --git a/src/particles/qquicktrailemitter_p.h b/src/particles/qquicktrailemitter_p.h
index 270bec52cf..bf21b66fb6 100644
--- a/src/particles/qquicktrailemitter_p.h
+++ b/src/particles/qquicktrailemitter_p.h
@@ -65,6 +65,7 @@ class QQuickTrailEmitter : public QQuickParticleEmitter
Q_PROPERTY(qreal emitHeight READ emitterYVariation WRITE setEmitterYVariation NOTIFY emitterYVariationChanged)
Q_PROPERTY(qreal emitWidth READ emitterXVariation WRITE setEmitterXVariation NOTIFY emitterXVariationChanged)
QML_NAMED_ELEMENT(TrailEmitter)
+ QML_ADDED_IN_VERSION(2, 0)
public:
enum EmitSize {
diff --git a/src/particles/qquickturbulence_p.h b/src/particles/qquickturbulence_p.h
index 52011381e4..77239660d8 100644
--- a/src/particles/qquickturbulence_p.h
+++ b/src/particles/qquickturbulence_p.h
@@ -63,6 +63,7 @@ class QQuickTurbulenceAffector : public QQuickParticleAffector
Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged)
Q_PROPERTY(QUrl noiseSource READ noiseSource WRITE setNoiseSource NOTIFY noiseSourceChanged)
QML_NAMED_ELEMENT(Turbulence)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickTurbulenceAffector(QQuickItem *parent = 0);
diff --git a/src/particles/qquickwander_p.h b/src/particles/qquickwander_p.h
index bf7acdacfb..174b780562 100644
--- a/src/particles/qquickwander_p.h
+++ b/src/particles/qquickwander_p.h
@@ -72,6 +72,7 @@ class QQuickWanderAffector : public QQuickParticleAffector
Q_PROPERTY(qreal yVariance READ yVariance WRITE setYVariance NOTIFY yVarianceChanged)
Q_PROPERTY(AffectableParameters affectedParameter READ affectedParameter WRITE setAffectedParameter NOTIFY affectedParameterChanged)
QML_NAMED_ELEMENT(Wander)
+ QML_ADDED_IN_VERSION(2, 0)
public:
enum AffectableParameters {
diff --git a/src/particles/qtquickparticlesglobal_p.h b/src/particles/qtquickparticlesglobal_p.h
index d7647b3d97..927bc29050 100644
--- a/src/particles/qtquickparticlesglobal_p.h
+++ b/src/particles/qtquickparticlesglobal_p.h
@@ -65,4 +65,6 @@
# define Q_QUICKPARTICLES_PRIVATE_EXPORT
#endif
+void Q_QUICKPARTICLES_PRIVATE_EXPORT qml_register_types_QtQuick_Particles();
+
#endif // QTQUICKPARTICLESGLOBAL_P_H
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp
index a3d19841cf..d435e82390 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp
@@ -94,9 +94,12 @@ qint64 NullDevice::writeData(const char *data, qint64 len)
// (otherwise we assert in QVariant::operator<< when actually saving it)
static bool isSaveable(const QVariant &value)
{
+ const int valType = static_cast<int>(value.userType());
+ if (valType >= QMetaType::User)
+ return false;
NullDevice nullDevice;
QDataStream fakeStream(&nullDevice);
- return QMetaType::save(fakeStream, static_cast<int>(value.userType()), value.constData());
+ return QMetaType::save(fakeStream, valType, value.constData());
}
QQmlEngineDebugServiceImpl::QQmlEngineDebugServiceImpl(QObject *parent) :
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp
index 61fea96e2f..333ce4b26f 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp
@@ -66,7 +66,6 @@ void JavaScriptJob::run()
QV4::ScopedContext ctx(scope, engine->currentStackFrame ? engine->currentContext()
: engine->scriptContext());
- QObject scopeObject;
QV4::CppStackFrame *frame = engine->currentStackFrame;
@@ -76,9 +75,10 @@ void JavaScriptJob::run()
ctx = static_cast<QV4::ExecutionContext *>(&frame->jsFrame->context);
if (context >= 0) {
- QQmlContext *extraContext = qmlContext(QQmlDebugService::objectForId(context));
+ QObject *forId = QQmlDebugService::objectForId(context);
+ QQmlContext *extraContext = qmlContext(forId);
if (extraContext)
- ctx = QV4::QmlContext::create(ctx, QQmlContextData::get(extraContext), &scopeObject);
+ ctx = QV4::QmlContext::create(ctx, QQmlContextData::get(extraContext), forId);
} else if (frameNr < 0) { // Use QML context if available
QQmlEngine *qmlEngine = engine->qmlEngine();
if (qmlEngine) {
@@ -99,7 +99,7 @@ void JavaScriptJob::run()
}
}
if (!engine->qmlContext())
- ctx = QV4::QmlContext::create(ctx, QQmlContextData::get(qmlRootContext), &scopeObject);
+ ctx = QV4::QmlContext::create(ctx, QQmlContextData::get(qmlRootContext), nullptr);
}
}
diff --git a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
index bf73440a39..c504ea605a 100644
--- a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
+++ b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
@@ -183,7 +183,7 @@ QQmlNativeDebugConnector::QQmlNativeDebugConnector()
: m_blockingMode(false)
{
const QString args = commandLineArguments();
- const auto lstjsDebugArguments = args.splitRef(QLatin1Char(','), QString::SkipEmptyParts);
+ const auto lstjsDebugArguments = args.splitRef(QLatin1Char(','), Qt::SkipEmptyParts);
QStringList services;
for (const QStringRef &strArgument : lstjsDebugArguments) {
if (strArgument == QLatin1String("block")) {
diff --git a/src/plugins/qmltooling/qmldbg_preview/qmldbg_preview.pro b/src/plugins/qmltooling/qmldbg_preview/qmldbg_preview.pro
index 08686a43e3..e1cbc393f7 100644
--- a/src/plugins/qmltooling/qmldbg_preview/qmldbg_preview.pro
+++ b/src/plugins/qmltooling/qmldbg_preview/qmldbg_preview.pro
@@ -3,6 +3,7 @@ QT += core-private qml-private packetprotocol-private network quick-private gui-
TARGET = qmldbg_preview
SOURCES += \
+ $$PWD/qqmldebugtranslationservice.cpp \
$$PWD/qqmlpreviewblacklist.cpp \
$$PWD/qqmlpreviewfileengine.cpp \
$$PWD/qqmlpreviewfileloader.cpp \
@@ -12,6 +13,7 @@ SOURCES += \
$$PWD/qqmlpreviewservicefactory.cpp
HEADERS += \
+ $$PWD/qqmldebugtranslationservice.h \
$$PWD/qqmlpreviewblacklist.h \
$$PWD/qqmlpreviewfileengine.h \
$$PWD/qqmlpreviewfileloader.h \
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmldebugtranslationservice.cpp b/src/plugins/qmltooling/qmldbg_preview/qqmldebugtranslationservice.cpp
new file mode 100644
index 0000000000..1561777202
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmldebugtranslationservice.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmldebugtranslationservice.h"
+
+QT_BEGIN_NAMESPACE
+
+QQmlDebugTranslationServiceImpl::QQmlDebugTranslationServiceImpl(QObject *parent) :
+ QQmlDebugTranslationService(1, parent)
+{
+}
+
+void QQmlDebugTranslationServiceImpl::messageReceived(const QByteArray &message)
+{
+ Q_UNUSED(message)
+}
+
+QString QQmlDebugTranslationServiceImpl::foundElidedText(QObject *textObject, const QString &layoutText, const QString &elideText)
+{
+ Q_UNUSED(textObject)
+ Q_UNUSED(layoutText)
+ return elideText;
+}
+
+void QQmlDebugTranslationServiceImpl::foundTranslationBinding(QQmlTranslationBinding *binding, QObject *scopeObject, QQmlContextData *contextData)
+{
+ Q_UNUSED(binding)
+ Q_UNUSED(scopeObject)
+ Q_UNUSED(contextData)
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmldebugtranslationservice.h b/src/plugins/qmltooling/qmldbg_preview/qqmldebugtranslationservice.h
new file mode 100644
index 0000000000..a337a937a5
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmldebugtranslationservice.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDEBUGMESSAGESERVICE_H
+#define QDEBUGMESSAGESERVICE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qqmldebugserviceinterfaces_p.h>
+
+#include <QtCore/qlogging.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qelapsedtimer.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlDebugTranslationServicePrivate;
+
+class QQmlDebugTranslationServiceImpl : public QQmlDebugTranslationService
+{
+ Q_OBJECT
+public:
+ //needs to be in sync with QQmlDebugTranslationClient in qqmldebugtranslationclient_p.h
+ enum Command {
+ ChangeLanguage,
+ ChangeWarningColor,
+ ChangeElidedTextWarningString,
+ SetDebugTranslationServiceLogFile,
+ EnableElidedTextWarning,
+ DisableElidedTextWarning,
+ TestAllLanguages
+ };
+ QQmlDebugTranslationServiceImpl(QObject *parent = 0);
+
+ QString foundElidedText(QObject *textObject, const QString &layoutText, const QString &elideText) override;
+ void foundTranslationBinding(QQmlTranslationBinding *binding, QObject *scopeObject, QQmlContextData *contextData) override;
+ void messageReceived(const QByteArray &message) override;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDEBUGMESSAGESERVICE_H
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.json b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.json
index d7e1ef1f10..5e148f8101 100644
--- a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.json
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservice.json
@@ -1,3 +1,3 @@
{
- "Keys" : [ "QmlPreview" ]
+ "Keys" : [ "QmlPreview", "DebugTranslation" ]
}
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservicefactory.cpp b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservicefactory.cpp
index f0aa3226c8..6ff9805bbe 100644
--- a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservicefactory.cpp
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewservicefactory.cpp
@@ -39,12 +39,18 @@
#include "qqmlpreviewservicefactory.h"
#include "qqmlpreviewservice.h"
+#include "qqmldebugtranslationservice.h"
QT_BEGIN_NAMESPACE
QQmlDebugService *QQmlPreviewServiceFactory::create(const QString &key)
{
- return key == QQmlPreviewServiceImpl::s_key ? new QQmlPreviewServiceImpl(this) : nullptr;
+ if (key == QQmlPreviewServiceImpl::s_key)
+ return new QQmlPreviewServiceImpl(this);
+ if (key == QQmlDebugTranslationServiceImpl::s_key)
+ return new QQmlDebugTranslationServiceImpl(this);
+
+ return nullptr;
}
QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
index cc663cd6b3..4d68a4508b 100644
--- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
+++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
@@ -345,7 +345,7 @@ void QQmlDebugServerImpl::parseArguments()
QString fileName;
QStringList services;
- const auto lstjsDebugArguments = args.splitRef(QLatin1Char(','), QString::SkipEmptyParts);
+ const auto lstjsDebugArguments = args.splitRef(QLatin1Char(','), Qt::SkipEmptyParts);
for (auto argsIt = lstjsDebugArguments.begin(), argsItEnd = lstjsDebugArguments.end(); argsIt != argsItEnd; ++argsIt) {
const QStringRef &strArgument = *argsIt;
if (strArgument.startsWith(QLatin1String("port:"))) {
@@ -422,6 +422,11 @@ void QQmlDebugServerImpl::parseArguments()
<< tr("Sends qDebug() and similar messages over the QML debug\n"
"\t\t connection. QtCreator uses this for showing debug\n"
"\t\t messages in the debugger console.") << '\n'
+ << '\n' << QQmlDebugTranslationService::s_key << "\t- "
+ //: Please preserve the line breaks and formatting
+ << tr("helps to see if a translated text\n"
+ "\t\t will result in an elided text\n"
+ "\t\t in QML elements.") << '\n'
<< tr("Other services offered by qmltooling plugins that implement "
"QQmlDebugServiceFactory and which can be found in the standard plugin "
"paths will also be available and can be specified. If no \"services\" "
diff --git a/src/plugins/qmltooling/qmltooling.pro b/src/plugins/qmltooling/qmltooling.pro
index 30097be77b..b5b6e5d7aa 100644
--- a/src/plugins/qmltooling/qmltooling.pro
+++ b/src/plugins/qmltooling/qmltooling.pro
@@ -36,7 +36,7 @@ qtHaveModule(quick) {
qmldbg_inspector \
qmldbg_quickprofiler
- qtConfig(qml-network): SUBDIRS += qmldbg_preview
+ qtConfig(settings):qtConfig(qml-network): SUBDIRS += qmldbg_preview
qmldbg_inspector.depends = packetprotocol
qmldbg_quickprofiler.depends = packetprotocol
diff --git a/src/qml/common/common.pri b/src/qml/common/common.pri
index bcc3ea0fa0..b333c0f6d9 100644
--- a/src/qml/common/common.pri
+++ b/src/qml/common/common.pri
@@ -28,6 +28,7 @@ HEADERS += \
$$PWD/qqmljsdiagnosticmessage_p.h \
$$PWD/qqmljsfixedpoolarray_p.h \
$$PWD/qqmljsmemorypool_p.h \
+ $$PWD/qqmljssourcelocation_p.h \
$$PWD/qv4alloca_p.h \
$$PWD/qv4calldata_p.h \
$$PWD/qv4compileddata_p.h \
diff --git a/src/qml/common/qqmlapiversion_p.h b/src/qml/common/qqmlapiversion_p.h
index 4baf37e11c..44d8e3f236 100644
--- a/src/qml/common/qqmlapiversion_p.h
+++ b/src/qml/common/qqmlapiversion_p.h
@@ -51,6 +51,6 @@
// We mean it.
//
-#define Q_QML_PRIVATE_API_VERSION 7
+#define Q_QML_PRIVATE_API_VERSION 8
#endif // QQMLAPIVERSION_P_H
diff --git a/src/qml/common/qqmljsdiagnosticmessage_p.h b/src/qml/common/qqmljsdiagnosticmessage_p.h
index 763332ba76..9f5380ae0c 100644
--- a/src/qml/common/qqmljsdiagnosticmessage_p.h
+++ b/src/qml/common/qqmljsdiagnosticmessage_p.h
@@ -58,6 +58,8 @@
// QQmlSourceLocation -> line/column change.
#include <private/qqmlapiversion_p.h>
+#include "qqmljssourcelocation_p.h"
+
QT_BEGIN_NAMESPACE
namespace QQmlJS {
@@ -65,8 +67,7 @@ struct DiagnosticMessage
{
QString message;
QtMsgType type = QtCriticalMsg;
- quint32 line = 0;
- quint32 column = 0;
+ SourceLocation loc;
bool isError() const
{
diff --git a/src/qml/parser/qqmljssourcelocation_p.h b/src/qml/common/qqmljssourcelocation_p.h
index d76e701d49..7c75541eb1 100644
--- a/src/qml/parser/qqmljssourcelocation_p.h
+++ b/src/qml/common/qqmljssourcelocation_p.h
@@ -40,8 +40,6 @@
#ifndef QQMLJSSOURCELOCATION_P_H
#define QQMLJSSOURCELOCATION_P_H
-#include "qqmljsglobal_p.h"
-
#include <QtCore/qglobal.h>
//
@@ -57,7 +55,7 @@
QT_BEGIN_NAMESPACE
-namespace QQmlJS { namespace AST {
+namespace QQmlJS {
class SourceLocation
{
@@ -80,7 +78,7 @@ public:
quint32 startColumn;
};
-} } // namespace AST
+} // namespace QQmlJS
QT_END_NAMESPACE
diff --git a/src/qml/common/qv4compileddata_p.h b/src/qml/common/qv4compileddata_p.h
index 1480df2817..7d6ef14854 100644
--- a/src/qml/common/qv4compileddata_p.h
+++ b/src/qml/common/qv4compileddata_p.h
@@ -57,6 +57,7 @@
#include <QtCore/qvector.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qhash.h>
+#include <QtCore/qversionnumber.h>
#if QT_CONFIG(temporaryfile)
#include <QtCore/qsavefile.h>
@@ -76,7 +77,7 @@ QT_BEGIN_NAMESPACE
// Also change the comment behind the number to describe the latest change. This has the added
// benefit that if another patch changes the version too, it will result in a merge conflict, and
// not get removed silently.
-#define QV4_DATA_STRUCTURE_VERSION 0x28// support inline components
+#define QV4_DATA_STRUCTURE_VERSION 0x30// support additional required property features
class QIODevice;
class QQmlTypeNameCache;
@@ -671,6 +672,12 @@ struct Property
};
static_assert(sizeof(Property) == 12, "Property structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+struct RequiredPropertyExtraData {
+ quint32_le nameIndex;
+};
+
+static_assert (sizeof(RequiredPropertyExtraData) == 4, "RequiredPropertyExtraData structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+
struct Alias {
enum Flags : unsigned int {
IsReadOnly = 0x1,
@@ -741,13 +748,16 @@ struct Object
Location locationOfIdProperty;
quint32_le offsetToInlineComponents;
quint16_le nInlineComponents;
+ quint32_le offsetToRequiredPropertyExtraData;
+ quint16_le nRequiredPropertyExtraData;
// Function[]
// Property[]
// Signal[]
// Binding[]
// InlineComponent[]
+// RequiredPropertyExtraData[]
- static int calculateSizeExcludingSignalsAndEnums(int nFunctions, int nProperties, int nAliases, int nEnums, int nSignals, int nBindings, int nNamedObjectsInComponent, int nInlineComponents)
+ static int calculateSizeExcludingSignalsAndEnums(int nFunctions, int nProperties, int nAliases, int nEnums, int nSignals, int nBindings, int nNamedObjectsInComponent, int nInlineComponents, int nRequiredPropertyExtraData)
{
return ( sizeof(Object)
+ nFunctions * sizeof(quint32)
@@ -758,6 +768,7 @@ struct Object
+ nBindings * sizeof(Binding)
+ nNamedObjectsInComponent * sizeof(int)
+ nInlineComponents * sizeof(InlineComponent)
+ + nRequiredPropertyExtraData * sizeof(RequiredPropertyExtraData)
+ 0x7
) & ~0x7;
}
@@ -811,6 +822,16 @@ struct Object
return reinterpret_cast<const InlineComponent*>(reinterpret_cast<const char *>(this) + offsetToInlineComponents);
}
+ const RequiredPropertyExtraData *requiredPropertyExtraDataAt(int idx) const
+ {
+ return requiredPropertyExtraDataTable() + idx;
+ }
+
+ const RequiredPropertyExtraData *requiredPropertyExtraDataTable() const
+ {
+ return reinterpret_cast<const RequiredPropertyExtraData*>(reinterpret_cast<const char *>(this) + offsetToRequiredPropertyExtraData);
+ }
+
// --- QQmlPropertyCacheCreator interface
int propertyCount() const { return nProperties; }
int aliasCount() const { return nAliases; }
@@ -839,10 +860,14 @@ struct Object
InlineComponentIterator inlineComponentsBegin() const {return InlineComponentIterator(this, 0);}
InlineComponentIterator inlineComponentsEnd() const {return InlineComponentIterator(this, nInlineComponents);}
+ typedef TableIterator<RequiredPropertyExtraData, Object, &Object::requiredPropertyExtraDataAt> RequiredPropertyExtraDataIterator;
+ RequiredPropertyExtraDataIterator requiredPropertyExtraDataBegin() const {return RequiredPropertyExtraDataIterator(this, 0); };
+ RequiredPropertyExtraDataIterator requiredPropertyExtraDataEnd() const {return RequiredPropertyExtraDataIterator(this, nRequiredPropertyExtraData); };
+
int namedObjectsInComponentCount() const { return nNamedObjectsInComponent; }
// ---
};
-static_assert(sizeof(Object) == 76, "Object structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+static_assert(sizeof(Object) == 84, "Object structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
struct Import
{
@@ -857,14 +882,16 @@ struct Import
quint32_le uriIndex;
quint32_le qualifierIndex;
- qint32_le majorVersion;
- qint32_le minorVersion;
-
Location location;
+ QTypeRevision version;
+ quint16_le reserved;
- Import() { type = 0; uriIndex = 0; qualifierIndex = 0; majorVersion = 0; minorVersion = 0; }
+ Import()
+ {
+ type = 0; uriIndex = 0; qualifierIndex = 0; version = QTypeRevision::zero(); reserved = 0;
+ }
};
-static_assert(sizeof(Import) == 24, "Import structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+static_assert(sizeof(Import) == 20, "Import structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
struct QmlUnit
{
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index 811f88cb73..5217e11115 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -64,6 +64,33 @@ using namespace QQmlJS;
return false; \
}
+void Object::simplifyRequiredProperties() {
+ // if a property of the current object was marked as required
+ // do not store that information in the ExtraData
+ // but rather mark the property as required
+ QSet<int> required;
+ for (auto it = this->requiredPropertyExtraDataBegin(); it != this->requiredPropertyExtraDataEnd(); ++it)
+ required.insert(it->nameIndex);
+ if (required.isEmpty())
+ return;
+ for (auto it = this->propertiesBegin(); it != this->propertiesEnd(); ++it) {
+ auto requiredIt = required.find(it->nameIndex);
+ if (requiredIt != required.end()) {
+ it->isRequired = true;
+ required.erase(requiredIt);
+ }
+ }
+ QmlIR::RequiredPropertyExtraData *prev = nullptr;
+ auto current = this->requiredPropertyExtraDatas->first;
+ while (current) {
+ if (required.contains(current->nameIndex))
+ prev = current;
+ else
+ requiredPropertyExtraDatas->unlink(prev, current);
+ current = current->next;
+ }
+}
+
bool Parameter::init(QV4::Compiler::JSUnitGenerator *stringGenerator, const QString &parameterName,
const QString &typeName)
{
@@ -142,7 +169,7 @@ QV4::CompiledData::BuiltinType Parameter::stringToBuiltinType(const QString &typ
return QV4::CompiledData::BuiltinType::InvalidBuiltin;
}
-void Object::init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex, const QQmlJS::AST::SourceLocation &loc)
+void Object::init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex, const QQmlJS::SourceLocation &loc)
{
inheritedTypeNameIndex = typeNameIndex;
@@ -162,10 +189,11 @@ void Object::init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex, cons
functions = pool->New<PoolList<Function> >();
functionsAndExpressions = pool->New<PoolList<CompiledFunctionOrExpression> >();
inlineComponents = pool->New<PoolList<InlineComponent>>();
+ requiredPropertyExtraDatas = pool->New<PoolList<RequiredPropertyExtraData>>();
declarationsOverride = nullptr;
}
-QString IRBuilder::sanityCheckFunctionNames(Object *obj, const QSet<QString> &illegalNames, QQmlJS::AST::SourceLocation *errorLocation)
+QString IRBuilder::sanityCheckFunctionNames(Object *obj, const QSet<QString> &illegalNames, QQmlJS::SourceLocation *errorLocation)
{
QSet<int> functionNames;
for (auto functionit = obj->functionsBegin(); functionit != obj->functionsEnd(); ++functionit) {
@@ -221,7 +249,7 @@ QString Object::appendSignal(Signal *signal)
return QString(); // no error
}
-QString Object::appendProperty(Property *prop, const QString &propertyName, bool isDefaultProperty, const QQmlJS::AST::SourceLocation &defaultToken, QQmlJS::AST::SourceLocation *errorLocation)
+QString Object::appendProperty(Property *prop, const QString &propertyName, bool isDefaultProperty, const QQmlJS::SourceLocation &defaultToken, QQmlJS::SourceLocation *errorLocation)
{
Object *target = declarationsOverride;
if (!target)
@@ -245,7 +273,7 @@ QString Object::appendProperty(Property *prop, const QString &propertyName, bool
return QString(); // no error
}
-QString Object::appendAlias(Alias *alias, const QString &aliasName, bool isDefaultProperty, const QQmlJS::AST::SourceLocation &defaultToken, QQmlJS::AST::SourceLocation *errorLocation)
+QString Object::appendAlias(Alias *alias, const QString &aliasName, bool isDefaultProperty, const QQmlJS::SourceLocation &defaultToken, QQmlJS::SourceLocation *errorLocation)
{
Object *target = declarationsOverride;
if (!target)
@@ -287,6 +315,11 @@ void Object::appendInlineComponent(InlineComponent *ic)
inlineComponents->append(ic);
}
+void Object::appendRequiredPropertyExtraData(RequiredPropertyExtraData *extraData)
+{
+ requiredPropertyExtraDatas->append(extraData);
+}
+
QString Object::appendBinding(Binding *b, bool isListBinding)
{
const bool bindingToDefaultProperty = (b->propertyNameIndex == quint32(0));
@@ -325,8 +358,8 @@ QString Object::bindingAsString(Document *doc, int scriptIndex) const
QQmlJS::AST::Node *node = foe->node;
if (QQmlJS::AST::ExpressionStatement *exprStmt = QQmlJS::AST::cast<QQmlJS::AST::ExpressionStatement *>(node))
node = exprStmt->expression;
- QQmlJS::AST::SourceLocation start = node->firstSourceLocation();
- QQmlJS::AST::SourceLocation end = node->lastSourceLocation();
+ QQmlJS::SourceLocation start = node->firstSourceLocation();
+ QQmlJS::SourceLocation end = node->lastSourceLocation();
return doc->code.mid(start.offset, end.offset + end.length - start.offset);
}
@@ -374,11 +407,7 @@ void ScriptDirectivesCollector::importModule(const QString &uri, const QString &
QV4::CompiledData::Import *import = engine->pool()->New<QV4::CompiledData::Import>();
import->type = QV4::CompiledData::Import::ImportLibrary;
import->uriIndex = jsGenerator->registerString(uri);
- int vmaj;
- int vmin;
- IRBuilder::extractVersion(QStringRef(&version), &vmaj, &vmin);
- import->majorVersion = vmaj;
- import->minorVersion = vmin;
+ import->version = IRBuilder::extractVersion(QStringRef(&version));
import->qualifierIndex = jsGenerator->registerString(module);
import->location.line = lineNumber;
import->location.column = column;
@@ -409,7 +438,7 @@ bool IRBuilder::generateFromQml(const QString &code, const QString &url, Documen
// Extract errors from the parser
for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) {
if (m.isWarning()) {
- qWarning("%s:%d : %s", qPrintable(url), m.line, qPrintable(m.message));
+ qWarning("%s:%d : %s", qPrintable(url), m.loc.startLine, qPrintable(m.message));
continue;
}
@@ -437,7 +466,7 @@ bool IRBuilder::generateFromQml(const QString &code, const QString &url, Documen
accept(program->headers);
if (program->members->next) {
- QQmlJS::AST::SourceLocation loc = program->members->next->firstSourceLocation();
+ QQmlJS::SourceLocation loc = program->members->next->firstSourceLocation();
recordError(loc, QCoreApplication::translate("QQmlParser", "Unexpected object definition"));
return false;
}
@@ -452,6 +481,10 @@ bool IRBuilder::generateFromQml(const QString &code, const QString &url, Documen
qSwap(_imports, output->imports);
qSwap(_pragmas, output->pragmas);
qSwap(_objects, output->objects);
+
+ for (auto object: output->objects)
+ object->simplifyRequiredProperties();
+
return errors.isEmpty();
}
@@ -498,7 +531,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiObjectDefinition *node)
int idx = 0;
if (!defineQMLObject(&idx, node))
return false;
- const QQmlJS::AST::SourceLocation nameLocation = node->qualifiedTypeNameId->identifierToken;
+ const QQmlJS::SourceLocation nameLocation = node->qualifiedTypeNameId->identifierToken;
appendBinding(nameLocation, nameLocation, emptyStringIndex, idx);
} else {
int idx = 0;
@@ -553,7 +586,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiScriptBinding *node)
bool IRBuilder::visit(QQmlJS::AST::UiArrayBinding *node)
{
- const QQmlJS::AST::SourceLocation qualifiedNameLocation = node->qualifiedId->identifierToken;
+ const QQmlJS::SourceLocation qualifiedNameLocation = node->qualifiedId->identifierToken;
Object *object = nullptr;
QQmlJS::AST::UiQualifiedId *name = node->qualifiedId;
if (!resolveQualifiedId(&name, &object))
@@ -618,7 +651,7 @@ void IRBuilder::accept(QQmlJS::AST::Node *node)
QQmlJS::AST::Node::accept(node, this);
}
-bool IRBuilder::defineQMLObject(int *objectIndex, QQmlJS::AST::UiQualifiedId *qualifiedTypeNameId, const QQmlJS::AST::SourceLocation &location, QQmlJS::AST::UiObjectInitializer *initializer, Object *declarationsOverride)
+bool IRBuilder::defineQMLObject(int *objectIndex, QQmlJS::AST::UiQualifiedId *qualifiedTypeNameId, const QQmlJS::SourceLocation &location, QQmlJS::AST::UiObjectInitializer *initializer, Object *declarationsOverride)
{
if (QQmlJS::AST::UiQualifiedId *lastName = qualifiedTypeNameId) {
while (lastName->next)
@@ -654,7 +687,7 @@ bool IRBuilder::defineQMLObject(int *objectIndex, QQmlJS::AST::UiQualifiedId *qu
if (!errors.isEmpty())
return false;
- QQmlJS::AST::SourceLocation loc;
+ QQmlJS::SourceLocation loc;
QString error = sanityCheckFunctionNames(obj, illegalNames, &loc);
if (!error.isEmpty()) {
recordError(loc, error);
@@ -715,16 +748,14 @@ bool IRBuilder::visit(QQmlJS::AST::UiImport *node)
}
if (node->version) {
- import->majorVersion = node->version->majorVersion;
- import->minorVersion = node->version->minorVersion;
+ import->version = node->version->version;
} else if (import->type == QV4::CompiledData::Import::ImportLibrary) {
recordError(node->importIdToken, QCoreApplication::translate("QQmlParser","Library import requires a version"));
return false;
} else {
// For backward compatibility in how the imports are loaded we
- // must otherwise initialize the major and minor version to -1.
- import->majorVersion = -1;
- import->minorVersion = -1;
+ // must otherwise initialize the major and minor version to invalid.
+ import->version = QTypeRevision();
}
import->location.line = node->importToken.startLine;
@@ -834,7 +865,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node)
const QString signalName = node->name.toString();
signal->nameIndex = registerString(signalName);
- QQmlJS::AST::SourceLocation loc = node->typeToken;
+ QQmlJS::SourceLocation loc = node->typeToken;
signal->location.line = loc.startLine;
signal->location.column = loc.startColumn;
@@ -917,11 +948,11 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node)
const QString propName = name.toString();
property->nameIndex = registerString(propName);
- QQmlJS::AST::SourceLocation loc = node->firstSourceLocation();
+ QQmlJS::SourceLocation loc = node->firstSourceLocation();
property->location.line = loc.startLine;
property->location.column = loc.startColumn;
- QQmlJS::AST::SourceLocation errorLocation;
+ QQmlJS::SourceLocation errorLocation;
QString error;
if (illegalNames.contains(propName))
@@ -962,7 +993,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiSourceElement *node)
const int index = _object->functionsAndExpressions->append(foe);
Function *f = New<Function>();
- QQmlJS::AST::SourceLocation loc = funDecl->identifierToken;
+ QQmlJS::SourceLocation loc = funDecl->identifierToken;
f->location.line = loc.startLine;
f->location.column = loc.startColumn;
f->index = index;
@@ -988,6 +1019,14 @@ bool IRBuilder::visit(QQmlJS::AST::UiSourceElement *node)
return false;
}
+bool IRBuilder::visit(AST::UiRequired *ast)
+{
+ auto extraData = New<RequiredPropertyExtraData>();
+ extraData->nameIndex = registerString(ast->name.toString());
+ _object->appendRequiredPropertyExtraData(extraData);
+ return false;
+}
+
QString IRBuilder::asString(QQmlJS::AST::UiQualifiedId *node)
{
QString s;
@@ -1010,32 +1049,25 @@ QStringRef IRBuilder::asStringRef(QQmlJS::AST::Node *node)
return textRefAt(node->firstSourceLocation(), node->lastSourceLocation());
}
-void IRBuilder::extractVersion(const QStringRef &string, int *maj, int *min)
+QTypeRevision IRBuilder::extractVersion(const QStringRef &string)
{
- *maj = -1; *min = -1;
-
- if (!string.isEmpty()) {
-
- int dot = string.indexOf(QLatin1Char('.'));
+ if (string.isEmpty())
+ return QTypeRevision();
- if (dot < 0) {
- *maj = string.toInt();
- *min = 0;
- } else {
- *maj = string.left(dot).toInt();
- *min = string.mid(dot + 1).toInt();
- }
- }
+ const int dot = string.indexOf(QLatin1Char('.'));
+ return (dot < 0)
+ ? QTypeRevision::fromVersion(string.toInt(), 0)
+ : QTypeRevision::fromVersion(string.left(dot).toInt(), string.mid(dot + 1).toInt());
}
-QStringRef IRBuilder::textRefAt(const QQmlJS::AST::SourceLocation &first, const QQmlJS::AST::SourceLocation &last) const
+QStringRef IRBuilder::textRefAt(const QQmlJS::SourceLocation &first, const QQmlJS::SourceLocation &last) const
{
return QStringRef(&sourceCode, first.offset, last.offset + last.length - first.offset);
}
void IRBuilder::setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement, QQmlJS::AST::Node *parentNode)
{
- QQmlJS::AST::SourceLocation loc = statement->firstSourceLocation();
+ QQmlJS::SourceLocation loc = statement->firstSourceLocation();
binding->valueLocation.line = loc.startLine;
binding->valueLocation.column = loc.startColumn;
binding->type = QV4::CompiledData::Binding::Type_Invalid;
@@ -1212,7 +1244,7 @@ void IRBuilder::tryGeneratingTranslationBinding(const QStringRef &base, AST::Arg
void IRBuilder::appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Statement *value, QQmlJS::AST::Node *parentNode)
{
- const QQmlJS::AST::SourceLocation qualifiedNameLocation = name->identifierToken;
+ const QQmlJS::SourceLocation qualifiedNameLocation = name->identifierToken;
Object *object = nullptr;
if (!resolveQualifiedId(&name, &object))
return;
@@ -1227,7 +1259,7 @@ void IRBuilder::appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Sta
void IRBuilder::appendBinding(QQmlJS::AST::UiQualifiedId *name, int objectIndex, bool isOnAssignment)
{
- const QQmlJS::AST::SourceLocation qualifiedNameLocation = name->identifierToken;
+ const QQmlJS::SourceLocation qualifiedNameLocation = name->identifierToken;
Object *object = nullptr;
if (!resolveQualifiedId(&name, &object, isOnAssignment))
return;
@@ -1236,7 +1268,7 @@ void IRBuilder::appendBinding(QQmlJS::AST::UiQualifiedId *name, int objectIndex,
qSwap(_object, object);
}
-void IRBuilder::appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation, const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex,
+void IRBuilder::appendBinding(const QQmlJS::SourceLocation &qualifiedNameLocation, const QQmlJS::SourceLocation &nameLocation, quint32 propertyNameIndex,
QQmlJS::AST::Statement *value, QQmlJS::AST::Node *parentNode)
{
Binding *binding = New<Binding>();
@@ -1252,7 +1284,7 @@ void IRBuilder::appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLo
}
}
-void IRBuilder::appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation, const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex, int objectIndex, bool isListItem, bool isOnAssignment)
+void IRBuilder::appendBinding(const QQmlJS::SourceLocation &qualifiedNameLocation, const QQmlJS::SourceLocation &nameLocation, quint32 propertyNameIndex, int objectIndex, bool isListItem, bool isOnAssignment)
{
if (stringAt(propertyNameIndex) == QLatin1String("id")) {
recordError(nameLocation, tr("Invalid component id specification"));
@@ -1301,7 +1333,7 @@ bool IRBuilder::appendAlias(QQmlJS::AST::UiPublicMember *node)
const QString propName = node->name.toString();
alias->nameIndex = registerString(propName);
- QQmlJS::AST::SourceLocation loc = node->firstSourceLocation();
+ QQmlJS::SourceLocation loc = node->firstSourceLocation();
alias->location.line = loc.startLine;
alias->location.column = loc.startColumn;
@@ -1310,7 +1342,7 @@ bool IRBuilder::appendAlias(QQmlJS::AST::UiPublicMember *node)
if (!node->statement && !node->binding)
COMPILE_EXCEPTION(loc, tr("No property alias location"));
- QQmlJS::AST::SourceLocation rhsLoc;
+ QQmlJS::SourceLocation rhsLoc;
if (node->binding)
rhsLoc = node->binding->firstSourceLocation();
else if (node->statement)
@@ -1345,7 +1377,7 @@ bool IRBuilder::appendAlias(QQmlJS::AST::UiPublicMember *node)
propertyValue += QLatin1Char('.') + aliasReference.at(2);
alias->propertyNameIndex = registerString(propertyValue);
- QQmlJS::AST::SourceLocation errorLocation;
+ QQmlJS::SourceLocation errorLocation;
QString error;
if (illegalNames.contains(propName))
@@ -1371,9 +1403,9 @@ Object *IRBuilder::bindingsTarget() const
return _object;
}
-bool IRBuilder::setId(const QQmlJS::AST::SourceLocation &idLocation, QQmlJS::AST::Statement *value)
+bool IRBuilder::setId(const QQmlJS::SourceLocation &idLocation, QQmlJS::AST::Statement *value)
{
- QQmlJS::AST::SourceLocation loc = value->firstSourceLocation();
+ QQmlJS::SourceLocation loc = value->firstSourceLocation();
QStringRef str;
QQmlJS::AST::Node *node = value;
@@ -1475,7 +1507,7 @@ bool IRBuilder::resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, O
binding->type = QV4::CompiledData::Binding::Type_GroupProperty;
int objIndex = 0;
- if (!defineQMLObject(&objIndex, nullptr, QQmlJS::AST::SourceLocation(), nullptr, nullptr))
+ if (!defineQMLObject(&objIndex, nullptr, QQmlJS::SourceLocation(), nullptr, nullptr))
return false;
binding->value.objectIndex = objIndex;
@@ -1498,11 +1530,10 @@ bool IRBuilder::resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, O
return true;
}
-void IRBuilder::recordError(const QQmlJS::AST::SourceLocation &location, const QString &description)
+void IRBuilder::recordError(const QQmlJS::SourceLocation &location, const QString &description)
{
QQmlJS::DiagnosticMessage error;
- error.line = location.startLine;
- error.column = location.startColumn;
+ error.loc = location;
error.message = description;
errors << error;
}
@@ -1590,7 +1621,7 @@ void QmlUnitGenerator::generate(Document &output, const QV4::CompiledData::Depen
uint nextOffset = objectOffset + objectOffsetTableSize;
for (Object *o : qAsConst(output.objects)) {
objectOffsets.insert(o, nextOffset);
- nextOffset += QV4::CompiledData::Object::calculateSizeExcludingSignalsAndEnums(o->functionCount(), o->propertyCount(), o->aliasCount(), o->enumCount(), o->signalCount(), o->bindingCount(), o->namedObjectsInComponent.size(), o->inlineComponentCount());
+ nextOffset += QV4::CompiledData::Object::calculateSizeExcludingSignalsAndEnums(o->functionCount(), o->propertyCount(), o->aliasCount(), o->enumCount(), o->signalCount(), o->bindingCount(), o->namedObjectsInComponent.size(), o->inlineComponentCount(), o->requiredPropertyExtraDataCount());
int signalTableSize = 0;
for (const Signal *s = o->firstSignal(); s; s = s->next)
@@ -1673,6 +1704,10 @@ void QmlUnitGenerator::generate(Document &output, const QV4::CompiledData::Depen
objectToWrite->offsetToInlineComponents = nextOffset;
nextOffset += objectToWrite->nInlineComponents * sizeof (QV4::CompiledData::InlineComponent);
+ objectToWrite->nRequiredPropertyExtraData = o->requiredPropertyExtraDataCount();
+ objectToWrite->offsetToRequiredPropertyExtraData = nextOffset;
+ nextOffset += objectToWrite->nRequiredPropertyExtraData * sizeof(QV4::CompiledData::RequiredPropertyExtraData);
+
quint32_le *functionsTable = reinterpret_cast<quint32_le *>(objectPtr + objectToWrite->offsetToFunctions);
for (const Function *f = o->firstFunction(); f; f = f->next)
*functionsTable++ = o->runtimeFunctionIndices.at(f->index);
@@ -1752,6 +1787,14 @@ void QmlUnitGenerator::generate(Document &output, const QV4::CompiledData::Depen
*icToWrite = *ic;
inlineComponentPtr += sizeof(QV4::CompiledData::InlineComponent);
}
+
+ char *requiredPropertyExtraDataPtr = objectPtr + objectToWrite->offsetToRequiredPropertyExtraData;
+ for (auto it = o->requiredPropertyExtraDataBegin(); it != o->requiredPropertyExtraDataEnd(); ++it) {
+ const RequiredPropertyExtraData *extraData = it.ptr;
+ QV4::CompiledData::RequiredPropertyExtraData *extraDataToWrite = reinterpret_cast<QV4::CompiledData::RequiredPropertyExtraData*>(requiredPropertyExtraDataPtr);
+ *extraDataToWrite = *extraData;
+ requiredPropertyExtraDataPtr += sizeof(QV4::CompiledData::RequiredPropertyExtraData);
+ }
}
if (!output.javaScriptCompilationUnit.data) {
diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h
index d4f2eb8dd4..1f2c11f7f3 100644
--- a/src/qml/compiler/qqmlirbuilder_p.h
+++ b/src/qml/compiler/qqmlirbuilder_p.h
@@ -285,6 +285,11 @@ struct Alias : public QV4::CompiledData::Alias
Alias *next;
};
+struct RequiredPropertyExtraData : public QV4::CompiledData::RequiredPropertyExtraData
+{
+ RequiredPropertyExtraData *next;
+};
+
struct Function
{
QV4::CompiledData::Location location;
@@ -341,6 +346,9 @@ public:
int functionCount() const { return functions->count; }
const InlineComponent *inlineComponent() const { return inlineComponents->first; }
int inlineComponentCount() const { return inlineComponents->count; }
+ const RequiredPropertyExtraData *requiredPropertyExtraData() const {return requiredPropertyExtraDatas->first; }
+ int requiredPropertyExtraDataCount() const { return requiredPropertyExtraDatas->count; }
+ void simplifyRequiredProperties();
PoolList<Binding>::Iterator bindingsBegin() const { return bindings->begin(); }
PoolList<Binding>::Iterator bindingsEnd() const { return bindings->end(); }
@@ -356,19 +364,22 @@ public:
PoolList<Function>::Iterator functionsEnd() const { return functions->end(); }
PoolList<InlineComponent>::Iterator inlineComponentsBegin() const { return inlineComponents->begin(); }
PoolList<InlineComponent>::Iterator inlineComponentsEnd() const { return inlineComponents->end(); }
+ PoolList<RequiredPropertyExtraData>::Iterator requiredPropertyExtraDataBegin() const {return requiredPropertyExtraDatas->begin(); }
+ PoolList<RequiredPropertyExtraData>::Iterator requiredPropertyExtraDataEnd() const {return requiredPropertyExtraDatas->end(); }
// If set, then declarations for this object (and init bindings for these) should go into the
// specified object. Used for declarations inside group properties.
Object *declarationsOverride;
- void init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex, const QQmlJS::AST::SourceLocation &location = QQmlJS::AST::SourceLocation());
+ void init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex, const QQmlJS::SourceLocation &location = QQmlJS::SourceLocation());
QString appendEnum(Enum *enumeration);
QString appendSignal(Signal *signal);
- QString appendProperty(Property *prop, const QString &propertyName, bool isDefaultProperty, const QQmlJS::AST::SourceLocation &defaultToken, QQmlJS::AST::SourceLocation *errorLocation);
- QString appendAlias(Alias *prop, const QString &aliasName, bool isDefaultProperty, const QQmlJS::AST::SourceLocation &defaultToken, QQmlJS::AST::SourceLocation *errorLocation);
+ QString appendProperty(Property *prop, const QString &propertyName, bool isDefaultProperty, const QQmlJS::SourceLocation &defaultToken, QQmlJS::SourceLocation *errorLocation);
+ QString appendAlias(Alias *prop, const QString &aliasName, bool isDefaultProperty, const QQmlJS::SourceLocation &defaultToken, QQmlJS::SourceLocation *errorLocation);
void appendFunction(QmlIR::Function *f);
void appendInlineComponent(InlineComponent *ic);
+ void appendRequiredPropertyExtraData(RequiredPropertyExtraData *extraData);
QString appendBinding(Binding *b, bool isListBinding);
Binding *findBinding(quint32 nameIndex) const;
@@ -393,6 +404,7 @@ private:
PoolList<Binding> *bindings;
PoolList<Function> *functions;
PoolList<InlineComponent> *inlineComponents;
+ PoolList<RequiredPropertyExtraData> *requiredPropertyExtraDatas;
};
struct Q_QMLCOMPILER_PRIVATE_EXPORT Pragma
@@ -469,27 +481,28 @@ public:
bool visit(QQmlJS::AST::UiPublicMember *ast) override;
bool visit(QQmlJS::AST::UiScriptBinding *ast) override;
bool visit(QQmlJS::AST::UiSourceElement *ast) override;
+ bool visit(QQmlJS::AST::UiRequired *ast) override;
void throwRecursionDepthError() override
{
- recordError(QQmlJS::AST::SourceLocation(),
+ recordError(QQmlJS::SourceLocation(),
QStringLiteral("Maximum statement or expression depth exceeded"));
}
void accept(QQmlJS::AST::Node *node);
// returns index in _objects
- bool defineQMLObject(int *objectIndex, QQmlJS::AST::UiQualifiedId *qualifiedTypeNameId, const QQmlJS::AST::SourceLocation &location, QQmlJS::AST::UiObjectInitializer *initializer, Object *declarationsOverride = nullptr);
+ bool defineQMLObject(int *objectIndex, QQmlJS::AST::UiQualifiedId *qualifiedTypeNameId, const QQmlJS::SourceLocation &location, QQmlJS::AST::UiObjectInitializer *initializer, Object *declarationsOverride = nullptr);
bool defineQMLObject(int *objectIndex, QQmlJS::AST::UiObjectDefinition *node, Object *declarationsOverride = nullptr)
{ return defineQMLObject(objectIndex, node->qualifiedTypeNameId, node->qualifiedTypeNameId->firstSourceLocation(), node->initializer, declarationsOverride); }
static QString asString(QQmlJS::AST::UiQualifiedId *node);
QStringRef asStringRef(QQmlJS::AST::Node *node);
- static void extractVersion(const QStringRef &string, int *maj, int *min);
- QStringRef textRefAt(const QQmlJS::AST::SourceLocation &loc) const
+ static QTypeRevision extractVersion(const QStringRef &string);
+ QStringRef textRefAt(const QQmlJS::SourceLocation &loc) const
{ return QStringRef(&sourceCode, loc.offset, loc.length); }
- QStringRef textRefAt(const QQmlJS::AST::SourceLocation &first,
- const QQmlJS::AST::SourceLocation &last) const;
+ QStringRef textRefAt(const QQmlJS::SourceLocation &first,
+ const QQmlJS::SourceLocation &last) const;
void setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement,
QQmlJS::AST::Node *parentNode);
@@ -498,24 +511,24 @@ public:
void appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Statement *value,
QQmlJS::AST::Node *parentNode);
void appendBinding(QQmlJS::AST::UiQualifiedId *name, int objectIndex, bool isOnAssignment = false);
- void appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation,
- const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex,
+ void appendBinding(const QQmlJS::SourceLocation &qualifiedNameLocation,
+ const QQmlJS::SourceLocation &nameLocation, quint32 propertyNameIndex,
QQmlJS::AST::Statement *value, QQmlJS::AST::Node *parentNode);
- void appendBinding(const QQmlJS::AST::SourceLocation &qualifiedNameLocation,
- const QQmlJS::AST::SourceLocation &nameLocation, quint32 propertyNameIndex,
+ void appendBinding(const QQmlJS::SourceLocation &qualifiedNameLocation,
+ const QQmlJS::SourceLocation &nameLocation, quint32 propertyNameIndex,
int objectIndex, bool isListItem = false, bool isOnAssignment = false);
bool appendAlias(QQmlJS::AST::UiPublicMember *node);
Object *bindingsTarget() const;
- bool setId(const QQmlJS::AST::SourceLocation &idLocation, QQmlJS::AST::Statement *value);
+ bool setId(const QQmlJS::SourceLocation &idLocation, QQmlJS::AST::Statement *value);
// resolves qualified name (font.pixelSize for example) and returns the last name along
// with the object any right-hand-side of a binding should apply to.
bool resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, Object **object, bool onAssignment = false);
- void recordError(const QQmlJS::AST::SourceLocation &location, const QString &description);
+ void recordError(const QQmlJS::SourceLocation &location, const QString &description);
quint32 registerString(const QString &str) const { return jsGenerator->registerString(str); }
template <typename _Tp> _Tp *New() { return pool->New<_Tp>(); }
@@ -525,7 +538,7 @@ public:
static bool isStatementNodeScript(QQmlJS::AST::Statement *statement);
static bool isRedundantNullInitializerForPropertyDeclaration(Property *property, QQmlJS::AST::Statement *statement);
- QString sanityCheckFunctionNames(Object *obj, const QSet<QString> &illegalNames, QQmlJS::AST::SourceLocation *errorLocation);
+ QString sanityCheckFunctionNames(Object *obj, const QSet<QString> &illegalNames, QQmlJS::SourceLocation *errorLocation);
QList<QQmlJS::DiagnosticMessage> errors;
diff --git a/src/qml/compiler/qv4bytecodegenerator.cpp b/src/qml/compiler/qv4bytecodegenerator.cpp
index 7df1614ffe..f8a41edb6a 100644
--- a/src/qml/compiler/qv4bytecodegenerator.cpp
+++ b/src/qml/compiler/qv4bytecodegenerator.cpp
@@ -45,7 +45,7 @@ QT_USE_NAMESPACE
using namespace QV4;
using namespace Moth;
-void BytecodeGenerator::setLocation(const QQmlJS::AST::SourceLocation &loc)
+void BytecodeGenerator::setLocation(const QQmlJS::SourceLocation &loc)
{
currentLine = static_cast<int>(loc.startLine);
}
diff --git a/src/qml/compiler/qv4bytecodegenerator_p.h b/src/qml/compiler/qv4bytecodegenerator_p.h
index 8c509dd9f1..1895a34a68 100644
--- a/src/qml/compiler/qv4bytecodegenerator_p.h
+++ b/src/qml/compiler/qv4bytecodegenerator_p.h
@@ -56,10 +56,8 @@
QT_BEGIN_NAMESPACE
namespace QQmlJS {
-namespace AST {
class SourceLocation;
}
-}
namespace QV4 {
@@ -244,7 +242,7 @@ QT_WARNING_POP
- void setLocation(const QQmlJS::AST::SourceLocation &loc);
+ void setLocation(const QQmlJS::SourceLocation &loc);
ExceptionHandler *exceptionHandler() const {
return currentExceptionHandler;
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index d61456f38d..4588690307 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -3821,8 +3821,7 @@ void Codegen::throwError(ErrorType errorType, const SourceLocation &loc, const Q
_errorType = errorType;
_error.message = detail;
- _error.line = loc.startLine;
- _error.column = loc.startColumn;
+ _error.loc = loc;
}
void Codegen::throwSyntaxError(const SourceLocation &loc, const QString &detail)
@@ -4105,7 +4104,7 @@ Codegen::Reference Codegen::Reference::asLValue() const
case Accumulator:
Q_UNREACHABLE();
case Super:
- codegen->throwSyntaxError(AST::SourceLocation(), QStringLiteral("Super lvalues not implemented."));
+ codegen->throwSyntaxError(SourceLocation(), QStringLiteral("Super lvalues not implemented."));
return *this;
case Member:
if (!propertyBase.isStackSlot()) {
diff --git a/src/qml/compiler/qv4codegen_p.h b/src/qml/compiler/qv4codegen_p.h
index 82a4fc3289..255698d790 100644
--- a/src/qml/compiler/qv4codegen_p.h
+++ b/src/qml/compiler/qv4codegen_p.h
@@ -661,12 +661,12 @@ protected:
bool visit(QQmlJS::AST::UiSourceElement *ast) override;
bool throwSyntaxErrorOnEvalOrArgumentsInStrictMode(const Reference &r,
- const QQmlJS::AST::SourceLocation &loc);
- virtual void throwSyntaxError(const QQmlJS::AST::SourceLocation &loc, const QString &detail);
- virtual void throwReferenceError(const QQmlJS::AST::SourceLocation &loc, const QString &detail);
+ const QQmlJS::SourceLocation &loc);
+ virtual void throwSyntaxError(const QQmlJS::SourceLocation &loc, const QString &detail);
+ virtual void throwReferenceError(const QQmlJS::SourceLocation &loc, const QString &detail);
void throwRecursionDepthError() override
{
- throwSyntaxError(QQmlJS::AST::SourceLocation(),
+ throwSyntaxError(QQmlJS::SourceLocation(),
QStringLiteral("Maximum statement or expression depth exceeded"));
}
@@ -700,7 +700,7 @@ public:
Reference referenceForName(
const QString &name, bool lhs,
- const QQmlJS::AST::SourceLocation &accessLocation = QQmlJS::AST::SourceLocation());
+ const QQmlJS::SourceLocation &accessLocation = QQmlJS::SourceLocation());
QV4::CompiledData::CompilationUnit generateCompilationUnit(bool generateUnitData = true);
static QV4::CompiledData::CompilationUnit compileModule(
@@ -810,7 +810,7 @@ protected:
private:
VolatileMemoryLocations scanVolatileMemoryLocations(QQmlJS::AST::Node *ast);
void handleConstruct(const Reference &base, QQmlJS::AST::ArgumentList *args);
- void throwError(ErrorType errorType, const QQmlJS::AST::SourceLocation &loc,
+ void throwError(ErrorType errorType, const QQmlJS::SourceLocation &loc,
const QString &detail);
};
diff --git a/src/qml/compiler/qv4compilercontext.cpp b/src/qml/compiler/qv4compilercontext.cpp
index 88837b0feb..872fc94dc9 100644
--- a/src/qml/compiler/qv4compilercontext.cpp
+++ b/src/qml/compiler/qv4compilercontext.cpp
@@ -45,6 +45,7 @@ QT_USE_NAMESPACE
using namespace QV4;
using namespace QV4::Compiler;
using namespace QQmlJS::AST;
+using namespace QQmlJS;
QT_BEGIN_NAMESPACE
@@ -86,7 +87,7 @@ bool Context::Member::requiresTDZCheck(const SourceLocation &accessLocation, boo
}
bool Context::addLocalVar(const QString &name, Context::MemberType type, VariableScope scope, FunctionExpression *function,
- const QQmlJS::AST::SourceLocation &endOfInitializer)
+ const QQmlJS::SourceLocation &endOfInitializer)
{
// ### can this happen?
if (name.isEmpty())
@@ -122,7 +123,7 @@ bool Context::addLocalVar(const QString &name, Context::MemberType type, Variabl
return true;
}
-Context::ResolvedName Context::resolveName(const QString &name, const QQmlJS::AST::SourceLocation &accessLocation)
+Context::ResolvedName Context::resolveName(const QString &name, const QQmlJS::SourceLocation &accessLocation)
{
int scope = 0;
Context *c = this;
diff --git a/src/qml/compiler/qv4compilercontext_p.h b/src/qml/compiler/qv4compilercontext_p.h
index 8c124ac409..4a14009c35 100644
--- a/src/qml/compiler/qv4compilercontext_p.h
+++ b/src/qml/compiler/qv4compilercontext_p.h
@@ -183,10 +183,10 @@ struct Context {
QQmlJS::AST::VariableScope scope = QQmlJS::AST::VariableScope::Var;
mutable bool canEscape = false;
QQmlJS::AST::FunctionExpression *function = nullptr;
- QQmlJS::AST::SourceLocation endOfInitializerLocation;
+ QQmlJS::SourceLocation endOfInitializerLocation;
bool isLexicallyScoped() const { return this->scope != QQmlJS::AST::VariableScope::Var; }
- bool requiresTDZCheck(const QQmlJS::AST::SourceLocation &accessLocation, bool accessAcrossContextBoundaries) const;
+ bool requiresTDZCheck(const QQmlJS::SourceLocation &accessLocation, bool accessAcrossContextBoundaries) const;
};
typedef QMap<QString, Member> MemberMap;
@@ -227,7 +227,7 @@ struct Context {
bool isWithBlock = false;
bool isCatchBlock = false;
QString caughtVariable;
- QQmlJS::AST::SourceLocation lastBlockInitializerLocation;
+ QQmlJS::SourceLocation lastBlockInitializerLocation;
enum UsesArgumentsObject {
ArgumentsObjectUnknown,
@@ -331,7 +331,7 @@ struct Context {
}
bool addLocalVar(const QString &name, MemberType contextType, QQmlJS::AST::VariableScope scope, QQmlJS::AST::FunctionExpression *function = nullptr,
- const QQmlJS::AST::SourceLocation &endOfInitializer = QQmlJS::AST::SourceLocation());
+ const QQmlJS::SourceLocation &endOfInitializer = QQmlJS::SourceLocation());
struct ResolvedName {
enum Type {
@@ -348,10 +348,10 @@ struct Context {
bool requiresTDZCheck = false;
int scope = -1;
int index = -1;
- QQmlJS::AST::SourceLocation endOfDeclarationLocation;
+ QQmlJS::SourceLocation endOfDeclarationLocation;
bool isValid() const { return type != Unresolved; }
};
- ResolvedName resolveName(const QString &name, const QQmlJS::AST::SourceLocation &accessLocation);
+ ResolvedName resolveName(const QString &name, const QQmlJS::SourceLocation &accessLocation);
void emitBlockHeader(Compiler::Codegen *codegen);
void emitBlockFooter(Compiler::Codegen *codegen);
diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp
index ab0ebf3d4b..a1ddee8234 100644
--- a/src/qml/compiler/qv4compilerscanfunctions.cpp
+++ b/src/qml/compiler/qv4compilerscanfunctions.cpp
@@ -55,7 +55,7 @@ using namespace QV4::Compiler;
using namespace QQmlJS;
using namespace QQmlJS::AST;
-static CompiledData::Location location(const QQmlJS::AST::SourceLocation &astLocation)
+static CompiledData::Location location(const QQmlJS::SourceLocation &astLocation)
{
CompiledData::Location target;
target.line = astLocation.startLine;
@@ -129,7 +129,7 @@ void ScanFunctions::checkDirectivePrologue(StatementList *ast)
}
}
-void ScanFunctions::checkName(const QStringRef &name, const SourceLocation &loc)
+void ScanFunctions::checkName(const QStringRef &name, const QQmlJS::SourceLocation &loc)
{
if (_context->isStrict) {
if (name == QLatin1String("implements")
@@ -330,7 +330,7 @@ bool ScanFunctions::visit(PatternElement *ast)
BoundNames names;
ast->boundNames(&names);
- QQmlJS::AST::SourceLocation lastInitializerLocation = ast->lastSourceLocation();
+ QQmlJS::SourceLocation lastInitializerLocation = ast->lastSourceLocation();
if (_context->lastBlockInitializerLocation.isValid())
lastInitializerLocation = _context->lastBlockInitializerLocation;
diff --git a/src/qml/compiler/qv4compilerscanfunctions_p.h b/src/qml/compiler/qv4compilerscanfunctions_p.h
index 2de80eac44..e39aa2454e 100644
--- a/src/qml/compiler/qv4compilerscanfunctions_p.h
+++ b/src/qml/compiler/qv4compilerscanfunctions_p.h
@@ -97,7 +97,7 @@ protected:
void checkDirectivePrologue(QQmlJS::AST::StatementList *ast);
- void checkName(const QStringRef &name, const QQmlJS::AST::SourceLocation &loc);
+ void checkName(const QStringRef &name, const QQmlJS::SourceLocation &loc);
bool visit(QQmlJS::AST::Program *ast) override;
void endVisit(QQmlJS::AST::Program *) override;
diff --git a/src/qml/debugger/qqmldebugserviceinterfaces.cpp b/src/qml/debugger/qqmldebugserviceinterfaces.cpp
index 76205c7760..3df1a21bda 100644
--- a/src/qml/debugger/qqmldebugserviceinterfaces.cpp
+++ b/src/qml/debugger/qqmldebugserviceinterfaces.cpp
@@ -48,6 +48,7 @@ const QString QQmlProfilerService::s_key = QStringLiteral("CanvasFrameRate");
const QString QDebugMessageService::s_key = QStringLiteral("DebugMessages");
const QString QQmlEngineControlService::s_key = QStringLiteral("EngineControl");
const QString QQmlNativeDebugService::s_key = QStringLiteral("NativeQmlDebugger");
+const QString QQmlDebugTranslationService::s_key = QStringLiteral("DebugTranslation");
QT_END_NAMESPACE
diff --git a/src/qml/debugger/qqmldebugserviceinterfaces_p.h b/src/qml/debugger/qqmldebugserviceinterfaces_p.h
index 01693aee24..b259e047a1 100644
--- a/src/qml/debugger/qqmldebugserviceinterfaces_p.h
+++ b/src/qml/debugger/qqmldebugserviceinterfaces_p.h
@@ -65,6 +65,7 @@ QT_BEGIN_NAMESPACE
class QWindow;
class QQuickWindow;
+class QQmlTranslationBinding;
#if !QT_CONFIG(qml_debug)
@@ -103,6 +104,11 @@ public:
class QDebugMessageService {};
class QQmlEngineControlService {};
class QQmlNativeDebugService {};
+class QQmlDebugTranslationService {
+public:
+ virtual QString foundElidedText(QObject *, const QString &, const QString &) {return {};}
+ virtual void foundTranslationBinding(QQmlTranslationBinding *, QObject *, QQmlContextData *) {}
+};
#else
@@ -162,6 +168,22 @@ protected:
QQmlBoundSignal *nextSignal(QQmlBoundSignal *prev) { return prev->m_nextSignal; }
};
+class Q_QML_PRIVATE_EXPORT QQmlDebugTranslationService : public QQmlDebugService
+{
+ Q_OBJECT
+public:
+ static const QString s_key;
+
+ virtual QString foundElidedText(QObject *qQuickTextObject, const QString &layoutText, const QString &elideText) = 0;
+ virtual void foundTranslationBinding(QQmlTranslationBinding *binding, QObject *scopeObject, QQmlContextData *contextData) = 0;
+protected:
+ friend class QQmlDebugConnector;
+
+ QQmlDebugTranslationService(float version, QObject *parent = nullptr) :
+ QQmlDebugService(s_key, version, parent) {}
+
+};
+
class Q_QML_PRIVATE_EXPORT QQmlInspectorService : public QQmlDebugService
{
Q_OBJECT
diff --git a/src/qml/doc/snippets/code/backend/backend.h b/src/qml/doc/snippets/code/backend/backend.h
index fa7ce9eb86..6c64236bc7 100644
--- a/src/qml/doc/snippets/code/backend/backend.h
+++ b/src/qml/doc/snippets/code/backend/backend.h
@@ -53,11 +53,13 @@
#include <QObject>
#include <QString>
+#include <qqml.h>
class BackEnd : public QObject
{
Q_OBJECT
Q_PROPERTY(QString userName READ userName WRITE setUserName NOTIFY userNameChanged)
+ QML_ELEMENT
public:
explicit BackEnd(QObject *parent = nullptr);
diff --git a/src/qml/doc/snippets/code/backend/backend.pro b/src/qml/doc/snippets/code/backend/backend.pro
new file mode 100644
index 0000000000..8bd2422718
--- /dev/null
+++ b/src/qml/doc/snippets/code/backend/backend.pro
@@ -0,0 +1,17 @@
+QT += qml
+
+#![registration]
+CONFIG += qmltypes
+QML_IMPORT_NAME = io.qt.examples.backend
+QML_IMPORT_MAJOR_VERSION = 1
+#![registration]
+
+HEADERS += \
+ backend.h
+
+SOURCES += \
+ backend.cpp \
+ main.cpp
+
+RESOURCES += \
+ main.qml
diff --git a/src/qml/doc/snippets/code/backend/main.cpp b/src/qml/doc/snippets/code/backend/main.cpp
index 91a012dfda..52fcb38621 100644
--- a/src/qml/doc/snippets/code/backend/main.cpp
+++ b/src/qml/doc/snippets/code/backend/main.cpp
@@ -51,14 +51,10 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
-#include "backend.h"
-
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
- qmlRegisterType<BackEnd>("io.qt.examples.backend", 1, 0, "BackEnd");
-
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
diff --git a/src/qml/doc/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp b/src/qml/doc/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp
index d74cc13d04..b41a9b4dff 100644
--- a/src/qml/doc/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp
+++ b/src/qml/doc/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp
@@ -51,84 +51,102 @@
#include "avatarExample.h"
#include <QQmlEngine>
#include <QQmlComponent>
+#include <QGuiApplication>
-void registerTypes()
+struct Expectations
{
-//![0]
- qmlRegisterType<AvatarExample>("Qt.example", 1, 0, "AvatarExample");
-//![0]
-}
+ QQmlEngine engine;
-void expectOne()
-{
+ void expectOne()
+ {
//![1]
-QQmlComponent component(&engine, "exampleOne.qml");
-QObject *object = component.create();
-// The scarce resource will have been released automatically
-// by this point, after the binding expression was evaluated.
-delete object;
+ QQmlComponent component(&engine, "qrc:/exampleOne.qml");
+ QObject *object = component.create();
+ // The scarce resource will have been released automatically
+ // by this point, after the binding expression was evaluated.
+ bool expectedResult = (object->property("avatarWidth").toInt() == 100);
+ delete object;
//![1]
-}
+ Q_ASSERT(expectedResult);
+ }
-void expectTwo()
-{
+ void expectTwo()
+ {
//![2]
-QQmlComponent component(&engine, "exampleTwo.qml");
-QObject *object = component.create();
-// The scarce resource will not have been released automatically
-// after the binding expression was evaluated.
-// Since the scarce resource was not released explicitly prior
-// to the binding expression being evaluated, we get:
-bool expectedResult = (object->property("avatar").isValid() == true);
-delete object;
+ QQmlComponent component(&engine, "qrc:/exampleTwo.qml");
+ QObject *object = component.create();
+ // The scarce resource will not have been released automatically
+ // after the binding expression was evaluated.
+ // Since the scarce resource was not released explicitly prior
+ // to the binding expression being evaluated, we get:
+ bool expectedResult = (object->property("avatar").isValid() == true);
+ delete object;
//![2]
-}
+ Q_ASSERT(expectedResult);
+ }
-void expectThree()
-{
+ void expectThree()
+ {
//![3]
-QQmlComponent component(&engine, "exampleThree.qml");
-QObject *object = component.create();
-// The resource was preserved explicitly during evaluation of the
-// JavaScript expression. Thus, during property assignment, the
-// scarce resource was still valid, and so we get:
-bool expectedResult = (object->property("avatar").isValid() == true);
-// The scarce resource will not be released until all references to
-// the resource are released, and the JavaScript garbage collector runs.
-delete object;
+ QQmlComponent component(&engine, "qrc:/exampleThree.qml");
+ QObject *object = component.create();
+ // The resource was preserved explicitly during evaluation of the
+ // JavaScript expression. Thus, during property assignment, the
+ // scarce resource was still valid, and so we get:
+ bool expectedResult = (object->property("avatar").isValid() == true);
+ // The scarce resource will not be released until all references to
+ // the resource are released, and the JavaScript garbage collector runs.
+ delete object;
//![3]
-}
+ Q_ASSERT(expectedResult);
+ }
-void expectFour()
-{
+ void expectFour()
+ {
//![4]
-QQmlComponent component(&engine, "exampleFour.qml");
-QObject *object = component.create();
-// The scarce resource was explicitly preserved by the client during
-// the importAvatar() function, and so the scarce resource
-// remains valid until the explicit call to releaseAvatar(). As such,
-// we get the expected results:
-bool expectedResultOne = (object->property("avatarOne").isValid() == true);
-bool expectedResultTwo = (object->property("avatarTwo").isValid() == false);
-// Because the scarce resource referenced by avatarTwo was released explicitly,
-// it will no longer be consuming any system resources (beyond what a normal
-// JS Object would; that small overhead will exist until the JS GC runs, as per
-// any other JavaScript object).
-delete object;
+ QQmlComponent component(&engine, "qrc:/exampleFour.qml");
+ QObject *object = component.create();
+ // The scarce resource was explicitly preserved by the client during
+ // the importAvatar() function, and so the scarce resource
+ // remains valid until the explicit call to releaseAvatar(). As such,
+ // we get the expected results:
+ bool expectedResultOne = (object->property("avatarOne").isValid() == true);
+ bool expectedResultTwo = (object->property("avatarTwo").isValid() == false);
+ // Because the scarce resource referenced by avatarTwo was released explicitly,
+ // it will no longer be consuming any system resources (beyond what a normal
+ // JS Object would; that small overhead will exist until the JS GC runs, as per
+ // any other JavaScript object).
+ delete object;
//![4]
-}
+ Q_ASSERT(expectedResultOne);
+ Q_ASSERT(expectedResultTwo);
+ }
-void expectFive()
-{
+ void expectFive()
+ {
//![5]
-QQmlComponent component(&engine, "exampleFive.qml");
-QObject *object = component.create();
-// We have the expected results:
-bool expectedResultOne = (object->property("avatarOne").isValid() == false);
-bool expectedResultTwo = (object->property("avatarTwo").isValid() == false);
-// Because although only avatarTwo was explicitly released,
-// avatarOne and avatarTwo were referencing the same
-// scarce resource.
-delete object;
+ QQmlComponent component(&engine, "qrc:/exampleFive.qml");
+ QObject *object = component.create();
+ // We have the expected results:
+ bool expectedResultOne = (object->property("avatarOne").isValid() == false);
+ bool expectedResultTwo = (object->property("avatarTwo").isValid() == false);
+ // Because although only avatarTwo was explicitly released,
+ // avatarOne and avatarTwo were referencing the same
+ // scarce resource.
+ delete object;
//![5]
+ Q_ASSERT(expectedResultOne);
+ Q_ASSERT(expectedResultTwo);
+ }
+};
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+ Expectations expectations;
+ expectations.expectOne();
+ expectations.expectTwo();
+ expectations.expectThree();
+ expectations.expectFour();
+ expectations.expectFive();
}
diff --git a/src/qml/doc/snippets/qml/integrating-javascript/scarceresources/avatarExample.h b/src/qml/doc/snippets/qml/integrating-javascript/scarceresources/avatarExample.h
index fb9e238512..1acc3a1c2f 100644
--- a/src/qml/doc/snippets/qml/integrating-javascript/scarceresources/avatarExample.h
+++ b/src/qml/doc/snippets/qml/integrating-javascript/scarceresources/avatarExample.h
@@ -53,6 +53,7 @@
#include <QObject>
#include <QPixmap>
+#include <qqml.h>
//![0]
// avatarExample.h
@@ -60,6 +61,8 @@ class AvatarExample : public QObject
{
Q_OBJECT
Q_PROPERTY(QPixmap avatar READ avatar WRITE setAvatar NOTIFY avatarChanged)
+ QML_ELEMENT
+
public:
AvatarExample(QObject *parent = 0)
: QObject(parent), m_value(100, 100)
diff --git a/src/qml/doc/snippets/qml/integrating-javascript/scarceresources/scarceresources.pro b/src/qml/doc/snippets/qml/integrating-javascript/scarceresources/scarceresources.pro
new file mode 100644
index 0000000000..d88f8f574c
--- /dev/null
+++ b/src/qml/doc/snippets/qml/integrating-javascript/scarceresources/scarceresources.pro
@@ -0,0 +1,22 @@
+QT += qml gui
+
+#![0]
+CONFIG += qmltypes
+QML_IMPORT_NAME = Qt.example
+QML_IMPORT_MAJOR_VERSION = 1
+#![0]
+
+RESOURCES += \
+ exampleFive.qml \
+ exampleFour.js \
+ exampleFour.qml \
+ exampleOne.qml \
+ exampleThree.js \
+ exampleThree.qml \
+ exampleTwo.qml
+
+HEADERS += \
+ avatarExample.h
+
+SOURCES += \
+ avatarExample.cpp
diff --git a/src/qml/doc/snippets/qml/qml-documents/A.qml b/src/qml/doc/snippets/qml/qml-documents/A.qml
new file mode 100644
index 0000000000..83c59dc5d7
--- /dev/null
+++ b/src/qml/doc/snippets/qml/qml-documents/A.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//! [document]
+// A.qml
+import QtQuick 2.15
+
+Item {
+ id: root
+ property string message: "From A"
+ component MyInlineComponent : Item {
+ Component.onCompleted: console.log(root.message)
+ }
+}
+//! [document]
diff --git a/src/qml/doc/snippets/qml/qml-documents/B.qml b/src/qml/doc/snippets/qml/qml-documents/B.qml
new file mode 100644
index 0000000000..5e603d50e0
--- /dev/null
+++ b/src/qml/doc/snippets/qml/qml-documents/B.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [document]
+// B.qml
+import QtQuick 2.15
+
+Item {
+ A.MyInlineComponent {}
+}
+//! [document]
diff --git a/src/qml/doc/snippets/qml/qml-documents/Images.qml b/src/qml/doc/snippets/qml/qml-documents/Images.qml
new file mode 100644
index 0000000000..fc9fa60282
--- /dev/null
+++ b/src/qml/doc/snippets/qml/qml-documents/Images.qml
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//! [document]
+// Images.qml
+import QtQuick 2.15
+
+Item {
+ component LabeledImage: Column {
+ property alias source: image.source
+ property alias caption: text.text
+
+ Image {
+ id: image
+ width: 50
+ height: 50
+ }
+ Text {
+ id: text
+ font.bold: true
+ }
+ }
+
+ Row {
+ LabeledImage {
+ id: before
+ source: "before.png"
+ caption: "Before"
+ }
+ LabeledImage {
+ id: after
+ source: "after.png"
+ caption: "After"
+ }
+ }
+ property LabeledImage selectedImage: before
+}
+//! [document]
diff --git a/src/qml/doc/snippets/qml/qml-documents/LabeledImageBox.qml b/src/qml/doc/snippets/qml/qml-documents/LabeledImageBox.qml
new file mode 100644
index 0000000000..5a259a0cc6
--- /dev/null
+++ b/src/qml/doc/snippets/qml/qml-documents/LabeledImageBox.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [document]
+// LabeledImageBox.qml
+import QtQuick 2.15
+
+Rectangle {
+ property alias caption: image.caption
+ property alias source: image.source
+ border.width: 2
+ border.color: "black"
+ Images.LabeledImage {
+ id: image
+ }
+}
+//! [document]
diff --git a/src/qml/doc/src/cppintegration/data.qdoc b/src/qml/doc/src/cppintegration/data.qdoc
index 7c2693508c..9dfb7837e5 100644
--- a/src/qml/doc/src/cppintegration/data.qdoc
+++ b/src/qml/doc/src/cppintegration/data.qdoc
@@ -197,6 +197,25 @@ type or method parameter, the value can be created as a JavaScript array or
object in QML, and is automatically converted to a QVariantList or QVariantMap
when it is passed to C++.
+Mind that QVariantList and QVariantMap properties of C++ types are stored as
+values and cannot be changed in place by QML code. You can only replace the
+whole map or list, but not manipulate its contents. The following code does
+not work if the property \c l is a QVariantList:
+
+\code
+MyListExposingItem {
+ l: [1, 2, 3]
+ Component.onCompleted: l[0] = 10
+}
+\endcode
+
+The following code does work:
+\code
+MyListExposingItem {
+ l: [1, 2, 3]
+ Component.onCompleted: l = [10, 2, 3]
+}
+\endcode
\section2 QDateTime to JavaScript Date
@@ -284,7 +303,7 @@ In particular, QML currently supports:
\li \c {std::vector<bool>}
\endlist
-and all registered QList, QVector, QQueue, QStack, QSet, QLinkedList, std::list,
+and all registered QList, QVector, QQueue, QStack, QSet, std::list,
std::vector that contain a type marked with \l Q_DECLARE_METATYPE.
These sequence types are implemented directly in terms of the underlying C++
diff --git a/src/qml/doc/src/cppintegration/definetypes.qdoc b/src/qml/doc/src/cppintegration/definetypes.qdoc
index 2e8102bd65..cbbbd9ba58 100644
--- a/src/qml/doc/src/cppintegration/definetypes.qdoc
+++ b/src/qml/doc/src/cppintegration/definetypes.qdoc
@@ -80,9 +80,17 @@ class instance can be manipulated from QML; as
Types to QML} explains, the properties, methods and signals of any
QObject-derived class are accessible from QML code.
-To register a QObject-derived class as an instantiable QML object type, call
-qmlRegisterType() to register the class as QML type into a particular type
-namespace. Clients can then import that namespace in order to use the type.
+To register a QObject-derived class as an instantiable QML object type, add
+\c QML_ELEMENT or \c QML_NAMED_ELEMENT(<name>) to the class declaration and
+\c {CONFIG += qmltypes}, a \c {QML_IMPORT_NAME}, and a
+\c QML_IMPORT_MAJOR_VERSION to your project file. This will register the class
+into the type namespace under the given major version, using either the class
+name or an explicitly given name as QML type name. The minor version(s) will
+be derived from any revisions attached to properties, methods, or signals. The
+default minor version is \c 0. You can explicitly restrict the type to be
+available only from specific minor versions by adding the
+\c QML_ADDED_IN_MINOR_VERSION() macro to the class declaration. Clients can
+import suitable versions of the namespace in order to use the type.
For example, suppose there is a \c Message class with \c author and
\c creationDate properties:
@@ -93,17 +101,20 @@ class Message : public QObject
Q_OBJECT
Q_PROPERTY(QString author READ author WRITE setAuthor NOTIFY authorChanged)
Q_PROPERTY(QDateTime creationDate READ creationDate WRITE setCreationDate NOTIFY creationDateChanged)
+ QML_ELEMENT
public:
// ...
};
\endcode
-This type can be registered by calling qmlRegisterType() with an appropriate
-type namespace and version number. For example, to make the type available in
-the \c com.mycompany.messaging namespace with version 1.0:
+This type can be registered by adding an appropriate type namespace and version
+number to the project file. For example, to make the type available in the
+\c com.mycompany.messaging namespace with version 1.0:
\code
-qmlRegisterType<Message>("com.mycompany.messaging", 1, 0, "Message");
+CONFIG += qmltypes
+QML_IMPORT_NAME = com.mycompany.messaging
+QML_IMPORT_MAJOR_VERSION = 1
\endcode
The type can be used in an \l{qtqml-syntax-basics.html#object-declarations}
@@ -135,23 +146,25 @@ not be instantiable
should not be instantiable from QML
\endlist
-The \l {Qt QML} module provides several methods for registering non-instantiable
+The \l {Qt QML} module provides several macros for registering non-instantiable
types:
\list
-\li qmlRegisterType() (with no parameters) registers a C++ type that is not
-instantiable and cannot be referred to from QML. This enables the engine to
-coerce any inherited types that are instantiable from QML.
-\li qmlRegisterInterface() registers an existing Qt interface type. The type is
+\li QML_ANONYMOUS registers a C++ type that is not instantiable and cannot be
+referred to from QML. This enables the engine to coerce any inherited types that
+are instantiable from QML.
+\li QML_INTERFACE registers an existing Qt interface type. The type is
not instantiable from QML, and you cannot declare QML properties with it. Using
C++ properties of this type from QML will do the expected interface casts,
though.
-\li qmlRegisterUncreatableType() registers a named C++ type that is not
-instantiable but should be identifiable as a type to the QML type system. This
-is useful if a type's enums or attached properties should be accessible from QML
-but the type itself should not be instantiable.
-\li qmlRegisterSingletonType() registers a singleton type that can be imported
-from QML, as discussed below.
+\li QML_UNCREATABLE(reason) combined with with QML_ELEMENT or QML_NAMED_ELEMENT
+registers a named C++ type that is not instantiable but should be identifiable
+as a type to the QML type system. This is useful if a type's enums or attached
+properties should be accessible from QML but the type itself should not be
+instantiable. The parameter should be an error message to be emitted if an
+attempt at creating an instance of the type is detected.
+\li QML_SINGLETON combined with QML_ELEMENT or QML_NAMED_ELEMENT registers a
+singleton type that can be imported from QML, as discussed below.
\endlist
Note that all C++ types registered with the QML type system must be
@@ -195,7 +208,7 @@ Rectangle {
A QJSValue may also be exposed as a singleton type, however clients should
be aware that properties of such a singleton type cannot be bound to.
-See \l{qmlRegisterSingletonType()} for more information on how implement and
+See \l{QML_SINGLETON} for more information on how implement and
register a new singleton type, and how to use an existing singleton type.
\note Enum values for registered types in QML should start with a capital.
@@ -245,30 +258,20 @@ class CppType : public BaseType
{
Q_OBJECT
Q_PROPERTY(int root READ root WRITE setRoot NOTIFY rootChanged REVISION 1)
+ QML_ELEMENT
signals:
Q_REVISION(1) void rootChanged();
};
\endcode
-To register the new class revision to a particular version the following
-function is used:
+The revisions given this way are automatically interpreted as minor versions to
+the major version given in the project file. In this case, \c root is only
+available when \c MyTypes version 1.1 or higher is imported. Imports of
+\c MyTypes version 1.0 remain unaffected.
-\code
-template<typename T, int metaObjectRevision>
-int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
-\endcode
-
-To register \c CppType version 1 for \c {MyTypes 1.1}:
-
-\code
-qmlRegisterType<CppType,1>("MyTypes", 1, 1, "CppType")
-\endcode
-
-\c root is only available when \c MyTypes version 1.1 is imported.
-
-For the same reason, new types introduced in later versions should use
-the minor version argument of qmlRegisterType.
+For the same reason, new types introduced in later versions should be tagged
+with the QML_ADDED_IN_MINOR_VERSION macro.
This feature of the language allows for behavioural changes to be made
without breaking existing applications. Consequently QML module authors
@@ -276,29 +279,10 @@ should always remember to document what changed between minor versions, and
QML module users should check that their application still runs correctly
before deploying an updated import statement.
-You may also register the revision of a base class that your type depends
-upon using the qmlRegisterRevision() function:
-
-\code
-template<typename T, int metaObjectRevision>
-int qmlRegisterRevision(const char *uri, int versionMajor, int versionMinor)
-
-template<typename T, int metaObjectRevision>
-int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason)
-
-template<typename T, typename E, int metaObjectRevision>
-int qmlRegisterExtendedUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason)
-\endcode
-
-For example, if \c BaseType is changed and now has a revision 1, you can
-specify that your type uses the new revision:
-
-\code
-qmlRegisterRevision<BaseType,1>("MyTypes", 1, 1);
-\endcode
-
-This is useful when deriving from base classes provided by other authors,
-e.g. when extending classes from the Qt Quick module.
+Revisions of a base class that your type depends upon are automatically
+registered when registering the type itself. This is useful when deriving
+from base classes provided by other authors, e.g. when extending classes from
+the Qt Quick module.
\note The QML engine does not support revisions for properties or signals of
grouped and attached property objects.
@@ -323,21 +307,8 @@ merged with the original target class when used from within QML. For example:
The \c leftMargin property is a new property added to an existing C++ type, \l
QLineEdit, without modifying its source code.
-The \l {QQmlEngine::}{qmlRegisterExtendedType()} function is for registering extended types.
-Note that it has two forms.
-
-\code
-template<typename T, typename ExtendedT>
-int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
-
-template<typename T, typename ExtendedT>
-int qmlRegisterExtendedType()
-\endcode
-
-This functions should be used instead of the regular \c qmlRegisterType()
-variations. The arguments are identical to the corresponding non-extension
-registration functions, except for the ExtendedT parameter which is the type of
-the extension object.
+The QML_EXTENDED(extended) macro is for registering extended types. The
+argument is the name of another class to be used as extension.
An extension class is a regular QObject, with a constructor that takes a QObject
pointer. However, the extension class creation is delayed until the first
@@ -425,8 +396,9 @@ the attributes to be made accessible to \e attachee objects. For the
attached property accesses. Consequently the attachment object may not be
deleted until the attachee \c object is destroyed.
-\li is declared as an attaching type, by calling the QML_DECLARE_TYPEINFO()
- macro with the QML_HAS_ATTACHED_PROPERTIES flag
+\li is declared as an attaching type, by adding the QML_ATTACHED(attached) macro
+ to the class declaration. The argument is the name of the
+ \e{attached object type}
\endlist
@@ -441,6 +413,7 @@ class Message : public QObject
Q_OBJECT
Q_PROPERTY(QString author READ author WRITE setAuthor NOTIFY authorChanged)
Q_PROPERTY(QDateTime creationDate READ creationDate WRITE setCreationDate NOTIFY creationDateChanged)
+ QML_ELEMENT
public:
// ...
};
@@ -472,6 +445,7 @@ class MessageBoardAttachedType : public QObject
{
Q_OBJECT
Q_PROPERTY(bool expired READ expired WRITE setExpired NOTIFY expiredChanged)
+ QML_ANONYMOUS
public:
MessageBoardAttachedType(QObject *parent);
bool expired() const;
@@ -485,20 +459,21 @@ signals:
Then the \e {attaching type}, \c MessageBoard, must declare a \c
qmlAttachedProperties() method that returns an instance of the
\e {attached object type} as implemented by MessageBoardAttachedType.
-Additionally, \c Message board must be declared as an attached type
-through the QML_DECLARE_TYPEINFO() macro:
+Additionally, \c MessageBoard must be declared as an attaching type
+via the QML_ATTACHED() macro:
\code
class MessageBoard : public QObject
{
Q_OBJECT
+ QML_ATTACHED(MessageBoardAttachedType)
+ QML_ELEMENT
public:
static MessageBoardAttachedType *qmlAttachedProperties(QObject *object)
{
return new MessageBoardAttachedType(object);
}
};
-QML_DECLARE_TYPEINFO(MessageBoard, QML_HAS_ATTACHED_PROPERTIES)
\endcode
Now, a \c Message type can access the properties and signals of the attached
@@ -607,6 +582,7 @@ class RandomNumberGenerator : public QObject, public QQmlPropertyValueSource
Q_OBJECT
Q_INTERFACES(QQmlPropertyValueSource)
Q_PROPERTY(int maxValue READ maxValue WRITE setMaxValue NOTIFY maxValueChanged);
+ QML_ELEMENT
public:
RandomNumberGenerator(QObject *parent)
: QObject(parent), m_maxValue(100)
@@ -690,6 +666,7 @@ class MessageBoard : public QObject
Q_OBJECT
Q_PROPERTY(QQmlListProperty<Message> messages READ messages)
Q_CLASSINFO("DefaultProperty", "messages")
+ QML_ELEMENT
public:
QQmlListProperty<Message> messages();
@@ -766,6 +743,7 @@ class MyQmlType : public QObject, public QQmlParserStatus
{
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
+ QML_ELEMENT
public:
virtual void componentComplete()
{
diff --git a/src/qml/doc/src/cppintegration/extending-tutorial.qdoc b/src/qml/doc/src/cppintegration/extending-tutorial.qdoc
index d587173e5a..458768bf18 100644
--- a/src/qml/doc/src/cppintegration/extending-tutorial.qdoc
+++ b/src/qml/doc/src/cppintegration/extending-tutorial.qdoc
@@ -103,11 +103,22 @@ functionality of an existing QObject-based class, it could inherit from that cla
Alternatively, if we want to create a visual item that doesn't need to perform drawing
operations with the QPainter API, we can just subclass QQuickItem.
-The \c PieChart class defines the two properties, \c name and \c color, with the Q_PROPERTY macro,
-and overrides QQuickPaintedItem::paint(). The class implementation in \c piechart.cpp
-simply sets and returns the \c m_name and \c m_color values as appropriate, and
-implements \c paint() to draw a simple pie chart. It also turns off the
-QGraphicsItem::ItemHasNoContents flag to enable painting:
+The \c PieChart class defines the two properties, \c name and \c color, with the
+Q_PROPERTY macro, and overrides QQuickPaintedItem::paint(). The \c PieChart
+class is registered using the QML_ELEMENT macro, to allow it to be used from
+QML. If you don't register the class, \c app.qml won't be able to create a
+\c PieChart.
+
+For the registration to take effect, the \c qmltypes option is added to
+\c CONFIG in the project file and a \c QML_IMPORT_NAME and
+\c QML_IMPORT_MAJOR_VERSION are given:
+
+\snippet tutorials/extending-qml/chapter1-basics/chapter1-basics.pro 0
+
+The class implementation in \c piechart.cpp simply sets and returns the
+\c m_name and \c m_color values as appropriate, and implements \c paint() to
+draw a simple pie chart. It also turns off the QGraphicsItem::ItemHasNoContents
+flag to enable painting:
\snippet tutorials/extending-qml/chapter1-basics/piechart.cpp 0
\dots 0
@@ -125,9 +136,7 @@ provided for various other \l {QML Basic Types}{basic types}; for example, a str
like "640x480" can be automatically converted to a QSize value.
We'll also create a C++ application that uses a QQuickView to run and
-display \c app.qml. The application must register the \c PieChart type
-using the qmlRegisterType() function, to allow it to be used from QML. If
-you don't register the type, \c app.qml won't be able to create a \c PieChart.
+display \c app.qml.
Here is the application \c main.cpp:
@@ -143,7 +152,7 @@ Now we can build and run the application:
\image extending-tutorial-chapter1.png
-\note You may see a warning \e {Expression ... depends on non-NOTIFYable properties:
+\note You may see a warning \e {Expression ... depends on non-NOTIFYable properties:
PieChart::name}. This happens because we add a binding to the writable \c name
property, but haven't yet defined a notify signal for it. The QML engine therefore
cannot update the binding if the \c name value changes. This is addressed in
@@ -450,7 +459,7 @@ In this tutorial, we've shown the basic steps for creating a QML extension:
\list
\li Define new QML types by subclassing QObject and registering them with
- qmlRegisterType()
+ QML_ELEMENT or QML_NAMED_ELEMENT()
\li Add callable methods using \l Q_INVOKABLE or Qt slots, and connect to Qt signals
with an \c onSignal syntax
\li Add property bindings by defining \l{Qt's Property System}{NOTIFY} signals
diff --git a/src/qml/doc/src/cppintegration/topic.qdoc b/src/qml/doc/src/cppintegration/topic.qdoc
index fbb654378d..bf4565a996 100644
--- a/src/qml/doc/src/cppintegration/topic.qdoc
+++ b/src/qml/doc/src/cppintegration/topic.qdoc
@@ -49,8 +49,16 @@ file contents with:
\snippet code/backend/backend.h backend_header
The \c Q_PROPERTY macro declares a property that could be accessed from QML.
+The \c QML_ELEMENT macro makes the BackEnd class available in QML.
-\li Replace its C++ file contents with:
+\li Add the following lines to your project file:
+
+\snippet code/backend/backend.pro registration
+
+The BackEnd class is automatically registered as a type, which is accessible
+from QML by importing the URL, "\c{io.qt.examples.backend 1.0}".
+
+\li Replace the contents of \c{backend.cpp} with:
\snippet code/backend/backend.cpp backend_cpp
@@ -58,14 +66,6 @@ The \c setUserName function emits the \c userNameChanged signal every time
\c m_userName value changes. The signal can be handled from QML using the
\c onUserNameChanged handler.
-\li Include \c "backend.h" in \c main.cpp and register the class as a QML type
-under a import URL as shown below:
-
-\snippet code/backend/main.cpp main_cpp
-
-The BackEnd class is registered as a type, which is accessible from QML by
-importing the URL, "\c{io.qt.examples.backend 1.0}".
-
\li Replace the contents of \c main.qml with the following code:
\snippet code/backend/main.qml main_qml
diff --git a/src/qml/doc/src/javascript/expressions.qdoc b/src/qml/doc/src/javascript/expressions.qdoc
index b83127389a..b27bde3cf9 100644
--- a/src/qml/doc/src/javascript/expressions.qdoc
+++ b/src/qml/doc/src/javascript/expressions.qdoc
@@ -147,7 +147,7 @@ Rectangle {
TapHandler {
id: inputHandler
- onTapped: {
+ onTapped: {
// arbitrary JavaScript expression
console.log("Tapped!")
}
@@ -339,7 +339,7 @@ For the following examples, imagine that we have defined the following class:
and that we have registered it with the QML type-system as follows:
-\snippet qml/integrating-javascript/scarceresources/avatarExample.cpp 0
+\snippet qml/integrating-javascript/scarceresources/scarceresources.pro 0
The AvatarExample class has a property which is a pixmap. When the property
is accessed in JavaScript scope, a copy of the resource will be created and
diff --git a/src/qml/doc/src/javascript/imports.qdoc b/src/qml/doc/src/javascript/imports.qdoc
index 8e26c4aadd..9227f0e604 100644
--- a/src/qml/doc/src/javascript/imports.qdoc
+++ b/src/qml/doc/src/javascript/imports.qdoc
@@ -154,7 +154,7 @@ var importedEnumValue = JsQtTest.MyQmlObject.EnumValue3
\endcode
In particular, this may be useful in order to access functionality provided
-via a singleton type; see qmlRegisterSingletonType() for more information.
+via a singleton type; see QML_SINGLETON for more information.
\note The .import syntax doesn't work for scripts used in the \l {WorkerScript}
*/
diff --git a/src/qml/doc/src/qmlfunctions.qdoc b/src/qml/doc/src/qmlfunctions.qdoc
index 67c0f6bb25..04d907f168 100644
--- a/src/qml/doc/src/qmlfunctions.qdoc
+++ b/src/qml/doc/src/qmlfunctions.qdoc
@@ -26,6 +26,274 @@
****************************************************************************/
/*!
+ \macro QML_ELEMENT
+ \relates QQmlEngine
+
+ Declares the enclosing type or namespace to be available in QML, using its
+ class or namespace name as the QML element name.
+
+ For example, this makes the C++ class \c Slider available as a QML type
+ named \c Slider.
+
+ \code
+ class Slider : public QObject
+ {
+ Q_OBJECT
+ QML_ELEMENT
+ ...
+ }
+ \endcode
+
+ You can use the build system to register the type in the type namespace
+ \e {com.mycompany.qmlcomponents} with major version \c 1 by specifying the
+ following in your project file:
+
+ \badcode
+ CONFIG += qmltypes
+ QML_IMPORT_NAME = com.mycompany.qmlcomponents
+ QML_IMPORT_MAJOR_VERSION = 1
+ \endcode
+
+ Once registered, the type can be used in QML by importing the
+ same type namespace and version number:
+
+ \qml
+ import com.mycompany.qmlcomponents 1.0
+
+ Slider {
+ // ...
+ }
+ \endqml
+
+ You can also make namespaces tagged with Q_NAMESPACE available this way, in
+ order to expose any enums tagged with Q_ENUM_NS they contain.
+
+ \sa {Choosing the Correct Integration Method Between C++ and QML}, QML_NAMED_ELEMENT(),
+ Q_REVISION(), QML_ADDED_IN_MINOR_VERSION()
+*/
+
+/*!
+ \macro QML_NAMED_ELEMENT(name)
+ \relates QQmlEngine
+
+ Declares the enclosing type or namespace to be available in QML, using \a name
+ as the element name. Otherwise behaves the same as QML_ELEMENT.
+
+ \sa {Choosing the Correct Integration Method Between C++ and QML}, QML_ELEMENT
+*/
+
+/*!
+ \macro QML_ANONYMOUS
+ \relates QQmlEngine
+
+ Declares the enclosing type to be available, but anonymous in QML. The type
+ cannot be created or used as property type, but when passed from C++, it is
+ recognized.
+
+ \sa QML_ELEMENT, QML_NAMED_ELEMENT(), QML_UNCREATABLE(), QML_INTERFACE
+*/
+
+/*!
+ \macro QML_INTERFACE
+ \relates QQmlEngine
+
+ This macro registers the enclosing C++ type in the QML system as an interface.
+
+ Types registered as an interface in QML should also declare themselves as an
+ interface with the \l {The Meta-Object System}{meta object system}. For
+ example:
+
+ \code
+ struct FooInterface
+ {
+ QML_INTERFACE
+ public:
+ virtual ~FooInterface();
+ virtual void doSomething() = 0;
+ };
+
+ Q_DECLARE_INTERFACE(FooInterface, "org.foo.FooInterface")
+ \endcode
+
+ When registered with QML in this way, they can be used as property types:
+
+ Q_PROPERTY(FooInterface *foo READ foo WRITE setFoo)
+
+ When you assign a \l QObject sub-class to this property, the QML engine does
+ the interface cast to \c FooInterface* automatically.
+
+ Interface types are implicitly anonymous and uncreatable in QML.
+
+ \sa QML_ELEMENT, QML_NAMED_ELEMENT(), QML_UNCREATABLE(), QML_ANONYMOUS
+*/
+
+/*!
+ \macro QML_UNCREATABLE(reason)
+ \relates QQmlEngine
+
+ Declares that the enclosing type shall not be creatable from QML. This takes
+ effect if the type is available in QML, by having a \l QML_ELEMENT or
+ \l QML_NAMED_ELEMENT() macro. The \a reason will be emitted as error message if an
+ attempt to create the type from QML is detected.
+
+ Some QML types are implicitly uncreatable, in particular types exposed with
+ \l QML_ANONYMOUS or namespaces exposed with \l QML_ELEMENT or
+ \l QML_NAMED_ELEMENT(). For such types, \l QML_UNCREATABLE() can be used to
+ provide a custom error message.
+
+ \sa QML_ELEMENT, QML_NAMED_ELEMENT(), QML_ANONYMOUS
+*/
+
+/*!
+ \macro QML_SINGLETON
+ \relates QQmlEngine
+
+ Declares the enclosing type to be a singleton in QML. This only takes effect
+ if the type is available in QML, by having a \l QML_ELEMENT or
+ \l QML_NAMED_ELEMENT() macro. By default, each QQmlEngine will try to create a
+ singleton instance using the type's default constructor when the type is first
+ accessed. If there is no default constructor the singleton is initially
+ inaccessible. This behavior can be overridden by calling
+ \l qmlRegisterSingletonType() with a specific factory function or
+ \l qmlRegisterSingletonInstance() with a specific instance for the same class
+ and the same type namespace and version.
+
+ \sa QML_ELEMENT, QML_NAMED_ELEMENT(), qmlRegisterSingletonInstance().
+*/
+
+/*!
+ \macro QML_ADDED_IN_MINOR_VERSION(VERSION)
+ \relates QQmlEngine
+
+ Declares that the enclosing type or namespace was added in the specified minor
+ \a VERSION, relative to the module major version. The minor version is assumed
+ to be in line with any revisions given by \l Q_REVISION() macros on methods,
+ slots, or signals, and any REVISION tags on properties declared with
+ \l Q_PROPERTY().
+
+ \l QML_ADDED_IN_MINOR_VERSION() only takes effect if the type or namespace is
+ available in QML, by having a \l QML_ELEMENT, \l QML_NAMED_ELEMENT(),
+ \l QML_ANONYMOUS, or \l QML_INTERFACE macro.
+
+ If the QML module the type belongs to is imported with a lower version than
+ the one determined this way, the QML type is invisible.
+
+ \sa QML_ELEMENT, QML_NAMED_ELEMENT()
+*/
+
+/*!
+ \macro QML_REMOVED_IN_MINOR_VERSION(VERSION)
+ \relates QQmlEngine
+
+ Declares that the enclosing type or namespace was removed in the specified
+ minor \a VERSION, relative to the module major version. This is primarily
+ useful when replacing the implementation of a QML type. If a corresponding
+ \l QML_ADDED_IN_MINOR_VERSION() is present on a different type or namespace of
+ the same QML name, then the removed type is used when importing versions of
+ the module lower than \a VERSION, and the added type is used when importing
+ versions of the module greater or equal \a VERSION.
+
+ \l QML_REMOVED_IN_MINOR_VERSION() only takes effect if type or namespace is
+ available in QML, by having a \l QML_ELEMENT, \l QML_NAMED_ELEMENT(),
+ \l QML_ANONYMOUS, or \l QML_INTERFACE macro.
+
+ \sa QML_ELEMENT, QML_NAMED_ELEMENT()
+*/
+
+/*!
+ \macro QML_ATTACHED(ATTACHED_TYPE)
+ \relates QQmlEngine
+
+ Declares that the enclosing type attaches \a ATTACHED_TYPE as an
+ \l {Attached Properties and Attached Signal Handlers}
+ {attached property} to other types. This takes effect if the type
+ is exposed to QML using a \l QML_ELEMENT or \l QML_NAMED_ELEMENT() macro.
+
+ \sa QML_ELEMENT, QML_NAMED_ELEMENT(), qmlAttachedPropertiesObject(),
+ {Providing Attached Properties}
+*/
+
+/*!
+ \macro QML_EXTENDED(EXTENDED_TYPE)
+ \relates QQmlEngine
+
+ Declares that the enclosing type uses \a EXTENDED_TYPE as an extension to
+ provide further properties and methods in QML. This takes effect if the type
+ is exposed to QML using a \l QML_ELEMENT or \l QML_NAMED_ELEMENT() macro.
+
+ \sa QML_ELEMENT, QML_NAMED_ELEMENT(), {Registering Extension Objects}
+*/
+
+/*!
+ \macro QML_FOREIGN(FOREIGN_TYPE)
+ \relates QQmlEngine
+
+ Declares that any \l QML_ELEMENT, \l QML_NAMED_ELEMENT(), \l QML_ANONYMOUS,
+ \l QML_INTERFACE, \l QML_UNCREATABLE(), \l QML_SINGLETON,
+ \l QML_ADDED_IN_MINOR_VERSION(), \l QML_REMOVED_IN_MINOR_VERSION(),
+ \l QML_ATTACHED(), or \l QML_EXTENDED() macros in the enclosing C++ type do
+ not apply to the enclosing type but instead to \a FOREIGN_TYPE. The enclosing
+ type still needs to be registered with the
+ \l {The Meta-Object System}{meta object system} using a \l Q_GADGET or
+ \l Q_OBJECT macro.
+
+ This is useful for registering types that cannot be amended to add the macros,
+ for example because they belong to 3rdparty libraries.
+
+ \sa QML_ELEMENT, QML_NAMED_ELEMENT()
+*/
+
+/*!
+ \macro QML_UNAVAILABLE
+ \relates QQmlEngine
+
+ This macro declares the enclosing type to be unavailable in QML. It registers
+ an internal dummy type called \c QQmlTypeNotAvailable as \l QML_FOREIGN()
+ type, using any further QML macros you specify.
+
+ Normally, the types exported by a module should be fixed. However, if a C++
+ type is not available, you should at least "reserve" the QML type name, and
+ give the user of the unavailable type a meaningful error message.
+
+ Example:
+
+ \code
+ #ifdef NO_GAMES_ALLOWED
+ struct MinehuntGame
+ {
+ Q_GADGET
+ QML_NAMED_ELEMENT(Game)
+ QML_UNAVAILABLE
+ QML_UNCREATABLE("Get back to work, slacker!");
+ };
+ #else
+ class MinehuntGame : public QObject
+ {
+ Q_OBJECT
+ QML_NAMED_ELEMENT(Game)
+ // ...
+ };
+ #endif
+ \endcode
+
+ This will cause any QML which attempts to use the "Game" type to produce an
+ error message:
+
+ \badcode
+ fun.qml: Get back to work, slacker!
+ Game {
+ ^
+ \endcode
+
+ Using this technique, you only need a \l Q_GADGET struct to customize the error
+ message, not a full-blown \l QObject. Without \l QML_UNCREATABLE(),
+ \l QML_UNAVAILABLE still results in a more specific error message than the usual
+ "is not a type" for completely unknown types.
+
+ \sa QML_ELEMENT, QML_NAMED_ELEMENT(), QML_UNCREATABLE(), QML_FOREIGN()
+*/
+
+/*!
\macro QML_DECLARE_TYPE()
\relates QQmlEngine
@@ -41,7 +309,8 @@
Current the only supported type info is \c QML_HAS_ATTACHED_PROPERTIES which
declares that the \a Type supports \l {Attached Properties and Attached Signal Handlers}
- {attached properties}.
+ {attached properties}. QML_DECLARE_TYPEINFO() is not necessary if \a Type contains the
+ QML_ATTACHED macro.
*/
/*!
@@ -106,7 +375,8 @@
QML written to previous versions to continue to work, even if more advanced versions of
some of its types are available.
- \sa {Choosing the Correct Integration Method Between C++ and QML}
+ \sa QML_ELEMENT, QML_NAMED_ELEMENT(),
+ {Choosing the Correct Integration Method Between C++ and QML}
*/
/*!
@@ -143,7 +413,7 @@
Returns the QML type id.
- \sa qmlRegisterTypeNotAvailable(),
+ \sa QML_UNCREATABLE(), qmlRegisterTypeNotAvailable(),
{Choosing the Correct Integration Method Between C++ and QML}
*/
@@ -158,7 +428,7 @@
Returns the QML type id.
- \sa qmlRegisterType(), {Registering Extension Objects}
+ \sa QML_EXTENDED(), qmlRegisterType(), {Registering Extension Objects}
*/
@@ -180,7 +450,7 @@
Returns the QML type id.
- \sa qmlRegisterUncreatableType()
+ \sa QML_EXTENDED(), QML_UNCREATABLE(), qmlRegisterUncreatableType()
*/
/*!
@@ -220,6 +490,8 @@
\code
Component.onCompleted: console.log(MyNamespace.Key2)
\endcode
+
+ \sa QML_ELEMENT, QML_NAMED_ELEMENT(), QML_UNCREATABLE()
*/
/*!
@@ -235,6 +507,8 @@
the \a parser provided.
Returns the QML type id.
+
+ \sa QML_ELEMENT, QML_NAMED_ELEMENT(), QML_EXTENDED()
*/
/*!
@@ -269,7 +543,7 @@
Without this, a generic "Game is not a type" message would be given.
- \sa qmlRegisterUncreatableType(),
+ \sa QML_UNAVAILABLE, qmlRegisterUncreatableType(),
{Choosing the Correct Integration Method Between C++ and QML}
*/
@@ -353,7 +627,7 @@
Returns the QML type id.
\since 5.14
- \sa {Choosing the Correct Integration Method Between C++ and QML}
+ \sa QML_ANONYMOUS, {Choosing the Correct Integration Method Between C++ and QML}
*/
/*!
@@ -397,6 +671,8 @@
the interface cast to \c FooInterface* automatically.
Returns the QML type id.
+
+ \sa QML_INTERFACE
*/
/*!
@@ -455,7 +731,7 @@
}
\endqml
- \sa {Choosing the Correct Integration Method Between C++ and QML}
+ \sa QML_SINGLETON, {Choosing the Correct Integration Method Between C++ and QML}
*/
/*!
@@ -477,8 +753,7 @@
Returns 0 if type \e T is not a valid attaching type, or if \a create is false and no
attachment object instance has previously been created for \a attachee.
- \sa {Providing Attached Properties}
-
+ \sa QML_ATTACHED(), {Providing Attached Properties}
*/
/*!
@@ -571,7 +846,7 @@
}
\endqml
- \sa {Choosing the Correct Integration Method Between C++ and QML}
+ \sa QML_SINGLETON, {Choosing the Correct Integration Method Between C++ and QML}
*/
@@ -626,10 +901,12 @@
That can be done by adding a pragma Singleton statement among the imports of the type's QML file. In addition
the type must be defined in a qmldir file with a singleton keyword and the qmldir must be imported by the QML
files using the singleton.
+
+ \sa QML_SINGLETON
*/
/*!
- \fn int qmlRegisterSingletonInstance(const char *uri, int versionMajor, int versionMinor, const char *typeName, QObject* cppObject)
+ \fn template<typename T> auto qmlRegisterSingletonInstance(const char *uri, int versionMajor, int versionMinor, const char *typeName, T *cppObject)
\relates QQmlEngine
\since 5.14
@@ -718,7 +995,7 @@
}
\endqml
- \sa qmlRegisterSingletonType
+ \sa QML_SINGLETON, qmlRegisterSingletonType
*/
/*!
@@ -792,5 +1069,5 @@
Returns -1 if no matching type was found or one of the given parameters
was invalid.
- \sa qmlRegisterType(), qmlRegisterSingletonType()
+ \sa QML_ELEMENT, QML_NAMED_ELEMENT, QML_SINGLETON, qmlRegisterType(), qmlRegisterSingletonType()
*/
diff --git a/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc b/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc
index 2de4eb0c18..a4119ff793 100644
--- a/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc
+++ b/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc
@@ -29,25 +29,37 @@
\title Defining Object Types through QML Documents
\brief Description of how a QML document is a reusable type definition
-One of the core features of QML is that it enables QML object types to be easily defined in a lightweight manner through QML documents to suit the needs of individual QML applications. The standard \l {Qt Quick} module provides various types like \l Rectangle, \l Text and \l Image for building a QML application; beyond these, you can easily define your own QML types to be reused within your application. This ability to create your own types forms the building blocks of any QML application.
+One of the core features of QML is that it enables QML object types to be
+easily defined in a lightweight manner through QML documents to suit the needs
+of individual QML applications. The standard \l {Qt Quick} module provides
+various types like \l Rectangle, \l Text and \l Image for building a QML
+application; beyond these, you can easily define your own QML types to be
+reused within your application. This ability to create your own types forms the
+building blocks of any QML application.
\section1 Defining an Object Type with a QML File
\section2 Naming Custom QML Object Types
-To create an object type, a QML document should be placed into a text file named as \e <TypeName>.qml where \e <TypeName> is the desired name of the type. The type name has the following requirements:
+To create an object type, a QML document should be placed into a text file
+named as \e <TypeName>.qml where \e <TypeName> is the desired name of the type.
+The type name has the following requirements:
\list
\li It must be comprised of alphanumeric characters or underscores.
\li It must begin with an uppercase letter.
\endlist
-This document is then automatically recognized by the engine as a definition of a QML type. Additionally, a type defined in this manner is automatically made available to other QML files within the same directory as the engine searches within the immediate directory when resolving QML type names.
+This document is then automatically recognized by the engine as a definition of
+a QML type. Additionally, a type defined in this manner is automatically made
+available to other QML files within the same directory as the engine searches
+within the immediate directory when resolving QML type names.
\section2 Custom QML Type Definition
-For example, below is a document that declares a \l Rectangle with a child \l MouseArea. The document has been saved to file named \c SquareButton.qml:
+For example, below is a document that declares a \l Rectangle with a child \l
+MouseArea. The document has been saved to file named \c SquareButton.qml:
\qml
// SquareButton.qml
@@ -65,7 +77,10 @@ Rectangle {
}
\endqml
-Since the file is named \c SquareButton.qml, \b {this can now be used as a type named \c SquareButton by any other QML file within the same directory}. For example, if there was a \c myapplication.qml file in the same directory, it could refer to the \c SquareButton type:
+Since the file is named \c SquareButton.qml, \b {this can now be used as a type
+named \c SquareButton by any other QML file within the same directory}. For
+example, if there was a \c myapplication.qml file in the same directory, it
+could refer to the \c SquareButton type:
\qml
// myapplication.qml
@@ -76,23 +91,80 @@ SquareButton {}
\image documents-definetypes-simple.png
-This creates a 100 x 100 red \l Rectangle with an inner \l MouseArea, as defined in \c SquareButton.qml. When this \c myapplication.qml document is loaded by the engine, it loads the SquareButton.qml document as a component and instantiates it to create a \c SquareButton object.
+This creates a 100 x 100 red \l Rectangle with an inner \l MouseArea, as
+defined in \c SquareButton.qml. When this \c myapplication.qml document is
+loaded by the engine, it loads the SquareButton.qml document as a component and
+instantiates it to create a \c SquareButton object.
+
+The \c SquareButton type encapsulates the tree of QML objects declared in \c
+SquareButton.qml. When the QML engine instantiates a \c SquareButton object
+from this type, it is instantiating an object from the \l Rectangle tree
+declared in \c SquareButton.qml.
+
+\note the letter case of the file name is significant on some (notably UNIX)
+filesystems. It is recommended the file name case matches the case of the
+desired QML type name exactly - for example, \c Box.qml and not \c BoX.qml -
+regardless of the platform to which the QML type will be deployed.
+
+\section2 Inline Components
+
+Sometimes, it can be inconvenient to create a new file for a type, for
+instance when reusing a small delegate in multiple views. If you don't actually
+need to expose the type, but only need to create an instance,
+\l{QtQml::Component}{Component} is an option.
+But if you want to declare properties with the component types, or if you
+want to use it in multiple files, \c Component is not an option. In that case,
+you can use \e {inline components}. Inline components declare a new component
+inside of a file. The syntax for that is
+\code
+component <component name> : BaseType {
+ // declare properties and bindings here
+}
+\endcode
+
+Inside the file which declares the inline component, the type can be referenced
+simply by its name.
+
+\snippet qml/qml-documents/Images.qml document
+
+In other files, it has to be prefixed with the name of its containing component.
+
+\snippet qml/qml-documents/LabeledImageBox.qml document
+
+\note Inline components don't share their scope with the component they are
+declared in. In the following example, when \c A.MyInlineComponent in file
+B.qml gets created, a ReferenceError will occur, as \c root does not exist as
+an id in B.qml.
+It is therefore advisable not to reference objects in an inline component
+which are not part of it.
-The \c SquareButton type encapsulates the tree of QML objects declared in \c SquareButton.qml. When the QML engine instantiates a \c SquareButton object from this type, it is instantiating an object from the \l Rectangle tree declared in \c SquareButton.qml.
+\snippet qml/qml-documents/A.qml document
+\snippet qml/qml-documents/B.qml document
-\note the letter case of the file name is significant on some (notably UNIX) filesystems. It is recommended the file name case matches the case of the desired QML type name exactly - for example, \c Box.qml and not \c BoX.qml - regardless of the platform to which the QML type will be deployed.
+\note Inline components cannot be nested.
\section2 Importing Types Defined Outside the Current Directory
If \c SquareButton.qml was not in the same directory as \c myapplication.qml,
-the \c SquareButton type would need to be specifically made available through an \e import statement in \c myapplication.qml. It could be imported from a relative path on the file system, or as an installed module; see \l {QML Modules}{module} for more details.
+the \c SquareButton type would need to be specifically made available through
+an \e import statement in \c myapplication.qml. It could be imported from a
+relative path on the file system, or as an installed module; see \l {QML
+Modules}{module} for more details.
\section1 Accessible Attributes of Custom Types
-The \b {root object} definition in a .qml file \b {defines the attributes that are available for a QML type}. All properties, signals and methods that belong to this root object - whether they are custom declared, or come from the QML type of the root object - are externally accessible and can be read and modified for objects of this type.
+The \b {root object} definition in a .qml file \b {defines the attributes that
+are available for a QML type}. All properties, signals and methods that belong
+to this root object - whether they are custom declared, or come from the QML
+type of the root object - are externally accessible and can be read and
+modified for objects of this type.
-For example, the root object type in the \c SquareButton.qml file above is \l Rectangle. This means any properties defined by the \l Rectangle type can be modified for a \c SquareButton object. The code below defines three \c SquareButton objects with customized values for some of the properties of the root \l Rectangle object of the \c SquareButton type:
+For example, the root object type in the \c SquareButton.qml file above is \l
+Rectangle. This means any properties defined by the \l Rectangle type can be
+modified for a \c SquareButton object. The code below defines three \c
+SquareButton objects with customized values for some of the properties of the
+root \l Rectangle object of the \c SquareButton type:
\qml
// application.qml
@@ -107,7 +179,12 @@ Column {
\image documents-definetypes-attributes.png
-The attributes that are accessible to objects of the custom QML type include any \l{Defining Property Attributes}{custom properties}, \l{Defining Method Attributes}{methods} and \l{Defining Signal Attributes}{signals} that have additionally been defined for an object. For example, suppose the \l Rectangle in \c SquareButton.qml had been defined as follows, with additional properties, methods and signals:
+The attributes that are accessible to objects of the custom QML type include
+any \l{Defining Property Attributes}{custom properties}, \l{Defining Method
+Attributes}{methods} and \l{Defining Signal Attributes}{signals} that have
+additionally been defined for an object. For example, suppose the \l Rectangle
+in \c SquareButton.qml had been defined as follows, with additional properties,
+methods and signals:
\qml
// SquareButton.qml
@@ -136,7 +213,9 @@ Rectangle {
}
\endqml
-Any \c SquareButton object could make use of the \c pressed property, \c buttonClicked signal and \c randomizeColor() method that have been added to the root \l Rectangle:
+Any \c SquareButton object could make use of the \c pressed property, \c
+buttonClicked signal and \c randomizeColor() method that have been added to the
+root \l Rectangle:
\qml
// application.qml
@@ -154,7 +233,14 @@ SquareButton {
}
\endqml
-Note that any of the \c id values defined in \c SquareButton.qml are not accessible to \c SquareButton objects, as id values are only accessible from within the component scope in which a component is declared. The \c SquareButton object definition above cannot refer to \c mouseArea in order to refer to the \l MouseArea child, and if it had an \c id of \c root rather than \c squareButton, this would not conflict with the \c id of the same value for the root object defined in \c SquareButton.qml as the two would be declared within separate scopes.
+Note that any of the \c id values defined in \c SquareButton.qml are not
+accessible to \c SquareButton objects, as id values are only accessible from
+within the component scope in which a component is declared. The \c
+SquareButton object definition above cannot refer to \c mouseArea in order to
+refer to the \l MouseArea child, and if it had an \c id of \c root rather than
+\c squareButton, this would not conflict with the \c id of the same value for
+the root object defined in \c SquareButton.qml as the two would be declared
+within separate scopes.
*/
diff --git a/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc b/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc
index f7d71030b5..99c7fa5621 100644
--- a/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc
+++ b/src/qml/doc/src/qmllanguageref/modules/qmldir.qdoc
@@ -422,7 +422,7 @@ import QtQuick.tooling 1.1
// Component objects.
Module {
// A Component object directly corresponds to a type exported
- // in a plugin with a call to qmlRegisterType.
+ // using the QML_ELEMENT or QML_NAMED_ELEMENT macros.
Component {
// The name is a unique identifier used to refer to this type.
@@ -440,25 +440,34 @@ Module {
attachedType: "QQuickAnimationAttached"
// The list of exports determines how a type can be imported.
- // Each string has the format "URI/Name version" and matches the
- // arguments to qmlRegisterType. Usually types are only exported
- // once, if at all.
- // If the "URI/" part of the string is missing that means the
- // type should be put into the package defined by the URI the
- // module was imported with.
- // For example if this module was imported with 'import Foo 4.8'
- // the Animation object would be found in the package Foo and
- // QtQuick.
+ // Each string has the format "URI/Name version". The URI is
+ // the import name given via the build system, for example as
+ // QML_IMPORT_NAME in qmake. The name is either the C++ class
+ // name or, in case of QML_NAMED_ELEMENT(), an explicitly given
+ // name. The version is constructed from the major version
+ // given via the build system, as QML_IMPORT_MAJOR_VERSION in
+ // qmake, and any revisions given in the class or its base
+ // classes by Q_REVISION(), the REVISION argument to Q_PROPERTY,
+ // or QML_ADDED_IN_MINOR_VERSION(). Usually types are only
+ // exported once, if at all. The following tells us that there
+ // are two variants of Animation, and that 'import QtQuick 2.0'
+ // will expose a different revision than imports of later
+ // versions.
exports: [
- "Animation 4.7",
- "QtQuick/Animation 1.0"
+ "QtQuick/Animation 2.0",
+ "QtQuick/Animation 2.1"
]
// The meta object revisions for the exports specified in 'exports'.
- // Describes with revisioned properties will be visible in an export.
- // The list must have exactly the same length as the 'exports' list.
- // For example the 'animations' propery described below will only be
- // available through the QtQuick/Animation 1.0 export.
+ // Each meta object revision may add additional properties or methods,
+ // relative to the previous one. Those will only be visible when the
+ // module is imported with at least the corresponding version as
+ // specified in the 'exports' list.
+ // The exportMetaObjectRevisions list must have exactly the same
+ // length as the 'exports' list. For example, the 'animations' property
+ // described below will only be available through the QtQuick/Animation
+ // 2.1 export. Usually the revisions will match the versions in the
+ // 'exports' list.
exportMetaObjectRevisions: [0, 1]
Property {
@@ -486,7 +495,7 @@ Module {
// declarations also support the isReadonly, isPointer and isList
// attributes which mean the same as for Property
Method { name: "restart" }
- Signal { name: "started"; revision: 2 }
+ Signal { name: "started"; revision: 1 }
Signal {
name: "runningChanged"
Parameter { type: "bool" }
diff --git a/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc b/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc
index 05447db627..496245820a 100644
--- a/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc
+++ b/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc
@@ -1,19 +1,22 @@
-QQmlExtensionPlugin is a plugin interface that makes it possible to
+\l QQmlEngineExtensionPlugin is a plugin interface that makes it possible to
create QML extensions that can be loaded dynamically into QML applications.
These extensions allow custom QML types to be made available to the
QML engine.
To write a QML extension plugin:
\list 1
-\li Subclass QQmlExtensionPlugin
+\li Subclass \l QQmlEngineExtensionPlugin and use the Q_PLUGIN_METADATA() macro
+ to register the plugin with the Qt meta object system.
+\li Use the \l QML_ELEMENT and \l QML_NAMED_ELEMENT() macros to declare
+ QML types.
+\li Write a project file for the plugin. Add:
\list
- \li Use the Q_PLUGIN_METADATA() macro to register the plugin with
- the Qt meta object system
- \li Override the \l{QQmlExtensionPlugin::}{registerTypes()} method
- and call qmlRegisterType() to register the types to be exported
- by the plugin
+ \li \c {CONFIG += qmltypes} to instruct the build system to generate
+ QML types.
+ \li \c {QML_IMPORT_NAME = <my.import.name>} to specify the import name.
+ \li \c {QML_IMPORT_MAJOR_VERSION = <version>} to specify the import
+ major version.
\endlist
-\li Write a project file for the plugin
\li Create a \l{Module Definition qmldir Files}{qmldir file} to
describe the plugin
\endlist
@@ -27,26 +30,18 @@ issues in the library user's code.
Suppose there is a new \c TimeModel C++ class that should be made available
as a new QML type. It provides the current time through \c hour and \c minute
-properties.
+properties. It declares a QML type called \c Time via \l QML_NAMED_ELEMENT().
\snippet qmlextensionplugins/timemodel.h 0
\dots
To make this type available, we create a plugin class named \c QExampleQmlPlugin
-which is a subclass of \l QQmlExtensionPlugin. It overrides the
-\l{QQmlExtensionPlugin::}{registerTypes()} method in order to register the \c TimeModel
-type using qmlRegisterType(). It also uses the Q_PLUGIN_METADATA() macro in the class
-definition to register the plugin with the Qt meta object system using a unique
-identifier for the plugin.
+which is a subclass of \l QQmlEngineExtensionPlugin. It uses the
+Q_PLUGIN_METADATA() macro in the class definition to register the plugin with the
+Qt meta object system using a unique identifier for the plugin.
\snippet qmlextensionplugins/plugin.cpp plugin
-This registers the \c TimeModel class with version \c{1.0} of this plugin library, as
-a QML type called \c Time. The Q_ASSERT() macro can ensure the type namespace is
-imported correctly by any QML components that use this plugin. The
-\l{Defining QML Types from C++} article has more information about registering C++
-types into the runtime.
-
\section1 Project settings for the plugin
Additionally, the project file (\c .pro) defines the project as a plugin library,
@@ -55,14 +50,22 @@ the plugin target name and various other details:
\code
TEMPLATE = lib
-CONFIG += qt plugin
+CONFIG += qt plugin qmltypes
QT += qml
-DESTDIR = imports/TimeExample
-TARGET = qmlqtimeexampleplugin
+QML_IMPORT_NAME = TimeExample
+QML_IMPORT_MAJOR_VERSION = 1
+
+DESTDIR = imports/$$QML_IMPORT_NAME
+TARGET = qmlqtimeexampleplugin
+
SOURCES += qexampleqmlplugin.cpp
\endcode
+This registers the \c TimeModel class with the import \c{TimeExample 1.0}, as
+a QML type called \c Time. The \l{Defining QML Types from C++} article has more
+information about registering C++ types for usage in QML.
+
\section1 Plugin definition in the qmldir
Finally, a \l{Module Definition qmldir Files}{qmldir file} is required
diff --git a/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc b/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc
index 32106d5bb8..fdba452271 100644
--- a/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc
+++ b/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc
@@ -127,15 +127,15 @@ Rectangle {
In this case, the engine will emit an error and refuse to load the file.
-\section4 Non-module Namespace Imports
+\section4 C++ Module Imports
-Types can also be registered into namespaces directly via the various
-registration functions in C++ (such as qmlRegisterType()). The types which
-have been registered into a namespace in this way may be imported by importing
-the namespace, as if the namespace was a module identifier.
+Usually, C++ types are declared using the QML_ELEMENT and QML_NAMED_ELEMENT()
+macros and registered via the build system using QML_IMPORT_NAME and
+QML_IMPORT_MAJOR_VERSION. The import name and version given this way form a
+module that can be imported to access the types.
This is most common in client applications which define their own QML object
-types in C++ and register them with the QML type system manually.
+types in C++.
\section4 Importing into a Qualified Local Namespace
diff --git a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc
index 401e099ebf..ecfef2e04f 100644
--- a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc
+++ b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc
@@ -112,7 +112,7 @@ Alternatively, a custom property of an object type may be defined in
an object declaration in a QML document with the following syntax:
\code
- [default] property <propertyType> <propertyName>
+ [default] [required] [readonly] property <propertyType> <propertyName>
\endcode
In this way an object declaration may \l {Defining Object Types from QML}
@@ -121,10 +121,13 @@ state more easily.
Property names must begin with a lower case letter and can only contain
letters, numbers and underscores. \l {JavaScript Reserved Words}
-{JavaScript reserved words} are not valid property names. The \c default
-keyword is optional, and modifies the semantics of the property being declared.
-See the upcoming section on \l {Default Properties}{default properties} for
-more information about the \c default property modifier.
+{JavaScript reserved words} are not valid property names. The \c default,
+\c required, and \c readonly keywords are optional, and modify the semantics
+of the property being declared.
+See the upcoming sections on \l {Default Properties}{default properties},
+\l {Required Properties}{required properties} and,
+\l {Read-Only Properties}{read-only properties} for more information
+about their respective meaning.
Declaring a custom property implicitly creates a value-change
\l{Signal attributes}{signal} for that property, as well as an associated
@@ -647,6 +650,45 @@ the \l{TabWidget Example}, which uses a default property to
automatically reassign children of the TabWidget as children of an inner
ListView. See also \l {Extending QML}.
+\section3 Required Properties
+
+An object declaration may define a property as required, using the \c required
+keyword. The syntax is
+\code
+ required property <propertyType> <propertyName>
+\endcode
+
+As the name suggests, required properties must be set when an instance of the object
+is created. Violation of this rule will result in QML applications not starting if it can be
+detected statically. In case of dynamically instantiated QML components (for instance via
+\l {QtQml::Qt::createComponent()}{Qt.createComponent()}), violating this rule results in a
+warning and a null return value.
+
+It's possible to make an existing property required with
+\code
+ required <propertyName>
+\endcode
+The following example shows how to create a custom Rectangle component, in which the color
+property always needs to be specified.
+\qml
+// ColorRectangle.qml
+Rectangle {
+ required color
+}
+\endqml
+
+\note You can't assign an initial value to a required property from QML, as that would go
+directly against the intended usage of required properties.
+
+Required properties play a special role in model-view-delegate code:
+If the delegate of a view has required properties whose names match with
+the role names of the view's model, then those properties will be initialized
+with the model's corresponding values.
+For more information, visit the \l{Models and Views in Qt Quick} page.
+
+\sa {QQmlComponent::createWithInitialProperties}, {QQmlApplicationEngine::setInitialProperties}
+and {QQuickView::setInitialProperties} for ways to initialize required properties from C++.
+
\section3 Read-Only Properties
An object declaration may define a read-only property using the \c readonly
diff --git a/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc b/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc
index 5144fe219e..53984a440d 100644
--- a/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc
+++ b/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc
@@ -582,34 +582,15 @@ property is only invoked when the property is reassigned to a different object v
QML objects (and certainly not JavaScript object either) and the key-value
pairs in \c attributes are \e not QML properties. Rather, the \c items
property holds an array of values, and \c attributes holds a set of key-value
- pairs. Since they are stored as a set of values, instead of as an object,
- their contents \e cannot be modified individually:
-
- \qml
- Item {
- property variant items: [1, 2, 3, "four", "five"]
- property variant attributes: { 'color': 'red', 'width': 100 }
-
- Component.onCompleted: {
- items[0] = 10
- console.log(items[0]) // This will still be '1'!
- attributes.color = 'blue'
- console.log(attributes.color) // This will still be 'red'!
- }
- }
- \endqml
-
- Since it is not possible to individually add or remove items from a list or
- object stored in a \c variant, the only way to modify its contents is to
- reassign a new value. However, this is not efficient, as it causes the value
- to be serialized and deserialized.
+ pairs.
Additionally, since \c items and \c attributes are not QML objects, changing
- their individual values do not trigger property change notifications. If
- the above example had \c onNumberChanged or \c onAnimalChanged signal
- handlers, they would not have been called. If, however, the \c items or
- \c attributes properties themselves were reassigned to different values, then
- such handlers would be called.
+ the values they contain does not trigger property change notifications. If
+ the above example had \c onItemsChanged or \c onAttributesChanged signal
+ handlers, they would not be called when assigning individual entries in
+ either property. If, however, the \c items or \c attributes properties
+ themselves were reassigned to different values, then such handlers would be
+ called.
JavaScript programmers should also note that when a JavaScript object is
copied to an array or map property, the \e contents of the object (that is,
diff --git a/src/qml/jsapi/qjsengine_p.h b/src/qml/jsapi/qjsengine_p.h
index 7866a5bdda..37376a1485 100644
--- a/src/qml/jsapi/qjsengine_p.h
+++ b/src/qml/jsapi/qjsengine_p.h
@@ -110,8 +110,8 @@ public:
QString uiLanguage;
// These methods may be called from the QML loader thread
- inline QQmlPropertyCache *cache(QObject *obj, int minorVersion = -1);
- inline QQmlPropertyCache *cache(const QMetaObject *, int minorVersion = -1);
+ inline QQmlPropertyCache *cache(QObject *obj, QTypeRevision version = QTypeRevision());
+ inline QQmlPropertyCache *cache(const QMetaObject *obj, QTypeRevision version = QTypeRevision());
};
QJSEnginePrivate::Locker::Locker(const QJSEngine *e)
@@ -161,14 +161,14 @@ and deleted before the loader thread has a chance to use or reference it. This
can't currently happen as the cache holds a reference to the
QQmlPropertyCache until the QQmlEngine is destroyed.
*/
-QQmlPropertyCache *QJSEnginePrivate::cache(QObject *obj, int minorVersion)
+QQmlPropertyCache *QJSEnginePrivate::cache(QObject *obj, QTypeRevision version)
{
if (!obj || QObjectPrivate::get(obj)->metaObject || QObjectPrivate::get(obj)->wasDeleted)
return nullptr;
Locker locker(this);
const QMetaObject *mo = obj->metaObject();
- return QQmlMetaType::propertyCache(mo, minorVersion);
+ return QQmlMetaType::propertyCache(mo, version);
}
/*!
@@ -180,12 +180,12 @@ exist for the lifetime of the QQmlEngine.
The returned cache is not referenced, so if it is to be stored, call addref().
*/
-QQmlPropertyCache *QJSEnginePrivate::cache(const QMetaObject *metaObject, int minorVersion)
+QQmlPropertyCache *QJSEnginePrivate::cache(const QMetaObject *metaObject, QTypeRevision version)
{
Q_ASSERT(metaObject);
Locker locker(this);
- return QQmlMetaType::propertyCache(metaObject, minorVersion);
+ return QQmlMetaType::propertyCache(metaObject, version);
}
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp
index 6c51b4cbcb..df9f117d04 100644
--- a/src/qml/jsruntime/qv4arrayobject.cpp
+++ b/src/qml/jsruntime/qv4arrayobject.cpp
@@ -362,7 +362,7 @@ ReturnedValue ArrayPrototype::method_toString(const FunctionObject *builtin, con
ScopedString string(scope, scope.engine->newString(QStringLiteral("join")));
ScopedFunctionObject f(scope, that->get(string));
if (f)
- return f->call(that, argv, argc);
+ return checkedResult(scope.engine, f->call(that, argv, argc));
return ObjectPrototype::method_toString(builtin, that, argv, argc);
}
@@ -1209,6 +1209,7 @@ ReturnedValue ArrayPrototype::method_every(const FunctionObject *b, const Value
arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
r = callback->call(that, arguments, 3);
+ CHECK_EXCEPTION();
ok = r->toBoolean();
}
return Encode(ok);
@@ -1276,6 +1277,7 @@ ReturnedValue ArrayPrototype::method_some(const FunctionObject *b, const Value *
arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
result = callback->call(that, arguments, 3);
+ CHECK_EXCEPTION();
if (result->toBoolean())
return Encode(true);
}
@@ -1345,6 +1347,7 @@ ReturnedValue ArrayPrototype::method_map(const FunctionObject *b, const Value *t
arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
mapped = callback->call(that, arguments, 3);
+ CHECK_EXCEPTION();
a->arraySet(k, mapped);
}
return a.asReturnedValue();
@@ -1380,6 +1383,7 @@ ReturnedValue ArrayPrototype::method_filter(const FunctionObject *b, const Value
arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
selected = callback->call(that, arguments, 3);
+ CHECK_EXCEPTION();
if (selected->toBoolean()) {
a->arraySet(to, arguments[0]);
++to;
@@ -1430,6 +1434,7 @@ ReturnedValue ArrayPrototype::method_reduce(const FunctionObject *b, const Value
arguments[2] = Value::fromDouble(k);
arguments[3] = instance;
acc = callback->call(nullptr, arguments, 4);
+ CHECK_EXCEPTION();
}
++k;
}
@@ -1483,6 +1488,7 @@ ReturnedValue ArrayPrototype::method_reduceRight(const FunctionObject *b, const
arguments[2] = Value::fromDouble(k - 1);
arguments[3] = instance;
acc = callback->call(nullptr, arguments, 4);
+ CHECK_EXCEPTION();
}
--k;
}
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index cc89947cec..bebcbd7e44 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -682,17 +682,17 @@ static inline QString ToTimeString(double t)
static inline QString ToLocaleString(double t)
{
- return ToDateTime(t, Qt::LocalTime).toString(Qt::DefaultLocaleShortDate);
+ return QLocale().toString(ToDateTime(t, Qt::LocalTime), QLocale::ShortFormat);
}
static inline QString ToLocaleDateString(double t)
{
- return ToDateTime(t, Qt::LocalTime).date().toString(Qt::DefaultLocaleShortDate);
+ return QLocale().toString(ToDateTime(t, Qt::LocalTime).date(), QLocale::ShortFormat);
}
static inline QString ToLocaleTimeString(double t)
{
- return ToDateTime(t, Qt::LocalTime).time().toString(Qt::DefaultLocaleShortDate);
+ return QLocale().toString(ToDateTime(t, Qt::LocalTime).time(), QLocale::ShortFormat);
}
static double getLocalTZA()
@@ -1561,7 +1561,7 @@ ReturnedValue DatePrototype::method_toJSON(const FunctionObject *b, const Value
if (!toIso)
return v4->throwTypeError();
- return toIso->call(O, nullptr, 0);
+ return checkedResult(v4, toIso->call(O, nullptr, 0));
}
ReturnedValue DatePrototype::method_symbolToPrimitive(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 86e178d568..1efe09c59f 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -1266,20 +1266,15 @@ QUrl ExecutionEngine::resolvedUrl(const QString &file)
void ExecutionEngine::markObjects(MarkStack *markStack)
{
- for (int i = 0; i < NClasses; ++i)
- if (classes[i]) {
- classes[i]->mark(markStack);
- if (markStack->top >= markStack->limit)
- markStack->drain();
- }
- markStack->drain();
+ for (int i = 0; i < NClasses; ++i) {
+ if (Heap::InternalClass *c = classes[i])
+ c->mark(markStack);
+ }
identifierTable->markObjects(markStack);
- for (auto compilationUnit: compilationUnits) {
+ for (auto compilationUnit: compilationUnits)
compilationUnit->markObjects(markStack);
- markStack->drain();
- }
}
ReturnedValue ExecutionEngine::throwError(const Value &value)
@@ -1512,12 +1507,41 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::Value &value, int
return QVariant::fromValue(QV4::JsonObject::toJsonArray(a));
}
+ QVariant retn;
#if QT_CONFIG(qml_sequence_object)
bool succeeded = false;
- QVariant retn = QV4::SequencePrototype::toVariant(value, typeHint, &succeeded);
+ retn = QV4::SequencePrototype::toVariant(value, typeHint, &succeeded);
if (succeeded)
return retn;
#endif
+ if (typeHint != -1) {
+ // the QVariant constructor will create a copy, so we have manually
+ // destroy the value returned by QMetaType::create
+ auto temp = QMetaType::create(typeHint);
+ retn = QVariant(typeHint, temp);
+ QMetaType::destroy(typeHint, temp);
+ auto retnAsIterable = retn.value<QtMetaTypePrivate::QSequentialIterableImpl>();
+ if (retnAsIterable._iteratorCapabilities & QtMetaTypePrivate::ContainerIsAppendable) {
+ auto const length = a->getLength();
+ QV4::ScopedValue arrayValue(scope);
+ for (qint64 i = 0; i < length; ++i) {
+ arrayValue = a->get(i);
+ QVariant asVariant = toVariant(e, arrayValue, retnAsIterable._metaType_id, false, visitedObjects);
+ auto originalType = asVariant.userType();
+ bool couldConvert = asVariant.convert(retnAsIterable._metaType_id);
+ if (!couldConvert) {
+ qWarning() << QLatin1String("Could not convert array value at position %1 from %2 to %3")
+ .arg(QString::number(i),
+ QString::fromUtf8(QMetaType::typeName(originalType)),
+ QString::fromUtf8(QMetaType::typeName(retnAsIterable._metaType_id)));
+ // create default constructed value
+ asVariant = QVariant(retnAsIterable._metaType_id, nullptr);
+ }
+ retnAsIterable.append(asVariant.constData());
+ }
+ return retn;
+ }
+ }
}
if (value.isUndefined())
@@ -1886,10 +1910,10 @@ QQmlRefPointer<ExecutableCompilationUnit> ExecutionEngine::compileModule(
sourceCode, sourceTimeStamp, &diagnostics);
for (const QQmlJS::DiagnosticMessage &m : diagnostics) {
if (m.isError()) {
- throwSyntaxError(m.message, url.toString(), m.line, m.column);
+ throwSyntaxError(m.message, url.toString(), m.loc.startLine, m.loc.startColumn);
return nullptr;
} else {
- qWarning() << url << ':' << m.line << ':' << m.column
+ qWarning() << url << ':' << m.loc.startLine << ':' << m.loc.startColumn
<< ": warning: " << m.message;
}
}
@@ -2331,9 +2355,11 @@ int ExecutionEngine::registerExtension()
return registrationData()->extensionCount++;
}
+#if QT_CONFIG(qml_network)
QNetworkAccessManager *QV4::detail::getNetworkAccessManager(ExecutionEngine *engine)
{
return engine->qmlEngine()->networkAccessManager();
}
+#endif // qml_network
QT_END_NAMESPACE
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h
index e0025feb00..efe44a324c 100644
--- a/src/qml/jsruntime/qv4engine_p.h
+++ b/src/qml/jsruntime/qv4engine_p.h
@@ -91,6 +91,7 @@ class PageAllocation;
QT_BEGIN_NAMESPACE
+#if QT_CONFIG(qml_network)
class QNetworkAccessManager;
namespace QV4 {
@@ -99,6 +100,9 @@ namespace detail {
QNetworkAccessManager *getNetworkAccessManager(ExecutionEngine *engine);
}
}
+#else
+namespace QV4 { struct QObjectMethod; }
+#endif // qml_network
// Used to allow a QObject method take and return raw V4 handles without having to expose
// 48 in the public API.
@@ -355,7 +359,9 @@ public:
FunctionObject *getStackFunction() const { return reinterpret_cast<FunctionObject *>(jsObjects + GetStack_Function); }
FunctionObject *thrower() const { return reinterpret_cast<FunctionObject *>(jsObjects + ThrowerObject); }
+#if QT_CONFIG(qml_network)
QNetworkAccessManager* (*networkAccessManager)(ExecutionEngine*) = detail::getNetworkAccessManager;
+#endif
enum JSStrings {
String_Empty,
diff --git a/src/qml/jsruntime/qv4executablecompilationunit.cpp b/src/qml/jsruntime/qv4executablecompilationunit.cpp
index fa4a1f1ce4..962b23fad6 100644
--- a/src/qml/jsruntime/qv4executablecompilationunit.cpp
+++ b/src/qml/jsruntime/qv4executablecompilationunit.cpp
@@ -817,7 +817,7 @@ QQmlRefPointer<QQmlPropertyCache> ResolvedTypeReference::createPropertyCache(QQm
if (typePropertyCache) {
return typePropertyCache;
} else if (type.isValid()) {
- typePropertyCache = QQmlEnginePrivate::get(engine)->cache(type.metaObject(), minorVersion);
+ typePropertyCache = QQmlEnginePrivate::get(engine)->cache(type.metaObject(), version);
return typePropertyCache;
} else {
Q_ASSERT(compilationUnit);
diff --git a/src/qml/jsruntime/qv4executablecompilationunit_p.h b/src/qml/jsruntime/qv4executablecompilationunit_p.h
index 8cad18a3dc..a748e0a762 100644
--- a/src/qml/jsruntime/qv4executablecompilationunit_p.h
+++ b/src/qml/jsruntime/qv4executablecompilationunit_p.h
@@ -182,8 +182,8 @@ public:
CompositeMetaTypeIds typeIdsForComponent(int objectid = 0) const;
- int metaTypeId = -1;
- int listMetaTypeId = -1;
+ QMetaType metaTypeId;
+ QMetaType listMetaTypeId;
bool isRegisteredWithEngine = false;
QHash<int, InlineComponentData> inlineComponentData;
@@ -326,17 +326,15 @@ private:
struct ResolvedTypeReference
{
ResolvedTypeReference()
- : majorVersion(0)
- , minorVersion(0)
- , isFullyDynamicType(false)
+ : version(QTypeRevision::zero())
+ , isFullyDynamicType(false)
{}
QQmlType type;
QQmlRefPointer<QQmlPropertyCache> typePropertyCache;
QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit;
- int majorVersion;
- int minorVersion;
+ QTypeRevision version;
// Types such as QQmlPropertyMap can add properties dynamically at run-time and
// therefore cannot have a property cache installed when instantiated.
bool isFullyDynamicType;
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index dfef52583e..cdb3b8942b 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -358,7 +358,7 @@ ReturnedValue FunctionPrototype::method_apply(const QV4::FunctionObject *b, cons
return v4->throwTypeError();
thisObject = argc ? argv : nullptr;
if (argc < 2 || argv[1].isNullOrUndefined())
- return f->call(thisObject, argv, 0);
+ return checkedResult(v4, f->call(thisObject, argv, 0));
Object *arr = argv[1].objectValue();
if (!arr)
@@ -398,13 +398,14 @@ ReturnedValue FunctionPrototype::method_apply(const QV4::FunctionObject *b, cons
}
}
- return f->call(thisObject, arguments, len);
+ return checkedResult(v4, f->call(thisObject, arguments, len));
}
ReturnedValue FunctionPrototype::method_call(const QV4::FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
{
+ QV4::ExecutionEngine *v4 = b->engine();
if (!thisObject->isFunctionObject())
- return b->engine()->throwTypeError();
+ return v4->throwTypeError();
const FunctionObject *f = static_cast<const FunctionObject *>(thisObject);
@@ -413,7 +414,7 @@ ReturnedValue FunctionPrototype::method_call(const QV4::FunctionObject *b, const
++argv;
--argc;
}
- return f->call(thisObject, argv, argc);
+ return checkedResult(v4, f->call(thisObject, argv, argc));
}
ReturnedValue FunctionPrototype::method_bind(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc)
@@ -713,12 +714,12 @@ void Heap::BoundFunction::init(QV4::ExecutionContext *scope, QV4::FunctionObject
ReturnedValue BoundFunction::virtualCall(const FunctionObject *fo, const Value *, const Value *argv, int argc)
{
- const BoundFunction *f = static_cast<const BoundFunction *>(fo);
- Scope scope(f->engine());
-
- if (scope.hasException())
+ QV4::ExecutionEngine *v4 = fo->engine();
+ if (v4->hasException)
return Encode::undefined();
+ const BoundFunction *f = static_cast<const BoundFunction *>(fo);
+ Scope scope(v4);
Scoped<MemberData> boundArgs(scope, f->boundArgs());
ScopedFunctionObject target(scope, f->target());
JSCallData jsCallData(scope, (boundArgs ? boundArgs->size() : 0) + argc);
@@ -729,7 +730,7 @@ ReturnedValue BoundFunction::virtualCall(const FunctionObject *fo, const Value *
argp += boundArgs->size();
}
memcpy(argp, argv, argc*sizeof(Value));
- return target->call(jsCallData);
+ return checkedResult(v4, target->call(jsCallData));
}
ReturnedValue BoundFunction::virtualCallAsConstructor(const FunctionObject *fo, const Value *argv, int argc, const Value *)
diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h
index c99cad8e33..78be58c60a 100644
--- a/src/qml/jsruntime/qv4functionobject_p.h
+++ b/src/qml/jsruntime/qv4functionobject_p.h
@@ -328,6 +328,10 @@ inline bool FunctionObject::isBoundFunction() const
return d()->vtable() == BoundFunction::staticVTable();
}
+inline ReturnedValue checkedResult(QV4::ExecutionEngine *v4, ReturnedValue result)
+{
+ return v4->hasException ? QV4::Encode::undefined() : result;
+}
}
diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp
index 64ca719e29..92face6f94 100644
--- a/src/qml/jsruntime/qv4include.cpp
+++ b/src/qml/jsruntime/qv4include.cpp
@@ -163,7 +163,7 @@ void QV4Include::finished()
QV4::Scope scope(v4);
QV4::ScopedObject resultObj(scope, m_resultObject.value());
QV4::ScopedString status(scope, v4->newString(QStringLiteral("status")));
- if (m_reply->networkError() == QNetworkReply::NoError) {
+ if (m_reply->error() == QNetworkReply::NoError) {
QByteArray data = m_reply->readAll();
QString code = QString::fromUtf8(data);
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp
index 936c032fad..ce759111f4 100644
--- a/src/qml/jsruntime/qv4jsonobject.cpp
+++ b/src/qml/jsruntime/qv4jsonobject.cpp
@@ -703,6 +703,8 @@ QString Stringify::Str(const QString &key, const Value &v)
*jsCallData->thisObject = value;
jsCallData->args[0] = v4->newString(key);
value = toJSON->call(jsCallData);
+ if (v4->hasException)
+ return QString();
}
}
@@ -714,6 +716,8 @@ QString Stringify::Str(const QString &key, const Value &v)
jsCallData->args[1] = value;
*jsCallData->thisObject = holder;
value = replacerFunction->call(jsCallData);
+ if (v4->hasException)
+ return QString();
}
o = value->asReturnedValue();
diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp
index 0cda6b864a..d3ea50867a 100644
--- a/src/qml/jsruntime/qv4lookup.cpp
+++ b/src/qml/jsruntime/qv4lookup.cpp
@@ -309,7 +309,8 @@ ReturnedValue Lookup::getterAccessor(Lookup *l, ExecutionEngine *engine, const V
if (!getter->isFunctionObject()) // ### catch at resolve time
return Encode::undefined();
- return static_cast<const FunctionObject *>(getter)->call(&object, nullptr, 0);
+ return checkedResult(engine, static_cast<const FunctionObject *>(getter)->call(
+ &object, nullptr, 0));
}
}
l->getter = getterFallback;
@@ -326,7 +327,8 @@ ReturnedValue Lookup::getterProtoAccessor(Lookup *l, ExecutionEngine *engine, co
if (!getter->isFunctionObject()) // ### catch at resolve time
return Encode::undefined();
- return static_cast<const FunctionObject *>(getter)->call(&object, nullptr, 0);
+ return checkedResult(engine, static_cast<const FunctionObject *>(getter)->call(
+ &object, nullptr, 0));
}
return getterTwoClasses(l, engine, object);
}
@@ -346,7 +348,8 @@ ReturnedValue Lookup::getterProtoAccessorTwoClasses(Lookup *l, ExecutionEngine *
if (!getter->isFunctionObject()) // ### catch at resolve time
return Encode::undefined();
- return static_cast<const FunctionObject *>(getter)->call(&object, nullptr, 0);
+ return checkedResult(engine, static_cast<const FunctionObject *>(getter)->call(
+ &object, nullptr, 0));
}
}
l->getter = getterFallback;
@@ -391,7 +394,8 @@ ReturnedValue Lookup::primitiveGetterAccessor(Lookup *l, ExecutionEngine *engine
if (!getter->isFunctionObject()) // ### catch at resolve time
return Encode::undefined();
- return static_cast<const FunctionObject *>(getter)->call(&object, nullptr, 0);
+ return checkedResult(engine, static_cast<const FunctionObject *>(getter)->call(
+ &object, nullptr, 0));
}
}
l->getter = getterGeneric;
@@ -429,7 +433,8 @@ ReturnedValue Lookup::globalGetterProtoAccessor(Lookup *l, ExecutionEngine *engi
if (!getter->isFunctionObject()) // ### catch at resolve time
return Encode::undefined();
- return static_cast<const FunctionObject *>(getter)->call(engine->globalObject, nullptr, 0);
+ return checkedResult(engine, static_cast<const FunctionObject *>(getter)->call(
+ engine->globalObject, nullptr, 0));
}
l->globalGetter = globalGetterGeneric;
return globalGetterGeneric(l, engine);
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index 89161433ed..b723141caa 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -105,7 +105,7 @@ ReturnedValue Object::getValueAccessor(const Value *thisObject, const Value &v,
JSCallData jsCallData(scope);
if (thisObject)
*jsCallData->thisObject = *thisObject;
- return f->call(jsCallData);
+ return checkedResult(scope.engine, f->call(jsCallData));
}
bool Object::putValue(uint memberIndex, PropertyAttributes attrs, const Value &value)
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp
index 7d910a1cbc..0c8cc192fc 100644
--- a/src/qml/jsruntime/qv4objectproto.cpp
+++ b/src/qml/jsruntime/qv4objectproto.cpp
@@ -667,7 +667,7 @@ ReturnedValue ObjectPrototype::method_toLocaleString(const FunctionObject *b, co
if (!f)
THROW_TYPE_ERROR();
- return f->call(thisObject, argv, argc);
+ return checkedResult(scope.engine, f->call(thisObject, argv, argc));
}
ReturnedValue ObjectPrototype::method_valueOf(const FunctionObject *b, const Value *thisObject, const Value *, int)
diff --git a/src/qml/jsruntime/qv4persistent.cpp b/src/qml/jsruntime/qv4persistent.cpp
index 79c372348f..f4901e3e4d 100644
--- a/src/qml/jsruntime/qv4persistent.cpp
+++ b/src/qml/jsruntime/qv4persistent.cpp
@@ -240,7 +240,6 @@ void PersistentValueStorage::mark(MarkStack *markStack)
if (Managed *m = p->values[i].as<Managed>())
m->mark(markStack);
}
- markStack->drain();
p = p->header.next;
}
diff --git a/src/qml/jsruntime/qv4promiseobject.cpp b/src/qml/jsruntime/qv4promiseobject.cpp
index 17d218a6eb..ecaff72b22 100644
--- a/src/qml/jsruntime/qv4promiseobject.cpp
+++ b/src/qml/jsruntime/qv4promiseobject.cpp
@@ -618,7 +618,7 @@ ReturnedValue PromiseCtor::method_all(const FunctionObject *f, const Value *this
}
ScopedObject nextPromise(scope, Value::fromReturnedValue(resolve->call(thisObject, nextValue, 1)));
- if (!nextPromise || scope.hasException()) {
+ if (scope.hasException() || !nextPromise) {
ScopedValue completion(scope, Runtime::IteratorClose::call(e, iteratorObject, doneValue));
if (scope.hasException()) {
completion = e->exceptionValue->asReturnedValue();
@@ -764,7 +764,7 @@ ReturnedValue PromiseCtor::method_race(const FunctionObject *f, const Value *thi
}
ScopedObject nextPromise(scope, Value::fromReturnedValue(resolve->call(thisObject, nextValue, 1)));
- if (!nextPromise || scope.hasException()) {
+ if (scope.hasException() || !nextPromise) {
ScopedValue completion(scope, Runtime::IteratorClose::call(e, iteratorObject, doneValue));
if (scope.hasException()) {
completion = e->exceptionValue->asReturnedValue();
diff --git a/src/qml/jsruntime/qv4proxy.cpp b/src/qml/jsruntime/qv4proxy.cpp
index 51f96b9003..24676ffd00 100644
--- a/src/qml/jsruntime/qv4proxy.cpp
+++ b/src/qml/jsruntime/qv4proxy.cpp
@@ -96,6 +96,8 @@ ReturnedValue ProxyObject::virtualGet(const Managed *m, PropertyKey id, const Va
cdata.args[2] = *receiver;
ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
+ if (scope.engine->hasException)
+ return Encode::undefined();
ScopedProperty targetDesc(scope);
PropertyAttributes attributes = target->getOwnProperty(id, targetDesc);
if (attributes != Attr_Invalid && !attributes.isConfigurable()) {
@@ -136,7 +138,7 @@ bool ProxyObject::virtualPut(Managed *m, PropertyKey id, const Value &value, Val
cdata.args[3] = *receiver;
ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
- if (!trapResult->toBoolean())
+ if (scope.engine->hasException || !trapResult->toBoolean())
return false;
ScopedProperty targetDesc(scope);
PropertyAttributes attributes = target->getOwnProperty(id, targetDesc);
@@ -176,7 +178,7 @@ bool ProxyObject::virtualDeleteProperty(Managed *m, PropertyKey id)
cdata.args[2] = o->d(); // ### fix receiver handling
ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
- if (!trapResult->toBoolean())
+ if (scope.engine->hasException || !trapResult->toBoolean())
return false;
ScopedProperty targetDesc(scope);
PropertyAttributes attributes = target->getOwnProperty(id, targetDesc);
@@ -211,6 +213,8 @@ bool ProxyObject::virtualHasProperty(const Managed *m, PropertyKey id)
cdata.args[1] = id.isArrayIndex() ? Value::fromUInt32(id.asArrayIndex()).toString(scope.engine) : id.asStringOrSymbol();
ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
+ if (scope.engine->hasException)
+ return false;
bool result = trapResult->toBoolean();
if (!result) {
ScopedProperty targetDesc(scope);
@@ -251,6 +255,8 @@ PropertyAttributes ProxyObject::virtualGetOwnProperty(const Managed *m, Property
cdata.args[1] = id.isArrayIndex() ? Value::fromUInt32(id.asArrayIndex()).toString(scope.engine) : id.asStringOrSymbol();
ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
+ if (scope.engine->hasException)
+ return Attr_Invalid;
if (!trapResult->isObject() && !trapResult->isUndefined()) {
scope.engine->throwTypeError();
return Attr_Invalid;
@@ -323,7 +329,7 @@ bool ProxyObject::virtualDefineOwnProperty(Managed *m, PropertyKey id, const Pro
cdata.args[2] = ObjectPrototype::fromPropertyDescriptor(scope.engine, p, attrs);
ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
- bool result = trapResult->toBoolean();
+ bool result = !scope.engine->hasException && trapResult->toBoolean();
if (!result)
return false;
@@ -373,6 +379,8 @@ bool ProxyObject::virtualIsExtensible(const Managed *m)
cdata.args[0] = target;
ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
+ if (scope.engine->hasException)
+ return false;
bool result = trapResult->toBoolean();
if (result != target->isExtensible()) {
scope.engine->throwTypeError();
@@ -404,6 +412,8 @@ bool ProxyObject::virtualPreventExtensions(Managed *m)
cdata.args[0] = target;
ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
+ if (scope.engine->hasException)
+ return false;
bool result = trapResult->toBoolean();
if (result && target->isExtensible()) {
scope.engine->throwTypeError();
@@ -439,6 +449,8 @@ Heap::Object *ProxyObject::virtualGetPrototypeOf(const Managed *m)
cdata.args[0] = target;
ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
+ if (scope.engine->hasException)
+ return nullptr;
if (!trapResult->isNull() && !trapResult->isObject()) {
scope.engine->throwTypeError();
return nullptr;
@@ -482,7 +494,7 @@ bool ProxyObject::virtualSetPrototypeOf(Managed *m, const Object *p)
cdata.args[1] = p ? p->asReturnedValue() : Encode::null();
ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
- bool result = trapResult->toBoolean();
+ bool result = !scope.engine->hasException && trapResult->toBoolean();
if (!result)
return false;
if (!target->isExtensible()) {
@@ -573,6 +585,8 @@ OwnPropertyKeyIterator *ProxyObject::virtualOwnPropertyKeys(const Object *m, Val
JSCallData cdata(scope, 1, nullptr, handler);
cdata.args[0] = target;
ScopedObject trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata));
+ if (scope.engine->hasException)
+ return nullptr;
if (!trapResult) {
scope.engine->throwTypeError();
return nullptr;
@@ -699,7 +713,7 @@ ReturnedValue ProxyFunctionObject::virtualCall(const FunctionObject *f, const Va
if (scope.hasException())
return Encode::undefined();
if (trap->isNullOrUndefined())
- return target->call(thisObject, argv, argc);
+ return checkedResult(scope.engine, target->call(thisObject, argv, argc));
if (!trap->isFunctionObject())
return scope.engine->throwTypeError();
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index 9613d064c4..66b79aa0e8 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -638,10 +638,11 @@ void QObjectWrapper::markWrapper(QObject *object, MarkStack *markStack)
if (!ddata)
return;
- if (ddata->jsEngineId == markStack->engine->m_engineId)
+ const QV4::ExecutionEngine *engine = markStack->engine();
+ if (ddata->jsEngineId == engine->m_engineId)
ddata->jsWrapper.markOnce(markStack);
- else if (markStack->engine->m_multiplyWrappedQObjects && ddata->hasTaintedV4Object)
- markStack->engine->m_multiplyWrappedQObjects->mark(object, markStack);
+ else if (engine->m_multiplyWrappedQObjects && ddata->hasTaintedV4Object)
+ engine->m_multiplyWrappedQObjects->mark(object, markStack);
}
void QObjectWrapper::setProperty(ExecutionEngine *engine, int propertyIndex, const Value &value)
diff --git a/src/qml/jsruntime/qv4reflect.cpp b/src/qml/jsruntime/qv4reflect.cpp
index 0772770d63..2a6c61f044 100644
--- a/src/qml/jsruntime/qv4reflect.cpp
+++ b/src/qml/jsruntime/qv4reflect.cpp
@@ -98,7 +98,8 @@ ReturnedValue Reflect::method_apply(const FunctionObject *f, const Value *, cons
if (scope.hasException())
return Encode::undefined();
- return static_cast<const FunctionObject &>(argv[0]).call(&argv[1], arguments.argv, arguments.argc);
+ return checkedResult(scope.engine, static_cast<const FunctionObject &>(argv[0]).call(
+ &argv[1], arguments.argv, arguments.argc));
}
ReturnedValue Reflect::method_construct(const FunctionObject *f, const Value *, const Value *argv, int argc)
diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp
index f1375e4ca4..a8a37cda37 100644
--- a/src/qml/jsruntime/qv4regexpobject.cpp
+++ b/src/qml/jsruntime/qv4regexpobject.cpp
@@ -481,6 +481,8 @@ ReturnedValue RegExpPrototype::exec(ExecutionEngine *engine, const Object *o, co
ScopedFunctionObject exec(scope, o->get(key));
if (exec) {
ScopedValue result(scope, exec->call(o, s, 1));
+ if (scope.hasException())
+ RETURN_UNDEFINED();
if (!result->isNull() && !result->isObject())
return scope.engine->throwTypeError();
return result->asReturnedValue();
@@ -737,6 +739,8 @@ ReturnedValue RegExpPrototype::method_replace(const FunctionObject *f, const Val
cData->args[nCaptures + 1] = Encode(position);
cData->args[nCaptures + 2] = s;
ScopedValue replValue(scope, replaceFunction->call(cData));
+ if (scope.hasException())
+ return Encode::undefined();
replacement = replValue->toQString();
} else {
replacement = RegExp::getSubstitution(matchString->toQString(), s->toQString(), position, cData.args, nCaptures, replaceValue->toQString());
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index e47a7a0b46..5fc94b9ddd 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -390,7 +390,7 @@ QV4::ReturnedValue Runtime::Instanceof::call(ExecutionEngine *engine, const Valu
return engine->throwTypeError();
ScopedValue result(scope, fHasInstance->call(&rval, &lval, 1));
- return Encode(result->toBoolean());
+ return scope.hasException() ? Encode::undefined() : Encode(result->toBoolean());
}
QV4::ReturnedValue Runtime::In::call(ExecutionEngine *engine, const Value &left, const Value &right)
@@ -515,6 +515,8 @@ ReturnedValue RuntimeHelpers::ordinaryToPrimitive(ExecutionEngine *engine, const
ScopedValue conv(scope, object->get(meth1));
if (FunctionObject *o = conv->as<FunctionObject>()) {
result = o->call(object, nullptr, 0);
+ if (engine->hasException)
+ return Encode::undefined();
if (result->isPrimitive())
return result->asReturnedValue();
}
@@ -525,6 +527,8 @@ ReturnedValue RuntimeHelpers::ordinaryToPrimitive(ExecutionEngine *engine, const
conv = object->get(meth2);
if (FunctionObject *o = conv->as<FunctionObject>()) {
result = o->call(object, nullptr, 0);
+ if (engine->hasException)
+ return Encode::undefined();
if (result->isPrimitive())
return result->asReturnedValue();
}
@@ -800,6 +804,8 @@ ReturnedValue Runtime::GetIterator::call(ExecutionEngine *engine, const Value &i
return engine->throwTypeError();
JSCallData cData(scope, 0, nullptr, o);
ScopedObject it(scope, f->call(cData));
+ if (engine->hasException)
+ return Encode::undefined();
if (!it)
return engine->throwTypeError();
return it->asReturnedValue();
@@ -1341,7 +1347,8 @@ ReturnedValue Runtime::CallGlobalLookup::call(ExecutionEngine *engine, uint inde
engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[l->nameIndex]->toQString());
}
- return static_cast<FunctionObject &>(function).call(&thisObject, argv, argc);
+ return checkedResult(engine, static_cast<FunctionObject &>(function).call(
+ &thisObject, argv, argc));
}
ReturnedValue Runtime::CallQmlContextPropertyLookup::call(ExecutionEngine *engine, uint index,
@@ -1356,7 +1363,8 @@ ReturnedValue Runtime::CallQmlContextPropertyLookup::call(ExecutionEngine *engin
engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[l->nameIndex]->toQString());
}
- return static_cast<FunctionObject &>(function).call(thisObject, argv, argc);
+ return checkedResult(engine, static_cast<FunctionObject &>(function).call(
+ thisObject, argv, argc));
}
ReturnedValue Runtime::CallPossiblyDirectEval::call(ExecutionEngine *engine, Value *argv, int argc)
@@ -1375,7 +1383,7 @@ ReturnedValue Runtime::CallPossiblyDirectEval::call(ExecutionEngine *engine, Val
if (function->d() == engine->evalFunction()->d())
return static_cast<EvalFunction *>(function.getPointer())->evalCall(thisObject, argv, argc, true);
- return function->call(thisObject, argv, argc);
+ return checkedResult(engine, function->call(thisObject, argv, argc));
}
ReturnedValue Runtime::CallName::call(ExecutionEngine *engine, int nameIndex, Value *argv, int argc)
@@ -1395,7 +1403,7 @@ ReturnedValue Runtime::CallName::call(ExecutionEngine *engine, int nameIndex, Va
->runtimeStrings[nameIndex]->toQString());
}
- return f->call(thisObject, argv, argc);
+ return checkedResult(engine, f->call(thisObject, argv, argc));
}
ReturnedValue Runtime::CallProperty::call(ExecutionEngine *engine, const Value &baseRef, int nameIndex, Value *argv, int argc)
@@ -1437,7 +1445,7 @@ ReturnedValue Runtime::CallProperty::call(ExecutionEngine *engine, const Value &
return engine->throwTypeError(error);
}
- return f->call(base, argv, argc);
+ return checkedResult(engine, f->call(base, argv, argc));
}
ReturnedValue Runtime::CallPropertyLookup::call(ExecutionEngine *engine, const Value &base, uint index, Value *argv, int argc)
@@ -1449,7 +1457,7 @@ ReturnedValue Runtime::CallPropertyLookup::call(ExecutionEngine *engine, const V
if (!f.isFunctionObject())
return engine->throwTypeError();
- return static_cast<FunctionObject &>(f).call(&base, argv, argc);
+ return checkedResult(engine, static_cast<FunctionObject &>(f).call(&base, argv, argc));
}
ReturnedValue Runtime::CallElement::call(ExecutionEngine *engine, const Value &baseRef, const Value &index, Value *argv, int argc)
@@ -1467,7 +1475,7 @@ ReturnedValue Runtime::CallElement::call(ExecutionEngine *engine, const Value &b
if (!f)
return engine->throwTypeError();
- return f->call(base, argv, argc);
+ return checkedResult(engine, f->call(base, argv, argc));
}
ReturnedValue Runtime::CallValue::call(ExecutionEngine *engine, const Value &func, Value *argv, int argc)
@@ -1475,7 +1483,8 @@ ReturnedValue Runtime::CallValue::call(ExecutionEngine *engine, const Value &fun
if (!func.isFunctionObject())
return engine->throwTypeError(QStringLiteral("%1 is not a function").arg(func.toQStringNoThrow()));
Value undef = Value::undefinedValue();
- return static_cast<const FunctionObject &>(func).call(&undef, argv, argc);
+ return checkedResult(engine, static_cast<const FunctionObject &>(func).call(
+ &undef, argv, argc));
}
ReturnedValue Runtime::CallWithReceiver::call(ExecutionEngine *engine, const Value &func,
@@ -1483,7 +1492,8 @@ ReturnedValue Runtime::CallWithReceiver::call(ExecutionEngine *engine, const Val
{
if (!func.isFunctionObject())
return engine->throwTypeError(QStringLiteral("%1 is not a function").arg(func.toQStringNoThrow()));
- return static_cast<const FunctionObject &>(func).call(&thisObject, argv, argc);
+ return checkedResult(engine, static_cast<const FunctionObject &>(func).call(
+ &thisObject, argv, argc));
}
struct CallArgs {
@@ -1537,7 +1547,8 @@ ReturnedValue Runtime::CallWithSpread::call(ExecutionEngine *engine, const Value
if (engine->hasException)
return Encode::undefined();
- return static_cast<const FunctionObject &>(function).call(&thisObject, arguments.argv, arguments.argc);
+ return checkedResult(engine, static_cast<const FunctionObject &>(function).call(
+ &thisObject, arguments.argv, arguments.argc));
}
ReturnedValue Runtime::Construct::call(ExecutionEngine *engine, const Value &function, const Value &newTarget, Value *argv, int argc)
@@ -1580,7 +1591,7 @@ ReturnedValue Runtime::TailCall::call(CppStackFrame *frame, ExecutionEngine *eng
if (!frame->callerCanHandleTailCall || !fo.canBeTailCalled() || engine->debugger()
|| unsigned(argc) > fo.formalParameterCount()) {
// Cannot tailcall, do a normal call:
- return fo.call(&thisObject, argv, argc);
+ return checkedResult(engine, fo.call(&thisObject, argv, argc));
}
memcpy(frame->jsFrame->args, argv, argc * sizeof(Value));
diff --git a/src/qml/jsruntime/qv4runtimecodegen.cpp b/src/qml/jsruntime/qv4runtimecodegen.cpp
index 162d75db63..b7737982b7 100644
--- a/src/qml/jsruntime/qv4runtimecodegen.cpp
+++ b/src/qml/jsruntime/qv4runtimecodegen.cpp
@@ -67,7 +67,7 @@ void RuntimeCodegen::generateFromFunctionExpression(const QString &fileName,
_module->rootContext = _module->functions.at(index);
}
-void RuntimeCodegen::throwSyntaxError(const AST::SourceLocation &loc, const QString &detail)
+void RuntimeCodegen::throwSyntaxError(const SourceLocation &loc, const QString &detail)
{
if (hasError())
return;
@@ -76,7 +76,7 @@ void RuntimeCodegen::throwSyntaxError(const AST::SourceLocation &loc, const QStr
engine->throwSyntaxError(detail, _module->fileName, loc.startLine, loc.startColumn);
}
-void RuntimeCodegen::throwReferenceError(const AST::SourceLocation &loc, const QString &detail)
+void RuntimeCodegen::throwReferenceError(const SourceLocation &loc, const QString &detail)
{
if (hasError())
return;
diff --git a/src/qml/jsruntime/qv4runtimecodegen_p.h b/src/qml/jsruntime/qv4runtimecodegen_p.h
index 71aaf1fb55..d3a30ce35d 100644
--- a/src/qml/jsruntime/qv4runtimecodegen_p.h
+++ b/src/qml/jsruntime/qv4runtimecodegen_p.h
@@ -69,8 +69,8 @@ public:
QQmlJS::AST::FunctionExpression *ast,
Compiler::Module *module);
- void throwSyntaxError(const QQmlJS::AST::SourceLocation &loc, const QString &detail) override;
- void throwReferenceError(const QQmlJS::AST::SourceLocation &loc, const QString &detail) override;
+ void throwSyntaxError(const QQmlJS::SourceLocation &loc, const QString &detail) override;
+ void throwReferenceError(const QQmlJS::SourceLocation &loc, const QString &detail) override;
private:
ExecutionEngine *engine;
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index 2fab9e4b7b..2add1222ea 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -52,6 +52,7 @@
#include <private/qqmljsparser_p.h>
#include <private/qqmljsast_p.h>
#include <private/qqmlengine_p.h>
+#include <private/qqmlsourcecoordinate_p.h>
#include <private/qv4profiling_p.h>
#include <qv4runtimecodegen_p.h>
@@ -109,10 +110,10 @@ void Script::parse()
const auto diagnosticMessages = parser.diagnosticMessages();
for (const DiagnosticMessage &m : diagnosticMessages) {
if (m.isError()) {
- valueScope.engine->throwSyntaxError(m.message, sourceFile, m.line, m.column);
+ valueScope.engine->throwSyntaxError(m.message, sourceFile, m.loc.startLine, m.loc.startColumn);
return;
} else {
- qWarning() << sourceFile << ':' << m.line << ':' << m.column
+ qWarning() << sourceFile << ':' << m.loc.startLine << ':' << m.loc.startColumn
<< ": warning: " << m.message;
}
}
@@ -209,8 +210,8 @@ QV4::CompiledData::CompilationUnit Script::precompile(
const auto v4Error = cg.error();
QQmlError error;
error.setUrl(cg.url());
- error.setLine(v4Error.line);
- error.setColumn(v4Error.column);
+ error.setLine(qmlConvertSourceCoordinate<quint32, int>(v4Error.loc.startLine));
+ error.setColumn(qmlConvertSourceCoordinate<quint32, int>(v4Error.loc.startColumn));
error.setDescription(v4Error.message);
reportedErrors->append(error);
}
diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp
index 9b4a2d575e..209a1b4e76 100644
--- a/src/qml/jsruntime/qv4stringobject.cpp
+++ b/src/qml/jsruntime/qv4stringobject.cpp
@@ -591,7 +591,7 @@ ReturnedValue StringPrototype::method_match(const FunctionObject *b, const Value
ScopedFunctionObject match(scope, that->get(scope.engine->symbol_match()));
if (!match)
return scope.engine->throwTypeError();
- return match->call(that, s, 1);
+ return checkedResult(scope.engine, match->call(that, s, 1));
}
ReturnedValue StringPrototype::method_normalize(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp
index 40a434d301..f425c6c87f 100644
--- a/src/qml/jsruntime/qv4typedarray.cpp
+++ b/src/qml/jsruntime/qv4typedarray.cpp
@@ -763,6 +763,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_every(const FunctionObject *b
arguments[1] = Value::fromDouble(k);
arguments[2] = v;
r = callback->call(that, arguments, 3);
+ CHECK_EXCEPTION();
ok = r->toBoolean();
}
return Encode(ok);
@@ -862,6 +863,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_filter(const FunctionObject *
arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
selected = callback->call(that, arguments, 3);
+ CHECK_EXCEPTION();
if (selected->toBoolean()) {
++arguments;
scope.alloc(1);
@@ -1194,6 +1196,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_map(const FunctionObject *b,
arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
mapped = callback->call(that, arguments, 3);
+ CHECK_EXCEPTION();
a->put(k, mapped);
}
return a->asReturnedValue();
@@ -1243,6 +1246,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_reduce(const FunctionObject *
arguments[2] = Value::fromDouble(k);
arguments[3] = instance;
acc = callback->call(nullptr, arguments, 4);
+ CHECK_EXCEPTION();
}
++k;
}
@@ -1298,6 +1302,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_reduceRight(const FunctionObj
arguments[2] = Value::fromDouble(k - 1);
arguments[3] = instance;
acc = callback->call(nullptr, arguments, 4);
+ CHECK_EXCEPTION();
}
--k;
}
@@ -1359,6 +1364,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_some(const FunctionObject *b,
arguments[1] = Value::fromDouble(k);
arguments[2] = instance;
result = callback->call(that, arguments, 3);
+ CHECK_EXCEPTION();
if (result->toBoolean())
return Encode(true);
}
diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp
index d29b060b9e..3449603a8a 100644
--- a/src/qml/jsruntime/qv4value.cpp
+++ b/src/qml/jsruntime/qv4value.cpp
@@ -250,6 +250,8 @@ bool Value::sameValue(Value other) const {
if (isDouble() && other.isInteger())
return other.int_32() ? (doubleValue() == double(other.int_32()))
: (doubleValue() == 0 && !std::signbit(doubleValue()));
+ if (isManaged())
+ return other.isManaged() && cast<Managed>()->isEqualTo(other.cast<Managed>());
return false;
}
@@ -269,6 +271,8 @@ bool Value::sameValueZero(Value other) const {
return true;
}
}
+ if (isManaged())
+ return other.isManaged() && cast<Managed>()->isEqualTo(other.cast<Managed>());
return false;
}
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index ae12033eb4..42e97b1d36 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -537,29 +537,8 @@ struct ValueArray {
}
void mark(MarkStack *markStack) {
- Value *v = values;
- const Value *end = v + alloc;
- if (alloc > 32*1024) {
- // drain from time to time to avoid overflows in the js stack
- Value::HeapBasePtr *currentBase = markStack->top;
- while (v < end) {
- v->mark(markStack);
- ++v;
- if (markStack->top >= currentBase + 32*1024) {
- Value::HeapBasePtr *oldBase = markStack->base;
- markStack->base = currentBase;
- markStack->drain();
- markStack->base = oldBase;
- }
- }
- } else {
- while (v < end) {
- v->mark(markStack);
- if (markStack->top >= markStack->limit)
- markStack->drain();
- ++v;
- }
- }
+ for (Value *v = values, *end = values + alloc; v < end; ++v)
+ v->mark(markStack);
}
};
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp
index 35b2ff2749..3ed1bc48fd 100644
--- a/src/qml/memory/qv4mm.cpp
+++ b/src/qml/memory/qv4mm.cpp
@@ -848,16 +848,18 @@ Heap::Object *MemoryManager::allocObjectWithMemberData(const QV4::VTable *vtable
static uint markStackSize = 0;
MarkStack::MarkStack(ExecutionEngine *engine)
- : engine(engine)
+ : m_engine(engine)
{
- base = (Heap::Base **)engine->gcStack->base();
- top = base;
- limit = base + engine->maxGCStackSize()/sizeof(Heap::Base)*3/4;
+ m_base = (Heap::Base **)engine->gcStack->base();
+ m_top = m_base;
+ const size_t size = engine->maxGCStackSize() / sizeof(Heap::Base);
+ m_hardLimit = m_base + size;
+ m_softLimit = m_base + size * 3 / 4;
}
void MarkStack::drain()
{
- while (top > base) {
+ while (m_top > m_base) {
Heap::Base *h = pop();
++markStackSize;
Q_ASSERT(h); // at this point we should only have Heap::Base objects in this area on the stack. If not, weird things might happen.
@@ -904,20 +906,15 @@ void MemoryManager::collectRoots(MarkStack *markStack)
if (keepAlive)
qobjectWrapper->mark(markStack);
-
- if (markStack->top >= markStack->limit)
- markStack->drain();
}
}
void MemoryManager::mark()
{
markStackSize = 0;
-
MarkStack markStack(engine);
collectRoots(&markStack);
-
- markStack.drain();
+ // dtor of MarkStack drains
}
void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPtr)
@@ -1220,8 +1217,6 @@ void MemoryManager::collectFromJSStack(MarkStack *markStack) const
Q_ASSERT(m->inUse());
// Skip pointers to already freed objects, they are bogus as well
m->mark(markStack);
- if (markStack->top >= markStack->limit)
- markStack->drain();
}
++v;
}
diff --git a/src/qml/memory/qv4mmdefs_p.h b/src/qml/memory/qv4mmdefs_p.h
index 8a53492822..117e8f4360 100644
--- a/src/qml/memory/qv4mmdefs_p.h
+++ b/src/qml/memory/qv4mmdefs_p.h
@@ -53,6 +53,7 @@
#include <private/qv4global_p.h>
#include <private/qv4runtimeapi_p.h>
#include <QtCore/qalgorithms.h>
+#include <QtCore/qmath.h>
#include <qdebug.h>
QT_BEGIN_NAMESPACE
@@ -270,22 +271,41 @@ Q_STATIC_ASSERT(sizeof(HeapItem) == Chunk::SlotSize);
Q_STATIC_ASSERT(QT_POINTER_SIZE*8 == Chunk::Bits);
Q_STATIC_ASSERT((1 << Chunk::BitShift) == Chunk::Bits);
-struct MarkStack {
+struct Q_QML_PRIVATE_EXPORT MarkStack {
MarkStack(ExecutionEngine *engine);
- Heap::Base **top = nullptr;
- Heap::Base **base = nullptr;
- Heap::Base **limit = nullptr;
- ExecutionEngine *engine;
+ ~MarkStack() { drain(); }
+
void push(Heap::Base *m) {
- *top = m;
- ++top;
- }
- Heap::Base *pop() {
- --top;
- return *top;
+ *(m_top++) = m;
+
+ if (m_top < m_softLimit)
+ return;
+
+ // If at or above soft limit, partition the remaining space into at most 64 segments and
+ // allow one C++ recursion of drain() per segment, plus one for the fence post.
+ const quintptr segmentSize = qNextPowerOfTwo(quintptr(m_hardLimit - m_softLimit) / 64u);
+ if (m_drainRecursion * segmentSize <= quintptr(m_top - m_softLimit)) {
+ ++m_drainRecursion;
+ drain();
+ --m_drainRecursion;
+ } else if (m_top == m_hardLimit) {
+ qFatal("GC mark stack overrun. Either simplify your application or"
+ "increase QV4_GC_MAX_STACK_SIZE");
+ }
}
+
+ ExecutionEngine *engine() const { return m_engine; }
+
+private:
+ Heap::Base *pop() { return *(--m_top); }
void drain();
+ Heap::Base **m_top = nullptr;
+ Heap::Base **m_base = nullptr;
+ Heap::Base **m_softLimit = nullptr;
+ Heap::Base **m_hardLimit = nullptr;
+ ExecutionEngine *m_engine = nullptr;
+ quintptr m_drainRecursion = 0;
};
// Some helper to automate the generation of our
diff --git a/src/qml/parser/parser.pri b/src/qml/parser/parser.pri
index e15730f5d1..57855a82f9 100644
--- a/src/qml/parser/parser.pri
+++ b/src/qml/parser/parser.pri
@@ -5,9 +5,7 @@ HEADERS += \
$$PWD/qqmljsengine_p.h \
$$PWD/qqmljslexer_p.h \
$$PWD/qqmljsglobal_p.h \
- $$PWD/qqmljskeywords_p.h \
- $$PWD/qqmljsengine_p.h \
- $$PWD/qqmljssourcelocation_p.h
+ $$PWD/qqmljskeywords_p.h
SOURCES += \
$$PWD/qqmljsast.cpp \
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g
index 397c0b51a5..ef814a57b0 100644
--- a/src/qml/parser/qqmljs.g
+++ b/src/qml/parser/qqmljs.g
@@ -73,7 +73,7 @@
%token T_VAR "var" T_VOID "void" T_WHILE "while"
%token T_WITH "with" T_XOR "^" T_XOR_EQ "^="
%token T_NULL "null" T_TRUE "true" T_FALSE "false"
-%token T_CONST "const" T_LET "let"
+%token T_CONST "const" T_LET "let" T_AT "@"
%token T_DEBUGGER "debugger"
%token T_RESERVED_WORD "reserved word"
%token T_MULTILINE_STRING_LITERAL "multiline string literal"
@@ -326,6 +326,8 @@ public:
AST::UiQualifiedId *UiQualifiedId;
AST::UiEnumMemberList *UiEnumMemberList;
AST::UiVersionSpecifier *UiVersionSpecifier;
+ AST::UiAnnotation *UiAnnotation;
+ AST::UiAnnotationList *UiAnnotationList;
};
public:
@@ -388,10 +390,10 @@ public:
{ return diagnosticMessage().message; }
inline int errorLineNumber() const
- { return diagnosticMessage().line; }
+ { return diagnosticMessage().loc.startLine; }
inline int errorColumnNumber() const
- { return diagnosticMessage().column; }
+ { return diagnosticMessage().loc.startColumn; }
protected:
bool parse(int startToken);
@@ -407,7 +409,7 @@ protected:
inline QStringRef &rawStringRef(int index)
{ return rawString_stack [tos + index - 1]; }
- inline AST::SourceLocation &loc(int index)
+ inline SourceLocation &loc(int index)
{ return location_stack [tos + index - 1]; }
AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr);
@@ -415,21 +417,20 @@ protected:
void pushToken(int token);
int lookaheadToken(Lexer *lexer);
- static DiagnosticMessage compileError(const AST::SourceLocation &location,
+ static DiagnosticMessage compileError(const SourceLocation &location,
const QString &message, QtMsgType kind = QtCriticalMsg)
{
DiagnosticMessage error;
- error.line = location.startLine;
- error.column = location.startColumn;
+ error.loc = location;
error.message = message;
error.type = kind;
return error;
}
- void syntaxError(const AST::SourceLocation &location, const char *message) {
+ void syntaxError(const SourceLocation &location, const char *message) {
diagnostic_messages.append(compileError(location, QLatin1String(message)));
}
- void syntaxError(const AST::SourceLocation &location, const QString &message) {
+ void syntaxError(const SourceLocation &location, const QString &message) {
diagnostic_messages.append(compileError(location, message));
}
@@ -442,7 +443,7 @@ protected:
int stack_size = 0;
Value *sym_stack = nullptr;
int *state_stack = nullptr;
- AST::SourceLocation *location_stack = nullptr;
+ SourceLocation *location_stack = nullptr;
QVector<QStringRef> string_stack;
QVector<QStringRef> rawString_stack;
@@ -454,7 +455,7 @@ protected:
struct SavedToken {
int token;
double dval;
- AST::SourceLocation loc;
+ SourceLocation loc;
QStringRef spell;
QStringRef raw;
};
@@ -463,8 +464,8 @@ protected:
double yylval = 0.;
QStringRef yytokenspell;
QStringRef yytokenraw;
- AST::SourceLocation yylloc;
- AST::SourceLocation yyprevlloc;
+ SourceLocation yylloc;
+ SourceLocation yyprevlloc;
SavedToken token_buffer[TOKEN_BUFFER_SIZE];
SavedToken *first_token = nullptr;
@@ -477,7 +478,7 @@ protected:
CE_ParenthesizedExpression,
CE_FormalParameterList
};
- AST::SourceLocation coverExpressionErrorLocation;
+ SourceLocation coverExpressionErrorLocation;
CoverExpressionType coverExpressionType = CE_Invalid;
QList<DiagnosticMessage> diagnostic_messages;
@@ -522,7 +523,7 @@ void Parser::reallocateStack()
sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
- location_stack = reinterpret_cast<AST::SourceLocation*> (realloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
+ location_stack = reinterpret_cast<SourceLocation*> (realloc(location_stack, stack_size * sizeof(SourceLocation)));
string_stack.resize(stack_size);
rawString_stack.resize(stack_size);
}
@@ -542,9 +543,9 @@ Parser::~Parser()
}
}
-static inline AST::SourceLocation location(Lexer *lexer)
+static inline SourceLocation location(Lexer *lexer)
{
- AST::SourceLocation loc;
+ SourceLocation loc;
loc.offset = lexer->tokenOffset();
loc.length = lexer->tokenLength();
loc.startLine = lexer->tokenStartLine();
@@ -555,7 +556,7 @@ static inline AST::SourceLocation location(Lexer *lexer)
AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
{
QVarLengthArray<QStringRef, 4> nameIds;
- QVarLengthArray<AST::SourceLocation, 4> locations;
+ QVarLengthArray<SourceLocation, 4> locations;
AST::ExpressionNode *it = expr;
while (AST::FieldMemberExpression *m = AST::cast<AST::FieldMemberExpression *>(it)) {
@@ -739,7 +740,7 @@ TopLevel: T_FEED_JS_EXPRESSION Expression;
} break;
./
-TopLevel: T_FEED_UI_OBJECT_MEMBER UiObjectMember;
+TopLevel: T_FEED_UI_OBJECT_MEMBER UiAnnotatedObjectMember;
/.
case $rule_number: {
sym(1).Node = sym(2).Node;
@@ -834,7 +835,15 @@ UiImport: UiImportHead Semicolon;
UiVersionSpecifier: T_VERSION_NUMBER T_DOT T_VERSION_NUMBER;
/.
case $rule_number: {
- auto version = new (pool) AST::UiVersionSpecifier(sym(1).dval, sym(3).dval);
+ const int major = sym(1).dval;
+ const int minor = sym(3).dval;
+ if (!QTypeRevision::isValidSegment(major) || !QTypeRevision::isValidSegment(minor)) {
+ diagnostic_messages.append(
+ compileError(loc(1),
+ QLatin1String("Invalid version. Version numbers must be >= 0 and < 255.")));
+ return false;
+ }
+ auto version = new (pool) AST::UiVersionSpecifier(major, minor);
version->majorToken = loc(1);
version->minorToken = loc(3);
sym(1).UiVersionSpecifier = version;
@@ -845,6 +854,13 @@ UiVersionSpecifier: T_VERSION_NUMBER T_DOT T_VERSION_NUMBER;
UiVersionSpecifier: T_VERSION_NUMBER;
/.
case $rule_number: {
+ const int major = sym(1).dval;
+ if (!QTypeRevision::isValidSegment(major)) {
+ diagnostic_messages.append(
+ compileError(loc(1),
+ QLatin1String("Invalid major version. Version numbers must be >= 0 and < 255.")));
+ return false;
+ }
auto version = new (pool) AST::UiVersionSpecifier(sym(1).dval, 0);
version->majorToken = loc(1);
sym(1).UiVersionSpecifier = version;
@@ -913,21 +929,92 @@ Empty: ;
} break;
./
-UiRootMember: UiObjectDefinition;
+UiRootMember: UiAnnotatedObject;
/.
case $rule_number: {
sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember);
} break;
./
-UiObjectMemberList: UiObjectMember;
+UiSimpleQualifiedId: T_IDENTIFIER;
+/.
+ case $rule_number: {
+ AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1));
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+ } break;
+./
+
+UiSimpleQualifiedId: UiSimpleQualifiedId T_DOT T_IDENTIFIER;
+/.
+ case $rule_number: {
+ AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3));
+ node->dotToken = loc(2);
+ node->identifierToken = loc(3);
+ sym(1).Node = node;
+ } break;
+./
+
+UiAnnotationObjectDefinition: UiSimpleQualifiedId UiObjectInitializer;
+/.
+ case $rule_number: {
+ if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) {
+ sym(1).UiQualifiedId = qualifiedId;
+ } else {
+ sym(1).UiQualifiedId = 0;
+
+ diagnostic_messages.append(compileError(loc(1),
+ QLatin1String("Expected a qualified name id")));
+
+ return false;
+ }
+ AST::UiAnnotation *node = new (pool) AST::UiAnnotation(sym(1).UiQualifiedId, sym(2).UiObjectInitializer);
+ sym(1).Node = node;
+ } break;
+./
+
+UiAnnotation: T_AT UiAnnotationObjectDefinition;
+/.
+case $rule_number: {
+ sym(1).Node = sym(2).Node;
+} break;
+./
+
+
+UiAnnotationList: UiAnnotation;
+/.
+ case $rule_number: {
+ sym(1).Node = new (pool) AST::UiAnnotationList(sym(1).UiAnnotation);
+ } break;
+./
+
+UiAnnotationList: UiAnnotationList UiAnnotation;
+/.
+ case $rule_number: {
+ AST::UiAnnotationList *node = new (pool) AST::UiAnnotationList(sym(1).UiAnnotationList, sym(2).UiAnnotation);
+ sym(1).Node = node;
+ } break;
+./
+
+UiAnnotatedObject: UiAnnotationList UiObjectDefinition;
+/.
+ case $rule_number: {
+ AST::UiObjectDefinition *node = sym(2).UiObjectDefinition;
+ node->annotations = sym(1).UiAnnotationList->finish();
+ sym(1).Node = node;
+ } break;
+./
+
+UiAnnotatedObject: UiObjectDefinition;
+
+UiObjectMemberList: UiAnnotatedObjectMember;
/.
case $rule_number: {
sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember);
} break;
./
-UiObjectMemberList: UiObjectMemberList UiObjectMember;
+UiObjectMemberList: UiObjectMemberList UiAnnotatedObjectMember;
/.
case $rule_number: {
AST::UiObjectMemberList *node = new (pool) AST:: UiObjectMemberList(sym(1).UiObjectMemberList, sym(2).UiObjectMember);
@@ -979,6 +1066,17 @@ UiObjectDefinition: UiQualifiedId UiObjectInitializer;
} break;
./
+UiAnnotatedObjectMember: UiAnnotationList UiObjectMember;
+/.
+ case $rule_number: {
+ AST::UiObjectMember *node = sym(2).UiObjectMember;
+ node->annotations = sym(1).UiAnnotationList->finish();
+ sym(1).Node = sym(2).Node;
+ } break;
+./
+
+UiAnnotatedObjectMember: UiObjectMember;
+
UiObjectMember: UiObjectDefinition;
UiObjectMember: UiQualifiedId T_COLON ExpressionStatementLookahead T_LBRACKET UiArrayMemberList T_RBRACKET;
@@ -1247,12 +1345,49 @@ UiObjectMember: T_DEFAULT UiObjectMemberListPropertyNoInitialiser;
} break;
./
+UiObjectMember: T_DEFAULT T_REQUIRED UiObjectMemberPropertyNoInitialiser;
+/.
+ case $rule_number: {
+ AST::UiPublicMember *node = sym(3).UiPublicMember;
+ node->isDefaultMember = true;
+ node->defaultToken = loc(1);
+ node->isRequired = true;
+ node->requiredToken = loc(2);
+ sym(1).Node = node;
+ } break;
+./
+
+
+UiObjectMember: T_REQUIRED T_DEFAULT UiObjectMemberPropertyNoInitialiser;
+/.
+ case $rule_number: {
+ AST::UiPublicMember *node = sym(3).UiPublicMember;
+ node->isDefaultMember = true;
+ node->defaultToken = loc(2);
+ node->isRequired = true;
+ node->requiredToken = loc(1);
+ sym(1).Node = node;
+ } break;
+./
+
OptionalSemicolon: | Semicolon;
/.
/* we need OptionalSemicolon because UiScriptStatement might already parse the last semicolon
and then we would miss a semicolon (see tests/auto/quick/qquickvisualdatamodel/data/objectlist.qml)*/
./
+UiRequired: T_REQUIRED QmlIdentifier Semicolon;
+/.
+ case $rule_number: {
+ AST::UiRequired *node = new (pool) AST::UiRequired(stringRef(2));
+ node->requiredToken = loc(1);
+ node->semicolonToken = loc(3);
+ sym(1).Node = node;
+ } break;
+./
+
+UiObjectMember: UiRequired;
+
UiObjectMember: T_REQUIRED UiObjectMemberPropertyNoInitialiser;
/.
case $rule_number: {
@@ -1263,7 +1398,6 @@ UiObjectMember: T_REQUIRED UiObjectMemberPropertyNoInitialiser;
} break;
./
-
UiObjectMemberWithScriptStatement: T_PROPERTY UiPropertyType QmlIdentifier T_COLON UiScriptStatement OptionalSemicolon;
/.
case $rule_number: {
@@ -2722,7 +2856,7 @@ AssignmentExpression_In: LeftHandSideExpression T_EQ AssignmentExpression_In;
case $rule_number: {
// need to convert the LHS to an AssignmentPattern if it was an Array/ObjectLiteral
if (AST::Pattern *p = sym(1).Expression->patternCast()) {
- AST::SourceLocation errorLoc;
+ SourceLocation errorLoc;
QString errorMsg;
if (!p->convertLiteralToAssignmentPattern(pool, &errorLoc, &errorMsg)) {
syntaxError(errorLoc, errorMsg);
@@ -3388,7 +3522,7 @@ IterationStatement: T_FOR T_LPAREN LeftHandSideExpression InOrOf Expression_In T
case $rule_number: {
// need to convert the LHS to an AssignmentPattern if it was an Array/ObjectLiteral
if (AST::Pattern *p = sym(3).Expression->patternCast()) {
- AST::SourceLocation errorLoc;
+ SourceLocation errorLoc;
QString errorMsg;
if (!p->convertLiteralToAssignmentPattern(pool, &errorLoc, &errorMsg)) {
syntaxError(errorLoc, errorMsg);
diff --git a/src/qml/parser/qqmljsast.cpp b/src/qml/parser/qqmljsast.cpp
index aa3e8ab5e3..2a34c5a66c 100644
--- a/src/qml/parser/qqmljsast.cpp
+++ b/src/qml/parser/qqmljsast.cpp
@@ -167,7 +167,7 @@ UiObjectMember *UiObjectMember::uiObjectMemberCast()
return this;
}
-void NestedExpression::accept0(Visitor *visitor)
+void NestedExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -185,7 +185,7 @@ ClassExpression *NestedExpression::asClassDefinition()
return expression->asClassDefinition();
}
-void ThisExpression::accept0(Visitor *visitor)
+void ThisExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -193,7 +193,7 @@ void ThisExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void IdentifierExpression::accept0(Visitor *visitor)
+void IdentifierExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -201,7 +201,7 @@ void IdentifierExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void NullExpression::accept0(Visitor *visitor)
+void NullExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -209,7 +209,7 @@ void NullExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void TrueLiteral::accept0(Visitor *visitor)
+void TrueLiteral::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -217,7 +217,7 @@ void TrueLiteral::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void FalseLiteral::accept0(Visitor *visitor)
+void FalseLiteral::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -225,7 +225,7 @@ void FalseLiteral::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void SuperLiteral::accept0(Visitor *visitor)
+void SuperLiteral::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -234,7 +234,7 @@ void SuperLiteral::accept0(Visitor *visitor)
}
-void StringLiteral::accept0(Visitor *visitor)
+void StringLiteral::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -242,7 +242,7 @@ void StringLiteral::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void TemplateLiteral::accept0(Visitor *visitor)
+void TemplateLiteral::accept0(BaseVisitor *visitor)
{
bool accepted = true;
for (TemplateLiteral *it = this; it && accepted; it = it->next) {
@@ -251,7 +251,7 @@ void TemplateLiteral::accept0(Visitor *visitor)
}
}
-void NumericLiteral::accept0(Visitor *visitor)
+void NumericLiteral::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -259,7 +259,7 @@ void NumericLiteral::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void RegExpLiteral::accept0(Visitor *visitor)
+void RegExpLiteral::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -267,7 +267,7 @@ void RegExpLiteral::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ArrayPattern::accept0(Visitor *visitor)
+void ArrayPattern::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this))
accept(elements, visitor);
@@ -287,7 +287,7 @@ bool ArrayPattern::isValidArrayLiteral(SourceLocation *errorLocation) const {
return true;
}
-void ObjectPattern::accept0(Visitor *visitor)
+void ObjectPattern::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(properties, visitor);
@@ -462,7 +462,7 @@ bool PatternProperty::convertLiteralToAssignmentPattern(MemoryPool *pool, Source
}
-void Elision::accept0(Visitor *visitor)
+void Elision::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
// ###
@@ -471,7 +471,7 @@ void Elision::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void IdentifierPropertyName::accept0(Visitor *visitor)
+void IdentifierPropertyName::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -479,7 +479,7 @@ void IdentifierPropertyName::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void StringLiteralPropertyName::accept0(Visitor *visitor)
+void StringLiteralPropertyName::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -487,7 +487,7 @@ void StringLiteralPropertyName::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void NumericLiteralPropertyName::accept0(Visitor *visitor)
+void NumericLiteralPropertyName::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -517,7 +517,7 @@ QString NumericLiteralPropertyName::asString()const
return locale.toString(id, 'g', 16);
}
-void ArrayMemberExpression::accept0(Visitor *visitor)
+void ArrayMemberExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(base, visitor);
@@ -527,7 +527,7 @@ void ArrayMemberExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void FieldMemberExpression::accept0(Visitor *visitor)
+void FieldMemberExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(base, visitor);
@@ -536,7 +536,7 @@ void FieldMemberExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void NewMemberExpression::accept0(Visitor *visitor)
+void NewMemberExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(base, visitor);
@@ -546,7 +546,7 @@ void NewMemberExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void NewExpression::accept0(Visitor *visitor)
+void NewExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -555,7 +555,7 @@ void NewExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void CallExpression::accept0(Visitor *visitor)
+void CallExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(base, visitor);
@@ -565,7 +565,7 @@ void CallExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ArgumentList::accept0(Visitor *visitor)
+void ArgumentList::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
for (ArgumentList *it = this; it; it = it->next) {
@@ -576,7 +576,7 @@ void ArgumentList::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void PostIncrementExpression::accept0(Visitor *visitor)
+void PostIncrementExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(base, visitor);
@@ -585,7 +585,7 @@ void PostIncrementExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void PostDecrementExpression::accept0(Visitor *visitor)
+void PostDecrementExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(base, visitor);
@@ -594,7 +594,7 @@ void PostDecrementExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void DeleteExpression::accept0(Visitor *visitor)
+void DeleteExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -603,7 +603,7 @@ void DeleteExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void VoidExpression::accept0(Visitor *visitor)
+void VoidExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -612,7 +612,7 @@ void VoidExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void TypeOfExpression::accept0(Visitor *visitor)
+void TypeOfExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -621,7 +621,7 @@ void TypeOfExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void PreIncrementExpression::accept0(Visitor *visitor)
+void PreIncrementExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -630,7 +630,7 @@ void PreIncrementExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void PreDecrementExpression::accept0(Visitor *visitor)
+void PreDecrementExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -639,7 +639,7 @@ void PreDecrementExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void UnaryPlusExpression::accept0(Visitor *visitor)
+void UnaryPlusExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -648,7 +648,7 @@ void UnaryPlusExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void UnaryMinusExpression::accept0(Visitor *visitor)
+void UnaryMinusExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -657,7 +657,7 @@ void UnaryMinusExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void TildeExpression::accept0(Visitor *visitor)
+void TildeExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -666,7 +666,7 @@ void TildeExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void NotExpression::accept0(Visitor *visitor)
+void NotExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -675,7 +675,7 @@ void NotExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void BinaryExpression::accept0(Visitor *visitor)
+void BinaryExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(left, visitor);
@@ -685,7 +685,7 @@ void BinaryExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ConditionalExpression::accept0(Visitor *visitor)
+void ConditionalExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -696,7 +696,7 @@ void ConditionalExpression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void Expression::accept0(Visitor *visitor)
+void Expression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(left, visitor);
@@ -706,7 +706,7 @@ void Expression::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void Block::accept0(Visitor *visitor)
+void Block::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(statements, visitor);
@@ -715,7 +715,7 @@ void Block::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void StatementList::accept0(Visitor *visitor)
+void StatementList::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
for (StatementList *it = this; it; it = it->next) {
@@ -726,7 +726,7 @@ void StatementList::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void VariableStatement::accept0(Visitor *visitor)
+void VariableStatement::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(declarations, visitor);
@@ -735,7 +735,7 @@ void VariableStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void VariableDeclarationList::accept0(Visitor *visitor)
+void VariableDeclarationList::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
for (VariableDeclarationList *it = this; it; it = it->next) {
@@ -746,7 +746,7 @@ void VariableDeclarationList::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void EmptyStatement::accept0(Visitor *visitor)
+void EmptyStatement::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -754,7 +754,7 @@ void EmptyStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ExpressionStatement::accept0(Visitor *visitor)
+void ExpressionStatement::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -763,7 +763,7 @@ void ExpressionStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void IfStatement::accept0(Visitor *visitor)
+void IfStatement::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -774,7 +774,7 @@ void IfStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void DoWhileStatement::accept0(Visitor *visitor)
+void DoWhileStatement::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(statement, visitor);
@@ -784,7 +784,7 @@ void DoWhileStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void WhileStatement::accept0(Visitor *visitor)
+void WhileStatement::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -794,7 +794,7 @@ void WhileStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ForStatement::accept0(Visitor *visitor)
+void ForStatement::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(initialiser, visitor);
@@ -807,7 +807,7 @@ void ForStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ForEachStatement::accept0(Visitor *visitor)
+void ForEachStatement::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(lhs, visitor);
@@ -818,7 +818,7 @@ void ForEachStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ContinueStatement::accept0(Visitor *visitor)
+void ContinueStatement::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -826,7 +826,7 @@ void ContinueStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void BreakStatement::accept0(Visitor *visitor)
+void BreakStatement::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -834,7 +834,7 @@ void BreakStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ReturnStatement::accept0(Visitor *visitor)
+void ReturnStatement::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -843,7 +843,7 @@ void ReturnStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void YieldExpression::accept0(Visitor *visitor)
+void YieldExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -853,7 +853,7 @@ void YieldExpression::accept0(Visitor *visitor)
}
-void WithStatement::accept0(Visitor *visitor)
+void WithStatement::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -863,7 +863,7 @@ void WithStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void SwitchStatement::accept0(Visitor *visitor)
+void SwitchStatement::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -873,7 +873,7 @@ void SwitchStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void CaseBlock::accept0(Visitor *visitor)
+void CaseBlock::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(clauses, visitor);
@@ -884,7 +884,7 @@ void CaseBlock::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void CaseClauses::accept0(Visitor *visitor)
+void CaseClauses::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
for (CaseClauses *it = this; it; it = it->next) {
@@ -895,7 +895,7 @@ void CaseClauses::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void CaseClause::accept0(Visitor *visitor)
+void CaseClause::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -905,7 +905,7 @@ void CaseClause::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void DefaultClause::accept0(Visitor *visitor)
+void DefaultClause::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(statements, visitor);
@@ -914,7 +914,7 @@ void DefaultClause::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void LabelledStatement::accept0(Visitor *visitor)
+void LabelledStatement::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(statement, visitor);
@@ -923,7 +923,7 @@ void LabelledStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ThrowStatement::accept0(Visitor *visitor)
+void ThrowStatement::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -932,7 +932,7 @@ void ThrowStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void TryStatement::accept0(Visitor *visitor)
+void TryStatement::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(statement, visitor);
@@ -943,7 +943,7 @@ void TryStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void Catch::accept0(Visitor *visitor)
+void Catch::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(patternElement, visitor);
@@ -953,7 +953,7 @@ void Catch::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void Finally::accept0(Visitor *visitor)
+void Finally::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(statement, visitor);
@@ -962,7 +962,7 @@ void Finally::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void FunctionDeclaration::accept0(Visitor *visitor)
+void FunctionDeclaration::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(formals, visitor);
@@ -973,7 +973,7 @@ void FunctionDeclaration::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void FunctionExpression::accept0(Visitor *visitor)
+void FunctionExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(formals, visitor);
@@ -1018,7 +1018,7 @@ BoundNames FormalParameterList::boundNames() const
return names;
}
-void FormalParameterList::accept0(Visitor *visitor)
+void FormalParameterList::accept0(BaseVisitor *visitor)
{
bool accepted = true;
for (FormalParameterList *it = this; it && accepted; it = it->next) {
@@ -1043,7 +1043,7 @@ FormalParameterList *FormalParameterList::finish(QQmlJS::MemoryPool *pool)
return front;
}
-void Program::accept0(Visitor *visitor)
+void Program::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(statements, visitor);
@@ -1052,7 +1052,7 @@ void Program::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ImportSpecifier::accept0(Visitor *visitor)
+void ImportSpecifier::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
@@ -1060,7 +1060,7 @@ void ImportSpecifier::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ImportsList::accept0(Visitor *visitor)
+void ImportsList::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
for (ImportsList *it = this; it; it = it->next) {
@@ -1071,7 +1071,7 @@ void ImportsList::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void NamedImports::accept0(Visitor *visitor)
+void NamedImports::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(importsList, visitor);
@@ -1080,7 +1080,7 @@ void NamedImports::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void FromClause::accept0(Visitor *visitor)
+void FromClause::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -1088,7 +1088,7 @@ void FromClause::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void NameSpaceImport::accept0(Visitor *visitor)
+void NameSpaceImport::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -1096,7 +1096,7 @@ void NameSpaceImport::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ImportClause::accept0(Visitor *visitor)
+void ImportClause::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(nameSpaceImport, visitor);
@@ -1106,7 +1106,7 @@ void ImportClause::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ImportDeclaration::accept0(Visitor *visitor)
+void ImportDeclaration::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(importClause, visitor);
@@ -1116,7 +1116,7 @@ void ImportDeclaration::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ExportSpecifier::accept0(Visitor *visitor)
+void ExportSpecifier::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
@@ -1125,7 +1125,7 @@ void ExportSpecifier::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ExportsList::accept0(Visitor *visitor)
+void ExportsList::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
for (ExportsList *it = this; it; it = it->next) {
@@ -1136,7 +1136,7 @@ void ExportsList::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ExportClause::accept0(Visitor *visitor)
+void ExportClause::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(exportsList, visitor);
@@ -1145,7 +1145,7 @@ void ExportClause::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ExportDeclaration::accept0(Visitor *visitor)
+void ExportDeclaration::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(fromClause, visitor);
@@ -1156,7 +1156,7 @@ void ExportDeclaration::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ESModule::accept0(Visitor *visitor)
+void ESModule::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(body, visitor);
@@ -1165,7 +1165,7 @@ void ESModule::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void DebuggerStatement::accept0(Visitor *visitor)
+void DebuggerStatement::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -1173,7 +1173,7 @@ void DebuggerStatement::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void UiProgram::accept0(Visitor *visitor)
+void UiProgram::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(headers, visitor);
@@ -1183,19 +1183,23 @@ void UiProgram::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void UiPublicMember::accept0(Visitor *visitor)
+void UiPublicMember::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
+ // accept(annotations, visitor); // accept manually in visit if interested
+ // accept(memberType, visitor); // accept manually in visit if interested
accept(statement, visitor);
accept(binding, visitor);
+ // accept(parameters, visitor); // accept manually in visit if interested
}
visitor->endVisit(this);
}
-void UiObjectDefinition::accept0(Visitor *visitor)
+void UiObjectDefinition::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
+ // accept(annotations, visitor); // accept manually in visit if interested
accept(qualifiedTypeNameId, visitor);
accept(initializer, visitor);
}
@@ -1203,7 +1207,7 @@ void UiObjectDefinition::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void UiObjectInitializer::accept0(Visitor *visitor)
+void UiObjectInitializer::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(members, visitor);
@@ -1212,16 +1216,18 @@ void UiObjectInitializer::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void UiParameterList::accept0(Visitor *visitor)
+void UiParameterList::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
+ // accept(type, visitor); // accept manually in visit if interested
}
visitor->endVisit(this);
}
-void UiObjectBinding::accept0(Visitor *visitor)
+void UiObjectBinding::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
+ // accept(annotations, visitor); // accept manually in visit if interested
accept(qualifiedId, visitor);
accept(qualifiedTypeNameId, visitor);
accept(initializer, visitor);
@@ -1230,9 +1236,10 @@ void UiObjectBinding::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void UiScriptBinding::accept0(Visitor *visitor)
+void UiScriptBinding::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
+ // accept(annotations, visitor); // accept manually in visit if interested
accept(qualifiedId, visitor);
accept(statement, visitor);
}
@@ -1240,9 +1247,10 @@ void UiScriptBinding::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void UiArrayBinding::accept0(Visitor *visitor)
+void UiArrayBinding::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
+ // accept(annotations, visitor); // accept manually in visit if interested
accept(qualifiedId, visitor);
accept(members, visitor);
}
@@ -1250,7 +1258,7 @@ void UiArrayBinding::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void UiObjectMemberList::accept0(Visitor *visitor)
+void UiObjectMemberList::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
for (UiObjectMemberList *it = this; it; it = it->next)
@@ -1260,7 +1268,7 @@ void UiObjectMemberList::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void UiArrayMemberList::accept0(Visitor *visitor)
+void UiArrayMemberList::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
for (UiArrayMemberList *it = this; it; it = it->next)
@@ -1270,15 +1278,16 @@ void UiArrayMemberList::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void UiQualifiedId::accept0(Visitor *visitor)
+void UiQualifiedId::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
+ // accept(next, visitor) // accept manually in visit if interested
}
visitor->endVisit(this);
}
-void Type::accept0(Visitor *visitor)
+void Type::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(typeId, visitor);
@@ -1288,7 +1297,7 @@ void Type::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void TypeArgumentList::accept0(Visitor *visitor)
+void TypeArgumentList::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
for (TypeArgumentList *it = this; it; it = it->next)
@@ -1298,7 +1307,7 @@ void TypeArgumentList::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void TypeAnnotation::accept0(Visitor *visitor)
+void TypeAnnotation::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(type, visitor);
@@ -1307,16 +1316,17 @@ void TypeAnnotation::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void UiImport::accept0(Visitor *visitor)
+void UiImport::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(importUri, visitor);
+ // accept(version, visitor); // accept manually in visit if interested
}
visitor->endVisit(this);
}
-void UiPragma::accept0(Visitor *visitor)
+void UiPragma::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -1324,7 +1334,7 @@ void UiPragma::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void UiHeaderItemList::accept0(Visitor *visitor)
+void UiHeaderItemList::accept0(BaseVisitor *visitor)
{
bool accepted = true;
for (UiHeaderItemList *it = this; it && accepted; it = it->next) {
@@ -1337,25 +1347,27 @@ void UiHeaderItemList::accept0(Visitor *visitor)
}
-void UiSourceElement::accept0(Visitor *visitor)
+void UiSourceElement::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
+ // accept(annotations, visitor); // accept manually in visit if interested
accept(sourceElement, visitor);
}
visitor->endVisit(this);
}
-void UiEnumDeclaration::accept0(Visitor *visitor)
+void UiEnumDeclaration::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
+ // accept(annotations, visitor); // accept manually in visit if interested
accept(members, visitor);
}
visitor->endVisit(this);
}
-void UiEnumMemberList::accept0(Visitor *visitor)
+void UiEnumMemberList::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -1363,7 +1375,7 @@ void UiEnumMemberList::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void TaggedTemplate::accept0(Visitor *visitor)
+void TaggedTemplate::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(base, visitor);
@@ -1373,7 +1385,7 @@ void TaggedTemplate::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void PatternElement::accept0(Visitor *visitor)
+void PatternElement::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(bindingTarget, visitor);
@@ -1396,7 +1408,7 @@ void PatternElement::boundNames(BoundNames *names)
}
}
-void PatternElementList::accept0(Visitor *visitor)
+void PatternElementList::accept0(BaseVisitor *visitor)
{
bool accepted = true;
for (PatternElementList *it = this; it && accepted; it = it->next) {
@@ -1417,7 +1429,7 @@ void PatternElementList::boundNames(BoundNames *names)
}
}
-void PatternProperty::accept0(Visitor *visitor)
+void PatternProperty::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(name, visitor);
@@ -1434,7 +1446,7 @@ void PatternProperty::boundNames(BoundNames *names)
PatternElement::boundNames(names);
}
-void PatternPropertyList::accept0(Visitor *visitor)
+void PatternPropertyList::accept0(BaseVisitor *visitor)
{
bool accepted = true;
for (PatternPropertyList *it = this; it && accepted; it = it->next) {
@@ -1451,7 +1463,7 @@ void PatternPropertyList::boundNames(BoundNames *names)
it->property->boundNames(names);
}
-void ComputedPropertyName::accept0(Visitor *visitor)
+void ComputedPropertyName::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression, visitor);
@@ -1460,7 +1472,7 @@ void ComputedPropertyName::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ClassExpression::accept0(Visitor *visitor)
+void ClassExpression::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(heritage, visitor);
@@ -1475,7 +1487,7 @@ ClassExpression *ClassExpression::asClassDefinition()
return this;
}
-void ClassDeclaration::accept0(Visitor *visitor)
+void ClassDeclaration::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
accept(heritage, visitor);
@@ -1485,7 +1497,7 @@ void ClassDeclaration::accept0(Visitor *visitor)
visitor->endVisit(this);
}
-void ClassElementList::accept0(Visitor *visitor)
+void ClassElementList::accept0(BaseVisitor *visitor)
{
bool accepted = true;
for (ClassElementList *it = this; it && accepted; it = it->next) {
@@ -1514,7 +1526,7 @@ LeftHandSideExpression *LeftHandSideExpression::leftHandSideExpressionCast()
return this;
}
-void UiVersionSpecifier::accept0(Visitor *visitor)
+void UiVersionSpecifier::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
}
@@ -1545,15 +1557,44 @@ void Type::toString(QString *out) const
};
}
-void UiInlineComponent::accept0(Visitor *visitor)
+void UiInlineComponent::accept0(BaseVisitor *visitor)
{
if (visitor->visit(this)) {
+ // accept(annotations, visitor); // accept manually in visit if interested
accept(component, visitor);
}
visitor->endVisit(this);
}
+void UiRequired::accept0(BaseVisitor *visitor)
+{
+ if (visitor->visit(this)) {
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiAnnotationList::accept0(BaseVisitor *visitor)
+{
+ if (visitor->visit(this)) {
+ for (UiAnnotationList *it = this; it; it = it->next)
+ accept(it->annotation, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
+void UiAnnotation::accept0(BaseVisitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(qualifiedTypeNameId, visitor);
+ accept(initializer, visitor);
+ }
+
+ visitor->endVisit(this);
+}
+
} } // namespace QQmlJS::AST
QT_END_NAMESPACE
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index 48a994cd33..de554a53af 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -57,6 +57,7 @@
#include <private/qqmljsmemorypool_p.h>
#include <QtCore/qstring.h>
+#include <QtCore/qversionnumber.h>
QT_BEGIN_NAMESPACE
@@ -258,7 +259,10 @@ public:
Kind_UiHeaderItemList,
Kind_UiEnumDeclaration,
Kind_UiEnumMemberList,
- Kind_UiVersionSpecifier
+ Kind_UiVersionSpecifier,
+ Kind_UiRequired,
+ Kind_UiAnnotation,
+ Kind_UiAnnotationList
};
inline Node() {}
@@ -280,9 +284,9 @@ public:
bool ignoreRecursionDepth() const;
- inline void accept(Visitor *visitor)
+ inline void accept(BaseVisitor *visitor)
{
- Visitor::RecursionDepthCheck recursionCheck(visitor);
+ BaseVisitor::RecursionDepthCheck recursionCheck(visitor);
// Stack overflow is uncommon, ignoreRecursionDepth() only returns true if
// QV4_CRASH_ON_STACKOVERFLOW is set, and ignoreRecursionDepth() needs to be out of line.
@@ -296,19 +300,19 @@ public:
}
}
- inline static void accept(Node *node, Visitor *visitor)
+ inline static void accept(Node *node, BaseVisitor *visitor)
{
if (node)
node->accept(visitor);
}
// ### Remove when we can. This is part of the qmldevtools library, though.
- inline static void acceptChild(Node *node, Visitor *visitor)
+ inline static void acceptChild(Node *node, BaseVisitor *visitor)
{
return accept(node, visitor);
}
- virtual void accept0(Visitor *visitor) = 0;
+ virtual void accept0(BaseVisitor *visitor) = 0;
virtual SourceLocation firstSourceLocation() const = 0;
virtual SourceLocation lastSourceLocation() const = 0;
@@ -349,7 +353,7 @@ public:
return head;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return identifierToken; }
@@ -373,7 +377,7 @@ public:
, typeArguments(typeArguments)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return typeId->firstSourceLocation(); }
@@ -408,7 +412,7 @@ public:
previous->next = this;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return typeId->firstSourceLocation(); }
@@ -437,7 +441,7 @@ public:
: type(type)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return colonToken; }
@@ -482,7 +486,7 @@ public:
: expression(expression)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return lparenToken; }
@@ -507,7 +511,7 @@ public:
ThisExpression() { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return thisToken; }
@@ -527,7 +531,7 @@ public:
IdentifierExpression(const QStringRef &n):
name (n) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return identifierToken; }
@@ -547,7 +551,7 @@ public:
NullExpression() { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return nullToken; }
@@ -566,7 +570,7 @@ public:
TrueLiteral() { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return trueToken; }
@@ -585,7 +589,7 @@ public:
FalseLiteral() { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return falseToken; }
@@ -604,7 +608,7 @@ public:
SuperLiteral() { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return superToken; }
@@ -625,7 +629,7 @@ public:
NumericLiteral(double v):
value(v) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return literalToken; }
@@ -643,9 +647,12 @@ class QML_PARSER_EXPORT UiVersionSpecifier : public Node
public:
QQMLJS_DECLARE_AST_NODE(UiVersionSpecifier)
- UiVersionSpecifier(int majorum, int minorum) : majorVersion(majorum), minorVersion(minorum) { kind = K; }
+ UiVersionSpecifier(int majorum, int minorum) : version(QTypeRevision::fromVersion(majorum, minorum))
+ {
+ kind = K;
+ }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override { return majorToken; }
@@ -655,8 +662,7 @@ public:
}
// attributes:
- int majorVersion;
- int minorVersion;
+ QTypeRevision version;
SourceLocation majorToken;
SourceLocation minorToken;
};
@@ -669,7 +675,7 @@ public:
StringLiteral(const QStringRef &v):
value (v) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return literalToken; }
@@ -700,7 +706,7 @@ public:
return (last->expression ? last->expression->lastSourceLocation() : last->literalToken);
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
QStringRef value;
QStringRef rawValue;
@@ -717,7 +723,7 @@ public:
RegExpLiteral(const QStringRef &p, int f):
pattern (p), flags (f) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return literalToken; }
@@ -752,7 +758,7 @@ public:
: elements(elts)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return lbracketToken; }
@@ -783,7 +789,7 @@ public:
: properties(plist)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return lbraceToken; }
@@ -814,7 +820,7 @@ public:
previous->next = this;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return commaToken; }
@@ -920,7 +926,7 @@ public:
kind = K;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
virtual bool convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage);
SourceLocation firstSourceLocation() const override
@@ -973,7 +979,7 @@ public:
return front;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
void boundNames(BoundNames *names);
@@ -1008,7 +1014,7 @@ public:
: PatternElement(pattern, i), name(name)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return name->firstSourceLocation(); }
@@ -1044,7 +1050,7 @@ public:
previous->next = this;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
void boundNames(BoundNames *names);
@@ -1065,7 +1071,7 @@ public:
PatternPropertyList *next;
};
-class QML_PARSER_EXPORT IdentifierPropertyName : public PropertyName
+class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName
{
public:
QQMLJS_DECLARE_AST_NODE(IdentifierPropertyName)
@@ -1073,7 +1079,7 @@ public:
IdentifierPropertyName(const QStringRef &n):
id (n) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
QString asString() const override { return id.toString(); }
@@ -1089,7 +1095,7 @@ public:
StringLiteralPropertyName(const QStringRef &n):
id (n) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
QString asString() const override { return id.toString(); }
@@ -1105,7 +1111,7 @@ public:
NumericLiteralPropertyName(double n):
id (n) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
QString asString() const override;
@@ -1122,7 +1128,7 @@ public:
: expression(expression)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
QString asString() const override { return QString(); }
@@ -1146,7 +1152,7 @@ public:
base (b), expression (e)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return base->firstSourceLocation(); }
@@ -1170,7 +1176,7 @@ public:
base (b), name (n)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return base->firstSourceLocation(); }
@@ -1194,7 +1200,7 @@ public:
: base (b), templateLiteral(t)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return base->firstSourceLocation(); }
@@ -1216,7 +1222,7 @@ public:
base (b), arguments (a)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return newToken; }
@@ -1240,7 +1246,7 @@ public:
NewExpression(ExpressionNode *e):
expression (e) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return newToken; }
@@ -1262,7 +1268,7 @@ public:
base (b), arguments (a)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return base->firstSourceLocation(); }
@@ -1294,7 +1300,7 @@ public:
previous->next = this;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return expression->firstSourceLocation(); }
@@ -1328,7 +1334,7 @@ public:
PostIncrementExpression(ExpressionNode *b):
base (b) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return base->firstSourceLocation(); }
@@ -1349,7 +1355,7 @@ public:
PostDecrementExpression(ExpressionNode *b):
base (b) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return base->firstSourceLocation(); }
@@ -1370,7 +1376,7 @@ public:
DeleteExpression(ExpressionNode *e):
expression (e) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return deleteToken; }
@@ -1391,7 +1397,7 @@ public:
VoidExpression(ExpressionNode *e):
expression (e) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return voidToken; }
@@ -1412,7 +1418,7 @@ public:
TypeOfExpression(ExpressionNode *e):
expression (e) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return typeofToken; }
@@ -1433,7 +1439,7 @@ public:
PreIncrementExpression(ExpressionNode *e):
expression (e) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return incrementToken; }
@@ -1454,7 +1460,7 @@ public:
PreDecrementExpression(ExpressionNode *e):
expression (e) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return decrementToken; }
@@ -1475,7 +1481,7 @@ public:
UnaryPlusExpression(ExpressionNode *e):
expression (e) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return plusToken; }
@@ -1496,7 +1502,7 @@ public:
UnaryMinusExpression(ExpressionNode *e):
expression (e) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return minusToken; }
@@ -1517,7 +1523,7 @@ public:
TildeExpression(ExpressionNode *e):
expression (e) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return tildeToken; }
@@ -1538,7 +1544,7 @@ public:
NotExpression(ExpressionNode *e):
expression (e) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return notToken; }
@@ -1562,7 +1568,7 @@ public:
BinaryExpression *binaryExpressionCast() override;
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return left->firstSourceLocation(); }
@@ -1586,7 +1592,7 @@ public:
expression (e), ok (t), ko (f)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return expression->firstSourceLocation(); }
@@ -1610,7 +1616,7 @@ public:
Expression(ExpressionNode *l, ExpressionNode *r):
left (l), right (r) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return left->firstSourceLocation(); }
@@ -1632,7 +1638,7 @@ public:
Block(StatementList *slist):
statements (slist) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return lbraceToken; }
@@ -1662,7 +1668,7 @@ public:
return n;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return statement->firstSourceLocation(); }
@@ -1701,7 +1707,7 @@ public:
previous->next = this;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return declaration->firstSourceLocation(); }
@@ -1739,7 +1745,7 @@ public:
declarations (vlist)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return declarationKindToken; }
@@ -1759,7 +1765,7 @@ public:
EmptyStatement() { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return semicolonToken; }
@@ -1779,7 +1785,7 @@ public:
ExpressionStatement(ExpressionNode *e):
expression (e) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return expression->firstSourceLocation(); }
@@ -1801,7 +1807,7 @@ public:
expression (e), ok (t), ko (f)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return ifToken; }
@@ -1833,7 +1839,7 @@ public:
statement (stmt), expression (e)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return doToken; }
@@ -1860,7 +1866,7 @@ public:
expression (e), statement (stmt)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return whileToken; }
@@ -1890,7 +1896,7 @@ public:
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return forToken; }
@@ -1928,7 +1934,7 @@ public:
: lhs(v), expression(e), statement(stmt)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return forToken; }
@@ -1959,7 +1965,7 @@ public:
ContinueStatement(const QStringRef &l = QStringRef()):
label (l) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return continueToken; }
@@ -1982,7 +1988,7 @@ public:
BreakStatement(const QStringRef &l):
label (l) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return breakToken; }
@@ -2005,7 +2011,7 @@ public:
ReturnStatement(ExpressionNode *e):
expression (e) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return returnToken; }
@@ -2027,7 +2033,7 @@ public:
YieldExpression(ExpressionNode *e = nullptr):
expression (e) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return yieldToken; }
@@ -2050,7 +2056,7 @@ public:
expression (e), statement (stmt)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return withToken; }
@@ -2075,7 +2081,7 @@ public:
clauses (c), defaultClause (d), moreClauses (r)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return lbraceToken; }
@@ -2100,7 +2106,7 @@ public:
expression (e), block (b)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return switchToken; }
@@ -2125,7 +2131,7 @@ public:
expression (e), statements (slist)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return caseToken; }
@@ -2157,7 +2163,7 @@ public:
previous->next = this;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return clause->firstSourceLocation(); }
@@ -2188,7 +2194,7 @@ public:
statements (slist)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return defaultToken; }
@@ -2211,7 +2217,7 @@ public:
label (l), statement (stmt)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return identifierToken; }
@@ -2234,7 +2240,7 @@ public:
ThrowStatement(ExpressionNode *e):
expression (e) { kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return throwToken; }
@@ -2257,7 +2263,7 @@ public:
: patternElement(p), statement(stmt)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return catchToken; }
@@ -2283,7 +2289,7 @@ public:
statement (stmt)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return finallyToken; }
@@ -2313,7 +2319,7 @@ public:
statement (stmt), catchExpression (c), finallyExpression (nullptr)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return tryToken; }
@@ -2345,7 +2351,7 @@ public:
typeAnnotation(typeAnnotation)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return functionToken; }
@@ -2379,7 +2385,7 @@ public:
FunctionExpression(n, f, b, typeAnnotation)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
};
class QML_PARSER_EXPORT FormalParameterList: public Node
@@ -2450,7 +2456,7 @@ public:
BoundNames boundNames() const;
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return element->firstSourceLocation(); }
@@ -2476,7 +2482,7 @@ public:
: name(n), heritage(heritage), elements(elements)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return classToken; }
@@ -2505,7 +2511,7 @@ public:
: ClassExpression(n, heritage, elements)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
};
@@ -2527,7 +2533,7 @@ public:
return n;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return property->firstSourceLocation(); }
@@ -2555,7 +2561,7 @@ public:
: statements(statements)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return statements ? statements->firstSourceLocation() : SourceLocation(); }
@@ -2584,7 +2590,7 @@ public:
kind = K;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return identifier.isNull() ? importedBindingToken : identifierToken; }
@@ -2629,7 +2635,7 @@ public:
return head;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return importSpecifierToken; }
@@ -2661,7 +2667,7 @@ public:
kind = K;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return leftBraceToken; }
@@ -2685,7 +2691,7 @@ public:
kind = K;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
virtual SourceLocation firstSourceLocation() const override
{ return starToken; }
@@ -2735,7 +2741,7 @@ public:
kind = K;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
virtual SourceLocation firstSourceLocation() const override
{ return importedDefaultBinding.isNull() ? (nameSpaceImport ? nameSpaceImport->firstSourceLocation() : namedImports->firstSourceLocation()) : importedDefaultBindingToken; }
@@ -2760,7 +2766,7 @@ public:
kind = K;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return fromToken; }
@@ -2791,7 +2797,7 @@ public:
kind = K;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return importToken; }
@@ -2824,7 +2830,7 @@ public:
kind = K;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return identifierToken; }
@@ -2869,7 +2875,7 @@ public:
return head;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return exportSpecifier->firstSourceLocation(); }
@@ -2897,7 +2903,7 @@ public:
kind = K;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return leftBraceToken; }
@@ -2941,7 +2947,7 @@ public:
kind = K;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return exportToken; }
@@ -2968,7 +2974,7 @@ public:
kind = K;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return body ? body->firstSourceLocation() : SourceLocation(); }
@@ -2988,7 +2994,7 @@ public:
DebuggerStatement()
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return debuggerToken; }
@@ -3014,7 +3020,7 @@ public:
: importUri(uri)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return importToken; }
@@ -3041,6 +3047,9 @@ public:
SourceLocation lastSourceLocation() const override = 0;
UiObjectMember *uiObjectMemberCast() override;
+
+// attributes
+ UiAnnotationList *annotations = nullptr;
};
class QML_PARSER_EXPORT UiObjectMemberList: public Node
@@ -3060,7 +3069,7 @@ public:
previous->next = this;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return member->firstSourceLocation(); }
@@ -3089,7 +3098,7 @@ public:
: name(name)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return pragmaToken; }
@@ -3103,6 +3112,28 @@ public:
SourceLocation semicolonToken;
};
+class QML_PARSER_EXPORT UiRequired: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(UiRequired)
+
+ UiRequired(QStringRef name)
+ :name(name)
+ { kind = K; }
+
+ void accept0(BaseVisitor *visitor) override;
+
+ SourceLocation firstSourceLocation() const override
+ { return requiredToken; }
+
+ SourceLocation lastSourceLocation() const override
+ { return semicolonToken; }
+
+ QStringRef name;
+ SourceLocation requiredToken;
+ SourceLocation semicolonToken;
+};
+
class QML_PARSER_EXPORT UiHeaderItemList: public Node
{
public:
@@ -3139,7 +3170,7 @@ public:
return head;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return headerItem->firstSourceLocation(); }
@@ -3161,7 +3192,7 @@ public:
: headers(headers), members(members)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{
@@ -3203,7 +3234,7 @@ public:
previous->next = this;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return member->firstSourceLocation(); }
@@ -3233,7 +3264,7 @@ public:
: members(members)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return lbraceToken; }
@@ -3264,7 +3295,7 @@ public:
previous->next = this;
}
- void accept0(Visitor *) override;
+ void accept0(BaseVisitor *) override;
SourceLocation firstSourceLocation() const override
{ return colonToken.isValid() ? identifierToken : propertyTypeToken; }
@@ -3308,7 +3339,7 @@ public:
: type(Property), memberType(memberType), name(name), statement(statement), binding(nullptr), isDefaultMember(false), isReadonlyMember(false), parameters(nullptr)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{
@@ -3365,7 +3396,7 @@ public:
: qualifiedTypeNameId(qualifiedTypeNameId), initializer(initializer)
{ kind = K; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
SourceLocation firstSourceLocation() const override
{ return qualifiedTypeNameId->identifierToken; }
@@ -3387,17 +3418,18 @@ public:
: name(inlineComponentName), component(inlineComponent)
{ kind = K; }
- QStringRef name;
- UiObjectDefinition* component;
- SourceLocation componentToken;
-
SourceLocation lastSourceLocation() const override
{return component->lastSourceLocation();}
SourceLocation firstSourceLocation() const override
{return componentToken;}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
+
+ // attributes
+ QStringRef name;
+ UiObjectDefinition* component;
+ SourceLocation componentToken;
};
class QML_PARSER_EXPORT UiSourceElement: public UiObjectMember
@@ -3429,7 +3461,7 @@ public:
return SourceLocation();
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
// attributes
@@ -3461,7 +3493,7 @@ public:
SourceLocation lastSourceLocation() const override
{ return initializer->rbraceToken; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
// attributes
@@ -3489,7 +3521,7 @@ public:
SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
// attributes
UiQualifiedId *qualifiedId;
@@ -3514,7 +3546,7 @@ public:
SourceLocation lastSourceLocation() const override
{ return rbracketToken; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
// attributes
UiQualifiedId *qualifiedId;
@@ -3558,7 +3590,7 @@ public:
return last->valueToken.isValid() ? last->valueToken : last->memberToken;
}
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
UiEnumMemberList *finish()
{
@@ -3592,7 +3624,7 @@ public:
SourceLocation lastSourceLocation() const override
{ return rbraceToken; }
- void accept0(Visitor *visitor) override;
+ void accept0(BaseVisitor *visitor) override;
// attributes
SourceLocation enumToken;
@@ -3601,8 +3633,67 @@ public:
UiEnumMemberList *members;
};
-} } // namespace AST
+class QML_PARSER_EXPORT UiAnnotation: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(UiAnnotation)
+
+ UiAnnotation(UiQualifiedId *qualifiedTypeNameId,
+ UiObjectInitializer *initializer)
+ : qualifiedTypeNameId(qualifiedTypeNameId), initializer(initializer)
+ { kind = K; }
+ void accept0(BaseVisitor *visitor) override;
+
+ SourceLocation firstSourceLocation() const override
+ { return qualifiedTypeNameId->identifierToken; }
+
+ SourceLocation lastSourceLocation() const override
+ { return initializer->rbraceToken; }
+
+// attributes
+ UiQualifiedId *qualifiedTypeNameId;
+ UiObjectInitializer *initializer;
+};
+
+class QML_PARSER_EXPORT UiAnnotationList: public Node
+{
+public:
+ QQMLJS_DECLARE_AST_NODE(UiAnnotationList)
+
+ UiAnnotationList(UiAnnotation *annotation)
+ : next(this), annotation(annotation)
+ { kind = K; }
+
+ UiAnnotationList(UiAnnotationList *previous, UiAnnotation *annotation)
+ : annotation(annotation)
+ {
+ kind = K;
+ next = previous->next;
+ previous->next = this;
+ }
+
+ void accept0(BaseVisitor *visitor) override;
+
+ SourceLocation firstSourceLocation() const override
+ { return annotation->firstSourceLocation(); }
+
+ SourceLocation lastSourceLocation() const override
+ { return lastListElement(this)->annotation->lastSourceLocation(); }
+
+ UiAnnotationList *finish()
+ {
+ UiAnnotationList *head = next;
+ next = nullptr;
+ return head;
+ }
+
+// attributes
+ UiAnnotationList *next;
+ UiAnnotation *annotation;
+};
+
+} } // namespace AST
QT_END_NAMESPACE
diff --git a/src/qml/parser/qqmljsastfwd_p.h b/src/qml/parser/qqmljsastfwd_p.h
index 8a8ee2dfae..ef37e8072f 100644
--- a/src/qml/parser/qqmljsastfwd_p.h
+++ b/src/qml/parser/qqmljsastfwd_p.h
@@ -41,7 +41,7 @@
#define QQMLJSAST_FWD_P_H
#include "qqmljsglobal_p.h"
-#include "qqmljssourcelocation_p.h"
+#include <private/qqmljssourcelocation_p.h>
#include <QtCore/qglobal.h>
@@ -60,6 +60,7 @@ QT_BEGIN_NAMESPACE
namespace QQmlJS { namespace AST {
+class BaseVisitor;
class Visitor;
class Node;
class ExpressionNode;
@@ -151,7 +152,6 @@ class NamedImport;
class ImportClause;
class FromClause;
class ImportDeclaration;
-class ModuleItem;
class ESModule;
class DebuggerStatement;
class NestedExpression;
@@ -183,6 +183,9 @@ class UiHeaderItemList;
class UiEnumDeclaration;
class UiEnumMemberList;
class UiVersionSpecifier;
+class UiRequired;
+class UiAnnotation;
+class UiAnnotationList;
} // namespace AST
} // namespace QQmlJS
diff --git a/src/qml/parser/qqmljsastvisitor.cpp b/src/qml/parser/qqmljsastvisitor.cpp
index 5ecac36423..7388eccebb 100644
--- a/src/qml/parser/qqmljsastvisitor.cpp
+++ b/src/qml/parser/qqmljsastvisitor.cpp
@@ -43,11 +43,13 @@ QT_BEGIN_NAMESPACE
namespace QQmlJS { namespace AST {
-Visitor::Visitor(quint16 parentRecursionDepth) : m_recursionDepth(parentRecursionDepth)
+Visitor::Visitor(quint16 parentRecursionDepth) : BaseVisitor(parentRecursionDepth)
{
}
-Visitor::~Visitor()
+BaseVisitor::BaseVisitor(quint16 parentRecursionDepth) : m_recursionDepth(parentRecursionDepth) {}
+
+BaseVisitor::~BaseVisitor()
{
}
diff --git a/src/qml/parser/qqmljsastvisitor_p.h b/src/qml/parser/qqmljsastvisitor_p.h
index d6b92990ad..8fbdb97ee2 100644
--- a/src/qml/parser/qqmljsastvisitor_p.h
+++ b/src/qml/parser/qqmljsastvisitor_p.h
@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
namespace QQmlJS { namespace AST {
-class QML_PARSER_EXPORT Visitor
+class QML_PARSER_EXPORT BaseVisitor
{
public:
class RecursionDepthCheck
@@ -68,7 +68,7 @@ public:
RecursionDepthCheck(RecursionDepthCheck &&) = delete;
RecursionDepthCheck &operator=(RecursionDepthCheck &&) = delete;
- RecursionDepthCheck(Visitor *visitor) : m_visitor(visitor)
+ RecursionDepthCheck(BaseVisitor *visitor) : m_visitor(visitor)
{
++(m_visitor->m_recursionDepth);
}
@@ -84,335 +84,338 @@ public:
private:
static const quint16 s_recursionLimit = 4096;
- Visitor *m_visitor;
+ BaseVisitor *m_visitor;
};
- Visitor(quint16 parentRecursionDepth = 0);
- virtual ~Visitor();
+ BaseVisitor(quint16 parentRecursionDepth = 0);
+ virtual ~BaseVisitor();
- virtual bool preVisit(Node *) { return true; }
- virtual void postVisit(Node *) {}
+ virtual bool preVisit(Node *) = 0;
+ virtual void postVisit(Node *) = 0;
// Ui
- virtual bool visit(UiProgram *) { return true; }
- virtual bool visit(UiHeaderItemList *) { return true; }
- virtual bool visit(UiPragma *) { return true; }
- virtual bool visit(UiImport *) { return true; }
- virtual bool visit(UiPublicMember *) { return true; }
- virtual bool visit(UiSourceElement *) { return true; }
- virtual bool visit(UiObjectDefinition *) { return true; }
- virtual bool visit(UiObjectInitializer *) { return true; }
- virtual bool visit(UiObjectBinding *) { return true; }
- virtual bool visit(UiScriptBinding *) { return true; }
- virtual bool visit(UiArrayBinding *) { return true; }
- virtual bool visit(UiParameterList *) { return true; }
- virtual bool visit(UiObjectMemberList *) { return true; }
- virtual bool visit(UiArrayMemberList *) { return true; }
- virtual bool visit(UiQualifiedId *) { return true; }
- virtual bool visit(UiEnumDeclaration *) { return true; }
- virtual bool visit(UiEnumMemberList *) { return true; }
- virtual bool visit(UiVersionSpecifier *) { return true; }
- virtual bool visit(UiInlineComponent *) { return true; }
-
- virtual void endVisit(UiProgram *) {}
- virtual void endVisit(UiImport *) {}
- virtual void endVisit(UiHeaderItemList *) {}
- virtual void endVisit(UiPragma *) {}
- virtual void endVisit(UiPublicMember *) {}
- virtual void endVisit(UiSourceElement *) {}
- virtual void endVisit(UiObjectDefinition *) {}
- virtual void endVisit(UiObjectInitializer *) {}
- virtual void endVisit(UiObjectBinding *) {}
- virtual void endVisit(UiScriptBinding *) {}
- virtual void endVisit(UiArrayBinding *) {}
- virtual void endVisit(UiParameterList *) {}
- virtual void endVisit(UiObjectMemberList *) {}
- virtual void endVisit(UiArrayMemberList *) {}
- virtual void endVisit(UiQualifiedId *) {}
- virtual void endVisit(UiEnumDeclaration *) {}
- virtual void endVisit(UiEnumMemberList *) { }
- virtual void endVisit(UiVersionSpecifier *) {}
- virtual void endVisit(UiInlineComponent *) {}
+ virtual bool visit(UiProgram *) = 0;
+ virtual bool visit(UiHeaderItemList *) = 0;
+ virtual bool visit(UiPragma *) = 0;
+ virtual bool visit(UiImport *) = 0;
+ virtual bool visit(UiPublicMember *) = 0;
+ virtual bool visit(UiSourceElement *) = 0;
+ virtual bool visit(UiObjectDefinition *) = 0;
+ virtual bool visit(UiObjectInitializer *) = 0;
+ virtual bool visit(UiObjectBinding *) = 0;
+ virtual bool visit(UiScriptBinding *) = 0;
+ virtual bool visit(UiArrayBinding *) = 0;
+ virtual bool visit(UiParameterList *) = 0;
+ virtual bool visit(UiObjectMemberList *) = 0;
+ virtual bool visit(UiArrayMemberList *) = 0;
+ virtual bool visit(UiQualifiedId *) = 0;
+ virtual bool visit(UiEnumDeclaration *) = 0;
+ virtual bool visit(UiEnumMemberList *) = 0;
+ virtual bool visit(UiVersionSpecifier *) = 0;
+ virtual bool visit(UiInlineComponent *) = 0;
+ virtual bool visit(UiAnnotation *) = 0;
+ virtual bool visit(UiAnnotationList *) = 0;
+ virtual bool visit(UiRequired *) = 0;
+
+ virtual void endVisit(UiProgram *) = 0;
+ virtual void endVisit(UiImport *) = 0;
+ virtual void endVisit(UiHeaderItemList *) = 0;
+ virtual void endVisit(UiPragma *) = 0;
+ virtual void endVisit(UiPublicMember *) = 0;
+ virtual void endVisit(UiSourceElement *) = 0;
+ virtual void endVisit(UiObjectDefinition *) = 0;
+ virtual void endVisit(UiObjectInitializer *) = 0;
+ virtual void endVisit(UiObjectBinding *) = 0;
+ virtual void endVisit(UiScriptBinding *) = 0;
+ virtual void endVisit(UiArrayBinding *) = 0;
+ virtual void endVisit(UiParameterList *) = 0;
+ virtual void endVisit(UiObjectMemberList *) = 0;
+ virtual void endVisit(UiArrayMemberList *) = 0;
+ virtual void endVisit(UiQualifiedId *) = 0;
+ virtual void endVisit(UiEnumDeclaration *) = 0;
+ virtual void endVisit(UiEnumMemberList *) = 0;
+ virtual void endVisit(UiVersionSpecifier *) = 0;
+ virtual void endVisit(UiInlineComponent *) = 0;
+ virtual void endVisit(UiAnnotation *) = 0;
+ virtual void endVisit(UiAnnotationList *) = 0;
+ virtual void endVisit(UiRequired *) = 0;
// QQmlJS
- virtual bool visit(ThisExpression *) { return true; }
- virtual void endVisit(ThisExpression *) {}
-
- virtual bool visit(IdentifierExpression *) { return true; }
- virtual void endVisit(IdentifierExpression *) {}
+ virtual bool visit(ThisExpression *) = 0;
+ virtual void endVisit(ThisExpression *) = 0;
- virtual bool visit(NullExpression *) { return true; }
- virtual void endVisit(NullExpression *) {}
+ virtual bool visit(IdentifierExpression *) = 0;
+ virtual void endVisit(IdentifierExpression *) = 0;
- virtual bool visit(TrueLiteral *) { return true; }
- virtual void endVisit(TrueLiteral *) {}
+ virtual bool visit(NullExpression *) = 0;
+ virtual void endVisit(NullExpression *) = 0;
- virtual bool visit(FalseLiteral *) { return true; }
- virtual void endVisit(FalseLiteral *) {}
+ virtual bool visit(TrueLiteral *) = 0;
+ virtual void endVisit(TrueLiteral *) = 0;
- virtual bool visit(SuperLiteral *) { return true; }
- virtual void endVisit(SuperLiteral *) {}
+ virtual bool visit(FalseLiteral *) = 0;
+ virtual void endVisit(FalseLiteral *) = 0;
- virtual bool visit(StringLiteral *) { return true; }
- virtual void endVisit(StringLiteral *) {}
+ virtual bool visit(SuperLiteral *) = 0;
+ virtual void endVisit(SuperLiteral *) = 0;
- virtual bool visit(TemplateLiteral *) { return true; }
- virtual void endVisit(TemplateLiteral *) {}
+ virtual bool visit(StringLiteral *) = 0;
+ virtual void endVisit(StringLiteral *) = 0;
- virtual bool visit(NumericLiteral *) { return true; }
- virtual void endVisit(NumericLiteral *) {}
+ virtual bool visit(TemplateLiteral *) = 0;
+ virtual void endVisit(TemplateLiteral *) = 0;
- virtual bool visit(RegExpLiteral *) { return true; }
- virtual void endVisit(RegExpLiteral *) {}
+ virtual bool visit(NumericLiteral *) = 0;
+ virtual void endVisit(NumericLiteral *) = 0;
- virtual bool visit(ArrayPattern *) { return true; }
- virtual void endVisit(ArrayPattern *) {}
+ virtual bool visit(RegExpLiteral *) = 0;
+ virtual void endVisit(RegExpLiteral *) = 0;
- virtual bool visit(ObjectPattern *) { return true; }
- virtual void endVisit(ObjectPattern *) {}
+ virtual bool visit(ArrayPattern *) = 0;
+ virtual void endVisit(ArrayPattern *) = 0;
- virtual bool visit(PatternElementList *) { return true; }
- virtual void endVisit(PatternElementList *) {}
+ virtual bool visit(ObjectPattern *) = 0;
+ virtual void endVisit(ObjectPattern *) = 0;
- virtual bool visit(PatternPropertyList *) { return true; }
- virtual void endVisit(PatternPropertyList *) {}
+ virtual bool visit(PatternElementList *) = 0;
+ virtual void endVisit(PatternElementList *) = 0;
- virtual bool visit(PatternElement *) { return true; }
- virtual void endVisit(PatternElement *) {}
+ virtual bool visit(PatternPropertyList *) = 0;
+ virtual void endVisit(PatternPropertyList *) = 0;
- virtual bool visit(PatternProperty *) { return true; }
- virtual void endVisit(PatternProperty *) {}
+ virtual bool visit(PatternElement *) = 0;
+ virtual void endVisit(PatternElement *) = 0;
- virtual bool visit(Elision *) { return true; }
- virtual void endVisit(Elision *) {}
+ virtual bool visit(PatternProperty *) = 0;
+ virtual void endVisit(PatternProperty *) = 0;
- virtual bool visit(NestedExpression *) { return true; }
- virtual void endVisit(NestedExpression *) {}
+ virtual bool visit(Elision *) = 0;
+ virtual void endVisit(Elision *) = 0;
- virtual bool visit(IdentifierPropertyName *) { return true; }
- virtual void endVisit(IdentifierPropertyName *) {}
+ virtual bool visit(NestedExpression *) = 0;
+ virtual void endVisit(NestedExpression *) = 0;
- virtual bool visit(StringLiteralPropertyName *) { return true; }
- virtual void endVisit(StringLiteralPropertyName *) {}
+ virtual bool visit(IdentifierPropertyName *) = 0;
+ virtual void endVisit(IdentifierPropertyName *) = 0;
- virtual bool visit(NumericLiteralPropertyName *) { return true; }
- virtual void endVisit(NumericLiteralPropertyName *) {}
+ virtual bool visit(StringLiteralPropertyName *) = 0;
+ virtual void endVisit(StringLiteralPropertyName *) = 0;
- virtual bool visit(ComputedPropertyName *) { return true; }
- virtual void endVisit(ComputedPropertyName *) {}
+ virtual bool visit(NumericLiteralPropertyName *) = 0;
+ virtual void endVisit(NumericLiteralPropertyName *) = 0;
- virtual bool visit(ArrayMemberExpression *) { return true; }
- virtual void endVisit(ArrayMemberExpression *) {}
+ virtual bool visit(ComputedPropertyName *) = 0;
+ virtual void endVisit(ComputedPropertyName *) = 0;
- virtual bool visit(FieldMemberExpression *) { return true; }
- virtual void endVisit(FieldMemberExpression *) {}
+ virtual bool visit(ArrayMemberExpression *) = 0;
+ virtual void endVisit(ArrayMemberExpression *) = 0;
- virtual bool visit(TaggedTemplate *) { return true; }
- virtual void endVisit(TaggedTemplate *) {}
+ virtual bool visit(FieldMemberExpression *) = 0;
+ virtual void endVisit(FieldMemberExpression *) = 0;
- virtual bool visit(NewMemberExpression *) { return true; }
- virtual void endVisit(NewMemberExpression *) {}
+ virtual bool visit(TaggedTemplate *) = 0;
+ virtual void endVisit(TaggedTemplate *) = 0;
- virtual bool visit(NewExpression *) { return true; }
- virtual void endVisit(NewExpression *) {}
+ virtual bool visit(NewMemberExpression *) = 0;
+ virtual void endVisit(NewMemberExpression *) = 0;
- virtual bool visit(CallExpression *) { return true; }
- virtual void endVisit(CallExpression *) {}
+ virtual bool visit(NewExpression *) = 0;
+ virtual void endVisit(NewExpression *) = 0;
- virtual bool visit(ArgumentList *) { return true; }
- virtual void endVisit(ArgumentList *) {}
+ virtual bool visit(CallExpression *) = 0;
+ virtual void endVisit(CallExpression *) = 0;
- virtual bool visit(PostIncrementExpression *) { return true; }
- virtual void endVisit(PostIncrementExpression *) {}
+ virtual bool visit(ArgumentList *) = 0;
+ virtual void endVisit(ArgumentList *) = 0;
- virtual bool visit(PostDecrementExpression *) { return true; }
- virtual void endVisit(PostDecrementExpression *) {}
+ virtual bool visit(PostIncrementExpression *) = 0;
+ virtual void endVisit(PostIncrementExpression *) = 0;
- virtual bool visit(DeleteExpression *) { return true; }
- virtual void endVisit(DeleteExpression *) {}
+ virtual bool visit(PostDecrementExpression *) = 0;
+ virtual void endVisit(PostDecrementExpression *) = 0;
- virtual bool visit(VoidExpression *) { return true; }
- virtual void endVisit(VoidExpression *) {}
+ virtual bool visit(DeleteExpression *) = 0;
+ virtual void endVisit(DeleteExpression *) = 0;
- virtual bool visit(TypeOfExpression *) { return true; }
- virtual void endVisit(TypeOfExpression *) {}
+ virtual bool visit(VoidExpression *) = 0;
+ virtual void endVisit(VoidExpression *) = 0;
- virtual bool visit(PreIncrementExpression *) { return true; }
- virtual void endVisit(PreIncrementExpression *) {}
+ virtual bool visit(TypeOfExpression *) = 0;
+ virtual void endVisit(TypeOfExpression *) = 0;
- virtual bool visit(PreDecrementExpression *) { return true; }
- virtual void endVisit(PreDecrementExpression *) {}
+ virtual bool visit(PreIncrementExpression *) = 0;
+ virtual void endVisit(PreIncrementExpression *) = 0;
- virtual bool visit(UnaryPlusExpression *) { return true; }
- virtual void endVisit(UnaryPlusExpression *) {}
+ virtual bool visit(PreDecrementExpression *) = 0;
+ virtual void endVisit(PreDecrementExpression *) = 0;
- virtual bool visit(UnaryMinusExpression *) { return true; }
- virtual void endVisit(UnaryMinusExpression *) {}
+ virtual bool visit(UnaryPlusExpression *) = 0;
+ virtual void endVisit(UnaryPlusExpression *) = 0;
- virtual bool visit(TildeExpression *) { return true; }
- virtual void endVisit(TildeExpression *) {}
+ virtual bool visit(UnaryMinusExpression *) = 0;
+ virtual void endVisit(UnaryMinusExpression *) = 0;
- virtual bool visit(NotExpression *) { return true; }
- virtual void endVisit(NotExpression *) {}
+ virtual bool visit(TildeExpression *) = 0;
+ virtual void endVisit(TildeExpression *) = 0;
- virtual bool visit(BinaryExpression *) { return true; }
- virtual void endVisit(BinaryExpression *) {}
+ virtual bool visit(NotExpression *) = 0;
+ virtual void endVisit(NotExpression *) = 0;
- virtual bool visit(ConditionalExpression *) { return true; }
- virtual void endVisit(ConditionalExpression *) {}
+ virtual bool visit(BinaryExpression *) = 0;
+ virtual void endVisit(BinaryExpression *) = 0;
- virtual bool visit(Expression *) { return true; }
- virtual void endVisit(Expression *) {}
+ virtual bool visit(ConditionalExpression *) = 0;
+ virtual void endVisit(ConditionalExpression *) = 0;
- virtual bool visit(Block *) { return true; }
- virtual void endVisit(Block *) {}
+ virtual bool visit(Expression *) = 0;
+ virtual void endVisit(Expression *) = 0;
- virtual bool visit(StatementList *) { return true; }
- virtual void endVisit(StatementList *) {}
+ virtual bool visit(Block *) = 0;
+ virtual void endVisit(Block *) = 0;
- virtual bool visit(VariableStatement *) { return true; }
- virtual void endVisit(VariableStatement *) {}
+ virtual bool visit(StatementList *) = 0;
+ virtual void endVisit(StatementList *) = 0;
- virtual bool visit(VariableDeclarationList *) { return true; }
- virtual void endVisit(VariableDeclarationList *) {}
+ virtual bool visit(VariableStatement *) = 0;
+ virtual void endVisit(VariableStatement *) = 0;
- virtual bool visit(EmptyStatement *) { return true; }
- virtual void endVisit(EmptyStatement *) {}
+ virtual bool visit(VariableDeclarationList *) = 0;
+ virtual void endVisit(VariableDeclarationList *) = 0;
- virtual bool visit(ExpressionStatement *) { return true; }
- virtual void endVisit(ExpressionStatement *) {}
+ virtual bool visit(EmptyStatement *) = 0;
+ virtual void endVisit(EmptyStatement *) = 0;
- virtual bool visit(IfStatement *) { return true; }
- virtual void endVisit(IfStatement *) {}
+ virtual bool visit(ExpressionStatement *) = 0;
+ virtual void endVisit(ExpressionStatement *) = 0;
- virtual bool visit(DoWhileStatement *) { return true; }
- virtual void endVisit(DoWhileStatement *) {}
+ virtual bool visit(IfStatement *) = 0;
+ virtual void endVisit(IfStatement *) = 0;
- virtual bool visit(WhileStatement *) { return true; }
- virtual void endVisit(WhileStatement *) {}
+ virtual bool visit(DoWhileStatement *) = 0;
+ virtual void endVisit(DoWhileStatement *) = 0;
- virtual bool visit(ForStatement *) { return true; }
- virtual void endVisit(ForStatement *) {}
+ virtual bool visit(WhileStatement *) = 0;
+ virtual void endVisit(WhileStatement *) = 0;
- virtual bool visit(ForEachStatement *) { return true; }
- virtual void endVisit(ForEachStatement *) {}
+ virtual bool visit(ForStatement *) = 0;
+ virtual void endVisit(ForStatement *) = 0;
- virtual bool visit(ContinueStatement *) { return true; }
- virtual void endVisit(ContinueStatement *) {}
+ virtual bool visit(ForEachStatement *) = 0;
+ virtual void endVisit(ForEachStatement *) = 0;
- virtual bool visit(BreakStatement *) { return true; }
- virtual void endVisit(BreakStatement *) {}
+ virtual bool visit(ContinueStatement *) = 0;
+ virtual void endVisit(ContinueStatement *) = 0;
- virtual bool visit(ReturnStatement *) { return true; }
- virtual void endVisit(ReturnStatement *) {}
+ virtual bool visit(BreakStatement *) = 0;
+ virtual void endVisit(BreakStatement *) = 0;
- virtual bool visit(YieldExpression *) { return true; }
- virtual void endVisit(YieldExpression *) {}
+ virtual bool visit(ReturnStatement *) = 0;
+ virtual void endVisit(ReturnStatement *) = 0;
- virtual bool visit(WithStatement *) { return true; }
- virtual void endVisit(WithStatement *) {}
+ virtual bool visit(YieldExpression *) = 0;
+ virtual void endVisit(YieldExpression *) = 0;
- virtual bool visit(SwitchStatement *) { return true; }
- virtual void endVisit(SwitchStatement *) {}
+ virtual bool visit(WithStatement *) = 0;
+ virtual void endVisit(WithStatement *) = 0;
- virtual bool visit(CaseBlock *) { return true; }
- virtual void endVisit(CaseBlock *) {}
+ virtual bool visit(SwitchStatement *) = 0;
+ virtual void endVisit(SwitchStatement *) = 0;
- virtual bool visit(CaseClauses *) { return true; }
- virtual void endVisit(CaseClauses *) {}
+ virtual bool visit(CaseBlock *) = 0;
+ virtual void endVisit(CaseBlock *) = 0;
- virtual bool visit(CaseClause *) { return true; }
- virtual void endVisit(CaseClause *) {}
+ virtual bool visit(CaseClauses *) = 0;
+ virtual void endVisit(CaseClauses *) = 0;
- virtual bool visit(DefaultClause *) { return true; }
- virtual void endVisit(DefaultClause *) {}
+ virtual bool visit(CaseClause *) = 0;
+ virtual void endVisit(CaseClause *) = 0;
- virtual bool visit(LabelledStatement *) { return true; }
- virtual void endVisit(LabelledStatement *) {}
+ virtual bool visit(DefaultClause *) = 0;
+ virtual void endVisit(DefaultClause *) = 0;
- virtual bool visit(ThrowStatement *) { return true; }
- virtual void endVisit(ThrowStatement *) {}
+ virtual bool visit(LabelledStatement *) = 0;
+ virtual void endVisit(LabelledStatement *) = 0;
- virtual bool visit(TryStatement *) { return true; }
- virtual void endVisit(TryStatement *) {}
+ virtual bool visit(ThrowStatement *) = 0;
+ virtual void endVisit(ThrowStatement *) = 0;
- virtual bool visit(Catch *) { return true; }
- virtual void endVisit(Catch *) {}
+ virtual bool visit(TryStatement *) = 0;
+ virtual void endVisit(TryStatement *) = 0;
- virtual bool visit(Finally *) { return true; }
- virtual void endVisit(Finally *) {}
+ virtual bool visit(Catch *) = 0;
+ virtual void endVisit(Catch *) = 0;
- virtual bool visit(FunctionDeclaration *) { return true; }
- virtual void endVisit(FunctionDeclaration *) {}
+ virtual bool visit(Finally *) = 0;
+ virtual void endVisit(Finally *) = 0;
- virtual bool visit(FunctionExpression *) { return true; }
- virtual void endVisit(FunctionExpression *) {}
+ virtual bool visit(FunctionDeclaration *) = 0;
+ virtual void endVisit(FunctionDeclaration *) = 0;
- virtual bool visit(FormalParameterList *) { return true; }
- virtual void endVisit(FormalParameterList *) {}
+ virtual bool visit(FunctionExpression *) = 0;
+ virtual void endVisit(FunctionExpression *) = 0;
- virtual bool visit(ClassExpression *) { return true; }
- virtual void endVisit(ClassExpression *) {}
+ virtual bool visit(FormalParameterList *) = 0;
+ virtual void endVisit(FormalParameterList *) = 0;
- virtual bool visit(ClassDeclaration *) { return true; }
- virtual void endVisit(ClassDeclaration *) {}
+ virtual bool visit(ClassExpression *) = 0;
+ virtual void endVisit(ClassExpression *) = 0;
- virtual bool visit(ClassElementList *) { return true; }
- virtual void endVisit(ClassElementList *) {}
+ virtual bool visit(ClassDeclaration *) = 0;
+ virtual void endVisit(ClassDeclaration *) = 0;
- virtual bool visit(Program *) { return true; }
- virtual void endVisit(Program *) {}
+ virtual bool visit(ClassElementList *) = 0;
+ virtual void endVisit(ClassElementList *) = 0;
- virtual bool visit(NameSpaceImport *) { return true; }
- virtual void endVisit(NameSpaceImport *) {}
+ virtual bool visit(Program *) = 0;
+ virtual void endVisit(Program *) = 0;
- virtual bool visit(ImportSpecifier *) { return true; }
- virtual void endVisit(ImportSpecifier *) {}
+ virtual bool visit(NameSpaceImport *) = 0;
+ virtual void endVisit(NameSpaceImport *) = 0;
- virtual bool visit(ImportsList *) { return true; }
- virtual void endVisit(ImportsList *) {}
+ virtual bool visit(ImportSpecifier *) = 0;
+ virtual void endVisit(ImportSpecifier *) = 0;
- virtual bool visit(NamedImports *) { return true; }
- virtual void endVisit(NamedImports *) {}
+ virtual bool visit(ImportsList *) = 0;
+ virtual void endVisit(ImportsList *) = 0;
- virtual bool visit(FromClause *) { return true; }
- virtual void endVisit(FromClause *) {}
+ virtual bool visit(NamedImports *) = 0;
+ virtual void endVisit(NamedImports *) = 0;
- virtual bool visit(ImportClause *) { return true; }
- virtual void endVisit(ImportClause *) {}
+ virtual bool visit(FromClause *) = 0;
+ virtual void endVisit(FromClause *) = 0;
- virtual bool visit(ImportDeclaration *) { return true; }
- virtual void endVisit(ImportDeclaration *) {}
+ virtual bool visit(ImportClause *) = 0;
+ virtual void endVisit(ImportClause *) = 0;
- virtual bool visit(ExportSpecifier *) { return true; }
- virtual void endVisit(ExportSpecifier *) {}
+ virtual bool visit(ImportDeclaration *) = 0;
+ virtual void endVisit(ImportDeclaration *) = 0;
- virtual bool visit(ExportsList *) { return true; }
- virtual void endVisit(ExportsList *) {}
+ virtual bool visit(ExportSpecifier *) = 0;
+ virtual void endVisit(ExportSpecifier *) = 0;
- virtual bool visit(ExportClause *) { return true; }
- virtual void endVisit(ExportClause *) {}
+ virtual bool visit(ExportsList *) = 0;
+ virtual void endVisit(ExportsList *) = 0;
- virtual bool visit(ExportDeclaration *) { return true; }
- virtual void endVisit(ExportDeclaration *) {}
+ virtual bool visit(ExportClause *) = 0;
+ virtual void endVisit(ExportClause *) = 0;
- virtual bool visit(ModuleItem *) { return true; }
- virtual void endVisit(ModuleItem *) {}
+ virtual bool visit(ExportDeclaration *) = 0;
+ virtual void endVisit(ExportDeclaration *) = 0;
- virtual bool visit(ESModule *) { return true; }
- virtual void endVisit(ESModule *) {}
+ virtual bool visit(ESModule *) = 0;
+ virtual void endVisit(ESModule *) = 0;
- virtual bool visit(DebuggerStatement *) { return true; }
- virtual void endVisit(DebuggerStatement *) {}
+ virtual bool visit(DebuggerStatement *) = 0;
+ virtual void endVisit(DebuggerStatement *) = 0;
- virtual bool visit(Type *) { return true; }
- virtual void endVisit(Type *) {}
+ virtual bool visit(Type *) = 0;
+ virtual void endVisit(Type *) = 0;
- virtual bool visit(TypeArgumentList *) { return true; }
- virtual void endVisit(TypeArgumentList *) {}
+ virtual bool visit(TypeArgumentList *) = 0;
+ virtual void endVisit(TypeArgumentList *) = 0;
- virtual bool visit(TypeAnnotation *) { return true; }
- virtual void endVisit(TypeAnnotation *) {}
+ virtual bool visit(TypeAnnotation *) = 0;
+ virtual void endVisit(TypeAnnotation *) = 0;
virtual void throwRecursionDepthError() = 0;
@@ -423,6 +426,339 @@ protected:
friend class RecursionDepthCheck;
};
+class QML_PARSER_EXPORT Visitor: public BaseVisitor
+{
+public:
+ Visitor(quint16 parentRecursionDepth = 0);
+
+ bool preVisit(Node *) override { return true; }
+ void postVisit(Node *) override {}
+
+ // Ui
+ bool visit(UiProgram *) override { return true; }
+ bool visit(UiHeaderItemList *) override { return true; }
+ bool visit(UiPragma *) override { return true; }
+ bool visit(UiImport *) override { return true; }
+ bool visit(UiPublicMember *) override { return true; }
+ bool visit(UiSourceElement *) override { return true; }
+ bool visit(UiObjectDefinition *) override { return true; }
+ bool visit(UiObjectInitializer *) override { return true; }
+ bool visit(UiObjectBinding *) override { return true; }
+ bool visit(UiScriptBinding *) override { return true; }
+ bool visit(UiArrayBinding *) override { return true; }
+ bool visit(UiParameterList *) override { return true; }
+ bool visit(UiObjectMemberList *) override { return true; }
+ bool visit(UiArrayMemberList *) override { return true; }
+ bool visit(UiQualifiedId *) override { return true; }
+ bool visit(UiEnumDeclaration *) override { return true; }
+ bool visit(UiEnumMemberList *) override { return true; }
+ bool visit(UiVersionSpecifier *) override { return true; }
+ bool visit(UiInlineComponent *) override { return true; }
+ bool visit(UiAnnotation *) override { return true; }
+ bool visit(UiAnnotationList *) override { return true; }
+ bool visit(UiRequired *) override { return true; }
+
+ void endVisit(UiProgram *) override {}
+ void endVisit(UiImport *) override {}
+ void endVisit(UiHeaderItemList *) override {}
+ void endVisit(UiPragma *) override {}
+ void endVisit(UiPublicMember *) override {}
+ void endVisit(UiSourceElement *) override {}
+ void endVisit(UiObjectDefinition *) override {}
+ void endVisit(UiObjectInitializer *) override {}
+ void endVisit(UiObjectBinding *) override {}
+ void endVisit(UiScriptBinding *) override {}
+ void endVisit(UiArrayBinding *) override {}
+ void endVisit(UiParameterList *) override {}
+ void endVisit(UiObjectMemberList *) override {}
+ void endVisit(UiArrayMemberList *) override {}
+ void endVisit(UiQualifiedId *) override {}
+ void endVisit(UiEnumDeclaration *) override {}
+ void endVisit(UiEnumMemberList *) override {}
+ void endVisit(UiVersionSpecifier *) override {}
+ void endVisit(UiInlineComponent *) override {}
+ void endVisit(UiAnnotation *) override {}
+ void endVisit(UiAnnotationList *) override {}
+ void endVisit(UiRequired *) override {}
+
+ // QQmlJS
+ bool visit(ThisExpression *) override { return true; }
+ void endVisit(ThisExpression *) override {}
+
+ bool visit(IdentifierExpression *) override { return true; }
+ void endVisit(IdentifierExpression *) override {}
+
+ bool visit(NullExpression *) override { return true; }
+ void endVisit(NullExpression *) override {}
+
+ bool visit(TrueLiteral *) override { return true; }
+ void endVisit(TrueLiteral *) override {}
+
+ bool visit(FalseLiteral *) override { return true; }
+ void endVisit(FalseLiteral *) override {}
+
+ bool visit(SuperLiteral *) override { return true; }
+ void endVisit(SuperLiteral *) override {}
+
+ bool visit(StringLiteral *) override { return true; }
+ void endVisit(StringLiteral *) override {}
+
+ bool visit(TemplateLiteral *) override { return true; }
+ void endVisit(TemplateLiteral *) override {}
+
+ bool visit(NumericLiteral *) override { return true; }
+ void endVisit(NumericLiteral *) override {}
+
+ bool visit(RegExpLiteral *) override { return true; }
+ void endVisit(RegExpLiteral *) override {}
+
+ bool visit(ArrayPattern *) override { return true; }
+ void endVisit(ArrayPattern *) override {}
+
+ bool visit(ObjectPattern *) override { return true; }
+ void endVisit(ObjectPattern *) override {}
+
+ bool visit(PatternElementList *) override { return true; }
+ void endVisit(PatternElementList *) override {}
+
+ bool visit(PatternPropertyList *) override { return true; }
+ void endVisit(PatternPropertyList *) override {}
+
+ bool visit(PatternElement *) override { return true; }
+ void endVisit(PatternElement *) override {}
+
+ bool visit(PatternProperty *) override { return true; }
+ void endVisit(PatternProperty *) override {}
+
+ bool visit(Elision *) override { return true; }
+ void endVisit(Elision *) override {}
+
+ bool visit(NestedExpression *) override { return true; }
+ void endVisit(NestedExpression *) override {}
+
+ bool visit(IdentifierPropertyName *) override { return true; }
+ void endVisit(IdentifierPropertyName *) override {}
+
+ bool visit(StringLiteralPropertyName *) override { return true; }
+ void endVisit(StringLiteralPropertyName *) override {}
+
+ bool visit(NumericLiteralPropertyName *) override { return true; }
+ void endVisit(NumericLiteralPropertyName *) override {}
+
+ bool visit(ComputedPropertyName *) override { return true; }
+ void endVisit(ComputedPropertyName *) override {}
+
+ bool visit(ArrayMemberExpression *) override { return true; }
+ void endVisit(ArrayMemberExpression *) override {}
+
+ bool visit(FieldMemberExpression *) override { return true; }
+ void endVisit(FieldMemberExpression *) override {}
+
+ bool visit(TaggedTemplate *) override { return true; }
+ void endVisit(TaggedTemplate *) override {}
+
+ bool visit(NewMemberExpression *) override { return true; }
+ void endVisit(NewMemberExpression *) override {}
+
+ bool visit(NewExpression *) override { return true; }
+ void endVisit(NewExpression *) override {}
+
+ bool visit(CallExpression *) override { return true; }
+ void endVisit(CallExpression *) override {}
+
+ bool visit(ArgumentList *) override { return true; }
+ void endVisit(ArgumentList *) override {}
+
+ bool visit(PostIncrementExpression *) override { return true; }
+ void endVisit(PostIncrementExpression *) override {}
+
+ bool visit(PostDecrementExpression *) override { return true; }
+ void endVisit(PostDecrementExpression *) override {}
+
+ bool visit(DeleteExpression *) override { return true; }
+ void endVisit(DeleteExpression *) override {}
+
+ bool visit(VoidExpression *) override { return true; }
+ void endVisit(VoidExpression *) override {}
+
+ bool visit(TypeOfExpression *) override { return true; }
+ void endVisit(TypeOfExpression *) override {}
+
+ bool visit(PreIncrementExpression *) override { return true; }
+ void endVisit(PreIncrementExpression *) override {}
+
+ bool visit(PreDecrementExpression *) override { return true; }
+ void endVisit(PreDecrementExpression *) override {}
+
+ bool visit(UnaryPlusExpression *) override { return true; }
+ void endVisit(UnaryPlusExpression *) override {}
+
+ bool visit(UnaryMinusExpression *) override { return true; }
+ void endVisit(UnaryMinusExpression *) override {}
+
+ bool visit(TildeExpression *) override { return true; }
+ void endVisit(TildeExpression *) override {}
+
+ bool visit(NotExpression *) override { return true; }
+ void endVisit(NotExpression *) override {}
+
+ bool visit(BinaryExpression *) override { return true; }
+ void endVisit(BinaryExpression *) override {}
+
+ bool visit(ConditionalExpression *) override { return true; }
+ void endVisit(ConditionalExpression *) override {}
+
+ bool visit(Expression *) override { return true; }
+ void endVisit(Expression *) override {}
+
+ bool visit(Block *) override { return true; }
+ void endVisit(Block *) override {}
+
+ bool visit(StatementList *) override { return true; }
+ void endVisit(StatementList *) override {}
+
+ bool visit(VariableStatement *) override { return true; }
+ void endVisit(VariableStatement *) override {}
+
+ bool visit(VariableDeclarationList *) override { return true; }
+ void endVisit(VariableDeclarationList *) override {}
+
+ bool visit(EmptyStatement *) override { return true; }
+ void endVisit(EmptyStatement *) override {}
+
+ bool visit(ExpressionStatement *) override { return true; }
+ void endVisit(ExpressionStatement *) override {}
+
+ bool visit(IfStatement *) override { return true; }
+ void endVisit(IfStatement *) override {}
+
+ bool visit(DoWhileStatement *) override { return true; }
+ void endVisit(DoWhileStatement *) override {}
+
+ bool visit(WhileStatement *) override { return true; }
+ void endVisit(WhileStatement *) override {}
+
+ bool visit(ForStatement *) override { return true; }
+ void endVisit(ForStatement *) override {}
+
+ bool visit(ForEachStatement *) override { return true; }
+ void endVisit(ForEachStatement *) override {}
+
+ bool visit(ContinueStatement *) override { return true; }
+ void endVisit(ContinueStatement *) override {}
+
+ bool visit(BreakStatement *) override { return true; }
+ void endVisit(BreakStatement *) override {}
+
+ bool visit(ReturnStatement *) override { return true; }
+ void endVisit(ReturnStatement *) override {}
+
+ bool visit(YieldExpression *) override { return true; }
+ void endVisit(YieldExpression *) override {}
+
+ bool visit(WithStatement *) override { return true; }
+ void endVisit(WithStatement *) override {}
+
+ bool visit(SwitchStatement *) override { return true; }
+ void endVisit(SwitchStatement *) override {}
+
+ bool visit(CaseBlock *) override { return true; }
+ void endVisit(CaseBlock *) override {}
+
+ bool visit(CaseClauses *) override { return true; }
+ void endVisit(CaseClauses *) override {}
+
+ bool visit(CaseClause *) override { return true; }
+ void endVisit(CaseClause *) override {}
+
+ bool visit(DefaultClause *) override { return true; }
+ void endVisit(DefaultClause *) override {}
+
+ bool visit(LabelledStatement *) override { return true; }
+ void endVisit(LabelledStatement *) override {}
+
+ bool visit(ThrowStatement *) override { return true; }
+ void endVisit(ThrowStatement *) override {}
+
+ bool visit(TryStatement *) override { return true; }
+ void endVisit(TryStatement *) override {}
+
+ bool visit(Catch *) override { return true; }
+ void endVisit(Catch *) override {}
+
+ bool visit(Finally *) override { return true; }
+ void endVisit(Finally *) override {}
+
+ bool visit(FunctionDeclaration *) override { return true; }
+ void endVisit(FunctionDeclaration *) override {}
+
+ bool visit(FunctionExpression *) override { return true; }
+ void endVisit(FunctionExpression *) override {}
+
+ bool visit(FormalParameterList *) override { return true; }
+ void endVisit(FormalParameterList *) override {}
+
+ bool visit(ClassExpression *) override { return true; }
+ void endVisit(ClassExpression *) override {}
+
+ bool visit(ClassDeclaration *) override { return true; }
+ void endVisit(ClassDeclaration *) override {}
+
+ bool visit(ClassElementList *) override { return true; }
+ void endVisit(ClassElementList *) override {}
+
+ bool visit(Program *) override { return true; }
+ void endVisit(Program *) override {}
+
+ bool visit(NameSpaceImport *) override { return true; }
+ void endVisit(NameSpaceImport *) override {}
+
+ bool visit(ImportSpecifier *) override { return true; }
+ void endVisit(ImportSpecifier *) override {}
+
+ bool visit(ImportsList *) override { return true; }
+ void endVisit(ImportsList *) override {}
+
+ bool visit(NamedImports *) override { return true; }
+ void endVisit(NamedImports *) override {}
+
+ bool visit(FromClause *) override { return true; }
+ void endVisit(FromClause *) override {}
+
+ bool visit(ImportClause *) override { return true; }
+ void endVisit(ImportClause *) override {}
+
+ bool visit(ImportDeclaration *) override { return true; }
+ void endVisit(ImportDeclaration *) override {}
+
+ bool visit(ExportSpecifier *) override { return true; }
+ void endVisit(ExportSpecifier *) override {}
+
+ bool visit(ExportsList *) override { return true; }
+ void endVisit(ExportsList *) override {}
+
+ bool visit(ExportClause *) override { return true; }
+ void endVisit(ExportClause *) override {}
+
+ bool visit(ExportDeclaration *) override { return true; }
+ void endVisit(ExportDeclaration *) override {}
+
+ bool visit(ESModule *) override { return true; }
+ void endVisit(ESModule *) override {}
+
+ bool visit(DebuggerStatement *) override { return true; }
+ void endVisit(DebuggerStatement *) override {}
+
+ bool visit(Type *) override { return true; }
+ void endVisit(Type *) override {}
+
+ bool visit(TypeArgumentList *) override { return true; }
+ void endVisit(TypeArgumentList *) override {}
+
+ bool visit(TypeAnnotation *) override { return true; }
+ void endVisit(TypeAnnotation *) override {}
+};
+
} } // namespace AST
QT_END_NAMESPACE
diff --git a/src/qml/parser/qqmljsengine_p.cpp b/src/qml/parser/qqmljsengine_p.cpp
index bb27f3992e..cb6b0375e6 100644
--- a/src/qml/parser/qqmljsengine_p.cpp
+++ b/src/qml/parser/qqmljsengine_p.cpp
@@ -123,9 +123,9 @@ void Engine::setCode(const QString &code)
{ _code = code; }
void Engine::addComment(int pos, int len, int line, int col)
-{ if (len > 0) _comments.append(QQmlJS::AST::SourceLocation(pos, len, line, col)); }
+{ if (len > 0) _comments.append(QQmlJS::SourceLocation(pos, len, line, col)); }
-QList<QQmlJS::AST::SourceLocation> Engine::comments() const
+QList<QQmlJS::SourceLocation> Engine::comments() const
{ return _comments; }
Lexer *Engine::lexer() const
diff --git a/src/qml/parser/qqmljsengine_p.h b/src/qml/parser/qqmljsengine_p.h
index 8a3e2db6a1..a34922fa1e 100644
--- a/src/qml/parser/qqmljsengine_p.h
+++ b/src/qml/parser/qqmljsengine_p.h
@@ -52,7 +52,7 @@
//
#include "qqmljsglobal_p.h"
-#include "qqmljssourcelocation_p.h"
+#include <private/qqmljssourcelocation_p.h>
#include <private/qqmljsmemorypool_p.h>
@@ -97,7 +97,7 @@ class QML_PARSER_EXPORT Engine
Lexer *_lexer;
Directives *_directives;
MemoryPool _pool;
- QList<AST::SourceLocation> _comments;
+ QList<SourceLocation> _comments;
QString _extraCode;
QString _code;
@@ -109,7 +109,7 @@ public:
const QString &code() const { return _code; }
void addComment(int pos, int len, int line, int col);
- QList<AST::SourceLocation> comments() const;
+ QList<SourceLocation> comments() const;
Lexer *lexer() const;
void setLexer(Lexer *lexer);
diff --git a/src/qml/parser/qqmljslexer.cpp b/src/qml/parser/qqmljslexer.cpp
index 80d883e52f..243fc5bd30 100644
--- a/src/qml/parser/qqmljslexer.cpp
+++ b/src/qml/parser/qqmljslexer.cpp
@@ -719,6 +719,8 @@ again:
case ')': return T_RPAREN;
case '(': return T_LPAREN;
+ case '@': return T_AT;
+
case '&':
if (_char == QLatin1Char('=')) {
scanChar();
@@ -1478,8 +1480,8 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error)
{
auto setError = [error, this](QString message) {
error->message = std::move(message);
- error->line = tokenStartLine();
- error->column = tokenStartColumn();
+ error->loc.startLine = tokenStartLine();
+ error->loc.startColumn = tokenStartColumn();
};
QScopedValueRollback<bool> directivesGuard(_handlingDirectives, true);
@@ -1594,8 +1596,8 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error)
else
setError(QCoreApplication::translate("QQmlParser", "Module import requires a qualifier"));
if (tokenStartLine() != lineNumber) {
- error->line = lineNumber;
- error->line = column;
+ error->loc.startLine = lineNumber;
+ error->loc.startColumn = column;
}
return false; // expected `as'
}
diff --git a/src/qml/qml.pro b/src/qml/qml.pro
index 5b2ac4b5cf..7bb3547ee9 100644
--- a/src/qml/qml.pro
+++ b/src/qml/qml.pro
@@ -71,7 +71,7 @@ MODULE_PLUGIN_TYPES = \
QMLTYPES_FILENAME = plugins.qmltypes
QMLTYPES_INSTALL_DIR = $$[QT_INSTALL_QML]/QtQml
QML_IMPORT_NAME = QtQml
-IMPORT_VERSION = 2.15
+QML_IMPORT_VERSION = $$QT_VERSION
CONFIG += qmltypes install_qmltypes install_metatypes
load(qt_module)
diff --git a/src/qml/qml/ftw/qqmlthread.cpp b/src/qml/qml/ftw/qqmlthread.cpp
index 7d2ad354d6..0f7726ef65 100644
--- a/src/qml/qml/ftw/qqmlthread.cpp
+++ b/src/qml/qml/ftw/qqmlthread.cpp
@@ -188,13 +188,7 @@ void QQmlThreadPrivate::threadEvent()
lock();
for (;;) {
- if (m_shutdown) {
- quit();
- wakeOne();
- unlock();
-
- return;
- } else if (!threadList.isEmpty()) {
+ if (!threadList.isEmpty()) {
m_threadProcessing = true;
QQmlThread::Message *message = threadList.first();
@@ -206,6 +200,12 @@ void QQmlThreadPrivate::threadEvent()
lock();
delete threadList.takeFirst();
+ } else if (m_shutdown) {
+ quit();
+ wakeOne();
+ unlock();
+
+ return;
} else {
wakeOne();
@@ -242,6 +242,7 @@ void QQmlThread::shutdown()
d->lock();
Q_ASSERT(!d->m_shutdown);
+ d->m_shutdown = true;
for (;;) {
if (d->mainSync || !d->mainList.isEmpty()) {
d->unlock();
@@ -254,13 +255,10 @@ void QQmlThread::shutdown()
}
}
- d->m_shutdown = true;
- if (QCoreApplication::closingDown()) {
+ if (QCoreApplication::closingDown())
d->quit();
- } else {
+ else
d->triggerThreadEvent();
- d->wait();
- }
d->unlock();
d->QThread::wait();
diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp
index a33936647f..20dd3827c5 100644
--- a/src/qml/qml/qqml.cpp
+++ b/src/qml/qml/qqml.cpp
@@ -46,6 +46,7 @@
#include <private/qqmlmetatypedata_p.h>
#include <private/qqmltype_p_p.h>
#include <private/qqmltypemodule_p_p.h>
+#include <private/qqmltypenotavailable_p.h>
#include <QtCore/qmutex.h>
@@ -61,19 +62,20 @@ void qmlClearTypeRegistrations() // Declared in qqml.h
//From qqml.h
bool qmlProtectModule(const char *uri, int majVersion)
{
- return QQmlMetaType::protectModule(QString::fromUtf8(uri), majVersion);
+ return QQmlMetaType::protectModule(QString::fromUtf8(uri),
+ QTypeRevision::fromMajorVersion(majVersion));
}
//From qqml.h
void qmlRegisterModule(const char *uri, int versionMajor, int versionMinor)
{
- QQmlMetaType::registerModule(uri, versionMajor, versionMinor);
+ QQmlMetaType::registerModule(uri, QTypeRevision::fromVersion(versionMajor, versionMinor));
}
//From qqml.h
int qmlTypeId(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
{
- return QQmlMetaType::typeId(uri, versionMajor, versionMinor, qmlName);
+ return QQmlMetaType::typeId(uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName);
}
// From qqmlprivate.h
@@ -103,9 +105,9 @@ QObject *QQmlPrivate::RegisterSingletonFunctor::operator()(QQmlEngine *qeng, QJS
return m_object;
};
-static QVector<int> availableRevisions(const QMetaObject *metaObject)
+static QVector<QTypeRevision> availableRevisions(const QMetaObject *metaObject)
{
- QVector<int> revisions;
+ QVector<QTypeRevision> revisions;
if (!metaObject)
return revisions;
const int propertyOffset = metaObject->propertyOffset();
@@ -114,7 +116,7 @@ static QVector<int> availableRevisions(const QMetaObject *metaObject)
propertyIndex < propertyEnd; ++propertyIndex) {
const QMetaProperty property = metaObject->property(propertyIndex);
if (int revision = property.revision())
- revisions.append(revision);
+ revisions.append(QTypeRevision::fromEncodedVersion(revision));
}
const int methodOffset = metaObject->methodOffset();
const int methodCount = metaObject->methodCount();
@@ -122,7 +124,7 @@ static QVector<int> availableRevisions(const QMetaObject *metaObject)
methodIndex < methodEnd; ++methodIndex) {
const QMetaMethod method = metaObject->method(methodIndex);
if (int revision = method.revision())
- revisions.append(revision);
+ revisions.append(QTypeRevision::fromEncodedVersion(revision));
}
// Need to also check parent meta objects, as their revisions are inherited.
@@ -132,6 +134,54 @@ static QVector<int> availableRevisions(const QMetaObject *metaObject)
return revisions;
}
+template<typename Registration>
+void assignVersions(Registration *registration, QTypeRevision revision,
+ QTypeRevision defaultVersion)
+{
+ const quint8 majorVersion = revision.hasMajorVersion() ? revision.majorVersion()
+ : defaultVersion.majorVersion();
+ registration->version = revision.hasMinorVersion()
+ ? QTypeRevision::fromVersion(majorVersion, revision.minorVersion())
+ : QTypeRevision::fromMajorVersion(majorVersion);
+ registration->revision = revision;
+}
+
+static QVector<QTypeRevision> prepareRevisions(const QMetaObject *metaObject, QTypeRevision added)
+{
+ auto revisions = availableRevisions(metaObject);
+ revisions.append(added);
+ return revisions;
+}
+
+static void uniqueRevisions(QVector<QTypeRevision> *revisions, QTypeRevision defaultVersion,
+ QTypeRevision added)
+{
+ bool revisionsHaveMajorVersions = false;
+ for (QTypeRevision revision : QVector<QTypeRevision>(*revisions)) { // yes, copy
+ // allow any minor version for each explicitly specified past major one
+ if (revision.hasMajorVersion()) {
+ revisionsHaveMajorVersions = true;
+ if (revision.majorVersion() < defaultVersion.majorVersion())
+ revisions->append(QTypeRevision::fromVersion(revision.majorVersion(), 254));
+ }
+ }
+
+ if (revisionsHaveMajorVersions) {
+ if (!added.hasMajorVersion()) {
+ // If added in unspecified major version, assume default one.
+ revisions->append(QTypeRevision::fromVersion(defaultVersion.majorVersion(),
+ added.minorVersion()));
+ } else if (added.majorVersion() < defaultVersion.majorVersion()) {
+ // If added in past major version, add .0 of default version.
+ revisions->append(QTypeRevision::fromVersion(defaultVersion.majorVersion(), 0));
+ }
+ }
+
+ std::sort(revisions->begin(), revisions->end());
+ const auto it = std::unique(revisions->begin(), revisions->end());
+ revisions->erase(it, revisions->end());
+}
+
/*
This method is "over generalized" to allow us to (potentially) register more types of things in
the future without adding exported symbols.
@@ -163,8 +213,7 @@ int QQmlPrivate::qmlregister(RegistrationType type, void *data)
nullptr,
noCreateReason,
type.uri,
- type.versionMajor,
- -1,
+ type.version,
nullptr,
type.metaObject,
type.attachedPropertiesFunction,
@@ -175,28 +224,26 @@ int QQmlPrivate::qmlregister(RegistrationType type, void *data)
type.extensionObjectCreate,
type.extensionMetaObject,
nullptr,
- -1
+ QTypeRevision()
};
- const int added = intClassInfo(type.classInfoMetaObject, "QML.AddedInMinorVersion", 0);
- const int removed = intClassInfo(type.classInfoMetaObject, "QML.RemovedInMinorVersion", -1);
+ const QTypeRevision added = revisionClassInfo(
+ type.classInfoMetaObject, "QML.AddedInVersion",
+ QTypeRevision::fromMinorVersion(0));
+ const QTypeRevision removed = revisionClassInfo(
+ type.classInfoMetaObject, "QML.RemovedInVersion");
- auto revisions = availableRevisions(type.metaObject);
- revisions.append(qMax(added, 0));
+ auto revisions = prepareRevisions(type.metaObject, added);
if (type.attachedPropertiesMetaObject)
revisions += availableRevisions(type.attachedPropertiesMetaObject);
+ uniqueRevisions(&revisions, type.version, added);
- std::sort(revisions.begin(), revisions.end());
- const auto it = std::unique(revisions.begin(), revisions.end());
- revisions.erase(it, revisions.end());
-
- const bool typeWasRemoved = removed >= added;
- for (int revision : revisions) {
+ for (QTypeRevision revision : revisions) {
if (revision < added)
continue;
// When removed, we still add revisions, but anonymous ones
- if (typeWasRemoved && revision >= removed) {
+ if (removed.isValid() && !(revision < removed)) {
revisionRegistration.elementName = nullptr;
revisionRegistration.create = nullptr;
} else {
@@ -204,11 +251,8 @@ int QQmlPrivate::qmlregister(RegistrationType type, void *data)
revisionRegistration.create = creatable ? type.create : nullptr;
}
- // Equivalent of qmlRegisterRevision<T, revision>(...)
- revisionRegistration.versionMinor = revision;
- revisionRegistration.revision = revision;
+ assignVersions(&revisionRegistration, revision, type.version);
revisionRegistration.customParser = type.customParserFactory();
-
qmlregister(TypeRegistration, &revisionRegistration);
}
break;
@@ -220,36 +264,33 @@ int QQmlPrivate::qmlregister(RegistrationType type, void *data)
RegisterSingletonType revisionRegistration = {
QmlCurrentSingletonTypeRegistrationVersion,
type.uri,
- type.versionMajor,
- -1,
+ type.version,
elementName,
type.scriptApi,
nullptr,
type.instanceMetaObject,
type.typeId,
- -1,
+ QTypeRevision(),
type.generalizedQobjectApi
};
- const int added = intClassInfo(type.classInfoMetaObject, "QML.AddedInMinorVersion", 0);
- const int removed = intClassInfo(type.classInfoMetaObject, "QML.RemovedInMinorVersion", -1);
+ const QTypeRevision added = revisionClassInfo(
+ type.classInfoMetaObject, "QML.AddedInVersion",
+ QTypeRevision::fromMinorVersion(0));
+ const QTypeRevision removed = revisionClassInfo(
+ type.classInfoMetaObject, "QML.RemovedInVersion");
- auto revisions = availableRevisions(type.instanceMetaObject);
- revisions.append(qMax(added, 0));
+ auto revisions = prepareRevisions(type.instanceMetaObject, added);
+ uniqueRevisions(&revisions, type.version, added);
- std::sort(revisions.begin(), revisions.end());
- const auto it = std::unique(revisions.begin(), revisions.end());
- revisions.erase(it, revisions.end());
-
- const bool typeWasRemoved = removed >= added;
- for (int revision : qAsConst(revisions)) {
+ for (QTypeRevision revision : qAsConst(revisions)) {
if (revision < added)
continue;
// When removed, we still add revisions, but anonymous ones
- if (typeWasRemoved && revision >= removed) {
+ if (removed.isValid() && !(revision < removed)) {
revisionRegistration.typeName = nullptr;
revisionRegistration.scriptApi = nullptr;
revisionRegistration.generalizedQobjectApi = nullptr;
@@ -259,10 +300,7 @@ int QQmlPrivate::qmlregister(RegistrationType type, void *data)
revisionRegistration.generalizedQobjectApi = type.generalizedQobjectApi;
}
- // Equivalent of qmlRegisterRevision<T, revision>(...)
- revisionRegistration.versionMinor = revision;
- revisionRegistration.revision = revision;
-
+ assignVersions(&revisionRegistration, revision, type.version);
qmlregister(SingletonRegistration, &revisionRegistration);
}
break;
@@ -321,4 +359,38 @@ void QQmlPrivate::qmlunregister(RegistrationType type, quintptr data)
}
}
+namespace QQmlPrivate {
+ template<>
+ void qmlRegisterTypeAndRevisions<QQmlTypeNotAvailable, void>(
+ const char *uri, int versionMajor, const QMetaObject *classInfoMetaObject)
+ {
+ using T = QQmlTypeNotAvailable;
+
+ RegisterTypeAndRevisions type = {
+ 0,
+ QMetaType::fromType<T *>(),
+ QMetaType::fromType<QQmlListProperty<T>>(),
+ 0,
+ nullptr,
+
+ uri,
+ QTypeRevision::fromMajorVersion(versionMajor),
+
+ &QQmlTypeNotAvailable::staticMetaObject,
+ classInfoMetaObject,
+
+ attachedPropertiesFunc<T>(),
+ attachedPropertiesMetaObject<T>(),
+
+ StaticCastSelector<T, QQmlParserStatus>::cast(),
+ StaticCastSelector<T, QQmlPropertyValueSource>::cast(),
+ StaticCastSelector<T, QQmlPropertyValueInterceptor>::cast(),
+
+ nullptr, nullptr, qmlCreateCustomParser<T>
+ };
+
+ qmlregister(TypeAndRevisionsRegistration, &type);
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h
index ae3893dd73..840c6aaee3 100644
--- a/src/qml/qml/qqml.h
+++ b/src/qml/qml/qqml.h
@@ -44,6 +44,7 @@
#include <QtCore/qbytearray.h>
#include <QtCore/qmetaobject.h>
+#include <QtCore/qversionnumber.h>
#define QML_VERSION 0x020000
#define QML_VERSION_STR "2.0"
@@ -88,10 +89,16 @@
friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor);
#define QML_ADDED_IN_MINOR_VERSION(VERSION) \
- Q_CLASSINFO("QML.AddedInMinorVersion", #VERSION)
+ Q_CLASSINFO("QML.AddedInVersion", Q_REVISION(VERSION))
+
+#define QML_ADDED_IN_VERSION(MAJOR, MINOR) \
+ Q_CLASSINFO("QML.AddedInVersion", Q_REVISION(MAJOR, MINOR))
#define QML_REMOVED_IN_MINOR_VERSION(VERSION) \
- Q_CLASSINFO("QML.RemovedInMinorVersion", #VERSION)
+ Q_CLASSINFO("QML.RemovedInVersion", Q_REVISION(VERSION))
+
+#define QML_REMOVED_IN_VERSION(MAJOR, MINOR) \
+ Q_CLASSINFO("QML.RemovedInVersion", Q_REVISION(MAJOR, MINOR))
#define QML_ATTACHED(ATTACHED_TYPE) \
Q_CLASSINFO("QML.Attached", #ATTACHED_TYPE) \
@@ -113,6 +120,16 @@
template<typename T, typename... Args> \
friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor);
+#define QML_INTERFACE \
+ Q_CLASSINFO("QML.Element", "anonymous") \
+ enum class QmlIsInterface {yes = true}; \
+ template<typename, typename> friend struct QML_PRIVATE_NAMESPACE::QmlInterface; \
+ template<typename T, typename... Args> \
+ friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor);
+
+#define QML_UNAVAILABLE \
+ QML_FOREIGN(QQmlTypeNotAvailable)
+
enum { /* TYPEINFO flags */
QML_HAS_ATTACHED_PROPERTIES = 0x01
};
@@ -139,18 +156,16 @@ QQmlCustomParser *qmlCreateCustomParser();
template<typename T>
int qmlRegisterAnonymousType(const char *uri, int versionMajor)
{
- QML_GETTYPENAMES
-
QQmlPrivate::RegisterType type = {
0,
- qRegisterNormalizedMetaType<T *>(pointerName.constData()),
- qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
+ QMetaType::fromType<T *>(),
+ QMetaType::fromType<QQmlListProperty<T> >(),
0,
nullptr,
QString(),
- uri, versionMajor, 0, nullptr, &T::staticMetaObject,
+ uri, QTypeRevision::fromVersion(versionMajor, 0), nullptr, &T::staticMetaObject,
QQmlPrivate::attachedPropertiesFunc<T>(),
QQmlPrivate::attachedPropertiesMetaObject<T>(),
@@ -162,7 +177,7 @@ int qmlRegisterAnonymousType(const char *uri, int versionMajor)
nullptr, nullptr,
nullptr,
- 0
+ QTypeRevision::zero()
};
return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
@@ -176,23 +191,22 @@ QT_DEPRECATED_VERSION_X_5_14("Use qmlRegisterAnonymousType instead") int qmlRegi
}
#endif
-int Q_QML_EXPORT qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message);
+int Q_QML_EXPORT qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor,
+ const char *qmlName, const QString& message);
template<typename T>
int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason)
{
- QML_GETTYPENAMES
-
QQmlPrivate::RegisterType type = {
0,
- qRegisterNormalizedMetaType<T *>(pointerName.constData()),
- qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
+ QMetaType::fromType<T *>(),
+ QMetaType::fromType<QQmlListProperty<T>>(),
0,
nullptr,
reason,
- uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+ uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName, &T::staticMetaObject,
QQmlPrivate::attachedPropertiesFunc<T>(),
QQmlPrivate::attachedPropertiesMetaObject<T>(),
@@ -204,7 +218,7 @@ int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMin
nullptr, nullptr,
nullptr,
- 0
+ QTypeRevision::zero()
};
return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
@@ -213,18 +227,16 @@ int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMin
template<typename T, int metaObjectRevision>
int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason)
{
- QML_GETTYPENAMES
-
QQmlPrivate::RegisterType type = {
1,
- qRegisterNormalizedMetaType<T *>(pointerName.constData()),
- qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
+ QMetaType::fromType<T *>(),
+ QMetaType::fromType<QQmlListProperty<T> >(),
0,
nullptr,
reason,
- uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+ uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName, &T::staticMetaObject,
QQmlPrivate::attachedPropertiesFunc<T>(),
QQmlPrivate::attachedPropertiesMetaObject<T>(),
@@ -236,7 +248,7 @@ int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMin
nullptr, nullptr,
nullptr,
- metaObjectRevision
+ QTypeRevision::fromMinorVersion(metaObjectRevision)
};
return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
@@ -245,8 +257,6 @@ int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMin
template<typename T, typename E>
int qmlRegisterExtendedUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason)
{
- QML_GETTYPENAMES
-
QQmlAttachedPropertiesFunc attached = QQmlPrivate::attachedPropertiesFunc<E>();
const QMetaObject * attachedMetaObject = QQmlPrivate::attachedPropertiesMetaObject<E>();
if (!attached) {
@@ -257,13 +267,13 @@ int qmlRegisterExtendedUncreatableType(const char *uri, int versionMajor, int ve
QQmlPrivate::RegisterType type = {
0,
- qRegisterNormalizedMetaType<T *>(pointerName.constData()),
- qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
+ QMetaType::fromType<T *>(),
+ QMetaType::fromType<QQmlListProperty<T> >(),
0,
nullptr,
reason,
- uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+ uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName, &T::staticMetaObject,
attached,
attachedMetaObject,
@@ -275,7 +285,7 @@ int qmlRegisterExtendedUncreatableType(const char *uri, int versionMajor, int ve
QQmlPrivate::createParent<E>, &E::staticMetaObject,
nullptr,
- 0
+ QTypeRevision::zero()
};
return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
@@ -284,8 +294,6 @@ int qmlRegisterExtendedUncreatableType(const char *uri, int versionMajor, int ve
template<typename T, typename E, int metaObjectRevision>
int qmlRegisterExtendedUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason)
{
- QML_GETTYPENAMES
-
QQmlAttachedPropertiesFunc attached = QQmlPrivate::attachedPropertiesFunc<E>();
const QMetaObject * attachedMetaObject = QQmlPrivate::attachedPropertiesMetaObject<E>();
if (!attached) {
@@ -296,13 +304,13 @@ int qmlRegisterExtendedUncreatableType(const char *uri, int versionMajor, int ve
QQmlPrivate::RegisterType type = {
1,
- qRegisterNormalizedMetaType<T *>(pointerName.constData()),
- qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
+ QMetaType::fromType<T *>(),
+ QMetaType::fromType<QQmlListProperty<T> >(),
0,
nullptr,
reason,
- uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+ uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName, &T::staticMetaObject,
attached,
attachedMetaObject,
@@ -314,7 +322,7 @@ int qmlRegisterExtendedUncreatableType(const char *uri, int versionMajor, int ve
QQmlPrivate::createParent<E>, &E::staticMetaObject,
nullptr,
- metaObjectRevision
+ QTypeRevision::fromMinorVersion(metaObjectRevision)
};
return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
@@ -325,17 +333,15 @@ Q_QML_EXPORT int qmlRegisterUncreatableMetaObject(const QMetaObject &staticMetaO
template<typename T>
int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
{
- QML_GETTYPENAMES
-
QQmlPrivate::RegisterType type = {
0,
- qRegisterNormalizedMetaType<T *>(pointerName.constData()),
- qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
+ QMetaType::fromType<T *>(),
+ QMetaType::fromType<QQmlListProperty<T> >(),
sizeof(T), QQmlPrivate::createInto<T>,
QString(),
- uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+ uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName, &T::staticMetaObject,
QQmlPrivate::attachedPropertiesFunc<T>(),
QQmlPrivate::attachedPropertiesMetaObject<T>(),
@@ -347,7 +353,7 @@ int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const c
nullptr, nullptr,
nullptr,
- 0
+ QTypeRevision::zero()
};
return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
@@ -356,17 +362,15 @@ int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const c
template<typename T, int metaObjectRevision>
int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
{
- QML_GETTYPENAMES
-
QQmlPrivate::RegisterType type = {
1,
- qRegisterNormalizedMetaType<T *>(pointerName.constData()),
- qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
+ QMetaType::fromType<T *>(),
+ QMetaType::fromType<QQmlListProperty<T> >(),
sizeof(T), QQmlPrivate::createInto<T>,
QString(),
- uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+ uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName, &T::staticMetaObject,
QQmlPrivate::attachedPropertiesFunc<T>(),
QQmlPrivate::attachedPropertiesMetaObject<T>(),
@@ -378,7 +382,7 @@ int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const c
nullptr, nullptr,
nullptr,
- metaObjectRevision
+ QTypeRevision::fromMinorVersion(metaObjectRevision)
};
return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
@@ -387,17 +391,15 @@ int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const c
template<typename T, int metaObjectRevision>
int qmlRegisterRevision(const char *uri, int versionMajor, int versionMinor)
{
- QML_GETTYPENAMES
-
QQmlPrivate::RegisterType type = {
1,
- qRegisterNormalizedMetaType<T *>(pointerName.constData()),
- qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
+ QMetaType::fromType<T *>(),
+ QMetaType::fromType<QQmlListProperty<T> >(),
sizeof(T), QQmlPrivate::createInto<T>,
QString(),
- uri, versionMajor, versionMinor, nullptr, &T::staticMetaObject,
+ uri, QTypeRevision::fromVersion(versionMajor, versionMinor), nullptr, &T::staticMetaObject,
QQmlPrivate::attachedPropertiesFunc<T>(),
QQmlPrivate::attachedPropertiesMetaObject<T>(),
@@ -409,28 +411,25 @@ int qmlRegisterRevision(const char *uri, int versionMajor, int versionMinor)
nullptr, nullptr,
nullptr,
- metaObjectRevision
+ QTypeRevision::fromMinorVersion(metaObjectRevision)
};
return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
}
-
template<typename T, typename E>
-int qmlRegisterExtendedType()
+int qmlRegisterExtendedType(const char *uri, int versionMajor)
{
- QML_GETTYPENAMES
-
QQmlPrivate::RegisterType type = {
0,
- qRegisterNormalizedMetaType<T *>(pointerName.constData()),
- qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
+ QMetaType::fromType<T *>(),
+ QMetaType::fromType<QQmlListProperty<T> >(),
0,
nullptr,
QString(),
- nullptr, 0, 0, nullptr, &T::staticMetaObject,
+ uri, QTypeRevision::fromVersion(versionMajor, 0), nullptr, &T::staticMetaObject,
QQmlPrivate::attachedPropertiesFunc<T>(),
QQmlPrivate::attachedPropertiesMetaObject<T>(),
@@ -442,18 +441,25 @@ int qmlRegisterExtendedType()
QQmlPrivate::createParent<E>, &E::staticMetaObject,
nullptr,
- 0
+ QTypeRevision::zero()
};
return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
}
+#if QT_DEPRECATED_SINCE(5, 15)
+template<typename T, typename E>
+QT_DEPRECATED_VERSION_X_5_15("Use qmlRegisterExtendedType(uri, versionMajor) instead")
+int qmlRegisterExtendedType()
+{
+ return qmlRegisterExtendedType<T, E>("", 0);
+}
+#endif
+
template<typename T, typename E>
int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor,
const char *qmlName)
{
- QML_GETTYPENAMES
-
QQmlAttachedPropertiesFunc attached = QQmlPrivate::attachedPropertiesFunc<E>();
const QMetaObject * attachedMetaObject = QQmlPrivate::attachedPropertiesMetaObject<E>();
if (!attached) {
@@ -464,12 +470,12 @@ int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor,
QQmlPrivate::RegisterType type = {
0,
- qRegisterNormalizedMetaType<T *>(pointerName.constData()),
- qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
+ QMetaType::fromType<T *>(),
+ QMetaType::fromType<QQmlListProperty<T> >(),
sizeof(T), QQmlPrivate::createInto<T>,
QString(),
- uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+ uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName, &T::staticMetaObject,
attached,
attachedMetaObject,
@@ -481,13 +487,15 @@ int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor,
QQmlPrivate::createParent<E>, &E::staticMetaObject,
nullptr,
- 0
+ QTypeRevision::zero()
};
return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
}
+#if QT_DEPRECATED_SINCE(5, 15)
template<typename T>
+QT_DEPRECATED_VERSION_X_5_15("Use qmlRegisterInterface(uri, versionMajor) instead")
int qmlRegisterInterface(const char *typeName)
{
QByteArray name(typeName);
@@ -496,12 +504,31 @@ int qmlRegisterInterface(const char *typeName)
QByteArray listName("QQmlListProperty<" + name + '>');
QQmlPrivate::RegisterInterface qmlInterface = {
- 0,
+ 1,
- qRegisterNormalizedMetaType<T *>(pointerName.constData()),
- qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
+ QMetaType::fromType<T *>(),
+ QMetaType::fromType<QQmlListProperty<T> >(),
- qobject_interface_iid<T *>()
+ qobject_interface_iid<T *>(),
+ "",
+ QTypeRevision::zero()
+ };
+
+ return QQmlPrivate::qmlregister(QQmlPrivate::InterfaceRegistration, &qmlInterface);
+}
+#endif
+
+template<typename T>
+int qmlRegisterInterface(const char *uri, int versionMajor)
+{
+ QQmlPrivate::RegisterInterface qmlInterface = {
+ 1,
+ QMetaType::fromType<T *>(),
+ QMetaType::fromType<QQmlListProperty<T> >(),
+ qobject_interface_iid<T *>(),
+
+ uri,
+ QTypeRevision::fromVersion(versionMajor, 0)
};
return QQmlPrivate::qmlregister(QQmlPrivate::InterfaceRegistration, &qmlInterface);
@@ -511,17 +538,15 @@ template<typename T>
int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
const char *qmlName, QQmlCustomParser *parser)
{
- QML_GETTYPENAMES
-
QQmlPrivate::RegisterType type = {
0,
- qRegisterNormalizedMetaType<T *>(pointerName.constData()),
- qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
+ QMetaType::fromType<T *>(),
+ QMetaType::fromType<QQmlListProperty<T> >(),
sizeof(T), QQmlPrivate::createInto<T>,
QString(),
- uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+ uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName, &T::staticMetaObject,
QQmlPrivate::attachedPropertiesFunc<T>(),
QQmlPrivate::attachedPropertiesMetaObject<T>(),
@@ -533,7 +558,7 @@ int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
nullptr, nullptr,
parser,
- 0
+ QTypeRevision::zero()
};
return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
@@ -543,17 +568,15 @@ template<typename T, int metaObjectRevision>
int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
const char *qmlName, QQmlCustomParser *parser)
{
- QML_GETTYPENAMES
-
QQmlPrivate::RegisterType type = {
1,
- qRegisterNormalizedMetaType<T *>(pointerName.constData()),
- qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
+ QMetaType::fromType<T *>(),
+ QMetaType::fromType<QQmlListProperty<T> >(),
sizeof(T), QQmlPrivate::createInto<T>,
QString(),
- uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+ uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName, &T::staticMetaObject,
QQmlPrivate::attachedPropertiesFunc<T>(),
QQmlPrivate::attachedPropertiesMetaObject<T>(),
@@ -565,7 +588,7 @@ int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
nullptr, nullptr,
parser,
- metaObjectRevision
+ QTypeRevision::fromMinorVersion(metaObjectRevision)
};
return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
@@ -575,8 +598,6 @@ template<typename T, typename E>
int qmlRegisterCustomExtendedType(const char *uri, int versionMajor, int versionMinor,
const char *qmlName, QQmlCustomParser *parser)
{
- QML_GETTYPENAMES
-
QQmlAttachedPropertiesFunc attached = QQmlPrivate::attachedPropertiesFunc<E>();
const QMetaObject * attachedMetaObject = QQmlPrivate::attachedPropertiesMetaObject<E>();
if (!attached) {
@@ -587,12 +608,12 @@ int qmlRegisterCustomExtendedType(const char *uri, int versionMajor, int version
QQmlPrivate::RegisterType type = {
0,
- qRegisterNormalizedMetaType<T *>(pointerName.constData()),
- qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
+ QMetaType::fromType<T *>(),
+ QMetaType::fromType<QQmlListProperty<T> >(),
sizeof(T), QQmlPrivate::createInto<T>,
QString(),
- uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+ uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName, &T::staticMetaObject,
attached,
attachedMetaObject,
@@ -604,7 +625,7 @@ int qmlRegisterCustomExtendedType(const char *uri, int versionMajor, int version
QQmlPrivate::createParent<E>, &E::staticMetaObject,
parser,
- 0
+ QTypeRevision::zero()
};
return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
@@ -667,9 +688,9 @@ inline int qmlRegisterSingletonType(const char *uri, int versionMajor, int versi
QQmlPrivate::RegisterSingletonType api = {
0,
- uri, versionMajor, versionMinor, typeName,
+ uri, QTypeRevision::fromVersion(versionMajor, versionMinor), typeName,
- callback, nullptr, nullptr, 0, 0, {}
+ callback, nullptr, nullptr, QMetaType(), QTypeRevision::zero(), {}
};
return QQmlPrivate::qmlregister(QQmlPrivate::SingletonRegistration, &api);
@@ -680,14 +701,13 @@ template <typename T>
inline int qmlRegisterSingletonType(const char *uri, int versionMajor, int versionMinor, const char *typeName,
QObject *(*callback)(QQmlEngine *, QJSEngine *))
{
- QML_GETTYPENAMES
-
QQmlPrivate::RegisterSingletonType api = {
QmlCurrentSingletonTypeRegistrationVersion,
- uri, versionMajor, versionMinor, typeName,
+ uri, QTypeRevision::fromVersion(versionMajor, versionMinor), typeName,
+
- nullptr, nullptr, &T::staticMetaObject, qRegisterNormalizedMetaType<T *>(pointerName.constData()), 0, callback
+ nullptr, nullptr, &T::staticMetaObject, QMetaType::fromType<T *>(), QTypeRevision::zero(), callback
};
return QQmlPrivate::qmlregister(QQmlPrivate::SingletonRegistration, &api);
@@ -698,15 +718,13 @@ template <typename T, typename F, typename std::enable_if<std::is_convertible<F,
inline int qmlRegisterSingletonType(const char *uri, int versionMajor, int versionMinor, const char *typeName,
F&& callback)
{
-
- QML_GETTYPENAMES
-
QQmlPrivate::RegisterSingletonType api = {
QmlCurrentSingletonTypeRegistrationVersion,
- uri, versionMajor, versionMinor, typeName,
+ uri, QTypeRevision::fromVersion(versionMajor, versionMinor), typeName,
- nullptr, nullptr, &T::staticMetaObject, qRegisterNormalizedMetaType<T *>(pointerName.constData()), 0, callback
+
+ nullptr, nullptr, &T::staticMetaObject, QMetaType::fromType<T *>(), QTypeRevision::zero(), callback
};
return QQmlPrivate::qmlregister(QQmlPrivate::SingletonRegistration, &api);
@@ -732,8 +750,7 @@ inline int qmlRegisterSingletonType(const QUrl &url, const char *uri, int versio
QQmlPrivate::RegisterCompositeSingletonType type = {
url,
uri,
- versionMajor,
- versionMinor,
+ QTypeRevision::fromVersion(versionMajor, versionMinor),
qmlName
};
@@ -751,19 +768,18 @@ inline int qmlRegisterType(const QUrl &url, const char *uri, int versionMajor, i
QQmlPrivate::RegisterCompositeType type = {
url,
uri,
- versionMajor,
- versionMinor,
+ QTypeRevision::fromVersion(versionMajor, versionMinor),
qmlName
};
return QQmlPrivate::qmlregister(QQmlPrivate::CompositeRegistration, &type);
}
-template<class T, class Resolved, class Extended, bool Singleton>
+template<class T, class Resolved, class Extended, bool Singleton, bool Interface>
struct QmlTypeAndRevisionsRegistration;
template<class T, class Resolved, class Extended>
-struct QmlTypeAndRevisionsRegistration<T, Resolved, Extended, false> {
+struct QmlTypeAndRevisionsRegistration<T, Resolved, Extended, false, false> {
static void registerTypeAndRevisions(const char *uri, int versionMajor)
{
QQmlPrivate::qmlRegisterTypeAndRevisions<Resolved, Extended>(
@@ -772,7 +788,7 @@ struct QmlTypeAndRevisionsRegistration<T, Resolved, Extended, false> {
};
template<class T, class Resolved>
-struct QmlTypeAndRevisionsRegistration<T, Resolved, void, true> {
+struct QmlTypeAndRevisionsRegistration<T, Resolved, void, true, false> {
static void registerTypeAndRevisions(const char *uri, int versionMajor)
{
QQmlPrivate::qmlRegisterSingletonAndRevisions<Resolved>(
@@ -780,6 +796,14 @@ struct QmlTypeAndRevisionsRegistration<T, Resolved, void, true> {
}
};
+template<class T, class Resolved>
+struct QmlTypeAndRevisionsRegistration<T, Resolved, void, false, true> {
+ static void registerTypeAndRevisions(const char *uri, int versionMajor)
+ {
+ qmlRegisterInterface<Resolved>(uri, versionMajor);
+ }
+};
+
template<typename T = void, typename... Args>
void qmlRegisterTypesAndRevisions(const char *uri, int versionMajor);
@@ -789,7 +813,8 @@ void qmlRegisterTypesAndRevisions(const char *uri, int versionMajor)
QmlTypeAndRevisionsRegistration<
T, typename QQmlPrivate::QmlResolved<T>::Type,
typename QQmlPrivate::QmlExtended<T>::Type,
- QQmlPrivate::QmlSingleton<T>::Value>
+ QQmlPrivate::QmlSingleton<T>::Value,
+ QQmlPrivate::QmlInterface<T>::Value>
::registerTypeAndRevisions(uri, versionMajor);
qmlRegisterTypesAndRevisions<Args...>(uri, versionMajor);
}
@@ -797,6 +822,38 @@ void qmlRegisterTypesAndRevisions(const char *uri, int versionMajor)
template<>
inline void qmlRegisterTypesAndRevisions<>(const char *, int) {}
+inline void qmlRegisterNamespaceAndRevisions(const QMetaObject *metaObject,
+ const char *uri, int versionMajor)
+{
+ QQmlPrivate::RegisterTypeAndRevisions type = {
+ 0,
+ QMetaType(),
+ QMetaType(),
+ 0,
+ nullptr,
+
+ uri,
+ QTypeRevision::fromMajorVersion(versionMajor),
+
+ metaObject,
+ metaObject,
+
+ nullptr,
+ nullptr,
+
+ -1,
+ -1,
+ -1,
+
+ nullptr,
+ nullptr,
+
+ &qmlCreateCustomParser<void>
+ };
+
+ qmlregister(QQmlPrivate::TypeAndRevisionsRegistration, &type);
+}
+
int Q_QML_EXPORT qmlTypeId(const char *uri, int versionMajor, int versionMinor, const char *qmlName);
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index e14b00af22..b9566d5862 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -43,6 +43,10 @@
#include "qqmlcontext.h"
#include "qqmlinfo.h"
#include "qqmldata_p.h"
+
+#include <private/qqmldebugserviceinterfaces_p.h>
+#include <private/qqmldebugconnector_p.h>
+
#include <private/qqmlprofiler_p.h>
#include <private/qqmlexpression_p.h>
#include <private/qqmlscriptstring_p.h>
@@ -392,6 +396,11 @@ QQmlBinding *QQmlBinding::createTranslationBinding(const QQmlRefPointer<QV4::Exe
b->QQmlJavaScriptExpression::setContext(ctxt);
b->setScopeObject(obj);
+ if (QQmlDebugTranslationService *service
+ = QQmlDebugConnector::service<QQmlDebugTranslationService>()) {
+ service->foundTranslationBinding(b, obj, ctxt);
+ }
+
return b;
}
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 279998b5de..ede2816d5f 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -50,6 +50,7 @@
#include "qqmlincubator.h"
#include "qqmlincubator_p.h"
#include <private/qqmljavascriptexpression_p.h>
+#include <private/qqmlsourcecoordinate_p.h>
#include <private/qv4functionobject_p.h>
#include <private/qv4script_p.h>
@@ -1424,8 +1425,8 @@ QQmlError QQmlComponentPrivate::unsetRequiredPropertyToQQmlError(const RequiredP
}
error.setDescription(description);
error.setUrl(unsetRequiredProperty.fileUrl);
- error.setLine(unsetRequiredProperty.location.line);
- error.setColumn(unsetRequiredProperty.location.column);
+ error.setLine(qmlConvertSourceCoordinate<quint32, int>(unsetRequiredProperty.location.line));
+ error.setColumn(qmlConvertSourceCoordinate<quint32, int>(unsetRequiredProperty.location.column));
return error;
}
diff --git a/src/qml/qml/qqmlcomponent.h b/src/qml/qml/qqmlcomponent.h
index cb5d5a787c..9a4ea711f3 100644
--- a/src/qml/qml/qqmlcomponent.h
+++ b/src/qml/qml/qqmlcomponent.h
@@ -71,6 +71,7 @@ class Q_QML_EXPORT QQmlComponent : public QObject
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(QUrl url READ url CONSTANT)
QML_NAMED_ELEMENT(Component)
+ QML_ADDED_IN_VERSION(2, 0)
QML_ATTACHED(QQmlComponentAttached)
Q_CLASSINFO("QML.Builtin", "QML")
diff --git a/src/qml/qml/qqmlcomponentattached_p.h b/src/qml/qml/qqmlcomponentattached_p.h
index 8ecd9da17d..eb6d35652b 100644
--- a/src/qml/qml/qqmlcomponentattached_p.h
+++ b/src/qml/qml/qqmlcomponentattached_p.h
@@ -66,6 +66,7 @@ class Q_QML_PRIVATE_EXPORT QQmlComponentAttached : public QObject
// when registering QQmlComponent, but we cannot #include it from qqmlcomponent.h. Therefore we
// force an anonymous type registration here.
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQmlComponentAttached(QObject *parent = nullptr);
~QQmlComponentAttached();
diff --git a/src/qml/qml/qqmlcustomparser.cpp b/src/qml/qml/qqmlcustomparser.cpp
index 87f7fffe41..b0df4f26dc 100644
--- a/src/qml/qml/qqmlcustomparser.cpp
+++ b/src/qml/qml/qqmlcustomparser.cpp
@@ -40,6 +40,7 @@
#include "qqmlcustomparser_p.h"
#include <private/qv4compileddata_p.h>
+#include <private/qqmlsourcecoordinate_p.h>
#include <QtCore/qdebug.h>
@@ -100,10 +101,10 @@ void QQmlCustomParser::clearErrors()
*/
void QQmlCustomParser::error(const QV4::CompiledData::Location &location, const QString &description)
{
- QQmlJS::DiagnosticMessage error;
- error.line = location.line;
- error.column = location.column;
- error.message = description;
+ QQmlError error;
+ error.setLine(qmlConvertSourceCoordinate<quint32, int>(location.line));
+ error.setColumn(qmlConvertSourceCoordinate<quint32, int>(location.column));
+ error.setDescription(description);
exceptions << error;
}
@@ -125,8 +126,13 @@ int QQmlCustomParser::evaluateEnum(const QByteArray& script, bool *ok) const
// * <TypeName>.<EnumValue>
// * <TypeName>.<ScopedEnumName>.<EnumValue>
- int dot = script.indexOf('.');
- if (dot == -1 || dot == script.length()-1)
+ auto nextDot = [&](int dot) {
+ const int nextDot = script.indexOf('.', dot + 1);
+ return (nextDot == script.length() - 1) ? -1 : nextDot;
+ };
+
+ int dot = nextDot(-1);
+ if (dot == -1)
return -1;
QString scope = QString::fromUtf8(script.left(dot));
@@ -137,18 +143,32 @@ int QQmlCustomParser::evaluateEnum(const QByteArray& script, bool *ok) const
QQmlType type;
if (imports.isT1()) {
- imports.asT1()->resolveType(scope, &type, nullptr, nullptr, nullptr);
+ QQmlImportNamespace *ns = nullptr;
+ if (!imports.asT1()->resolveType(scope, &type, nullptr, &ns))
+ return -1;
+ if (!type.isValid() && ns != nullptr) {
+ dot = nextDot(dot);
+ if (dot == -1 || !imports.asT1()->resolveType(QString::fromUtf8(script.left(dot)),
+ &type, nullptr, nullptr)) {
+ return -1;
+ }
+ }
} else {
QQmlTypeNameCache::Result result = imports.asT2()->query(scope);
- if (result.isValid())
+ if (result.isValid()) {
type = result.type;
+ } else if (result.importNamespace) {
+ dot = nextDot(dot);
+ if (dot != -1)
+ type = imports.asT2()->query(QString::fromUtf8(script.left(dot))).type;
+ }
}
if (!type.isValid())
return -1;
- int dot2 = script.indexOf('.', dot+1);
- const bool dot2Valid = dot2 != -1 && dot2 != script.length()-1;
+ const int dot2 = nextDot(dot);
+ const bool dot2Valid = (dot2 != -1);
QByteArray enumValue = script.mid(dot2Valid ? dot2 + 1 : dot + 1);
QByteArray scopedEnumName = (dot2Valid ? script.mid(dot + 1, dot2 - dot - 1) : QByteArray());
if (!scopedEnumName.isEmpty())
diff --git a/src/qml/qml/qqmlcustomparser_p.h b/src/qml/qml/qqmlcustomparser_p.h
index df8cbc9072..4eb709228e 100644
--- a/src/qml/qml/qqmlcustomparser_p.h
+++ b/src/qml/qml/qqmlcustomparser_p.h
@@ -83,7 +83,7 @@ public:
virtual void verifyBindings(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &, const QList<const QV4::CompiledData::Binding *> &) = 0;
virtual void applyBindings(QObject *, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &, const QList<const QV4::CompiledData::Binding *> &) = 0;
- QVector<QQmlJS::DiagnosticMessage> errors() const { return exceptions; }
+ QVector<QQmlError> errors() const { return exceptions; }
protected:
void error(const QV4::CompiledData::Binding *binding, const QString& description)
@@ -97,7 +97,7 @@ protected:
const QMetaObject *resolveType(const QString&) const;
private:
- QVector<QQmlJS::DiagnosticMessage> exceptions;
+ QVector<QQmlError> exceptions;
QQmlEnginePrivate *engine;
const QQmlPropertyValidator *validator;
Flags m_flags;
@@ -107,11 +107,6 @@ private:
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlCustomParser::Flags)
-#if 0
-#define QML_REGISTER_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, CUSTOMTYPE) \
- qmlRegisterCustomType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE, new CUSTOMTYPE)
-#endif
-
QT_END_NAMESPACE
#endif
diff --git a/src/qml/qml/qqmldatablob.cpp b/src/qml/qml/qqmldatablob.cpp
index 1ab6002f0a..c29f207ae3 100644
--- a/src/qml/qml/qqmldatablob.cpp
+++ b/src/qml/qml/qqmldatablob.cpp
@@ -42,6 +42,7 @@
#include <private/qqmlprofiler_p.h>
#include <private/qqmltypeloader_p.h>
#include <private/qqmltypeloaderthread_p.h>
+#include <private/qqmlsourcecoordinate_p.h>
#include <QtQml/qqmlengine.h>
@@ -289,7 +290,18 @@ void QQmlDataBlob::setError(const QList<QQmlError> &errors)
Q_ASSERT(status() != Error);
Q_ASSERT(m_errors.isEmpty());
- m_errors = errors; // Must be set before the m_data fence
+ // m_errors must be set before the m_data fence
+ m_errors.reserve(errors.count());
+ for (const QQmlError &error : errors) {
+ if (error.url().isEmpty()) {
+ QQmlError mutableError = error;
+ mutableError.setUrl(url());
+ m_errors.append(mutableError);
+ } else {
+ m_errors.append(error);
+ }
+ }
+
m_data.setStatus(Error);
if (dumpErrors()) {
@@ -306,28 +318,13 @@ void QQmlDataBlob::setError(const QList<QQmlError> &errors)
void QQmlDataBlob::setError(const QQmlJS::DiagnosticMessage &error)
{
QQmlError e;
- e.setColumn(error.column);
- e.setLine(error.line);
+ e.setColumn(qmlConvertSourceCoordinate<quint32, int>(error.loc.startColumn));
+ e.setLine(qmlConvertSourceCoordinate<quint32, int>(error.loc.startLine));
e.setDescription(error.message);
e.setUrl(url());
setError(e);
}
-void QQmlDataBlob::setError(const QVector<QQmlJS::DiagnosticMessage> &errors)
-{
- QList<QQmlError> finalErrors;
- finalErrors.reserve(errors.count());
- for (const auto &error : errors) {
- QQmlError e;
- e.setColumn(error.column);
- e.setLine(error.line);
- e.setDescription(error.message);
- e.setUrl(url());
- finalErrors << e;
- }
- setError(finalErrors);
-}
-
void QQmlDataBlob::setError(const QString &description)
{
QQmlError e;
diff --git a/src/qml/qml/qqmldatablob_p.h b/src/qml/qml/qqmldatablob_p.h
index 0450e94c02..17db8f2dfe 100644
--- a/src/qml/qml/qqmldatablob_p.h
+++ b/src/qml/qml/qqmldatablob_p.h
@@ -132,7 +132,6 @@ protected:
void setError(const QQmlError &);
void setError(const QList<QQmlError> &errors);
void setError(const QQmlJS::DiagnosticMessage &error);
- void setError(const QVector<QQmlJS::DiagnosticMessage> &errors);
void setError(const QString &description);
void addDependency(QQmlDataBlob *);
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 5d7dddd153..725d2e7c7a 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -57,11 +57,11 @@
#include "qqmlnotifier_p.h"
#include "qqmlincubator.h"
#include "qqmlabstracturlinterceptor.h"
+#include "qqmlsourcecoordinate_p.h"
#include <private/qqmldirparser_p.h>
#include <private/qqmlboundsignal_p.h>
#include <private/qqmljsdiagnosticmessage_p.h>
#include <QtCore/qstandardpaths.h>
-#include <QtCore/qsettings.h>
#include <QtCore/qmetaobject.h>
#include <QDebug>
#include <QtCore/qcoreapplication.h>
@@ -112,13 +112,13 @@ int qmlRegisterUncreatableMetaObject(const QMetaObject &staticMetaObject,
QQmlPrivate::RegisterType type = {
0,
- 0,
- 0,
+ QMetaType(),
+ QMetaType(),
0,
nullptr,
reason,
- uri, versionMajor, versionMinor, qmlName, &staticMetaObject,
+ uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName, &staticMetaObject,
QQmlAttachedPropertiesFunc(),
nullptr,
@@ -130,7 +130,7 @@ int qmlRegisterUncreatableMetaObject(const QMetaObject &staticMetaObject,
nullptr, nullptr,
nullptr,
- 0
+ QTypeRevision::zero()
};
return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
@@ -654,11 +654,7 @@ QQmlEnginePrivate::~QQmlEnginePrivate()
for (auto iter = m_compositeTypes.cbegin(), end = m_compositeTypes.cend(); iter != end; ++iter) {
iter.value()->isRegisteredWithEngine = false;
-
- // since unregisterInternalCompositeType() will not be called in this
- // case, we have to clean up the type registration manually
- QMetaType::unregisterType(iter.value()->metaTypeId);
- QMetaType::unregisterType(iter.value()->listMetaTypeId);
+ QQmlMetaType::unregisterInternalCompositeType({iter.value()->metaTypeId, iter.value()->listMetaTypeId});
}
#if QT_CONFIG(qml_debug)
delete profiler;
@@ -1335,12 +1331,16 @@ void QQmlEngine::setOutputWarningsToStandardError(bool enabled)
\code
class MySingleton : public QObject {
\Q_OBJECT
+
+ // Register as default constructed singleton.
+ QML_ELEMENT
+ QML_SINGLETON
+
static int typeId;
// ...
};
- // Register with QObject* callback
- MySingleton::typeId = qmlRegisterSingletonType<MySingleton>(...);
+ MySingleton::typeId = qmlTypeId(...);
// Retrieve as QObject*
QQmlEngine engine;
@@ -1357,11 +1357,10 @@ void QQmlEngine::setOutputWarningsToStandardError(bool enabled)
QJSValue instance = engine.singletonInstance<QJSValue>(typeId);
\endcode
- It is recommended to store the QML type id during registration, e.g. as a static member
- in the singleton class. Otherwise, a costly lookup via qmlTypeId() has to be performed
- at run-time.
+ It is recommended to store the QML type id, e.g. as a static member in the
+ singleton class. The lookup via qmlTypeId() is costly.
- \sa qmlRegisterSingletonType(), qmlTypeId()
+ \sa QML_SINGLETON, qmlRegisterSingletonType(), qmlTypeId()
\since 5.12
*/
template<>
@@ -2096,15 +2095,15 @@ QList<QQmlError> QQmlEnginePrivate::qmlErrorFromDiagnostics(
QList<QQmlError> errors;
for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) {
if (m.isWarning()) {
- qWarning("%s:%d : %s", qPrintable(fileName), m.line, qPrintable(m.message));
+ qWarning("%s:%d : %s", qPrintable(fileName), m.loc.startLine, qPrintable(m.message));
continue;
}
QQmlError error;
error.setUrl(QUrl(fileName));
error.setDescription(m.message);
- error.setLine(m.line);
- error.setColumn(m.column);
+ error.setLine(qmlConvertSourceCoordinate<quint32, int>(m.loc.startLine));
+ error.setColumn(qmlConvertSourceCoordinate<quint32, int>(m.loc.startColumn));
errors << error;
}
return errors;
@@ -2244,7 +2243,7 @@ void QQmlEngine::setPluginPathList(const QStringList &paths)
bool QQmlEngine::importPlugin(const QString &filePath, const QString &uri, QList<QQmlError> *errors)
{
Q_D(QQmlEngine);
- return d->importDatabase.importDynamicPlugin(filePath, uri, QString(), -1, errors);
+ return d->importDatabase.importDynamicPlugin(filePath, uri, QString(), QTypeRevision(), errors);
}
#endif
@@ -2301,17 +2300,6 @@ QString QQmlEngine::offlineStorageDatabaseFilePath(const QString &databaseName)
return d->offlineStorageDatabaseDirectory() + QLatin1String(md5.result().toHex());
}
-// #### Qt 6: Remove this function, it exists only for binary compatibility.
-/*!
- * \internal
- */
-bool QQmlEngine::addNamedBundle(const QString &name, const QString &fileName)
-{
- Q_UNUSED(name)
- Q_UNUSED(fileName)
- return false;
-}
-
QString QQmlEnginePrivate::offlineStorageDatabaseDirectory() const
{
Q_Q(const QQmlEngine);
@@ -2356,67 +2344,100 @@ int QQmlEnginePrivate::listType(int t) const
static QQmlPropertyCache *propertyCacheForPotentialInlineComponentType(int t, const QHash<int, QV4::ExecutableCompilationUnit *>::const_iterator &iter) {
- if (t != (*iter)->metaTypeId) {
+ if (t != (*iter)->metaTypeId.id()) {
// this is an inline component, and what we have in the iterator is currently the parent compilation unit
for (auto &&icDatum: (*iter)->inlineComponentData)
- if (icDatum.typeIds.id == t)
+ if (icDatum.typeIds.id.id() == t)
return (*iter)->propertyCaches.at(icDatum.objectIndex);
}
return (*iter)->rootPropertyCache().data();
}
+/*!
+ * \internal
+ *
+ * Look up by type's baseMetaObject.
+ */
QQmlMetaObject QQmlEnginePrivate::rawMetaObjectForType(int t) const
{
- Locker locker(this);
- auto iter = m_compositeTypes.constFind(t);
- if (iter != m_compositeTypes.cend()) {
- return propertyCacheForPotentialInlineComponentType(t, iter);
- } else {
- QQmlType type = QQmlMetaType::qmlType(t);
- return QQmlMetaObject(type.baseMetaObject());
- }
+ if (QQmlPropertyCache *composite = findPropertyCacheInCompositeTypes(t))
+ return QQmlMetaObject(composite);
+
+ QQmlType type = QQmlMetaType::qmlType(t);
+ return QQmlMetaObject(type.baseMetaObject());
}
+/*!
+ * \internal
+ *
+ * Look up by type's metaObject.
+ */
QQmlMetaObject QQmlEnginePrivate::metaObjectForType(int t) const
{
- Locker locker(this);
- auto iter = m_compositeTypes.constFind(t);
- if (iter != m_compositeTypes.cend()) {
- return propertyCacheForPotentialInlineComponentType(t, iter);
- } else {
- QQmlType type = QQmlMetaType::qmlType(t);
- return QQmlMetaObject(type.metaObject());
- }
+ if (QQmlPropertyCache *composite = findPropertyCacheInCompositeTypes(t))
+ return QQmlMetaObject(composite);
+
+ QQmlType type = QQmlMetaType::qmlType(t);
+ return QQmlMetaObject(type.metaObject());
}
+/*!
+ * \internal
+ *
+ * Look up by type's metaObject and version.
+ */
QQmlPropertyCache *QQmlEnginePrivate::propertyCacheForType(int t)
{
- Locker locker(this);
- auto iter = m_compositeTypes.constFind(t);
- if (iter != m_compositeTypes.cend()) {
- return propertyCacheForPotentialInlineComponentType(t, iter);
- } else {
- QQmlType type = QQmlMetaType::qmlType(t);
- locker.unlock();
- return type.isValid() ? cache(type.metaObject()) : nullptr;
- }
+ if (QQmlPropertyCache *composite = findPropertyCacheInCompositeTypes(t))
+ return composite;
+
+ QQmlType type = QQmlMetaType::qmlType(t);
+ return type.isValid() ? cache(type.metaObject(), type.version()) : nullptr;
+}
+
+/*!
+ * \internal
+ *
+ * Look up by type's baseMetaObject and unspecified/any version.
+ * TODO: Is this correct? Passing a plain QTypeRevision() rather than QTypeRevision::zero() or
+ * the actual type's version seems strange. The behavior has been in place for a while.
+ */
+QQmlPropertyCache *QQmlEnginePrivate::rawPropertyCacheForType(int t)
+{
+ if (QQmlPropertyCache *composite = findPropertyCacheInCompositeTypes(t))
+ return composite;
+
+ QQmlType type = QQmlMetaType::qmlType(t);
+ return type.isValid() ? cache(type.baseMetaObject(), QTypeRevision()) : nullptr;
+}
+
+/*!
+ * \internal
+ *
+ * Look up by QQmlType and version. We only fall back to lookup by metaobject if the type
+ * has no revisiononed attributes here. Unspecified versions are interpreted as "any".
+ */
+QQmlPropertyCache *QQmlEnginePrivate::rawPropertyCacheForType(int t, QTypeRevision version)
+{
+ if (QQmlPropertyCache *composite = findPropertyCacheInCompositeTypes(t))
+ return composite;
+
+ QQmlType type = QQmlMetaType::qmlType(t);
+ if (!type.isValid())
+ return nullptr;
+
+ return type.containsRevisionedAttributes()
+ ? QQmlMetaType::propertyCache(type, version)
+ : cache(type.metaObject(), version);
}
-QQmlPropertyCache *QQmlEnginePrivate::rawPropertyCacheForType(int t, int minorVersion)
+QQmlPropertyCache *QQmlEnginePrivate::findPropertyCacheInCompositeTypes(int t) const
{
Locker locker(this);
auto iter = m_compositeTypes.constFind(t);
- if (iter != m_compositeTypes.cend()) {
- return propertyCacheForPotentialInlineComponentType(t, iter);
- } else {
- QQmlType type = QQmlMetaType::qmlType(t);
- locker.unlock();
-
- if (minorVersion >= 0)
- return type.isValid() ? cache(type, minorVersion) : nullptr;
- else
- return type.isValid() ? cache(type.baseMetaObject()) : nullptr;
- }
+ return (iter == m_compositeTypes.constEnd())
+ ? nullptr
+ : propertyCacheForPotentialInlineComponentType(t, iter);
}
void QQmlEnginePrivate::registerInternalCompositeType(QV4::ExecutableCompilationUnit *compilationUnit)
@@ -2426,10 +2447,9 @@ void QQmlEnginePrivate::registerInternalCompositeType(QV4::ExecutableCompilation
Locker locker(this);
// The QQmlCompiledData is not referenced here, but it is removed from this
// hash in the QQmlCompiledData destructor
- m_compositeTypes.insert(compilationUnit->metaTypeId, compilationUnit);
- for (auto &&data: compilationUnit->inlineComponentData) {
- m_compositeTypes.insert(data.typeIds.id, compilationUnit);
- }
+ m_compositeTypes.insert(compilationUnit->metaTypeId.id(), compilationUnit);
+ for (auto &&data: compilationUnit->inlineComponentData)
+ m_compositeTypes.insert(data.typeIds.id.id(), compilationUnit);
}
void QQmlEnginePrivate::unregisterInternalCompositeType(QV4::ExecutableCompilationUnit *compilationUnit)
@@ -2437,9 +2457,9 @@ void QQmlEnginePrivate::unregisterInternalCompositeType(QV4::ExecutableCompilati
compilationUnit->isRegisteredWithEngine = false;
Locker locker(this);
- m_compositeTypes.remove(compilationUnit->metaTypeId);
+ m_compositeTypes.remove(compilationUnit->metaTypeId.id());
for (auto&& icDatum: compilationUnit->inlineComponentData)
- m_compositeTypes.remove(icDatum.typeIds.id);
+ m_compositeTypes.remove(icDatum.typeIds.id.id());
}
QV4::ExecutableCompilationUnit *QQmlEnginePrivate::obtainExecutableCompilationUnit(int typeId)
diff --git a/src/qml/qml/qqmlengine.h b/src/qml/qml/qqmlengine.h
index 31fe3a1849..a686d8a1d9 100644
--- a/src/qml/qml/qqmlengine.h
+++ b/src/qml/qml/qqmlengine.h
@@ -112,7 +112,9 @@ public:
void setPluginPathList(const QStringList &paths);
void addPluginPath(const QString& dir);
- bool addNamedBundle(const QString &name, const QString &fileName);
+#if QT_DEPRECATED_SINCE(6, 0)
+ QT_DEPRECATED bool addNamedBundle(const QString &, const QString &) { return false; }
+#endif
#if QT_CONFIG(library)
bool importPlugin(const QString &filePath, const QString &uri, QList<QQmlError> *errors);
diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h
index 33fa800ff4..424335b61a 100644
--- a/src/qml/qml/qqmlengine_p.h
+++ b/src/qml/qml/qqmlengine_p.h
@@ -105,6 +105,7 @@ struct QObjectForeign {
Q_GADGET
QML_FOREIGN(QObject)
QML_NAMED_ELEMENT(QtObject)
+ QML_ADDED_IN_VERSION(2, 0)
Q_CLASSINFO("QML.Root", "QML")
};
@@ -216,7 +217,7 @@ public:
QString offlineStorageDatabaseDirectory() const;
// These methods may be called from the loader thread
- inline QQmlPropertyCache *cache(const QQmlType &, int);
+ inline QQmlPropertyCache *cache(const QQmlType &, QTypeRevision version);
using QJSEnginePrivate::cache;
// These methods may be called from the loader thread
@@ -228,7 +229,8 @@ public:
QQmlMetaObject rawMetaObjectForType(int) const;
QQmlMetaObject metaObjectForType(int) const;
QQmlPropertyCache *propertyCacheForType(int);
- QQmlPropertyCache *rawPropertyCacheForType(int, int minorVersion = -1);
+ QQmlPropertyCache *rawPropertyCacheForType(int);
+ QQmlPropertyCache *rawPropertyCacheForType(int, QTypeRevision version);
void registerInternalCompositeType(QV4::ExecutableCompilationUnit *compilationUnit);
void unregisterInternalCompositeType(QV4::ExecutableCompilationUnit *compilationUnit);
QV4::ExecutableCompilationUnit *obtainExecutableCompilationUnit(int typeId);
@@ -268,8 +270,24 @@ public:
mutable QMutex networkAccessManagerMutex;
+ QQmlGadgetPtrWrapper *valueTypeInstance(int typeIndex)
+ {
+ auto it = cachedValueTypeInstances.find(typeIndex);
+ if (it != cachedValueTypeInstances.end())
+ return *it;
+
+ if (QQmlValueType *valueType = QQmlValueTypeFactory::valueType(typeIndex)) {
+ QQmlGadgetPtrWrapper *instance = new QQmlGadgetPtrWrapper(valueType, q_func());
+ cachedValueTypeInstances.insert(typeIndex, instance);
+ return instance;
+ }
+
+ return nullptr;
+ }
+
private:
QHash<QQmlType, QJSValue> singletonInstances;
+ QHash<int, QQmlGadgetPtrWrapper *> cachedValueTypeInstances;
// These members must be protected by a QQmlEnginePrivate::Locker as they are required by
// the threaded loader. Only access them through their respective accessor methods.
@@ -282,6 +300,7 @@ private:
void doDeleteInEngineThread();
void cleanupScarceResources();
+ QQmlPropertyCache *findPropertyCacheInCompositeTypes(int t) const;
};
/*
@@ -380,15 +399,15 @@ Returns a QQmlPropertyCache for \a type with \a minorVersion.
The returned cache is not referenced, so if it is to be stored, call addref().
*/
-QQmlPropertyCache *QQmlEnginePrivate::cache(const QQmlType &type, int minorVersion)
+QQmlPropertyCache *QQmlEnginePrivate::cache(const QQmlType &type, QTypeRevision version)
{
Q_ASSERT(type.isValid());
- if (minorVersion == -1 || !type.containsRevisionedAttributes())
- return cache(type.metaObject(), minorVersion);
+ if (!version.hasMinorVersion() || !type.containsRevisionedAttributes())
+ return cache(type.metaObject(), version);
Locker locker(this);
- return QQmlMetaType::propertyCache(type, minorVersion);
+ return QQmlMetaType::propertyCache(type, version);
}
QV4::ExecutionEngine *QQmlEnginePrivate::getV4Engine(QQmlEngine *e)
diff --git a/src/qml/qml/qqmlerror.cpp b/src/qml/qml/qqmlerror.cpp
index 0b94ed3b49..da585d2126 100644
--- a/src/qml/qml/qqmlerror.cpp
+++ b/src/qml/qml/qqmlerror.cpp
@@ -77,12 +77,15 @@ QT_BEGIN_NAMESPACE
\sa QQuickView::errors(), QQmlComponent::errors()
*/
-class QQmlErrorPrivate : public QQmlJS::DiagnosticMessage
+class QQmlErrorPrivate
{
public:
- QQmlErrorPrivate() { type = QtWarningMsg; }
QUrl url;
QPointer<QObject> object;
+ QString message;
+ QtMsgType type = QtWarningMsg;
+ int line = -1;
+ int column = -1;
};
/*!
@@ -185,7 +188,7 @@ void QQmlError::setDescription(const QString &description)
int QQmlError::line() const
{
if (d)
- return qmlConvertSourceCoordinate<quint32, int>(d->line);
+ return d->line;
return -1;
}
@@ -196,7 +199,7 @@ void QQmlError::setLine(int line)
{
if (!d)
d = new QQmlErrorPrivate;
- d->line = qmlConvertSourceCoordinate<int, quint32>(line);
+ d->line = line;
}
/*!
@@ -205,7 +208,7 @@ void QQmlError::setLine(int line)
int QQmlError::column() const
{
if (d)
- return qmlConvertSourceCoordinate<quint32, int>(d->column);
+ return d->column;
return -1;
}
@@ -216,7 +219,7 @@ void QQmlError::setColumn(int column)
{
if (!d)
d = new QQmlErrorPrivate;
- d->column = qmlConvertSourceCoordinate<int, quint32>(column);
+ d->column = column;
}
/*!
diff --git a/src/qml/qml/qqmlextensionplugin.cpp b/src/qml/qml/qqmlextensionplugin.cpp
index 7a62c967e7..f779199b74 100644
--- a/src/qml/qml/qqmlextensionplugin.cpp
+++ b/src/qml/qml/qqmlextensionplugin.cpp
@@ -117,6 +117,16 @@ QUrl QQmlExtensionPlugin::baseUrl() const
}
/*!
+ \since 6.0
+
+ Override this method to unregister types manually registered in registerTypes.
+*/
+void QQmlExtensionPlugin::unregisterTypes()
+{
+
+}
+
+/*!
\internal
*/
diff --git a/src/qml/qml/qqmlextensionplugin.h b/src/qml/qml/qqmlextensionplugin.h
index ef7ff422cd..78371106bd 100644
--- a/src/qml/qml/qqmlextensionplugin.h
+++ b/src/qml/qml/qqmlextensionplugin.h
@@ -64,6 +64,7 @@ public:
QUrl baseUrl() const;
void registerTypes(const char *uri) override = 0;
+ virtual void unregisterTypes();
void initializeEngine(QQmlEngine *engine, const char *uri) override;
private:
diff --git a/src/qml/qml/qqmlfile.cpp b/src/qml/qml/qqmlfile.cpp
index ee54359d0f..465a342129 100644
--- a/src/qml/qml/qqmlfile.cpp
+++ b/src/qml/qml/qqmlfile.cpp
@@ -187,7 +187,7 @@ void QQmlFileNetworkReply::networkFinished()
}
}
- if (m_reply->networkError()) {
+ if (m_reply->error()) {
m_p->errorString = m_reply->errorString();
m_p->error = QQmlFilePrivate::Network;
} else {
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index 80eafdf146..47f7b40938 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -161,9 +161,17 @@ void qmlClearEnginePlugins()
#if QT_CONFIG(library)
for (auto &plugin : qAsConst(*plugins)) {
QPluginLoader* loader = plugin.loader;
- if (loader && !loader->unload())
- qWarning("Unloading %s failed: %s", qPrintable(plugin.uri), qPrintable(loader->errorString()));
- delete loader;
+ if (loader) {
+ auto extensionPlugin = qobject_cast<QQmlExtensionPlugin *>(loader->instance());
+ if (extensionPlugin) {
+ extensionPlugin->unregisterTypes();
+ }
+#ifndef Q_OS_MACOS
+ if (!loader->unload())
+ qWarning("Unloading %s failed: %s", qPrintable(plugin.uri), qPrintable(loader->errorString()));
+ delete loader;
+#endif
+ }
}
#endif
plugins->clear();
@@ -213,12 +221,12 @@ public:
QQmlImportNamespace *importNamespace(const QString &prefix) const;
bool addLibraryImport(const QString& uri, const QString &prefix,
- int vmaj, int vmin, const QString &qmldirIdentifier, const QString &qmldirUrl, bool incomplete,
+ QTypeRevision version, const QString &qmldirIdentifier,
+ const QString &qmldirUrl, bool incomplete,
QQmlImportDatabase *database,
QList<QQmlError> *errors);
- bool addFileImport(const QString &uri, const QString &prefix,
- int vmaj, int vmin,
+ bool addFileImport(const QString &uri, const QString &prefix, QTypeRevision version,
bool isImplicitImport, bool incomplete, QQmlImportDatabase *database,
QList<QQmlError> *errors);
@@ -227,7 +235,7 @@ public:
QQmlImportDatabase *database,
QList<QQmlError> *errors);
- bool resolveType(const QHashedStringRef &type, int *vmajor, int *vminor,
+ bool resolveType(const QHashedStringRef &type, QTypeRevision *version_return,
QQmlType *type_return, QList<QQmlError> *errors,
QQmlType::RegistrationType registrationType,
bool *typeRecursionDetected = nullptr);
@@ -247,14 +255,13 @@ public:
QQmlTypeLoader *typeLoader;
static QQmlImports::LocalQmldirResult locateLocalQmldir(
- const QString &uri, int vmaj, int vmin, QQmlImportDatabase *database,
+ const QString &uri, QTypeRevision version, QQmlImportDatabase *database,
QString *outQmldirFilePath, QString *outUrl);
- static bool validateQmldirVersion(const QQmlTypeLoaderQmldirContent &qmldir, const QString &uri, int vmaj, int vmin,
- QList<QQmlError> *errors);
+ static bool validateQmldirVersion(const QQmlTypeLoaderQmldirContent &qmldir, const QString &uri,
+ QTypeRevision version, QList<QQmlError> *errors);
- bool importExtension(const QString &absoluteFilePath, const QString &uri,
- int vmaj, int vmin,
+ bool importExtension(const QString &absoluteFilePath, const QString &uri, QTypeRevision version,
QQmlImportDatabase *database,
const QQmlTypeLoaderQmldirContent &qmldir,
QList<QQmlError> *errors);
@@ -264,10 +271,10 @@ public:
QString resolvedUri(const QString &dir_arg, QQmlImportDatabase *database);
- QQmlImportInstance *addImportToNamespace(QQmlImportNamespace *nameSpace,
- const QString &uri, const QString &url,
- int vmaj, int vmin, QV4::CompiledData::Import::ImportType type,
- QList<QQmlError> *errors, bool lowPrecedence = false);
+ QQmlImportInstance *addImportToNamespace(QQmlImportNamespace *nameSpace, const QString &uri,
+ const QString &url, QTypeRevision version,
+ QV4::CompiledData::Import::ImportType type,
+ QList<QQmlError> *errors, bool lowPrecedence = false);
bool populatePluginPairVector(QVector<StaticPluginPair> &result, const QString &uri, const QStringList &versionUris,
const QString &qmldirPath, QList<QQmlError> *errors);
@@ -344,9 +351,9 @@ void QQmlImports::populateCache(QQmlTypeNameCache *cache) const
for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
const QQmlImportInstance *import = set.imports.at(ii);
- QQmlTypeModule *module = QQmlMetaType::typeModule(import->uri, import->majversion);
+ QQmlTypeModule *module = QQmlMetaType::typeModule(import->uri, import->version);
if (module) {
- cache->m_anonymousImports.append(QQmlTypeModuleVersion(module, import->minversion));
+ cache->m_anonymousImports.append(QQmlTypeModuleVersion(module, import->version));
}
}
@@ -360,10 +367,10 @@ void QQmlImports::populateCache(QQmlTypeNameCache *cache) const
for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
const QQmlImportInstance *import = set.imports.at(ii);
- QQmlTypeModule *module = QQmlMetaType::typeModule(import->uri, import->majversion);
+ QQmlTypeModule *module = QQmlMetaType::typeModule(import->uri, import->version);
if (module) {
QQmlImportRef &typeimport = cache->m_namedImports[set.prefix];
- typeimport.modules.append(QQmlTypeModuleVersion(module, import->minversion));
+ typeimport.modules.append(QQmlTypeModuleVersion(module, import->version));
}
}
}
@@ -395,36 +402,35 @@ void findCompositeSingletons(const QQmlImportNamespace &set, QList<QQmlImports::
const QQmlDirComponents &components = import->qmlDirComponents;
- const int importMajorVersion = import->majversion;
- const int importMinorVersion = import->minversion;
- auto shouldSkipSingleton = [importMajorVersion, importMinorVersion](int singletonMajorVersion, int singletonMinorVersion) -> bool {
- return importMajorVersion != -1 &&
- (singletonMajorVersion > importMajorVersion || (singletonMajorVersion == importMajorVersion && singletonMinorVersion > importMinorVersion));
+ const QTypeRevision importVersion = import->version;
+ auto shouldSkipSingleton = [importVersion](QTypeRevision singletonVersion) -> bool {
+ return importVersion.hasMajorVersion() &&
+ (singletonVersion.majorVersion() > importVersion.majorVersion()
+ || (singletonVersion.majorVersion() == importVersion.majorVersion()
+ && singletonVersion.minorVersion() > importVersion.minorVersion()));
};
ConstIterator cend = components.constEnd();
for (ConstIterator cit = components.constBegin(); cit != cend; ++cit) {
if (cit->singleton && excludeBaseUrl(import->url, cit->fileName, baseUrl.toString())) {
- if (shouldSkipSingleton(cit->majorVersion, cit->minorVersion))
+ if (shouldSkipSingleton(cit->version))
continue;
QQmlImports::CompositeSingletonReference ref;
ref.typeName = cit->typeName;
ref.prefix = set.prefix;
- ref.majorVersion = cit->majorVersion;
- ref.minorVersion = cit->minorVersion;
+ ref.version = cit->version;
resultList.append(ref);
}
}
- if (QQmlTypeModule *module = QQmlMetaType::typeModule(import->uri, import->majversion)) {
+ if (QQmlTypeModule *module = QQmlMetaType::typeModule(import->uri, import->version)) {
module->walkCompositeSingletons([&resultList, &set, &shouldSkipSingleton](const QQmlType &singleton) {
- if (shouldSkipSingleton(singleton.majorVersion(), singleton.minorVersion()))
+ if (shouldSkipSingleton(singleton.version()))
return;
QQmlImports::CompositeSingletonReference ref;
ref.typeName = singleton.elementName();
ref.prefix = set.prefix;
- ref.majorVersion = singleton.majorVersion();
- ref.minorVersion = singleton.minorVersion();
+ ref.version = singleton.version();
resultList.append(ref);
});
}
@@ -461,9 +467,9 @@ QList<QQmlImports::CompositeSingletonReference> QQmlImports::resolvedCompositeSi
if (lhs.typeName != rhs.typeName)
return lhs.typeName < rhs.typeName;
- return lhs.majorVersion != rhs.majorVersion
- ? lhs.majorVersion < rhs.majorVersion
- : lhs.minorVersion < rhs.minorVersion;
+ return lhs.version.majorVersion() != rhs.version.majorVersion()
+ ? lhs.version.majorVersion() < rhs.version.majorVersion()
+ : lhs.version.minorVersion() < rhs.version.minorVersion();
});
return compositeSingletons;
@@ -532,16 +538,17 @@ static QString joinStringRefs(const QVector<QStringRef> &refs, const QChar &sep)
- base/QtQml.2/Models/qmldir
- base/QtQml/Models/qmldir
*/
-QStringList QQmlImports::completeQmldirPaths(const QString &uri, const QStringList &basePaths, int vmaj, int vmin)
+QStringList QQmlImports::completeQmldirPaths(const QString &uri, const QStringList &basePaths,
+ QTypeRevision version)
{
- const QVector<QStringRef> parts = uri.splitRef(Dot, QString::SkipEmptyParts);
+ const QVector<QStringRef> parts = uri.splitRef(Dot, Qt::SkipEmptyParts);
QStringList qmlDirPathsPaths;
// fully & partially versioned parts + 1 unversioned for each base path
qmlDirPathsPaths.reserve(basePaths.count() * (2 * parts.count() + 1));
- for (int version = FullyVersioned; version <= Unversioned; ++version) {
- const QString ver = versionString(vmaj, vmin, static_cast<QQmlImports::ImportVersion>(version));
+ for (int versionMode = FullyVersioned; versionMode <= Unversioned; ++versionMode) {
+ const QString ver = versionString(version, QQmlImports::ImportVersion(versionMode));
for (const QString &path : basePaths) {
QString dir = path;
@@ -551,7 +558,7 @@ QStringList QQmlImports::completeQmldirPaths(const QString &uri, const QStringLi
// append to the end
qmlDirPathsPaths += dir + joinStringRefs(parts, Slash) + ver + Slash_qmldir;
- if (version != Unversioned) {
+ if (versionMode != Unversioned) {
// insert in the middle
for (int index = parts.count() - 2; index >= 0; --index) {
qmlDirPathsPaths += dir + joinStringRefs(parts.mid(0, index + 1), Slash)
@@ -565,14 +572,14 @@ QStringList QQmlImports::completeQmldirPaths(const QString &uri, const QStringLi
return qmlDirPathsPaths;
}
-QString QQmlImports::versionString(int vmaj, int vmin, ImportVersion version)
+QString QQmlImports::versionString(QTypeRevision version, ImportVersion versionMode)
{
- if (version == QQmlImports::FullyVersioned) {
+ if (versionMode == QQmlImports::FullyVersioned) {
// extension with fully encoded version number (eg. MyModule.3.2)
- return QString::asprintf(".%d.%d", vmaj, vmin);
- } else if (version == QQmlImports::PartiallyVersioned) {
+ return QString::asprintf(".%d.%d", version.majorVersion(), version.minorVersion());
+ } else if (versionMode == QQmlImports::PartiallyVersioned) {
// extension with encoded version major (eg. MyModule.3)
- return QString::asprintf(".%d", vmaj);
+ return QString::asprintf(".%d", version.majorVersion());
} // else extension without version number (eg. MyModule)
return QString();
}
@@ -591,7 +598,7 @@ QString QQmlImports::versionString(int vmaj, int vmin, ImportVersion version)
\sa addFileImport(), addLibraryImport
*/
bool QQmlImports::resolveType(const QHashedStringRef &type,
- QQmlType *type_return, int *vmaj, int *vmin,
+ QQmlType *type_return, QTypeRevision *version_return,
QQmlImportNamespace** ns_return, QList<QQmlError> *errors,
QQmlType::RegistrationType registrationType,
bool *typeRecursionDetected) const
@@ -603,7 +610,7 @@ bool QQmlImports::resolveType(const QHashedStringRef &type,
return true;
}
if (type_return) {
- if (d->resolveType(type, vmaj, vmin, type_return, errors, registrationType,
+ if (d->resolveType(type, version_return, type_return, errors, registrationType,
typeRecursionDetected)) {
if (qmlImportTrace()) {
#define RESOLVE_TYPE_DEBUG qDebug().nospace() << "QQmlImports(" << qPrintable(baseUrl().toString()) \
@@ -627,7 +634,9 @@ bool QQmlImports::resolveType(const QHashedStringRef &type,
return false;
}
-bool QQmlImportInstance::setQmldirContent(const QString &resolvedUrl, const QQmlTypeLoaderQmldirContent &qmldir, QQmlImportNamespace *nameSpace, QList<QQmlError> *errors)
+bool QQmlImportInstance::setQmldirContent(const QString &resolvedUrl,
+ const QQmlTypeLoaderQmldirContent &qmldir,
+ QQmlImportNamespace *nameSpace, QList<QQmlError> *errors)
{
Q_ASSERT(resolvedUrl.endsWith(Slash));
url = resolvedUrl;
@@ -648,24 +657,27 @@ bool QQmlImportInstance::setQmldirContent(const QString &resolvedUrl, const QQml
}
}
- qmlDirScripts = getVersionedScripts(scripts, majversion, minversion);
+ qmlDirScripts = getVersionedScripts(scripts, version);
}
return true;
}
-QQmlDirScripts QQmlImportInstance::getVersionedScripts(const QQmlDirScripts &qmldirscripts, int vmaj, int vmin)
+QQmlDirScripts QQmlImportInstance::getVersionedScripts(const QQmlDirScripts &qmldirscripts,
+ QTypeRevision version)
{
QMap<QString, QQmlDirParser::Script> versioned;
for (QList<QQmlDirParser::Script>::const_iterator sit = qmldirscripts.constBegin();
sit != qmldirscripts.constEnd(); ++sit) {
// Only include scripts that match our requested version
- if (((vmaj == -1) || (sit->majorVersion == vmaj)) &&
- ((vmin == -1) || (sit->minorVersion <= vmin))) {
+ if ((!version.hasMajorVersion() || (sit->version.majorVersion() == version.majorVersion()))
+ && (!version.hasMinorVersion()
+ || (sit->version.minorVersion() <= version.minorVersion()))) {
// Load the highest version that matches
QMap<QString, QQmlDirParser::Script>::iterator vit = versioned.find(sit->nameSpace);
- if (vit == versioned.end() || (vit->minorVersion < sit->minorVersion)) {
+ if (vit == versioned.end()
+ || (vit->version.minorVersion() < sit->version.minorVersion())) {
versioned.insert(sit->nameSpace, *sit);
}
}
@@ -685,26 +697,25 @@ QQmlDirScripts QQmlImportInstance::getVersionedScripts(const QQmlDirScripts &qml
If the return pointer is 0, the corresponding search is not done.
*/
bool QQmlImports::resolveType(QQmlImportNamespace *ns, const QHashedStringRef &type,
- QQmlType *type_return, int *vmaj, int *vmin,
+ QQmlType *type_return, QTypeRevision *version_return,
QQmlType::RegistrationType registrationType) const
{
- return ns->resolveType(d->typeLoader, type, vmaj, vmin, type_return, nullptr, nullptr, registrationType);
+ return ns->resolveType(d->typeLoader, type, version_return, type_return, nullptr, nullptr,
+ registrationType);
}
bool QQmlImportInstance::resolveType(QQmlTypeLoader *typeLoader, const QHashedStringRef& type,
- int *vmajor, int *vminor, QQmlType *type_return, QString *base,
- bool *typeRecursionDetected,
+ QTypeRevision *version_return, QQmlType *type_return,
+ QString *base, bool *typeRecursionDetected,
QQmlType::RegistrationType registrationType,
QQmlImport::RecursionRestriction recursionRestriction,
QList<QQmlError> *errors) const
{
- if (majversion >= 0 && minversion >= 0) {
- QQmlType t = QQmlMetaType::qmlType(type, uri, majversion, minversion);
+ if (version.hasMajorVersion() && version.hasMinorVersion()) {
+ QQmlType t = QQmlMetaType::qmlType(type, uri, version);
if (t.isValid()) {
- if (vmajor)
- *vmajor = majversion;
- if (vminor)
- *vminor = minversion;
+ if (version_return)
+ *version_return = version;
if (type_return)
*type_return = t;
return true;
@@ -724,6 +735,7 @@ bool QQmlImportInstance::resolveType(QQmlTypeLoader *typeLoader, const QHashedSt
Q_ASSERT(ok);
typePriv->extraData.id->url = QUrl(this->url);
auto icType = QQmlType(typePriv);
+ typePriv->release();
return icType;
};
if (containingType.isValid()) {
@@ -763,14 +775,16 @@ bool QQmlImportInstance::resolveType(QQmlTypeLoader *typeLoader, const QHashedSt
break;
}
- // importing version -1 means import ALL versions
- if ((majversion == -1) ||
- (implicitlyImported && c.internal) || // allow the implicit import of internal types
- (c.majorVersion == majversion && c.minorVersion <= minversion)) {
+ // importing invalid version means import ALL versions
+ if (!version.hasMajorVersion() || (implicitlyImported && c.internal)
+ // allow the implicit import of internal types
+ || (c.version.majorVersion() == version.majorVersion()
+ && c.version.minorVersion() <= version.minorVersion())) {
// Is this better than the previous candidate?
- if ((candidate == end) ||
- (c.majorVersion > candidate->majorVersion) ||
- ((c.majorVersion == candidate->majorVersion) && (c.minorVersion > candidate->minorVersion))) {
+ if ((candidate == end)
+ || (c.version.majorVersion() > candidate->version.majorVersion())
+ || ((c.version.majorVersion() == candidate->version.majorVersion())
+ && (c.version.minorVersion() > candidate->version.minorVersion()))) {
if (base) {
componentUrl = resolveLocalUrl(QString(url + c.typeName + dotqml_string), c.fileName);
if (c.internal) {
@@ -798,12 +812,9 @@ bool QQmlImportInstance::resolveType(QQmlTypeLoader *typeLoader, const QHashedSt
if (!base) // ensure we have a componentUrl
componentUrl = resolveLocalUrl(QString(url + candidate->typeName + dotqml_string), candidate->fileName);
QQmlType returnType = QQmlMetaType::typeForUrl(componentUrl, type, isCompositeSingleton,
- nullptr, candidate->majorVersion,
- candidate->minorVersion);
- if (vmajor)
- *vmajor = candidate->majorVersion;
- if (vminor)
- *vminor = candidate->minorVersion;
+ nullptr, candidate->version);
+ if (version_return)
+ *version_return = candidate->version;
if (type_return)
*type_return = returnType;
return returnType.isValid();
@@ -855,14 +866,14 @@ bool QQmlImportInstance::resolveType(QQmlTypeLoader *typeLoader, const QHashedSt
return false;
}
-bool QQmlImportsPrivate::resolveType(const QHashedStringRef& type, int *vmajor, int *vminor,
+bool QQmlImportsPrivate::resolveType(const QHashedStringRef& type, QTypeRevision *version_return,
QQmlType *type_return, QList<QQmlError> *errors,
QQmlType::RegistrationType registrationType,
bool *typeRecursionDetected)
{
const QVector<QHashedStringRef> splitName = type.split(Dot);
auto resolveTypeInNamespace = [&](QHashedStringRef unqualifiedtype, QQmlImportNamespace *nameSpace, QList<QQmlError> *errors) -> bool {
- if (nameSpace->resolveType(typeLoader, unqualifiedtype, vmajor, vminor, type_return, &base, errors,
+ if (nameSpace->resolveType(typeLoader, unqualifiedtype, version_return, type_return, &base, errors,
registrationType, typeRecursionDetected))
return true;
if (nameSpace->imports.count() == 1 && !nameSpace->imports.at(0)->isLibrary && type_return && nameSpace != &unqualifiedset) {
@@ -900,6 +911,7 @@ bool QQmlImportsPrivate::resolveType(const QHashedStringRef& type, int *vmajor,
int placeholderId = type_return->generatePlaceHolderICId();
icTypePriv->extraData.id->url.setFragment(QString::number(placeholderId));
auto icType = QQmlType(icTypePriv);
+ icTypePriv->release();
type_return->associateInlineComponent(icName, placeholderId, CompositeMetaTypeIds {}, icType);
*type_return = icType;
}
@@ -936,6 +948,7 @@ bool QQmlImportsPrivate::resolveType(const QHashedStringRef& type, int *vmajor,
int placeholderId = type_return->generatePlaceHolderICId();
icTypePriv->extraData.id->url.setFragment(QString::number(placeholderId));
auto icType = QQmlType(icTypePriv);
+ icTypePriv->release();
type_return->associateInlineComponent(icName, placeholderId, CompositeMetaTypeIds {}, icType);
*type_return = icType;
}
@@ -973,7 +986,7 @@ QQmlImportInstance *QQmlImportNamespace::findImport(const QString &uri) const
}
bool QQmlImportNamespace::resolveType(QQmlTypeLoader *typeLoader, const QHashedStringRef &type,
- int *vmajor, int *vminor, QQmlType *type_return,
+ QTypeRevision *version_return, QQmlType *type_return,
QString *base, QList<QQmlError> *errors,
QQmlType::RegistrationType registrationType,
bool *typeRecursionDetected)
@@ -987,13 +1000,13 @@ bool QQmlImportNamespace::resolveType(QQmlTypeLoader *typeLoader, const QHashedS
for (int i=0; i<imports.count(); ++i) {
const QQmlImportInstance *import = imports.at(i);
- if (import->resolveType(typeLoader, type, vmajor, vminor, type_return, base,
+ if (import->resolveType(typeLoader, type, version_return, type_return, base,
typeRecursionDetected, registrationType, recursionRestriction, errors)) {
if (qmlCheckTypes()) {
// check for type clashes
for (int j = i+1; j<imports.count(); ++j) {
const QQmlImportInstance *import2 = imports.at(j);
- if (import2->resolveType(typeLoader, type, vmajor, vminor, nullptr, base,
+ if (import2->resolveType(typeLoader, type, version_return, nullptr, base,
nullptr, registrationType)) {
if (errors) {
QString u1 = import->url;
@@ -1020,9 +1033,11 @@ bool QQmlImportNamespace::resolveType(QQmlTypeLoader *typeLoader, const QHashedS
error.setDescription(QQmlImportDatabase::tr("is ambiguous. Found in %1 and in %2").arg(u1).arg(u2));
} else {
error.setDescription(QQmlImportDatabase::tr("is ambiguous. Found in %1 in version %2.%3 and %4.%5")
- .arg(u1)
- .arg(import->majversion).arg(import->minversion)
- .arg(import2->majversion).arg(import2->minversion));
+ .arg(u1)
+ .arg(import->version.majorVersion())
+ .arg(import->version.minorVersion())
+ .arg(import2->version.majorVersion())
+ .arg(import2->version.minorVersion()));
}
errors->prepend(error);
}
@@ -1068,18 +1083,19 @@ QQmlImportNamespace *QQmlImportsPrivate::findQualifiedNamespace(const QHashedStr
QtQml.Models, \a vmaj is 2, and \a vmin is 0, this method returns the following:
[QtQml.Models.2.0, QtQml.2.0.Models, QtQml.Models.2, QtQml.2.Models, QtQml.Models]
*/
-static QStringList versionUriList(const QString &uri, int vmaj, int vmin)
+static QStringList versionUriList(const QString &uri, QTypeRevision version)
{
QStringList result;
- for (int version = QQmlImports::FullyVersioned; version <= QQmlImports::Unversioned; ++version) {
+ for (int mode = QQmlImports::FullyVersioned; mode <= QQmlImports::Unversioned; ++mode) {
int index = uri.length();
do {
QString versionUri = uri;
- versionUri.insert(index, QQmlImports::versionString(vmaj, vmin, static_cast<QQmlImports::ImportVersion>(version)));
+ versionUri.insert(index, QQmlImports::versionString(
+ version, QQmlImports::ImportVersion(mode)));
result += versionUri;
index = uri.lastIndexOf(Dot, index - 1);
- } while (index > 0 && version != QQmlImports::Unversioned);
+ } while (index > 0 && mode != QQmlImports::Unversioned);
}
return result;
}
@@ -1144,8 +1160,7 @@ Import an extension defined by a qmldir file.
\a qmldirFilePath is a raw file path.
*/
bool QQmlImportsPrivate::importExtension(const QString &qmldirFilePath,
- const QString &uri,
- int vmaj, int vmin,
+ const QString &uri, QTypeRevision version,
QQmlImportDatabase *database,
const QQmlTypeLoaderQmldirContent &qmldir,
QList<QQmlError> *errors)
@@ -1170,13 +1185,7 @@ bool QQmlImportsPrivate::importExtension(const QString &qmldirFilePath,
if (qmldirPluginCount == 0)
return true;
- if (database->qmlDirFilesForWhichPluginsHaveBeenLoaded.contains(qmldirFilePath)) {
- if ((vmaj >= 0 && vmin >= 0)
- ? !QQmlMetaType::isModule(uri, vmaj, vmin)
- : !QQmlMetaType::isAnyModule(uri)) {
- QQmlMetaType::qmlRegisterModuleTypes(uri, vmaj);
- }
- } else {
+ if (!database->qmlDirFilesForWhichPluginsHaveBeenLoaded.contains(qmldirFilePath)) {
// First search for listed qmldir plugins dynamically. If we cannot resolve them all, we continue
// searching static plugins that has correct metadata uri. Note that since we only know the uri
// for a static plugin, and not the filename, we cannot know which static plugin belongs to which
@@ -1198,7 +1207,7 @@ bool QQmlImportsPrivate::importExtension(const QString &qmldirFilePath,
QString resolvedFilePath = database->resolvePlugin(typeLoader, qmldirPath, plugin.path, plugin.name);
if (!resolvedFilePath.isEmpty()) {
dynamicPluginsFound++;
- if (!database->importDynamicPlugin(resolvedFilePath, uri, typeNamespace, vmaj, errors)) {
+ if (!database->importDynamicPlugin(resolvedFilePath, uri, typeNamespace, version, errors)) {
if (errors) {
// XXX TODO: should we leave the import plugin error alone?
// Here, we pop it off the top and coalesce it into this error's message.
@@ -1223,7 +1232,7 @@ bool QQmlImportsPrivate::importExtension(const QString &qmldirFilePath,
// versioned to unversioned, we need to compare with differnt version strings. If a module
// has several plugins, they must all have the same version. Start by populating pluginPairs
// with relevant plugins to cut the list short early on:
- const QStringList versionUris = versionUriList(uri, vmaj, vmin);
+ const QStringList versionUris = versionUriList(uri, version);
QVector<StaticPluginPair> pluginPairs;
if (!populatePluginPairVector(pluginPairs, uri, versionUris, qmldirFilePath, errors))
return false;
@@ -1235,7 +1244,7 @@ bool QQmlImportsPrivate::importExtension(const QString &qmldirFilePath,
if (versionUri == metaTagUri.toString()) {
staticPluginsFound++;
QObject *instance = pair.first.instance();
- if (!database->importStaticPlugin(instance, basePath, uri, typeNamespace, vmaj, errors)) {
+ if (!database->importStaticPlugin(instance, basePath, uri, typeNamespace, version, errors)) {
if (errors) {
QQmlError poppedError = errors->takeFirst();
QQmlError error;
@@ -1338,10 +1347,11 @@ and fills in outQmldirFilePath and outQmldirUrl appropriately. Otherwise return
false.
*/
QQmlImports::LocalQmldirResult QQmlImportsPrivate::locateLocalQmldir(
- const QString &uri, int vmaj, int vmin, QQmlImportDatabase *database,
+ const QString &uri, QTypeRevision version, QQmlImportDatabase *database,
QString *outQmldirFilePath, QString *outQmldirPathUrl)
{
- Q_ASSERT(vmaj >= 0 && vmin >= 0); // Versions are always specified for libraries
+ // Versions are always specified for libraries
+ Q_ASSERT(version.hasMajorVersion() && version.hasMinorVersion());
// Check cache first
@@ -1352,7 +1362,7 @@ QQmlImports::LocalQmldirResult QQmlImportsPrivate::locateLocalQmldir(
cacheHead = *cachePtr;
QQmlImportDatabase::QmldirCache *cache = cacheHead;
while (cache) {
- if (cache->versionMajor == vmaj && cache->versionMinor == vmin) {
+ if (cache->version == version) {
*outQmldirFilePath = cache->qmldirFilePath;
*outQmldirPathUrl = cache->qmldirPathUrl;
return cache->qmldirFilePath.isEmpty() ? QQmlImports::QmldirNotFound
@@ -1372,7 +1382,7 @@ QQmlImports::LocalQmldirResult QQmlImportsPrivate::locateLocalQmldir(
// Search local import paths for a matching version
const QStringList qmlDirPaths = QQmlImports::completeQmldirPaths(
- uri, localImportPaths, vmaj, vmin);
+ uri, localImportPaths, version);
bool pathTurnedRemote = false;
for (QString qmldirPath : qmlDirPaths) {
if (interceptor) {
@@ -1394,8 +1404,7 @@ QQmlImports::LocalQmldirResult QQmlImportsPrivate::locateLocalQmldir(
url = QUrl::fromLocalFile(absolutePath.toString()).toString();
QQmlImportDatabase::QmldirCache *cache = new QQmlImportDatabase::QmldirCache;
- cache->versionMajor = vmaj;
- cache->versionMinor = vmin;
+ cache->version = version;
cache->qmldirFilePath = absoluteFilePath;
cache->qmldirPathUrl = url;
cache->next = cacheHead;
@@ -1409,19 +1418,19 @@ QQmlImports::LocalQmldirResult QQmlImportsPrivate::locateLocalQmldir(
}
QQmlImportDatabase::QmldirCache *cache = new QQmlImportDatabase::QmldirCache;
- cache->versionMajor = vmaj;
- cache->versionMinor = vmin;
+ cache->version = version;
cache->next = cacheHead;
database->qmldirCache.insert(uri, cache);
return pathTurnedRemote ? QQmlImports::QmldirInterceptedToRemote : QQmlImports::QmldirNotFound;
}
-bool QQmlImportsPrivate::validateQmldirVersion(const QQmlTypeLoaderQmldirContent &qmldir, const QString &uri, int vmaj, int vmin,
+bool QQmlImportsPrivate::validateQmldirVersion(const QQmlTypeLoaderQmldirContent &qmldir,
+ const QString &uri, QTypeRevision version,
QList<QQmlError> *errors)
{
- int lowest_min = INT_MAX;
- int highest_min = INT_MIN;
+ quint8 lowest_min = std::numeric_limits<quint8>::max();
+ quint8 highest_min = 0;
typedef QQmlDirComponents::const_iterator ConstIterator;
const QQmlDirComponents &components = qmldir.components();
@@ -1429,21 +1438,20 @@ bool QQmlImportsPrivate::validateQmldirVersion(const QQmlTypeLoaderQmldirContent
ConstIterator cend = components.constEnd();
for (ConstIterator cit = components.constBegin(); cit != cend; ++cit) {
for (ConstIterator cit2 = components.constBegin(); cit2 != cit; ++cit2) {
- if ((cit2->typeName == cit->typeName) &&
- (cit2->majorVersion == cit->majorVersion) &&
- (cit2->minorVersion == cit->minorVersion)) {
+ if (cit2->typeName == cit->typeName && cit2->version == cit->version) {
// This entry clashes with a predecessor
QQmlError error;
error.setDescription(QQmlImportDatabase::tr("\"%1\" version %2.%3 is defined more than once in module \"%4\"")
- .arg(cit->typeName).arg(cit->majorVersion).arg(cit->minorVersion).arg(uri));
+ .arg(cit->typeName).arg(cit->version.majorVersion())
+ .arg(cit->version.minorVersion()).arg(uri));
errors->prepend(error);
return false;
}
}
- if (cit->majorVersion == vmaj) {
- lowest_min = qMin(lowest_min, cit->minorVersion);
- highest_min = qMax(highest_min, cit->minorVersion);
+ if (cit->version.majorVersion() == version.majorVersion()) {
+ lowest_min = qMin(lowest_min, cit->version.minorVersion());
+ highest_min = qMax(highest_min, cit->version.minorVersion());
}
}
@@ -1453,27 +1461,27 @@ bool QQmlImportsPrivate::validateQmldirVersion(const QQmlTypeLoaderQmldirContent
SConstIterator send = scripts.constEnd();
for (SConstIterator sit = scripts.constBegin(); sit != send; ++sit) {
for (SConstIterator sit2 = scripts.constBegin(); sit2 != sit; ++sit2) {
- if ((sit2->nameSpace == sit->nameSpace) &&
- (sit2->majorVersion == sit->majorVersion) &&
- (sit2->minorVersion == sit->minorVersion)) {
+ if (sit2->nameSpace == sit->nameSpace && sit2->version == sit->version) {
// This entry clashes with a predecessor
QQmlError error;
error.setDescription(QQmlImportDatabase::tr("\"%1\" version %2.%3 is defined more than once in module \"%4\"")
- .arg(sit->nameSpace).arg(sit->majorVersion).arg(sit->minorVersion).arg(uri));
+ .arg(sit->nameSpace).arg(sit->version.majorVersion())
+ .arg(sit->version.minorVersion()).arg(uri));
errors->prepend(error);
return false;
}
}
- if (sit->majorVersion == vmaj) {
- lowest_min = qMin(lowest_min, sit->minorVersion);
- highest_min = qMax(highest_min, sit->minorVersion);
+ if (sit->version.majorVersion() == version.majorVersion()) {
+ lowest_min = qMin(lowest_min, sit->version.minorVersion());
+ highest_min = qMax(highest_min, sit->version.minorVersion());
}
}
- if (lowest_min > vmin || highest_min < vmin) {
+ if (lowest_min > version.minorVersion() || highest_min < version.minorVersion()) {
QQmlError error;
- error.setDescription(QQmlImportDatabase::tr("module \"%1\" version %2.%3 is not installed").arg(uri).arg(vmaj).arg(vmin));
+ error.setDescription(QQmlImportDatabase::tr("module \"%1\" version %2.%3 is not installed")
+ .arg(uri).arg(version.majorVersion()).arg(version.minorVersion()));
errors->prepend(error);
return false;
}
@@ -1500,10 +1508,9 @@ QQmlImportNamespace *QQmlImportsPrivate::importNamespace(const QString &prefix)
return nameSpace;
}
-QQmlImportInstance *QQmlImportsPrivate::addImportToNamespace(QQmlImportNamespace *nameSpace,
- const QString &uri, const QString &url, int vmaj, int vmin,
- QV4::CompiledData::Import::ImportType type,
- QList<QQmlError> *errors, bool lowPrecedence)
+QQmlImportInstance *QQmlImportsPrivate::addImportToNamespace(
+ QQmlImportNamespace *nameSpace, const QString &uri, const QString &url, QTypeRevision version,
+ QV4::CompiledData::Import::ImportType type, QList<QQmlError> *errors, bool lowPrecedence)
{
Q_ASSERT(nameSpace);
Q_ASSERT(errors);
@@ -1514,8 +1521,7 @@ QQmlImportInstance *QQmlImportsPrivate::addImportToNamespace(QQmlImportNamespace
import->uri = uri;
import->url = url;
import->localDirectoryPath = QQmlFile::urlToLocalFileOrQrc(url);
- import->majversion = vmaj;
- import->minversion = vmin;
+ import->version = version;
import->isLibrary = (type == QV4::CompiledData::Import::ImportLibrary);
if (lowPrecedence)
@@ -1526,10 +1532,10 @@ QQmlImportInstance *QQmlImportsPrivate::addImportToNamespace(QQmlImportNamespace
return import;
}
-bool QQmlImportsPrivate::addLibraryImport(const QString& uri, const QString &prefix,
- int vmaj, int vmin, const QString &qmldirIdentifier, const QString &qmldirUrl, bool incomplete,
- QQmlImportDatabase *database,
- QList<QQmlError> *errors)
+bool QQmlImportsPrivate::addLibraryImport(
+ const QString& uri, const QString &prefix, QTypeRevision version,
+ const QString &qmldirIdentifier, const QString &qmldirUrl, bool incomplete,
+ QQmlImportDatabase *database, QList<QQmlError> *errors)
{
Q_ASSERT(database);
Q_ASSERT(errors);
@@ -1537,7 +1543,9 @@ bool QQmlImportsPrivate::addLibraryImport(const QString& uri, const QString &pre
QQmlImportNamespace *nameSpace = importNamespace(prefix);
Q_ASSERT(nameSpace);
- QQmlImportInstance *inserted = addImportToNamespace(nameSpace, uri, qmldirUrl, vmaj, vmin, QV4::CompiledData::Import::ImportLibrary, errors);
+ QQmlImportInstance *inserted = addImportToNamespace(
+ nameSpace, uri, qmldirUrl, version,
+ QV4::CompiledData::Import::ImportLibrary, errors);
Q_ASSERT(inserted);
if (!incomplete) {
@@ -1548,7 +1556,7 @@ bool QQmlImportsPrivate::addLibraryImport(const QString& uri, const QString &pre
return false;
if (qmldir.hasContent()) {
- if (!importExtension(qmldir.pluginLocation(), uri, vmaj, vmin, database, qmldir, errors))
+ if (!importExtension(qmldir.pluginLocation(), uri, version, database, qmldir, errors))
return false;
if (!inserted->setQmldirContent(qmldirUrl, qmldir, nameSpace, errors))
@@ -1557,18 +1565,22 @@ bool QQmlImportsPrivate::addLibraryImport(const QString& uri, const QString &pre
}
// Ensure that we are actually providing something
- if ((vmaj < 0) || (vmin < 0) || !QQmlMetaType::isModule(uri, vmaj, vmin)) {
+ if (!version.hasMajorVersion() || !version.hasMinorVersion()
+ || !QQmlMetaType::isModule(uri, version)) {
if (inserted->qmlDirComponents.isEmpty() && inserted->qmlDirScripts.isEmpty()) {
QQmlError error;
- if (QQmlMetaType::isAnyModule(uri))
- error.setDescription(QQmlImportDatabase::tr("module \"%1\" version %2.%3 is not installed").arg(uri).arg(vmaj).arg(vmin));
- else
+ if (QQmlMetaType::isAnyModule(uri)) {
+ error.setDescription(QQmlImportDatabase::tr("module \"%1\" version %2.%3 is not installed")
+ .arg(uri).arg(version.majorVersion()).arg(version.minorVersion()));
+ } else {
error.setDescription(QQmlImportDatabase::tr("module \"%1\" is not installed").arg(uri));
+ }
errors->prepend(error);
return false;
- } else if ((vmaj >= 0) && (vmin >= 0) && qmldir.hasContent()) {
+ } else if (version.hasMajorVersion() && version.hasMinorVersion()
+ && qmldir.hasContent()) {
// Verify that the qmldir content is valid for this version
- if (!validateQmldirVersion(qmldir, uri, vmaj, vmin, errors))
+ if (!validateQmldirVersion(qmldir, uri, version, errors))
return false;
}
}
@@ -1577,10 +1589,9 @@ bool QQmlImportsPrivate::addLibraryImport(const QString& uri, const QString &pre
return true;
}
-bool QQmlImportsPrivate::addFileImport(const QString& uri, const QString &prefix,
- int vmaj, int vmin,
- bool isImplicitImport, bool incomplete, QQmlImportDatabase *database,
- QList<QQmlError> *errors)
+bool QQmlImportsPrivate::addFileImport(const QString& uri, const QString &prefix, QTypeRevision version,
+ bool isImplicitImport, bool incomplete,
+ QQmlImportDatabase *database, QList<QQmlError> *errors)
{
Q_ASSERT(errors);
@@ -1656,7 +1667,9 @@ bool QQmlImportsPrivate::addFileImport(const QString& uri, const QString &prefix
}
}
- QQmlImportInstance *inserted = addImportToNamespace(nameSpace, importUri, url, vmaj, vmin, QV4::CompiledData::Import::ImportFile, errors, isImplicitImport);
+ QQmlImportInstance *inserted = addImportToNamespace(
+ nameSpace, importUri, url, version, QV4::CompiledData::Import::ImportFile,
+ errors, isImplicitImport);
Q_ASSERT(inserted);
if (!incomplete && !qmldirIdentifier.isEmpty()) {
@@ -1665,7 +1678,7 @@ bool QQmlImportsPrivate::addFileImport(const QString& uri, const QString &prefix
return false;
if (qmldir.hasContent()) {
- if (!importExtension(qmldir.pluginLocation(), importUri, vmaj, vmin, database, qmldir, errors))
+ if (!importExtension(qmldir.pluginLocation(), importUri, version, database, qmldir, errors))
return false;
if (!inserted->setQmldirContent(url, qmldir, nameSpace, errors))
@@ -1689,26 +1702,27 @@ bool QQmlImportsPrivate::updateQmldirContent(const QString &uri, const QString &
return false;
if (qmldir.hasContent()) {
- int vmaj = import->majversion;
- int vmin = import->minversion;
- if (!importExtension(qmldir.pluginLocation(), uri, vmaj, vmin, database, qmldir, errors))
+ QTypeRevision version = import->version;
+ if (!importExtension(qmldir.pluginLocation(), uri, version, database, qmldir, errors))
return false;
if (import->setQmldirContent(qmldirUrl, qmldir, nameSpace, errors)) {
if (import->qmlDirComponents.isEmpty() && import->qmlDirScripts.isEmpty()) {
// The implicit import qmldir can be empty, and plugins have no extra versions
- if (uri != QLatin1String(".") && !QQmlMetaType::isModule(uri, vmaj, vmin)) {
+ if (uri != QLatin1String(".") && !QQmlMetaType::isModule(uri, version)) {
QQmlError error;
- if (QQmlMetaType::isAnyModule(uri))
- error.setDescription(QQmlImportDatabase::tr("module \"%1\" version %2.%3 is not installed").arg(uri).arg(vmaj).arg(vmin));
- else
+ if (QQmlMetaType::isAnyModule(uri)) {
+ error.setDescription(QQmlImportDatabase::tr("module \"%1\" version %2.%3 is not installed")
+ .arg(uri).arg(version.majorVersion()).arg(version.minorVersion()));
+ } else {
error.setDescription(QQmlImportDatabase::tr("module \"%1\" is not installed").arg(uri));
+ }
errors->prepend(error);
return false;
}
- } else if ((vmaj >= 0) && (vmin >= 0)) {
+ } else if (version.hasMajorVersion() && version.hasMinorVersion()) {
// Verify that the qmldir content is valid for this version
- if (!validateQmldirVersion(qmldir, uri, vmaj, vmin, errors))
+ if (!validateQmldirVersion(qmldir, uri, version, errors))
return false;
}
return true;
@@ -1742,7 +1756,8 @@ bool QQmlImports::addImplicitImport(QQmlImportDatabase *importDb, QList<QQmlErro
<< ")::addImplicitImport";
bool incomplete = !isLocal(baseUrl());
- return d->addFileImport(QLatin1String("."), QString(), -1, -1, true, incomplete, importDb, errors);
+ return d->addFileImport(QLatin1String("."), QString(), QTypeRevision(), true, incomplete,
+ importDb, errors);
}
/*!
@@ -1753,8 +1768,7 @@ bool QQmlImports::addInlineComponentImport(QQmlImportInstance *const importInsta
importInstance->url = importUrl.toString();
importInstance->uri = name;
importInstance->isInlineComponent = true;
- importInstance->majversion = 0;
- importInstance->minversion = 0;
+ importInstance->version = QTypeRevision::zero();
importInstance->containingType = containingType;
d->unqualifiedset.imports.push_back(importInstance);
return true;
@@ -1782,7 +1796,7 @@ bool QQmlImports::addInlineComponentImport(QQmlImportInstance *const importInsta
filled appropriately.
*/
bool QQmlImports::addFileImport(QQmlImportDatabase *importDb,
- const QString& uri, const QString& prefix, int vmaj, int vmin,
+ const QString& uri, const QString& prefix, QTypeRevision version,
bool incomplete, QList<QQmlError> *errors)
{
Q_ASSERT(importDb);
@@ -1790,13 +1804,13 @@ bool QQmlImports::addFileImport(QQmlImportDatabase *importDb,
if (qmlImportTrace())
qDebug().nospace() << "QQmlImports(" << qPrintable(baseUrl().toString()) << ')' << "::addFileImport: "
- << uri << ' ' << vmaj << '.' << vmin << " as " << prefix;
+ << uri << ' ' << version << " as " << prefix;
- return d->addFileImport(uri, prefix, vmaj, vmin, false, incomplete, importDb, errors);
+ return d->addFileImport(uri, prefix, version, false, incomplete, importDb, errors);
}
bool QQmlImports::addLibraryImport(QQmlImportDatabase *importDb,
- const QString &uri, const QString &prefix, int vmaj, int vmin,
+ const QString &uri, const QString &prefix, QTypeRevision version,
const QString &qmldirIdentifier, const QString& qmldirUrl, bool incomplete, QList<QQmlError> *errors)
{
Q_ASSERT(importDb);
@@ -1804,9 +1818,9 @@ bool QQmlImports::addLibraryImport(QQmlImportDatabase *importDb,
if (qmlImportTrace())
qDebug().nospace() << "QQmlImports(" << qPrintable(baseUrl().toString()) << ')' << "::addLibraryImport: "
- << uri << ' ' << vmaj << '.' << vmin << " as " << prefix;
+ << uri << ' ' << version << " as " << prefix;
- return d->addLibraryImport(uri, prefix, vmaj, vmin, qmldirIdentifier, qmldirUrl, incomplete, importDb, errors);
+ return d->addLibraryImport(uri, prefix, version, qmldirIdentifier, qmldirUrl, incomplete, importDb, errors);
}
bool QQmlImports::updateQmldirContent(QQmlImportDatabase *importDb,
@@ -1824,10 +1838,10 @@ bool QQmlImports::updateQmldirContent(QQmlImportDatabase *importDb,
}
QQmlImports::LocalQmldirResult QQmlImports::locateLocalQmldir(
- QQmlImportDatabase *importDb, const QString &uri, int vmaj, int vmin,
+ QQmlImportDatabase *importDb, const QString &uri, QTypeRevision version,
QString *qmldirFilePath, QString *url)
{
- return d->locateLocalQmldir(uri, vmaj, vmin, importDb, qmldirFilePath, url);
+ return d->locateLocalQmldir(uri, version, importDb, qmldirFilePath, url);
}
bool QQmlImports::isLocal(const QString &url)
@@ -1878,7 +1892,7 @@ QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e)
#else
QLatin1Char pathSep(':');
#endif
- QStringList paths = envImportPath.split(pathSep, QString::SkipEmptyParts);
+ QStringList paths = envImportPath.split(pathSep, Qt::SkipEmptyParts);
for (int ii = paths.count() - 1; ii >= 0; --ii)
addImportPath(paths.at(ii));
}
@@ -1890,7 +1904,7 @@ QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e)
if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty("QT_BUNDLED_LIBS_PATH"))) {
const QString envImportPath = qEnvironmentVariable("QT_BUNDLED_LIBS_PATH");
QLatin1Char pathSep(':');
- QStringList paths = envImportPath.split(pathSep, QString::SkipEmptyParts);
+ QStringList paths = envImportPath.split(pathSep, Qt::SkipEmptyParts);
for (int ii = paths.count() - 1; ii >= 0; --ii)
addPluginPath(paths.at(ii));
}
@@ -1993,8 +2007,11 @@ QString QQmlImportDatabase::resolvePlugin(QQmlTypeLoader *typeLoader,
static const QStringList suffixes = {
# ifdef QT_DEBUG
QLatin1String("d.dll"), // try a qmake-style debug build first
-# endif
QLatin1String(".dll")
+#else
+ QLatin1String(".dll"),
+ QLatin1String("d.dll") // try a qmake-style debug build after
+# endif
};
#elif defined(Q_OS_DARWIN)
static const QString prefix = QLatin1String("lib");
@@ -2133,19 +2150,21 @@ void QQmlImportDatabase::setImportPathList(const QStringList &paths)
\internal
*/
static bool registerPluginTypes(QObject *instance, const QString &basePath, const QString &uri,
- const QString &typeNamespace, int vmaj, QList<QQmlError> *errors)
+ const QString &typeNamespace, QTypeRevision version,
+ QList<QQmlError> *errors)
{
if (qmlImportTrace())
qDebug().nospace() << "QQmlImportDatabase::registerPluginTypes: " << uri << " from " << basePath;
- if (!QQmlMetaType::registerPluginTypes(instance, basePath, uri, typeNamespace, vmaj, errors))
+ if (!QQmlMetaType::registerPluginTypes(instance, basePath, uri, typeNamespace, version, errors))
return false;
- if (vmaj >= 0 && !typeNamespace.isEmpty() && !QQmlMetaType::protectModule(uri, vmaj)) {
+ if (version.hasMajorVersion() && !typeNamespace.isEmpty()
+ && !QQmlMetaType::protectModule(uri, version)) {
QQmlError error;
error.setDescription(
QString::fromLatin1("Cannot protect module %1 %2 as it was never registered")
- .arg(uri).arg(vmaj));
+ .arg(uri).arg(version.majorVersion()));
errors->append(error);
return false;
}
@@ -2156,8 +2175,9 @@ static bool registerPluginTypes(QObject *instance, const QString &basePath, cons
/*!
\internal
*/
-bool QQmlImportDatabase::importStaticPlugin(QObject *instance, const QString &basePath,
- const QString &uri, const QString &typeNamespace, int vmaj, QList<QQmlError> *errors)
+bool QQmlImportDatabase::importStaticPlugin(
+ QObject *instance, const QString &basePath, const QString &uri,
+ const QString &typeNamespace, QTypeRevision version, QList<QQmlError> *errors)
{
// Dynamic plugins are differentiated by their filepath. For static plugins we
// don't have that information so we use their address as key instead.
@@ -2180,7 +2200,7 @@ bool QQmlImportDatabase::importStaticPlugin(QObject *instance, const QString &ba
plugin.loader = nullptr;
plugins->insert(uniquePluginID, plugin);
- if (!registerPluginTypes(instance, basePath, uri, typeNamespace, vmaj, errors))
+ if (!registerPluginTypes(instance, basePath, uri, typeNamespace, version, errors))
return false;
}
@@ -2200,8 +2220,9 @@ bool QQmlImportDatabase::importStaticPlugin(QObject *instance, const QString &ba
/*!
\internal
*/
-bool QQmlImportDatabase::importDynamicPlugin(const QString &filePath, const QString &uri,
- const QString &typeNamespace, int vmaj, QList<QQmlError> *errors)
+bool QQmlImportDatabase::importDynamicPlugin(
+ const QString &filePath, const QString &uri, const QString &typeNamespace,
+ QTypeRevision version, QList<QQmlError> *errors)
{
QFileInfo fileInfo(filePath);
const QString absoluteFilePath = fileInfo.absoluteFilePath();
@@ -2255,7 +2276,7 @@ bool QQmlImportDatabase::importDynamicPlugin(const QString &filePath, const QStr
plugins->insert(absoluteFilePath, plugin);
// Continue with shared code path for dynamic and static plugins:
- if (!registerPluginTypes(instance, fileInfo.absolutePath(), uri, typeNamespace, vmaj, errors))
+ if (!registerPluginTypes(instance, fileInfo.absolutePath(), uri, typeNamespace, version, errors))
return false;
}
}
diff --git a/src/qml/qml/qqmlimport_p.h b/src/qml/qml/qqmlimport_p.h
index 2e994fd27f..7416bb7a4c 100644
--- a/src/qml/qml/qqmlimport_p.h
+++ b/src/qml/qml/qqmlimport_p.h
@@ -81,8 +81,7 @@ struct QQmlImportInstance
QString url; // the base path of the import
QString localDirectoryPath; // the base path of the import if it's a local file
QQmlType containingType; // points to the containing type for inline components
- int majversion; // the major version imported
- int minversion; // the minor version imported
+ QTypeRevision version; // the version imported
bool isLibrary; // true means that this is not a file import
bool implicitlyImported = false;
bool isInlineComponent = false;
@@ -92,10 +91,11 @@ struct QQmlImportInstance
bool setQmldirContent(const QString &resolvedUrl, const QQmlTypeLoaderQmldirContent &qmldir,
QQmlImportNamespace *nameSpace, QList<QQmlError> *errors);
- static QQmlDirScripts getVersionedScripts(const QQmlDirScripts &qmldirscripts, int vmaj, int vmin);
+ static QQmlDirScripts getVersionedScripts(const QQmlDirScripts &qmldirscripts,
+ QTypeRevision version);
bool resolveType(QQmlTypeLoader *typeLoader, const QHashedStringRef &type,
- int *vmajor, int *vminor, QQmlType* type_return,
+ QTypeRevision *version_return, QQmlType* type_return,
QString *base = nullptr, bool *typeRecursionDetected = nullptr,
QQmlType::RegistrationType = QQmlType::AnyRegistrationType,
QQmlImport::RecursionRestriction recursionRestriction = QQmlImport::PreventRecursion,
@@ -113,7 +113,7 @@ public:
QQmlImportInstance *findImport(const QString &uri) const;
bool resolveType(QQmlTypeLoader *typeLoader, const QHashedStringRef& type,
- int *vmajor, int *vminor, QQmlType* type_return,
+ QTypeRevision *version_return, QQmlType* type_return,
QString *base = nullptr, QList<QQmlError> *errors = nullptr,
QQmlType::RegistrationType registrationType = QQmlType::AnyRegistrationType,
bool *typeRecursionDeteced = nullptr);
@@ -140,14 +140,14 @@ public:
bool resolveType(const QHashedStringRef &type,
QQmlType *type_return,
- int *version_major, int *version_minor,
+ QTypeRevision *version_return,
QQmlImportNamespace **ns_return,
QList<QQmlError> *errors = nullptr,
QQmlType::RegistrationType registrationType = QQmlType::AnyRegistrationType,
bool *typeRecursionDetected = nullptr) const;
bool resolveType(QQmlImportNamespace *,
const QHashedStringRef& type,
- QQmlType *type_return, int *version_major, int *version_minor,
+ QQmlType *type_return, QTypeRevision *version_return,
QQmlType::RegistrationType registrationType
= QQmlType::AnyRegistrationType) const;
@@ -156,11 +156,11 @@ public:
bool addInlineComponentImport(QQmlImportInstance *const importInstance, const QString &name, const QUrl importUrl, QQmlType containingType);
bool addFileImport(QQmlImportDatabase *,
- const QString& uri, const QString& prefix, int vmaj, int vmin, bool incomplete,
- QList<QQmlError> *errors);
+ const QString& uri, const QString& prefix, QTypeRevision version,
+ bool incomplete, QList<QQmlError> *errors);
bool addLibraryImport(QQmlImportDatabase *importDb,
- const QString &uri, const QString &prefix, int vmaj, int vmin,
+ const QString &uri, const QString &prefix, QTypeRevision version,
const QString &qmldirIdentifier, const QString &qmldirUrl, bool incomplete, QList<QQmlError> *errors);
bool updateQmldirContent(QQmlImportDatabase *importDb,
@@ -174,7 +174,7 @@ public:
};
LocalQmldirResult locateLocalQmldir(
- QQmlImportDatabase *, const QString &uri, int vmaj, int vmin,
+ QQmlImportDatabase *, const QString &uri, QTypeRevision version,
QString *qmldirFilePath, QString *url);
void populateCache(QQmlTypeNameCache *cache) const;
@@ -192,14 +192,14 @@ public:
{
QString typeName;
QString prefix;
- int majorVersion;
- int minorVersion;
+ QTypeRevision version;
};
QList<CompositeSingletonReference> resolvedCompositeSingletons() const;
- static QStringList completeQmldirPaths(const QString &uri, const QStringList &basePaths, int vmaj, int vmin);
- static QString versionString(int vmaj, int vmin, ImportVersion version);
+ static QStringList completeQmldirPaths(const QString &uri, const QStringList &basePaths,
+ QTypeRevision version);
+ static QString versionString(QTypeRevision version, ImportVersion importVersion);
static bool isLocal(const QString &url);
static bool isLocal(const QUrl &url);
@@ -222,7 +222,9 @@ public:
~QQmlImportDatabase();
#if QT_CONFIG(library)
- bool importDynamicPlugin(const QString &filePath, const QString &uri, const QString &importNamespace, int vmaj, QList<QQmlError> *errors);
+ bool importDynamicPlugin(const QString &filePath, const QString &uri,
+ const QString &importNamespace, QTypeRevision version,
+ QList<QQmlError> *errors);
bool removeDynamicPlugin(const QString &filePath);
QStringList dynamicPlugins() const;
#endif
@@ -245,13 +247,13 @@ private:
const QString &qmldirPath, const QString &qmldirPluginPath,
const QString &baseName);
bool importStaticPlugin(QObject *instance, const QString &basePath, const QString &uri,
- const QString &typeNamespace, int vmaj, QList<QQmlError> *errors);
+ const QString &typeNamespace, QTypeRevision version,
+ QList<QQmlError> *errors);
void clearDirCache();
void finalizePlugin(QObject *instance, const QString &path, const QString &uri);
struct QmldirCache {
- int versionMajor;
- int versionMinor;
+ QTypeRevision version;
QString qmldirFilePath;
QString qmldirPathUrl;
QmldirCache *next;
diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp
index 4911cd2879..0ad013e90b 100644
--- a/src/qml/qml/qqmlincubator.cpp
+++ b/src/qml/qml/qqmlincubator.cpp
@@ -722,8 +722,8 @@ bool QQmlIncubatorPrivate::hadRequiredProperties() const
}
/*!
-Stores a mapping from property names to initial values with which the incubated
-component will be initialized
+Stores a mapping from property names to initial values, contained in
+\a initialProperties, with which the incubated component will be initialized.
\sa QQmlComponent::setInitialProperties
\since 5.15
diff --git a/src/qml/qml/qqmlincubator_p.h b/src/qml/qml/qqmlincubator_p.h
index aadb147bd5..a674ff274f 100644
--- a/src/qml/qml/qqmlincubator_p.h
+++ b/src/qml/qml/qqmlincubator_p.h
@@ -61,9 +61,7 @@
QT_BEGIN_NAMESPACE
-class QQmlPropertyData;
-struct RequiredPropertyInfo;
-using RequiredProperties = QHash<QQmlPropertyData*, RequiredPropertyInfo>;
+class RequiredProperties;
class QQmlIncubator;
class Q_QML_PRIVATE_EXPORT QQmlIncubatorPrivate : public QQmlEnginePrivate::Incubator
diff --git a/src/qml/qml/qqmlinfo.cpp b/src/qml/qml/qqmlinfo.cpp
index dd401bdb20..7204d5ccd2 100644
--- a/src/qml/qml/qqmlinfo.cpp
+++ b/src/qml/qml/qqmlinfo.cpp
@@ -44,6 +44,7 @@
#include "qqmlcontext_p.h"
#include "qqmlmetatype_p.h"
#include "qqmlengine_p.h"
+#include "qqmlsourcecoordinate_p.h"
#include <QCoreApplication>
@@ -218,8 +219,8 @@ QQmlInfo::~QQmlInfo()
QQmlData *ddata = QQmlData::get(object, false);
if (ddata && ddata->outerContext) {
error.setUrl(ddata->outerContext->url());
- error.setLine(ddata->lineNumber);
- error.setColumn(ddata->columnNumber);
+ error.setLine(qmlConvertSourceCoordinate<quint16, int>(ddata->lineNumber));
+ error.setColumn(qmlConvertSourceCoordinate<quint16, int>(ddata->columnNumber));
}
}
diff --git a/src/qml/qml/qqmlirloader.cpp b/src/qml/qml/qqmlirloader.cpp
index b284e44fdf..f66094fad7 100644
--- a/src/qml/qml/qqmlirloader.cpp
+++ b/src/qml/qml/qqmlirloader.cpp
@@ -78,14 +78,14 @@ struct FakeExpression : public QQmlJS::AST::NullExpression
: location(start, length)
{}
- virtual QQmlJS::AST::SourceLocation firstSourceLocation() const
+ virtual QQmlJS::SourceLocation firstSourceLocation() const
{ return location; }
- virtual QQmlJS::AST::SourceLocation lastSourceLocation() const
+ virtual QQmlJS::SourceLocation lastSourceLocation() const
{ return location; }
private:
- QQmlJS::AST::SourceLocation location;
+ QQmlJS::SourceLocation location;
};
QmlIR::Object *QQmlIRLoader::loadObject(const QV4::CompiledData::Object *serializedObject)
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index 8661ebcc13..6a9ef06159 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -50,6 +50,7 @@
#include <private/qqmlglobal_p.h>
#include <private/qv4qobjectwrapper_p.h>
#include <private/qqmlbuiltinfunctions_p.h>
+#include <private/qqmlsourcecoordinate_p.h>
QT_BEGIN_NAMESPACE
@@ -72,8 +73,8 @@ bool QQmlDelayedError::addError(QQmlEnginePrivate *e)
void QQmlDelayedError::setErrorLocation(const QQmlSourceLocation &sourceLocation)
{
m_error.setUrl(QUrl(sourceLocation.sourceFile));
- m_error.setLine(sourceLocation.line);
- m_error.setColumn(sourceLocation.column);
+ m_error.setLine(qmlConvertSourceCoordinate<quint16, int>(sourceLocation.line));
+ m_error.setColumn(qmlConvertSourceCoordinate<quint16, int>(sourceLocation.column));
}
void QQmlDelayedError::setErrorDescription(const QString &description)
diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp
index 1743410776..bc227ad713 100644
--- a/src/qml/qml/qqmllocale.cpp
+++ b/src/qml/qml/qqmllocale.cpp
@@ -314,7 +314,7 @@ ReturnedValue QQmlDateExtension::method_fromLocaleDateString(const QV4::Function
QLocale locale;
QString dateString = s->toQString();
QDate date = locale.toDate(dateString);
- RETURN_RESULT(engine->newDateObject(QDateTime(date)));
+ RETURN_RESULT(engine->newDateObject(date.startOfDay()));
}
}
@@ -341,7 +341,7 @@ ReturnedValue QQmlDateExtension::method_fromLocaleDateString(const QV4::Function
dt = r->d()->locale->toDate(dateString, enumFormat);
}
- RETURN_RESULT(engine->newDateObject(QDateTime(dt)));
+ RETURN_RESULT(engine->newDateObject(dt.startOfDay()));
}
ReturnedValue QQmlDateExtension::method_timeZoneUpdated(const QV4::FunctionObject *b, const QV4::Value *, const QV4::Value *, int argc)
diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h
index 1d6fdb12a7..d7bff5a1b7 100644
--- a/src/qml/qml/qqmllocale_p.h
+++ b/src/qml/qml/qqmllocale_p.h
@@ -96,7 +96,7 @@ class Q_QML_PRIVATE_EXPORT QQmlLocale
Q_GADGET
QML_NAMED_ELEMENT(Locale)
QML_UNCREATABLE("Locale cannot be instantiated. Use Qt.locale().")
- QML_ADDED_IN_MINOR_VERSION(2)
+ QML_ADDED_IN_VERSION(2, 2)
public:
~QQmlLocale();
diff --git a/src/qml/qml/qqmlloggingcategory_p.h b/src/qml/qml/qqmlloggingcategory_p.h
index c7377528b4..9cee029a9b 100644
--- a/src/qml/qml/qqmlloggingcategory_p.h
+++ b/src/qml/qml/qqmlloggingcategory_p.h
@@ -66,9 +66,9 @@ class QQmlLoggingCategory : public QObject, public QQmlParserStatus
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QString name READ name WRITE setName)
- Q_PROPERTY(DefaultLogLevel defaultLogLevel READ defaultLogLevel WRITE setDefaultLogLevel REVISION 12)
+ Q_PROPERTY(DefaultLogLevel defaultLogLevel READ defaultLogLevel WRITE setDefaultLogLevel REVISION(2, 12))
QML_NAMED_ELEMENT(LoggingCategory)
- QML_ADDED_IN_MINOR_VERSION(8)
+ QML_ADDED_IN_VERSION(2, 8)
public:
enum DefaultLogLevel {
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index 76816618ac..68b95d1cc3 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -92,8 +92,12 @@ static QQmlTypePrivate *createQQmlType(QQmlMetaTypeData *data,
d->typeId = type.typeId;
d->listId = type.listId;
d->isSetup = true;
- d->version_maj = 0;
- d->version_min = 0;
+ if (type.structVersion > 0) {
+ d->module = QString::fromUtf8(type.uri);
+ d->version = type.version;
+ } else {
+ d->version = QTypeRevision::zero();
+ }
data->registerType(d);
return d;
}
@@ -105,28 +109,30 @@ static QQmlTypePrivate *createQQmlType(QQmlMetaTypeData *data, const QString &el
data->registerType(d);
d->setName(QString::fromUtf8(type.uri), elementName);
- d->version_maj = type.versionMajor;
- d->version_min = type.versionMinor;
+ d->version = type.version;
- if (type.qobjectApi || (type.version >= 3 && type.generalizedQobjectApi)) {
- if (type.version >= 1) // static metaobject added in version 1
+ if (type.qobjectApi || (type.structVersion >= 3 && type.generalizedQobjectApi)) {
+ if (type.structVersion >= 1) // static metaobject added in version 1
d->baseMetaObject = type.instanceMetaObject;
- if (type.version >= 2) // typeId added in version 2
+ if (type.structVersion >= 2) // typeId added in version 2
d->typeId = type.typeId;
- if (type.version >= 2) // revisions added in version 2
+ if (type.structVersion >= 2) // revisions added in version 2
d->revision = type.revision;
}
d->extraData.sd->singletonInstanceInfo = new QQmlType::SingletonInstanceInfo;
d->extraData.sd->singletonInstanceInfo->scriptCallback = type.scriptApi;
- if (type.version >= 3) {
+ if (type.structVersion >= 3) {
d->extraData.sd->singletonInstanceInfo->qobjectCallback = type.generalizedQobjectApi;
} else {
d->extraData.sd->singletonInstanceInfo->qobjectCallback = type.qobjectApi;
}
d->extraData.sd->singletonInstanceInfo->typeName = QString::fromUtf8(type.typeName);
d->extraData.sd->singletonInstanceInfo->instanceMetaObject
- = ((type.qobjectApi || (type.version >= 3 && type.generalizedQobjectApi) ) && type.version >= 1) ? type.instanceMetaObject : nullptr;
+ = ((type.qobjectApi || (type.structVersion >= 3 && type.generalizedQobjectApi) )
+ && type.structVersion >= 1)
+ ? type.instanceMetaObject
+ : nullptr;
return d;
}
@@ -138,9 +144,8 @@ static QQmlTypePrivate *createQQmlType(QQmlMetaTypeData *data, const QString &el
data->registerType(d);
d->setName(QString::fromUtf8(type.uri), elementName);
- d->version_maj = type.versionMajor;
- d->version_min = type.versionMinor;
- if (type.version >= 1) // revisions added in version 1
+ d->version = type.version;
+ if (type.structVersion >= 1) // revisions added in version 1
d->revision = type.revision;
d->typeId = type.typeId;
d->listId = type.listId;
@@ -176,8 +181,7 @@ static QQmlTypePrivate *createQQmlType(QQmlMetaTypeData *data, const QString &el
auto *d = new QQmlTypePrivate(QQmlType::CompositeType);
data->registerType(d);
d->setName(QString::fromUtf8(type.uri), elementName);
- d->version_maj = type.versionMajor;
- d->version_min = type.versionMinor;
+ d->version = type.version;
d->extraData.fd->url = QQmlTypeLoader::normalize(type.url);
return d;
@@ -190,8 +194,7 @@ static QQmlTypePrivate *createQQmlType(QQmlMetaTypeData *data, const QString &el
data->registerType(d);
d->setName(QString::fromUtf8(type.uri), elementName);
- d->version_maj = type.versionMajor;
- d->version_min = type.versionMinor;
+ d->version = type.version;
d->extraData.sd->singletonInstanceInfo = new QQmlType::SingletonInstanceInfo;
d->extraData.sd->singletonInstanceInfo->url = QQmlTypeLoader::normalize(type.url);
@@ -267,35 +270,43 @@ void QQmlMetaType::clone(QMetaObjectBuilder &builder, const QMetaObject *mo,
}
}
-void QQmlMetaType::qmlInsertModuleRegistration(const QString &uri, int majorVersion,
- void (*registerFunction)())
+void QQmlMetaType::qmlInsertModuleRegistration(const QString &uri, void (*registerFunction)())
{
- const QQmlMetaTypeData::VersionedUri versionedUri(uri, majorVersion);
QQmlMetaTypeDataPtr data;
- if (data->moduleTypeRegistrationFunctions.contains(versionedUri))
- qFatal("Cannot add multiple registrations for %s %d", qPrintable(uri), majorVersion);
+ if (data->moduleTypeRegistrationFunctions.contains(uri))
+ qFatal("Cannot add multiple registrations for %s", qPrintable(uri));
else
- data->moduleTypeRegistrationFunctions.insert(versionedUri, registerFunction);
+ data->moduleTypeRegistrationFunctions.insert(uri, registerFunction);
}
-void QQmlMetaType::qmlRemoveModuleRegistration(const QString &uri, int majorVersion)
+void QQmlMetaType::qmlRemoveModuleRegistration(const QString &uri)
{
- const QQmlMetaTypeData::VersionedUri versionedUri(uri, majorVersion);
QQmlMetaTypeDataPtr data;
if (!data.isValid())
return; // shutdown/deletion race. Not a problem.
- if (!data->moduleTypeRegistrationFunctions.contains(versionedUri))
- qFatal("Cannot remove multiple registrations for %s %d", qPrintable(uri), majorVersion);
+ if (!data->moduleTypeRegistrationFunctions.contains(uri))
+ qFatal("Cannot remove multiple registrations for %s", qPrintable(uri));
else
- data->moduleTypeRegistrationFunctions.remove(versionedUri);
+ data->moduleTypeRegistrationFunctions.remove(uri);
+}
+
+bool QQmlMetaType::qmlRegisterModuleTypes(const QString &uri)
+{
+ QQmlMetaTypeDataPtr data;
+ return data->registerModuleTypes(uri);
}
-bool QQmlMetaType::qmlRegisterModuleTypes(const QString &uri, int majorVersion)
+/*!
+ \internal
+ Method is only used to in tst_qqmlenginecleanup.cpp to test whether all
+ types have been removed from qmlLists after shutdown of QQmlEngine
+ */
+int QQmlMetaType::qmlRegisteredListTypeCount()
{
QQmlMetaTypeDataPtr data;
- return data->registerModuleTypes(QQmlMetaTypeData::VersionedUri(uri, majorVersion));
+ return data->qmlLists.count();
}
void QQmlMetaType::clearTypeRegistrations()
@@ -334,24 +345,19 @@ void QQmlMetaType::unregisterAutoParentFunction(const QQmlPrivate::AutoParentFun
QQmlType QQmlMetaType::registerInterface(const QQmlPrivate::RegisterInterface &type)
{
- if (type.version > 0)
+ if (type.structVersion > 1)
qFatal("qmlRegisterType(): Cannot mix incompatible QML versions.");
QQmlMetaTypeDataPtr data;
QQmlTypePrivate *priv = createQQmlType(data, type);
Q_ASSERT(priv);
- data->idToType.insert(priv->typeId, priv);
- data->idToType.insert(priv->listId, priv);
- if (!priv->elementName.isEmpty())
- data->nameToType.insert(priv->elementName, priv);
- if (data->interfaces.size() <= type.typeId)
- data->interfaces.resize(type.typeId + 16);
- if (data->lists.size() <= type.listId)
- data->lists.resize(type.listId + 16);
- data->interfaces.setBit(type.typeId, true);
- data->lists.setBit(type.listId, true);
+ data->idToType.insert(priv->typeId.id(), priv);
+ data->idToType.insert(priv->listId.id(), priv);
+
+ data->interfaces.insert(type.typeId.id());
+ data->lists.insert(type.listId.id());
return QQmlType(priv);
}
@@ -372,7 +378,7 @@ QString registrationTypeString(QQmlType::RegistrationType typeType)
// NOTE: caller must hold a QMutexLocker on "data"
bool checkRegistration(QQmlType::RegistrationType typeType, QQmlMetaTypeData *data,
- const char *uri, const QString &typeName, int majorVersion)
+ const char *uri, const QString &typeName, QTypeRevision version)
{
if (!typeName.isEmpty()) {
if (typeName.at(0).isLower()) {
@@ -393,14 +399,14 @@ bool checkRegistration(QQmlType::RegistrationType typeType, QQmlMetaTypeData *da
if (uri && !typeName.isEmpty()) {
QString nameSpace = QString::fromUtf8(uri);
- QQmlMetaTypeData::VersionedUri versionedUri;
- versionedUri.uri = nameSpace;
- versionedUri.majorVersion = majorVersion;
+ QQmlMetaTypeData::VersionedUri versionedUri(nameSpace, version);
if (QQmlTypeModule* qqtm = data->uriToModule.value(versionedUri, 0)){
if (qqtm->isLocked()){
QString failure(QCoreApplication::translate("qmlRegisterType",
"Cannot install %1 '%2' into protected module '%3' version '%4'"));
- data->recordTypeRegFailure(failure.arg(registrationTypeString(typeType)).arg(typeName).arg(nameSpace).arg(majorVersion));
+ data->recordTypeRegFailure(failure.arg(registrationTypeString(typeType))
+ .arg(typeName).arg(nameSpace)
+ .arg(version.majorVersion()));
return false;
}
}
@@ -410,9 +416,9 @@ bool checkRegistration(QQmlType::RegistrationType typeType, QQmlMetaTypeData *da
}
// NOTE: caller must hold a QMutexLocker on "data"
-QQmlTypeModule *getTypeModule(const QHashedString &uri, int majorVersion, QQmlMetaTypeData *data)
+QQmlTypeModule *getTypeModule(const QHashedString &uri, QTypeRevision version, QQmlMetaTypeData *data)
{
- QQmlMetaTypeData::VersionedUri versionedUri(uri, majorVersion);
+ QQmlMetaTypeData::VersionedUri versionedUri(uri, version);
QQmlTypeModule *module = data->uriToModule.value(versionedUri);
if (!module) {
module = new QQmlTypeModule(versionedUri.uri, versionedUri.majorVersion);
@@ -432,24 +438,20 @@ void addTypeToData(QQmlTypePrivate *type, QQmlMetaTypeData *data)
if (type->baseMetaObject)
data->metaObjectToType.insert(type->baseMetaObject, type);
- if (type->typeId) {
- data->idToType.insert(type->typeId, type);
- if (data->objects.size() <= type->typeId)
- data->objects.resize(type->typeId + 16);
- data->objects.setBit(type->typeId, true);
+ if (type->typeId.isValid()) {
+ data->idToType.insert(type->typeId.id(), type);
+ data->objects.insert(type->typeId.id());
}
- if (type->listId) {
- if (data->lists.size() <= type->listId)
- data->lists.resize(type->listId + 16);
- data->lists.setBit(type->listId, true);
- data->idToType.insert(type->listId, type);
+ if (type->listId.isValid()) {
+ data->idToType.insert(type->listId.id(), type);
+ data->lists.insert(type->listId.id());
}
if (!type->module.isEmpty()) {
const QHashedString &mod = type->module;
- QQmlTypeModule *module = getTypeModule(mod, type->version_maj, data);
+ QQmlTypeModule *module = getTypeModule(mod, type->version, data);
Q_ASSERT(module);
module->add(type);
}
@@ -460,14 +462,14 @@ QQmlType QQmlMetaType::registerType(const QQmlPrivate::RegisterType &type)
QQmlMetaTypeDataPtr data;
QString elementName = QString::fromUtf8(type.elementName);
- if (!checkRegistration(QQmlType::CppType, data, type.uri, elementName, type.versionMajor))
+ if (!checkRegistration(QQmlType::CppType, data, type.uri, elementName, type.version))
return QQmlType();
QQmlTypePrivate *priv = createQQmlType(data, elementName, type);
addTypeToData(priv, data);
- if (!type.typeId)
- data->idToType.insert(priv->typeId, priv);
+ if (!type.typeId.isValid())
+ data->idToType.insert(priv->typeId.id(), priv);
return QQmlType(priv);
}
@@ -477,7 +479,7 @@ QQmlType QQmlMetaType::registerSingletonType(const QQmlPrivate::RegisterSingleto
QQmlMetaTypeDataPtr data;
QString typeName = QString::fromUtf8(type.typeName);
- if (!checkRegistration(QQmlType::SingletonType, data, type.uri, typeName, type.versionMajor))
+ if (!checkRegistration(QQmlType::SingletonType, data, type.uri, typeName, type.version))
return QQmlType();
QQmlTypePrivate *priv = createQQmlType(data, typeName, type);
@@ -497,7 +499,7 @@ QQmlType QQmlMetaType::registerCompositeSingletonType(const QQmlPrivate::Registe
if (*(type.uri) == '\0')
fileImport = true;
if (!checkRegistration(QQmlType::CompositeSingletonType, data, fileImport ? nullptr : type.uri,
- typeName, type.versionMajor)) {
+ typeName, type.version)) {
return QQmlType();
}
@@ -519,7 +521,7 @@ QQmlType QQmlMetaType::registerCompositeType(const QQmlPrivate::RegisterComposit
bool fileImport = false;
if (*(type.uri) == '\0')
fileImport = true;
- if (!checkRegistration(QQmlType::CompositeType, data, fileImport?nullptr:type.uri, typeName, type.versionMajor))
+ if (!checkRegistration(QQmlType::CompositeType, data, fileImport?nullptr:type.uri, typeName, type.version))
return QQmlType();
QQmlTypePrivate *priv = createQQmlType(data, typeName, type);
@@ -531,26 +533,50 @@ QQmlType QQmlMetaType::registerCompositeType(const QQmlPrivate::RegisterComposit
return QQmlType(priv);
}
+
+
+template <typename T>
+struct QQmlMetaTypeInterface : QtPrivate::QMetaTypeInterface
+{
+ const QByteArray name;
+ QQmlMetaTypeInterface(const QByteArray &name)
+ : QMetaTypeInterface {
+ /*.revision=*/ 0,
+ /*.size=*/ sizeof(T),
+ /*.alignment=*/ alignof(T),
+ /*.flags=*/ QtPrivate::QMetaTypeTypeFlags<T>::Flags,
+ /*.metaObject=*/ nullptr,
+ /*.name=*/ name.constData(),
+ /*.typeId=*/ 0,
+ /*.ref=*/ Q_REFCOUNT_INITIALIZE_STATIC,
+ /*.deleteSelf=*/ [](QMetaTypeInterface *self) {
+ delete static_cast<QQmlMetaTypeInterface *>(self);
+ },
+ /*.defaultCtr=*/ [](const QMetaTypeInterface *, void *addr) { new (addr) T(); },
+ /*.copyCtr=*/ [](const QMetaTypeInterface *, void *addr, const void *other) {
+ new (addr) T(*reinterpret_cast<const T *>(other));
+ },
+ /*.moveCtr=*/ [](const QMetaTypeInterface *, void *addr, void *other) {
+ new (addr) T(std::move(*reinterpret_cast<T *>(other)));
+ },
+ /*.dtor=*/ [](const QMetaTypeInterface *, void *addr) {
+ reinterpret_cast<T *>(addr)->~T();
+ },
+ /*.legacyRegisterOp=*/ nullptr
+ }
+ , name(name) { }
+};
+
CompositeMetaTypeIds QQmlMetaType::registerInternalCompositeType(const QByteArray &className)
{
QByteArray ptr = className + '*';
QByteArray lst = "QQmlListProperty<" + className + '>';
- int ptr_type = QMetaType::registerNormalizedType(ptr,
- QtMetaTypePrivate::QMetaTypeFunctionHelper<QObject*>::Destruct,
- QtMetaTypePrivate::QMetaTypeFunctionHelper<QObject*>::Construct,
- sizeof(QObject*),
- static_cast<QFlags<QMetaType::TypeFlag> >(QtPrivate::QMetaTypeTypeFlags<QObject*>::Flags),
- nullptr);
- int lst_type = QMetaType::registerNormalizedType(lst,
- QtMetaTypePrivate::QMetaTypeFunctionHelper<QQmlListProperty<QObject> >::Destruct,
- QtMetaTypePrivate::QMetaTypeFunctionHelper<QQmlListProperty<QObject> >::Construct,
- sizeof(QQmlListProperty<QObject>),
- static_cast<QFlags<QMetaType::TypeFlag> >(QtPrivate::QMetaTypeTypeFlags<QQmlListProperty<QObject> >::Flags),
- static_cast<QMetaObject*>(nullptr));
+ QMetaType ptr_type(new QQmlMetaTypeInterface<QObject*>(ptr));
+ QMetaType lst_type(new QQmlMetaTypeInterface<QQmlListProperty<QObject>>(lst));
QQmlMetaTypeDataPtr data;
- data->qmlLists.insert(lst_type, ptr_type);
+ data->qmlLists.insert(lst_type.id(), ptr_type.id());
return {ptr_type, lst_type};
}
@@ -558,16 +584,13 @@ CompositeMetaTypeIds QQmlMetaType::registerInternalCompositeType(const QByteArra
void QQmlMetaType::unregisterInternalCompositeType(const CompositeMetaTypeIds &typeIds)
{
QQmlMetaTypeDataPtr data;
- data->qmlLists.remove(typeIds.listId);
-
- QMetaType::unregisterType(typeIds.id);
- QMetaType::unregisterType(typeIds.listId);
+ data->qmlLists.remove(typeIds.listId.id());
}
int QQmlMetaType::registerUnitCacheHook(
const QQmlPrivate::RegisterQmlUnitCacheHook &hookRegistration)
{
- if (hookRegistration.version > 0)
+ if (hookRegistration.structVersion > 0)
qFatal("qmlRegisterType(): Cannot mix incompatible QML versions.");
QQmlMetaTypeDataPtr data;
@@ -575,40 +598,37 @@ int QQmlMetaType::registerUnitCacheHook(
return 0;
}
-bool QQmlMetaType::protectModule(const QString &uri, int majVersion)
+bool QQmlMetaType::protectModule(const QString &uri, QTypeRevision version)
{
QQmlMetaTypeDataPtr data;
- QQmlMetaTypeData::VersionedUri versionedUri;
- versionedUri.uri = uri;
- versionedUri.majorVersion = majVersion;
-
- if (QQmlTypeModule* qqtm = data->uriToModule.value(versionedUri, 0)) {
+ if (QQmlTypeModule* qqtm = data->uriToModule.value(
+ QQmlMetaTypeData::VersionedUri(uri, version), nullptr)) {
qqtm->lock();
return true;
}
return false;
}
-void QQmlMetaType::registerModule(const char *uri, int versionMajor, int versionMinor)
+void QQmlMetaType::registerModule(const char *uri, QTypeRevision version)
{
QQmlMetaTypeDataPtr data;
- QQmlTypeModule *module = getTypeModule(QString::fromUtf8(uri), versionMajor, data);
+ QQmlTypeModule *module = getTypeModule(QString::fromUtf8(uri), version, data);
Q_ASSERT(module);
- module->addMinorVersion(versionMinor);
+ module->addMinorVersion(version.minorVersion());
}
-int QQmlMetaType::typeId(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
+int QQmlMetaType::typeId(const char *uri, QTypeRevision version, const char *qmlName)
{
QQmlMetaTypeDataPtr data;
- QQmlTypeModule *module = getTypeModule(QString::fromUtf8(uri), versionMajor, data);
+ QQmlTypeModule *module = getTypeModule(QString::fromUtf8(uri), version, data);
if (!module)
return -1;
- QQmlType type = module->type(QHashedStringRef(QString::fromUtf8(qmlName)), versionMinor);
+ QQmlType type = module->type(QHashedStringRef(QString::fromUtf8(qmlName)), version);
if (!type.isValid())
return -1;
@@ -622,12 +642,12 @@ void QQmlMetaType::registerUndeletableType(const QQmlType &dtype)
}
static bool namespaceContainsRegistrations(const QQmlMetaTypeData *data, const QString &uri,
- int majorVersion)
+ QTypeRevision version)
{
// Has any type previously been installed to this namespace?
QHashedString nameSpace(uri);
for (const QQmlType &type : data->types) {
- if (type.module() == nameSpace && type.majorVersion() == majorVersion)
+ if (type.module() == nameSpace && type.version().majorVersion() == version.majorVersion())
return true;
}
@@ -654,8 +674,8 @@ public:
bool QQmlMetaType::registerPluginTypes(QObject *instance, const QString &basePath,
- const QString &uri, const QString &typeNamespace, int vmaj,
- QList<QQmlError> *errors)
+ const QString &uri, const QString &typeNamespace,
+ QTypeRevision version, QList<QQmlError> *errors)
{
if (!typeNamespace.isEmpty() && typeNamespace != uri) {
// This is an 'identified' module
@@ -676,7 +696,7 @@ bool QQmlMetaType::registerPluginTypes(QObject *instance, const QString &basePat
QQmlMetaTypeRegistrationFailureRecorder failureRecorder(data, &failures);
if (!typeNamespace.isEmpty()) {
// This is an 'identified' module
- if (namespaceContainsRegistrations(data, typeNamespace, vmaj)) {
+ if (namespaceContainsRegistrations(data, typeNamespace, version)) {
// Other modules have already installed to this namespace
if (errors) {
QQmlError error;
@@ -718,7 +738,7 @@ bool QQmlMetaType::registerPluginTypes(QObject *instance, const QString &basePat
iface->registerTypes(moduleId);
}
- data->registerModuleTypes(QQmlMetaTypeData::VersionedUri(uri, vmaj));
+ data->registerModuleTypes(uri);
if (!failures.isEmpty()) {
if (errors) {
@@ -749,7 +769,7 @@ bool QQmlMetaType::registerPluginTypes(QObject *instance, const QString &basePat
QQmlType QQmlMetaType::typeForUrl(const QString &urlString,
const QHashedStringRef &qualifiedType,
bool isCompositeSingleton, QList<QQmlError> *errors,
- int majorVersion, int minorVersion)
+ QTypeRevision version)
{
// ### unfortunate (costly) conversion
const QUrl url = QQmlTypeLoader::normalize(QUrl(urlString));
@@ -794,11 +814,10 @@ QQmlType QQmlMetaType::typeForUrl(const QString &urlString,
const QQmlType::RegistrationType registrationType = isCompositeSingleton
? QQmlType::CompositeSingletonType
: QQmlType::CompositeType;
- if (checkRegistration(registrationType, data, nullptr, typeName, majorVersion)) {
+ if (checkRegistration(registrationType, data, nullptr, typeName, version)) {
auto *priv = new QQmlTypePrivate(registrationType);
priv->setName(QString(), typeName);
- priv->version_maj = majorVersion;
- priv->version_min = minorVersion;
+ priv->version = version;
if (isCompositeSingleton) {
priv->extraData.sd->singletonInstanceInfo = new QQmlType::SingletonInstanceInfo;
@@ -851,14 +870,12 @@ bool QQmlMetaType::isAnyModule(const QString &uri)
/*
Returns true if a module \a uri of this version is installed and locked;
*/
-bool QQmlMetaType::isLockedModule(const QString &uri, int majVersion)
+bool QQmlMetaType::isLockedModule(const QString &uri, QTypeRevision version)
{
QQmlMetaTypeDataPtr data;
- QQmlMetaTypeData::VersionedUri versionedUri;
- versionedUri.uri = uri;
- versionedUri.majorVersion = majVersion;
- if (QQmlTypeModule* qqtm = data->uriToModule.value(versionedUri, 0))
+ if (QQmlTypeModule* qqtm = data->uriToModule.value(
+ QQmlMetaTypeData::VersionedUri(uri, version), nullptr))
return qqtm->isLocked();
return false;
}
@@ -870,24 +887,24 @@ bool QQmlMetaType::isLockedModule(const QString &uri, int majVersion)
So if only 4.7 and 4.9 have been registered, 4.7,4.8, and 4.9 are valid, but not 4.6 nor 4.10.
*/
-bool QQmlMetaType::isModule(const QString &module, int versionMajor, int versionMinor)
+bool QQmlMetaType::isModule(const QString &module, QTypeRevision version)
{
- Q_ASSERT(versionMajor >= 0 && versionMinor >= 0);
+ Q_ASSERT(version.hasMajorVersion() && version.hasMinorVersion());
QQmlMetaTypeDataPtr data;
// first, check Types
QQmlTypeModule *tm =
- data->uriToModule.value(QQmlMetaTypeData::VersionedUri(module, versionMajor));
- if (tm && tm->minimumMinorVersion() <= versionMinor && tm->maximumMinorVersion() >= versionMinor)
+ data->uriToModule.value(QQmlMetaTypeData::VersionedUri(module, version));
+ if (tm && tm->minimumMinorVersion() <= version.minorVersion() && tm->maximumMinorVersion() >= version.minorVersion())
return true;
return false;
}
-QQmlTypeModule *QQmlMetaType::typeModule(const QString &uri, int majorVersion)
+QQmlTypeModule *QQmlMetaType::typeModule(const QString &uri, QTypeRevision version)
{
QQmlMetaTypeDataPtr data;
- return data->uriToModule.value(QQmlMetaTypeData::VersionedUri(uri, majorVersion));
+ return data->uriToModule.value(QQmlMetaTypeData::VersionedUri(uri, version));
}
QList<QQmlPrivate::AutoParentFunction> QQmlMetaType::parentFunctions()
@@ -912,9 +929,8 @@ bool QQmlMetaType::isQObject(int userType)
{
if (userType == QMetaType::QObjectStar)
return true;
-
QQmlMetaTypeDataPtr data;
- return userType >= 0 && userType < data->objects.size() && data->objects.testBit(userType);
+ return data->objects.contains(userType);
}
/*
@@ -927,8 +943,8 @@ int QQmlMetaType::listType(int id)
if (iter != data->qmlLists.cend())
return *iter;
QQmlTypePrivate *type = data->idToType.value(id);
- if (type && type->listId == id)
- return type->typeId;
+ if (type && type->listId.id() == id)
+ return type->typeId.id();
else
return 0;
}
@@ -1028,9 +1044,9 @@ QQmlMetaType::TypeCategory QQmlMetaType::typeCategory(int userType)
QQmlMetaTypeDataPtr data;
if (data->qmlLists.contains(userType))
return List;
- else if (userType < data->objects.size() && data->objects.testBit(userType))
+ else if (data->objects.contains(userType))
return Object;
- else if (userType < data->lists.size() && data->lists.testBit(userType))
+ else if (data->lists.contains(userType))
return List;
else
return Unknown;
@@ -1042,7 +1058,7 @@ QQmlMetaType::TypeCategory QQmlMetaType::typeCategory(int userType)
bool QQmlMetaType::isInterface(int userType)
{
const QQmlMetaTypeDataPtr data;
- return userType >= 0 && userType < data->interfaces.size() && data->interfaces.testBit(userType);
+ return data->interfaces.contains(userType);
}
const char *QQmlMetaType::interfaceIId(int userType)
@@ -1055,7 +1071,7 @@ const char *QQmlMetaType::interfaceIId(int userType)
}
QQmlType type(typePrivate);
- if (type.isInterface() && type.typeId() == userType)
+ if (type.isInterface() && type.typeId().id() == userType)
return type.interfaceIId();
else
return nullptr;
@@ -1063,10 +1079,10 @@ const char *QQmlMetaType::interfaceIId(int userType)
bool QQmlMetaType::isList(int userType)
{
- const QQmlMetaTypeDataPtr data;
+ QQmlMetaTypeDataPtr data;
if (data->qmlLists.contains(userType))
return true;
- return userType >= 0 && userType < data->lists.size() && data->lists.testBit(userType);
+ return data->lists.contains(userType);
}
/*!
@@ -1106,7 +1122,7 @@ QQmlMetaType::StringConverter QQmlMetaType::customStringConverter(int type)
Returns the type (if any) of URI-qualified named \a qualifiedName and version specified
by \a version_major and \a version_minor.
*/
-QQmlType QQmlMetaType::qmlType(const QString &qualifiedName, int version_major, int version_minor)
+QQmlType QQmlMetaType::qmlType(const QString &qualifiedName, QTypeRevision version)
{
int slash = qualifiedName.indexOf(QLatin1Char('/'));
if (slash <= 0)
@@ -1115,23 +1131,23 @@ QQmlType QQmlMetaType::qmlType(const QString &qualifiedName, int version_major,
QHashedStringRef module(qualifiedName.constData(), slash);
QHashedStringRef name(qualifiedName.constData() + slash + 1, qualifiedName.length() - slash - 1);
- return qmlType(name, module, version_major, version_minor);
+ return qmlType(name, module, version);
}
/*!
Returns the type (if any) of \a name in \a module and version specified
by \a version_major and \a version_minor.
*/
-QQmlType QQmlMetaType::qmlType(const QHashedStringRef &name, const QHashedStringRef &module, int version_major, int version_minor)
+QQmlType QQmlMetaType::qmlType(const QHashedStringRef &name, const QHashedStringRef &module,
+ QTypeRevision version)
{
- Q_ASSERT(version_major >= 0 && version_minor >= 0);
+ Q_ASSERT(version.hasMajorVersion() && version.hasMinorVersion());
const QQmlMetaTypeDataPtr data;
QQmlMetaTypeData::Names::ConstIterator it = data->nameToType.constFind(name);
while (it != data->nameToType.cend() && it.key() == name) {
QQmlType t(*it);
- // XXX version_major<0 just a kludge for QQmlPropertyPrivate::initProperty
- if (version_major < 0 || module.isEmpty() || t.availableInVersion(module, version_major,version_minor))
+ if (module.isEmpty() || t.availableInVersion(module, version))
return t;
++it;
}
@@ -1154,15 +1170,16 @@ QQmlType QQmlMetaType::qmlType(const QMetaObject *metaObject)
by \a version_major and \a version_minor in module specified by \a uri. Returns null if no
type is registered.
*/
-QQmlType QQmlMetaType::qmlType(const QMetaObject *metaObject, const QHashedStringRef &module, int version_major, int version_minor)
+QQmlType QQmlMetaType::qmlType(const QMetaObject *metaObject, const QHashedStringRef &module,
+ QTypeRevision version)
{
- Q_ASSERT(version_major >= 0 && version_minor >= 0);
+ Q_ASSERT(version.hasMajorVersion() && version.hasMinorVersion());
const QQmlMetaTypeDataPtr data;
QQmlMetaTypeData::MetaObjects::const_iterator it = data->metaObjectToType.constFind(metaObject);
while (it != data->metaObjectToType.cend() && it.key() == metaObject) {
QQmlType t(*it);
- if (version_major < 0 || module.isEmpty() || t.availableInVersion(module, version_major,version_minor))
+ if (module.isEmpty() || t.availableInVersion(module, version))
return t;
++it;
}
@@ -1181,7 +1198,7 @@ QQmlType QQmlMetaType::qmlType(int typeId, TypeIdCategory category)
if (category == TypeIdCategory::MetaType) {
QQmlTypePrivate *type = data->idToType.value(typeId);
- if (type && type->typeId == typeId)
+ if (type && type->typeId.id() == typeId)
return QQmlType(type);
} else if (category == TypeIdCategory::QmlType) {
QQmlType type = data->types.value(typeId);
@@ -1212,16 +1229,16 @@ QQmlType QQmlMetaType::qmlType(const QUrl &unNormalizedUrl, bool includeNonFileI
return QQmlType();
}
-QQmlPropertyCache *QQmlMetaType::propertyCache(const QMetaObject *metaObject, int minorVersion)
+QQmlPropertyCache *QQmlMetaType::propertyCache(const QMetaObject *metaObject, QTypeRevision version)
{
QQmlMetaTypeDataPtr data; // not const: the cache is created on demand
- return data->propertyCache(metaObject, minorVersion);
+ return data->propertyCache(metaObject, version);
}
-QQmlPropertyCache *QQmlMetaType::propertyCache(const QQmlType &type, int minorVersion)
+QQmlPropertyCache *QQmlMetaType::propertyCache(const QQmlType &type, QTypeRevision version)
{
QQmlMetaTypeDataPtr data; // not const: the cache is created on demand
- return data->propertyCache(type, minorVersion);
+ return data->propertyCache(type, version);
}
void QQmlMetaType::unregisterType(int typeIndex)
@@ -1236,7 +1253,7 @@ void QQmlMetaType::unregisterType(int typeIndex)
removeQQmlTypePrivate(data->metaObjectToType, d);
for (auto & module : data->uriToModule)
module->remove(d);
- data->clearPropertyCachesForMinorVersion(typeIndex);
+ data->clearPropertyCachesForVersion(typeIndex);
data->types[typeIndex] = QQmlType();
data->undeletableTypes.remove(type);
}
@@ -1268,7 +1285,7 @@ void QQmlMetaType::freeUnusedTypesAndCaches()
for (auto &module : data->uriToModule)
module->remove(d);
- data->clearPropertyCachesForMinorVersion(d->index);
+ data->clearPropertyCachesForVersion(d->index);
*it = QQmlType();
} else {
++it;
diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h
index 037cf89beb..28d647520d 100644
--- a/src/qml/qml/qqmlmetatype_p.h
+++ b/src/qml/qml/qqmlmetatype_p.h
@@ -65,11 +65,9 @@ namespace QV4 { class ExecutableCompilationUnit; }
struct CompositeMetaTypeIds
{
- int id = -1;
- int listId = -1;
- CompositeMetaTypeIds() = default;
- CompositeMetaTypeIds(int id, int listId) : id(id), listId(listId) {}
- bool isValid() const { return id != -1 && listId != -1; }
+ QMetaType id;
+ QMetaType listId;
+ bool isValid() const { return id.isValid() && listId.isValid(); }
};
class Q_QML_PRIVATE_EXPORT QQmlMetaType
@@ -81,20 +79,20 @@ public:
static QQmlType registerCompositeSingletonType(const QQmlPrivate::RegisterCompositeSingletonType &type);
static QQmlType registerCompositeType(const QQmlPrivate::RegisterCompositeType &type);
static bool registerPluginTypes(QObject *instance, const QString &basePath,
- const QString &uri, const QString &typeNamespace, int vmaj,
- QList<QQmlError> *errors);
+ const QString &uri, const QString &typeNamespace,
+ QTypeRevision version, QList<QQmlError> *errors);
static QQmlType typeForUrl(const QString &urlString, const QHashedStringRef& typeName,
bool isCompositeSingleton, QList<QQmlError> *errors,
- int majorVersion = -1, int minorVersion = -1);
+ QTypeRevision version = QTypeRevision());
static void unregisterType(int type);
static CompositeMetaTypeIds registerInternalCompositeType(const QByteArray &className);
static void unregisterInternalCompositeType(const CompositeMetaTypeIds &typeIds);
- static void registerModule(const char *uri, int versionMajor, int versionMinor);
- static bool protectModule(const QString &uri, int majVersion);
+ static void registerModule(const char *uri, QTypeRevision version);
+ static bool protectModule(const QString &uri, QTypeRevision version);
- static int typeId(const char *uri, int versionMajor, int versionMinor, const char *qmlName);
+ static int typeId(const char *uri, QTypeRevision version, const char *qmlName);
static void registerUndeletableType(const QQmlType &dtype);
@@ -108,15 +106,16 @@ public:
QmlType
};
- static QQmlType qmlType(const QString &qualifiedName, int, int);
- static QQmlType qmlType(const QHashedStringRef &name, const QHashedStringRef &module, int, int);
+ static QQmlType qmlType(const QString &qualifiedName, QTypeRevision version);
+ static QQmlType qmlType(const QHashedStringRef &name, const QHashedStringRef &module, QTypeRevision version);
static QQmlType qmlType(const QMetaObject *);
- static QQmlType qmlType(const QMetaObject *metaObject, const QHashedStringRef &module, int version_major, int version_minor);
+ static QQmlType qmlType(const QMetaObject *metaObject, const QHashedStringRef &module, QTypeRevision version);
static QQmlType qmlType(int typeId, TypeIdCategory category = TypeIdCategory::MetaType);
static QQmlType qmlType(const QUrl &unNormalizedUrl, bool includeNonFileImports = false);
- static QQmlPropertyCache *propertyCache(const QMetaObject *metaObject, int minorVersion = -1);
- static QQmlPropertyCache *propertyCache(const QQmlType &type, int minorVersion);
+ static QQmlPropertyCache *propertyCache(const QMetaObject *metaObject,
+ QTypeRevision version = QTypeRevision());
+ static QQmlPropertyCache *propertyCache(const QQmlType &type, QTypeRevision version);
static void freeUnusedTypesAndCaches();
@@ -150,9 +149,9 @@ public:
static StringConverter customStringConverter(int);
static bool isAnyModule(const QString &uri);
- static bool isLockedModule(const QString &uri, int majorVersion);
- static bool isModule(const QString &module, int versionMajor, int versionMinor);
- static QQmlTypeModule *typeModule(const QString &uri, int majorVersion);
+ static bool isLockedModule(const QString &uri, QTypeRevision version);
+ static bool isModule(const QString &module, QTypeRevision version);
+ static QQmlTypeModule *typeModule(const QString &uri, QTypeRevision version);
static QList<QQmlPrivate::AutoParentFunction> parentFunctions();
@@ -197,11 +196,12 @@ public:
static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo,
const QMetaObject *ignoreStart, const QMetaObject *ignoreEnd);
- static void qmlInsertModuleRegistration(const QString &uri, int majorVersion,
- void (*registerFunction)());
- static void qmlRemoveModuleRegistration(const QString &uri, int majorVersion);
+ static void qmlInsertModuleRegistration(const QString &uri, void (*registerFunction)());
+ static void qmlRemoveModuleRegistration(const QString &uri);
- static bool qmlRegisterModuleTypes(const QString &uri, int majorVersion);
+ static bool qmlRegisterModuleTypes(const QString &uri);
+
+ static int qmlRegisteredListTypeCount();
};
Q_DECLARE_TYPEINFO(QQmlMetaType, Q_MOVABLE_TYPE);
diff --git a/src/qml/qml/qqmlmetatypedata.cpp b/src/qml/qml/qqmlmetatypedata.cpp
index ed885eaa97..a34a0c1ae4 100644
--- a/src/qml/qml/qqmlmetatypedata.cpp
+++ b/src/qml/qml/qqmlmetatypedata.cpp
@@ -78,9 +78,9 @@ void QQmlMetaTypeData::registerType(QQmlTypePrivate *priv)
priv->release();
}
-bool QQmlMetaTypeData::registerModuleTypes(const QQmlMetaTypeData::VersionedUri &versionedUri)
+bool QQmlMetaTypeData::registerModuleTypes(const QString &uri)
{
- auto function = moduleTypeRegistrationFunctions.constFind(versionedUri);
+ auto function = moduleTypeRegistrationFunctions.constFind(uri);
if (function != moduleTypeRegistrationFunctions.constEnd()) {
(*function)();
return true;
@@ -88,28 +88,28 @@ bool QQmlMetaTypeData::registerModuleTypes(const QQmlMetaTypeData::VersionedUri
return false;
}
-QQmlPropertyCache *QQmlMetaTypeData::propertyCacheForMinorVersion(int index, int minorVersion) const
+QQmlPropertyCache *QQmlMetaTypeData::propertyCacheForVersion(int index, QTypeRevision version) const
{
return (index < typePropertyCaches.length())
- ? typePropertyCaches.at(index).value(minorVersion).data()
+ ? typePropertyCaches.at(index).value(version).data()
: nullptr;
}
-void QQmlMetaTypeData::setPropertyCacheForMinorVersion(int index, int minorVersion,
- QQmlPropertyCache *cache)
+void QQmlMetaTypeData::setPropertyCacheForVersion(int index, QTypeRevision version,
+ QQmlPropertyCache *cache)
{
if (index >= typePropertyCaches.length())
typePropertyCaches.resize(index + 1);
- typePropertyCaches[index][minorVersion] = cache;
+ typePropertyCaches[index][version] = cache;
}
-void QQmlMetaTypeData::clearPropertyCachesForMinorVersion(int index)
+void QQmlMetaTypeData::clearPropertyCachesForVersion(int index)
{
if (index < typePropertyCaches.length())
typePropertyCaches[index].clear();
}
-QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QMetaObject *metaObject, int minorVersion)
+QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QMetaObject *metaObject, QTypeRevision version)
{
if (QQmlPropertyCache *rv = propertyCaches.value(metaObject))
return rv;
@@ -119,29 +119,36 @@ QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QMetaObject *metaObject
propertyCaches.insert(metaObject, rv);
return rv;
}
- QQmlPropertyCache *super = propertyCache(metaObject->superClass(), minorVersion);
- QQmlPropertyCache *rv = super->copyAndAppend(metaObject, minorVersion);
+ QQmlPropertyCache *super = propertyCache(metaObject->superClass(), version);
+ QQmlPropertyCache *rv = super->copyAndAppend(metaObject, version);
propertyCaches.insert(metaObject, rv);
return rv;
}
-QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QQmlType &type, int minorVersion)
+QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QQmlType &type, QTypeRevision version)
{
Q_ASSERT(type.isValid());
- if (QQmlPropertyCache *pc = propertyCacheForMinorVersion(type.index(), minorVersion))
+ if (QQmlPropertyCache *pc = propertyCacheForVersion(type.index(), version))
return pc;
QVector<QQmlType> types;
- int maxMinorVersion = 0;
+ quint8 maxMinorVersion = 0;
const QMetaObject *metaObject = type.metaObject();
+ const QTypeRevision combinedVersion = version.hasMajorVersion()
+ ? version
+ : (version.hasMinorVersion()
+ ? QTypeRevision::fromVersion(type.version().majorVersion(),
+ version.minorVersion())
+ : type.version());
+
while (metaObject) {
- QQmlType t = QQmlMetaType::qmlType(metaObject, type.module(), type.majorVersion(), minorVersion);
+ QQmlType t = QQmlMetaType::qmlType(metaObject, type.module(), combinedVersion);
if (t.isValid()) {
- maxMinorVersion = qMax(maxMinorVersion, t.minorVersion());
+ maxMinorVersion = qMax(maxMinorVersion, t.version().minorVersion());
types << t;
} else {
types << QQmlType();
@@ -150,12 +157,14 @@ QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QQmlType &type, int min
metaObject = metaObject->superClass();
}
- if (QQmlPropertyCache *pc = propertyCacheForMinorVersion(type.index(), maxMinorVersion)) {
- setPropertyCacheForMinorVersion(type.index(), minorVersion, pc);
+ const QTypeRevision maxVersion = QTypeRevision::fromVersion(combinedVersion.majorVersion(),
+ maxMinorVersion);
+ if (QQmlPropertyCache *pc = propertyCacheForVersion(type.index(), maxVersion)) {
+ setPropertyCacheForVersion(type.index(), maxVersion, pc);
return pc;
}
- QQmlPropertyCache *raw = propertyCache(type.metaObject(), minorVersion);
+ QQmlPropertyCache *raw = propertyCache(type.metaObject(), combinedVersion);
bool hasCopied = false;
@@ -164,7 +173,7 @@ QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QQmlType &type, int min
if (!currentType.isValid())
continue;
- int rev = currentType.metaObjectRevision();
+ QTypeRevision rev = currentType.metaObjectRevision();
int moIndex = types.count() - 1 - ii;
if (raw->allowedRevision(moIndex) != rev) {
@@ -222,13 +231,13 @@ QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QQmlType &type, int min
}
#endif
- setPropertyCacheForMinorVersion(type.index(), minorVersion, raw);
+ setPropertyCacheForVersion(type.index(), version, raw);
if (hasCopied)
raw->release();
- if (minorVersion != maxMinorVersion)
- setPropertyCacheForMinorVersion(type.index(), maxMinorVersion, raw);
+ if (version != maxVersion)
+ setPropertyCacheForVersion(type.index(), maxVersion, raw);
return raw;
}
diff --git a/src/qml/qml/qqmlmetatypedata_p.h b/src/qml/qml/qqmlmetatypedata_p.h
index e51d4ca1a4..322ead084a 100644
--- a/src/qml/qml/qqmlmetatypedata_p.h
+++ b/src/qml/qml/qqmlmetatypedata_p.h
@@ -57,7 +57,6 @@
#include <QtCore/qset.h>
#include <QtCore/qvector.h>
-#include <QtCore/qbitarray.h>
QT_BEGIN_NAMESPACE
@@ -83,29 +82,28 @@ struct QQmlMetaTypeData
MetaObjects metaObjectToType;
typedef QHash<int, QQmlMetaType::StringConverter> StringConverters;
StringConverters stringConverters;
- QVector<QHash<int, QQmlRefPointer<QQmlPropertyCache>>> typePropertyCaches;
+ QVector<QHash<QTypeRevision, QQmlRefPointer<QQmlPropertyCache>>> typePropertyCaches;
struct VersionedUri {
- VersionedUri()
- : majorVersion(0) {}
- VersionedUri(const QHashedString &uri, int majorVersion)
- : uri(uri), majorVersion(majorVersion) {}
+ VersionedUri() : majorVersion(0) {}
+ VersionedUri(const QHashedString &uri, QTypeRevision version)
+ : uri(uri), majorVersion(version.majorVersion()) {}
bool operator==(const VersionedUri &other) const {
return other.majorVersion == majorVersion && other.uri == uri;
}
QHashedString uri;
- int majorVersion;
+ quint8 majorVersion;
};
typedef QHash<VersionedUri, QQmlTypeModule *> TypeModules;
TypeModules uriToModule;
- QHash<VersionedUri, void (*)()> moduleTypeRegistrationFunctions;
- bool registerModuleTypes(const VersionedUri &versionedUri);
+ QHash<QString, void (*)()> moduleTypeRegistrationFunctions;
+ bool registerModuleTypes(const QString &uri);
- QBitArray objects;
- QBitArray interfaces;
- QBitArray lists;
+ QSet<int> interfaces;
+ QSet<int> objects;
+ QSet<int> lists;
QList<QQmlPrivate::AutoParentFunction> parentFunctions;
QVector<QQmlPrivate::QmlUnitCacheLookupFunction> lookupCachedQmlUnit;
@@ -114,12 +112,12 @@ struct QQmlMetaTypeData
QHash<const QMetaObject *, QQmlPropertyCache *> propertyCaches;
- QQmlPropertyCache *propertyCacheForMinorVersion(int index, int minorVersion) const;
- void setPropertyCacheForMinorVersion(int index, int minorVersion, QQmlPropertyCache *cache);
- void clearPropertyCachesForMinorVersion(int index);
+ QQmlPropertyCache *propertyCacheForVersion(int index, QTypeRevision version) const;
+ void setPropertyCacheForVersion(int index, QTypeRevision version, QQmlPropertyCache *cache);
+ void clearPropertyCachesForVersion(int index);
- QQmlPropertyCache *propertyCache(const QMetaObject *metaObject, int minorVersion);
- QQmlPropertyCache *propertyCache(const QQmlType &type, int minorVersion);
+ QQmlPropertyCache *propertyCache(const QMetaObject *metaObject, QTypeRevision version);
+ QQmlPropertyCache *propertyCache(const QQmlType &type, QTypeRevision version);
void setTypeRegistrationFailures(QStringList *failures)
{
diff --git a/src/qml/qml/qqmlmoduleregistration.cpp b/src/qml/qml/qqmlmoduleregistration.cpp
index b7bc3555a6..422a5c0551 100644
--- a/src/qml/qml/qqmlmoduleregistration.cpp
+++ b/src/qml/qml/qqmlmoduleregistration.cpp
@@ -39,27 +39,33 @@
#include <QtQml/private/qqmlmetatype_p.h>
#include <QtQml/qqmlmoduleregistration.h>
+#include <QtCore/qversionnumber.h>
QT_BEGIN_NAMESPACE
struct QQmlModuleRegistrationPrivate
{
const QString uri;
- const int majorVersion;
};
+QQmlModuleRegistration::QQmlModuleRegistration(const char *uri, void (*registerFunction)()) :
+ d(new QQmlModuleRegistrationPrivate { QString::fromUtf8(uri) })
+{
+ QQmlMetaType::qmlInsertModuleRegistration(d->uri, registerFunction);
+}
+
+#if QT_DEPRECATED_SINCE(6, 0)
QQmlModuleRegistration::QQmlModuleRegistration(
- const char *uri, int majorVersion,
- void (*registerFunction)()) :
- d(new QQmlModuleRegistrationPrivate { QString::fromUtf8(uri), majorVersion })
+ const char *uri, int majorVersion, void (*registerFunction)()) :
+ QQmlModuleRegistration(uri, registerFunction)
{
- QQmlMetaType::qmlInsertModuleRegistration(d->uri, d->majorVersion,
- registerFunction);
+ Q_UNUSED(majorVersion);
}
+#endif
QQmlModuleRegistration::~QQmlModuleRegistration()
{
- QQmlMetaType::qmlRemoveModuleRegistration(d->uri, d->majorVersion);
+ QQmlMetaType::qmlRemoveModuleRegistration(d->uri);
delete d;
}
diff --git a/src/qml/qml/qqmlmoduleregistration.h b/src/qml/qml/qqmlmoduleregistration.h
index 6f553a2823..3db535faa0 100644
--- a/src/qml/qml/qqmlmoduleregistration.h
+++ b/src/qml/qml/qqmlmoduleregistration.h
@@ -49,9 +49,14 @@ class Q_QML_EXPORT QQmlModuleRegistration
{
Q_DISABLE_COPY_MOVE(QQmlModuleRegistration)
public:
- QQmlModuleRegistration(const char *uri, int majorVersion, void (*registerFunction)());
+ QQmlModuleRegistration(const char *uri, void (*registerFunction)());
~QQmlModuleRegistration();
+#if QT_DEPRECATED_SINCE(6, 0)
+ QT_DEPRECATED_X("Use registration without major version")
+ QQmlModuleRegistration(const char *uri, int majorVersion, void (*registerFunction)());
+#endif
+
private:
QQmlModuleRegistrationPrivate *d = nullptr;
};
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 198ce98f2d..538a87ff5b 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -56,6 +56,7 @@
#include <private/qqmldebugconnector_p.h>
#include <private/qqmldebugserviceinterfaces_p.h>
#include <private/qqmlscriptdata_p.h>
+#include <private/qqmlsourcecoordinate_p.h>
#include <private/qjsvalue_p.h>
#include <private/qv4generatorobject_p.h>
@@ -173,7 +174,7 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI
context = new QQmlContextData;
context->isInternal = true;
context->imports = compilationUnit->typeNameCache;
- context->initFromTypeCompilationUnit(compilationUnit, flags & CreationFlags::NormalObject ? subComponentIndex : -1);
+ context->initFromTypeCompilationUnit(compilationUnit, subComponentIndex);
context->setParent(parentContext);
if (!sharedState->rootContext) {
@@ -856,12 +857,12 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *bindingProper
if (stringAt(obj->inheritedTypeNameIndex).isEmpty()) {
QObject *groupObject = nullptr;
- QQmlValueType *valueType = nullptr;
+ QQmlGadgetPtrWrapper *valueType = nullptr;
const QQmlPropertyData *valueTypeProperty = nullptr;
QObject *bindingTarget = _bindingTarget;
if (QQmlValueTypeFactory::isValueType(bindingProperty->propType())) {
- valueType = QQmlValueTypeFactory::valueType(bindingProperty->propType());
+ valueType = QQmlGadgetPtrWrapper::instance(engine, bindingProperty->propType());
if (!valueType) {
recordError(binding->location, tr("Cannot set properties on %1 as it is null").arg(stringAt(binding->propertyNameIndex)));
return false;
@@ -1135,8 +1136,8 @@ void QQmlObjectCreator::recordError(const QV4::CompiledData::Location &location,
{
QQmlError error;
error.setUrl(compilationUnit->url());
- error.setLine(location.line);
- error.setColumn(location.column);
+ error.setLine(qmlConvertSourceCoordinate<quint32, int>(location.line));
+ error.setColumn(qmlConvertSourceCoordinate<quint32, int>(location.column));
error.setDescription(description);
errors << error;
}
@@ -1147,11 +1148,6 @@ void QQmlObjectCreator::registerObjectWithContextById(const QV4::CompiledData::O
context->setIdProperty(object->id, instance);
}
-void QQmlObjectCreator::createQmlContext()
-{
- _qmlContext->setM(QV4::QmlContext::create(v4->rootContext(), context, _scopeObject));
-}
-
QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isContextObject)
{
const QV4::CompiledData::Object *obj = compilationUnit->objectAt(index);
@@ -1264,7 +1260,10 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo
ddata->columnNumber = obj->location.column;
ddata->setImplicitDestructible();
- if (static_cast<quint32>(index) == /*root object*/0 || ddata->rootObjectInCreation) {
+ // inline components are root objects, but their index is != 0, so we need
+ // an additional check
+ const bool isInlineComponent = obj->flags & QV4::CompiledData::Object::IsInlineComponentRoot;
+ if (static_cast<quint32>(index) == /*root object*/0 || ddata->rootObjectInCreation || isInlineComponent) {
if (ddata->context) {
Q_ASSERT(ddata->context != context);
Q_ASSERT(ddata->outerContext);
@@ -1505,15 +1504,45 @@ bool QQmlObjectCreator::populateInstance(int index, QObject *instance, QObject *
if (_compiledObject->flags & QV4::CompiledData::Object::HasDeferredBindings)
_ddata->deferData(_compiledObjectIndex, compilationUnit, context);
+ QSet<QString> postHocRequired;
+ for (auto it = _compiledObject->requiredPropertyExtraDataBegin(); it != _compiledObject->requiredPropertyExtraDataEnd(); ++it)
+ postHocRequired.insert(stringAt(it->nameIndex));
+ bool hadInheritedRequiredProperties = !postHocRequired.empty();
+
for (int propertyIndex = 0; propertyIndex != _compiledObject->propertyCount(); ++propertyIndex) {
const QV4::CompiledData::Property* property = _compiledObject->propertiesBegin() + propertyIndex;
QQmlPropertyData *propertyData = _propertyCache->property(_propertyCache->propertyOffset() + propertyIndex);
- if (property->isRequired) {
- sharedState->hadRequiredProperties = true;
- sharedState->requiredProperties.insert(propertyData,
- RequiredPropertyInfo {compilationUnit->stringAt(property->nameIndex), compilationUnit->finalUrl(), property->location, {}});
- }
+ // only compute stringAt if there's a chance for the lookup to succeed
+ auto postHocIt = postHocRequired.isEmpty() ? postHocRequired.end() : postHocRequired.find(stringAt(property->nameIndex));
+ if (!property->isRequired && postHocRequired.end() == postHocIt)
+ continue;
+ if (postHocIt != postHocRequired.end())
+ postHocRequired.erase(postHocIt);
+ sharedState->hadRequiredProperties = true;
+ sharedState->requiredProperties.insert(propertyData,
+ RequiredPropertyInfo {compilationUnit->stringAt(property->nameIndex), compilationUnit->finalUrl(), property->location, {}});
+
+ }
+
+ for (int i = 0; i <= _propertyCache->propertyOffset(); ++i) {
+ QQmlPropertyData *propertyData = _propertyCache->maybeUnresolvedProperty(i);
+ if (!propertyData)
+ continue;
+ if (!propertyData->isRequired() && postHocRequired.isEmpty())
+ continue;
+ QString name = propertyData->name(_qobject);
+ auto postHocIt = postHocRequired.find(name);
+ if (!propertyData->isRequired() && postHocRequired.end() == postHocIt )
+ continue;
+
+ if (postHocIt != postHocRequired.end())
+ postHocRequired.erase(postHocIt);
+
+ sharedState->hadRequiredProperties = true;
+ sharedState->requiredProperties.insert(propertyData, RequiredPropertyInfo {name, compilationUnit->finalUrl(), _compiledObject->location, {}});
}
+ if (!postHocRequired.isEmpty() && hadInheritedRequiredProperties)
+ recordError({}, QLatin1String("Property %1 was marked as required but does not exist").arg(*postHocRequired.begin()));
if (_compiledObject->nFunctions > 0)
setupFunctions();
diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h
index f8ad90be15..50ce8d5909 100644
--- a/src/qml/qml/qqmlobjectcreator_p.h
+++ b/src/qml/qml/qqmlobjectcreator_p.h
@@ -86,7 +86,7 @@ struct RequiredPropertyInfo
QVector<AliasToRequiredInfo> aliasesToRequired;
};
-using RequiredProperties = QHash<QQmlPropertyData*, RequiredPropertyInfo>;
+class RequiredProperties : public QHash<QQmlPropertyData*, RequiredPropertyInfo> {};
struct QQmlObjectCreatorSharedState : public QSharedData
{
@@ -162,7 +162,6 @@ private:
void registerObjectWithContextById(const QV4::CompiledData::Object *object, QObject *instance) const;
inline QV4::QmlContext *currentQmlContext();
- Q_NEVER_INLINE void createQmlContext();
QV4::ResolvedTypeReference *resolvedType(int id) const
{
return compilationUnit->resolvedType(id);
diff --git a/src/qml/qml/qqmlprivate.h b/src/qml/qml/qqmlprivate.h
index 9504fc37dc..8a1cbc2ddf 100644
--- a/src/qml/qml/qqmlprivate.h
+++ b/src/qml/qml/qqmlprivate.h
@@ -63,24 +63,11 @@
#include <QtCore/qvariant.h>
#include <QtCore/qurl.h>
#include <QtCore/qpointer.h>
+#include <QtCore/qversionnumber.h>
#include <QtCore/qmetaobject.h>
#include <QtCore/qdebug.h>
-#define QML_GETTYPENAMES \
- const char *className = T::staticMetaObject.className(); \
- const int nameLen = int(strlen(className)); \
- QVarLengthArray<char,48> pointerName(nameLen+2); \
- memcpy(pointerName.data(), className, size_t(nameLen)); \
- pointerName[nameLen] = '*'; \
- pointerName[nameLen+1] = '\0'; \
- const int listLen = int(strlen("QQmlListProperty<")); \
- QVarLengthArray<char,64> listName(listLen + nameLen + 2); \
- memcpy(listName.data(), "QQmlListProperty<", size_t(listLen)); \
- memcpy(listName.data()+listLen, className, size_t(nameLen)); \
- listName[listLen+nameLen] = '>'; \
- listName[listLen+nameLen+1] = '\0';
-
QT_BEGIN_NAMESPACE
class QQmlPropertyValueInterceptor;
@@ -124,6 +111,7 @@ class QJSValue;
class QJSEngine;
class QQmlEngine;
class QQmlCustomParser;
+class QQmlTypeNotAvailable;
template<class T>
QQmlCustomParser *qmlCreateCustomParser()
@@ -342,17 +330,16 @@ namespace QQmlPrivate
typedef AutoParentResult (*AutoParentFunction)(QObject *object, QObject *parent);
struct RegisterType {
- int version;
+ int structVersion;
- int typeId;
- int listId;
+ QMetaType typeId;
+ QMetaType listId;
int objectSize;
void (*create)(void *);
QString noCreationReason;
const char *uri;
- int versionMajor;
- int versionMinor;
+ QTypeRevision version;
const char *elementName;
const QMetaObject *metaObject;
@@ -368,20 +355,20 @@ namespace QQmlPrivate
QQmlCustomParser *customParser;
- int revision;
+ QTypeRevision revision;
// If this is extended ensure "version" is bumped!!!
};
struct RegisterTypeAndRevisions {
- int version;
+ int structVersion;
- int typeId;
- int listId;
+ QMetaType typeId;
+ QMetaType listId;
int objectSize;
void (*create)(void *);
const char *uri;
- int versionMajor;
+ QTypeRevision version;
const QMetaObject *metaObject;
const QMetaObject *classInfoMetaObject;
@@ -400,12 +387,15 @@ namespace QQmlPrivate
};
struct RegisterInterface {
- int version;
+ int structVersion;
- int typeId;
- int listId;
+ QMetaType typeId;
+ QMetaType listId;
const char *iid;
+
+ const char *uri;
+ QTypeRevision version;
};
struct RegisterAutoParent {
@@ -415,48 +405,45 @@ namespace QQmlPrivate
};
struct RegisterSingletonType {
- int version;
+ int structVersion;
const char *uri;
- int versionMajor;
- int versionMinor;
+ QTypeRevision version;
const char *typeName;
QJSValue (*scriptApi)(QQmlEngine *, QJSEngine *);
QObject *(*qobjectApi)(QQmlEngine *, QJSEngine *);
const QMetaObject *instanceMetaObject; // new in version 1
- int typeId; // new in version 2
- int revision; // new in version 2
+ QMetaType typeId; // new in version 2
+ QTypeRevision revision; // new in version 2
std::function<QObject*(QQmlEngine *, QJSEngine *)> generalizedQobjectApi; // new in version 3
// If this is extended ensure "version" is bumped!!!
};
struct RegisterSingletonTypeAndRevisions {
- int version;
+ int structVersion;
const char *uri;
- int versionMajor;
+ QTypeRevision version;
QJSValue (*scriptApi)(QQmlEngine *, QJSEngine *);
const QMetaObject *instanceMetaObject;
const QMetaObject *classInfoMetaObject;
- int typeId;
+ QMetaType typeId;
std::function<QObject*(QQmlEngine *, QJSEngine *)> generalizedQobjectApi; // new in version 3
};
struct RegisterCompositeType {
QUrl url;
const char *uri;
- int versionMajor;
- int versionMinor;
+ QTypeRevision version;
const char *typeName;
};
struct RegisterCompositeSingletonType {
QUrl url;
const char *uri;
- int versionMajor;
- int versionMinor;
+ QTypeRevision version;
const char *typeName;
};
@@ -468,7 +455,7 @@ namespace QQmlPrivate
typedef const CachedQmlUnit *(*QmlUnitCacheLookupFunction)(const QUrl &url);
struct RegisterQmlUnitCacheHook {
- int version;
+ int structVersion;
QmlUnitCacheLookupFunction lookupCachedQmlUnit;
};
@@ -512,11 +499,13 @@ namespace QQmlPrivate
return metaObject->classInfo(indexOfOwnClassInfo(metaObject, key)).value();
}
- inline int intClassInfo(const QMetaObject *metaObject, const char *key, int defaultValue = 0)
+ inline QTypeRevision revisionClassInfo(const QMetaObject *metaObject, const char *key,
+ QTypeRevision defaultValue = QTypeRevision())
{
const int index = indexOfOwnClassInfo(metaObject, key);
return (index == -1) ? defaultValue
- : QByteArray(metaObject->classInfo(index).value()).toInt();
+ : QTypeRevision::fromEncodedVersion(
+ QByteArray(metaObject->classInfo(index).value()).toInt());
}
inline bool boolClassInfo(const QMetaObject *metaObject, const char *key,
@@ -579,24 +568,34 @@ namespace QQmlPrivate
static constexpr bool Value = bool(T::QmlIsSingleton::yes);
};
+ template<class T, class = QmlVoidT<>>
+ struct QmlInterface
+ {
+ static constexpr bool Value = false;
+ };
+
+ template<class T>
+ struct QmlInterface<T, QmlVoidT<typename T::QmlIsInterface>>
+ {
+ static constexpr bool Value = bool(T::QmlIsInterface::yes);
+ };
+
template<typename T>
void qmlRegisterSingletonAndRevisions(const char *uri, int versionMajor,
const QMetaObject *classInfoMetaObject)
{
- QML_GETTYPENAMES
-
RegisterSingletonTypeAndRevisions api = {
0,
uri,
- versionMajor,
+ QTypeRevision::fromMajorVersion(versionMajor),
nullptr,
&T::staticMetaObject,
classInfoMetaObject,
- qRegisterNormalizedMetaType<T *>(pointerName.constData()),
+ QMetaType::fromType<T *>(),
Constructors<T>::createSingletonInstance
};
@@ -607,17 +606,15 @@ namespace QQmlPrivate
void qmlRegisterTypeAndRevisions(const char *uri, int versionMajor,
const QMetaObject *classInfoMetaObject)
{
- QML_GETTYPENAMES
-
RegisterTypeAndRevisions type = {
0,
- qRegisterNormalizedMetaType<T *>(pointerName.constData()),
- qRegisterNormalizedMetaType<QQmlListProperty<T> >(listName.constData()),
+ QMetaType::fromType<T*>(),
+ QMetaType::fromType<QQmlListProperty<T>>(),
int(sizeof(T)),
Constructors<T>::createInto,
uri,
- versionMajor,
+ QTypeRevision::fromMajorVersion(versionMajor),
&T::staticMetaObject,
classInfoMetaObject,
@@ -637,6 +634,11 @@ namespace QQmlPrivate
qmlregister(TypeAndRevisionsRegistration, &type);
}
+
+ template<>
+ void Q_QML_EXPORT qmlRegisterTypeAndRevisions<QQmlTypeNotAvailable, void>(
+ const char *uri, int versionMajor, const QMetaObject *classInfoMetaObject);
+
} // namespace QQmlPrivate
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp
index 93020661e2..8521de6ab3 100644
--- a/src/qml/qml/qqmlproperty.cpp
+++ b/src/qml/qml/qqmlproperty.cpp
@@ -353,10 +353,15 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name)
if (terminal.count() >= 3 &&
terminal.at(0) == QLatin1Char('o') &&
terminal.at(1) == QLatin1Char('n') &&
- terminal.at(2).isUpper()) {
+ (terminal.at(2).isUpper() || terminal.at(2) == '_')) {
QString signalName = terminal.mid(2).toString();
- signalName[0] = signalName.at(0).toLower();
+ int firstNon_;
+ int length = signalName.length();
+ for (firstNon_ = 0; firstNon_ < length; ++firstNon_)
+ if (signalName.at(firstNon_) != '_')
+ break;
+ signalName[firstNon_] = signalName.at(firstNon_).toLower();
// XXX - this code treats methods as signals
@@ -1044,13 +1049,19 @@ QVariant QQmlProperty::read(const QObject *object, const QString &name, QQmlEngi
QVariant QQmlPropertyPrivate::readValueProperty()
{
- if (isValueType()) {
-
- QQmlValueType *valueType = QQmlValueTypeFactory::valueType(core.propType());
- Q_ASSERT(valueType);
- valueType->read(object, core.coreIndex());
- return valueType->metaObject()->property(valueTypeData.coreIndex()).read(valueType);
+ auto doRead = [&](QQmlGadgetPtrWrapper *wrapper) {
+ wrapper->read(object, core.coreIndex());
+ return wrapper->property(valueTypeData.coreIndex()).read(wrapper);
+ };
+ if (isValueType()) {
+ if (QQmlGadgetPtrWrapper *wrapper = QQmlGadgetPtrWrapper::instance(engine, core.propType()))
+ return doRead(wrapper);
+ if (QQmlValueType *valueType = QQmlValueTypeFactory::valueType(core.propType())) {
+ QQmlGadgetPtrWrapper wrapper(valueType, nullptr);
+ return doRead(&wrapper);
+ }
+ return QVariant();
} else if (core.isQList()) {
QQmlListProperty<QObject> prop;
@@ -1183,10 +1194,22 @@ QQmlPropertyPrivate::writeValueProperty(QObject *object,
bool rv = false;
if (valueTypeData.isValid()) {
- QQmlValueType *writeBack = QQmlValueTypeFactory::valueType(core.propType());
- writeBack->read(object, core.coreIndex());
- rv = write(writeBack, valueTypeData, value, context, flags);
- writeBack->write(object, core.coreIndex(), flags);
+ auto doWrite = [&](QQmlGadgetPtrWrapper *wrapper) {
+ wrapper->read(object, core.coreIndex());
+ rv = write(wrapper, valueTypeData, value, context, flags);
+ wrapper->write(object, core.coreIndex(), flags);
+ };
+
+ QQmlGadgetPtrWrapper *wrapper = context
+ ? QQmlGadgetPtrWrapper::instance(context->engine, core.propType())
+ : nullptr;
+ if (wrapper) {
+ doWrite(wrapper);
+ } else if (QQmlValueType *valueType = QQmlValueTypeFactory::valueType(core.propType())) {
+ QQmlGadgetPtrWrapper wrapper(valueType, nullptr);
+ doWrite(&wrapper);
+ }
+
} else {
rv = write(object, core, value, context, flags);
}
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index c4afbbd598..09e16fdbe0 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -75,6 +75,7 @@ static QQmlPropertyData::Flags fastFlagsForProperty(const QMetaProperty &p)
flags.setIsWritable(p.isWritable());
flags.setIsResettable(p.isResettable());
flags.setIsFinal(p.isFinal());
+ flags.setIsRequired(p.isRequired());
if (p.isEnumType())
flags.type = QQmlPropertyData::Flags::EnumType;
@@ -82,13 +83,11 @@ static QQmlPropertyData::Flags fastFlagsForProperty(const QMetaProperty &p)
return flags;
}
-// Flags that do depend on the property's QMetaProperty::userType() and thus are slow to
-// load
-static void flagsForPropertyType(int propType, QQmlPropertyData::Flags &flags)
+// Flags that do depend on the property's QMetaType
+static void flagsForPropertyType(QMetaType metaType, QQmlPropertyData::Flags &flags)
{
- Q_ASSERT(propType != -1);
-
- if (propType == QMetaType::QObjectStar) {
+ int propType = metaType.id();
+ if (metaType.flags() & QMetaType::PointerToQObject) {
flags.type = QQmlPropertyData::Flags::QObjectDerivedType;
} else if (propType == QMetaType::QVariant) {
flags.type = QQmlPropertyData::Flags::QVariantType;
@@ -100,8 +99,7 @@ static void flagsForPropertyType(int propType, QQmlPropertyData::Flags &flags)
flags.type = QQmlPropertyData::Flags::QJSValueType;
} else {
QQmlMetaType::TypeCategory cat = QQmlMetaType::typeCategory(propType);
-
- if (cat == QQmlMetaType::Object || QMetaType::typeFlags(propType) & QMetaType::PointerToQObject)
+ if (cat == QQmlMetaType::Object)
flags.type = QQmlPropertyData::Flags::QObjectDerivedType;
else if (cat == QQmlMetaType::List)
flags.type = QQmlPropertyData::Flags::QListType;
@@ -120,17 +118,17 @@ QQmlPropertyData::Flags
QQmlPropertyData::flagsForProperty(const QMetaProperty &p)
{
auto flags = fastFlagsForProperty(p);
- flagsForPropertyType(p.userType(), flags);
+ flagsForPropertyType(p.metaType(), flags);
return flags;
}
static void populate(QQmlPropertyData *data, const QMetaProperty &p)
{
- Q_ASSERT(p.revision() <= Q_INT16_MAX);
+ Q_ASSERT(p.revision() <= std::numeric_limits<quint16>::max());
data->setCoreIndex(p.propertyIndex());
data->setNotifyIndex(QMetaObjectPrivate::signalIndex(p.notifySignal()));
data->setFlags(fastFlagsForProperty(p));
- data->setRevision(p.revision());
+ data->setRevision(QTypeRevision::fromEncodedVersion(p.revision()));
}
void QQmlPropertyData::lazyLoad(const QMetaProperty &p)
@@ -153,8 +151,9 @@ void QQmlPropertyData::lazyLoad(const QMetaProperty &p)
void QQmlPropertyData::load(const QMetaProperty &p)
{
populate(this, p);
- setPropType(p.userType());
- flagsForPropertyType(propType(), m_flags);
+ QMetaType type = p.metaType();
+ setPropType(type.id());
+ flagsForPropertyType(type, m_flags);
}
void QQmlPropertyData::load(const QMetaMethod &m)
@@ -182,8 +181,8 @@ void QQmlPropertyData::load(const QMetaMethod &m)
if (m.attributes() & QMetaMethod::Cloned)
m_flags.setIsCloned(true);
- Q_ASSERT(m.revision() <= Q_INT16_MAX);
- setRevision(m.revision());
+ Q_ASSERT(m.revision() <= std::numeric_limits<quint16>::max());
+ setRevision(QTypeRevision::fromEncodedVersion(m.revision()));
}
void QQmlPropertyData::lazyLoad(const QMetaMethod &m)
@@ -211,14 +210,14 @@ QQmlPropertyCache::QQmlPropertyCache()
/*!
Creates a new QQmlPropertyCache of \a metaObject.
*/
-QQmlPropertyCache::QQmlPropertyCache(const QMetaObject *metaObject, int metaObjectRevision)
+QQmlPropertyCache::QQmlPropertyCache(const QMetaObject *metaObject, QTypeRevision metaObjectRevision)
: QQmlPropertyCache()
{
Q_ASSERT(metaObject);
update(metaObject);
- if (metaObjectRevision > 0) {
+ if (metaObjectRevision.isValid() && metaObjectRevision != QTypeRevision::zero()) {
// Set the revision of the meta object that this cache describes to be
// 'metaObjectRevision'. This is useful when constructing a property cache
// from a type that was created directly in C++, and not through QML. For such
@@ -290,14 +289,15 @@ QQmlPropertyCache *QQmlPropertyCache::copyAndReserve(int propertyCount, int meth
This is different from QMetaMethod::methodIndex().
*/
void QQmlPropertyCache::appendProperty(const QString &name, QQmlPropertyData::Flags flags,
- int coreIndex, int propType, int minorVersion, int notifyIndex)
+ int coreIndex, int propType, QTypeRevision version,
+ int notifyIndex)
{
QQmlPropertyData data;
data.setPropType(propType);
data.setCoreIndex(coreIndex);
data.setNotifyIndex(notifyIndex);
data.setFlags(flags);
- data.setTypeMinorVersion(minorVersion);
+ data.setTypeVersion(version);
QQmlPropertyData *old = findNamedProperty(name);
if (old)
@@ -398,6 +398,19 @@ const QMetaObject *QQmlPropertyCache::createMetaObject()
return _metaObject;
}
+QQmlPropertyData *QQmlPropertyCache::maybeUnresolvedProperty(int index) const
+{
+ if (index < 0 || index >= (propertyIndexCacheStart + propertyIndexCache.count()))
+ return nullptr;
+
+ QQmlPropertyData *rv = nullptr;
+ if (index < propertyIndexCacheStart)
+ return _parent->maybeUnresolvedProperty(index);
+ else
+ rv = const_cast<QQmlPropertyData *>(&propertyIndexCache.at(index - propertyIndexCacheStart));
+ return rv;
+}
+
QQmlPropertyData *QQmlPropertyCache::defaultProperty() const
{
return property(defaultPropertyName(), nullptr, nullptr);
@@ -419,12 +432,12 @@ QQmlPropertyCache::copyAndAppend(const QMetaObject *metaObject,
QQmlPropertyData::Flags methodFlags,
QQmlPropertyData::Flags signalFlags)
{
- return copyAndAppend(metaObject, -1, propertyFlags, methodFlags, signalFlags);
+ return copyAndAppend(metaObject, QTypeRevision(), propertyFlags, methodFlags, signalFlags);
}
QQmlPropertyCache *
QQmlPropertyCache::copyAndAppend(const QMetaObject *metaObject,
- int typeMinorVersion,
+ QTypeRevision typeVersion,
QQmlPropertyData::Flags propertyFlags,
QQmlPropertyData::Flags methodFlags,
QQmlPropertyData::Flags signalFlags)
@@ -438,13 +451,13 @@ QQmlPropertyCache::copyAndAppend(const QMetaObject *metaObject,
QMetaObjectPrivate::get(metaObject)->signalCount +
QMetaObjectPrivate::get(metaObject)->propertyCount);
- rv->append(metaObject, typeMinorVersion, propertyFlags, methodFlags, signalFlags);
+ rv->append(metaObject, typeVersion, propertyFlags, methodFlags, signalFlags);
return rv;
}
void QQmlPropertyCache::append(const QMetaObject *metaObject,
- int typeMinorVersion,
+ QTypeRevision typeVersion,
QQmlPropertyData::Flags propertyFlags,
QQmlPropertyData::Flags methodFlags,
QQmlPropertyData::Flags signalFlags)
@@ -453,7 +466,7 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject,
bool dynamicMetaObject = isDynamicMetaObject(metaObject);
- allowedRevisionCache.append(0);
+ allowedRevisionCache.append(QTypeRevision::zero());
int methodCount = metaObject->methodCount();
Q_ASSERT(QMetaObjectPrivate::get(metaObject)->revision >= 4);
@@ -598,7 +611,7 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject,
data->setFlags(propertyFlags);
data->lazyLoad(p);
- data->setTypeMinorVersion(typeMinorVersion);
+ data->setTypeVersion(typeVersion);
data->m_flags.setIsDirect(!dynamicMetaObject);
@@ -672,7 +685,7 @@ void QQmlPropertyCache::resolve(QQmlPropertyData *data) const
data->setPropType(registerResult == -1 ? QMetaType::UnknownType : registerResult);
}
}
- flagsForPropertyType(data->propType(), data->m_flags);
+ flagsForPropertyType(QMetaType(data->propType()), data->m_flags);
}
}
@@ -683,7 +696,7 @@ void QQmlPropertyCache::updateRecur(const QMetaObject *metaObject)
updateRecur(metaObject->superClass());
- append(metaObject, -1);
+ append(metaObject, QTypeRevision());
}
void QQmlPropertyCache::update(const QMetaObject *metaObject)
@@ -731,7 +744,7 @@ void QQmlPropertyCache::invalidate(const QMetaObject *metaObject)
methodIndexCacheStart = parent()->methodIndexCache.count() + parent()->methodIndexCacheStart;
signalHandlerIndexCacheStart = parent()->signalHandlerIndexCache.count() + parent()->signalHandlerIndexCacheStart;
stringCache.linkAndReserve(parent()->stringCache, reserve);
- append(metaObject, -1);
+ append(metaObject, QTypeRevision());
} else {
propertyIndexCacheStart = 0;
methodIndexCacheStart = 0;
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h
index bfd78eef88..9e6eaf9778 100644
--- a/src/qml/qml/qqmlpropertycache_p.h
+++ b/src/qml/qml/qqmlpropertycache_p.h
@@ -60,6 +60,7 @@
#include <private/qlinkedstringhash_p.h>
#include <QtCore/qvarlengtharray.h>
#include <QtCore/qvector.h>
+#include <QtCore/qversionnumber.h>
#include <private/qv4value_p.h>
#include <private/qqmlpropertydata_p.h>
@@ -80,7 +81,7 @@ class Q_QML_PRIVATE_EXPORT QQmlPropertyCache : public QQmlRefCount
{
public:
QQmlPropertyCache();
- QQmlPropertyCache(const QMetaObject *, int metaObjectRevision = 0);
+ QQmlPropertyCache(const QMetaObject *, QTypeRevision metaObjectRevision = QTypeRevision::zero());
~QQmlPropertyCache() override;
void update(const QMetaObject *);
@@ -92,7 +93,8 @@ public:
QQmlPropertyData::Flags propertyFlags = QQmlPropertyData::Flags(),
QQmlPropertyData::Flags methodFlags = QQmlPropertyData::Flags(),
QQmlPropertyData::Flags signalFlags = QQmlPropertyData::Flags());
- QQmlPropertyCache *copyAndAppend(const QMetaObject *, int typeMinorVersion,
+ QQmlPropertyCache *copyAndAppend(
+ const QMetaObject *, QTypeRevision typeVersion,
QQmlPropertyData::Flags propertyFlags = QQmlPropertyData::Flags(),
QQmlPropertyData::Flags methodFlags = QQmlPropertyData::Flags(),
QQmlPropertyData::Flags signalFlags = QQmlPropertyData::Flags());
@@ -100,7 +102,7 @@ public:
QQmlPropertyCache *copyAndReserve(int propertyCount,
int methodCount, int signalCount, int enumCount);
void appendProperty(const QString &, QQmlPropertyData::Flags flags, int coreIndex,
- int propType, int revision, int notifyIndex);
+ int propType, QTypeRevision revision, int notifyIndex);
void appendSignal(const QString &, QQmlPropertyData::Flags, int coreIndex,
const int *types = nullptr, const QList<QByteArray> &names = QList<QByteArray>());
void appendMethod(const QString &, QQmlPropertyData::Flags flags, int coreIndex, int returnType,
@@ -118,6 +120,7 @@ public:
}
QQmlPropertyData *property(int) const;
+ QQmlPropertyData *maybeUnresolvedProperty(int) const;
QQmlPropertyData *method(int) const;
QQmlPropertyData *signal(int index) const;
QQmlEnumData *qmlEnum(int) const;
@@ -173,8 +176,8 @@ public:
QByteArray checksum(bool *ok);
- int allowedRevision(int index) const { return allowedRevisionCache[index]; }
- void setAllowedRevision(int index, int allowed) { allowedRevisionCache[index] = allowed; }
+ QTypeRevision allowedRevision(int index) const { return allowedRevisionCache[index]; }
+ void setAllowedRevision(int index, QTypeRevision allowed) { allowedRevisionCache[index] = allowed; }
private:
friend class QQmlEnginePrivate;
@@ -186,7 +189,7 @@ private:
inline QQmlPropertyCache *copy(int reserve);
- void append(const QMetaObject *, int typeMinorVersion,
+ void append(const QMetaObject *, QTypeRevision typeVersion,
QQmlPropertyData::Flags propertyFlags = QQmlPropertyData::Flags(),
QQmlPropertyData::Flags methodFlags = QQmlPropertyData::Flags(),
QQmlPropertyData::Flags signalFlags = QQmlPropertyData::Flags());
@@ -195,7 +198,7 @@ private:
typedef QVector<QQmlPropertyData> IndexCache;
typedef QLinkedStringMultiHash<QPair<int, QQmlPropertyData *> > StringCache;
- typedef QVector<int> AllowedRevisionCache;
+ typedef QVector<QTypeRevision> AllowedRevisionCache;
QQmlPropertyData *findProperty(StringCache::ConstIterator it, QObject *, QQmlContextData *) const;
QQmlPropertyData *findProperty(StringCache::ConstIterator it, const QQmlVMEMetaObject *, QQmlContextData *) const;
@@ -351,8 +354,9 @@ QQmlPropertyCache::overrideData(QQmlPropertyData *data) const
bool QQmlPropertyCache::isAllowedInRevision(QQmlPropertyData *data) const
{
- return (data->metaObjectOffset() == -1 && data->revision() == 0) ||
- (allowedRevisionCache[data->metaObjectOffset()] >= data->revision());
+ return (data->metaObjectOffset() == -1 && data->revision() == QTypeRevision::zero())
+ || (allowedRevisionCache[data->metaObjectOffset()].toEncodedVersion<quint16>()
+ >= data->revision().toEncodedVersion<quint16>());
}
int QQmlPropertyCache::propertyCount() const
diff --git a/src/qml/qml/qqmlpropertycachecreator.cpp b/src/qml/qml/qqmlpropertycachecreator.cpp
index 36581bda4e..f132fb2d78 100644
--- a/src/qml/qml/qqmlpropertycachecreator.cpp
+++ b/src/qml/qml/qqmlpropertycachecreator.cpp
@@ -119,9 +119,12 @@ QQmlRefPointer<QQmlPropertyCache> QQmlBindingInstantiationContext::instantiating
{
if (instantiatingProperty) {
if (instantiatingProperty->isQObject()) {
- return enginePrivate->rawPropertyCacheForType(instantiatingProperty->propType(), instantiatingProperty->typeMinorVersion());
+ // rawPropertyCacheForType assumes a given unspecified version means "any version".
+ // There is another overload that takes no version, which we shall not use here.
+ return enginePrivate->rawPropertyCacheForType(instantiatingProperty->propType(),
+ instantiatingProperty->typeVersion());
} else if (const QMetaObject *vtmo = QQmlValueTypeFactory::metaObjectForMetaType(instantiatingProperty->propType())) {
- return enginePrivate->cache(vtmo, instantiatingProperty->typeMinorVersion());
+ return enginePrivate->cache(vtmo, instantiatingProperty->typeVersion());
}
}
return QQmlRefPointer<QQmlPropertyCache>();
diff --git a/src/qml/qml/qqmlpropertycachecreator_p.h b/src/qml/qml/qqmlpropertycachecreator_p.h
index a050a0bf0a..cadbfdd481 100644
--- a/src/qml/qml/qqmlpropertycachecreator_p.h
+++ b/src/qml/qml/qqmlpropertycachecreator_p.h
@@ -56,19 +56,20 @@
#include <private/qqmlpropertyresolver_p.h>
#include <private/qqmltypedata_p.h>
#include <private/inlinecomponentutils_p.h>
+#include <private/qqmlsourcecoordinate_p.h>
#include <QScopedValueRollback>
#include <vector>
QT_BEGIN_NAMESPACE
-inline QQmlJS::DiagnosticMessage qQmlCompileError(const QV4::CompiledData::Location &location,
+inline QQmlError qQmlCompileError(const QV4::CompiledData::Location &location,
const QString &description)
{
- QQmlJS::DiagnosticMessage error;
- error.line = location.line;
- error.column = location.column;
- error.message = description;
+ QQmlError error;
+ error.setLine(qmlConvertSourceCoordinate<quint32, int>(location.line));
+ error.setColumn(qmlConvertSourceCoordinate<quint32, int>(location.column));
+ error.setDescription(description);
return error;
}
@@ -117,16 +118,16 @@ public:
const ObjectContainer *objectContainer, const QQmlImports *imports,
const QByteArray &typeClassName);
- QQmlJS::DiagnosticMessage buildMetaObjects();
+ QQmlError buildMetaObjects();
enum class VMEMetaObjectIsRequired {
Maybe,
Always
};
protected:
- QQmlJS::DiagnosticMessage buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context, VMEMetaObjectIsRequired isVMERequired);
- QQmlRefPointer<QQmlPropertyCache> propertyCacheForObject(const CompiledObject *obj, const QQmlBindingInstantiationContext &context, QQmlJS::DiagnosticMessage *error) const;
- QQmlJS::DiagnosticMessage createMetaObject(int objectIndex, const CompiledObject *obj, const QQmlRefPointer<QQmlPropertyCache> &baseTypeCache);
+ QQmlError buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context, VMEMetaObjectIsRequired isVMERequired);
+ QQmlRefPointer<QQmlPropertyCache> propertyCacheForObject(const CompiledObject *obj, const QQmlBindingInstantiationContext &context, QQmlError *error) const;
+ QQmlError createMetaObject(int objectIndex, const CompiledObject *obj, const QQmlRefPointer<QQmlPropertyCache> &baseTypeCache);
int metaTypeForParameter(const QV4::CompiledData::ParameterType &param, QString *customTypeName = nullptr);
@@ -153,12 +154,13 @@ inline QQmlPropertyCacheCreator<ObjectContainer>::QQmlPropertyCacheCreator(QQmlP
, propertyCaches(propertyCaches)
, pendingGroupPropertyBindings(pendingGroupPropertyBindings)
, typeClassName(typeClassName)
+ , currentRoot(-1)
{
propertyCaches->resize(objectContainer->objectCount());
}
template <typename ObjectContainer>
-inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObjects()
+inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObjects()
{
using namespace icutils;
QQmlBindingInstantiationContext context;
@@ -185,8 +187,8 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::buil
auto nodesSorted = topoSort(nodes, adjacencyList, hasCycle);
if (hasCycle) {
- QQmlJS::DiagnosticMessage diag;
- diag.message = QLatin1String("Inline components form a cycle!");
+ QQmlError diag;
+ diag.setDescription(QLatin1String("Inline components form a cycle!"));
return diag;
}
@@ -200,7 +202,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::buil
QByteArray icTypeName { objectContainer->stringAt(ic.nameIndex).toUtf8() };
QScopedValueRollback<QByteArray> nameChange {typeClassName, icTypeName};
QScopedValueRollback<unsigned int> rootChange {currentRoot, ic.objectIndex};
- QQmlJS::DiagnosticMessage diag = buildMetaObjectRecursively(ic.objectIndex, context, VMEMetaObjectIsRequired::Always);
+ QQmlError diag = buildMetaObjectRecursively(ic.objectIndex, context, VMEMetaObjectIsRequired::Always);
if (diag.isValid()) {
return diag;
}
@@ -212,7 +214,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::buil
}
template <typename ObjectContainer>
-inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context, VMEMetaObjectIsRequired isVMERequired)
+inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context, VMEMetaObjectIsRequired isVMERequired)
{
auto isAddressable = [](const QUrl &url) {
const QString fileName = url.fileName();
@@ -241,7 +243,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::buil
auto *typeRef = objectContainer->resolvedType(obj->inheritedTypeNameIndex);
Q_ASSERT(typeRef);
QQmlRefPointer<QQmlPropertyCache> baseTypeCache = typeRef->createPropertyCache(QQmlEnginePrivate::get(enginePrivate));
- QQmlJS::DiagnosticMessage error = createMetaObject(context.referencingObjectIndex, obj, baseTypeCache);
+ QQmlError error = createMetaObject(context.referencingObjectIndex, obj, baseTypeCache);
if (error.isValid())
return error;
}
@@ -256,7 +258,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::buil
QQmlRefPointer<QQmlPropertyCache> baseTypeCache;
{
- QQmlJS::DiagnosticMessage error;
+ QQmlError error;
baseTypeCache = propertyCacheForObject(obj, context, &error);
if (error.isValid())
return error;
@@ -264,7 +266,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::buil
if (baseTypeCache) {
if (needVMEMetaObject) {
- QQmlJS::DiagnosticMessage error = createMetaObject(objectIndex, obj, baseTypeCache);
+ QQmlError error = createMetaObject(objectIndex, obj, baseTypeCache);
if (error.isValid())
return error;
} else {
@@ -286,18 +288,18 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::buil
if (!context.resolveInstantiatingProperty())
pendingGroupPropertyBindings->append(context);
- QQmlJS::DiagnosticMessage error = buildMetaObjectRecursively(binding->value.objectIndex, context, VMEMetaObjectIsRequired::Maybe);
+ QQmlError error = buildMetaObjectRecursively(binding->value.objectIndex, context, VMEMetaObjectIsRequired::Maybe);
if (error.isValid())
return error;
}
}
- QQmlJS::DiagnosticMessage noError;
+ QQmlError noError;
return noError;
}
template <typename ObjectContainer>
-inline QQmlRefPointer<QQmlPropertyCache> QQmlPropertyCacheCreator<ObjectContainer>::propertyCacheForObject(const CompiledObject *obj, const QQmlBindingInstantiationContext &context, QQmlJS::DiagnosticMessage *error) const
+inline QQmlRefPointer<QQmlPropertyCache> QQmlPropertyCacheCreator<ObjectContainer>::propertyCacheForObject(const CompiledObject *obj, const QQmlBindingInstantiationContext &context, QQmlError *error) const
{
if (context.instantiatingProperty) {
return context.instantiatingPropertyCache(enginePrivate);
@@ -343,7 +345,7 @@ inline QQmlRefPointer<QQmlPropertyCache> QQmlPropertyCacheCreator<ObjectContaine
}
template <typename ObjectContainer>
-inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::createMetaObject(int objectIndex, const CompiledObject *obj, const QQmlRefPointer<QQmlPropertyCache> &baseTypeCache)
+inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObject(int objectIndex, const CompiledObject *obj, const QQmlRefPointer<QQmlPropertyCache> &baseTypeCache)
{
QQmlRefPointer<QQmlPropertyCache> cache;
cache.adopt(baseTypeCache->copyAndReserve(obj->propertyCount() + obj->aliasCount(),
@@ -537,7 +539,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::crea
pend = obj->propertiesEnd();
for ( ; p != pend; ++p, ++propertyIdx) {
int propertyType = 0;
- int propertTypeMinorVersion = 0;
+ QTypeRevision propertyTypeVersion = QTypeRevision::zero();
QQmlPropertyData::Flags propertyFlags;
const QV4::CompiledData::BuiltinType type = p->builtinType();
@@ -556,7 +558,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::crea
QQmlType qmltype;
bool selfReference = false;
- if (!imports->resolveType(stringAt(p->builtinTypeOrTypeNameIndex), &qmltype, nullptr, nullptr, nullptr,
+ if (!imports->resolveType(stringAt(p->builtinTypeOrTypeNameIndex), &qmltype, nullptr, nullptr,
nullptr, QQmlType::AnyRegistrationType, &selfReference)) {
return qQmlCompileError(p->location, QQmlPropertyCacheCreatorBase::tr("Invalid property type"));
}
@@ -589,16 +591,16 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::crea
}
if (p->isList) {
- propertyType = typeIds.listId;
+ propertyType = typeIds.listId.id();
} else {
- propertyType = typeIds.id;
+ propertyType = typeIds.id.id();
}
} else {
if (p->isList) {
- propertyType = qmltype.qListTypeId();
+ propertyType = qmltype.qListTypeId().id();
} else {
- propertyType = qmltype.typeId();
- propertTypeMinorVersion = qmltype.minorVersion();
+ propertyType = qmltype.typeId().id();
+ propertyTypeVersion = qmltype.version();
}
}
@@ -616,12 +618,12 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator<ObjectContainer>::crea
if (!obj->defaultPropertyIsAlias && propertyIdx == obj->indexOfDefaultPropertyOrAlias)
cache->_defaultPropertyName = propertyName;
cache->appendProperty(propertyName, propertyFlags, effectivePropertyIndex++,
- propertyType, propertTypeMinorVersion, effectiveSignalIndex);
+ propertyType, propertyTypeVersion, effectiveSignalIndex);
effectiveSignalIndex++;
}
- QQmlJS::DiagnosticMessage noError;
+ QQmlError noError;
return noError;
}
@@ -640,15 +642,15 @@ inline int QQmlPropertyCacheCreator<ObjectContainer>::metaTypeForParameter(const
*customTypeName = typeName;
QQmlType qmltype;
bool selfReference = false;
- if (!imports->resolveType(typeName, &qmltype, nullptr, nullptr, nullptr, nullptr, QQmlType::AnyRegistrationType,
- &selfReference))
+ if (!imports->resolveType(typeName, &qmltype, nullptr, nullptr, nullptr,
+ QQmlType::AnyRegistrationType, &selfReference))
return QMetaType::UnknownType;
if (!qmltype.isComposite())
- return qmltype.typeId();
+ return qmltype.typeId().id();
if (selfReference)
- return objectContainer->typeIdsForComponent().id;
+ return objectContainer->typeIdsForComponent().id.id();
QQmlRefPointer<QQmlTypeData> tdata = enginePrivate->typeLoader.getType(qmltype.sourceUrl());
Q_ASSERT(tdata);
@@ -656,7 +658,7 @@ inline int QQmlPropertyCacheCreator<ObjectContainer>::metaTypeForParameter(const
auto compilationUnit = tdata->compilationUnit();
- return compilationUnit->metaTypeId;
+ return compilationUnit->metaTypeId.id();
}
template <typename ObjectContainer>
@@ -669,11 +671,11 @@ public:
void appendAliasPropertiesToMetaObjects(QQmlEnginePrivate *enginePriv);
- QQmlJS::DiagnosticMessage appendAliasesToPropertyCache(const CompiledObject &component, int objectIndex, QQmlEnginePrivate *enginePriv);
+ QQmlError appendAliasesToPropertyCache(const CompiledObject &component, int objectIndex, QQmlEnginePrivate *enginePriv);
private:
void appendAliasPropertiesInMetaObjectsWithinComponent(const CompiledObject &component, int firstObjectIndex, QQmlEnginePrivate *enginePriv);
- QQmlJS::DiagnosticMessage propertyDataForAlias(const CompiledObject &component, const QV4::CompiledData::Alias &alias, int *type, int *rev, QQmlPropertyData::Flags *propertyFlags, QQmlEnginePrivate *enginePriv);
+ QQmlError propertyDataForAlias(const CompiledObject &component, const QV4::CompiledData::Alias &alias, int *type, QTypeRevision *version, QQmlPropertyData::Flags *propertyFlags, QQmlEnginePrivate *enginePriv);
void collectObjectsWithAliasesRecursively(int objectIndex, QVector<int> *objectsWithAliases) const;
@@ -784,8 +786,10 @@ inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::collectObjectsWithAl
}
template <typename ObjectContainer>
-inline QQmlJS::DiagnosticMessage QQmlPropertyCacheAliasCreator<ObjectContainer>::propertyDataForAlias(const CompiledObject &component, const QV4::CompiledData::Alias &alias, int *type, int *minorVersion,
- QQmlPropertyData::Flags *propertyFlags, QQmlEnginePrivate *enginePriv)
+inline QQmlError QQmlPropertyCacheAliasCreator<ObjectContainer>::propertyDataForAlias(
+ const CompiledObject &component, const QV4::CompiledData::Alias &alias, int *type,
+ QTypeRevision *version, QQmlPropertyData::Flags *propertyFlags,
+ QQmlEnginePrivate *enginePriv)
{
*type = 0;
bool writable = false;
@@ -817,7 +821,7 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheAliasCreator<ObjectContainer>:
lastAlias = targetAlias;
} while (lastAlias->aliasToLocalAlias);
- return propertyDataForAlias(component, *lastAlias, type, minorVersion, propertyFlags, enginePriv);
+ return propertyDataForAlias(component, *lastAlias, type, version, propertyFlags, enginePriv);
}
const int targetObjectIndex = objectForId(component, alias.targetObjectId);
@@ -836,11 +840,11 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheAliasCreator<ObjectContainer>:
}
if (typeRef->type.isValid())
- *type = typeRef->type.typeId();
+ *type = typeRef->type.typeId().id();
else
- *type = typeRef->compilationUnit->metaTypeId;
+ *type = typeRef->compilationUnit->metaTypeId.id();
- *minorVersion = typeRef->minorVersion;
+ *version = typeRef->version;
propertyFlags->type = QQmlPropertyData::Flags::QObjectDerivedType;
} else {
@@ -895,16 +899,16 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheAliasCreator<ObjectContainer>:
propertyFlags->setIsWritable(!(alias.flags & QV4::CompiledData::Alias::IsReadOnly) && writable);
propertyFlags->setIsResettable(resettable);
- return QQmlJS::DiagnosticMessage();
+ return QQmlError();
}
template <typename ObjectContainer>
-inline QQmlJS::DiagnosticMessage QQmlPropertyCacheAliasCreator<ObjectContainer>::appendAliasesToPropertyCache(
+inline QQmlError QQmlPropertyCacheAliasCreator<ObjectContainer>::appendAliasesToPropertyCache(
const CompiledObject &component, int objectIndex, QQmlEnginePrivate *enginePriv)
{
const CompiledObject &object = *objectContainer->objectAt(objectIndex);
if (!object.aliasCount())
- return QQmlJS::DiagnosticMessage();
+ return QQmlError();
QQmlPropertyCache *propertyCache = propertyCaches->at(objectIndex);
Q_ASSERT(propertyCache);
@@ -919,9 +923,10 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheAliasCreator<ObjectContainer>:
Q_ASSERT(alias->flags & QV4::CompiledData::Alias::Resolved);
int type = 0;
- int minorVersion = 0;
+ QTypeRevision version = QTypeRevision::zero();
QQmlPropertyData::Flags propertyFlags;
- QQmlJS::DiagnosticMessage error = propertyDataForAlias(component, *alias, &type, &minorVersion, &propertyFlags, enginePriv);
+ QQmlError error = propertyDataForAlias(component, *alias, &type, &version,
+ &propertyFlags, enginePriv);
if (error.isValid())
return error;
@@ -931,10 +936,10 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheAliasCreator<ObjectContainer>:
propertyCache->_defaultPropertyName = propertyName;
propertyCache->appendProperty(propertyName, propertyFlags, effectivePropertyIndex++,
- type, minorVersion, effectiveSignalIndex++);
+ type, version, effectiveSignalIndex++);
}
- return QQmlJS::DiagnosticMessage();
+ return QQmlError();
}
template <typename ObjectContainer>
diff --git a/src/qml/qml/qqmlpropertydata_p.h b/src/qml/qml/qqmlpropertydata_p.h
index 2d9091edcd..f21b502b50 100644
--- a/src/qml/qml/qqmlpropertydata_p.h
+++ b/src/qml/qml/qqmlpropertydata_p.h
@@ -53,6 +53,7 @@
#include <private/qobject_p.h>
#include <QtCore/qglobal.h>
+#include <QtCore/qversionnumber.h>
QT_BEGIN_NAMESPACE
@@ -109,7 +110,7 @@ public:
unsigned isFinalORisV4Function : 1; // Has FINAL flag OR Function takes QQmlV4Function* args
unsigned isSignalHandler : 1; // Function is a signal handler
unsigned isOverload : 1; // Function is an overload of another function
- unsigned isCloned : 1; // The function was marked as cloned
+ unsigned isRequiredORisCloned : 1; // Has REQUIRED flag OR The function was marked as cloned
unsigned isConstructor : 1; // The function was marked is a constructor
unsigned isDirect : 1; // Exists on a C++ QMetaObject
unsigned isOverridden : 1; // Is overridden by a extension property
@@ -159,6 +160,11 @@ public:
isDirect = b;
}
+ void setIsRequired(bool b) {
+ Q_ASSERT(type != FunctionType);
+ isRequiredORisCloned = b;
+ }
+
void setIsVMEFunction(bool b) {
Q_ASSERT(type == FunctionType);
isConstantORisVMEFunction = b;
@@ -193,7 +199,7 @@ public:
void setIsCloned(bool b) {
Q_ASSERT(type == FunctionType);
- isCloned = b;
+ isRequiredORisCloned = b;
}
void setIsConstructor(bool b) {
@@ -224,6 +230,7 @@ public:
bool isFinal() const { return !isFunction() && m_flags.isFinalORisV4Function; }
bool isOverridden() const { return m_flags.isOverridden; }
bool isDirect() const { return m_flags.isOverload; }
+ bool isRequired() const { return !isFunction() && m_flags.isRequiredORisCloned; }
bool hasStaticMetaCallFunction() const { return staticMetaCallFunction() != nullptr; }
bool isFunction() const { return m_flags.type == Flags::FunctionType; }
bool isQObject() const { return m_flags.type == Flags::QObjectDerivedType; }
@@ -241,11 +248,11 @@ public:
bool isSignalHandler() const { return m_flags.isSignalHandler; }
bool isOverload() const { return m_flags.isOverload; }
void setOverload(bool onoff) { m_flags.isOverload = onoff; }
- bool isCloned() const { return isFunction() && m_flags.isCloned; }
+ bool isCloned() const { return isFunction() && m_flags.isRequiredORisCloned; }
bool isConstructor() const { return m_flags.isConstructor; }
bool hasOverride() const { return overrideIndex() >= 0; }
- bool hasRevision() const { return revision() != 0; }
+ bool hasRevision() const { return revision() != QTypeRevision::zero(); }
bool isFullyResolved() const { return !m_flags.notFullyResolved; }
@@ -284,12 +291,8 @@ public:
m_coreIndex = qint16(idx);
}
- quint8 revision() const { return m_revision; }
- void setRevision(quint8 rev)
- {
- Q_ASSERT(rev <= std::numeric_limits<quint8>::max());
- m_revision = quint8(rev);
- }
+ QTypeRevision revision() const { return m_revision; }
+ void setRevision(QTypeRevision revision) { m_revision = revision; }
/* If a property is a C++ type, then we store the minor
* version of this type.
@@ -309,12 +312,8 @@ public:
*
*/
- quint8 typeMinorVersion() const { return m_typeMinorVersion; }
- void setTypeMinorVersion(quint8 rev)
- {
- Q_ASSERT(rev <= std::numeric_limits<quint8>::max());
- m_typeMinorVersion = quint8(rev);
- }
+ QTypeRevision typeVersion() const { return m_typeVersion; }
+ void setTypeVersion(QTypeRevision typeVersion) { m_typeVersion = typeVersion; }
QQmlPropertyCacheMethodArguments *arguments() const { return m_arguments; }
void setArguments(QQmlPropertyCacheMethodArguments *args) { m_arguments = args; }
@@ -406,18 +405,20 @@ private:
qint16 m_notifyIndex = -1;
qint16 m_overrideIndex = -1;
- quint8 m_revision = 0;
- quint8 m_typeMinorVersion = 0;
qint16 m_metaObjectOffset = -1;
+ quint16 m_reserved = 0;
+
+ QTypeRevision m_revision = QTypeRevision::zero();
+ QTypeRevision m_typeVersion = QTypeRevision::zero();
QQmlPropertyCacheMethodArguments *m_arguments = nullptr;
StaticMetaCallFunction m_staticMetaCallFunction = nullptr;
};
#if QT_POINTER_SIZE == 4
- Q_STATIC_ASSERT(sizeof(QQmlPropertyData) == 24);
+ Q_STATIC_ASSERT(sizeof(QQmlPropertyData) == 28);
#else // QT_POINTER_SIZE == 8
- Q_STATIC_ASSERT(sizeof(QQmlPropertyData) == 32);
+ Q_STATIC_ASSERT(sizeof(QQmlPropertyData) == 40);
#endif
bool QQmlPropertyData::operator==(const QQmlPropertyData &other) const
@@ -438,7 +439,7 @@ QQmlPropertyData::Flags::Flags()
, isFinalORisV4Function(false)
, isSignalHandler(false)
, isOverload(false)
- , isCloned(false)
+ , isRequiredORisCloned(false)
, isConstructor(false)
, isOverridden(false)
, type(OtherType)
@@ -455,7 +456,7 @@ bool QQmlPropertyData::Flags::operator==(const QQmlPropertyData::Flags &other) c
isFinalORisV4Function == other.isFinalORisV4Function &&
isOverridden == other.isOverridden &&
isSignalHandler == other.isSignalHandler &&
- isCloned == other.isCloned &&
+ isRequiredORisCloned == other.isRequiredORisCloned &&
type == other.type &&
isConstructor == other.isConstructor &&
notFullyResolved == other.notFullyResolved &&
diff --git a/src/qml/qml/qqmlpropertyvalidator.cpp b/src/qml/qml/qqmlpropertyvalidator.cpp
index 8762dc328d..312153576a 100644
--- a/src/qml/qml/qqmlpropertyvalidator.cpp
+++ b/src/qml/qml/qqmlpropertyvalidator.cpp
@@ -73,7 +73,7 @@ QQmlPropertyValidator::QQmlPropertyValidator(QQmlEnginePrivate *enginePrivate, c
bindingPropertyDataPerObject->resize(compilationUnit->objectCount());
}
-QVector<QQmlJS::DiagnosticMessage> QQmlPropertyValidator::validate()
+QVector<QQmlError> QQmlPropertyValidator::validate()
{
return validateObject(/*root object*/0, /*instantiatingBinding*/nullptr);
}
@@ -96,7 +96,7 @@ struct BindingFinder
}
};
-QVector<QQmlJS::DiagnosticMessage> QQmlPropertyValidator::validateObject(
+QVector<QQmlError> QQmlPropertyValidator::validateObject(
int objectIndex, const QV4::CompiledData::Binding *instantiatingBinding, bool populatingValueTypeGroupProperty) const
{
const QV4::CompiledData::Object *obj = compilationUnit->objectAt(objectIndex);
@@ -104,7 +104,7 @@ QVector<QQmlJS::DiagnosticMessage> QQmlPropertyValidator::validateObject(
validateObject(it->objectIndex, /* instantiatingBinding*/ nullptr);
}
- if (obj->flags & QV4::CompiledData::Object::IsComponent) {
+ if (obj->flags & QV4::CompiledData::Object::IsComponent && !(obj->flags & QV4::CompiledData::Object::IsInlineComponentRoot)) {
Q_ASSERT(obj->nBindings == 1);
const QV4::CompiledData::Binding *componentBinding = obj->bindingTable();
Q_ASSERT(componentBinding->type == QV4::CompiledData::Binding::Type_Object);
@@ -113,7 +113,7 @@ QVector<QQmlJS::DiagnosticMessage> QQmlPropertyValidator::validateObject(
QQmlPropertyCache *propertyCache = propertyCaches.at(objectIndex);
if (!propertyCache)
- return QVector<QQmlJS::DiagnosticMessage>();
+ return QVector<QQmlError>();
QQmlCustomParser *customParser = nullptr;
if (auto typeRef = resolvedType(obj->inheritedTypeNameIndex)) {
@@ -192,7 +192,10 @@ QVector<QQmlJS::DiagnosticMessage> QQmlPropertyValidator::validateObject(
QString typeName = stringAt(obj->inheritedTypeNameIndex);
auto *objectType = resolvedType(obj->inheritedTypeNameIndex);
if (objectType && objectType->type.isValid()) {
- return recordError(binding->location, tr("\"%1.%2\" is not available in %3 %4.%5.").arg(typeName).arg(name).arg(objectType->type.module()).arg(objectType->majorVersion).arg(objectType->minorVersion));
+ return recordError(binding->location, tr("\"%1.%2\" is not available in %3 %4.%5.")
+ .arg(typeName).arg(name).arg(objectType->type.module())
+ .arg(objectType->version.majorVersion())
+ .arg(objectType->version.minorVersion()));
} else {
return recordError(binding->location, tr("\"%1.%2\" is not available due to component versioning.").arg(typeName).arg(name));
}
@@ -212,7 +215,7 @@ QVector<QQmlJS::DiagnosticMessage> QQmlPropertyValidator::validateObject(
if (name.constData()->isUpper() && !binding->isAttachedProperty()) {
QQmlType type;
QQmlImportNamespace *typeNamespace = nullptr;
- imports.resolveType(stringAt(binding->propertyNameIndex), &type, nullptr, nullptr, &typeNamespace);
+ imports.resolveType(stringAt(binding->propertyNameIndex), &type, nullptr, &typeNamespace);
if (typeNamespace)
return recordError(binding->location, tr("Invalid use of namespace"));
return recordError(binding->location, tr("Invalid attached object assignment"));
@@ -223,7 +226,7 @@ QVector<QQmlJS::DiagnosticMessage> QQmlPropertyValidator::validateObject(
= pd
&& QQmlValueTypeFactory::metaObjectForMetaType(pd->propType())
&& !(binding->flags & QV4::CompiledData::Binding::IsOnAssignment);
- const QVector<QQmlJS::DiagnosticMessage> subObjectValidatorErrors
+ const QVector<QQmlError> subObjectValidatorErrors
= validateObject(binding->value.objectIndex, binding,
populatingValueTypeGroupProperty);
if (!subObjectValidatorErrors.isEmpty())
@@ -280,11 +283,11 @@ QVector<QQmlJS::DiagnosticMessage> QQmlPropertyValidator::validateObject(
}
if (binding->type < QV4::CompiledData::Binding::Type_Script) {
- QQmlJS::DiagnosticMessage bindingError = validateLiteralBinding(propertyCache, pd, binding);
+ QQmlError bindingError = validateLiteralBinding(propertyCache, pd, binding);
if (bindingError.isValid())
return recordError(bindingError);
} else if (binding->type == QV4::CompiledData::Binding::Type_Object) {
- QQmlJS::DiagnosticMessage bindingError = validateObjectBinding(pd, name, binding);
+ QQmlError bindingError = validateObjectBinding(pd, name, binding);
if (bindingError.isValid())
return recordError(bindingError);
} else if (binding->isGroupProperty()) {
@@ -346,24 +349,24 @@ QVector<QQmlJS::DiagnosticMessage> QQmlPropertyValidator::validateObject(
customParser->validator = nullptr;
customParser->engine = nullptr;
customParser->imports = (QQmlImports*)nullptr;
- QVector<QQmlJS::DiagnosticMessage> parserErrors = customParser->errors();
+ QVector<QQmlError> parserErrors = customParser->errors();
if (!parserErrors.isEmpty())
return parserErrors;
}
(*bindingPropertyDataPerObject)[objectIndex] = collectedBindingPropertyData;
- QVector<QQmlJS::DiagnosticMessage> noError;
+ QVector<QQmlError> noError;
return noError;
}
-QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache *propertyCache, QQmlPropertyData *property, const QV4::CompiledData::Binding *binding) const
+QQmlError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache *propertyCache, QQmlPropertyData *property, const QV4::CompiledData::Binding *binding) const
{
if (property->isQList()) {
return qQmlCompileError(binding->valueLocation, tr("Cannot assign primitives to lists"));
}
- QQmlJS::DiagnosticMessage noError;
+ QQmlError noError;
if (property->isEnum()) {
if (binding->flags & QV4::CompiledData::Binding::IsResolvedEnum)
@@ -387,8 +390,8 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateLiteralBinding(QQmlProp
if (binding->type == QV4::CompiledData::Binding::Type_Null) {
QQmlError warning;
warning.setUrl(compilationUnit->url());
- warning.setLine(binding->valueLocation.line);
- warning.setColumn(binding->valueLocation.column);
+ warning.setLine(qmlConvertSourceCoordinate<quint32, int>(binding->valueLocation.line));
+ warning.setColumn(qmlConvertSourceCoordinate<quint32, int>(binding->valueLocation.column));
warning.setDescription(error + tr(" - Assigning null to incompatible properties in QML "
"is deprecated. This will become a compile error in "
"future versions of Qt."));
@@ -659,23 +662,23 @@ bool QQmlPropertyValidator::canCoerce(int to, QQmlPropertyCache *fromMo) const
return false;
}
-QVector<QQmlJS::DiagnosticMessage> QQmlPropertyValidator::recordError(const QV4::CompiledData::Location &location, const QString &description) const
+QVector<QQmlError> QQmlPropertyValidator::recordError(const QV4::CompiledData::Location &location, const QString &description) const
{
- QVector<QQmlJS::DiagnosticMessage> errors;
+ QVector<QQmlError> errors;
errors.append(qQmlCompileError(location, description));
return errors;
}
-QVector<QQmlJS::DiagnosticMessage> QQmlPropertyValidator::recordError(const QQmlJS::DiagnosticMessage &error) const
+QVector<QQmlError> QQmlPropertyValidator::recordError(const QQmlError &error) const
{
- QVector<QQmlJS::DiagnosticMessage> errors;
+ QVector<QQmlError> errors;
errors.append(error);
return errors;
}
-QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *property, const QString &propertyName, const QV4::CompiledData::Binding *binding) const
+QQmlError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *property, const QString &propertyName, const QV4::CompiledData::Binding *binding) const
{
- QQmlJS::DiagnosticMessage noError;
+ QQmlError noError;
if (binding->flags & QV4::CompiledData::Binding::IsOnAssignment) {
Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Object);
@@ -744,8 +747,8 @@ QQmlJS::DiagnosticMessage QQmlPropertyValidator::validateObjectBinding(QQmlPrope
// We want to use the raw metaObject here as the raw metaobject is the
// actual property type before we applied any extensions that might
// effect the properties on the type, but don't effect assignability
- // Using -1 for the minor version ensures that we get the raw metaObject.
- QQmlPropertyCache *propertyMetaObject = enginePrivate->rawPropertyCacheForType(propType, -1);
+ // Not passing a version ensures that we get the raw metaObject.
+ QQmlPropertyCache *propertyMetaObject = enginePrivate->rawPropertyCacheForType(propType);
if (propertyMetaObject) {
// Will be true if the assigned type inherits propertyMetaObject
diff --git a/src/qml/qml/qqmlpropertyvalidator_p.h b/src/qml/qml/qqmlpropertyvalidator_p.h
index 74a1281927..281472981c 100644
--- a/src/qml/qml/qqmlpropertyvalidator_p.h
+++ b/src/qml/qml/qqmlpropertyvalidator_p.h
@@ -66,25 +66,24 @@ class QQmlPropertyValidator
public:
QQmlPropertyValidator(QQmlEnginePrivate *enginePrivate, const QQmlImports &imports, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit);
- QVector<QQmlJS::DiagnosticMessage> validate();
+ QVector<QQmlError> validate();
private:
- QVector<QQmlJS::DiagnosticMessage> validateObject(
+ QVector<QQmlError> validateObject(
int objectIndex, const QV4::CompiledData::Binding *instantiatingBinding,
bool populatingValueTypeGroupProperty = false) const;
- QQmlJS::DiagnosticMessage validateLiteralBinding(
+ QQmlError validateLiteralBinding(
QQmlPropertyCache *propertyCache, QQmlPropertyData *property,
const QV4::CompiledData::Binding *binding) const;
- QQmlJS::DiagnosticMessage validateObjectBinding(
+ QQmlError validateObjectBinding(
QQmlPropertyData *property, const QString &propertyName,
const QV4::CompiledData::Binding *binding) const;
bool canCoerce(int to, QQmlPropertyCache *fromMo) const;
- Q_REQUIRED_RESULT QVector<QQmlJS::DiagnosticMessage> recordError(
+ Q_REQUIRED_RESULT QVector<QQmlError> recordError(
const QV4::CompiledData::Location &location, const QString &description) const;
- Q_REQUIRED_RESULT QVector<QQmlJS::DiagnosticMessage> recordError(
- const QQmlJS::DiagnosticMessage &error) const;
+ Q_REQUIRED_RESULT QVector<QQmlError> recordError(const QQmlError &error) const;
QString stringAt(int index) const { return compilationUnit->stringAt(index); }
QV4::ResolvedTypeReference *resolvedType(int id) const
{
diff --git a/src/qml/qml/qqmlscriptblob.cpp b/src/qml/qml/qqmlscriptblob.cpp
index eb103dc434..dac21f7ee7 100644
--- a/src/qml/qml/qqmlscriptblob.cpp
+++ b/src/qml/qml/qqmlscriptblob.cpp
@@ -41,6 +41,7 @@
#include <private/qqmlirbuilder_p.h>
#include <private/qqmlscriptblob_p.h>
#include <private/qqmlscriptdata_p.h>
+#include <private/qqmlsourcecoordinate_p.h>
#include <private/qv4runtimecodegen_p.h>
#include <private/qv4script_p.h>
@@ -167,8 +168,8 @@ void QQmlScriptBlob::done()
QList<QQmlError> errors = script.script->errors();
QQmlError error;
error.setUrl(url());
- error.setLine(script.location.line);
- error.setColumn(script.location.column);
+ error.setLine(qmlConvertSourceCoordinate<quint32, int>(script.location.line));
+ error.setColumn(qmlConvertSourceCoordinate<quint32, int>(script.location.column));
error.setDescription(QQmlTypeLoader::tr("Script %1 unavailable").arg(script.script->urlString()));
errors.prepend(error);
setError(errors);
diff --git a/src/qml/qml/qqmltype.cpp b/src/qml/qml/qqmltype.cpp
index 28fefca239..db22c93733 100644
--- a/src/qml/qml/qqmltype.cpp
+++ b/src/qml/qml/qqmltype.cpp
@@ -53,7 +53,7 @@
QT_BEGIN_NAMESPACE
QQmlTypePrivate::QQmlTypePrivate(QQmlType::RegistrationType type)
- : regType(type), iid(nullptr), typeId(0), listId(0), revision(0),
+ : regType(type), iid(nullptr), revision(QTypeRevision::zero()),
containsRevisionedAttributes(false), baseMetaObject(nullptr),
index(-1), isSetup(false), isEnumFromCacheSetup(false), isEnumFromBaseSetup(false),
haveSuperType(false)
@@ -132,34 +132,29 @@ QHashedString QQmlType::module() const
return d->module;
}
-int QQmlType::majorVersion() const
+QTypeRevision QQmlType::version() const
{
if (!d)
- return -1;
- return d->version_maj;
+ return QTypeRevision();
+ return d->version;
}
-int QQmlType::minorVersion() const
+bool QQmlType::availableInVersion(QTypeRevision version) const
{
- if (!d)
- return -1;
- return d->version_min;
-}
-
-bool QQmlType::availableInVersion(int vmajor, int vminor) const
-{
- Q_ASSERT(vmajor >= 0 && vminor >= 0);
+ Q_ASSERT(version.hasMajorVersion() && version.hasMinorVersion());
if (!d)
return false;
- return vmajor == d->version_maj && vminor >= d->version_min;
+ return version.majorVersion() == d->version.majorVersion()
+ && version.minorVersion() >= d->version.minorVersion();
}
-bool QQmlType::availableInVersion(const QHashedStringRef &module, int vmajor, int vminor) const
+bool QQmlType::availableInVersion(const QHashedStringRef &module, QTypeRevision version) const
{
- Q_ASSERT(vmajor >= 0 && vminor >= 0);
+ Q_ASSERT(version.hasMajorVersion() && version.hasMinorVersion());
if (!d)
return false;
- return module == d->module && vmajor == d->version_maj && vminor >= d->version_min;
+ return module == d->module && version.majorVersion() == d->version.majorVersion()
+ && version.minorVersion() >= d->version.minorVersion();
}
QQmlType QQmlTypePrivate::resolveCompositeBaseType(QQmlEnginePrivate *engine) const
@@ -592,14 +587,14 @@ bool QQmlType::isQJSValueSingleton() const
return d && d->regType == SingletonType && d->extraData.sd->singletonInstanceInfo->scriptCallback;
}
-int QQmlType::typeId() const
+QMetaType QQmlType::typeId() const
{
- return d ? d->typeId : -1;
+ return d ? d->typeId : QMetaType{};
}
-int QQmlType::qListTypeId() const
+QMetaType QQmlType::qListTypeId() const
{
- return d ? d->listId : -1;
+ return d ? d->listId : QMetaType{};
}
const QMetaObject *QQmlType::metaObject() const
@@ -629,21 +624,21 @@ bool QQmlType::containsRevisionedAttributes() const
return d->containsRevisionedAttributes;
}
-int QQmlType::metaObjectRevision() const
+QTypeRevision QQmlType::metaObjectRevision() const
{
- return d ? d->revision : -1;
+ return d ? d->revision : QTypeRevision();
}
QQmlAttachedPropertiesFunc QQmlType::attachedPropertiesFunction(QQmlEnginePrivate *engine) const
{
- if (const QQmlTypePrivate *base = d->attachedPropertiesBase(engine))
+ if (const QQmlTypePrivate *base = d ? d->attachedPropertiesBase(engine) : nullptr)
return base->extraData.cd->attachedPropertiesFunc;
return nullptr;
}
const QMetaObject *QQmlType::attachedPropertiesType(QQmlEnginePrivate *engine) const
{
- if (const QQmlTypePrivate *base = d->attachedPropertiesBase(engine))
+ if (const QQmlTypePrivate *base = d ? d->attachedPropertiesBase(engine) : nullptr)
return base->extraData.cd->attachedPropertiesType;
return nullptr;
}
@@ -946,7 +941,8 @@ int QQmlType::generatePlaceHolderICId() const
void QQmlType::associateInlineComponent(const QString &name, int objectID, const CompositeMetaTypeIds &metaTypeIds, QQmlType existingType)
{
- auto priv = existingType.isValid() ? const_cast<QQmlTypePrivate *>(existingType.d.data()) : new QQmlTypePrivate { RegistrationType::InlineComponentType } ;
+ bool const reuseExistingType = existingType.isValid();
+ auto priv = reuseExistingType ? const_cast<QQmlTypePrivate *>(existingType.d.data()) : new QQmlTypePrivate { RegistrationType::InlineComponentType } ;
priv->setName( QString::fromUtf8(typeName()), name);
auto icUrl = QUrl(sourceUrl());
icUrl.setFragment(QString::number(objectID));
@@ -958,6 +954,8 @@ void QQmlType::associateInlineComponent(const QString &name, int objectID, const
d->namesToInlineComponentObjectIndex.insert(name, objectID);
QQmlType icType(priv);
d->objectIdToICType.insert(objectID, icType);
+ if (!reuseExistingType)
+ priv->release();
}
void QQmlType::setPendingResolutionName(const QString &name)
diff --git a/src/qml/qml/qqmltype_p.h b/src/qml/qml/qqmltype_p.h
index 387baa74bb..2b37ec16be 100644
--- a/src/qml/qml/qqmltype_p.h
+++ b/src/qml/qml/qqmltype_p.h
@@ -60,6 +60,7 @@
#include <QtQml/qjsvalue.h>
#include <QtCore/qobject.h>
+#include <QtCore/qversionnumber.h>
QT_BEGIN_NAMESPACE
@@ -98,11 +99,10 @@ public:
QString elementName() const;
QHashedString module() const;
- int majorVersion() const;
- int minorVersion() const;
+ QTypeRevision version() const;
- bool availableInVersion(int vmajor, int vminor) const;
- bool availableInVersion(const QHashedStringRef &module, int vmajor, int vminor) const;
+ bool availableInVersion(QTypeRevision version) const;
+ bool availableInVersion(const QHashedStringRef &module, QTypeRevision version) const;
QObject *create() const;
void create(QObject **, void **, size_t) const;
@@ -124,12 +124,12 @@ public:
bool isQObjectSingleton() const;
bool isQJSValueSingleton() const;
- int typeId() const;
- int qListTypeId() const;
+ QMetaType typeId() const;
+ QMetaType qListTypeId() const;
const QMetaObject *metaObject() const;
const QMetaObject *baseMetaObject() const;
- int metaObjectRevision() const;
+ QTypeRevision metaObjectRevision() const;
bool containsRevisionedAttributes() const;
QQmlAttachedPropertiesFunc attachedPropertiesFunction(QQmlEnginePrivate *engine) const;
diff --git a/src/qml/qml/qqmltype_p_p.h b/src/qml/qml/qqmltype_p_p.h
index 43344827db..c94ac8c130 100644
--- a/src/qml/qml/qqmltype_p_p.h
+++ b/src/qml/qml/qqmltype_p_p.h
@@ -157,11 +157,10 @@ public:
QHashedString module;
QString name;
QString elementName;
- int version_maj;
- int version_min;
- int typeId;
- int listId;
- int revision;
+ QMetaType typeId;
+ QMetaType listId;
+ QTypeRevision version;
+ QTypeRevision revision;
mutable bool containsRevisionedAttributes;
mutable QQmlType superType;
const QMetaObject *baseMetaObject;
diff --git a/src/qml/qml/qqmltypecompiler.cpp b/src/qml/qml/qqmltypecompiler.cpp
index 842ca697e0..5c04abf367 100644
--- a/src/qml/qml/qqmltypecompiler.cpp
+++ b/src/qml/qml/qqmltypecompiler.cpp
@@ -82,7 +82,7 @@ QQmlRefPointer<QV4::ExecutableCompilationUnit> QQmlTypeCompiler::compile()
{
QQmlPropertyCacheCreator<QQmlTypeCompiler> propertyCacheBuilder(&m_propertyCaches, &pendingGroupPropertyBindings,
engine, this, imports(), typeData->typeClassName());
- QQmlJS::DiagnosticMessage error = propertyCacheBuilder.buildMetaObjects();
+ QQmlError error = propertyCacheBuilder.buildMetaObjects();
if (error.isValid()) {
recordError(error);
return nullptr;
@@ -174,8 +174,8 @@ QQmlRefPointer<QV4::ExecutableCompilationUnit> QQmlTypeCompiler::compile()
void QQmlTypeCompiler::recordError(const QV4::CompiledData::Location &location, const QString &description)
{
QQmlError error;
- error.setLine(location.line);
- error.setColumn(location.column);
+ error.setLine(qmlConvertSourceCoordinate<quint32, int>(location.line));
+ error.setColumn(qmlConvertSourceCoordinate<quint32, int>(location.column));
error.setDescription(description);
error.setUrl(url());
errors << error;
@@ -185,8 +185,15 @@ void QQmlTypeCompiler::recordError(const QQmlJS::DiagnosticMessage &message)
{
QQmlError error;
error.setDescription(message.message);
- error.setLine(message.line);
- error.setColumn(message.column);
+ error.setLine(qmlConvertSourceCoordinate<quint32, int>(message.loc.startLine));
+ error.setColumn(qmlConvertSourceCoordinate<quint32, int>(message.loc.startColumn));
+ error.setUrl(url());
+ errors << error;
+}
+
+void QQmlTypeCompiler::recordError(const QQmlError &e)
+{
+ QQmlError error = e;
error.setUrl(url());
errors << error;
}
@@ -257,7 +264,7 @@ QString QQmlTypeCompiler::bindingAsString(const QmlIR::Object *object, int scrip
return object->bindingAsString(document, scriptIndex);
}
-void QQmlTypeCompiler::addImport(const QString &module, const QString &qualifier, int majorVersion, int minorVersion)
+void QQmlTypeCompiler::addImport(const QString &module, const QString &qualifier, QTypeRevision version)
{
const quint32 moduleIdx = registerString(module);
const quint32 qualifierIdx = registerString(qualifier);
@@ -272,8 +279,7 @@ void QQmlTypeCompiler::addImport(const QString &module, const QString &qualifier
auto pool = memoryPool();
QV4::CompiledData::Import *import = pool->New<QV4::CompiledData::Import>();
import->type = QV4::CompiledData::Import::ImportLibrary;
- import->majorVersion = majorVersion;
- import->minorVersion = minorVersion;
+ import->version = version;
import->uriIndex = moduleIdx;
import->qualifierIndex = qualifierIdx;
document->imports.append(import);
@@ -394,7 +400,10 @@ bool SignalHandlerConverter::convertSignalHandlerExpressionsToFunctionDeclaratio
auto *typeRef = resolvedType(obj->inheritedTypeNameIndex);
const QQmlType type = typeRef ? typeRef->type : QQmlType();
if (type.isValid()) {
- COMPILE_EXCEPTION(binding, tr("\"%1.%2\" is not available in %3 %4.%5.").arg(typeName).arg(originalPropertyName).arg(type.module()).arg(type.majorVersion()).arg(type.minorVersion()));
+ COMPILE_EXCEPTION(binding, tr("\"%1.%2\" is not available in %3 %4.%5.")
+ .arg(typeName).arg(originalPropertyName).arg(type.module())
+ .arg(type.version().majorVersion())
+ .arg(type.version().minorVersion()));
} else {
COMPILE_EXCEPTION(binding, tr("\"%1.%2\" is not available due to component versioning.").arg(typeName).arg(originalPropertyName));
}
@@ -816,7 +825,12 @@ void QQmlComponentAndAliasResolver::findAndRegisterImplicitComponents(const QmlI
if (!pd || !pd->isQObject())
continue;
- QQmlPropertyCache *pc = enginePrivate->rawPropertyCacheForType(pd->propType(), pd->typeMinorVersion());
+ // If the version is given, use it and look up by QQmlType.
+ // Otherwise, make sure we look up by metaobject.
+ // TODO: Is this correct?
+ QQmlPropertyCache *pc = pd->typeVersion().hasMinorVersion()
+ ? enginePrivate->rawPropertyCacheForType(pd->propType(), pd->typeVersion())
+ : enginePrivate->rawPropertyCacheForType(pd->propType());
const QMetaObject *mo = pc ? pc->firstCppMetaObject() : nullptr;
while (mo) {
if (mo == &QQmlComponent::staticMetaObject)
@@ -832,7 +846,7 @@ void QQmlComponentAndAliasResolver::findAndRegisterImplicitComponents(const QmlI
Q_ASSERT(componentType.isValid());
const QString qualifier = QStringLiteral("QmlInternals");
- compiler->addImport(componentType.module(), qualifier, componentType.majorVersion(), componentType.minorVersion());
+ compiler->addImport(componentType.module(), qualifier, componentType.version());
QmlIR::Object *syntheticComponent = pool->New<QmlIR::Object>();
syntheticComponent->init(pool, compiler->registerString(qualifier + QLatin1Char('.') + componentType.elementName()), compiler->registerString(QString()));
@@ -842,8 +856,7 @@ void QQmlComponentAndAliasResolver::findAndRegisterImplicitComponents(const QmlI
if (!containsResolvedType(syntheticComponent->inheritedTypeNameIndex)) {
auto typeRef = new QV4::ResolvedTypeReference;
typeRef->type = componentType;
- typeRef->majorVersion = componentType.majorVersion();
- typeRef->minorVersion = componentType.minorVersion();
+ typeRef->version = componentType.version();
insertResolvedType(syntheticComponent->inheritedTypeNameIndex, typeRef);
}
@@ -875,6 +888,10 @@ bool QQmlComponentAndAliasResolver::resolve()
const int objCountWithoutSynthesizedComponents = qmlObjects->count();
for (int i = 0; i < objCountWithoutSynthesizedComponents; ++i) {
QmlIR::Object *obj = qmlObjects->at(i);
+ if (obj->isInlineComponent) {
+ componentRoots.append(i);
+ continue;
+ }
QQmlPropertyCache *cache = propertyCaches.at(i);
if (obj->inheritedTypeNameIndex == 0 && !cache)
continue;
@@ -930,7 +947,7 @@ bool QQmlComponentAndAliasResolver::resolve()
_objectsWithAliases.clear();
- if (!collectIdsAndAliases(rootBinding->value.objectIndex))
+ if (!collectIdsAndAliases(component->isInlineComponent ? componentRoots.at(i) : rootBinding->value.objectIndex))
return false;
component->namedObjectsInComponent.allocate(pool, _idToObjectIndex);
@@ -1006,7 +1023,7 @@ bool QQmlComponentAndAliasResolver::resolveAliases(int componentIndex)
for (int objectIndex: qAsConst(_objectsWithAliases)) {
- QQmlJS::DiagnosticMessage error;
+ QQmlError error;
const auto result = resolveAliasesInObject(objectIndex, &error);
if (error.isValid()) {
@@ -1015,7 +1032,7 @@ bool QQmlComponentAndAliasResolver::resolveAliases(int componentIndex)
}
if (result == AllAliasesResolved) {
- QQmlJS::DiagnosticMessage error = aliasCacheCreator.appendAliasesToPropertyCache(*qmlObjects->at(componentIndex), objectIndex, enginePrivate);
+ QQmlError error = aliasCacheCreator.appendAliasesToPropertyCache(*qmlObjects->at(componentIndex), objectIndex, enginePrivate);
if (error.isValid()) {
recordError(error);
return false;
@@ -1046,7 +1063,7 @@ bool QQmlComponentAndAliasResolver::resolveAliases(int componentIndex)
QQmlComponentAndAliasResolver::AliasResolutionResult
QQmlComponentAndAliasResolver::resolveAliasesInObject(int objectIndex,
- QQmlJS::DiagnosticMessage *error)
+ QQmlError *error)
{
const QmlIR::Object * const obj = qmlObjects->at(objectIndex);
if (!obj->aliasCount())
diff --git a/src/qml/qml/qqmltypecompiler_p.h b/src/qml/qml/qqmltypecompiler_p.h
index 319df8673b..883fbf0d68 100644
--- a/src/qml/qml/qqmltypecompiler_p.h
+++ b/src/qml/qml/qqmltypecompiler_p.h
@@ -100,7 +100,8 @@ public:
QList<QQmlError> compilationErrors() const { return errors; }
void recordError(const QV4::CompiledData::Location &location, const QString &description);
- void recordError(const QQmlJS::DiagnosticMessage &error);
+ void recordError(const QQmlJS::DiagnosticMessage &message);
+ void recordError(const QQmlError &e);
int registerString(const QString &str);
int registerConstant(QV4::ReturnedValue v);
@@ -124,7 +125,7 @@ public:
QString bindingAsString(const QmlIR::Object *object, int scriptIndex) const;
- void addImport(const QString &module, const QString &qualifier, int majorVersion, int minorVersion);
+ void addImport(const QString &module, const QString &qualifier, QTypeRevision version);
QV4::ResolvedTypeReference *resolvedType(int id) const
{
@@ -157,7 +158,7 @@ struct QQmlCompilePass
protected:
void recordError(const QV4::CompiledData::Location &location, const QString &description) const
{ compiler->recordError(location, description); }
- void recordError(const QQmlJS::DiagnosticMessage &error)
+ void recordError(const QQmlError &error)
{ compiler->recordError(error); }
QV4::ResolvedTypeReference *resolvedType(int id) const
@@ -280,7 +281,7 @@ protected:
AllAliasesResolved
};
- AliasResolutionResult resolveAliasesInObject(int objectIndex, QQmlJS::DiagnosticMessage *error);
+ AliasResolutionResult resolveAliasesInObject(int objectIndex, QQmlError *error);
QQmlEnginePrivate *enginePrivate;
QQmlJS::MemoryPool *pool;
diff --git a/src/qml/qml/qqmltypedata.cpp b/src/qml/qml/qqmltypedata.cpp
index f7abe67921..7b21edec37 100644
--- a/src/qml/qml/qqmltypedata.cpp
+++ b/src/qml/qml/qqmltypedata.cpp
@@ -182,8 +182,8 @@ bool QQmlTypeData::tryLoadFromDiskCache()
const QV4::CompiledData::Import *import = m_compiledData->importAt(i);
if (m_compiledData->stringAt(import->uriIndex) == QLatin1String(".")
&& import->qualifierIndex == 0
- && import->majorVersion == -1
- && import->minorVersion == -1) {
+ && !import->version.hasMajorVersion()
+ && !import->version.hasMinorVersion()) {
QList<QQmlError> errors;
auto pendingImport = std::make_shared<PendingImport>(this, import);
if (!fetchQmldir(qmldirUrl, pendingImport, 1, &errors)) {
@@ -203,8 +203,8 @@ bool QQmlTypeData::tryLoadFromDiskCache()
Q_ASSERT(errors.size());
QQmlError error(errors.takeFirst());
error.setUrl(m_importCache.baseUrl());
- error.setLine(import->location.line);
- error.setColumn(import->location.column);
+ error.setLine(qmlConvertSourceCoordinate<quint32, int>(import->location.line));
+ error.setColumn(qmlConvertSourceCoordinate<quint32, int>(import->location.column));
errors.prepend(error); // put it back on the list after filling out information.
setError(errors);
return false;
@@ -213,9 +213,9 @@ bool QQmlTypeData::tryLoadFromDiskCache()
QQmlType containingType;
auto containingTypeName = finalUrl().fileName().split(QLatin1Char('.')).first();
- int major = -1, minor = -1;
+ QTypeRevision version;
QQmlImportNamespace *ns = nullptr;
- m_importCache.resolveType(containingTypeName, &containingType, &major, &minor, &ns);
+ m_importCache.resolveType(containingTypeName, &containingType, &version, &ns);
for (auto&& ic: ics) {
QString const nameString = m_compiledData->stringAt(ic.nameIndex);
QByteArray const name = nameString.toUtf8();
@@ -244,7 +244,7 @@ void QQmlTypeData::createTypeAndPropertyCaches(
QQmlPropertyCacheCreator<QV4::ExecutableCompilationUnit> propertyCacheCreator(
&m_compiledData->propertyCaches, &pendingGroupPropertyBindings, engine,
m_compiledData.data(), &m_importCache, typeClassName());
- QQmlJS::DiagnosticMessage error = propertyCacheCreator.buildMetaObjects();
+ QQmlError error = propertyCacheCreator.buildMetaObjects();
if (error.isValid()) {
setError(error);
return;
@@ -325,8 +325,8 @@ void QQmlTypeData::done()
QList<QQmlError> errors = script.script->errors();
QQmlError error;
error.setUrl(url());
- error.setLine(script.location.line);
- error.setColumn(script.location.column);
+ error.setLine(qmlConvertSourceCoordinate<quint32, int>(script.location.line));
+ error.setColumn(qmlConvertSourceCoordinate<quint32, int>(script.location.column));
error.setDescription(QQmlTypeLoader::tr("Script %1 unavailable").arg(script.script->urlString()));
errors.prepend(error);
setError(errors);
@@ -349,8 +349,8 @@ void QQmlTypeData::done()
QList<QQmlError> errors = type.typeData ? type.typeData->errors() : QList<QQmlError>{};
QQmlError error;
error.setUrl(url());
- error.setLine(type.location.line);
- error.setColumn(type.location.column);
+ error.setLine(qmlConvertSourceCoordinate<quint32, int>(type.location.line));
+ error.setColumn(qmlConvertSourceCoordinate<quint32, int>(type.location.column));
error.setDescription(QQmlTypeLoader::tr("Type %1 has no inline component type called %2").arg(typeName.leftRef(lastDot), type.type.pendingResolutionName()));
errors.prepend(error);
setError(errors);
@@ -365,8 +365,8 @@ void QQmlTypeData::done()
QList<QQmlError> errors = type.typeData->errors();
QQmlError error;
error.setUrl(url());
- error.setLine(type.location.line);
- error.setColumn(type.location.column);
+ error.setLine(qmlConvertSourceCoordinate<quint32, int>(type.location.line));
+ error.setColumn(qmlConvertSourceCoordinate<quint32, int>(type.location.column));
error.setDescription(QQmlTypeLoader::tr("Type %1 unavailable").arg(typeName));
errors.prepend(error);
setError(errors);
@@ -384,8 +384,8 @@ void QQmlTypeData::done()
QList<QQmlError> errors = type.typeData->errors();
QQmlError error;
error.setUrl(url());
- error.setLine(type.location.line);
- error.setColumn(type.location.column);
+ error.setLine(qmlConvertSourceCoordinate<quint32, int>(type.location.line));
+ error.setColumn(qmlConvertSourceCoordinate<quint32, int>(type.location.column));
error.setDescription(QQmlTypeLoader::tr("Type %1 unavailable").arg(typeName));
errors.prepend(error);
setError(errors);
@@ -414,7 +414,7 @@ void QQmlTypeData::done()
QV4::ResolvedTypeReferenceMap resolvedTypeCache;
QQmlRefPointer<QQmlTypeNameCache> typeNameCache;
{
- QQmlJS::DiagnosticMessage error = buildTypeResolutionCaches(&typeNameCache, &resolvedTypeCache);
+ QQmlError error = buildTypeResolutionCaches(&typeNameCache, &resolvedTypeCache);
if (error.isValid()) {
setError(error);
qDeleteAll(resolvedTypeCache);
@@ -461,7 +461,7 @@ void QQmlTypeData::done()
{
// Sanity check property bindings
QQmlPropertyValidator validator(enginePrivate, m_importCache, m_compiledData);
- QVector<QQmlJS::DiagnosticMessage> errors = validator.validate();
+ QVector<QQmlError> errors = validator.validate();
if (!errors.isEmpty()) {
setError(errors);
return;
@@ -625,8 +625,8 @@ bool QQmlTypeData::loadFromSource()
for (const QQmlJS::DiagnosticMessage &msg : qAsConst(compiler.errors)) {
QQmlError e;
e.setUrl(url());
- e.setLine(msg.line);
- e.setColumn(msg.column);
+ e.setLine(qmlConvertSourceCoordinate<quint32, int>(msg.loc.startLine));
+ e.setColumn(qmlConvertSourceCoordinate<quint32, int>(msg.loc.startColumn));
e.setDescription(msg.message);
errors << e;
}
@@ -651,9 +651,9 @@ void QQmlTypeData::continueLoadFromIR()
{
QQmlType containingType;
auto containingTypeName = finalUrl().fileName().split(QLatin1Char('.')).first();
- int major = -1, minor = -1;
+ QTypeRevision version;
QQmlImportNamespace *ns = nullptr;
- m_importCache.resolveType(containingTypeName, &containingType, &major, &minor, &ns);
+ m_importCache.resolveType(containingTypeName, &containingType, &version, &ns);
for (auto const& object: m_document->objects) {
for (auto it = object->inlineComponentsBegin(); it != object->inlineComponentsEnd(); ++it) {
QString const nameString = m_document->stringAt(it->nameIndex);
@@ -679,8 +679,7 @@ void QQmlTypeData::continueLoadFromIR()
// This qmldir is for the implicit import
auto implicitImport = std::make_shared<PendingImport>();
implicitImport->uri = QLatin1String(".");
- implicitImport->majorVersion = -1;
- implicitImport->minorVersion = -1;
+ implicitImport->version = QTypeRevision();
QList<QQmlError> errors;
if (!fetchQmldir(qmldirUrl, implicitImport, 1, &errors)) {
@@ -697,8 +696,8 @@ void QQmlTypeData::continueLoadFromIR()
Q_ASSERT(errors.size());
QQmlError error(errors.takeFirst());
error.setUrl(m_importCache.baseUrl());
- error.setLine(import->location.line);
- error.setColumn(import->location.column);
+ error.setLine(qmlConvertSourceCoordinate<quint32, int>(import->location.line));
+ error.setColumn(qmlConvertSourceCoordinate<quint32, int>(import->location.column));
errors.prepend(error); // put it back on the list after filling out information.
setError(errors);
return;
@@ -724,8 +723,8 @@ void QQmlTypeData::allDependenciesDone()
QQmlError error;
error.setDescription(QQmlTypeLoader::tr("module \"%1\" is not installed").arg(import->uri));
error.setUrl(m_importCache.baseUrl());
- error.setLine(import->location.line);
- error.setColumn(import->location.column);
+ error.setLine(qmlConvertSourceCoordinate<quint32, int>(import->location.line));
+ error.setColumn(qmlConvertSourceCoordinate<quint32, int>(import->location.column));
errors.prepend(error);
}
}
@@ -824,17 +823,15 @@ void QQmlTypeData::resolveTypes()
typeName = csRef.typeName;
}
- int majorVersion = csRef.majorVersion > -1 ? csRef.majorVersion : -1;
- int minorVersion = csRef.minorVersion > -1 ? csRef.minorVersion : -1;
-
- if (!resolveType(typeName, majorVersion, minorVersion, ref, -1, -1, true,
- QQmlType::CompositeSingletonType))
+ QTypeRevision version = csRef.version;
+ if (!resolveType(typeName, version, ref, -1, -1, true, QQmlType::CompositeSingletonType))
return;
if (ref.type.isCompositeSingleton()) {
ref.typeData = typeLoader()->getType(ref.type.sourceUrl());
- if (ref.typeData->status() == QQmlDataBlob::ResolvingDependencies || m_waitingOnMe.contains(ref.typeData.data())) {
- // TODO: give an error message? If so, we should record and show the path of the cycle.
+ if (ref.typeData->isWaiting() || m_waitingOnMe.contains(ref.typeData.data())) {
+ qWarning() << "Cyclic dependency detected between" << ref.typeData->urlString()
+ << "and" << urlString();
continue;
}
addDependency(ref.typeData.data());
@@ -851,14 +848,13 @@ void QQmlTypeData::resolveTypes()
const bool reportErrors = unresolvedRef->errorWhenNotFound;
- int majorVersion = -1;
- int minorVersion = -1;
+ QTypeRevision version;
const QString name = stringAt(unresolvedRef.key());
bool *selfReferenceDetection = unresolvedRef->needsCreation ? nullptr : &ref.selfReference;
- if (!resolveType(name, majorVersion, minorVersion, ref, unresolvedRef->location.line,
+ if (!resolveType(name, version, ref, unresolvedRef->location.line,
unresolvedRef->location.column, reportErrors,
QQmlType::AnyRegistrationType, selfReferenceDetection) && reportErrors)
return;
@@ -878,8 +874,7 @@ void QQmlTypeData::resolveTypes()
}
}
}
- ref.majorVersion = majorVersion;
- ref.minorVersion = minorVersion;
+ ref.version = version;
ref.location.line = unresolvedRef->location.line;
ref.location.column = unresolvedRef->location.column;
@@ -893,7 +888,7 @@ void QQmlTypeData::resolveTypes()
loadImplicitImport();
}
-QQmlJS::DiagnosticMessage QQmlTypeData::buildTypeResolutionCaches(
+QQmlError QQmlTypeData::buildTypeResolutionCaches(
QQmlRefPointer<QQmlTypeNameCache> *typeNameCache,
QV4::ResolvedTypeReferenceMap *resolvedTypeCache
) const
@@ -939,7 +934,8 @@ QQmlJS::DiagnosticMessage QQmlTypeData::buildTypeResolutionCaches(
ref->type = qmlType;
if (qmlType.isValid()) {
// this is required for inline components in singletons
- auto typeID = qmlType.lookupInlineComponentById(qmlType.inlineComponendId()).typeId();
+ auto type = qmlType.lookupInlineComponentById(qmlType.inlineComponendId()).typeId();
+ auto typeID = type.isValid() ? type.id() : -1;
auto exUnit = engine->obtainExecutableCompilationUnit(typeID);
if (exUnit) {
ref->compilationUnit = exUnit;
@@ -962,21 +958,18 @@ QQmlJS::DiagnosticMessage QQmlTypeData::buildTypeResolutionCaches(
return qQmlCompileError(resolvedType->location, reason);
}
- if (ref->type.containsRevisionedAttributes()) {
- ref->typePropertyCache = engine->cache(ref->type,
- resolvedType->minorVersion);
- }
+ if (ref->type.containsRevisionedAttributes())
+ ref->typePropertyCache = engine->cache(ref->type, resolvedType->version);
}
- ref->majorVersion = resolvedType->majorVersion;
- ref->minorVersion = resolvedType->minorVersion;
+ ref->version = resolvedType->version;
ref->doDynamicTypeCheck();
resolvedTypeCache->insert(resolvedType.key(), ref.take());
}
- QQmlJS::DiagnosticMessage noError;
+ QQmlError noError;
return noError;
}
-bool QQmlTypeData::resolveType(const QString &typeName, int &majorVersion, int &minorVersion,
+bool QQmlTypeData::resolveType(const QString &typeName, QTypeRevision &version,
TypeReference &ref, int lineNumber, int columnNumber,
bool reportErrors, QQmlType::RegistrationType registrationType,
bool *typeRecursionDetected)
@@ -984,7 +977,7 @@ bool QQmlTypeData::resolveType(const QString &typeName, int &majorVersion, int &
QQmlImportNamespace *typeNamespace = nullptr;
QList<QQmlError> errors;
- bool typeFound = m_importCache.resolveType(typeName, &ref.type, &majorVersion, &minorVersion,
+ bool typeFound = m_importCache.resolveType(typeName, &ref.type, &version,
&typeNamespace, &errors, registrationType,
typeRecursionDetected);
if (!typeNamespace && !typeFound && !m_implicitImportLoaded) {
@@ -992,7 +985,7 @@ bool QQmlTypeData::resolveType(const QString &typeName, int &majorVersion, int &
if (loadImplicitImport()) {
// Try again to find the type
errors.clear();
- typeFound = m_importCache.resolveType(typeName, &ref.type, &majorVersion, &minorVersion,
+ typeFound = m_importCache.resolveType(typeName, &ref.type, &version,
&typeNamespace, &errors, registrationType,
typeRecursionDetected);
} else {
diff --git a/src/qml/qml/qqmltypedata_p.h b/src/qml/qml/qqmltypedata_p.h
index d894090b36..c3b0faa5b4 100644
--- a/src/qml/qml/qqmltypedata_p.h
+++ b/src/qml/qml/qqmltypedata_p.h
@@ -62,12 +62,11 @@ class Q_AUTOTEST_EXPORT QQmlTypeData : public QQmlTypeLoader::Blob
public:
struct TypeReference
{
- TypeReference() : majorVersion(0), minorVersion(0), needsCreation(true) {}
+ TypeReference() : version(QTypeRevision::zero()), needsCreation(true) {}
QV4::CompiledData::Location location;
QQmlType type;
- int majorVersion;
- int minorVersion;
+ QTypeRevision version;
QQmlRefPointer<QQmlTypeData> typeData;
bool selfReference = false;
QString prefix; // used by CompositeSingleton types
@@ -125,7 +124,7 @@ private:
void restoreIR(QV4::CompiledData::CompilationUnit &&unit);
void continueLoadFromIR();
void resolveTypes();
- QQmlJS::DiagnosticMessage buildTypeResolutionCaches(
+ QQmlError buildTypeResolutionCaches(
QQmlRefPointer<QQmlTypeNameCache> *typeNameCache,
QV4::ResolvedTypeReferenceMap *resolvedTypeCache
) const;
@@ -134,7 +133,7 @@ private:
const QV4::CompiledData::DependentTypesHasher &dependencyHasher);
void createTypeAndPropertyCaches(const QQmlRefPointer<QQmlTypeNameCache> &typeNameCache,
const QV4::ResolvedTypeReferenceMap &resolvedTypeCache);
- bool resolveType(const QString &typeName, int &majorVersion, int &minorVersion,
+ bool resolveType(const QString &typeName, QTypeRevision &version,
TypeReference &ref, int lineNumber = -1, int columnNumber = -1,
bool reportErrors = true,
QQmlType::RegistrationType registrationType = QQmlType::AnyRegistrationType,
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index e9a38945fa..75dc9d15a5 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -45,6 +45,7 @@
#include <private/qqmltypedata_p.h>
#include <private/qqmltypeloaderqmldircontent_p.h>
#include <private/qqmltypeloaderthread_p.h>
+#include <private/qqmlsourcecoordinate_p.h>
#include <QtQml/qqmlabstracturlinterceptor.h>
#include <QtQml/qqmlengine.h>
@@ -357,8 +358,8 @@ void QQmlTypeLoader::networkReplyFinished(QNetworkReply *reply)
}
}
- if (reply->networkError()) {
- blob->networkError(reply->networkError());
+ if (reply->error()) {
+ blob->networkError(reply->error());
} else {
QByteArray data = reply->readAll();
setData(blob, data);
@@ -393,7 +394,7 @@ QQmlEngine *QQmlTypeLoader::engine() const
return m_engine;
}
-/*!
+/*! \internal
Call the initializeEngine() method on \a iface. Used by QQmlImportDatabase to ensure it
gets called in the correct thread.
*/
@@ -487,8 +488,7 @@ QQmlTypeLoader::Blob::PendingImport::PendingImport(QQmlTypeLoader::Blob *blob, c
type = static_cast<QV4::CompiledData::Import::ImportType>(quint32(import->type));
uri = blob->stringAt(import->uriIndex);
qualifier = blob->stringAt(import->qualifierIndex);
- majorVersion = import->majorVersion;
- minorVersion = import->minorVersion;
+ version = import->version;
location = import->location;
}
@@ -578,12 +578,13 @@ bool QQmlTypeLoader::Blob::addImport(QQmlTypeLoader::Blob::PendingImportPtr impo
QString qmldirUrl;
const QQmlImports::LocalQmldirResult qmldirResult = m_importCache.locateLocalQmldir(
- importDatabase, import->uri, import->majorVersion, import->minorVersion,
+ importDatabase, import->uri, import->version,
&qmldirFilePath, &qmldirUrl);
if (qmldirResult == QQmlImports::QmldirFound) {
// This is a local library import
- if (!m_importCache.addLibraryImport(importDatabase, import->uri, import->qualifier, import->majorVersion,
- import->minorVersion, qmldirFilePath, qmldirUrl, false, errors))
+ if (!m_importCache.addLibraryImport(
+ importDatabase, import->uri, import->qualifier,
+ import->version, qmldirFilePath, qmldirUrl, false, errors))
return false;
if (!loadImportDependencies(import, qmldirFilePath, errors))
@@ -602,49 +603,59 @@ bool QQmlTypeLoader::Blob::addImport(QQmlTypeLoader::Blob::PendingImportPtr impo
scriptImported(blob, import->location, script.nameSpace, import->qualifier);
}
}
+ } else if (
+ // Major version of module already registered:
+ // We believe that the registration is complete.
+ QQmlMetaType::typeModule(import->uri, import->version)
+
+ // Otherwise, try to register further module types.
+ || (qmldirResult != QQmlImports::QmldirInterceptedToRemote
+ && QQmlMetaType::qmlRegisterModuleTypes(import->uri))
+
+ // Otherwise, there is no way to register any further types.
+ // Try with any module of that name.
+ || QQmlMetaType::isAnyModule(import->uri)) {
+
+ if (!m_importCache.addLibraryImport(
+ importDatabase, import->uri, import->qualifier, import->version,
+ QString(), QString(), false, errors)) {
+ return false;
+ }
} else {
- // Is this a module?
- if (QQmlMetaType::isAnyModule(import->uri)
- || (qmldirResult != QQmlImports::QmldirInterceptedToRemote
- && QQmlMetaType::qmlRegisterModuleTypes(import->uri,
- import->majorVersion))) {
- if (!m_importCache.addLibraryImport(importDatabase, import->uri, import->qualifier, import->majorVersion,
- import->minorVersion, QString(), QString(), false, errors))
+ // We haven't yet resolved this import
+ m_unresolvedImports << import;
+
+ QQmlAbstractUrlInterceptor *interceptor = typeLoader()->engine()->urlInterceptor();
+
+ // Query any network import paths for this library.
+ // Interceptor might redirect local paths.
+ QStringList remotePathList = importDatabase->importPathList(
+ interceptor ? QQmlImportDatabase::LocalOrRemote
+ : QQmlImportDatabase::Remote);
+ if (!remotePathList.isEmpty()) {
+ // Add this library and request the possible locations for it
+ if (!m_importCache.addLibraryImport(
+ importDatabase, import->uri, import->qualifier, import->version,
+ QString(), QString(), true, errors))
return false;
- } else {
- // We haven't yet resolved this import
- m_unresolvedImports << import;
-
- QQmlAbstractUrlInterceptor *interceptor = typeLoader()->engine()->urlInterceptor();
-
- // Query any network import paths for this library.
- // Interceptor might redirect local paths.
- QStringList remotePathList = importDatabase->importPathList(
- interceptor ? QQmlImportDatabase::LocalOrRemote
- : QQmlImportDatabase::Remote);
- if (!remotePathList.isEmpty()) {
- // Add this library and request the possible locations for it
- if (!m_importCache.addLibraryImport(importDatabase, import->uri, import->qualifier, import->majorVersion,
- import->minorVersion, QString(), QString(), true, errors))
- return false;
- // Probe for all possible locations
- int priority = 0;
- const QStringList qmlDirPaths = QQmlImports::completeQmldirPaths(import->uri, remotePathList, import->majorVersion, import->minorVersion);
- for (const QString &qmldirPath : qmlDirPaths) {
- if (interceptor) {
- QUrl url = interceptor->intercept(
- QQmlImports::urlFromLocalFileOrQrcOrUrl(qmldirPath),
- QQmlAbstractUrlInterceptor::QmldirFile);
- if (!QQmlFile::isLocalFile(url)
- && !fetchQmldir(url, import, ++priority, errors)) {
- return false;
- }
- } else if (!fetchQmldir(QUrl(qmldirPath), import, ++priority, errors)) {
+ // Probe for all possible locations
+ int priority = 0;
+ const QStringList qmlDirPaths = QQmlImports::completeQmldirPaths(
+ import->uri, remotePathList, import->version);
+ for (const QString &qmldirPath : qmlDirPaths) {
+ if (interceptor) {
+ QUrl url = interceptor->intercept(
+ QQmlImports::urlFromLocalFileOrQrcOrUrl(qmldirPath),
+ QQmlAbstractUrlInterceptor::QmldirFile);
+ if (!QQmlFile::isLocalFile(url)
+ && !fetchQmldir(url, import, ++priority, errors)) {
return false;
}
-
+ } else if (!fetchQmldir(QUrl(qmldirPath), import, ++priority, errors)) {
+ return false;
}
+
}
}
}
@@ -663,8 +674,8 @@ bool QQmlTypeLoader::Blob::addImport(QQmlTypeLoader::Blob::PendingImportPtr impo
incomplete = true;
}
- if (!m_importCache.addFileImport(importDatabase, import->uri, import->qualifier, import->majorVersion,
- import->minorVersion, incomplete, errors))
+ if (!m_importCache.addFileImport(importDatabase, import->uri, import->qualifier,
+ import->version, incomplete, errors))
return false;
if (incomplete) {
@@ -688,8 +699,8 @@ void QQmlTypeLoader::Blob::dependencyComplete(QQmlDataBlob *blob)
Q_ASSERT(errors.size());
QQmlError error(errors.takeFirst());
error.setUrl(m_importCache.baseUrl());
- error.setLine(import->location.line);
- error.setColumn(import->location.column);
+ error.setLine(qmlConvertSourceCoordinate<quint32, int>(import->location.line));
+ error.setColumn(qmlConvertSourceCoordinate<quint32, int>(import->location.column));
errors.prepend(error); // put it back on the list after filling out information.
setError(errors);
}
@@ -703,8 +714,7 @@ bool QQmlTypeLoader::Blob::loadImportDependencies(PendingImportPtr currentImport
auto dependencyImport = std::make_shared<PendingImport>();
dependencyImport->uri = implicitImports;
dependencyImport->qualifier = currentImport->qualifier;
- dependencyImport->majorVersion = currentImport->majorVersion;
- dependencyImport->minorVersion = currentImport->minorVersion;
+ dependencyImport->version = currentImport->version;
if (!addImport(dependencyImport, errors))
return false;
}
diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h
index adecf61896..a1ba2967e3 100644
--- a/src/qml/qml/qqmltypeloader_p.h
+++ b/src/qml/qml/qqmltypeloader_p.h
@@ -97,8 +97,7 @@ public:
QString uri;
QString qualifier;
- int majorVersion = -1;
- int minorVersion = -1;
+ QTypeRevision version;
QV4::CompiledData::Location location;
diff --git a/src/qml/qml/qqmltypeloaderqmldircontent.cpp b/src/qml/qml/qqmltypeloaderqmldircontent.cpp
index 860971d296..714ea79e67 100644
--- a/src/qml/qml/qqmltypeloaderqmldircontent.cpp
+++ b/src/qml/qml/qqmltypeloaderqmldircontent.cpp
@@ -38,6 +38,7 @@
****************************************************************************/
#include <private/qqmltypeloaderqmldircontent_p.h>
+#include <private/qqmlsourcecoordinate_p.h>
#include <QtQml/qqmlerror.h>
QT_BEGIN_NAMESPACE
@@ -59,8 +60,8 @@ QList<QQmlError> QQmlTypeLoaderQmldirContent::errors(const QString &uri) const
for (const auto &parseError : parseErrors) {
QQmlError error;
error.setUrl(url);
- error.setLine(parseError.line);
- error.setColumn(parseError.column);
+ error.setLine(qmlConvertSourceCoordinate<quint32, int>(parseError.loc.startLine));
+ error.setColumn(qmlConvertSourceCoordinate<quint32, int>(parseError.loc.startColumn));
error.setDescription(parseError.message);
errors.append(error);
}
@@ -83,8 +84,8 @@ void QQmlTypeLoaderQmldirContent::setContent(const QString &location, const QStr
void QQmlTypeLoaderQmldirContent::setError(const QQmlError &error)
{
QQmlJS::DiagnosticMessage parseError;
- parseError.line = error.line();
- parseError.column = error.column();
+ parseError.loc.startLine = error.line();
+ parseError.loc.startColumn = error.column();
parseError.message = error.description();
m_parser.setError(parseError);
}
diff --git a/src/qml/qml/qqmltypemodule.cpp b/src/qml/qml/qqmltypemodule.cpp
index 9d6f269030..e6bf796d74 100644
--- a/src/qml/qml/qqmltypemodule.cpp
+++ b/src/qml/qml/qqmltypemodule.cpp
@@ -45,7 +45,7 @@
QT_BEGIN_NAMESPACE
-QQmlTypeModule::QQmlTypeModule(const QString &module, int majorVersion)
+QQmlTypeModule::QQmlTypeModule(const QString &module, quint8 majorVersion)
: d(new QQmlTypeModulePrivate(module, majorVersion))
{
}
@@ -61,23 +61,23 @@ QString QQmlTypeModule::module() const
return d->module;
}
-int QQmlTypeModule::majorVersion() const
+quint8 QQmlTypeModule::majorVersion() const
{
// No need to lock. d->majorVersion is const
return d->majorVersion;
}
-int QQmlTypeModule::minimumMinorVersion() const
+quint8 QQmlTypeModule::minimumMinorVersion() const
{
return d->minMinorVersion.loadRelaxed();
}
-int QQmlTypeModule::maximumMinorVersion() const
+quint8 QQmlTypeModule::maximumMinorVersion() const
{
return d->maxMinorVersion.loadRelaxed();
}
-void QQmlTypeModule::addMinorVersion(int version)
+void QQmlTypeModule::addMinorVersion(quint8 version)
{
for (int oldVersion = d->minMinorVersion.loadRelaxed();
oldVersion > version && !d->minMinorVersion.testAndSetOrdered(oldVersion, version);
@@ -93,16 +93,16 @@ void QQmlTypeModule::addMinorVersion(int version)
void QQmlTypeModule::add(QQmlTypePrivate *type)
{
QMutexLocker lock(&d->mutex);
- addMinorVersion(type->version_min);
+ addMinorVersion(type->version.minorVersion());
QList<QQmlTypePrivate *> &list = d->typeHash[type->elementName];
for (int ii = 0; ii < list.count(); ++ii) {
QQmlTypePrivate *in_list = list.at(ii);
Q_ASSERT(in_list);
- if (in_list->version_min < type->version_min) {
+ if (in_list->version.minorVersion() < type->version.minorVersion()) {
list.insert(ii, type);
return;
- } else if (in_list->version_min == type->version_min) {
+ } else if (in_list->version.minorVersion() == type->version.minorVersion()) {
list[ii] = type;
return;
}
@@ -137,26 +137,26 @@ void QQmlTypeModule::lock()
d->locked.storeRelaxed(1);
}
-QQmlType QQmlTypeModule::type(const QHashedStringRef &name, int minor) const
+QQmlType QQmlTypeModule::type(const QHashedStringRef &name, QTypeRevision version) const
{
QMutexLocker lock(&d->mutex);
QList<QQmlTypePrivate *> *types = d->typeHash.value(name);
if (types) {
for (int ii = 0; ii < types->count(); ++ii)
- if (types->at(ii)->version_min <= minor)
+ if (types->at(ii)->version.minorVersion() <= version.minorVersion())
return QQmlType(types->at(ii));
}
return QQmlType();
}
-QQmlType QQmlTypeModule::type(const QV4::String *name, int minor) const
+QQmlType QQmlTypeModule::type(const QV4::String *name, QTypeRevision version) const
{
QMutexLocker lock(&d->mutex);
QList<QQmlTypePrivate *> *types = d->typeHash.value(name);
if (types) {
for (int ii = 0; ii < types->count(); ++ii)
- if (types->at(ii)->version_min <= minor)
+ if (types->at(ii)->version.minorVersion() <= version.minorVersion())
return QQmlType(types->at(ii));
}
diff --git a/src/qml/qml/qqmltypemodule_p.h b/src/qml/qml/qqmltypemodule_p.h
index b84a91b5db..d3149567a3 100644
--- a/src/qml/qml/qqmltypemodule_p.h
+++ b/src/qml/qml/qqmltypemodule_p.h
@@ -53,6 +53,7 @@
#include <QtQml/qtqmlglobal.h>
#include <QtCore/qstring.h>
+#include <QtCore/qversionnumber.h>
#include <functional>
@@ -72,7 +73,7 @@ class QQmlTypeModulePrivate;
class QQmlTypeModule
{
public:
- QQmlTypeModule(const QString &uri = QString(), int majorVersion = 0);
+ QQmlTypeModule(const QString &uri = QString(), quint8 majorVersion = 0);
~QQmlTypeModule();
void add(QQmlTypePrivate *);
@@ -82,14 +83,14 @@ public:
void lock();
QString module() const;
- int majorVersion() const;
+ quint8 majorVersion() const;
- void addMinorVersion(int minorVersion);
- int minimumMinorVersion() const;
- int maximumMinorVersion() const;
+ void addMinorVersion(quint8 minorVersion);
+ quint8 minimumMinorVersion() const;
+ quint8 maximumMinorVersion() const;
- QQmlType type(const QHashedStringRef &, int) const;
- QQmlType type(const QV4::String *, int) const;
+ QQmlType type(const QHashedStringRef &, QTypeRevision version) const;
+ QQmlType type(const QV4::String *, QTypeRevision version) const;
void walkCompositeSingletons(const std::function<void(const QQmlType &)> &callback) const;
diff --git a/src/qml/qml/qqmltypemodule_p_p.h b/src/qml/qml/qqmltypemodule_p_p.h
index b1dab1c4a0..5d4d2e458a 100644
--- a/src/qml/qml/qqmltypemodule_p_p.h
+++ b/src/qml/qml/qqmltypemodule_p_p.h
@@ -62,15 +62,15 @@ QT_BEGIN_NAMESPACE
class QQmlTypeModulePrivate
{
public:
- QQmlTypeModulePrivate(QString module, int majorVersion) :
+ QQmlTypeModulePrivate(QString module, quint8 majorVersion) :
module(std::move(module)), majorVersion(majorVersion)
{}
const QString module;
- const int majorVersion = 0;
+ const quint8 majorVersion = 0;
// Can only ever decrease
- QAtomicInt minMinorVersion = std::numeric_limits<int>::max();
+ QAtomicInt minMinorVersion = std::numeric_limits<quint8>::max();
// Can only ever increase
QAtomicInt maxMinorVersion = 0;
diff --git a/src/qml/qml/qqmltypemoduleversion.cpp b/src/qml/qml/qqmltypemoduleversion.cpp
index bbbfa1a7b6..207b77770a 100644
--- a/src/qml/qml/qqmltypemoduleversion.cpp
+++ b/src/qml/qml/qqmltypemoduleversion.cpp
@@ -49,11 +49,11 @@ QQmlTypeModuleVersion::QQmlTypeModuleVersion()
{
}
-QQmlTypeModuleVersion::QQmlTypeModuleVersion(QQmlTypeModule *module, int minor)
- : m_module(module), m_minor(minor)
+QQmlTypeModuleVersion::QQmlTypeModuleVersion(QQmlTypeModule *module, QTypeRevision version)
+ : m_module(module), m_minor(version.minorVersion())
{
Q_ASSERT(m_module);
- Q_ASSERT(m_minor >= 0);
+ Q_ASSERT(QTypeRevision::isValidSegment(m_minor));
}
QQmlTypeModuleVersion::QQmlTypeModuleVersion(const QQmlTypeModuleVersion &o)
@@ -68,28 +68,18 @@ QQmlTypeModuleVersion &QQmlTypeModuleVersion::operator=(const QQmlTypeModuleVers
return *this;
}
-QQmlTypeModule *QQmlTypeModuleVersion::module() const
-{
- return m_module;
-}
-
-int QQmlTypeModuleVersion::minorVersion() const
-{
- return m_minor;
-}
-
QQmlType QQmlTypeModuleVersion::type(const QHashedStringRef &name) const
{
if (!m_module)
return QQmlType();
- return m_module->type(name, m_minor);
+ return m_module->type(name, QTypeRevision::fromMinorVersion(m_minor));
}
QQmlType QQmlTypeModuleVersion::type(const QV4::String *name) const
{
if (!m_module)
return QQmlType();
- return m_module->type(name, m_minor);
+ return m_module->type(name, QTypeRevision::fromMinorVersion(m_minor));
}
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmltypemoduleversion_p.h b/src/qml/qml/qqmltypemoduleversion_p.h
index 20f4709ecb..b7e94ef27b 100644
--- a/src/qml/qml/qqmltypemoduleversion_p.h
+++ b/src/qml/qml/qqmltypemoduleversion_p.h
@@ -52,6 +52,7 @@
//
#include <QtQml/qtqmlglobal.h>
+#include <QtCore/qversionnumber.h>
QT_BEGIN_NAMESPACE
@@ -67,19 +68,16 @@ class QQmlTypeModuleVersion
{
public:
QQmlTypeModuleVersion();
- QQmlTypeModuleVersion(QQmlTypeModule *, int);
+ QQmlTypeModuleVersion(QQmlTypeModule *, QTypeRevision);
QQmlTypeModuleVersion(const QQmlTypeModuleVersion &);
QQmlTypeModuleVersion &operator=(const QQmlTypeModuleVersion &);
- QQmlTypeModule *module() const;
- int minorVersion() const;
-
QQmlType type(const QHashedStringRef &) const;
QQmlType type(const QV4::String *) const;
private:
QQmlTypeModule *m_module;
- int m_minor;
+ quint8 m_minor;
};
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmltypenamecache.cpp b/src/qml/qml/qqmltypenamecache.cpp
index 1015403226..45333668e3 100644
--- a/src/qml/qml/qqmltypenamecache.cpp
+++ b/src/qml/qml/qqmltypenamecache.cpp
@@ -101,7 +101,7 @@ QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name)
QQmlImportNamespace *typeNamespace = nullptr;
QList<QQmlError> errors;
QQmlType t;
- bool typeFound = m_imports.resolveType(name, &t, nullptr, nullptr, &typeNamespace, &errors);
+ bool typeFound = m_imports.resolveType(name, &t, nullptr, &typeNamespace, &errors);
if (typeFound) {
return Result(t);
}
@@ -129,7 +129,7 @@ QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name,
QQmlImportNamespace *typeNamespace = nullptr;
QList<QQmlError> errors;
QQmlType t;
- bool typeFound = m_imports.resolveType(qualifiedTypeName, &t, nullptr, nullptr, &typeNamespace, &errors);
+ bool typeFound = m_imports.resolveType(qualifiedTypeName, &t, nullptr, &typeNamespace, &errors);
if (typeFound) {
return Result(t);
}
@@ -155,7 +155,7 @@ QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QV4::String *name, QQml
QList<QQmlError> errors;
QQmlType t;
bool typeRecursionDetected = false;
- bool typeFound = m_imports.resolveType(typeName, &t, nullptr, nullptr, &typeNamespace, &errors,
+ bool typeFound = m_imports.resolveType(typeName, &t, nullptr, &typeNamespace, &errors,
QQmlType::AnyRegistrationType,
recursionRestriction == QQmlImport::AllowRecursion ? &typeRecursionDetected : nullptr);
if (typeFound) {
@@ -191,7 +191,7 @@ QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QV4::String *name, cons
QQmlImportNamespace *typeNamespace = nullptr;
QList<QQmlError> errors;
QQmlType t;
- bool typeFound = m_imports.resolveType(qualifiedTypeName, &t, nullptr, nullptr, &typeNamespace, &errors);
+ bool typeFound = m_imports.resolveType(qualifiedTypeName, &t, nullptr, &typeNamespace, &errors);
if (typeFound) {
return Result(t);
}
diff --git a/src/qml/qml/qqmltypenotavailable.cpp b/src/qml/qml/qqmltypenotavailable.cpp
index ffa4472e4b..0e95d6062c 100644
--- a/src/qml/qml/qqmltypenotavailable.cpp
+++ b/src/qml/qml/qqmltypenotavailable.cpp
@@ -46,8 +46,6 @@ int qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMi
return qmlRegisterUncreatableType<QQmlTypeNotAvailable>(uri,versionMajor,versionMinor,qmlName,message);
}
-QQmlTypeNotAvailable::QQmlTypeNotAvailable() { }
-
QT_END_NAMESPACE
#include "moc_qqmltypenotavailable_p.cpp"
diff --git a/src/qml/qml/qqmltypenotavailable_p.h b/src/qml/qml/qqmltypenotavailable_p.h
index 8db5876b10..dbd37ace2a 100644
--- a/src/qml/qml/qqmltypenotavailable_p.h
+++ b/src/qml/qml/qqmltypenotavailable_p.h
@@ -55,14 +55,11 @@
QT_BEGIN_NAMESPACE
-
class QQmlTypeNotAvailable : public QObject {
Q_OBJECT
QML_NAMED_ELEMENT(TypeNotAvailable)
+ QML_ADDED_IN_VERSION(2, 15)
QML_UNCREATABLE("Type not available.")
-
-public:
- QQmlTypeNotAvailable();
};
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp
index fa5d36503d..7bcc5e9900 100644
--- a/src/qml/qml/qqmltypewrapper.cpp
+++ b/src/qml/qml/qqmltypewrapper.cpp
@@ -407,9 +407,9 @@ ReturnedValue QQmlTypeWrapper::virtualInstanceOf(const Object *typeObject, const
if (!wrapperObject)
return engine->throwTypeError();
- const int myTypeId = typeWrapper->d()->type().typeId();
+ const QMetaType myTypeId = typeWrapper->d()->type().typeId();
QQmlMetaObject myQmlType;
- if (myTypeId == 0) {
+ if (!myTypeId.isValid()) {
// we're a composite type; a composite type cannot be equal to a
// non-composite object instance (Rectangle{} is never an instance of
// CustomRectangle)
@@ -420,9 +420,9 @@ ReturnedValue QQmlTypeWrapper::virtualInstanceOf(const Object *typeObject, const
QQmlRefPointer<QQmlTypeData> td = qenginepriv->typeLoader.getType(typeWrapper->d()->type().sourceUrl());
ExecutableCompilationUnit *cu = td->compilationUnit();
- myQmlType = qenginepriv->metaObjectForType(cu->metaTypeId);
+ myQmlType = qenginepriv->metaObjectForType(cu->metaTypeId.id());
} else {
- myQmlType = qenginepriv->metaObjectForType(myTypeId);
+ myQmlType = qenginepriv->metaObjectForType(myTypeId.id());
}
const QMetaObject *theirType = wrapperObject->metaObject();
diff --git a/src/qml/qml/qqmlvaluetype.cpp b/src/qml/qml/qqmlvaluetype.cpp
index 4beb6a4d07..254f1015e2 100644
--- a/src/qml/qml/qqmlvaluetype.cpp
+++ b/src/qml/qml/qqmlvaluetype.cpp
@@ -42,11 +42,11 @@
#include <QtCore/qmutex.h>
#include <private/qqmlglobal_p.h>
#include <QtCore/qdebug.h>
+#include <private/qqmlengine_p.h>
#include <private/qmetaobjectbuilder_p.h>
#if QT_CONFIG(qml_itemmodel)
#include <private/qqmlmodelindexvaluetype_p.h>
#endif
-#include <private/qmetatype_p.h>
Q_DECLARE_METATYPE(QQmlProperty)
@@ -221,61 +221,82 @@ void QQmlValueTypeFactory::registerValueTypes(const char *uri, int versionMajor,
#endif
}
-QQmlValueType::QQmlValueType() :
- _metaObject(nullptr),
- gadgetPtr(nullptr),
- metaType(QMetaType::UnknownType)
+QQmlValueType::QQmlValueType(int typeId, const QMetaObject *gadgetMetaObject)
+ : metaType(typeId)
{
+ QMetaObjectBuilder builder(gadgetMetaObject);
+ dynamicMetaObject = builder.toMetaObject();
+ *static_cast<QMetaObject*>(this) = *dynamicMetaObject;
}
-QQmlValueType::QQmlValueType(int typeId, const QMetaObject *gadgetMetaObject)
- : gadgetPtr(QMetaType::create(typeId))
- , metaType(typeId)
+QQmlValueType::~QQmlValueType()
{
- QObjectPrivate *op = QObjectPrivate::get(this);
- Q_ASSERT(!op->metaObject);
- op->metaObject = this;
+ ::free(dynamicMetaObject);
+}
- QMetaObjectBuilder builder(gadgetMetaObject);
- _metaObject = builder.toMetaObject();
+QQmlGadgetPtrWrapper *QQmlGadgetPtrWrapper::instance(QQmlEngine *engine, int index)
+{
+ return engine ? QQmlEnginePrivate::get(engine)->valueTypeInstance(index) : nullptr;
+}
- *static_cast<QMetaObject*>(this) = *_metaObject;
+QQmlGadgetPtrWrapper::QQmlGadgetPtrWrapper(QQmlValueType *valueType, QObject *parent)
+ : QObject(parent), m_gadgetPtr(valueType->create())
+{
+ QObjectPrivate *d = QObjectPrivate::get(this);
+ Q_ASSERT(!d->metaObject);
+ d->metaObject = valueType;
}
-QQmlValueType::~QQmlValueType()
+QQmlGadgetPtrWrapper::~QQmlGadgetPtrWrapper()
{
- QObjectPrivate *op = QObjectPrivate::get(this);
- Q_ASSERT(op->metaObject == nullptr || op->metaObject == this);
- op->metaObject = nullptr;
- ::free(const_cast<QMetaObject *>(_metaObject));
- metaType.destroy(gadgetPtr);
+ QObjectPrivate *d = QObjectPrivate::get(this);
+ static_cast<const QQmlValueType *>(d->metaObject)->destroy(m_gadgetPtr);
+ d->metaObject = nullptr;
}
-void QQmlValueType::read(QObject *obj, int idx)
+void QQmlGadgetPtrWrapper::read(QObject *obj, int idx)
{
- void *a[] = { gadgetPtr, nullptr };
+ Q_ASSERT(m_gadgetPtr);
+ void *a[] = { m_gadgetPtr, nullptr };
QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
}
-void QQmlValueType::write(QObject *obj, int idx, QQmlPropertyData::WriteFlags flags)
+void QQmlGadgetPtrWrapper::write(QObject *obj, int idx, QQmlPropertyData::WriteFlags flags)
{
- Q_ASSERT(gadgetPtr);
+ Q_ASSERT(m_gadgetPtr);
int status = -1;
- void *a[] = { gadgetPtr, nullptr, &status, &flags };
+ void *a[] = { m_gadgetPtr, nullptr, &status, &flags };
QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
}
-QVariant QQmlValueType::value()
+QVariant QQmlGadgetPtrWrapper::value()
+{
+ Q_ASSERT(m_gadgetPtr);
+ return QVariant(metaTypeId(), m_gadgetPtr);
+}
+
+void QQmlGadgetPtrWrapper::setValue(const QVariant &value)
+{
+ Q_ASSERT(m_gadgetPtr);
+ Q_ASSERT(metaTypeId() == value.userType());
+ const QQmlValueType *type = valueType();
+ type->destruct(m_gadgetPtr);
+ type->construct(m_gadgetPtr, value.constData());
+}
+
+int QQmlGadgetPtrWrapper::metaCall(QMetaObject::Call type, int id, void **argv)
{
- Q_ASSERT(gadgetPtr);
- return QVariant(metaType.id(), gadgetPtr);
+ Q_ASSERT(m_gadgetPtr);
+ const QMetaObject *metaObject = valueType();
+ QQmlMetaObject::resolveGadgetMethodOrPropertyIndex(type, &metaObject, &id);
+ metaObject->d.static_metacall(static_cast<QObject *>(m_gadgetPtr), type, id, argv);
+ return id;
}
-void QQmlValueType::setValue(const QVariant &value)
+const QQmlValueType *QQmlGadgetPtrWrapper::valueType() const
{
- Q_ASSERT(metaType.id() == value.userType());
- metaType.destruct(gadgetPtr);
- metaType.construct(gadgetPtr, value.constData());
+ const QObjectPrivate *d = QObjectPrivate::get(this);
+ return static_cast<const QQmlValueType *>(d->metaObject);
}
QAbstractDynamicMetaObject *QQmlValueType::toDynamicMetaObject(QObject *)
@@ -287,12 +308,9 @@ void QQmlValueType::objectDestroyed(QObject *)
{
}
-int QQmlValueType::metaCall(QObject *, QMetaObject::Call type, int _id, void **argv)
+int QQmlValueType::metaCall(QObject *object, QMetaObject::Call type, int _id, void **argv)
{
- const QMetaObject *mo = _metaObject;
- QQmlMetaObject::resolveGadgetMethodOrPropertyIndex(type, &mo, &_id);
- mo->d.static_metacall(reinterpret_cast<QObject*>(gadgetPtr), type, _id, argv);
- return _id;
+ return static_cast<QQmlGadgetPtrWrapper *>(object)->metaCall(type, _id, argv);
}
QString QQmlPointFValueType::toString() const
diff --git a/src/qml/qml/qqmlvaluetype_p.h b/src/qml/qml/qqmlvaluetype_p.h
index ff664adbe7..0b38c746d6 100644
--- a/src/qml/qml/qqmlvaluetype_p.h
+++ b/src/qml/qml/qqmlvaluetype_p.h
@@ -54,7 +54,9 @@
#include "qqml.h"
#include "qqmlproperty.h"
#include "qqmlproperty_p.h"
+
#include <private/qqmlnullablevalue_p.h>
+#include <private/qmetatype_p.h>
#include <QtCore/qobject.h>
#include <QtCore/qrect.h>
@@ -65,16 +67,20 @@
QT_BEGIN_NAMESPACE
-class Q_QML_PRIVATE_EXPORT QQmlValueType : public QObject, public QAbstractDynamicMetaObject
+class Q_QML_PRIVATE_EXPORT QQmlValueType : public QAbstractDynamicMetaObject
{
public:
- QQmlValueType();
+ QQmlValueType() : metaType(QMetaType::UnknownType) {}
QQmlValueType(int userType, const QMetaObject *metaObject);
- ~QQmlValueType() override;
- void read(QObject *, int);
- void write(QObject *, int, QQmlPropertyData::WriteFlags flags);
- QVariant value();
- void setValue(const QVariant &);
+ ~QQmlValueType();
+
+ void *create() const { return metaType.create(); }
+ void destroy(void *gadgetPtr) const { metaType.destroy(gadgetPtr); }
+
+ void construct(void *gadgetPtr, const void *copy) const { metaType.construct(gadgetPtr, copy); }
+ void destruct(void *gadgetPtr) const { metaType.destruct(gadgetPtr); }
+
+ int metaTypeId() const { return metaType.id(); }
// ---- dynamic meta object data interface
QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *) override;
@@ -82,12 +88,33 @@ public:
int metaCall(QObject *obj, QMetaObject::Call type, int _id, void **argv) override;
// ----
-private:
- const QMetaObject *_metaObject;
- void *gadgetPtr;
-
public:
QMetaType metaType;
+ QMetaObject *dynamicMetaObject = nullptr;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlGadgetPtrWrapper : public QObject
+{
+ Q_OBJECT
+public:
+ static QQmlGadgetPtrWrapper *instance(QQmlEngine *engine, int index);
+
+ QQmlGadgetPtrWrapper(QQmlValueType *valueType, QObject *parent);
+ ~QQmlGadgetPtrWrapper();
+
+ void read(QObject *obj, int idx);
+ void write(QObject *obj, int idx, QQmlPropertyData::WriteFlags flags);
+ QVariant value();
+ void setValue(const QVariant &value);
+
+ int metaTypeId() const { return valueType()->metaTypeId(); }
+ int metaCall(QMetaObject::Call type, int id, void **argv);
+ QMetaProperty property(int index) { return valueType()->property(index); }
+
+private:
+ const QQmlValueType *valueType() const;
+
+ void *m_gadgetPtr = nullptr;
};
class Q_QML_PRIVATE_EXPORT QQmlValueTypeFactory
@@ -219,6 +246,7 @@ struct QQmlEasingValueType
QEasingCurve v;
Q_GADGET
QML_NAMED_ELEMENT(Easing)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("Use the Type enum.")
Q_PROPERTY(QQmlEasingValueType::Type type READ type WRITE setType FINAL)
@@ -282,18 +310,14 @@ public:
template<typename T>
int qmlRegisterValueTypeEnums(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
{
- QByteArray name(T::staticMetaObject.className());
-
- QByteArray pointerName(name + '*');
-
QQmlPrivate::RegisterType type = {
0,
- qRegisterNormalizedMetaType<T *>(pointerName.constData()), 0, 0, nullptr,
+ QMetaType::fromType<T*>(), QMetaType(), 0, nullptr,
QString(),
- uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject,
+ uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName, &T::staticMetaObject,
nullptr, nullptr,
@@ -302,7 +326,7 @@ int qmlRegisterValueTypeEnums(const char *uri, int versionMajor, int versionMino
nullptr, nullptr,
nullptr,
- 0
+ QTypeRevision::zero()
};
return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type);
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index ecb86e2f10..aa9f4bc1bd 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -48,6 +48,7 @@
#include "qqmlcontext_p.h"
#include "qqmlbinding_p.h"
#include "qqmlpropertyvalueinterceptor_p.h"
+#include <qqmlinfo.h>
#include <private/qqmlglobal_p.h>
@@ -60,6 +61,8 @@
#include <private/qqmlpropertycachecreator_p.h>
#include <private/qqmlpropertycachemethodarguments_p.h>
+#include <climits> // for CHAR_BIT
+
QT_BEGIN_NAMESPACE
class ResolvedList
@@ -67,13 +70,22 @@ class ResolvedList
Q_DISABLE_COPY_MOVE(ResolvedList)
public:
- ResolvedList(QQmlListProperty<QObject> *prop) :
- m_metaObject(static_cast<QQmlVMEMetaObject *>(QObjectPrivate::get(prop->object)->metaObject)),
- m_id(quintptr(prop->data))
+ ResolvedList(QQmlListProperty<QObject> *prop)
{
+ // see QQmlVMEMetaObject::metaCall for how this was constructed
+ auto encodedIndex = quintptr(prop->data);
+ constexpr quintptr usableBits = sizeof(quintptr) * CHAR_BIT;
+ quintptr inheritanceDepth = encodedIndex >> (usableBits / 2);
+ m_id = encodedIndex & ((quintptr(1) << (usableBits / 2)) - 1);
+
+ // walk up to the correct meta object if necessary
+ auto mo = prop->object->metaObject();
+ while (inheritanceDepth--)
+ mo = mo->superClass();
+ m_metaObject = static_cast<QQmlVMEMetaObject *>(const_cast<QMetaObject *>(mo));
Q_ASSERT(m_metaObject);
+ Q_ASSERT( ::strstr(m_metaObject->property(m_metaObject->propOffset() + m_id).typeName(), "QQmlListProperty") );
Q_ASSERT(m_metaObject->object == prop->object);
- Q_ASSERT(m_id <= quintptr(std::numeric_limits<int>::max() - m_metaObject->methodOffset()));
// readPropertyAsList() with checks transformed into Q_ASSERT
// and without allocation.
@@ -136,6 +148,20 @@ static void list_clear(QQmlListProperty<QObject> *prop)
resolved.activateSignal();
}
+static void list_replace(QQmlListProperty<QObject> *prop, int index, QObject *o)
+{
+ const ResolvedList resolved(prop);
+ resolved.list()->replace(index, o);
+ resolved.activateSignal();
+}
+
+static void list_removeLast(QQmlListProperty<QObject> *prop)
+{
+ const ResolvedList resolved(prop);
+ resolved.list()->removeLast();
+ resolved.activateSignal();
+}
+
QQmlVMEVariantQObjectPtr::QQmlVMEVariantQObjectPtr()
: QQmlGuard<QObject>(nullptr), m_target(nullptr), m_index(-1)
{
@@ -289,11 +315,13 @@ bool QQmlInterceptorMetaObject::intercept(QMetaObject::Call c, int id, void **a)
continue;
const int valueIndex = vi->m_propertyIndex.valueTypeIndex();
- int type = QQmlData::get(object)->propertyCache->property(id)->propType();
+ const QQmlData *data = QQmlData::get(object);
+ const int type = data->propertyCache->property(id)->propType();
if (type != QMetaType::UnknownType) {
if (valueIndex != -1) {
- QQmlValueType *valueType = QQmlValueTypeFactory::valueType(type);
+ QQmlGadgetPtrWrapper *valueType = QQmlGadgetPtrWrapper::instance(
+ data->context->engine, type);
Q_ASSERT(valueType);
//
@@ -327,7 +355,7 @@ bool QQmlInterceptorMetaObject::intercept(QMetaObject::Call c, int id, void **a)
// (7) Issue the interceptor call with the new component value.
//
- QMetaProperty valueProp = valueType->metaObject()->property(valueIndex);
+ QMetaProperty valueProp = valueType->property(valueIndex);
QVariant newValue(type, a[0]);
valueType->read(object, id);
@@ -731,11 +759,37 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void *
break;
case QV4::CompiledData::BuiltinType::InvalidBuiltin:
if (property.isList) {
+ // when reading from the list, we need to find the correct MetaObject,
+ // namely this. However, obejct->metaObject might point to any MetaObject
+ // down the inheritance hierarchy, so we need to store how far we have
+ // to go down
+ // To do this, we encode the hierarchy depth together with the id of the
+ // property in a single quintptr, with the first half storing the depth
+ // and the second half storing the property id
+ auto mo = object->metaObject();
+ quintptr inheritanceDepth = 0u;
+ while (mo && mo != this) {
+ mo = mo->superClass();
+ ++inheritanceDepth;
+ }
+ constexpr quintptr usableBits = sizeof(quintptr) * CHAR_BIT;
+ if (Q_UNLIKELY(inheritanceDepth >= (quintptr(1) << quintptr(usableBits / 2u) ) )) {
+ qmlWarning(object) << "Too many objects in inheritance hierarchy for list property";
+ return -1;
+ }
+ if (Q_UNLIKELY(quintptr(id) >= (quintptr(1) << quintptr(usableBits / 2) ) )) {
+ qmlWarning(object) << "Too many properties in object for list property";
+ return -1;
+ }
+ quintptr encodedIndex = (inheritanceDepth << (usableBits/2)) + id;
+
+
readPropertyAsList(id); // Initializes if necessary
*static_cast<QQmlListProperty<QObject> *>(a[0])
= QQmlListProperty<QObject>(
- object, reinterpret_cast<void *>(quintptr(id)),
- list_append, list_count, list_at, list_clear);
+ object, reinterpret_cast<void *>(quintptr(encodedIndex)),
+ list_append, list_count, list_at,
+ list_clear, list_replace, list_removeLast);
} else {
*reinterpret_cast<QObject **>(a[0]) = readPropertyAsQObject(id);
}
@@ -879,9 +933,9 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void *
return -1;
const QQmlPropertyData *pd = targetDData->propertyCache->property(coreIndex);
// Value type property or deep alias
- QQmlValueType *valueType = QQmlValueTypeFactory::valueType(pd->propType());
+ QQmlGadgetPtrWrapper *valueType = QQmlGadgetPtrWrapper::instance(
+ ctxt->engine, pd->propType());
if (valueType) {
-
valueType->read(target, coreIndex);
int rv = QMetaObject::metacall(valueType, c, valueTypePropertyIndex, a);
@@ -1184,7 +1238,7 @@ void QQmlVMEMetaObject::ensureQObjectWrapper()
void QQmlVMEMetaObject::mark(QV4::MarkStack *markStack)
{
- if (engine != markStack->engine)
+ if (engine != markStack->engine())
return;
propertyAndMethodStorage.markOnce(markStack);
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index c820499703..61070113cc 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -1203,25 +1203,15 @@ void QQmlXMLHttpRequest::requestFromUrl(const QUrl &url)
if (m_method == QLatin1String("PUT"))
{
if (!xhrFileWrite()) {
- if (qEnvironmentVariableIsSet("QML_XHR_ALLOW_FILE_WRITE")) {
- qWarning("XMLHttpRequest: Tried to use PUT on a local file despite being disabled.");
- return;
- } else {
- qWarning("XMLHttpRequest: Using PUT on a local file is dangerous "
- "and will be disabled by default in a future Qt version."
- "Set QML_XHR_ALLOW_FILE_WRITE to 1 if you wish to continue using this feature.");
- }
+ qWarning("XMLHttpRequest: Using PUT on a local file is disabled by default.\n"
+ "Set QML_XHR_ALLOW_FILE_WRITE to 1 to enable this feature.");
+ return;
}
} else if (m_method == QLatin1String("GET")) {
if (!xhrFileRead()) {
- if (qEnvironmentVariableIsSet("QML_XHR_ALLOW_FILE_READ")) {
- qWarning("XMLHttpRequest: Tried to use GET on a local file despite being disabled.");
- return;
- } else {
- qWarning("XMLHttpRequest: Using GET on a local file is dangerous "
- "and will be disabled by default in a future Qt version."
- "Set QML_XHR_ALLOW_FILE_READ to 1 if you wish to continue using this feature.");
- }
+ qWarning("XMLHttpRequest: Using GET on a local file is disabled by default.\n"
+ "Set QML_XHR_ALLOW_FILE_READ to 1 to enable this feature.");
+ return;
}
} else {
qWarning("XMLHttpRequest: Unsupported method used on a local file");
@@ -1291,7 +1281,7 @@ void QQmlXMLHttpRequest::requestFromUrl(const QUrl &url)
if (m_network->bytesAvailable() > 0)
readyRead();
- QNetworkReply::NetworkError networkError = m_network->networkError();
+ QNetworkReply::NetworkError networkError = m_network->error();
if (networkError != QNetworkReply::NoError) {
error(networkError);
} else {
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index 02032142ee..4e5ab9b899 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -722,70 +722,114 @@ ReturnedValue QtObject::method_tint(const FunctionObject *b, const Value *, cons
return scope.engine->fromVariant(QQml_colorProvider()->tint(v1, v2));
}
+namespace {
+template <typename T>
+QString formatDateTimeObjectUsingDateFormat(T formatThis, Qt::DateFormat format) {
+ switch (format) {
+ case Qt::TextDate:
+ case Qt::ISODate:
+ case Qt::RFC2822Date:
+ case Qt::ISODateWithMs:
+ return formatThis.toString(format);
+ default: // ### Qt 6: remove once qtbase has removed the rest of the enum !
+ break;
+ }
+ // Q_UNREACHABLE(); // ### Qt 6: restore once the default is gone
+ return QString();
+}
+
+template <typename T>
+ReturnedValue formatDateTimeObject(const T &formatThis, const QV4::Scope &scope, const QString &functionName, int argc, const Value *argv) {
+
+ QString formatted;
+ if (argc >= 2) {
+ QV4::ScopedString s(scope, argv[1]);
+ if (s) {
+ if (argc == 3)
+ scope.engine->throwError(QLatin1String("%1(): Stay argument, third argument can only be used if second argument is a locale").arg(functionName));
+ QString format = s->toQString();
+ formatted = formatThis.toString(format);
+ } else if (argv[1].isNumber()) {
+ if (argc == 3)
+ scope.engine->throwError(QLatin1String("%1(): Stay argument, third argument can only be used if second argument is a locale").arg(functionName));
+ quint32 intFormat = argv[1].asDouble();
+ Qt::DateFormat format = Qt::DateFormat(intFormat);
+ formatted = formatDateTimeObjectUsingDateFormat(formatThis, format);
+ } else {
+ QLocale::FormatType formatOptions = QLocale::ShortFormat;
+ if (argc == 3) {
+ if (argv[2].isNumber())
+ formatOptions = QLocale::FormatType(quint32(argv[2].asDouble()));
+ else
+ scope.engine->throwError(QLatin1String("%1(): Third argument must be a Locale format option").arg(functionName));
+ }
+ auto enginePriv = QQmlEnginePrivate::get(scope.engine->qmlEngine());
+ auto localeMetaTypeId = qMetaTypeId<QLocale>();
+ QVariant locale = enginePriv->v4engine()->toVariant(argv[1], localeMetaTypeId);
+ if (!locale.canConvert(localeMetaTypeId))
+ scope.engine->throwError(QLatin1String("%1(): Bad second argument (must be either string, number or locale)").arg(functionName));
+ formatted = locale.value<QLocale>().toString(formatThis, formatOptions);
+ }
+ } else {
+ formatted = QLocale().toString(formatThis, QLocale::ShortFormat);
+ }
+
+ return Encode(scope.engine->newString(formatted));
+}
+
+}
+
/*!
-\qmlmethod string Qt::formatDate(datetime date, variant format)
+\qmlmethod string Qt::formatDate(datetime date, variant format, variant localeFormatOption)
-Returns a string representation of \a date, optionally formatted according
-to \a format.
+Returns a string representation of \a date, optionally formatted using \a format.
The \a date parameter may be a JavaScript \c Date object, a \l{date}{date}
-property, a QDate, or QDateTime value. The \a format parameter may be any of
-the possible format values as described for
+property, a QDate, or QDateTime value. The \a format and \a localeFormatOption
+parameter may be any of the possible format values as described for
\l{QtQml::Qt::formatDateTime()}{Qt.formatDateTime()}.
If \a format is not specified, \a date is formatted using
-\l {Qt::DefaultLocaleShortDate}{Qt.DefaultLocaleShortDate}.
+\l {QLocale::FormatType}{Locale.ShortFormat} using the
+default locale.
\sa Locale
*/
ReturnedValue QtObject::method_formatDate(const FunctionObject *b, const Value *, const Value *argv, int argc)
{
QV4::Scope scope(b);
- if (argc < 1 || argc > 2)
- THROW_GENERIC_ERROR("Qt.formatDate(): Invalid arguments");
+ if (argc < 1)
+ THROW_GENERIC_ERROR("Qt.formatDate(): Missing argument");
+ if (argc > 3)
+ THROW_GENERIC_ERROR("Qt.formatDate(): Stray arguments; formatDate takes at most 3 arguments.");
- Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
QDate date = scope.engine->toVariant(argv[0], -1).toDateTime().date();
- QString formattedDate;
- if (argc == 2) {
- QV4::ScopedString s(scope, argv[1]);
- if (s) {
- QString format = s->toQString();
- formattedDate = date.toString(format);
- } else if (argv[1].isNumber()) {
- quint32 intFormat = argv[1].asDouble();
- Qt::DateFormat format = Qt::DateFormat(intFormat);
- formattedDate = date.toString(format);
- } else {
- THROW_GENERIC_ERROR("Qt.formatDate(): Invalid date format");
- }
- } else {
- formattedDate = date.toString(enumFormat);
- }
-
- return Encode(scope.engine->newString(formattedDate));
+ return formatDateTimeObject(date, scope, QLatin1String("Qt.formatDate"), argc, argv);
}
/*!
-\qmlmethod string Qt::formatTime(datetime time, variant format)
+\qmlmethod string Qt::formatTime(datetime time, variant format, variant localeFormatOption)
-Returns a string representation of \a time, optionally formatted according to
-\a format.
+Returns a string representation of \a time, optionally formatted using
+\a format, and, if provided, \a localeFormatOption.
The \a time parameter may be a JavaScript \c Date object, a QTime, or QDateTime
-value. The \a format parameter may be any of the possible format values as
-described for \l{QtQml::Qt::formatDateTime()}{Qt.formatDateTime()}.
+value. The \a format and \a localeFormatOption parameter may be any of the
+possible format values as described for
+\l{QtQml::Qt::formatDateTime()}{Qt.formatDateTime()}.
If \a format is not specified, \a time is formatted using
-\l {Qt::DefaultLocaleShortDate}{Qt.DefaultLocaleShortDate}.
+\l {QLocale::FormatType}{Locale.ShortFormat} using the default locale.
\sa Locale
*/
ReturnedValue QtObject::method_formatTime(const FunctionObject *b, const Value *, const Value *argv, int argc)
{
QV4::Scope scope(b);
- if (argc < 1 || argc > 2)
- THROW_GENERIC_ERROR("Qt.formatTime(): Invalid arguments");
+ if (argc < 1)
+ THROW_GENERIC_ERROR("Qt.formatTime(): Missing argument");
+ if (argc > 3)
+ THROW_GENERIC_ERROR("Qt.formatTime(): Stray arguments; formatTime takes at most 3 arguments.");
QVariant argVariant = scope.engine->toVariant(argv[0], -1);
QTime time;
@@ -793,47 +837,34 @@ ReturnedValue QtObject::method_formatTime(const FunctionObject *b, const Value *
time = argVariant.toDateTime().time();
else // if (argVariant.type() == QVariant::Time), or invalid.
time = argVariant.toTime();
-
- Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
- QString formattedTime;
- if (argc == 2) {
- QV4::ScopedString s(scope, argv[1]);
- if (s) {
- QString format = s->toQString();
- formattedTime = time.toString(format);
- } else if (argv[1].isNumber()) {
- quint32 intFormat = argv[1].asDouble();
- Qt::DateFormat format = Qt::DateFormat(intFormat);
- formattedTime = time.toString(format);
- } else {
- THROW_GENERIC_ERROR("Qt.formatTime(): Invalid time format");
- }
- } else {
- formattedTime = time.toString(enumFormat);
- }
-
- return Encode(scope.engine->newString(formattedTime));
+ return formatDateTimeObject(time, scope, QLatin1String("Qt.formatTime"), argc, argv);
}
/*!
-\qmlmethod string Qt::formatDateTime(datetime dateTime, variant format)
+\qmlmethod string Qt::formatDateTime(datetime dateTime, variant format, variant localeFormatOption)
-Returns a string representation of \a dateTime, optionally formatted according to
-\a format.
+Returns a string representation of \a dateTime, optionally formatted using
+\a format and \a localeFormatOption.
The \a dateTime parameter may be a JavaScript \c Date object, a \l{date}{date}
property, a QDate, QTime, or QDateTime value.
If \a format is not provided, \a dateTime is formatted using
-\l {Qt::DefaultLocaleShortDate}{Qt.DefaultLocaleShortDate}. Otherwise,
-\a format should be either:
+\l {QLocale::FormatType}{Locale.ShortFormat} using the
+default locale. Otherwise, \a format should be either:
\list
\li One of the Qt::DateFormat enumeration values, such as
- \c Qt.DefaultLocaleShortDate or \c Qt.ISODate
+ \c Qt.RFC2822Date or \c Qt.ISODate.
\li A string that specifies the format of the returned string, as detailed below.
+\li A \c locale object.
\endlist
+If \a format specifies a locale object, \dateTime is formatted
+with \l{QLocale::toString}. In this case, \a localeFormatOption can hold a value
+of type \l {QLocale::FormatType} to further tune the formatting. If none is
+provided, \l {QLocale::FormatType}{Locale.ShortFormat} is used.
+
If \a format specifies a format string, it should use the following expressions
to specify the date:
@@ -910,29 +941,13 @@ with the \a format values below to produce the following results:
ReturnedValue QtObject::method_formatDateTime(const FunctionObject *b, const Value *, const Value *argv, int argc)
{
QV4::Scope scope(b);
- if (argc < 1 || argc > 2)
- THROW_GENERIC_ERROR("Qt.formatDateTime(): Invalid arguments");
+ if (argc < 1)
+ THROW_GENERIC_ERROR("Qt.formatDateTime(): Missing argument");
+ if (argc > 3)
+ THROW_GENERIC_ERROR("Qt.formatDateTime(): Stray arguments; formatDate takes at most 3 arguments.");
- Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
QDateTime dt = scope.engine->toVariant(argv[0], -1).toDateTime();
- QString formattedDt;
- if (argc == 2) {
- QV4::ScopedString s(scope, argv[1]);
- if (s) {
- QString format = s->toQString();
- formattedDt = dt.toString(format);
- } else if (argv[1].isNumber()) {
- quint32 intFormat = argv[1].asDouble();
- Qt::DateFormat format = Qt::DateFormat(intFormat);
- formattedDt = dt.toString(format);
- } else {
- THROW_GENERIC_ERROR("Qt.formatDateTime(): Invalid datetime format");
- }
- } else {
- formattedDt = dt.toString(enumFormat);
- }
-
- return Encode(scope.engine->newString(formattedDt));
+ return formatDateTimeObject(dt, scope, QLatin1String("Qt.formatDateTime"), argc, argv);
}
/*!
diff --git a/src/qml/qmldirparser/qqmldirparser.cpp b/src/qml/qmldirparser/qqmldirparser.cpp
index 36b47a3302..161d902854 100644
--- a/src/qml/qmldirparser/qqmldirparser.cpp
+++ b/src/qml/qmldirparser/qqmldirparser.cpp
@@ -60,17 +60,17 @@ static int parseInt(const QStringRef &str, bool *ok)
return number;
}
-static bool parseVersion(const QString &str, int *major, int *minor)
+static QTypeRevision parseVersion(const QString &str)
{
const int dotIndex = str.indexOf(QLatin1Char('.'));
if (dotIndex != -1 && str.indexOf(QLatin1Char('.'), dotIndex + 1) == -1) {
bool ok = false;
- *major = parseInt(QStringRef(&str, 0, dotIndex), &ok);
- if (ok)
- *minor = parseInt(QStringRef(&str, dotIndex + 1, str.length() - dotIndex - 1), &ok);
- return ok;
+ const int major = parseInt(QStringRef(&str, 0, dotIndex), &ok);
+ if (!ok) return QTypeRevision();
+ const int minor = parseInt(QStringRef(&str, dotIndex + 1, str.length() - dotIndex - 1), &ok);
+ return ok ? QTypeRevision::fromVersion(major, minor) : QTypeRevision();
}
- return false;
+ return QTypeRevision();
}
void QQmlDirParser::clear()
@@ -203,7 +203,7 @@ bool QQmlDirParser::parse(const QString &source)
QStringLiteral("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1));
continue;
}
- Component entry(sections[1], sections[2], -1, -1);
+ Component entry(sections[1], sections[2], QTypeRevision());
entry.internal = true;
_components.insert(entry.typeName, entry);
} else if (sections[0] == QLatin1String("singleton")) {
@@ -214,16 +214,16 @@ bool QQmlDirParser::parse(const QString &source)
} else if (sectionCount == 3) {
// handle qmldir directory listing case where singleton is defined in the following pattern:
// singleton TestSingletonType TestSingletonType.qml
- Component entry(sections[1], sections[2], -1, -1);
+ Component entry(sections[1], sections[2], QTypeRevision());
entry.singleton = true;
_components.insert(entry.typeName, entry);
} else {
// handle qmldir module listing case where singleton is defined in the following pattern:
// singleton TestSingletonType 2.0 TestSingletonType20.qml
- int major, minor;
- if (parseVersion(sections[2], &major, &minor)) {
+ const QTypeRevision version = parseVersion(sections[2]);
+ if (version.isValid()) {
const QString &fileName = sections[3];
- Component entry(sections[1], fileName, major, minor);
+ Component entry(sections[1], fileName, version);
entry.singleton = true;
_components.insert(entry.typeName, entry);
} else {
@@ -253,9 +253,9 @@ bool QQmlDirParser::parse(const QString &source)
continue;
}
- int major, minor;
- if (parseVersion(sections[2], &major, &minor)) {
- Component entry(sections[1], QString(), major, minor);
+ const QTypeRevision version = parseVersion(sections[2]);
+ if (version.isValid()) {
+ Component entry(sections[1], QString(), version);
entry.internal = true;
_dependencies.insert(entry.typeName, entry);
} else {
@@ -270,19 +270,19 @@ bool QQmlDirParser::parse(const QString &source)
_imports << sections[1];
} else if (sectionCount == 2) {
// No version specified (should only be used for relative qmldir files)
- const Component entry(sections[0], sections[1], -1, -1);
+ const Component entry(sections[0], sections[1], QTypeRevision());
_components.insert(entry.typeName, entry);
} else if (sectionCount == 3) {
- int major, minor;
- if (parseVersion(sections[1], &major, &minor)) {
+ const QTypeRevision version = parseVersion(sections[1]);
+ if (version.isValid()) {
const QString &fileName = sections[2];
if (fileName.endsWith(QLatin1String(".js")) || fileName.endsWith(QLatin1String(".mjs"))) {
// A 'js' extension indicates a namespaced script import
- const Script entry(sections[0], fileName, major, minor);
+ const Script entry(sections[0], fileName, version);
_scripts.append(entry);
} else {
- const Component entry(sections[0], fileName, major, minor);
+ const Component entry(sections[0], fileName, version);
_components.insert(entry.typeName, entry);
}
} else {
@@ -302,8 +302,8 @@ bool QQmlDirParser::parse(const QString &source)
void QQmlDirParser::reportError(quint16 line, quint16 column, const QString &description)
{
QQmlJS::DiagnosticMessage error;
- error.line = line;
- error.column = column;
+ error.loc.startLine = line;
+ error.loc.startColumn = column;
error.message = description;
_errors.append(error);
}
@@ -319,7 +319,7 @@ bool QQmlDirParser::hasError() const
void QQmlDirParser::setError(const QQmlJS::DiagnosticMessage &e)
{
_errors.clear();
- reportError(e.line, e.column, e.message);
+ reportError(e.loc.startLine, e.loc.startColumn, e.message);
}
QList<QQmlJS::DiagnosticMessage> QQmlDirParser::errors(const QString &uri) const
@@ -387,15 +387,17 @@ QString QQmlDirParser::className() const
QDebug &operator<< (QDebug &debug, const QQmlDirParser::Component &component)
{
- const QString output = QStringLiteral("{%1 %2.%3}").
- arg(component.typeName).arg(component.majorVersion).arg(component.minorVersion);
+ const QString output = QStringLiteral("{%1 %2.%3}")
+ .arg(component.typeName).arg(component.version.majorVersion())
+ .arg(component.version.minorVersion());
return debug << qPrintable(output);
}
QDebug &operator<< (QDebug &debug, const QQmlDirParser::Script &script)
{
- const QString output = QStringLiteral("{%1 %2.%3}").
- arg(script.nameSpace).arg(script.majorVersion).arg(script.minorVersion);
+ const QString output = QStringLiteral("{%1 %2.%3}")
+ .arg(script.nameSpace).arg(script.version.majorVersion())
+ .arg(script.version.minorVersion());
return debug << qPrintable(output);
}
diff --git a/src/qml/qmldirparser/qqmldirparser_p.h b/src/qml/qmldirparser/qqmldirparser_p.h
index 3696a1aa12..ccdac8f484 100644
--- a/src/qml/qmldirparser/qqmldirparser_p.h
+++ b/src/qml/qmldirparser/qqmldirparser_p.h
@@ -54,6 +54,7 @@
#include <QtCore/QUrl>
#include <QtCore/QHash>
#include <QtCore/QDebug>
+#include <QtCore/QTypeRevision>
#include <private/qtqmlcompilerglobal_p.h>
#include <private/qqmljsengine_p.h>
#include <private/qqmljsdiagnosticmessage_p.h>
@@ -101,8 +102,8 @@ public:
{
Component() = default;
- Component(const QString &typeName, const QString &fileName, int majorVersion, int minorVersion)
- : typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion),
+ Component(const QString &typeName, const QString &fileName, QTypeRevision version)
+ : typeName(typeName), fileName(fileName), version(version),
internal(false), singleton(false)
{
checkNonRelative("Component", typeName, fileName);
@@ -110,8 +111,7 @@ public:
QString typeName;
QString fileName;
- int majorVersion = 0;
- int minorVersion = 0;
+ QTypeRevision version = QTypeRevision::zero();
bool internal = false;
bool singleton = false;
};
@@ -120,16 +120,15 @@ public:
{
Script() = default;
- Script(const QString &nameSpace, const QString &fileName, int majorVersion, int minorVersion)
- : nameSpace(nameSpace), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion)
+ Script(const QString &nameSpace, const QString &fileName, QTypeRevision version)
+ : nameSpace(nameSpace), fileName(fileName), version(version)
{
checkNonRelative("Script", nameSpace, fileName);
}
QString nameSpace;
QString fileName;
- int majorVersion = 0;
- int minorVersion = 0;
+ QTypeRevision version = QTypeRevision::zero();
};
QMultiHash<QString,Component> components() const;
diff --git a/src/qml/qtqmlglobal_p.h b/src/qml/qtqmlglobal_p.h
index 9ca0cf2abe..a729729b67 100644
--- a/src/qml/qtqmlglobal_p.h
+++ b/src/qml/qtqmlglobal_p.h
@@ -60,6 +60,8 @@
#define Q_QML_PRIVATE_EXPORT Q_QML_EXPORT
+void Q_QML_PRIVATE_EXPORT qml_register_types_QtQml();
+
#if !defined(QT_QMLDEVTOOLS_LIB) && !defined(QT_BUILD_QMLDEVTOOLS_LIB)
# define Q_QML_AUTOTEST_EXPORT Q_AUTOTEST_EXPORT
#else
diff --git a/src/qml/types/qqmlbind_p.h b/src/qml/types/qqmlbind_p.h
index c709224c23..052af0d167 100644
--- a/src/qml/types/qqmlbind_p.h
+++ b/src/qml/types/qqmlbind_p.h
@@ -77,11 +77,12 @@ private:
Q_PROPERTY(QString property READ property WRITE setProperty)
Q_PROPERTY(QJSValue value READ value WRITE setValue)
Q_PROPERTY(bool when READ when WRITE setWhen)
- Q_PROPERTY(bool delayed READ delayed WRITE setDelayed REVISION 8)
+ Q_PROPERTY(bool delayed READ delayed WRITE setDelayed REVISION(2, 8))
Q_PROPERTY(RestorationMode restoreMode READ restoreMode WRITE setRestoreMode
- NOTIFY restoreModeChanged REVISION 14)
+ NOTIFY restoreModeChanged REVISION(2, 14))
Q_ENUM(RestorationMode)
QML_NAMED_ELEMENT(Binding)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQmlBind(QObject *parent=nullptr);
diff --git a/src/qml/types/qqmlconnections.cpp b/src/qml/types/qqmlconnections.cpp
index 1e801641e5..4c44bba43e 100644
--- a/src/qml/types/qqmlconnections.cpp
+++ b/src/qml/types/qqmlconnections.cpp
@@ -238,7 +238,8 @@ void QQmlConnectionsParser::verifyBindings(const QQmlRefPointer<QV4::ExecutableC
const QV4::CompiledData::Binding *binding = props.at(ii);
const QString &propName = compilationUnit->stringAt(binding->propertyNameIndex);
- if (!propName.startsWith(QLatin1String("on")) || (propName.length() < 3 || !propName.at(2).isUpper())) {
+ const bool thirdCharacterIsValid = (propName.length() >= 2) && (propName.at(2).isUpper() || propName.at(2) == '_');
+ if (!propName.startsWith(QLatin1String("on")) || !thirdCharacterIsValid) {
error(props.at(ii), QQmlConnections::tr("Cannot assign to non-existent property \"%1\"").arg(propName));
return;
}
diff --git a/src/qml/types/qqmlconnections_p.h b/src/qml/types/qqmlconnections_p.h
index 7bf688cf75..8ed874d9fc 100644
--- a/src/qml/types/qqmlconnections_p.h
+++ b/src/qml/types/qqmlconnections_p.h
@@ -69,9 +69,10 @@ class Q_AUTOTEST_EXPORT QQmlConnections : public QObject, public QQmlParserStatu
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
- Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged REVISION 3)
+ Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged REVISION(2, 3))
Q_PROPERTY(bool ignoreUnknownSignals READ ignoreUnknownSignals WRITE setIgnoreUnknownSignals)
QML_NAMED_ELEMENT(Connections)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQmlConnections(QObject *parent=nullptr);
@@ -88,7 +89,7 @@ public:
Q_SIGNALS:
void targetChanged();
- Q_REVISION(3) void enabledChanged();
+ Q_REVISION(2, 3) void enabledChanged();
private:
void connectSignals();
diff --git a/src/qml/types/qqmltimer_p.h b/src/qml/types/qqmltimer_p.h
index 0cd93e4659..a8236977c4 100644
--- a/src/qml/types/qqmltimer_p.h
+++ b/src/qml/types/qqmltimer_p.h
@@ -73,6 +73,7 @@ class Q_QML_PRIVATE_EXPORT QQmlTimer : public QObject, public QQmlParserStatus
Q_PROPERTY(bool triggeredOnStart READ triggeredOnStart WRITE setTriggeredOnStart NOTIFY triggeredOnStartChanged)
Q_PROPERTY(QObject *parent READ parent CONSTANT)
QML_NAMED_ELEMENT(Timer)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQmlTimer(QObject *parent=nullptr);
diff --git a/src/qmldebug/qmldebug.pro b/src/qmldebug/qmldebug.pro
index 94d300b765..ac3f3bf3bf 100644
--- a/src/qmldebug/qmldebug.pro
+++ b/src/qmldebug/qmldebug.pro
@@ -1,5 +1,5 @@
TARGET = QtQmlDebug
-QT = core-private network packetprotocol-private
+QT = core-private qml-private network packetprotocol-private
CONFIG += static internal_module
load(qt_module)
@@ -8,6 +8,7 @@ SOURCES += \
qqmldebugclient.cpp \
qqmldebugconnection.cpp \
qqmldebugmessageclient.cpp \
+ qqmldebugtranslationclient.cpp \
qqmlenginecontrolclient.cpp \
qqmlenginedebugclient.cpp \
qqmlinspectorclient.cpp \
@@ -24,6 +25,7 @@ HEADERS += \
qqmldebugclient_p_p.h \
qqmldebugconnection_p.h \
qqmldebugmessageclient_p.h \
+ qqmldebugtranslationclient_p.h \
qqmlenginedebugclient_p.h \
qqmlenginedebugclient_p_p.h \
qqmlenginecontrolclient_p.h \
diff --git a/src/qmldebug/qqmldebugtranslationclient.cpp b/src/qmldebug/qqmldebugtranslationclient.cpp
new file mode 100644
index 0000000000..1fd0748fa0
--- /dev/null
+++ b/src/qmldebug/qqmldebugtranslationclient.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmldebugtranslationclient_p.h"
+#include "qqmldebugconnection_p.h"
+
+#include <QUrl>
+#include <QDataStream>
+
+#include <QDebug>
+#include <QtPacketProtocol/private/qpacket_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QQmlDebugTranslationClient
+ \internal
+
+ \brief Client for the debug translation service
+
+ The QQmlDebugTranslationClient can test if translated texts will fit.
+ */
+
+QQmlDebugTranslationClient::QQmlDebugTranslationClient(QQmlDebugConnection *client)
+ : QQmlDebugClient(QLatin1String("DebugTranslation"), client)
+{
+}
+
+void QQmlDebugTranslationClient::messageReceived(const QByteArray &data)
+{
+ Q_UNUSED(data);
+}
+
+void QQmlDebugTranslationClient::triggerLanguage(const QUrl &url, const QString &locale)
+{
+ Q_UNUSED(url)
+ Q_UNUSED(locale)
+}
+
+QT_END_NAMESPACE
diff --git a/src/qmldebug/qqmldebugtranslationclient_p.h b/src/qmldebug/qqmldebugtranslationclient_p.h
new file mode 100644
index 0000000000..3163759d9e
--- /dev/null
+++ b/src/qmldebug/qqmldebugtranslationclient_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QQMLDEBUGTRANSLATIONCLIENT_P_H
+#define QQMLDEBUGTRANSLATIONCLIENT_P_H
+
+#include "qqmldebugclient_p.h"
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QQmlDebugTranslationClient : public QQmlDebugClient
+{
+ Q_OBJECT
+
+public:
+ //needs to be in sync with QQmlDebugTranslationServiceImpl in qqmldebugtranslationservice.h
+ enum Command {
+ ChangeLanguage,
+ ChangeWarningColor,
+ ChangeElidedTextWarningString,
+ SetDebugTranslationServiceLogFile,
+ EnableElidedTextWarning,
+ DisableElidedTextWarning,
+ TestAllLanguages
+ };
+
+ explicit QQmlDebugTranslationClient(QQmlDebugConnection *client);
+
+ virtual void messageReceived(const QByteArray &) override;
+ void triggerLanguage(const QUrl &url, const QString &locale);
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLDEBUGTRANSLATIONCLIENT_P_H
diff --git a/src/imports/models/dependencies.json b/src/qmlmodels/dependencies.json
index 0d4f101c7a..0d4f101c7a 100644
--- a/src/imports/models/dependencies.json
+++ b/src/qmlmodels/dependencies.json
diff --git a/src/qmlmodels/qmlmodels.pro b/src/qmlmodels/qmlmodels.pro
index d3a7495599..34380ee14e 100644
--- a/src/qmlmodels/qmlmodels.pro
+++ b/src/qmlmodels/qmlmodels.pro
@@ -66,7 +66,7 @@ qtConfig(qml-delegate-model) {
QMLTYPES_FILENAME = plugins.qmltypes
QMLTYPES_INSTALL_DIR = $$[QT_INSTALL_QML]/QtQml/Models
QML_IMPORT_NAME = QtQml.Models
-IMPORT_VERSION = 2.15
+QML_IMPORT_VERSION = $$QT_VERSION
CONFIG += qmltypes install_qmltypes install_metatypes
load(qt_module)
diff --git a/src/qmlmodels/qqmlabstractdelegatecomponent_p.h b/src/qmlmodels/qqmlabstractdelegatecomponent_p.h
index 07cae6b092..853a7e8af8 100644
--- a/src/qmlmodels/qqmlabstractdelegatecomponent_p.h
+++ b/src/qmlmodels/qqmlabstractdelegatecomponent_p.h
@@ -65,6 +65,7 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlAbstractDelegateComponent : public QQmlComp
{
Q_OBJECT
QML_NAMED_ELEMENT(AbstractDelegateComponent)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("Cannot create instance of abstract class AbstractDelegateComponent.")
public:
diff --git a/src/qmlmodels/qqmladaptormodel.cpp b/src/qmlmodels/qqmladaptormodel.cpp
index fbb85327a7..8c8c37d237 100644
--- a/src/qmlmodels/qqmladaptormodel.cpp
+++ b/src/qmlmodels/qqmladaptormodel.cpp
@@ -93,7 +93,7 @@ class QQmlDMCachedModelData : public QQmlDelegateModelItem
{
public:
QQmlDMCachedModelData(
- QQmlDelegateModelItemMetaType *metaType,
+ const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType,
VDMModelDelegateDataType *dataType,
int index, int row, int column);
@@ -255,7 +255,9 @@ public:
bool hasModelData;
};
-QQmlDMCachedModelData::QQmlDMCachedModelData(QQmlDelegateModelItemMetaType *metaType, VDMModelDelegateDataType *dataType, int index, int row, int column)
+QQmlDMCachedModelData::QQmlDMCachedModelData(
+ const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType,
+ VDMModelDelegateDataType *dataType, int index, int row, int column)
: QQmlDelegateModelItem(metaType, dataType, index, row, column)
, type(dataType)
{
@@ -390,7 +392,7 @@ class QQmlDMAbstractItemModelData : public QQmlDMCachedModelData
public:
QQmlDMAbstractItemModelData(
- QQmlDelegateModelItemMetaType *metaType,
+ const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType,
VDMModelDelegateDataType *dataType,
int index, int row, int column)
: QQmlDMCachedModelData(metaType, dataType, index, row, column)
@@ -458,7 +460,7 @@ public:
void cleanup(QQmlAdaptorModel &) const override
{
- const_cast<VDMAbstractItemModelDataType *>(this)->release();
+ release();
}
QVariant value(const QQmlAdaptorModel &model, int index, const QString &role) const override
@@ -512,7 +514,7 @@ public:
QQmlDelegateModelItem *createItem(
QQmlAdaptorModel &model,
- QQmlDelegateModelItemMetaType *metaType,
+ const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType,
int index, int row, int column) const override
{
VDMAbstractItemModelDataType *dataType = const_cast<VDMAbstractItemModelDataType *>(this);
@@ -560,7 +562,7 @@ class QQmlDMListAccessorData : public QQmlDelegateModelItem
Q_OBJECT
Q_PROPERTY(QVariant modelData READ modelData WRITE setModelData NOTIFY modelDataChanged)
public:
- QQmlDMListAccessorData(QQmlDelegateModelItemMetaType *metaType,
+ QQmlDMListAccessorData(const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType,
QQmlAdaptorModel::Accessors *accessor,
int index, int row, int column, const QVariant &value)
: QQmlDelegateModelItem(metaType, accessor, index, row, column)
@@ -676,7 +678,7 @@ public:
QQmlDelegateModelItem *createItem(
QQmlAdaptorModel &model,
- QQmlDelegateModelItemMetaType *metaType,
+ const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType,
int index, int row, int column) const override
{
VDMListDelegateDataType *dataType = const_cast<VDMListDelegateDataType *>(this);
@@ -719,7 +721,7 @@ class QQmlDMObjectData : public QQmlDelegateModelItem, public QQmlAdaptorModelPr
Q_INTERFACES(QQmlAdaptorModelProxyInterface)
public:
QQmlDMObjectData(
- QQmlDelegateModelItemMetaType *metaType,
+ const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType,
VDMObjectDelegateDataType *dataType,
int index, int row, int column,
QObject *object);
@@ -790,7 +792,7 @@ public:
QQmlDelegateModelItem *createItem(
QQmlAdaptorModel &model,
- QQmlDelegateModelItemMetaType *metaType,
+ const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType,
int index, int row, int column) const override
{
VDMObjectDelegateDataType *dataType = const_cast<VDMObjectDelegateDataType *>(this);
@@ -930,7 +932,7 @@ public:
VDMObjectDelegateDataType *m_type;
};
-QQmlDMObjectData::QQmlDMObjectData(QQmlDelegateModelItemMetaType *metaType,
+QQmlDMObjectData::QQmlDMObjectData(const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType,
VDMObjectDelegateDataType *dataType,
int index, int row, int column,
QObject *object)
@@ -975,6 +977,9 @@ void QQmlAdaptorModel::setModel(const QVariant &variant, QObject *parent, QQmlEn
} else if (list.type() == QQmlListAccessor::ListProperty) {
setObject(static_cast<const QQmlListReference *>(variant.constData())->object(), parent);
accessors = new VDMObjectDelegateDataType;
+ } else if (list.type() == QQmlListAccessor::ObjectList) {
+ setObject(nullptr, parent);
+ accessors = new VDMObjectDelegateDataType;
} else if (list.type() != QQmlListAccessor::Invalid
&& list.type() != QQmlListAccessor::Instance) { // Null QObject
setObject(nullptr, parent);
@@ -1030,9 +1035,9 @@ int QQmlAdaptorModel::indexAt(int row, int column) const
return column * rowCount() + row;
}
-void QQmlAdaptorModel::useImportVersion(int minorVersion)
+void QQmlAdaptorModel::useImportVersion(QTypeRevision revision)
{
- modelItemRevision = minorVersion;
+ modelItemRevision = revision;
}
void QQmlAdaptorModel::objectDestroyed(QObject *)
diff --git a/src/qmlmodels/qqmladaptormodel_p.h b/src/qmlmodels/qqmladaptormodel_p.h
index a4549127af..2c90ffc1d1 100644
--- a/src/qmlmodels/qqmladaptormodel_p.h
+++ b/src/qmlmodels/qqmladaptormodel_p.h
@@ -87,7 +87,7 @@ public:
virtual QQmlDelegateModelItem *createItem(
QQmlAdaptorModel &,
- QQmlDelegateModelItemMetaType *,
+ const QQmlRefPointer<QQmlDelegateModelItemMetaType> &,
int, int, int) const { return nullptr; }
virtual bool notify(
@@ -115,7 +115,7 @@ public:
QPersistentModelIndex rootIndex;
QQmlListAccessor list;
- int modelItemRevision = 0;
+ QTypeRevision modelItemRevision = QTypeRevision::zero();
QQmlAdaptorModel();
~QQmlAdaptorModel();
@@ -132,7 +132,7 @@ public:
int columnAt(int index) const;
int indexAt(int row, int column) const;
- void useImportVersion(int minorVersion);
+ void useImportVersion(QTypeRevision revision);
inline bool adaptsAim() const { return qobject_cast<QAbstractItemModel *>(object()); }
inline QAbstractItemModel *aim() { return static_cast<QAbstractItemModel *>(object()); }
@@ -140,10 +140,16 @@ public:
inline QVariant value(int index, const QString &role) const {
return accessors->value(*this, index, role); }
- inline QQmlDelegateModelItem *createItem(QQmlDelegateModelItemMetaType *metaType, int index) {
- return accessors->createItem(*this, metaType, index, rowAt(index), columnAt(index)); }
+ inline QQmlDelegateModelItem *createItem(
+ const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType, int index)
+ {
+ return accessors->createItem(*this, metaType, index, rowAt(index), columnAt(index));
+ }
inline bool hasProxyObject() const {
- return list.type() == QQmlListAccessor::Instance || list.type() == QQmlListAccessor::ListProperty; }
+ return list.type() == QQmlListAccessor::Instance
+ || list.type() == QQmlListAccessor::ListProperty
+ || list.type() == QQmlListAccessor::ObjectList;
+ }
inline bool notify(
const QList<QQmlDelegateModelItem *> &items,
diff --git a/src/qmlmodels/qqmldelegatemodel.cpp b/src/qmlmodels/qqmldelegatemodel.cpp
index 3a3903965c..3a05bf1689 100644
--- a/src/qmlmodels/qqmldelegatemodel.cpp
+++ b/src/qmlmodels/qqmldelegatemodel.cpp
@@ -731,7 +731,7 @@ QQmlListProperty<QQmlDelegateModelGroup> QQmlDelegateModel::groups()
QQmlDelegateModelPrivate::group_append,
QQmlDelegateModelPrivate::group_count,
QQmlDelegateModelPrivate::group_at,
- nullptr);
+ nullptr, nullptr, nullptr);
}
/*!
@@ -1211,11 +1211,13 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, QQ
}
Compositor::iterator it = m_compositor.find(group, index);
+ const auto flags = it->flags;
+ const auto modelIndex = it.modelIndex();
QQmlDelegateModelItem *cacheItem = it->inCache() ? m_cache.at(it.cacheIndex) : 0;
if (!cacheItem || !cacheItem->delegate) {
- QQmlComponent *delegate = resolveDelegate(it.modelIndex());
+ QQmlComponent *delegate = resolveDelegate(modelIndex);
if (!delegate)
return nullptr;
@@ -1226,17 +1228,17 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, QQ
// all related properties, and return the object (which
// has already been incubated, otherwise it wouldn't be in the pool).
addCacheItem(cacheItem, it);
- reuseItem(cacheItem, index, it->flags);
+ reuseItem(cacheItem, index, flags);
cacheItem->referenceObject();
return cacheItem->object;
}
// Since we could't find an available item in the pool, we create a new one
- cacheItem = m_adaptorModel.createItem(m_cacheMetaType, it.modelIndex());
+ cacheItem = m_adaptorModel.createItem(m_cacheMetaType, modelIndex);
if (!cacheItem)
return nullptr;
- cacheItem->groups = it->flags;
+ cacheItem->groups = flags;
addCacheItem(cacheItem, it);
}
@@ -2267,9 +2269,10 @@ void QV4::Heap::QQmlDelegateModelItemObject::destroy()
}
-QQmlDelegateModelItem::QQmlDelegateModelItem(QQmlDelegateModelItemMetaType *metaType,
- QQmlAdaptorModel::Accessors *accessor,
- int modelIndex, int row, int column)
+QQmlDelegateModelItem::QQmlDelegateModelItem(
+ const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType,
+ QQmlAdaptorModel::Accessors *accessor,
+ int modelIndex, int row, int column)
: v4(metaType->v4Engine)
, metaType(metaType)
, contextData(nullptr)
@@ -2285,8 +2288,6 @@ QQmlDelegateModelItem::QQmlDelegateModelItem(QQmlDelegateModelItemMetaType *meta
, row(row)
, column(column)
{
- metaType->addref();
-
if (accessor->propertyCache) {
// The property cache in the accessor is common for all the model
// items in the model it wraps. It describes available model roles,
@@ -2315,9 +2316,6 @@ QQmlDelegateModelItem::~QQmlDelegateModelItem()
else
delete incubationTask;
}
-
- metaType->release();
-
}
void QQmlDelegateModelItem::Dispose()
diff --git a/src/qmlmodels/qqmldelegatemodel_p.h b/src/qmlmodels/qqmldelegatemodel_p.h
index adb5f7008b..f4578e130e 100644
--- a/src/qmlmodels/qqmldelegatemodel_p.h
+++ b/src/qmlmodels/qqmldelegatemodel_p.h
@@ -86,7 +86,7 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlDelegateModel : public QQmlInstanceModel, p
Q_PROPERTY(QVariant rootIndex READ rootIndex WRITE setRootIndex NOTIFY rootIndexChanged)
Q_CLASSINFO("DefaultProperty", "delegate")
QML_NAMED_ELEMENT(DelegateModel)
- QML_ADDED_IN_MINOR_VERSION(1)
+ QML_ADDED_IN_VERSION(2, 1)
QML_ATTACHED(QQmlDelegateModelAttached)
Q_INTERFACES(QQmlParserStatus)
@@ -144,8 +144,6 @@ Q_SIGNALS:
void defaultGroupsChanged();
void rootIndexChanged();
void delegateChanged();
- void itemPooled(int index, QObject *object);
- void itemReused(int index, QObject *object);
private Q_SLOTS:
void _q_itemsChanged(int index, int count, const QVector<int> &roles);
@@ -174,7 +172,7 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlDelegateModelGroup : public QObject
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(bool includeByDefault READ defaultInclude WRITE setDefaultInclude NOTIFY defaultIncludeChanged)
QML_NAMED_ELEMENT(DelegateModelGroup)
- QML_ADDED_IN_MINOR_VERSION(1)
+ QML_ADDED_IN_VERSION(2, 1)
public:
QQmlDelegateModelGroup(QObject *parent = nullptr);
QQmlDelegateModelGroup(const QString &name, QQmlDelegateModel *model, int compositorType, QObject *parent = nullptr);
diff --git a/src/qmlmodels/qqmldelegatemodel_p_p.h b/src/qmlmodels/qqmldelegatemodel_p_p.h
index a1c4555d01..8684439508 100644
--- a/src/qmlmodels/qqmldelegatemodel_p_p.h
+++ b/src/qmlmodels/qqmldelegatemodel_p_p.h
@@ -100,11 +100,11 @@ class QQmlDelegateModelItem : public QObject
{
Q_OBJECT
Q_PROPERTY(int index READ modelIndex NOTIFY modelIndexChanged)
- Q_PROPERTY(int row READ modelRow NOTIFY rowChanged REVISION 12)
- Q_PROPERTY(int column READ modelColumn NOTIFY columnChanged REVISION 12)
+ Q_PROPERTY(int row READ modelRow NOTIFY rowChanged REVISION(2, 12))
+ Q_PROPERTY(int column READ modelColumn NOTIFY columnChanged REVISION(2, 12))
Q_PROPERTY(QObject *model READ modelObject CONSTANT)
public:
- QQmlDelegateModelItem(QQmlDelegateModelItemMetaType *metaType,
+ QQmlDelegateModelItem(const QQmlRefPointer<QQmlDelegateModelItemMetaType> &metaType,
QQmlAdaptorModel::Accessors *accessor, int modelIndex,
int row, int column);
~QQmlDelegateModelItem();
@@ -148,7 +148,7 @@ public:
static QV4::ReturnedValue get_index(QQmlDelegateModelItem *thisItem, uint flag, const QV4::Value &arg);
QV4::ExecutionEngine *v4;
- QQmlDelegateModelItemMetaType * const metaType;
+ QQmlRefPointer<QQmlDelegateModelItemMetaType> const metaType;
QQmlContextDataRef contextData;
QPointer<QObject> object;
QPointer<QQmlDelegateModelAttached> attached;
@@ -162,8 +162,8 @@ public:
Q_SIGNALS:
void modelIndexChanged();
- Q_REVISION(12) void rowChanged();
- Q_REVISION(12) void columnChanged();
+ Q_REVISION(2, 12) void rowChanged();
+ Q_REVISION(2, 12) void columnChanged();
protected:
void objectDestroyed(QObject *);
diff --git a/src/qmlmodels/qqmlinstantiator_p.h b/src/qmlmodels/qqmlinstantiator_p.h
index 9f6d816d18..fec5c3888a 100644
--- a/src/qmlmodels/qqmlinstantiator_p.h
+++ b/src/qmlmodels/qqmlinstantiator_p.h
@@ -73,7 +73,7 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlInstantiator : public QObject, public QQmlP
Q_PROPERTY(QObject *object READ object NOTIFY objectChanged)
Q_CLASSINFO("DefaultProperty", "delegate")
QML_NAMED_ELEMENT(Instantiator)
- QML_ADDED_IN_MINOR_VERSION(1)
+ QML_ADDED_IN_VERSION(2, 1)
public:
QQmlInstantiator(QObject *parent = nullptr);
diff --git a/src/qmlmodels/qqmllistaccessor.cpp b/src/qmlmodels/qqmllistaccessor.cpp
index c450c616e7..69427df184 100644
--- a/src/qmlmodels/qqmllistaccessor.cpp
+++ b/src/qmlmodels/qqmllistaccessor.cpp
@@ -80,6 +80,8 @@ void QQmlListAccessor::setList(const QVariant &v, QQmlEngine *engine)
m_type = StringList;
} else if (d.userType() == QMetaType::QVariantList) {
m_type = VariantList;
+ } else if (d.userType() == qMetaTypeId<QList<QObject *>>()) {
+ m_type = ObjectList;
} else if (d.canConvert(QMetaType::Int)) {
// Here we have to check for an upper limit, because down the line code might (well, will)
// allocate memory depending on the number of elements. The upper limit cannot be INT_MAX:
@@ -120,6 +122,8 @@ int QQmlListAccessor::count() const
return qvariant_cast<QStringList>(d).count();
case VariantList:
return qvariant_cast<QVariantList>(d).count();
+ case ObjectList:
+ return qvariant_cast<QList<QObject *>>(d).count();
case ListProperty:
return ((const QQmlListReference *)d.constData())->count();
case Instance:
@@ -140,6 +144,8 @@ QVariant QQmlListAccessor::at(int idx) const
return QVariant::fromValue(qvariant_cast<QStringList>(d).at(idx));
case VariantList:
return qvariant_cast<QVariantList>(d).at(idx);
+ case ObjectList:
+ return QVariant::fromValue(qvariant_cast<QList<QObject *>>(d).at(idx));
case ListProperty:
return QVariant::fromValue(((const QQmlListReference *)d.constData())->at(idx));
case Instance:
diff --git a/src/qmlmodels/qqmllistaccessor_p.h b/src/qmlmodels/qqmllistaccessor_p.h
index bcd079adef..a57e4173e3 100644
--- a/src/qmlmodels/qqmllistaccessor_p.h
+++ b/src/qmlmodels/qqmllistaccessor_p.h
@@ -70,7 +70,7 @@ public:
int count() const;
QVariant at(int) const;
- enum Type { Invalid, StringList, VariantList, ListProperty, Instance, Integer };
+ enum Type { Invalid, StringList, VariantList, ObjectList, ListProperty, Instance, Integer };
Type type() const { return m_type; }
private:
diff --git a/src/qmlmodels/qqmllistmodel.cpp b/src/qmlmodels/qqmllistmodel.cpp
index 2c05b04429..e58fc19178 100644
--- a/src/qmlmodels/qqmllistmodel.cpp
+++ b/src/qmlmodels/qqmllistmodel.cpp
@@ -2786,10 +2786,12 @@ bool QQmlListModelParser::applyProperty(
QV4::ScopedContext context(scope, QV4::QmlContext::create(v4->rootContext(), QQmlContextData::get(qmlContext(model->m_modelCache)), nullptr));
QV4::ScopedFunctionObject function(scope, QV4::FunctionObject::createScriptFunction(context, compilationUnit->runtimeFunctions[id]));
- QV4::ReturnedValue result = function->call(v4->globalObject, nullptr, 0);
-
QJSValue v;
- QJSValuePrivate::setValue(&v, v4, result);
+ QV4::ScopedValue result(scope, function->call(v4->globalObject, nullptr, 0));
+ if (v4->hasException)
+ v4->catchException();
+ else
+ QJSValuePrivate::setValue(&v, v4, result->asReturnedValue());
value.setValue<QJSValue>(v);
} else {
QByteArray script = scriptStr.toUtf8();
diff --git a/src/qmlmodels/qqmllistmodel_p.h b/src/qmlmodels/qqmllistmodel_p.h
index dc5063eb97..bf4279cd05 100644
--- a/src/qmlmodels/qqmllistmodel_p.h
+++ b/src/qmlmodels/qqmllistmodel_p.h
@@ -82,8 +82,9 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlListModel : public QAbstractListModel
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(bool dynamicRoles READ dynamicRoles WRITE setDynamicRoles)
- Q_PROPERTY(QObject *agent READ agent CONSTANT REVISION(14))
+ Q_PROPERTY(QObject *agent READ agent CONSTANT REVISION(2, 14))
QML_NAMED_ELEMENT(ListModel)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQmlListModel(QObject *parent=nullptr);
@@ -174,6 +175,7 @@ class QQmlListElement : public QObject
{
Q_OBJECT
QML_NAMED_ELEMENT(ListElement)
+ QML_ADDED_IN_VERSION(2, 0)
};
class QQmlListModelParser : public QQmlCustomParser
diff --git a/src/qmlmodels/qqmllistmodelworkeragent_p.h b/src/qmlmodels/qqmllistmodelworkeragent_p.h
index f65909dcec..1700ff755f 100644
--- a/src/qmlmodels/qqmllistmodelworkeragent_p.h
+++ b/src/qmlmodels/qqmllistmodelworkeragent_p.h
@@ -73,6 +73,7 @@ class QQmlListModelWorkerAgent : public QObject
Q_PROPERTY(int count READ count)
Q_PROPERTY(QV4::ExecutionEngine *engine READ engine WRITE setEngine NOTIFY engineChanged)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQmlListModelWorkerAgent(QQmlListModel *);
diff --git a/src/qmlmodels/qqmlmodelsmodule_p.h b/src/qmlmodels/qqmlmodelsmodule_p.h
index e3e43f3922..70268f53f2 100644
--- a/src/qmlmodels/qqmlmodelsmodule_p.h
+++ b/src/qmlmodels/qqmlmodelsmodule_p.h
@@ -67,7 +67,7 @@ struct QItemSelectionModelForeign
Q_GADGET
QML_FOREIGN(QItemSelectionModel)
QML_NAMED_ELEMENT(ItemSelectionModel)
- QML_ADDED_IN_MINOR_VERSION(2)
+ QML_ADDED_IN_VERSION(2, 2)
};
#endif
diff --git a/src/qmlmodels/qqmlobjectmodel.cpp b/src/qmlmodels/qqmlobjectmodel.cpp
index 85e64cc2f9..dac868a0a2 100644
--- a/src/qmlmodels/qqmlobjectmodel.cpp
+++ b/src/qmlmodels/qqmlobjectmodel.cpp
@@ -91,6 +91,15 @@ public:
static_cast<QQmlObjectModelPrivate *>(prop->data)->clear();
}
+ static void children_replace(QQmlListProperty<QObject> *prop, int index, QObject *item) {
+ static_cast<QQmlObjectModelPrivate *>(prop->data)->replace(index, item);
+ }
+
+ static void children_removeLast(QQmlListProperty<QObject> *prop) {
+ auto data = static_cast<QQmlObjectModelPrivate *>(prop->data);
+ data->remove(data->children.count() - 1, 1);
+ }
+
void insert(int index, QObject *item) {
Q_Q(QQmlObjectModel);
children.insert(index, Item(item));
@@ -105,6 +114,18 @@ public:
emit q->childrenChanged();
}
+ void replace(int index, QObject *item) {
+ Q_Q(QQmlObjectModel);
+ auto *attached = QQmlObjectModelAttached::properties(children.at(index).item);
+ attached->setIndex(-1);
+ children.replace(index, Item(item));
+ QQmlObjectModelAttached::properties(children.at(index).item)->setIndex(index);
+ QQmlChangeSet changeSet;
+ changeSet.change(index, 1);
+ emit q->modelUpdated(changeSet, false);
+ emit q->childrenChanged();
+ }
+
void move(int from, int to, int n) {
Q_Q(QQmlObjectModel);
if (from > to) {
@@ -229,12 +250,13 @@ QQmlObjectModel::QQmlObjectModel(QObject *parent)
QQmlListProperty<QObject> QQmlObjectModel::children()
{
Q_D(QQmlObjectModel);
- return QQmlListProperty<QObject>(this,
- d,
- d->children_append,
- d->children_count,
- d->children_at,
- d->children_clear);
+ return QQmlListProperty<QObject>(this, d,
+ QQmlObjectModelPrivate::children_append,
+ QQmlObjectModelPrivate::children_count,
+ QQmlObjectModelPrivate::children_at,
+ QQmlObjectModelPrivate::children_clear,
+ QQmlObjectModelPrivate::children_replace,
+ QQmlObjectModelPrivate::children_removeLast);
}
/*!
diff --git a/src/qmlmodels/qqmlobjectmodel_p.h b/src/qmlmodels/qqmlobjectmodel_p.h
index 6c68e55012..761e9c73ec 100644
--- a/src/qmlmodels/qqmlobjectmodel_p.h
+++ b/src/qmlmodels/qqmlobjectmodel_p.h
@@ -70,6 +70,7 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlInstanceModel : public QObject
Q_PROPERTY(int count READ count NOTIFY countChanged)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
enum ReusableFlag {
@@ -104,6 +105,8 @@ Q_SIGNALS:
void createdItem(int index, QObject *object);
void initItem(int index, QObject *object);
void destroyingItem(QObject *object);
+ Q_REVISION(2, 15) void itemPooled(int index, QObject *object);
+ Q_REVISION(2, 15) void itemReused(int index, QObject *object);
protected:
QQmlInstanceModel(QObjectPrivate &dd, QObject *parent = nullptr)
@@ -123,7 +126,7 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlObjectModel : public QQmlInstanceModel
Q_PROPERTY(QQmlListProperty<QObject> children READ children NOTIFY childrenChanged DESIGNABLE false)
Q_CLASSINFO("DefaultProperty", "children")
QML_NAMED_ELEMENT(ObjectModel)
- QML_ADDED_IN_MINOR_VERSION(1)
+ QML_ADDED_IN_VERSION(2, 1)
QML_ATTACHED(QQmlObjectModelAttached)
public:
@@ -144,14 +147,14 @@ public:
static QQmlObjectModelAttached *qmlAttachedProperties(QObject *obj);
- Q_REVISION(3) Q_INVOKABLE QObject *get(int index) const;
- Q_REVISION(3) Q_INVOKABLE void append(QObject *object);
- Q_REVISION(3) Q_INVOKABLE void insert(int index, QObject *object);
- Q_REVISION(3) Q_INVOKABLE void move(int from, int to, int n = 1);
- Q_REVISION(3) Q_INVOKABLE void remove(int index, int n = 1);
+ Q_REVISION(2, 3) Q_INVOKABLE QObject *get(int index) const;
+ Q_REVISION(2, 3) Q_INVOKABLE void append(QObject *object);
+ Q_REVISION(2, 3) Q_INVOKABLE void insert(int index, QObject *object);
+ Q_REVISION(2, 3) Q_INVOKABLE void move(int from, int to, int n = 1);
+ Q_REVISION(2, 3) Q_INVOKABLE void remove(int index, int n = 1);
public Q_SLOTS:
- Q_REVISION(3) void clear();
+ Q_REVISION(2, 3) void clear();
Q_SIGNALS:
void childrenChanged();
diff --git a/src/qmlmodels/qqmltableinstancemodel.cpp b/src/qmlmodels/qqmltableinstancemodel.cpp
index b4d1e61e31..8c034356f3 100644
--- a/src/qmlmodels/qqmltableinstancemodel.cpp
+++ b/src/qmlmodels/qqmltableinstancemodel.cpp
@@ -78,13 +78,14 @@ void QQmlTableInstanceModel::deleteModelItemLater(QQmlDelegateModelItem *modelIt
QQmlTableInstanceModel::QQmlTableInstanceModel(QQmlContext *qmlContext, QObject *parent)
: QQmlInstanceModel(*(new QObjectPrivate()), parent)
, m_qmlContext(qmlContext)
- , m_metaType(new QQmlDelegateModelItemMetaType(m_qmlContext->engine()->handle(), nullptr, QStringList()))
+ , m_metaType(new QQmlDelegateModelItemMetaType(m_qmlContext->engine()->handle(), nullptr, QStringList()),
+ QQmlRefPointer<QQmlDelegateModelItemMetaType>::Adopt)
{
}
-void QQmlTableInstanceModel::useImportVersion(int minorVersion)
+void QQmlTableInstanceModel::useImportVersion(QTypeRevision version)
{
- m_adaptorModel.useImportVersion(minorVersion);
+ m_adaptorModel.useImportVersion(version);
}
QQmlTableInstanceModel::~QQmlTableInstanceModel()
@@ -149,7 +150,7 @@ QQmlDelegateModelItem *QQmlTableInstanceModel::resolveModelItem(int index)
}
// Create a new item from scratch
- modelItem = m_adaptorModel.createItem(m_metaType, index);
+ modelItem = m_adaptorModel.createItem(m_metaType.data(), index);
if (modelItem) {
modelItem->delegate = delegate;
m_modelItems.insert(index, modelItem);
@@ -242,6 +243,25 @@ void QQmlTableInstanceModel::destroyModelItem(QQmlDelegateModelItem *modelItem)
delete modelItem;
}
+void QQmlTableInstanceModel::dispose(QObject *object)
+{
+ Q_ASSERT(object);
+ auto modelItem = qvariant_cast<QQmlDelegateModelItem *>(object->property(kModelItemTag));
+ Q_ASSERT(modelItem);
+
+ modelItem->releaseObject();
+
+ // The item is not referenced by anyone
+ Q_ASSERT(!modelItem->isObjectReferenced());
+ Q_ASSERT(!modelItem->isReferenced());
+
+ m_modelItems.remove(modelItem->index);
+
+ emit destroyingItem(object);
+ delete object;
+ delete modelItem;
+}
+
void QQmlTableInstanceModel::cancel(int index)
{
auto modelItem = m_modelItems.value(index);
diff --git a/src/qmlmodels/qqmltableinstancemodel_p.h b/src/qmlmodels/qqmltableinstancemodel_p.h
index d924455918..57b9b26e43 100644
--- a/src/qmlmodels/qqmltableinstancemodel_p.h
+++ b/src/qmlmodels/qqmltableinstancemodel_p.h
@@ -89,7 +89,7 @@ public:
QQmlTableInstanceModel(QQmlContext *qmlContext, QObject *parent = nullptr);
~QQmlTableInstanceModel() override;
- void useImportVersion(int minorVersion);
+ void useImportVersion(QTypeRevision version);
int count() const override { return m_adaptorModel.count(); }
int rows() const { return m_adaptorModel.rowCount(); }
@@ -110,6 +110,7 @@ public:
QObject *object(int index, QQmlIncubator::IncubationMode incubationMode = QQmlIncubator::AsynchronousIfNested) override;
ReleaseFlags release(QObject *object, ReusableFlag reusable = NotReusable) override;
+ void dispose(QObject *object);
void cancel(int) override;
void drainReusableItemsPool(int maxPoolTime) override;
@@ -122,10 +123,6 @@ public:
void setWatchedRoles(const QList<QByteArray> &) override { Q_UNREACHABLE(); }
int indexOf(QObject *, QObject *) const override { Q_UNREACHABLE(); return 0; }
-Q_SIGNALS:
- void itemPooled(int index, QObject *object);
- void itemReused(int index, QObject *object);
-
private:
QQmlComponent *resolveDelegate(int index);
@@ -133,7 +130,7 @@ private:
QQmlAbstractDelegateComponent *m_delegateChooser = nullptr;
QQmlComponent *m_delegate = nullptr;
QPointer<QQmlContext> m_qmlContext;
- QQmlDelegateModelItemMetaType *m_metaType;
+ QQmlRefPointer<QQmlDelegateModelItemMetaType> m_metaType;
QHash<int, QQmlDelegateModelItem *> m_modelItems;
QQmlReusableDelegateModelItemsPool m_reusableItemsPool;
diff --git a/src/qmlmodels/qquickpackage.cpp b/src/qmlmodels/qquickpackage.cpp
index 567381e5ab..42e7d0e09f 100644
--- a/src/qmlmodels/qquickpackage.cpp
+++ b/src/qmlmodels/qquickpackage.cpp
@@ -115,6 +115,14 @@ public:
QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
return list->count();
}
+ static void data_replace(QQmlListProperty<QObject> *prop, int index, QObject *o) {
+ QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
+ list->replace(index, DataGuard(o, list));
+ }
+ static void data_removeLast(QQmlListProperty<QObject> *prop) {
+ QList<DataGuard> *list = static_cast<QList<DataGuard> *>(prop->data);
+ list->removeLast();
+ }
};
QHash<QObject *, QQuickPackageAttached *> QQuickPackageAttached::attached;
@@ -152,10 +160,13 @@ QQuickPackage::~QQuickPackage()
QQmlListProperty<QObject> QQuickPackage::data()
{
Q_D(QQuickPackage);
- return QQmlListProperty<QObject>(this, &d->dataList, QQuickPackagePrivate::data_append,
- QQuickPackagePrivate::data_count,
- QQuickPackagePrivate::data_at,
- QQuickPackagePrivate::data_clear);
+ return QQmlListProperty<QObject>(this, &d->dataList,
+ QQuickPackagePrivate::data_append,
+ QQuickPackagePrivate::data_count,
+ QQuickPackagePrivate::data_at,
+ QQuickPackagePrivate::data_clear,
+ QQuickPackagePrivate::data_replace,
+ QQuickPackagePrivate::data_removeLast);
}
bool QQuickPackage::hasPart(const QString &name)
diff --git a/src/qmlmodels/qquickpackage_p.h b/src/qmlmodels/qquickpackage_p.h
index 801b8d8409..f40ffe552a 100644
--- a/src/qmlmodels/qquickpackage_p.h
+++ b/src/qmlmodels/qquickpackage_p.h
@@ -67,6 +67,7 @@ class Q_AUTOTEST_EXPORT QQuickPackage : public QObject
Q_CLASSINFO("DefaultProperty", "data")
QML_NAMED_ELEMENT(Package)
+ QML_ADDED_IN_VERSION(2, 0)
QML_ATTACHED(QQuickPackageAttached)
Q_PROPERTY(QQmlListProperty<QObject> data READ data)
diff --git a/src/qmlmodels/qtqmlmodelsglobal_p.h b/src/qmlmodels/qtqmlmodelsglobal_p.h
index 145112c9c1..1a1157138d 100644
--- a/src/qmlmodels/qtqmlmodelsglobal_p.h
+++ b/src/qmlmodels/qtqmlmodelsglobal_p.h
@@ -58,4 +58,6 @@
#define Q_QMLMODELS_PRIVATE_EXPORT Q_QMLMODELS_EXPORT
#define Q_QMLMODELS_AUTOTEST_EXPORT Q_AUTOTEST_EXPORT
+void Q_QMLMODELS_PRIVATE_EXPORT qml_register_types_QtQml_Models();
+
#endif // QTQMLMODELSGLOBAL_P_H
diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp
index 470b3c0f7a..96a5c20f22 100644
--- a/src/qmltest/quicktest.cpp
+++ b/src/qmltest/quicktest.cpp
@@ -52,7 +52,7 @@
#include <QtQml/qqmlpropertymap.h>
#include <QtQuick/private/qquickitem_p.h>
#include <QtQuick/qquickitem.h>
-#include <QtGui/qopengl.h>
+#include <qopengl.h>
#include <QtCore/qurl.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qdir.h>
diff --git a/src/qmltest/quicktestresult_p.h b/src/qmltest/quicktestresult_p.h
index 81b9d78830..7ebfb21186 100644
--- a/src/qmltest/quicktestresult_p.h
+++ b/src/qmltest/quicktestresult_p.h
@@ -158,10 +158,10 @@ public Q_SLOTS:
QObject *grabImage(QQuickItem *item);
- Q_REVISION(1) QObject *findChild(QObject *parent, const QString &objectName);
+ Q_REVISION(1, 1) QObject *findChild(QObject *parent, const QString &objectName);
- Q_REVISION(13) bool isPolishScheduled(QQuickItem *item) const;
- Q_REVISION(13) bool waitForItemPolished(QQuickItem *item, int timeout);
+ Q_REVISION(1, 13) bool isPolishScheduled(QQuickItem *item) const;
+ Q_REVISION(1, 13) bool waitForItemPolished(QQuickItem *item, int timeout);
public:
// Helper functions for the C++ main() shell.
diff --git a/src/qmltyperegistrar/qmltyperegistrar.cpp b/src/qmltyperegistrar/qmltyperegistrar.cpp
index 4738e28314..33f1ebbbd5 100644
--- a/src/qmltyperegistrar/qmltyperegistrar.cpp
+++ b/src/qmltyperegistrar/qmltyperegistrar.cpp
@@ -47,14 +47,32 @@ struct ScopedPointerFileCloser
static inline void cleanup(FILE *handle) { if (handle) fclose(handle); }
};
-static bool acceptClassForQmlTypeRegistration(const QJsonObject &classDef)
+enum RegistrationMode {
+ NoRegistration,
+ ObjectRegistration,
+ GadgetRegistration,
+ NamespaceRegistration
+};
+
+static RegistrationMode qmlTypeRegistrationMode(const QJsonObject &classDef)
{
const QJsonArray classInfos = classDef[QLatin1String("classInfos")].toArray();
for (const QJsonValue &info: classInfos) {
- if (info[QLatin1String("name")].toString() == QLatin1String("QML.Element"))
- return true;
+ const QString name = info[QLatin1String("name")].toString();
+ if (name == QLatin1String("QML.Element")) {
+ if (classDef[QLatin1String("object")].toBool())
+ return ObjectRegistration;
+ if (classDef[QLatin1String("gadget")].toBool())
+ return GadgetRegistration;
+ if (classDef[QLatin1String("namespace")].toBool())
+ return NamespaceRegistration;
+ qWarning() << "Not registering classInfo which is neither an object, "
+ "nor a gadget, nor a namespace:"
+ << name;
+ break;
+ }
}
- return false;
+ return NoRegistration;
}
static bool argumentsFromCommandLineAndFile(QStringList &allArguments, const QStringList &arguments)
@@ -317,7 +335,10 @@ int main(int argc, char **argv)
const QJsonArray classes = metaObject[QLatin1String("classes")].toArray();
for (const auto &cls : classes) {
QJsonObject classDef = cls.toObject();
- if (acceptClassForQmlTypeRegistration(classDef)) {
+ switch (qmlTypeRegistrationMode(classDef)) {
+ case NamespaceRegistration:
+ case GadgetRegistration:
+ case ObjectRegistration: {
const QString include = metaObject[QLatin1String("inputFile")].toString();
const bool declaredInHeader = include.endsWith(QLatin1String(".h"));
if (declaredInHeader) {
@@ -329,9 +350,13 @@ int main(int argc, char **argv)
qPrintable(classDef.value(QLatin1String("qualifiedClassName"))
.toString()));
}
+
types.append(classDef);
- } else {
+ break;
+ }
+ case NoRegistration:
foreignTypes.append(classDef);
+ break;
}
}
};
@@ -393,16 +418,22 @@ int main(int argc, char **argv)
continue;
const QString className = classDef[QLatin1String("qualifiedClassName")].toString();
- fprintf(output, "\n qmlRegisterTypesAndRevisions<%s>(\"%s\", %s);", qPrintable(className),
- qPrintable(module), qPrintable(majorVersion));
+
+ if (classDef.value(QLatin1String("namespace")).toBool()) {
+ fprintf(output, "\n qmlRegisterNamespaceAndRevisions(&%s::staticMetaObject, \"%s\", %s);",
+ qPrintable(className), qPrintable(module), qPrintable(majorVersion));
+ } else {
+ fprintf(output, "\n qmlRegisterTypesAndRevisions<%s>(\"%s\", %s);",
+ qPrintable(className), qPrintable(module), qPrintable(majorVersion));
+ }
}
fprintf(output, "\n qmlRegisterModule(\"%s\", %s, %s);",
qPrintable(module), qPrintable(majorVersion),
qPrintable(parser.value(minorVersionOption)));
fprintf(output, "\n}\n");
- fprintf(output, "\nstatic const QQmlModuleRegistration registration(\"%s\", %s, %s);\n",
- qPrintable(module), qPrintable(majorVersion), qPrintable(functionName));
+ fprintf(output, "\nstatic const QQmlModuleRegistration registration(\"%s\", %s);\n",
+ qPrintable(module), qPrintable(functionName));
if (!parser.isSet(pluginTypesOption))
return EXIT_SUCCESS;
@@ -447,7 +478,7 @@ int main(int argc, char **argv)
creator.setOwnTypes(std::move(types));
creator.setForeignTypes(std::move(foreignTypes));
creator.setModule(module);
- creator.setMajorVersion(parser.value(majorVersionOption).toInt());
+ creator.setVersion(QTypeRevision::fromVersion(parser.value(majorVersionOption).toInt(), 0));
creator.generate(parser.value(pluginTypesOption), parser.value(dependenciesOption));
return EXIT_SUCCESS;
diff --git a/src/qmltyperegistrar/qmltypesclassdescription.cpp b/src/qmltyperegistrar/qmltypesclassdescription.cpp
index 15a8113ac8..e21abd97bc 100644
--- a/src/qmltyperegistrar/qmltypesclassdescription.cpp
+++ b/src/qmltyperegistrar/qmltypesclassdescription.cpp
@@ -27,18 +27,19 @@
****************************************************************************/
#include "qmltypesclassdescription.h"
+#include "qmltypescreator.h"
#include <QtCore/qjsonarray.h>
static void collectExtraVersions(const QJsonObject *component, const QString &key,
- QList<int> &extraVersions)
+ QList<QTypeRevision> &extraVersions)
{
const QJsonArray &items = component->value(key).toArray();
for (const QJsonValue &item : items) {
const QJsonObject obj = item.toObject();
const auto revision = obj.find(QLatin1String("revision"));
if (revision != obj.end()) {
- const int extraVersion = revision.value().toInt();
+ const auto extraVersion = QTypeRevision::fromEncodedVersion(revision.value().toInt());
if (!extraVersions.contains(extraVersion))
extraVersions.append(extraVersion);
}
@@ -60,7 +61,7 @@ const QJsonObject *QmlTypesClassDescription::findType(const QVector<QJsonObject>
void QmlTypesClassDescription::collect(const QJsonObject *classDef,
const QVector<QJsonObject> &types,
const QVector<QJsonObject> &foreign,
- bool topLevel)
+ CollectMode mode, QTypeRevision defaultRevision)
{
const auto classInfos = classDef->value(QLatin1String("classInfos")).toArray();
for (const QJsonValue &classInfo : classInfos) {
@@ -69,18 +70,19 @@ void QmlTypesClassDescription::collect(const QJsonObject *classDef,
const QString value = obj[QLatin1String("value")].toString();
if (name == QLatin1String("DefaultProperty")) {
- if (defaultProp.isEmpty())
+ if (mode != AttachedType && defaultProp.isEmpty())
defaultProp = value;
- } else if (name == QLatin1String("QML.AddedInMinorVersion")) {
- if (topLevel) {
- addedInRevision = value.toInt();
- revisions.append(value.toInt());
+ } else if (name == QLatin1String("QML.AddedInVersion")) {
+ const QTypeRevision revision = QTypeRevision::fromEncodedVersion(value.toInt());
+ if (mode == TopLevel) {
+ addedInRevision = revision;
+ revisions.append(revision);
} else if (!elementName.isEmpty()) {
- revisions.append(value.toInt());
+ revisions.append(revision);
}
}
- if (!topLevel)
+ if (mode != TopLevel)
continue;
// These only apply to the original class
@@ -89,32 +91,28 @@ void QmlTypesClassDescription::collect(const QJsonObject *classDef,
elementName = classDef->value(QLatin1String("className")).toString();
else if (value != QLatin1String("anonymous"))
elementName = value;
- } else if (name == QLatin1String("QML.RemovedInMinorVersion")) {
- removedInRevision = value.toInt();
+ } else if (name == QLatin1String("QML.RemovedInVersion")) {
+ removedInRevision = QTypeRevision::fromEncodedVersion(value.toInt());
} else if (name == QLatin1String("QML.Creatable")) {
isCreatable = (value != QLatin1String("false"));
} else if (name == QLatin1String("QML.Attached")) {
- attachedType = value;
- if (const QJsonObject *other = findType(types, attachedType))
- collect(other, types, foreign, false);
- else if (const QJsonObject *other = findType(foreign, attachedType))
- collect(other, types, foreign, false);
+ collectAttached(value, types, foreign, defaultRevision);
} else if (name == QLatin1String("QML.Singleton")) {
if (value == QLatin1String("true"))
isSingleton = true;
} else if (name == QLatin1String("QML.Foreign")) {
if (const QJsonObject *other = findType(foreign, value)) {
classDef = other;
- if (defaultProp.isEmpty()) {
- // Foreign type can have a default property
- const auto classInfos = classDef->value(QLatin1String("classInfos")).toArray();
- for (const QJsonValue &classInfo : classInfos) {
- QJsonObject obj = classInfo.toObject();
- if (obj[QLatin1String("name")].toString() == QLatin1String("DefaultProperty")) {
- defaultProp = obj[QLatin1String("value")].toString();
- break;
- }
- }
+ // Foreign type can have a default property or an attached types
+ const auto classInfos = classDef->value(QLatin1String("classInfos")).toArray();
+ for (const QJsonValue &classInfo : classInfos) {
+ const QJsonObject obj = classInfo.toObject();
+ const QString foreignName = obj[QLatin1String("name")].toString();
+ const QString foreignValue = obj[QLatin1String("value")].toString();
+ if (defaultProp.isEmpty() && foreignName == QLatin1String("DefaultProperty"))
+ defaultProp = foreignValue;
+ else if (foreignName == QLatin1String("QML.Attached"))
+ collectAttached(foreignValue, types, foreign, defaultRevision);
}
}
} else if (name == QLatin1String("QML.Root")) {
@@ -125,7 +123,7 @@ void QmlTypesClassDescription::collect(const QJsonObject *classDef,
}
}
- if (!elementName.isEmpty()) {
+ if (mode == AttachedType || !elementName.isEmpty()) {
collectExtraVersions(classDef, QString::fromLatin1("properties"), revisions);
collectExtraVersions(classDef, QString::fromLatin1("slots"), revisions);
collectExtraVersions(classDef, QString::fromLatin1("methods"), revisions);
@@ -137,19 +135,22 @@ void QmlTypesClassDescription::collect(const QJsonObject *classDef,
const QJsonObject superObject = supers.first().toObject();
if (superObject[QLatin1String("access")].toString() == QLatin1String("public")) {
const QString superName = superObject[QLatin1String("name")].toString();
- if (topLevel && superClass.isEmpty())
+ if (mode == TopLevel && superClass.isEmpty())
superClass = superName;
+ const CollectMode superMode = (mode == TopLevel) ? SuperClass : AttachedType;
if (const QJsonObject *other = findType(types, superName))
- collect(other, types, foreign, false);
+ collect(other, types, foreign, superMode, defaultRevision);
else if (const QJsonObject *other = findType(foreign, superName))
- collect(other, types, foreign, false);
+ collect(other, types, foreign, superMode, defaultRevision);
}
}
- if (addedInRevision == -1) {
- revisions.append(0);
- addedInRevision = 0;
+ if (!addedInRevision.isValid()) {
+ revisions.append(defaultRevision);
+ addedInRevision = defaultRevision;
+ } else if (addedInRevision < defaultRevision) {
+ revisions.append(defaultRevision);
}
std::sort(revisions.begin(), revisions.end());
@@ -157,4 +158,19 @@ void QmlTypesClassDescription::collect(const QJsonObject *classDef,
revisions.erase(end, revisions.end());
resolvedClass = classDef;
+
+ // If it's not a QObject, it's not creatable
+ isCreatable = isCreatable && classDef->value(QLatin1String("object")).toBool();
+}
+
+void QmlTypesClassDescription::collectAttached(const QString &attached,
+ const QVector<QJsonObject> &types,
+ const QVector<QJsonObject> &foreign,
+ QTypeRevision defaultRevision)
+{
+ attachedType = attached;
+ if (const QJsonObject *other = findType(types, attachedType))
+ collect(other, types, foreign, AttachedType, defaultRevision);
+ else if (const QJsonObject *other = findType(foreign, attachedType))
+ collect(other, types, foreign, AttachedType, defaultRevision);
}
diff --git a/src/qmltyperegistrar/qmltypesclassdescription.h b/src/qmltyperegistrar/qmltypesclassdescription.h
index 8f3a6ea124..e4ae37a84e 100644
--- a/src/qmltyperegistrar/qmltypesclassdescription.h
+++ b/src/qmltyperegistrar/qmltypesclassdescription.h
@@ -33,6 +33,7 @@
#include <QtCore/qjsonobject.h>
#include <QtCore/qvector.h>
#include <QtCore/qset.h>
+#include <QtCore/qversionnumber.h>
struct QmlTypesClassDescription
{
@@ -41,16 +42,25 @@ struct QmlTypesClassDescription
QString defaultProp;
QString superClass;
QString attachedType;
- QList<int> revisions;
- int addedInRevision = -1;
- int removedInRevision = -1;
+ QList<QTypeRevision> revisions;
+ QTypeRevision addedInRevision;
+ QTypeRevision removedInRevision;
bool isCreatable = true;
bool isSingleton = false;
bool isRootClass = false;
bool isBuiltin = false;
+ enum CollectMode {
+ TopLevel,
+ SuperClass,
+ AttachedType
+ };
+
void collect(const QJsonObject *classDef, const QVector<QJsonObject> &types,
- const QVector<QJsonObject> &foreign, bool topLevel);
+ const QVector<QJsonObject> &foreign, CollectMode mode,
+ QTypeRevision defaultRevision);
+ void collectAttached(const QString &attached, const QVector<QJsonObject> &types,
+ const QVector<QJsonObject> &foreign, QTypeRevision defaultRevision);
static const QJsonObject *findType(const QVector<QJsonObject> &types, const QString &name);
};
diff --git a/src/qmltyperegistrar/qmltypescreator.cpp b/src/qmltyperegistrar/qmltypescreator.cpp
index 911120027e..3569bbe253 100644
--- a/src/qmltyperegistrar/qmltypescreator.cpp
+++ b/src/qmltyperegistrar/qmltypescreator.cpp
@@ -35,6 +35,7 @@
#include <QtCore/qsavefile.h>
#include <QtCore/qfile.h>
#include <QtCore/qjsondocument.h>
+#include <QtCore/qversionnumber.h>
static QString enquote(const QString &string)
{
@@ -62,24 +63,24 @@ void QmlTypesCreator::writeClassProperties(const QmlTypesClassDescription &colle
QStringList exports;
QStringList metaObjects;
+ if (collector.isBuiltin) {
+ exports.append(enquote(QString::fromLatin1("QML/%1 1.0").arg(collector.elementName)));
+ metaObjects.append(QString::number(QTypeRevision::fromVersion(1, 0).toEncodedVersion<quint16>()));
+ }
+
for (auto it = collector.revisions.begin(), end = collector.revisions.end(); it != end; ++it) {
- const int revision = *it;
+ const QTypeRevision revision = *it;
if (revision < collector.addedInRevision)
continue;
- if (collector.removedInRevision > collector.addedInRevision
- && revision >= collector.removedInRevision) {
+ if (collector.removedInRevision.isValid() && !(revision < collector.removedInRevision))
break;
- }
-
- if (collector.isBuiltin) {
- exports.append(enquote(QString::fromLatin1("QML/%1 1.0").arg(collector.elementName)));
- metaObjects.append(QLatin1String("0"));
- }
exports.append(enquote(QString::fromLatin1("%1/%2 %3.%4")
- .arg(m_module).arg(collector.elementName)
- .arg(m_majorVersion).arg(revision)));
- metaObjects.append(QString::number(revision));
+ .arg(m_module).arg(collector.elementName)
+ .arg(revision.hasMajorVersion() ? revision.majorVersion()
+ : m_version.majorVersion())
+ .arg(revision.minorVersion())));
+ metaObjects.append(QString::number(revision.toEncodedVersion<quint16>()));
}
m_qml.writeArrayBinding(QLatin1String("exports"), exports);
@@ -245,7 +246,8 @@ void QmlTypesCreator::writeComponents()
m_qml.writeStartObject(componentElement);
QmlTypesClassDescription collector;
- collector.collect(&component, m_ownTypes, m_foreignTypes, true);
+ collector.collect(&component, m_ownTypes, m_foreignTypes,
+ QmlTypesClassDescription::TopLevel, m_version);
writeClassProperties(collector);
diff --git a/src/qmltyperegistrar/qmltypescreator.h b/src/qmltyperegistrar/qmltypescreator.h
index 9207a64b7e..808c189323 100644
--- a/src/qmltyperegistrar/qmltypescreator.h
+++ b/src/qmltyperegistrar/qmltypescreator.h
@@ -45,7 +45,7 @@ public:
void setOwnTypes(QVector<QJsonObject> ownTypes) { m_ownTypes = std::move(ownTypes); }
void setForeignTypes(QVector<QJsonObject> foreignTypes) { m_foreignTypes = std::move(foreignTypes); }
void setModule(QString module) { m_module = std::move(module); }
- void setMajorVersion(int majorVersion) { m_majorVersion = majorVersion; }
+ void setVersion(QTypeRevision version) { m_version = version; }
private:
void writeClassProperties(const QmlTypesClassDescription &collector);
@@ -62,7 +62,7 @@ private:
QVector<QJsonObject> m_ownTypes;
QVector<QJsonObject> m_foreignTypes;
QString m_module;
- int m_majorVersion = 0;
+ QTypeRevision m_version = QTypeRevision::zero();
};
#endif // QMLTYPESCREATOR_H
diff --git a/src/imports/workerscript/dependencies.json b/src/qmlworkerscript/dependencies.json
index 0d4f101c7a..0d4f101c7a 100644
--- a/src/imports/workerscript/dependencies.json
+++ b/src/qmlworkerscript/dependencies.json
diff --git a/src/qmlworkerscript/qmlworkerscript.pro b/src/qmlworkerscript/qmlworkerscript.pro
index a8ec68d423..82b61ab12e 100644
--- a/src/qmlworkerscript/qmlworkerscript.pro
+++ b/src/qmlworkerscript/qmlworkerscript.pro
@@ -20,7 +20,7 @@ include(../3rdparty/masm/masm-defs.pri)
QMLTYPES_FILENAME = plugins.qmltypes
QMLTYPES_INSTALL_DIR = $$[QT_INSTALL_QML]/QtQml/WorkerScript
QML_IMPORT_NAME = QtQml.WorkerScript
-IMPORT_VERSION = 2.15
+QML_IMPORT_VERSION = $$QT_VERSION
CONFIG += qmltypes install_qmltypes install_metatypes
load(qt_module)
diff --git a/src/qmlworkerscript/qquickworkerscript.cpp b/src/qmlworkerscript/qquickworkerscript.cpp
index 4a79027234..0bdbbabadc 100644
--- a/src/qmlworkerscript/qquickworkerscript.cpp
+++ b/src/qmlworkerscript/qquickworkerscript.cpp
@@ -130,7 +130,9 @@ struct WorkerScript : public QV4::ExecutionEngine {
QQuickWorkerScriptEnginePrivate *p = nullptr;
QUrl source;
QQuickWorkerScript *owner = nullptr;
+#if QT_CONFIG(qml_network)
QScopedPointer<QNetworkAccessManager> scriptLocalNAM;
+#endif
int id = -1;
};
@@ -390,6 +392,7 @@ WorkerScript::WorkerScript(int id, QQuickWorkerScriptEnginePrivate *parent)
QV4::ScopedValue sendMessage(scope, QV4::FunctionObject::createBuiltinFunction(this, name, QQuickWorkerScriptEnginePrivate::method_sendMessage, 1));
api->put(QV4::ScopedString(scope, scope.engine->newString(QStringLiteral("sendMessage"))), sendMessage);
globalObject->put(QV4::ScopedString(scope, scope.engine->newString(QStringLiteral("WorkerScript"))), api);
+#if QT_CONFIG(qml_network)
networkAccessManager = [](QV4::ExecutionEngine *engine){
auto *workerScript = static_cast<WorkerScript *>(engine);
if (workerScript->scriptLocalNAM)
@@ -400,6 +403,7 @@ WorkerScript::WorkerScript(int id, QQuickWorkerScriptEnginePrivate *parent)
workerScript->scriptLocalNAM.reset(new QNetworkAccessManager(workerScript->p));
return workerScript->scriptLocalNAM.get();
};
+#endif // qml_network
}
int QQuickWorkerScriptEngine::registerWorkerScript(QQuickWorkerScript *owner)
diff --git a/src/qmlworkerscript/qquickworkerscript_p.h b/src/qmlworkerscript/qquickworkerscript_p.h
index 03581089e0..d1ea34422a 100644
--- a/src/qmlworkerscript/qquickworkerscript_p.h
+++ b/src/qmlworkerscript/qquickworkerscript_p.h
@@ -84,13 +84,14 @@ private:
};
class QQmlV4Function;
-class Q_QMLWORKERSCRIPT_PRIVATE_EXPORT QQuickWorkerScript : public QObject, public QQmlParserStatus
+class Q_AUTOTEST_EXPORT QQuickWorkerScript : public QObject, public QQmlParserStatus
{
Q_OBJECT
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(bool ready READ ready NOTIFY readyChanged)
+ Q_PROPERTY(bool ready READ ready NOTIFY readyChanged REVISION(2, 15))
QML_NAMED_ELEMENT(WorkerScript);
+ QML_ADDED_IN_VERSION(2, 0)
Q_INTERFACES(QQmlParserStatus)
public:
@@ -107,7 +108,7 @@ public Q_SLOTS:
Q_SIGNALS:
void sourceChanged();
- void readyChanged();
+ Q_REVISION(2, 15) void readyChanged();
void message(const QJSValue &messageObject);
protected:
diff --git a/src/qmlworkerscript/qtqmlworkerscriptglobal_p.h b/src/qmlworkerscript/qtqmlworkerscriptglobal_p.h
index 34236cd79e..c75d5f3129 100644
--- a/src/qmlworkerscript/qtqmlworkerscriptglobal_p.h
+++ b/src/qmlworkerscript/qtqmlworkerscriptglobal_p.h
@@ -57,4 +57,6 @@
#define Q_QMLWORKERSCRIPT_PRIVATE_EXPORT Q_QMLWORKERSCRIPT_EXPORT
#define Q_QMLWORKERSCRIPT_AUTOTEST_EXPORT Q_AUTOTEST_EXPORT
+void Q_QMLWORKERSCRIPT_PRIVATE_EXPORT qml_register_types_QtQml_WorkerScript();
+
#endif // QTQMLWORKERSCRIPTGLOBAL_P_H
diff --git a/src/quick/accessible/qaccessiblequickview.cpp b/src/quick/accessible/qaccessiblequickview.cpp
index 41a02fc09c..b23b0316f5 100644
--- a/src/quick/accessible/qaccessiblequickview.cpp
+++ b/src/quick/accessible/qaccessiblequickview.cpp
@@ -84,8 +84,12 @@ QAccessibleInterface *QAccessibleQuickWindow::child(int index) const
QAccessibleInterface *QAccessibleQuickWindow::focusChild() const
{
QObject *focusObject = window()->focusObject();
- if (focusObject)
- return QAccessible::queryAccessibleInterface(focusObject);
+ if (focusObject) {
+ QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(focusObject);
+ if (!iface || iface == this || !iface->focusChild())
+ return iface;
+ return iface->focusChild();
+ }
return nullptr;
}
diff --git a/src/quick/designer/qquickdesignersupportitems.cpp b/src/quick/designer/qquickdesignersupportitems.cpp
index ed5fdf3a4a..4fd9158f4a 100644
--- a/src/quick/designer/qquickdesignersupportitems.cpp
+++ b/src/quick/designer/qquickdesignersupportitems.cpp
@@ -210,14 +210,14 @@ static bool isCrashingType(const QQmlType &type)
return false;
}
-QObject *QQuickDesignerSupportItems::createPrimitive(const QString &typeName, int majorNumber, int minorNumber, QQmlContext *context)
+QObject *QQuickDesignerSupportItems::createPrimitive(const QString &typeName, QTypeRevision version, QQmlContext *context)
{
ComponentCompleteDisabler disableComponentComplete;
Q_UNUSED(disableComponentComplete)
QObject *object = nullptr;
- QQmlType type = QQmlMetaType::qmlType(typeName, majorNumber, minorNumber);
+ QQmlType type = QQmlMetaType::qmlType(typeName, version);
if (isCrashingType(type)) {
object = new QObject;
@@ -242,7 +242,8 @@ QObject *QQuickDesignerSupportItems::createPrimitive(const QString &typeName, in
if (!object) {
qWarning() << "QuickDesigner: Cannot create an object of type"
- << QString::fromLatin1("%1 %2,%3").arg(typeName).arg(majorNumber).arg(minorNumber)
+ << QString::fromLatin1("%1 %2,%3").arg(typeName)
+ .arg(version.majorVersion()).arg(version.minorVersion())
<< "- type isn't known to declarative meta type system";
}
diff --git a/src/quick/designer/qquickdesignersupportitems_p.h b/src/quick/designer/qquickdesignersupportitems_p.h
index 8c5a44d9fe..93b4c529fa 100644
--- a/src/quick/designer/qquickdesignersupportitems_p.h
+++ b/src/quick/designer/qquickdesignersupportitems_p.h
@@ -58,6 +58,7 @@
#include <QVariant>
#include <QList>
#include <QByteArray>
+#include <QTypeRevision>
#include <QQmlContext>
#include <QQmlListReference>
@@ -66,7 +67,7 @@ QT_BEGIN_NAMESPACE
class Q_QUICK_EXPORT QQuickDesignerSupportItems
{
public:
- static QObject *createPrimitive(const QString &typeName, int majorNumber, int minorNumber, QQmlContext *context);
+ static QObject *createPrimitive(const QString &typeName, QTypeRevision version, QQmlContext *context);
static QObject *createComponent(const QUrl &componentUrl, QQmlContext *context);
static void tweakObjects(QObject *object);
static bool objectWasDeleted(QObject *object);
diff --git a/src/quick/designer/qquickdesignersupportproperties.cpp b/src/quick/designer/qquickdesignersupportproperties.cpp
index c746f55daa..335795acf1 100644
--- a/src/quick/designer/qquickdesignersupportproperties.cpp
+++ b/src/quick/designer/qquickdesignersupportproperties.cpp
@@ -155,8 +155,8 @@ QQuickDesignerSupport::PropertyNameList QQuickDesignerSupportProperties::propert
baseName + QQuickDesignerSupport::PropertyName(metaProperty.name())
+ '.', inspectedObjects));
}
- } else if (QQmlValueTypeFactory::valueType(metaProperty.userType())) {
- QQmlValueType *valueType = QQmlValueTypeFactory::valueType(metaProperty.userType());
+ } else if (QQmlGadgetPtrWrapper *valueType
+ = QQmlGadgetPtrWrapper::instance(qmlEngine(object), metaProperty.userType())) {
valueType->setValue(metaProperty.read(object));
propertyNameList.append(propertyNameListForWritableProperties(valueType,
baseName + QQuickDesignerSupport::PropertyName(metaProperty.name())
@@ -223,8 +223,8 @@ QQuickDesignerSupport::PropertyNameList QQuickDesignerSupportProperties::allProp
+ QQuickDesignerSupport::PropertyName(metaProperty.name())
+ '.', inspectedObjects));
}
- } else if (QQmlValueTypeFactory::valueType(metaProperty.userType())) {
- QQmlValueType *valueType = QQmlValueTypeFactory::valueType(metaProperty.userType());
+ } else if (QQmlGadgetPtrWrapper *valueType
+ = QQmlGadgetPtrWrapper::instance(qmlEngine(object), metaProperty.userType())) {
valueType->setValue(metaProperty.read(object));
propertyNameList.append(baseName + QQuickDesignerSupport::PropertyName(metaProperty.name()));
propertyNameList.append(allPropertyNames(valueType,
diff --git a/src/quick/doc/snippets/qml/qml-data-models/listmodel-listview-required.qml b/src/quick/doc/snippets/qml/qml-data-models/listmodel-listview-required.qml
new file mode 100644
index 0000000000..e9a668ed8f
--- /dev/null
+++ b/src/quick/doc/snippets/qml/qml-data-models/listmodel-listview-required.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [document]
+import QtQuick 2.0
+
+Item {
+ width: 200
+ height: 250
+
+ ListModel {
+ id: myModel
+ ListElement { type: "Dog"; age: 8; noise: "meow" }
+ ListElement { type: "Cat"; age: 5; noise: "woof" }
+ }
+
+ component MyDelegate : Text {
+ required property string type
+ required property int age
+ text: type + ", " + age
+ // WRONG: Component.onCompleted: () => console.log(noise)
+ // The above line would cause a ReferenceError
+ // as there is no required property noise,
+ // and the presence of the required properties prevents
+ // noise from being injected into the scope
+ }
+
+ ListView {
+ anchors.fill: parent
+ model: myModel
+ delegate: MyDelegate {}
+ }
+}
+//! [document]
diff --git a/src/quick/doc/snippets/qml/tableview/cpp-tablemodel.cpp b/src/quick/doc/snippets/qml/tableview/cpp-tablemodel.cpp
index ea9f76f131..a8a37f80af 100644
--- a/src/quick/doc/snippets/qml/tableview/cpp-tablemodel.cpp
+++ b/src/quick/doc/snippets/qml/tableview/cpp-tablemodel.cpp
@@ -48,56 +48,19 @@
**
****************************************************************************/
-//![0]
+#include "cpp-tablemodel.h"
#include <QGuiApplication>
-#include <QQmlApplicationEngine>
-#include <QAbstractTableModel>
-
-class TableModel : public QAbstractTableModel
-{
- Q_OBJECT
-
-public:
-
- int rowCount(const QModelIndex & = QModelIndex()) const override
- {
- return 200;
- }
-
- int columnCount(const QModelIndex & = QModelIndex()) const override
- {
- return 200;
- }
-
- QVariant data(const QModelIndex &index, int role) const override
- {
- switch (role) {
- case Qt::DisplayRole:
- return QString("%1, %2").arg(index.column()).arg(index.row());
- default:
- break;
- }
-
- return QVariant();
- }
-
- QHash<int, QByteArray> roleNames() const override
- {
- return { {Qt::DisplayRole, "display"} };
- }
-};
+#include <QQuickView>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
- qmlRegisterType<TableModel>("TableModel", 0, 1, "TableModel");
-
- QQmlApplicationEngine engine;
- engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+ QQuickView view;
+ view.setSource(QStringLiteral("qrc:/cpp-tablemodel.qml"));
+ view.show();
return app.exec();
}
-#include "main.moc"
//![0]
diff --git a/src/quick/doc/snippets/qml/tableview/cpp-tablemodel.h b/src/quick/doc/snippets/qml/tableview/cpp-tablemodel.h
new file mode 100644
index 0000000000..4a3c46b573
--- /dev/null
+++ b/src/quick/doc/snippets/qml/tableview/cpp-tablemodel.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2020 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the documentation of the Qt Toolkit.
+ **
+ ** $QT_BEGIN_LICENSE:BSD$
+ ** Commercial License Usage
+ ** Licensees holding valid commercial Qt licenses may use this file in
+ ** accordance with the commercial license agreement provided with the
+ ** Software or, alternatively, in accordance with the terms contained in
+ ** a written agreement between you and The Qt Company. For licensing terms
+ ** and conditions see https://www.qt.io/terms-conditions. For further
+ ** information use the contact form at https://www.qt.io/contact-us.
+ **
+ ** BSD License Usage
+ ** Alternatively, you may use this file under the terms of the BSD license
+ ** as follows:
+ **
+ ** "Redistribution and use in source and binary forms, with or without
+ ** modification, are permitted provided that the following conditions are
+ ** met:
+ ** * Redistributions of source code must retain the above copyright
+ ** notice, this list of conditions and the following disclaimer.
+ ** * Redistributions in binary form must reproduce the above copyright
+ ** notice, this list of conditions and the following disclaimer in
+ ** the documentation and/or other materials provided with the
+ ** distribution.
+ ** * Neither the name of The Qt Company Ltd nor the names of its
+ ** contributors may be used to endorse or promote products derived
+ ** from this software without specific prior written permission.
+ **
+ **
+ ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+ **
+ ** $QT_END_LICENSE$
+ **
+ ****************************************************************************/
+
+#ifndef CPPTABLEMODEL_H
+#define CPPTABLEMODEL_H
+
+//![0]
+#include <qqml.h>
+#include <QAbstractTableModel>
+
+class TableModel : public QAbstractTableModel
+{
+ Q_OBJECT
+ QML_ELEMENT
+ QML_ADDED_IN_MINOR_VERSION(1)
+
+public:
+ int rowCount(const QModelIndex & = QModelIndex()) const override
+ {
+ return 200;
+ }
+
+ int columnCount(const QModelIndex & = QModelIndex()) const override
+ {
+ return 200;
+ }
+
+ QVariant data(const QModelIndex &index, int role) const override
+ {
+ switch (role) {
+ case Qt::DisplayRole:
+ return QString("%1, %2").arg(index.column()).arg(index.row());
+ default:
+ break;
+ }
+
+ return QVariant();
+ }
+
+ QHash<int, QByteArray> roleNames() const override
+ {
+ return { {Qt::DisplayRole, "display"} };
+ }
+};
+//![0]
+
+#endif // CPPTABLEMODEL_H
diff --git a/src/quick/doc/snippets/qml/tableview/tableview.pro b/src/quick/doc/snippets/qml/tableview/tableview.pro
new file mode 100644
index 0000000000..0821f1b5d3
--- /dev/null
+++ b/src/quick/doc/snippets/qml/tableview/tableview.pro
@@ -0,0 +1,20 @@
+TEMPLATE = app
+
+QT += qml quick
+
+CONFIG += qmltypes
+QML_IMPORT_NAME = TableModel
+QML_IMPORT_MAJOR_VERSION = 0
+
+SOURCES += \
+ cpp-tablemodel.cpp
+
+HEADERS += \
+ cpp-tablemodel.h
+
+RESOURCES += \
+ cpp-tablemodel.qml \
+ qml-tablemodel.qml \
+ reusabledelegate.qml \
+ tableviewwithheader.qml \
+ tableviewwithprovider.qml
diff --git a/src/quick/doc/snippets/qml/xmlrole.xml b/src/quick/doc/snippets/qml/xmlrole.xml
deleted file mode 100644
index 70280e067d..0000000000
--- a/src/quick/doc/snippets/qml/xmlrole.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="iso-8859-1" ?>
-<catalog>
- <book type="Online" wanted="true">
- <title>Qt 5 Cadaques</title>
- <year>2014</year>
- <author>Juergen Bocklage-Ryannel</author>
- <author>Johan Thelin</author>
- </book>
- <book type="Hardcover">
- <title>C++ GUI Programming with Qt 4</title>
- <year>2006</year>
- <author>Jasmin Blanchette</author>
- <author>Mark Summerfield</author>
- </book>
- <book type="Paperback">
- <title>Programming with Qt</title>
- <year>2002</year>
- <author>Matthias Kalle Dalheimer</author>
- </book>
- </catalog>
diff --git a/src/quick/doc/src/concepts/modelviewsdata/modelview.qdoc b/src/quick/doc/src/concepts/modelviewsdata/modelview.qdoc
index 04dbf1cf20..555f730c9e 100644
--- a/src/quick/doc/src/concepts/modelviewsdata/modelview.qdoc
+++ b/src/quick/doc/src/concepts/modelviewsdata/modelview.qdoc
@@ -164,6 +164,16 @@ To visualize data, bind the view's \c model property to a model and the
\snippet qml/qml-data-models/listmodel-listview.qml document
+ To get finer control over which roles are accessible, and to make delegates
+ more self-contained and usable outside of views,
+ \li{Required Properties}{required properties} can be used. If a delegate
+ contains required properties, the named roles are not provided. Instead,
+ the QML engine will check if the name of a required property matches that of
+ a model role. If so, that property will be bound to the corresponding value
+ from the model.
+
+ \snippet qml/qml-data-models/listmodel-listview-required.qml document
+
If there is a naming clash between the model's properties and the delegate's
properties, the roles can be accessed with the qualified \e model name
instead. For example, if a \l Text type had \e type or \e age properties,
@@ -186,6 +196,10 @@ To visualize data, bind the view's \c model property to a model and the
modelData role is also provided for models that have only one role. In this
case the \e modelData role contains the same data as the named role.
+ \note \e model, \e index, and \e modelData roles are not accessible
+ if the delegate contains required properties, unless it has also required
+ properties with matching names.
+
QML provides several types of data models among the built-in set of QML
types. In addition, models can be created with Qt C++ and then made
available to \l{QQmlEngine} for use by
@@ -417,6 +431,12 @@ ListView {
\note The \c edit role is equal to \l Qt::EditRole. See \l{QAbstractItemModel::}{roleNames}()
for the built-in role names. However, real life models would usually register custom roles.
+\node If a model role is bound to a \li{Required Property}{required property}, assigning to
+that property will not modify the model. It will instead break the binding to the model (just
+like assigning to any other property breaks existing bindings). If you want to use
+required properties and change the model data, make model also a required property and assign to
+\e model.propertyName.
+
For more information, visit the \l{qtquick-modelviewsdata-cppmodels.html#changing-model-data}{Using C++ Models with Qt Quick Views}
article.
diff --git a/src/quick/doc/src/qmltypereference.qdoc b/src/quick/doc/src/qmltypereference.qdoc
index 418475f100..528444cad3 100644
--- a/src/quick/doc/src/qmltypereference.qdoc
+++ b/src/quick/doc/src/qmltypereference.qdoc
@@ -179,6 +179,7 @@ available when you import \c QtQuick.
\li \l bool \c font.kerning
\li \l bool \c font.preferShaping
\li \l enumeration \c font.hintingPreference
+ \li \l string \c font.styleName
\endlist
Example:
diff --git a/src/quick/handlers/qquickdragaxis_p.h b/src/quick/handlers/qquickdragaxis_p.h
index ef74902122..b3db1be620 100644
--- a/src/quick/handlers/qquickdragaxis_p.h
+++ b/src/quick/handlers/qquickdragaxis_p.h
@@ -63,7 +63,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickDragAxis : public QObject
Q_PROPERTY(qreal maximum READ maximum WRITE setMaximum NOTIFY maximumChanged)
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
QML_NAMED_ELEMENT(DragAxis)
- QML_ADDED_IN_MINOR_VERSION(12)
+ QML_ADDED_IN_VERSION(2, 12)
QML_UNCREATABLE("DragAxis is only available as a grouped property of DragHandler.")
public:
diff --git a/src/quick/handlers/qquickdraghandler_p.h b/src/quick/handlers/qquickdraghandler_p.h
index 22d51c78ec..1315f79114 100644
--- a/src/quick/handlers/qquickdraghandler_p.h
+++ b/src/quick/handlers/qquickdraghandler_p.h
@@ -62,9 +62,9 @@ class Q_QUICK_PRIVATE_EXPORT QQuickDragHandler : public QQuickMultiPointHandler
Q_PROPERTY(QQuickDragAxis * xAxis READ xAxis CONSTANT)
Q_PROPERTY(QQuickDragAxis * yAxis READ yAxis CONSTANT)
Q_PROPERTY(QVector2D translation READ translation NOTIFY translationChanged)
- Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged REVISION 14)
+ Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged REVISION(2, 14))
QML_NAMED_ELEMENT(DragHandler)
- QML_ADDED_IN_MINOR_VERSION(12)
+ QML_ADDED_IN_VERSION(2, 12)
public:
enum SnapMode {
@@ -91,7 +91,7 @@ public:
Q_SIGNALS:
void translationChanged();
- Q_REVISION(14) void snapModeChanged();
+ Q_REVISION(2, 14) void snapModeChanged();
protected:
void onActiveChanged() override;
diff --git a/src/quick/handlers/qquickhandlerpoint.cpp b/src/quick/handlers/qquickhandlerpoint.cpp
index f3d92cf200..72efdfd0f4 100644
--- a/src/quick/handlers/qquickhandlerpoint.cpp
+++ b/src/quick/handlers/qquickhandlerpoint.cpp
@@ -119,8 +119,13 @@ void QQuickHandlerPoint::reset(const QQuickEventPoint *point)
m_rotation = tp->rotation();
m_pressure = tp->pressure();
m_ellipseDiameters = tp->ellipseDiameters();
+#if QT_CONFIG(tabletevent)
} else if (event->asPointerTabletEvent()) {
- // TODO
+ m_uniqueId = event->device()->uniqueId();
+ m_rotation = static_cast<const QQuickEventTabletPoint *>(point)->rotation();
+ m_pressure = static_cast<const QQuickEventTabletPoint *>(point)->pressure();
+ m_ellipseDiameters = QSizeF();
+#endif
} else {
m_uniqueId = event->device()->uniqueId();
m_rotation = 0;
diff --git a/src/quick/handlers/qquickhoverhandler.cpp b/src/quick/handlers/qquickhoverhandler.cpp
index 79cb288af8..b12d85784a 100644
--- a/src/quick/handlers/qquickhoverhandler.cpp
+++ b/src/quick/handlers/qquickhoverhandler.cpp
@@ -64,6 +64,9 @@ Q_LOGGING_CATEGORY(lcHoverHandler, "qt.quick.handler.hover")
properties can be used to narrow the behavior to detect hovering of
specific kinds of devices or while holding a modifier key.
+ The \l cursorShape property allows changing the cursor whenever
+ \l hovered changes to \c true.
+
\sa MouseArea, PointHandler
*/
@@ -90,11 +93,22 @@ bool QQuickHoverHandler::wantsPointerEvent(QQuickPointerEvent *event)
{
QQuickEventPoint *point = event->point(0);
if (QQuickPointerDeviceHandler::wantsPointerEvent(event) && wantsEventPoint(point) && parentContains(point)) {
- // assume this is a mouse event, so there's only one point
+ // assume this is a mouse or tablet event, so there's only one point
setPointId(point->pointId());
return true;
}
- setHovered(false);
+
+ // Some hover events come from QQuickWindow::tabletEvent(). In between,
+ // some hover events come from QQWindowPrivate::flushFrameSynchronousEvents(),
+ // but those look like mouse events. If a particular HoverHandler instance
+ // is filtering for tablet events only (e.g. by setting
+ // acceptedDevices:PointerDevice.Stylus), those events should not cause
+ // the hovered property to transition to false prematurely.
+ // If a QQuickPointerTabletEvent caused the hovered property to become true,
+ // then only another QQuickPointerTabletEvent can make it become false.
+ if (!(m_hoveredTablet && event->asPointerMouseEvent()))
+ setHovered(false);
+
return false;
}
@@ -104,6 +118,8 @@ void QQuickHoverHandler::handleEventPoint(QQuickEventPoint *point)
if (point->state() == QQuickEventPoint::Released &&
point->pointerEvent()->device()->pointerType() == QQuickPointerDevice::Finger)
hovered = false;
+ else if (point->pointerEvent()->asPointerTabletEvent())
+ m_hoveredTablet = true;
setHovered(hovered);
setPassiveGrab(point);
}
@@ -121,8 +137,58 @@ void QQuickHoverHandler::setHovered(bool hovered)
if (m_hovered != hovered) {
qCDebug(lcHoverHandler) << objectName() << "hovered" << m_hovered << "->" << hovered;
m_hovered = hovered;
+ if (!hovered)
+ m_hoveredTablet = false;
emit hoveredChanged();
}
}
+/*!
+ \since 5.15
+ \qmlproperty Qt::CursorShape QtQuick::HoverHandler::cursorShape
+ This property holds the cursor shape that will appear whenever
+ \l hovered is \c true and no other handler is overriding it.
+
+ The available cursor shapes are:
+ \list
+ \li Qt.ArrowCursor
+ \li Qt.UpArrowCursor
+ \li Qt.CrossCursor
+ \li Qt.WaitCursor
+ \li Qt.IBeamCursor
+ \li Qt.SizeVerCursor
+ \li Qt.SizeHorCursor
+ \li Qt.SizeBDiagCursor
+ \li Qt.SizeFDiagCursor
+ \li Qt.SizeAllCursor
+ \li Qt.BlankCursor
+ \li Qt.SplitVCursor
+ \li Qt.SplitHCursor
+ \li Qt.PointingHandCursor
+ \li Qt.ForbiddenCursor
+ \li Qt.WhatsThisCursor
+ \li Qt.BusyCursor
+ \li Qt.OpenHandCursor
+ \li Qt.ClosedHandCursor
+ \li Qt.DragCopyCursor
+ \li Qt.DragMoveCursor
+ \li Qt.DragLinkCursor
+ \endlist
+
+ The default value of this property is not set, which allows any active
+ handler on the same \l parentItem to determine the cursor shape.
+ This property can be reset to the initial condition by setting it to
+ \c undefined.
+
+ If any handler with defined \c cursorShape is
+ \l {PointerHandler::active}{active}, that cursor will appear.
+ Else if the HoverHandler has a defined \c cursorShape, that cursor will appear.
+ Otherwise, the \l {QQuickItem::cursor()}{cursor} of \l parentItem will appear.
+
+ \note When this property has not been set, or has been set to \c undefined,
+ if you read the value it will return \c Qt.ArrowCursor.
+
+ \sa Qt::CursorShape, QQuickItem::cursor()
+*/
+
QT_END_NAMESPACE
diff --git a/src/quick/handlers/qquickhoverhandler_p.h b/src/quick/handlers/qquickhoverhandler_p.h
index e4786bfa53..4b9d0a9f39 100644
--- a/src/quick/handlers/qquickhoverhandler_p.h
+++ b/src/quick/handlers/qquickhoverhandler_p.h
@@ -63,7 +63,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickHoverHandler : public QQuickSinglePointHandle
Q_OBJECT
Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged)
QML_NAMED_ELEMENT(HoverHandler)
- QML_ADDED_IN_MINOR_VERSION(12)
+ QML_ADDED_IN_VERSION(2, 12)
public:
explicit QQuickHoverHandler(QQuickItem *parent = nullptr);
@@ -84,6 +84,7 @@ private:
private:
bool m_hovered = false;
+ bool m_hoveredTablet = false;
};
QT_END_NAMESPACE
diff --git a/src/quick/handlers/qquickpinchhandler.cpp b/src/quick/handlers/qquickpinchhandler.cpp
index 5b30d08557..8413b8b721 100644
--- a/src/quick/handlers/qquickpinchhandler.cpp
+++ b/src/quick/handlers/qquickpinchhandler.cpp
@@ -153,49 +153,6 @@ void QQuickPinchHandler::setMaximumRotation(qreal maximumRotation)
emit maximumRotationChanged();
}
-#if QT_DEPRECATED_SINCE(5, 12)
-void QQuickPinchHandler::warnAboutMinMaxDeprecated() const
-{
- qmlWarning(this) << "min and max constraints are now part of the xAxis and yAxis properties";
-}
-
-void QQuickPinchHandler::setMinimumX(qreal minX)
-{
- warnAboutMinMaxDeprecated();
- if (qFuzzyCompare(m_minimumX, minX))
- return;
- m_minimumX = minX;
- emit minimumXChanged();
-}
-
-void QQuickPinchHandler::setMaximumX(qreal maxX)
-{
- warnAboutMinMaxDeprecated();
- if (qFuzzyCompare(m_maximumX, maxX))
- return;
- m_maximumX = maxX;
- emit maximumXChanged();
-}
-
-void QQuickPinchHandler::setMinimumY(qreal minY)
-{
- warnAboutMinMaxDeprecated();
- if (qFuzzyCompare(m_minimumY, minY))
- return;
- m_minimumY = minY;
- emit minimumYChanged();
-}
-
-void QQuickPinchHandler::setMaximumY(qreal maxY)
-{
- warnAboutMinMaxDeprecated();
- if (qFuzzyCompare(m_maximumY, maxY))
- return;
- m_maximumY = maxY;
- emit maximumYChanged();
-}
-#endif
-
bool QQuickPinchHandler::wantsPointerEvent(QQuickPointerEvent *event)
{
if (!QQuickMultiPointHandler::wantsPointerEvent(event))
diff --git a/src/quick/handlers/qquickpinchhandler_p.h b/src/quick/handlers/qquickpinchhandler_p.h
index 708c836acf..b4e9fa0336 100644
--- a/src/quick/handlers/qquickpinchhandler_p.h
+++ b/src/quick/handlers/qquickpinchhandler_p.h
@@ -70,16 +70,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPinchHandler : public QQuickMultiPointHandler
Q_PROPERTY(qreal activeScale READ activeScale NOTIFY updated)
Q_PROPERTY(qreal rotation READ rotation NOTIFY updated)
Q_PROPERTY(QVector2D translation READ translation NOTIFY updated)
-#if QT_DEPRECATED_SINCE(5, 12)
- Q_PROPERTY(qreal minimumX READ minimumX WRITE setMinimumX NOTIFY minimumXChanged) // ### Qt 6: remove
- Q_PROPERTY(qreal maximumX READ maximumX WRITE setMaximumX NOTIFY maximumXChanged) // ### Qt 6: remove
- Q_PROPERTY(qreal minimumY READ minimumY WRITE setMinimumY NOTIFY minimumYChanged) // ### Qt 6: remove
- Q_PROPERTY(qreal maximumY READ maximumY WRITE setMaximumY NOTIFY maximumYChanged) // ### Qt 6: remove
-#endif
Q_PROPERTY(QQuickDragAxis * xAxis READ xAxis CONSTANT)
Q_PROPERTY(QQuickDragAxis * yAxis READ yAxis CONSTANT)
QML_NAMED_ELEMENT(PinchHandler)
- QML_ADDED_IN_MINOR_VERSION(12)
+ QML_ADDED_IN_VERSION(2, 12)
public:
explicit QQuickPinchHandler(QQuickItem *parent = nullptr);
@@ -101,18 +95,6 @@ public:
qreal activeScale() const { return m_activeScale; }
qreal rotation() const { return m_activeRotation; }
-#if QT_DEPRECATED_SINCE(5, 12)
- void warnAboutMinMaxDeprecated() const;
- qreal minimumX() const { warnAboutMinMaxDeprecated(); return m_minimumX; }
- void setMinimumX(qreal minX);
- qreal maximumX() const { warnAboutMinMaxDeprecated(); return m_maximumX; }
- void setMaximumX(qreal maxX);
- qreal minimumY() const { warnAboutMinMaxDeprecated(); return m_minimumY; }
- void setMinimumY(qreal minY);
- qreal maximumY() const { warnAboutMinMaxDeprecated(); return m_maximumY; }
- void setMaximumY(qreal maxY);
-#endif
-
QQuickDragAxis *xAxis() { return &m_xAxis; }
QQuickDragAxis *yAxis() { return &m_yAxis; }
@@ -121,10 +103,6 @@ signals:
void maximumScaleChanged();
void minimumRotationChanged();
void maximumRotationChanged();
- void minimumXChanged();
- void maximumXChanged();
- void minimumYChanged();
- void maximumYChanged();
void updated();
protected:
@@ -145,10 +123,6 @@ private:
qreal m_minimumRotation = -qInf();
qreal m_maximumRotation = qInf();
- qreal m_minimumX = -qInf();
- qreal m_maximumX = qInf();
- qreal m_minimumY = -qInf();
- qreal m_maximumY = qInf();
QQuickDragAxis m_xAxis;
QQuickDragAxis m_yAxis;
diff --git a/src/quick/handlers/qquickpointerhandler.cpp b/src/quick/handlers/qquickpointerhandler.cpp
index c498c96454..adb753e000 100644
--- a/src/quick/handlers/qquickpointerhandler.cpp
+++ b/src/quick/handlers/qquickpointerhandler.cpp
@@ -51,7 +51,6 @@ Q_LOGGING_CATEGORY(lcPointerHandlerActive, "qt.quick.handler.active")
\qmltype PointerHandler
\qmlabstract
\since 5.10
- \preliminary
\instantiates QQuickPointerHandler
\inqmlmodule QtQuick
\brief Abstract handler for pointer events.
@@ -154,6 +153,87 @@ void QQuickPointerHandler::resetDragThreshold()
}
/*!
+ \since 5.15
+ \qmlproperty Qt::CursorShape PointerHandler::cursorShape
+ This property holds the cursor shape that will appear whenever the mouse is
+ hovering over the \l parentItem while \l active is \c true.
+
+ The available cursor shapes are:
+ \list
+ \li Qt.ArrowCursor
+ \li Qt.UpArrowCursor
+ \li Qt.CrossCursor
+ \li Qt.WaitCursor
+ \li Qt.IBeamCursor
+ \li Qt.SizeVerCursor
+ \li Qt.SizeHorCursor
+ \li Qt.SizeBDiagCursor
+ \li Qt.SizeFDiagCursor
+ \li Qt.SizeAllCursor
+ \li Qt.BlankCursor
+ \li Qt.SplitVCursor
+ \li Qt.SplitHCursor
+ \li Qt.PointingHandCursor
+ \li Qt.ForbiddenCursor
+ \li Qt.WhatsThisCursor
+ \li Qt.BusyCursor
+ \li Qt.OpenHandCursor
+ \li Qt.ClosedHandCursor
+ \li Qt.DragCopyCursor
+ \li Qt.DragMoveCursor
+ \li Qt.DragLinkCursor
+ \endlist
+
+ The default value is not set, which allows the \l {QQuickItem::cursor()}{cursor}
+ of \l parentItem to appear. This property can be reset to the same initial
+ condition by setting it to undefined.
+
+ \note When this property has not been set, or has been set to \c undefined,
+ if you read the value it will return \c Qt.ArrowCursor.
+
+ \sa Qt::CursorShape, QQuickItem::cursor(), HoverHandler::cursorShape
+*/
+#if QT_CONFIG(cursor)
+Qt::CursorShape QQuickPointerHandler::cursorShape() const
+{
+ Q_D(const QQuickPointerHandler);
+ return d->cursorShape;
+}
+
+void QQuickPointerHandler::setCursorShape(Qt::CursorShape shape)
+{
+ Q_D(QQuickPointerHandler);
+ if (d->cursorSet && shape == d->cursorShape)
+ return;
+ d->cursorShape = shape;
+ d->cursorSet = true;
+ QQuickItemPrivate *itemPriv = QQuickItemPrivate::get(parentItem());
+ itemPriv->hasCursorHandler = true;
+ itemPriv->setHasCursorInChild(true);
+ emit cursorShapeChanged();
+}
+
+void QQuickPointerHandler::resetCursorShape()
+{
+ Q_D(QQuickPointerHandler);
+ if (!d->cursorSet)
+ return;
+ d->cursorShape = Qt::ArrowCursor;
+ d->cursorSet = false;
+ QQuickItemPrivate *itemPriv = QQuickItemPrivate::get(parentItem());
+ itemPriv->hasCursorHandler = false;
+ itemPriv->setHasCursorInChild(itemPriv->hasCursor);
+ emit cursorShapeChanged();
+}
+
+bool QQuickPointerHandler::isCursorShapeExplicitlySet() const
+{
+ Q_D(const QQuickPointerHandler);
+ return d->cursorSet;
+}
+#endif
+
+/*!
Notification that the grab has changed in some way which is relevant to this handler.
The \a grabber (subject) will be the Input Handler whose state is changing,
or null if the state change regards an Item.
@@ -597,11 +677,13 @@ QQuickPointerHandlerPrivate::QQuickPointerHandlerPrivate()
: grabPermissions(QQuickPointerHandler::CanTakeOverFromItems |
QQuickPointerHandler::CanTakeOverFromHandlersOfDifferentType |
QQuickPointerHandler::ApprovesTakeOverByAnything)
+ , cursorShape(Qt::ArrowCursor)
, enabled(true)
, active(false)
, targetExplicitlySet(false)
, hadKeepMouseGrab(false)
, hadKeepTouchGrab(false)
+ , cursorSet(false)
{
}
diff --git a/src/quick/handlers/qquickpointerhandler_p.h b/src/quick/handlers/qquickpointerhandler_p.h
index 34ae9ce2c2..3e7876b3d9 100644
--- a/src/quick/handlers/qquickpointerhandler_p.h
+++ b/src/quick/handlers/qquickpointerhandler_p.h
@@ -71,11 +71,14 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointerHandler : public QObject, public QQmlP
Q_PROPERTY(QQuickItem * parent READ parentItem CONSTANT)
Q_PROPERTY(GrabPermissions grabPermissions READ grabPermissions WRITE setGrabPermissions NOTIFY grabPermissionChanged)
Q_PROPERTY(qreal margin READ margin WRITE setMargin NOTIFY marginChanged)
- Q_PROPERTY(int dragThreshold READ dragThreshold WRITE setDragThreshold RESET resetDragThreshold NOTIFY dragThresholdChanged REVISION 15)
+ Q_PROPERTY(int dragThreshold READ dragThreshold WRITE setDragThreshold RESET resetDragThreshold NOTIFY dragThresholdChanged REVISION(2, 15))
+#if QT_CONFIG(cursor)
+ Q_PROPERTY(Qt::CursorShape cursorShape READ cursorShape WRITE setCursorShape RESET resetCursorShape NOTIFY cursorShapeChanged REVISION(2, 15))
+#endif
QML_NAMED_ELEMENT(PointerHandler)
QML_UNCREATABLE("PointerHandler is an abstract base class.")
- QML_ADDED_IN_MINOR_VERSION(12)
+ QML_ADDED_IN_VERSION(2, 12)
public:
explicit QQuickPointerHandler(QQuickItem *parent = nullptr);
@@ -119,15 +122,25 @@ public:
void setDragThreshold(int t);
void resetDragThreshold();
+#if QT_CONFIG(cursor)
+ Qt::CursorShape cursorShape() const;
+ void setCursorShape(Qt::CursorShape shape);
+ void resetCursorShape();
+ bool isCursorShapeExplicitlySet() const;
+#endif
+
Q_SIGNALS:
void enabledChanged();
void activeChanged();
void targetChanged();
void marginChanged();
- Q_REVISION(15) void dragThresholdChanged();
+ Q_REVISION(2, 15) void dragThresholdChanged();
void grabChanged(QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point);
void grabPermissionChanged();
void canceled(QQuickEventPoint *point);
+#if QT_CONFIG(cursor)
+ Q_REVISION(2, 15) void cursorShapeChanged();
+#endif
protected:
QQuickPointerHandler(QQuickPointerHandlerPrivate &dd, QQuickItem *parent);
diff --git a/src/quick/handlers/qquickpointerhandler_p_p.h b/src/quick/handlers/qquickpointerhandler_p_p.h
index 5727b1ef55..db053fb6b4 100644
--- a/src/quick/handlers/qquickpointerhandler_p_p.h
+++ b/src/quick/handlers/qquickpointerhandler_p_p.h
@@ -79,11 +79,13 @@ public:
qreal m_margin = 0;
qint16 dragThreshold = -1; // -1 means use the platform default
uint8_t grabPermissions : 8;
+ Qt::CursorShape cursorShape : 6;
bool enabled : 1;
bool active : 1;
bool targetExplicitlySet : 1;
bool hadKeepMouseGrab : 1; // some handlers override target()->setKeepMouseGrab(); this remembers previous state
bool hadKeepTouchGrab : 1; // some handlers override target()->setKeepTouchGrab(); this remembers previous state
+ bool cursorSet : 1;
};
QT_END_NAMESPACE
diff --git a/src/quick/handlers/qquickpointhandler_p.h b/src/quick/handlers/qquickpointhandler_p.h
index 42677540a7..cedbc1c539 100644
--- a/src/quick/handlers/qquickpointhandler_p.h
+++ b/src/quick/handlers/qquickpointhandler_p.h
@@ -60,7 +60,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointHandler : public QQuickSinglePointHandle
Q_OBJECT
Q_PROPERTY(QVector2D translation READ translation NOTIFY translationChanged)
QML_NAMED_ELEMENT(PointHandler)
- QML_ADDED_IN_MINOR_VERSION(12)
+ QML_ADDED_IN_VERSION(2, 12)
public:
explicit QQuickPointHandler(QQuickItem *parent = nullptr);
diff --git a/src/quick/handlers/qquicktaphandler_p.h b/src/quick/handlers/qquicktaphandler_p.h
index 07454bccb8..d5c16b071f 100644
--- a/src/quick/handlers/qquicktaphandler_p.h
+++ b/src/quick/handlers/qquicktaphandler_p.h
@@ -68,7 +68,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTapHandler : public QQuickSinglePointHandler
Q_PROPERTY(GesturePolicy gesturePolicy READ gesturePolicy WRITE setGesturePolicy NOTIFY gesturePolicyChanged)
QML_NAMED_ELEMENT(TapHandler)
- QML_ADDED_IN_MINOR_VERSION(12)
+ QML_ADDED_IN_VERSION(2, 12)
public:
enum GesturePolicy {
diff --git a/src/quick/handlers/qquickwheelhandler_p.h b/src/quick/handlers/qquickwheelhandler_p.h
index 26b052c5b3..021cd23679 100644
--- a/src/quick/handlers/qquickwheelhandler_p.h
+++ b/src/quick/handlers/qquickwheelhandler_p.h
@@ -73,7 +73,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickWheelHandler : public QQuickSinglePointHandle
Q_PROPERTY(bool targetTransformAroundCursor READ isTargetTransformAroundCursor WRITE setTargetTransformAroundCursor NOTIFY targetTransformAroundCursorChanged)
QML_NAMED_ELEMENT(WheelHandler)
- QML_ADDED_IN_MINOR_VERSION(14)
+ QML_ADDED_IN_VERSION(2, 14)
public:
explicit QQuickWheelHandler(QQuickItem *parent = nullptr);
diff --git a/src/quick/items/context2d/qquickcanvasitem_p.h b/src/quick/items/context2d/qquickcanvasitem_p.h
index 6575caf806..48663c2dad 100644
--- a/src/quick/items/context2d/qquickcanvasitem_p.h
+++ b/src/quick/items/context2d/qquickcanvasitem_p.h
@@ -100,6 +100,7 @@ class QQuickCanvasItem : public QQuickItem
Q_PROPERTY(RenderTarget renderTarget READ renderTarget WRITE setRenderTarget NOTIFY renderTargetChanged)
Q_PROPERTY(RenderStrategy renderStrategy READ renderStrategy WRITE setRenderStrategy NOTIFY renderStrategyChanged)
QML_NAMED_ELEMENT(Canvas)
+ QML_ADDED_IN_VERSION(2, 0)
public:
enum RenderTarget {
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index 54cda72a36..8361be7277 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -74,12 +74,12 @@
#include <QtCore/private/qnumeric_p.h>
#include <QtCore/QRunnable>
#include <QtGui/qguiapplication.h>
-#include <QtGui/qopenglframebufferobject.h>
#include <private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
#if QT_CONFIG(opengl)
-# include <private/qsgdefaultrendercontext_p.h>
+#include <qopenglframebufferobject.h>
+#include <private/qsgdefaultrendercontext_p.h>
#endif
#include <cmath>
diff --git a/src/quick/items/qquickaccessibleattached_p.h b/src/quick/items/qquickaccessibleattached_p.h
index b7254d6686..8a71c492a3 100644
--- a/src/quick/items/qquickaccessibleattached_p.h
+++ b/src/quick/items/qquickaccessibleattached_p.h
@@ -91,6 +91,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickAccessibleAttached : public QObject
Q_PROPERTY(bool ignored READ ignored WRITE setIgnored NOTIFY ignoredChanged FINAL)
QML_NAMED_ELEMENT(Accessible)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("Accessible is only available via attached properties.")
QML_ATTACHED(QQuickAccessibleAttached)
diff --git a/src/quick/items/qquickanchors_p.h b/src/quick/items/qquickanchors_p.h
index e0276549e9..d243f6070f 100644
--- a/src/quick/items/qquickanchors_p.h
+++ b/src/quick/items/qquickanchors_p.h
@@ -85,6 +85,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickAnchors : public QObject
Q_PROPERTY(QQuickItem *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn NOTIFY centerInChanged)
Q_PROPERTY(bool alignWhenCentered READ alignWhenCentered WRITE setAlignWhenCentered NOTIFY centerAlignedChanged)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickAnchors(QQuickItem *item, QObject *parent=nullptr);
diff --git a/src/quick/items/qquickanimatedimage.cpp b/src/quick/items/qquickanimatedimage.cpp
index 18d492cd68..192ed289e2 100644
--- a/src/quick/items/qquickanimatedimage.cpp
+++ b/src/quick/items/qquickanimatedimage.cpp
@@ -67,7 +67,7 @@ QQuickPixmap* QQuickAnimatedImagePrivate::infoForCurrentFrame(QQmlEngine *engine
.arg(current));
}
if (!requestedUrl.isEmpty()) {
- if (QQuickPixmap::isCached(requestedUrl, QSize(), 0, QQuickImageProviderOptions()))
+ if (QQuickPixmap::isCached(requestedUrl, QRect(), QSize(), 0, QQuickImageProviderOptions()))
pixmap = new QQuickPixmap(engine, requestedUrl);
else
pixmap = new QQuickPixmap(requestedUrl, movie->currentImage());
diff --git a/src/quick/items/qquickanimatedimage_p.h b/src/quick/items/qquickanimatedimage_p.h
index 7f2199fd2a..6f7a7e45d5 100644
--- a/src/quick/items/qquickanimatedimage_p.h
+++ b/src/quick/items/qquickanimatedimage_p.h
@@ -70,11 +70,12 @@ class Q_AUTOTEST_EXPORT QQuickAnimatedImage : public QQuickImage
Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY frameChanged)
Q_PROPERTY(int frameCount READ frameCount NOTIFY frameCountChanged)
- Q_PROPERTY(qreal speed READ speed WRITE setSpeed NOTIFY speedChanged REVISION 11)
+ Q_PROPERTY(qreal speed READ speed WRITE setSpeed NOTIFY speedChanged REVISION(2, 11))
// read-only for AnimatedImage
Q_PROPERTY(QSize sourceSize READ sourceSize NOTIFY sourceSizeChanged)
QML_NAMED_ELEMENT(AnimatedImage)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickAnimatedImage(QQuickItem *parent=nullptr);
@@ -104,7 +105,7 @@ Q_SIGNALS:
void frameChanged();
void currentFrameChanged();
void frameCountChanged();
- Q_REVISION(11) void speedChanged();
+ Q_REVISION(2, 11) void speedChanged();
private Q_SLOTS:
void movieUpdate();
diff --git a/src/quick/items/qquickanimatedsprite_p.h b/src/quick/items/qquickanimatedsprite_p.h
index c28b6ce3af..77147add16 100644
--- a/src/quick/items/qquickanimatedsprite_p.h
+++ b/src/quick/items/qquickanimatedsprite_p.h
@@ -92,8 +92,9 @@ class Q_AUTOTEST_EXPORT QQuickAnimatedSprite : public QQuickItem
Q_PROPERTY(int loops READ loops WRITE setLoops NOTIFY loopsChanged)
Q_PROPERTY(bool paused READ paused WRITE setPaused NOTIFY pausedChanged)
Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY currentFrameChanged)
- Q_PROPERTY(FinishBehavior finishBehavior READ finishBehavior WRITE setFinishBehavior NOTIFY finishBehaviorChanged REVISION 15)
+ Q_PROPERTY(FinishBehavior finishBehavior READ finishBehavior WRITE setFinishBehavior NOTIFY finishBehaviorChanged REVISION(2, 15))
QML_NAMED_ELEMENT(AnimatedSprite)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickAnimatedSprite(QQuickItem *parent = nullptr);
@@ -124,6 +125,7 @@ public:
bool paused() const;
int currentFrame() const;
FinishBehavior finishBehavior() const;
+ void setFinishBehavior(FinishBehavior arg);
Q_SIGNALS:
@@ -143,9 +145,9 @@ Q_SIGNALS:
void frameDurationChanged(int arg);
void loopsChanged(int arg);
void currentFrameChanged(int arg);
- Q_REVISION(15) void finishBehaviorChanged(FinishBehavior arg);
+ Q_REVISION(2, 15) void finishBehaviorChanged(FinishBehavior arg);
- Q_REVISION(12) void finished();
+ Q_REVISION(2, 12) void finished();
public Q_SLOTS:
void start();
@@ -172,7 +174,6 @@ public Q_SLOTS:
void resetFrameDuration();
void setLoops(int arg);
void setCurrentFrame(int arg);
- void setFinishBehavior(FinishBehavior arg);
private Q_SLOTS:
void createEngine();
diff --git a/src/quick/items/qquickborderimage.cpp b/src/quick/items/qquickborderimage.cpp
index 32407a474f..3679df37d1 100644
--- a/src/quick/items/qquickborderimage.cpp
+++ b/src/quick/items/qquickborderimage.cpp
@@ -478,7 +478,7 @@ void QQuickBorderImage::sciRequestFinished()
}
d->redirectCount=0;
- if (d->sciReply->networkError() != QNetworkReply::NoError) {
+ if (d->sciReply->error() != QNetworkReply::NoError) {
d->status = Error;
d->sciReply->deleteLater();
d->sciReply = nullptr;
diff --git a/src/quick/items/qquickborderimage_p.h b/src/quick/items/qquickborderimage_p.h
index 515edb33da..48922147ba 100644
--- a/src/quick/items/qquickborderimage_p.h
+++ b/src/quick/items/qquickborderimage_p.h
@@ -68,6 +68,7 @@ class Q_AUTOTEST_EXPORT QQuickBorderImage : public QQuickImageBase
// read-only for BorderImage
Q_PROPERTY(QSize sourceSize READ sourceSize NOTIFY sourceSizeChanged)
QML_NAMED_ELEMENT(BorderImage)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickBorderImage(QQuickItem *parent=nullptr);
diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp
index 737b7ffe24..117daef924 100644
--- a/src/quick/items/qquickdrag.cpp
+++ b/src/quick/items/qquickdrag.cpp
@@ -61,6 +61,7 @@ class QQuickDragAttachedPrivate : public QObjectPrivate, public QQuickItemChange
{
Q_DECLARE_PUBLIC(QQuickDragAttached)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
static QQuickDragAttachedPrivate *get(QQuickDragAttached *attached) {
diff --git a/src/quick/items/qquickdrag_p.h b/src/quick/items/qquickdrag_p.h
index 9dbaac18f9..36b0a2bfd1 100644
--- a/src/quick/items/qquickdrag_p.h
+++ b/src/quick/items/qquickdrag_p.h
@@ -173,6 +173,7 @@ class Q_AUTOTEST_EXPORT QQuickDrag : public QObject
//### consider drag and drop
QML_NAMED_ELEMENT(Drag)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("Drag is only available via attached properties.")
QML_ATTACHED(QQuickDragAttached)
@@ -260,6 +261,7 @@ class QQuickDragAttached : public QObject
Q_PROPERTY(QQuickDrag::DragType dragType READ dragType WRITE setDragType NOTIFY dragTypeChanged)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickDragAttached(QObject *parent);
diff --git a/src/quick/items/qquickdroparea_p.h b/src/quick/items/qquickdroparea_p.h
index ee2deaa97a..b1d3d78a37 100644
--- a/src/quick/items/qquickdroparea_p.h
+++ b/src/quick/items/qquickdroparea_p.h
@@ -81,6 +81,7 @@ class QQuickDropEvent : public QObject
Q_PROPERTY(QList<QUrl> urls READ urls)
Q_PROPERTY(QStringList formats READ formats)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickDropEvent(QQuickDropAreaPrivate *d, QDropEvent *event) : d(d), event(event) {}
@@ -127,6 +128,7 @@ class QQuickDropAreaDrag : public QObject
Q_PROPERTY(qreal y READ y NOTIFY positionChanged)
Q_PROPERTY(QObject *source READ source NOTIFY sourceChanged)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickDropAreaDrag(QQuickDropAreaPrivate *d, QObject *parent = 0);
~QQuickDropAreaDrag();
@@ -154,6 +156,7 @@ class Q_AUTOTEST_EXPORT QQuickDropArea : public QQuickItem
Q_PROPERTY(QStringList keys READ keys WRITE setKeys NOTIFY keysChanged)
Q_PROPERTY(QQuickDropAreaDrag *drag READ drag CONSTANT)
QML_NAMED_ELEMENT(DropArea)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickDropArea(QQuickItem *parent=0);
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index 03280e4c1f..804c3a081e 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -597,8 +597,10 @@ Q_GLOBAL_STATIC_WITH_ARGS(ConstructableQQuickPointerDevice, g_genericMouseDevice
QQuickPointerDevice::Position | QQuickPointerDevice::Scroll | QQuickPointerDevice::Hover,
1, 3, QLatin1String("core pointer"), 0))
+#if QT_CONFIG(tabletevent)
typedef QHash<qint64, QQuickPointerDevice *> PointerDeviceForDeviceIdHash;
Q_GLOBAL_STATIC(PointerDeviceForDeviceIdHash, g_tabletDevices)
+#endif
// debugging helpers
static const char *pointStateString(const QQuickEventPoint *point)
@@ -658,15 +660,76 @@ QQuickPointerDevice *QQuickPointerDevice::genericMouseDevice()
return g_genericMouseDevice;
}
-QQuickPointerDevice *QQuickPointerDevice::tabletDevice(qint64 id)
+#if QT_CONFIG(tabletevent)
+QQuickPointerDevice *QQuickPointerDevice::tabletDevice(const QTabletEvent *event)
{
- auto it = g_tabletDevices->find(id);
+ // QTabletEvent::uniqueId() is the same for the pointy end and the eraser end of the stylus.
+ // We need to make those unique. QTabletEvent::PointerType only needs 2 bits' worth of storage.
+ // The key into g_tabletDevices just needs to be unique; we don't need to extract uniqueId
+ // back out of it, because QQuickPointerDevice stores that separately anyway.
+ // So the shift-and-add can be thought of as a sort of hash function, even though
+ // most of the time the result will be recognizable because the uniqueId MSBs are often 0.
+ qint64 key = event->uniqueId() + (qint64(event->pointerType()) << 60);
+ auto it = g_tabletDevices->find(key);
if (it != g_tabletDevices->end())
return it.value();
- // ### Figure out how to populate the tablet devices
- return nullptr;
+ DeviceType type = UnknownDevice;
+ int buttonCount = 0;
+ Capabilities caps = Position | Pressure | Hover;
+ // TODO Qt 6: we can't know for sure about XTilt or YTilt until we have a
+ // QTabletDevice populated with capabilities provided by QPA plugins
+
+ switch (event->deviceType()) {
+ case QTabletEvent::Stylus:
+ type = QQuickPointerDevice::Stylus;
+ buttonCount = 3;
+ break;
+ case QTabletEvent::RotationStylus:
+ type = QQuickPointerDevice::Stylus;
+ caps |= QQuickPointerDevice::Rotation;
+ buttonCount = 1;
+ break;
+ case QTabletEvent::Airbrush:
+ type = QQuickPointerDevice::Airbrush;
+ buttonCount = 2;
+ break;
+ case QTabletEvent::Puck:
+ type = QQuickPointerDevice::Puck;
+ buttonCount = 3;
+ break;
+ case QTabletEvent::FourDMouse:
+ type = QQuickPointerDevice::Mouse;
+ caps |= QQuickPointerDevice::Rotation;
+ buttonCount = 3;
+ break;
+ default:
+ type = QQuickPointerDevice::UnknownDevice;
+ break;
+ }
+
+ PointerType ptype = GenericPointer;
+ switch (event->pointerType()) {
+ case QTabletEvent::Pen:
+ ptype = Pen;
+ break;
+ case QTabletEvent::Eraser:
+ ptype = Eraser;
+ break;
+ case QTabletEvent::Cursor:
+ ptype = Cursor;
+ break;
+ case QTabletEvent::UnknownPointer:
+ break;
+ }
+
+ QQuickPointerDevice *device = new QQuickPointerDevice(type, ptype, caps, 1, buttonCount,
+ QLatin1String("tablet tool ") + QString::number(event->uniqueId()), event->uniqueId());
+
+ g_tabletDevices->insert(key, device);
+ return device;
}
+#endif
/*!
\qmltype EventPoint
@@ -1284,6 +1347,12 @@ QVector2D QQuickEventPoint::estimatedVelocity() const
QQuickPointerEvent::~QQuickPointerEvent()
{}
+QQuickPointerMouseEvent::QQuickPointerMouseEvent(QObject *parent, QQuickPointerDevice *device)
+ : QQuickSinglePointEvent(parent, device)
+{
+ m_point = new QQuickEventPoint(this);
+}
+
QQuickPointerEvent *QQuickPointerMouseEvent::reset(QEvent *event)
{
auto ev = static_cast<QMouseEvent*>(event);
@@ -1398,6 +1467,12 @@ void QQuickPointerTouchEvent::localize(QQuickItem *target)
}
#if QT_CONFIG(gestures)
+QQuickPointerNativeGestureEvent::QQuickPointerNativeGestureEvent(QObject *parent, QQuickPointerDevice *device)
+ : QQuickSinglePointEvent(parent, device)
+{
+ m_point = new QQuickEventPoint(this);
+}
+
QQuickPointerEvent *QQuickPointerNativeGestureEvent::reset(QEvent *event)
{
auto ev = static_cast<QNativeGestureEvent*>(event);
@@ -1560,6 +1635,12 @@ QQuickEventPoint *QQuickSinglePointEvent::point(int i) const
\note Many platforms provide no such information. On such platforms,
\c inverted always returns false.
*/
+QQuickPointerScrollEvent::QQuickPointerScrollEvent(QObject *parent, QQuickPointerDevice *device)
+ : QQuickSinglePointEvent(parent, device)
+{
+ m_point = new QQuickEventPoint(this);
+}
+
QQuickPointerEvent *QQuickPointerScrollEvent::reset(QEvent *event)
{
m_event = static_cast<QInputEvent*>(event);
@@ -1626,6 +1707,8 @@ bool QQuickSinglePointEvent::allPointsGrabbed() const
QMouseEvent *QQuickPointerMouseEvent::asMouseEvent(const QPointF &localPos) const
{
+ if (!m_event)
+ return nullptr;
auto event = static_cast<QMouseEvent *>(m_event);
event->setLocalPos(localPos);
return event;
@@ -1830,6 +1913,81 @@ QMouseEvent *QQuickPointerTouchEvent::syntheticMouseEvent(int pointID, QQuickIte
return &m_synthMouseEvent;
}
+#if QT_CONFIG(tabletevent)
+QQuickPointerTabletEvent::QQuickPointerTabletEvent(QObject *parent, QQuickPointerDevice *device)
+ : QQuickSinglePointEvent(parent, device)
+{
+ m_point = new QQuickEventTabletPoint(this);
+}
+
+QQuickPointerEvent *QQuickPointerTabletEvent::reset(QEvent *event)
+{
+ auto ev = static_cast<QTabletEvent*>(event);
+ m_event = ev;
+ if (!event)
+ return this;
+
+ Q_ASSERT(m_device == QQuickPointerDevice::tabletDevice(ev));
+ m_device->eventDeliveryTargets().clear();
+ m_button = ev->button();
+ m_pressedButtons = ev->buttons();
+ static_cast<QQuickEventTabletPoint *>(m_point)->reset(ev);
+ return this;
+}
+
+QQuickEventTabletPoint::QQuickEventTabletPoint(QQuickPointerTabletEvent *parent)
+ : QQuickEventPoint(parent)
+{
+}
+
+void QQuickEventTabletPoint::reset(const QTabletEvent *ev)
+{
+ Qt::TouchPointState state = Qt::TouchPointStationary;
+ switch (ev->type()) {
+ case QEvent::TabletPress:
+ state = Qt::TouchPointPressed;
+ clearPassiveGrabbers();
+ break;
+ case QEvent::TabletRelease:
+ state = Qt::TouchPointReleased;
+ break;
+ case QEvent::TabletMove:
+ state = Qt::TouchPointMoved;
+ break;
+ default:
+ break;
+ }
+ QQuickEventPoint::reset(state, ev->posF(), 1, ev->timestamp());
+ m_rotation = ev->rotation();
+ m_pressure = ev->pressure();
+ m_tangentialPressure = ev->tangentialPressure();
+ m_tilt = QVector2D(ev->xTilt(), ev->yTilt());
+}
+
+bool QQuickPointerTabletEvent::isPressEvent() const
+{
+ auto me = static_cast<QTabletEvent *>(m_event);
+ return me->type() == QEvent::TabletPress;
+}
+
+bool QQuickPointerTabletEvent::isUpdateEvent() const
+{
+ auto me = static_cast<QTabletEvent *>(m_event);
+ return me->type() == QEvent::TabletMove;
+}
+
+bool QQuickPointerTabletEvent::isReleaseEvent() const
+{
+ auto me = static_cast<QTabletEvent *>(m_event);
+ return me->type() == QEvent::TabletRelease;
+}
+
+QTabletEvent *QQuickPointerTabletEvent::asTabletEvent() const
+{
+ return static_cast<QTabletEvent *>(m_event);
+}
+#endif // QT_CONFIG(tabletevent)
+
#if QT_CONFIG(gestures)
bool QQuickPointerNativeGestureEvent::isPressEvent() const
{
diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h
index 4615ce43d2..b1d8b52372 100644
--- a/src/quick/items/qquickevents_p_p.h
+++ b/src/quick/items/qquickevents_p_p.h
@@ -56,12 +56,14 @@
#include <QtCore/qobject.h>
#include <QtCore/qpointer.h>
-#include <QtGui/qvector2d.h>
#include <QtGui/qevent.h>
+#include <QtGui/qtouchdevice.h>
+#include <QtGui/qvector2d.h>
+#include <QtQuick/qquickitem.h>
+
#if QT_CONFIG(shortcut)
# include <QtGui/qkeysequence.h>
#endif
-#include <QtQuick/qquickitem.h>
QT_BEGIN_NAMESPACE
@@ -87,6 +89,7 @@ class QQuickKeyEvent : public QObject
Q_PROPERTY(quint32 nativeScanCode READ nativeScanCode CONSTANT)
Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickKeyEvent()
@@ -117,7 +120,7 @@ public:
void setAccepted(bool accepted) { event.setAccepted(accepted); }
#if QT_CONFIG(shortcut)
- Q_REVISION(2) Q_INVOKABLE bool matches(QKeySequence::StandardKey key) const { return event.matches(key); }
+ Q_REVISION(2, 2) Q_INVOKABLE bool matches(QKeySequence::StandardKey key) const { return event.matches(key); }
#endif
private:
@@ -133,12 +136,13 @@ class Q_QUICK_PRIVATE_EXPORT QQuickMouseEvent : public QObject
Q_PROPERTY(int button READ button CONSTANT)
Q_PROPERTY(int buttons READ buttons CONSTANT)
Q_PROPERTY(int modifiers READ modifiers CONSTANT)
- Q_PROPERTY(int source READ source CONSTANT REVISION 7)
+ Q_PROPERTY(int source READ source CONSTANT REVISION(2, 7))
Q_PROPERTY(bool wasHeld READ wasHeld CONSTANT)
Q_PROPERTY(bool isClick READ isClick CONSTANT)
Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
- Q_PROPERTY(int flags READ flags CONSTANT REVISION 11)
+ Q_PROPERTY(int flags READ flags CONSTANT REVISION(2, 11))
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickMouseEvent()
@@ -205,6 +209,7 @@ class QQuickWheelEvent : public QObject
Q_PROPERTY(bool inverted READ inverted CONSTANT)
Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickWheelEvent()
@@ -250,6 +255,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickCloseEvent : public QObject
Q_OBJECT
Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickCloseEvent() {}
@@ -278,7 +284,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickEventPoint : public QObject
QML_NAMED_ELEMENT(EventPoint)
QML_UNCREATABLE("EventPoint is only available as a member of PointerEvent.")
- QML_ADDED_IN_MINOR_VERSION(12)
+ QML_ADDED_IN_VERSION(2, 12)
public:
enum State {
@@ -373,7 +379,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickEventTouchPoint : public QQuickEventPoint
QML_NAMED_ELEMENT(EventTouchPoint)
QML_UNCREATABLE("EventTouchPoint is only available as a member of PointerEvent.")
- QML_ADDED_IN_MINOR_VERSION(12)
+ QML_ADDED_IN_VERSION(2, 12)
public:
QQuickEventTouchPoint(QQuickPointerTouchEvent *parent);
@@ -406,7 +412,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointerEvent : public QObject
QML_NAMED_ELEMENT(PointerEvent)
QML_UNCREATABLE("PointerEvent is only available as a parameter of several signals in PointerHandler")
- QML_ADDED_IN_MINOR_VERSION(12)
+ QML_ADDED_IN_VERSION(2, 12)
public:
QQuickPointerEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr)
@@ -476,8 +482,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickSinglePointEvent : public QQuickPointerEvent
{
Q_OBJECT
public:
- QQuickSinglePointEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr)
- : QQuickPointerEvent(parent, device), m_point(new QQuickEventPoint(this)) { }
+ QQuickSinglePointEvent(QObject *parent, QQuickPointerDevice *device)
+ : QQuickPointerEvent(parent, device) { }
void localize(QQuickItem *target) override;
int pointCount() const override { return 1; }
@@ -491,7 +497,7 @@ public:
bool hasExclusiveGrabber(const QQuickPointerHandler *handler) const override;
protected:
- QQuickEventPoint *m_point;
+ QQuickEventPoint *m_point = nullptr;
Q_DISABLE_COPY(QQuickSinglePointEvent)
};
@@ -502,11 +508,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointerMouseEvent : public QQuickSinglePointE
QML_NAMED_ELEMENT(PointerMouseEvent)
QML_UNCREATABLE("PointerMouseEvent is only available as a parameter of several signals in PointerHandler")
- QML_ADDED_IN_MINOR_VERSION(12)
+ QML_ADDED_IN_VERSION(2, 12)
public:
- QQuickPointerMouseEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr)
- : QQuickSinglePointEvent(parent, device) { }
+ QQuickPointerMouseEvent(QObject *parent, QQuickPointerDevice *device);
QQuickPointerEvent *reset(QEvent *) override;
bool isPressEvent() const override;
@@ -527,7 +532,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointerTouchEvent : public QQuickPointerEvent
QML_NAMED_ELEMENT(PointerTouchEvent)
QML_UNCREATABLE("PointerTouchEvent is only available as a parameter of several signals in PointerHandler")
- QML_ADDED_IN_MINOR_VERSION(12)
+ QML_ADDED_IN_VERSION(2, 12)
public:
QQuickPointerTouchEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr)
@@ -568,6 +573,60 @@ private:
Q_DISABLE_COPY(QQuickPointerTouchEvent)
};
+#if QT_CONFIG(tabletevent)
+class Q_QUICK_PRIVATE_EXPORT QQuickEventTabletPoint : public QQuickEventPoint
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal rotation READ rotation)
+ Q_PROPERTY(qreal pressure READ pressure)
+ Q_PROPERTY(qreal tangentialPressure READ tangentialPressure)
+ Q_PROPERTY(QVector2D tilt READ tilt)
+
+ QML_NAMED_ELEMENT(EventTabletPoint)
+ QML_UNCREATABLE("EventTouchPoint is only available as a member of PointerEvent.")
+ QML_ADDED_IN_VERSION(2, 15)
+
+public:
+ QQuickEventTabletPoint(QQuickPointerTabletEvent *parent);
+
+ void reset(const QTabletEvent *e);
+
+ qreal rotation() const { return m_rotation; }
+ qreal pressure() const { return m_pressure; }
+ qreal tangentialPressure() const { return m_tangentialPressure; }
+ QVector2D tilt() const { return m_tilt; }
+
+private:
+ qreal m_rotation;
+ qreal m_pressure;
+ qreal m_tangentialPressure;
+ QVector2D m_tilt;
+
+ friend class QQuickPointerTouchEvent;
+
+ Q_DISABLE_COPY(QQuickEventTabletPoint)
+};
+
+class Q_QUICK_PRIVATE_EXPORT QQuickPointerTabletEvent : public QQuickSinglePointEvent
+{
+ Q_OBJECT
+public:
+ QQuickPointerTabletEvent(QObject *parent, QQuickPointerDevice *device);
+
+ QQuickPointerEvent *reset(QEvent *) override;
+ bool isPressEvent() const override;
+ bool isUpdateEvent() const override;
+ bool isReleaseEvent() const override;
+ QQuickPointerTabletEvent *asPointerTabletEvent() override { return this; }
+ const QQuickPointerTabletEvent *asPointerTabletEvent() const override { return this; }
+ const QQuickEventTabletPoint *tabletPoint() const { return static_cast<QQuickEventTabletPoint *>(m_point); }
+
+ QTabletEvent *asTabletEvent() const;
+
+ Q_DISABLE_COPY(QQuickPointerTabletEvent)
+};
+#endif // QT_CONFIG(tabletevent)
+
#if QT_CONFIG(gestures)
class Q_QUICK_PRIVATE_EXPORT QQuickPointerNativeGestureEvent : public QQuickSinglePointEvent
{
@@ -576,8 +635,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointerNativeGestureEvent : public QQuickSing
Q_PROPERTY(qreal value READ value CONSTANT)
public:
- QQuickPointerNativeGestureEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr)
- : QQuickSinglePointEvent(parent, device) { }
+ QQuickPointerNativeGestureEvent(QObject *parent, QQuickPointerDevice *device);
QQuickPointerEvent *reset(QEvent *) override;
bool isPressEvent() const override;
@@ -603,11 +661,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointerScrollEvent : public QQuickSinglePoint
QML_NAMED_ELEMENT(PointerScrollEvent)
QML_UNCREATABLE("PointerScrollEvent is only available via the WheelHandler::wheel signal.")
- QML_ADDED_IN_MINOR_VERSION(14)
+ QML_ADDED_IN_VERSION(2, 14)
public:
- QQuickPointerScrollEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr)
- : QQuickSinglePointEvent(parent, device) { }
+ QQuickPointerScrollEvent(QObject *parent, QQuickPointerDevice *device);
QQuickPointerEvent *reset(QEvent *) override;
void localize(QQuickItem *target) override;
@@ -656,7 +713,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointerDevice : public QObject
QML_NAMED_ELEMENT(PointerDevice)
QML_UNCREATABLE("PointerDevice is only available as a property of PointerEvent.")
- QML_ADDED_IN_MINOR_VERSION(12)
+ QML_ADDED_IN_VERSION(2, 12)
public:
enum DeviceType : qint16 {
@@ -712,7 +769,9 @@ public:
static QQuickPointerDevice *touchDevice(const QTouchDevice *d);
static QList<QQuickPointerDevice *> touchDevices();
static QQuickPointerDevice *genericMouseDevice();
- static QQuickPointerDevice *tabletDevice(qint64);
+#if QT_CONFIG(tabletevent)
+ static QQuickPointerDevice *tabletDevice(const QTabletEvent *event);
+#endif
QVector<QQuickPointerHandler *> &eventDeliveryTargets() { return m_eventDeliveryTargets; }
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index 8ade5b7e37..27c57e147a 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -128,8 +128,13 @@ void QQuickFlickableVisibleArea::updateVisible()
// Vertical
const qreal viewheight = flickable->height();
const qreal maxyextent = -flickable->maxYExtent() + flickable->minYExtent();
- qreal pagePos = (-p->vData.move.value() + flickable->minYExtent()) / (maxyextent + viewheight);
- qreal pageSize = viewheight / (maxyextent + viewheight);
+ const qreal maxYBounds = maxyextent + viewheight;
+ qreal pagePos = 0;
+ qreal pageSize = 0;
+ if (!qFuzzyIsNull(maxYBounds)) {
+ pagePos = (-p->vData.move.value() + flickable->minYExtent()) / maxYBounds;
+ pageSize = viewheight / maxYBounds;
+ }
if (pageSize != m_heightRatio) {
m_heightRatio = pageSize;
@@ -143,8 +148,14 @@ void QQuickFlickableVisibleArea::updateVisible()
// Horizontal
const qreal viewwidth = flickable->width();
const qreal maxxextent = -flickable->maxXExtent() + flickable->minXExtent();
- pagePos = (-p->hData.move.value() + flickable->minXExtent()) / (maxxextent + viewwidth);
- pageSize = viewwidth / (maxxextent + viewwidth);
+ const qreal maxXBounds = maxxextent + viewwidth;
+ if (!qFuzzyIsNull(maxXBounds)) {
+ pagePos = (-p->hData.move.value() + flickable->minXExtent()) / maxXBounds;
+ pageSize = viewwidth / maxXBounds;
+ } else {
+ pagePos = 0;
+ pageSize = 0;
+ }
if (pageSize != m_widthRatio) {
m_widthRatio = pageSize;
diff --git a/src/quick/items/qquickflickable_p.h b/src/quick/items/qquickflickable_p.h
index 2d8d4a5e9a..fe74425d57 100644
--- a/src/quick/items/qquickflickable_p.h
+++ b/src/quick/items/qquickflickable_p.h
@@ -80,7 +80,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickFlickable : public QQuickItem
Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged)
Q_PROPERTY(BoundsBehavior boundsBehavior READ boundsBehavior WRITE setBoundsBehavior NOTIFY boundsBehaviorChanged)
- Q_PROPERTY(BoundsMovement boundsMovement READ boundsMovement WRITE setBoundsMovement NOTIFY boundsMovementChanged REVISION 10)
+ Q_PROPERTY(BoundsMovement boundsMovement READ boundsMovement WRITE setBoundsMovement NOTIFY boundsMovementChanged REVISION(2, 10))
Q_PROPERTY(QQuickTransition *rebound READ rebound WRITE setRebound NOTIFY reboundChanged)
Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged)
Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
@@ -106,15 +106,16 @@ class Q_QUICK_PRIVATE_EXPORT QQuickFlickable : public QQuickItem
Q_PROPERTY(QQuickFlickableVisibleArea *visibleArea READ visibleArea CONSTANT)
Q_PROPERTY(bool pixelAligned READ pixelAligned WRITE setPixelAligned NOTIFY pixelAlignedChanged)
- Q_PROPERTY(bool synchronousDrag READ synchronousDrag WRITE setSynchronousDrag NOTIFY synchronousDragChanged REVISION 12)
+ Q_PROPERTY(bool synchronousDrag READ synchronousDrag WRITE setSynchronousDrag NOTIFY synchronousDragChanged REVISION(2, 12))
- Q_PROPERTY(qreal horizontalOvershoot READ horizontalOvershoot NOTIFY horizontalOvershootChanged REVISION 9)
- Q_PROPERTY(qreal verticalOvershoot READ verticalOvershoot NOTIFY verticalOvershootChanged REVISION 9)
+ Q_PROPERTY(qreal horizontalOvershoot READ horizontalOvershoot NOTIFY horizontalOvershootChanged REVISION(2, 9))
+ Q_PROPERTY(qreal verticalOvershoot READ verticalOvershoot NOTIFY verticalOvershootChanged REVISION(2, 9))
Q_PROPERTY(QQmlListProperty<QObject> flickableData READ flickableData)
Q_PROPERTY(QQmlListProperty<QQuickItem> flickableChildren READ flickableChildren)
Q_CLASSINFO("DefaultProperty", "flickableData")
QML_NAMED_ELEMENT(Flickable)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickFlickable(QQuickItem *parent=nullptr);
@@ -252,7 +253,7 @@ Q_SIGNALS:
void flickableDirectionChanged();
void interactiveChanged();
void boundsBehaviorChanged();
- Q_REVISION(10) void boundsMovementChanged();
+ Q_REVISION(2, 10) void boundsMovementChanged();
void reboundChanged();
void maximumFlickVelocityChanged();
void flickDecelerationChanged();
@@ -264,11 +265,11 @@ Q_SIGNALS:
void dragStarted();
void dragEnded();
void pixelAlignedChanged();
- Q_REVISION(12) void synchronousDragChanged();
- Q_REVISION(9) void horizontalOvershootChanged();
- Q_REVISION(9) void verticalOvershootChanged();
+ Q_REVISION(2, 12) void synchronousDragChanged();
+ Q_REVISION(2, 9) void horizontalOvershootChanged();
+ Q_REVISION(2, 9) void verticalOvershootChanged();
- // The next four signals should be marked as Q_REVISION(12). See QTBUG-71243
+ // The next four signals should be marked as Q_REVISION(2, 12). See QTBUG-71243
void atXEndChanged();
void atYEndChanged();
void atXBeginningChanged();
diff --git a/src/quick/items/qquickflickable_p_p.h b/src/quick/items/qquickflickable_p_p.h
index 1ff55dae90..0d7f27492a 100644
--- a/src/quick/items/qquickflickable_p_p.h
+++ b/src/quick/items/qquickflickable_p_p.h
@@ -73,7 +73,7 @@ class QQuickFlickableVisibleArea;
class QQuickTransition;
class QQuickFlickableReboundTransition;
-class Q_AUTOTEST_EXPORT QQuickFlickablePrivate : public QQuickItemPrivate, public QQuickItemChangeListener
+class Q_QUICK_PRIVATE_EXPORT QQuickFlickablePrivate : public QQuickItemPrivate, public QQuickItemChangeListener
{
Q_DECLARE_PUBLIC(QQuickFlickable)
@@ -285,6 +285,7 @@ class QQuickFlickableVisibleArea : public QObject
Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY widthRatioChanged)
Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY heightRatioChanged)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickFlickableVisibleArea(QQuickFlickable *parent=nullptr);
diff --git a/src/quick/items/qquickflipable_p.h b/src/quick/items/qquickflipable_p.h
index 42c632a33c..8d6716ec53 100644
--- a/src/quick/items/qquickflipable_p.h
+++ b/src/quick/items/qquickflipable_p.h
@@ -72,6 +72,7 @@ class Q_AUTOTEST_EXPORT QQuickFlipable : public QQuickItem
Q_PROPERTY(QQuickItem *back READ back WRITE setBack NOTIFY backChanged)
Q_PROPERTY(Side side READ side NOTIFY sideChanged)
QML_NAMED_ELEMENT(Flipable)
+ QML_ADDED_IN_VERSION(2, 0)
//### flipAxis
//### flipRotation
public:
diff --git a/src/quick/items/qquickfocusscope_p.h b/src/quick/items/qquickfocusscope_p.h
index c32fa93cd9..d3e9197fc7 100644
--- a/src/quick/items/qquickfocusscope_p.h
+++ b/src/quick/items/qquickfocusscope_p.h
@@ -59,6 +59,7 @@ class Q_AUTOTEST_EXPORT QQuickFocusScope : public QQuickItem
{
Q_OBJECT
QML_NAMED_ELEMENT(FocusScope)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickFocusScope(QQuickItem *parent=nullptr);
virtual ~QQuickFocusScope();
diff --git a/src/quick/items/qquickgraphicsinfo.cpp b/src/quick/items/qquickgraphicsinfo.cpp
index adf620b256..0e711afcf2 100644
--- a/src/quick/items/qquickgraphicsinfo.cpp
+++ b/src/quick/items/qquickgraphicsinfo.cpp
@@ -40,7 +40,7 @@
#include "qquickgraphicsinfo_p.h"
#include "qquickwindow.h"
#include "qquickitem.h"
-#include <QtGui/qopenglcontext.h>
+#include <qopenglcontext.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/items/qquickgraphicsinfo_p.h b/src/quick/items/qquickgraphicsinfo_p.h
index aa7d15f72d..c55a35ed5e 100644
--- a/src/quick/items/qquickgraphicsinfo_p.h
+++ b/src/quick/items/qquickgraphicsinfo_p.h
@@ -76,7 +76,7 @@ class QQuickGraphicsInfo : public QObject
Q_PROPERTY(RenderableType renderableType READ renderableType NOTIFY renderableTypeChanged FINAL)
QML_NAMED_ELEMENT(GraphicsInfo)
- QML_ADDED_IN_MINOR_VERSION(8)
+ QML_ADDED_IN_VERSION(2, 8)
QML_UNCREATABLE("GraphicsInfo is only available via attached properties.")
QML_ATTACHED(QQuickGraphicsInfo)
diff --git a/src/quick/items/qquickgridview_p.h b/src/quick/items/qquickgridview_p.h
index 9072e5f269..7187eb7816 100644
--- a/src/quick/items/qquickgridview_p.h
+++ b/src/quick/items/qquickgridview_p.h
@@ -74,6 +74,7 @@ class Q_AUTOTEST_EXPORT QQuickGridView : public QQuickItemView
Q_CLASSINFO("DefaultProperty", "data")
QML_NAMED_ELEMENT(GridView)
+ QML_ADDED_IN_VERSION(2, 0)
QML_ATTACHED(QQuickGridViewAttached)
public:
diff --git a/src/quick/items/qquickimage.cpp b/src/quick/items/qquickimage.cpp
index fccacdcce8..1882ec8997 100644
--- a/src/quick/items/qquickimage.cpp
+++ b/src/quick/items/qquickimage.cpp
@@ -427,10 +427,10 @@ qreal QQuickImage::paintedHeight() const
/*!
\qmlproperty QSize QtQuick::Image::sourceSize
- This property holds the actual width and height of the loaded image.
+ This property holds the scaled width and height of the full-frame image.
Unlike the \l {Item::}{width} and \l {Item::}{height} properties, which scale
- the painting of the image, this property sets the actual number of pixels
+ the painting of the image, this property sets the maximum number of pixels
stored for the loaded image so that large images do not use more
memory than necessary. For example, this ensures the image in memory is no
larger than 1024x1024 pixels, regardless of the Image's \l {Item::}{width} and
@@ -455,7 +455,7 @@ qreal QQuickImage::paintedHeight() const
other dimension is set in proportion to preserve the source image's aspect ratio.
(The \l fillMode is independent of this.)
- If both the sourceSize.width and sourceSize.height are set the image will be scaled
+ If both the sourceSize.width and sourceSize.height are set, the image will be scaled
down to fit within the specified size (unless PreserveAspectCrop or PreserveAspectFit
are used, then it will be scaled to match the optimal size for cropping/fitting),
maintaining the image's aspect ratio. The actual
@@ -470,6 +470,9 @@ qreal QQuickImage::paintedHeight() const
be no greater than this property specifies. For some formats (currently only JPEG),
the whole image will never actually be loaded into memory.
+ If the \l sourceClipRect property is also set, \c sourceSize determines the scale,
+ but it will be clipped to the size of the clip rectangle.
+
sourceSize can be cleared to the natural size of the image
by setting sourceSize to \c undefined.
@@ -478,6 +481,51 @@ qreal QQuickImage::paintedHeight() const
*/
/*!
+ \qmlproperty rect QtQuick::Image::sourceClipRect
+ \since 5.15
+
+ This property, if set, holds the rectangular region of the source image to
+ be loaded.
+
+ The \c sourceClipRect works together with the \l sourceSize property to
+ conserve system resources when only a portion of an image needs to be
+ loaded.
+
+ \code
+ Rectangle {
+ width: ...
+ height: ...
+
+ Image {
+ anchors.fill: parent
+ source: "reallyBigImage.svg"
+ sourceSize.width: 1024
+ sourceSize.height: 1024
+ sourceClipRect: Qt.rect(100, 100, 512, 512)
+ }
+ }
+ \endcode
+
+ In the above example, we conceptually scale the SVG graphic to 1024x1024
+ first, and then cut out a region of interest that is 512x512 pixels from a
+ location 100 pixels from the top and left edges. Thus \c sourceSize
+ determines the scale, but the actual output image is 512x512 pixels.
+
+ Some image formats are able to conserve CPU time by rendering only the
+ specified region. Others will need to load the entire image first and then
+ clip it to the specified region.
+
+ This property can be cleared to reload the entire image by setting
+ \c sourceClipRect to \c undefined.
+
+ \note \e {Changing this property dynamically causes the image source to be reloaded,
+ potentially even from the network, if it is not in the disk cache.}
+
+ \note Sub-pixel clipping is not supported: the given rectangle will be
+ passed to \l QImageReader::setScaledClipRect().
+*/
+
+/*!
\qmlproperty url QtQuick::Image::source
Image can handle any image format supported by Qt, loaded from any URL scheme supported by Qt.
diff --git a/src/quick/items/qquickimage_p.h b/src/quick/items/qquickimage_p.h
index f7e652cdcc..1119f20e45 100644
--- a/src/quick/items/qquickimage_p.h
+++ b/src/quick/items/qquickimage_p.h
@@ -66,9 +66,11 @@ class Q_QUICK_PRIVATE_EXPORT QQuickImage : public QQuickImageBase
Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedGeometryChanged)
Q_PROPERTY(HAlignment horizontalAlignment READ horizontalAlignment WRITE setHorizontalAlignment NOTIFY horizontalAlignmentChanged)
Q_PROPERTY(VAlignment verticalAlignment READ verticalAlignment WRITE setVerticalAlignment NOTIFY verticalAlignmentChanged)
- Q_PROPERTY(bool mipmap READ mipmap WRITE setMipmap NOTIFY mipmapChanged REVISION 3)
- Q_PROPERTY(bool autoTransform READ autoTransform WRITE setAutoTransform NOTIFY autoTransformChanged REVISION 5)
+ Q_PROPERTY(bool mipmap READ mipmap WRITE setMipmap NOTIFY mipmapChanged REVISION(2, 3))
+ Q_PROPERTY(bool autoTransform READ autoTransform WRITE setAutoTransform NOTIFY autoTransformChanged REVISION(2, 5))
+ Q_PROPERTY(QRectF sourceClipRect READ sourceClipRect WRITE setSourceClipRect RESET resetSourceClipRect NOTIFY sourceClipRectChanged REVISION(2, 15))
QML_NAMED_ELEMENT(Image)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickImage(QQuickItem *parent=nullptr);
@@ -113,8 +115,8 @@ Q_SIGNALS:
void paintedGeometryChanged();
void horizontalAlignmentChanged(HAlignment alignment);
void verticalAlignmentChanged(VAlignment alignment);
- Q_REVISION(3) void mipmapChanged(bool);
- Q_REVISION(5) void autoTransformChanged();
+ Q_REVISION(2, 3) void mipmapChanged(bool);
+ Q_REVISION(2, 5) void autoTransformChanged();
private Q_SLOTS:
void invalidateSceneGraph();
diff --git a/src/quick/items/qquickimagebase.cpp b/src/quick/items/qquickimagebase.cpp
index 55b29d7a70..8849c2005c 100644
--- a/src/quick/items/qquickimagebase.cpp
+++ b/src/quick/items/qquickimagebase.cpp
@@ -167,6 +167,29 @@ void QQuickImageBase::resetSourceSize()
setSourceSize(QSize());
}
+QRectF QQuickImageBase::sourceClipRect() const
+{
+ Q_D(const QQuickImageBase);
+ return d->sourceClipRect;
+}
+
+void QQuickImageBase::setSourceClipRect(const QRectF &r)
+{
+ Q_D(QQuickImageBase);
+ if (d->sourceClipRect == r)
+ return;
+
+ d->sourceClipRect = r;
+ emit sourceClipRectChanged();
+ if (isComponentComplete())
+ load();
+}
+
+void QQuickImageBase::resetSourceClipRect()
+{
+ setSourceClipRect(QRect());
+}
+
bool QQuickImageBase::cache() const
{
Q_D(const QQuickImageBase);
@@ -295,6 +318,7 @@ void QQuickImageBase::loadPixmap(const QUrl &url, LoadPixmapOptions loadOptions)
d->pix.load(qmlEngine(this),
loadUrl,
+ d->sourceClipRect.toRect(),
(loadOptions & HandleDPR) ? d->sourcesize * d->devicePixelRatio : QSize(),
options,
(loadOptions & UseProviderOptions) ? d->providerOptions : QQuickImageProviderOptions(),
@@ -372,6 +396,10 @@ void QQuickImageBase::requestFinished()
d->frameCount = d->pix.frameCount();
emit frameCountChanged();
}
+ if (d->colorSpace != d->pix.colorSpace()) {
+ d->colorSpace = d->pix.colorSpace();
+ emit colorSpaceChanged();
+ }
update();
}
@@ -464,6 +492,22 @@ void QQuickImageBase::setAutoTransform(bool transform)
emitAutoTransformBaseChanged();
}
+QColorSpace QQuickImageBase::colorSpace() const
+{
+ Q_D(const QQuickImageBase);
+ return d->colorSpace;
+}
+
+void QQuickImageBase::setColorSpace(const QColorSpace &colorSpace)
+{
+ Q_D(QQuickImageBase);
+ if (d->colorSpace == colorSpace)
+ return;
+ d->colorSpace = colorSpace;
+ d->providerOptions.setTargetColorSpace(colorSpace);
+ emit colorSpaceChanged();
+}
+
QT_END_NAMESPACE
#include "moc_qquickimagebase_p.cpp"
diff --git a/src/quick/items/qquickimagebase_p.h b/src/quick/items/qquickimagebase_p.h
index 9308230bfa..9265792be1 100644
--- a/src/quick/items/qquickimagebase_p.h
+++ b/src/quick/items/qquickimagebase_p.h
@@ -53,6 +53,7 @@
#include "qquickimplicitsizeitem_p.h"
#include <private/qtquickglobal_p.h>
+#include <QtGui/qcolorspace.h>
QT_BEGIN_NAMESPACE
@@ -68,11 +69,12 @@ class Q_QUICK_PRIVATE_EXPORT QQuickImageBase : public QQuickImplicitSizeItem
Q_PROPERTY(bool cache READ cache WRITE setCache NOTIFY cacheChanged)
Q_PROPERTY(QSize sourceSize READ sourceSize WRITE setSourceSize RESET resetSourceSize NOTIFY sourceSizeChanged)
Q_PROPERTY(bool mirror READ mirror WRITE setMirror NOTIFY mirrorChanged)
- Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY currentFrameChanged REVISION 14)
- Q_PROPERTY(int frameCount READ frameCount NOTIFY frameCountChanged REVISION 14)
+ Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY currentFrameChanged REVISION(2, 14))
+ Q_PROPERTY(int frameCount READ frameCount NOTIFY frameCountChanged REVISION(2, 14))
+ Q_PROPERTY(QColorSpace colorSpace READ colorSpace WRITE setColorSpace NOTIFY colorSpaceChanged REVISION(2, 15))
QML_NAMED_ELEMENT(ImageBase);
- QML_ADDED_IN_MINOR_VERSION(14)
+ QML_ADDED_IN_VERSION(2, 14)
QML_UNCREATABLE("ImageBase is an abstract base class.")
public:
@@ -107,6 +109,10 @@ public:
QSize sourceSize() const;
void resetSourceSize();
+ QRectF sourceClipRect() const;
+ void setSourceClipRect(const QRectF &r);
+ void resetSourceClipRect();
+
virtual void setMirror(bool mirror);
bool mirror() const;
@@ -118,6 +124,9 @@ public:
virtual void setAutoTransform(bool transform);
bool autoTransform() const;
+ QColorSpace colorSpace() const;
+ virtual void setColorSpace(const QColorSpace &colorSpace);
+
static void resolve2xLocalFile(const QUrl &url, qreal targetDevicePixelRatio, QUrl *sourceUrl, qreal *sourceDevicePixelRatio);
// Use a virtual rather than a signal->signal to avoid the huge
@@ -132,8 +141,10 @@ Q_SIGNALS:
void asynchronousChanged();
void cacheChanged();
void mirrorChanged();
- Q_REVISION(14) void currentFrameChanged();
- Q_REVISION(14) void frameCountChanged();
+ Q_REVISION(2, 14) void currentFrameChanged();
+ Q_REVISION(2, 14) void frameCountChanged();
+ Q_REVISION(2, 15) void sourceClipRectChanged();
+ Q_REVISION(2, 15) void colorSpaceChanged();
protected:
void loadEmptyUrl();
diff --git a/src/quick/items/qquickimagebase_p_p.h b/src/quick/items/qquickimagebase_p_p.h
index 88e18ba32e..ebb7568caf 100644
--- a/src/quick/items/qquickimagebase_p_p.h
+++ b/src/quick/items/qquickimagebase_p_p.h
@@ -86,7 +86,9 @@ public:
QSize sourcesize;
QSize oldSourceSize;
qreal devicePixelRatio;
+ QRectF sourceClipRect;
QQuickImageProviderOptions providerOptions;
+ QColorSpace colorSpace;
int currentFrame;
int frameCount;
bool async : 1;
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 03cdeb5bef..4d9e3de859 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -2569,6 +2569,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
bool skip = false;
QQuickItem *startItem = item;
+ QQuickItem *originalStartItem = startItem;
// Protect from endless loop:
// If we start on an invisible item we will not find it again.
// If there is no other item which can become the focus item, we have a forever loop,
@@ -2644,7 +2645,12 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
}
}
from = last;
- if (current == startItem && from == firstFromItem) {
+ // if [from] item is equal to [firstFromItem], means we have traversed one path and
+ // jump back to parent of the chain, and then we have to check whether we have
+ // traversed all of the chain (by compare the [current] item with [startItem])
+ // Since the [startItem] might be promoted to its parent if it is invisible,
+ // we still have to check [current] item with original start item
+ if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
// wrapped around, avoid endless loops
if (item == contentItem) {
qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
@@ -3244,6 +3250,7 @@ QQuickItemPrivate::QQuickItemPrivate()
#else
, touchEnabled(false)
#endif
+ , hasCursorHandler(false)
, dirtyAttributes(0)
, nextDirtyItem(nullptr)
, prevDirtyItem(nullptr)
@@ -7472,14 +7479,14 @@ void QQuickItem::setAcceptTouchEvents(bool enabled)
d->touchEnabled = enabled;
}
-void QQuickItemPrivate::setHasCursorInChild(bool hasCursor)
+void QQuickItemPrivate::setHasCursorInChild(bool hc)
{
#if QT_CONFIG(cursor)
Q_Q(QQuickItem);
// if we're asked to turn it off (because of an unsetcursor call, or a node
// removal) then we should make sure it's really ok to turn it off.
- if (!hasCursor && subtreeCursorEnabled) {
+ if (!hc && subtreeCursorEnabled) {
if (hasCursor)
return; // nope! sorry, I have a cursor myself
for (QQuickItem *otherChild : qAsConst(childItems)) {
@@ -7489,14 +7496,14 @@ void QQuickItemPrivate::setHasCursorInChild(bool hasCursor)
}
}
- subtreeCursorEnabled = hasCursor;
+ subtreeCursorEnabled = hc;
QQuickItem *parent = q->parentItem();
if (parent) {
QQuickItemPrivate *parentPrivate = QQuickItemPrivate::get(parent);
- parentPrivate->setHasCursorInChild(hasCursor);
+ parentPrivate->setHasCursorInChild(hc);
}
#else
- Q_UNUSED(hasCursor);
+ Q_UNUSED(hc);
#endif
}
@@ -7573,17 +7580,20 @@ void QQuickItem::setCursor(const QCursor &cursor)
}
}
+ QPointF updateCursorPos;
if (!d->hasCursor) {
- d->setHasCursorInChild(true);
d->hasCursor = true;
if (d->window) {
QWindow *renderWindow = QQuickRenderControl::renderWindowFor(d->window);
QWindow *window = renderWindow ? renderWindow : d->window;
QPointF pos = window->mapFromGlobal(QGuiApplicationPrivate::lastCursorPosition.toPoint());
if (contains(mapFromScene(pos)))
- QQuickWindowPrivate::get(d->window)->updateCursor(pos);
+ updateCursorPos = pos;
}
}
+ d->setHasCursorInChild(d->hasCursor || d->hasCursorHandler);
+ if (!updateCursorPos.isNull())
+ QQuickWindowPrivate::get(d->window)->updateCursor(updateCursorPos);
}
/*!
@@ -7597,8 +7607,8 @@ void QQuickItem::unsetCursor()
Q_D(QQuickItem);
if (!d->hasCursor)
return;
- d->setHasCursorInChild(false);
d->hasCursor = false;
+ d->setHasCursorInChild(d->hasCursorHandler);
if (d->extra.isAllocated())
d->extra->cursor = QCursor();
@@ -7611,6 +7621,64 @@ void QQuickItem::unsetCursor()
}
}
+/*!
+ \internal
+ Returns the cursor that should actually be shown, allowing the given
+ \handler to override the Item cursor if it is active or hovered.
+
+ \sa cursor(), setCursor(), QtQuick::PointerHandler::cursor
+*/
+QCursor QQuickItemPrivate::effectiveCursor(const QQuickPointerHandler *handler) const
+{
+ Q_Q(const QQuickItem);
+ if (!handler)
+ return q->cursor();
+ bool hoverCursorSet = false;
+ QCursor hoverCursor;
+ bool activeCursorSet = false;
+ QCursor activeCursor;
+ if (const QQuickHoverHandler *hoverHandler = qobject_cast<const QQuickHoverHandler *>(handler)) {
+ hoverCursorSet = hoverHandler->isCursorShapeExplicitlySet();
+ hoverCursor = hoverHandler->cursorShape();
+ } else if (handler->active()) {
+ activeCursorSet = handler->isCursorShapeExplicitlySet();
+ activeCursor = handler->cursorShape();
+ }
+ if (activeCursorSet)
+ return activeCursor;
+ if (hoverCursorSet)
+ return hoverCursor;
+ return q->cursor();
+}
+
+/*!
+ \internal
+ Returns the Pointer Handler that is currently attempting to set the cursor shape,
+ or null if there is no such handler.
+
+ \sa QtQuick::PointerHandler::cursor
+*/
+QQuickPointerHandler *QQuickItemPrivate::effectiveCursorHandler() const
+{
+ if (!hasPointerHandlers())
+ return nullptr;
+ QQuickPointerHandler *retHoverHandler = nullptr;
+ for (QQuickPointerHandler *h : extra->pointerHandlers) {
+ if (!h->isCursorShapeExplicitlySet())
+ continue;
+ QQuickHoverHandler *hoverHandler = qmlobject_cast<QQuickHoverHandler *>(h);
+ // For now, we don't expect multiple hover handlers in one Item, so we choose the first one found;
+ // but a future use case could be to have different cursors for different tablet stylus devices.
+ // In that case, this function needs more information: which device did the event come from.
+ // TODO Qt 6: add QPointerDevice* as argument to this function? (it doesn't exist yet in Qt 5)
+ if (!retHoverHandler && hoverHandler)
+ retHoverHandler = hoverHandler;
+ if (!hoverHandler && h->active())
+ return h;
+ }
+ return retHoverHandler;
+}
+
#endif
/*!
@@ -8192,6 +8260,10 @@ bool QQuickItem::event(QEvent *ev)
ev->ignore();
break;
#endif // gestures
+ case QEvent::LanguageChange:
+ for (QQuickItem *item : d->childItems)
+ QCoreApplication::sendEvent(item, ev);
+ break;
default:
return QObject::event(ev);
}
diff --git a/src/quick/items/qquickitem.h b/src/quick/items/qquickitem.h
index 8c04ced11b..ca0c2f4764 100644
--- a/src/quick/items/qquickitem.h
+++ b/src/quick/items/qquickitem.h
@@ -59,6 +59,7 @@ class Q_QUICK_EXPORT QQuickTransform : public QObject
{
Q_OBJECT
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickTransform(QObject *parent = nullptr);
~QQuickTransform() override;
@@ -133,7 +134,7 @@ class Q_QUICK_EXPORT QQuickItem : public QObject, public QQmlParserStatus
Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL)
Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged FINAL)
- Q_PROPERTY(bool activeFocusOnTab READ activeFocusOnTab WRITE setActiveFocusOnTab NOTIFY activeFocusOnTabChanged FINAL REVISION 1)
+ Q_PROPERTY(bool activeFocusOnTab READ activeFocusOnTab WRITE setActiveFocusOnTab NOTIFY activeFocusOnTabChanged FINAL REVISION(2, 1))
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
@@ -145,13 +146,14 @@ class Q_QUICK_EXPORT QQuickItem : public QObject, public QQmlParserStatus
Q_PROPERTY(bool antialiasing READ antialiasing WRITE setAntialiasing NOTIFY antialiasingChanged RESET resetAntialiasing)
Q_PROPERTY(qreal implicitWidth READ implicitWidth WRITE setImplicitWidth NOTIFY implicitWidthChanged)
Q_PROPERTY(qreal implicitHeight READ implicitHeight WRITE setImplicitHeight NOTIFY implicitHeightChanged)
- Q_PROPERTY(QObject *containmentMask READ containmentMask WRITE setContainmentMask NOTIFY containmentMaskChanged REVISION 11)
+ Q_PROPERTY(QObject *containmentMask READ containmentMask WRITE setContainmentMask NOTIFY containmentMaskChanged REVISION(2, 11))
Q_PRIVATE_PROPERTY(QQuickItem::d_func(), QQuickItemLayer *layer READ layer DESIGNABLE false CONSTANT FINAL)
Q_CLASSINFO("DefaultProperty", "data")
Q_CLASSINFO("qt_QmlJSWrapperFactoryMethod", "_q_createJSWrapper(QV4::ExecutionEngine*)")
QML_NAMED_ELEMENT(Item)
+ QML_ADDED_IN_VERSION(2, 0)
public:
enum Flag {
@@ -320,7 +322,7 @@ public:
void setKeepTouchGrab(bool);
// implemented in qquickitemgrabresult.cpp
- Q_REVISION(4) Q_INVOKABLE bool grabToImage(const QJSValue &callback, const QSize &targetSize = QSize());
+ Q_REVISION(2, 4) Q_INVOKABLE bool grabToImage(const QJSValue &callback, const QSize &targetSize = QSize());
QSharedPointer<QQuickItemGrabResult> grabToImage(const QSize &targetSize = QSize());
Q_INVOKABLE virtual bool contains(const QPointF &point) const;
@@ -343,11 +345,11 @@ public:
Q_INVOKABLE void mapFromItem(QQmlV4Function*) const;
Q_INVOKABLE void mapToItem(QQmlV4Function*) const;
- Q_REVISION(7) Q_INVOKABLE void mapFromGlobal(QQmlV4Function*) const;
- Q_REVISION(7) Q_INVOKABLE void mapToGlobal(QQmlV4Function*) const;
+ Q_REVISION(2, 7) Q_INVOKABLE void mapFromGlobal(QQmlV4Function*) const;
+ Q_REVISION(2, 7) Q_INVOKABLE void mapToGlobal(QQmlV4Function*) const;
Q_INVOKABLE void forceActiveFocus();
Q_INVOKABLE void forceActiveFocus(Qt::FocusReason reason);
- Q_REVISION(1) Q_INVOKABLE QQuickItem *nextItemInFocusChain(bool forward = true);
+ Q_REVISION(2, 1) Q_INVOKABLE QQuickItem *nextItemInFocusChain(bool forward = true);
Q_INVOKABLE QQuickItem *childAt(qreal x, qreal y) const;
#if QT_CONFIG(im)
@@ -373,13 +375,13 @@ Q_SIGNALS:
void stateChanged(const QString &);
void focusChanged(bool);
void activeFocusChanged(bool);
- Q_REVISION(1) void activeFocusOnTabChanged(bool);
+ Q_REVISION(2, 1) void activeFocusOnTabChanged(bool);
void parentChanged(QQuickItem *);
void transformOriginChanged(TransformOrigin);
void smoothChanged(bool);
void antialiasingChanged(bool);
void clipChanged(bool);
- Q_REVISION(1) void windowChanged(QQuickWindow* window);
+ Q_REVISION(2, 1) void windowChanged(QQuickWindow* window);
void childrenChanged();
void opacityChanged();
@@ -396,7 +398,7 @@ Q_SIGNALS:
void zChanged();
void implicitWidthChanged();
void implicitHeightChanged();
- Q_REVISION(11) void containmentMaskChanged();
+ Q_REVISION(2, 11) void containmentMaskChanged();
protected:
bool event(QEvent *) override;
diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h
index 3c0517cb3b..a8958dfd59 100644
--- a/src/quick/items/qquickitem_p.h
+++ b/src/quick/items/qquickitem_p.h
@@ -153,6 +153,7 @@ class QQuickItemLayer : public QObject, public QQuickItemChangeListener
Q_PROPERTY(QQuickShaderEffectSource::TextureMirroring textureMirroring READ textureMirroring WRITE setTextureMirroring NOTIFY textureMirroringChanged)
Q_PROPERTY(int samples READ samples WRITE setSamples NOTIFY samplesChanged)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickItemLayer(QQuickItem *item);
@@ -471,6 +472,7 @@ public:
bool isTabFence:1;
bool replayingPressEvent:1;
bool touchEnabled:1;
+ bool hasCursorHandler:1;
enum DirtyType {
TransformOrigin = 0x00000001,
@@ -651,6 +653,10 @@ public:
void setHasCursorInChild(bool hasCursor);
void setHasHoverInChild(bool hasHover);
+#if QT_CONFIG(cursor)
+ QCursor effectiveCursor(const QQuickPointerHandler *handler) const;
+ QQuickPointerHandler *effectiveCursorHandler() const;
+#endif
virtual void updatePolish() { }
};
@@ -717,6 +723,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickKeyNavigationAttached : public QObject, publi
Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged)
QML_NAMED_ELEMENT(KeyNavigation)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("KeyNavigation is only available via attached properties.")
QML_ATTACHED(QQuickKeyNavigationAttached)
@@ -766,6 +773,7 @@ class QQuickLayoutMirroringAttached : public QObject
Q_PROPERTY(bool childrenInherit READ childrenInherit WRITE setChildrenInherit NOTIFY childrenInheritChanged)
QML_NAMED_ELEMENT(LayoutMirroring)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("LayoutMirroring is only available via attached properties.")
QML_ATTACHED(QQuickLayoutMirroringAttached)
@@ -795,7 +803,7 @@ class QQuickEnterKeyAttached : public QObject
QML_NAMED_ELEMENT(EnterKey)
QML_UNCREATABLE("EnterKey is only available via attached properties")
- QML_ADDED_IN_MINOR_VERSION(6)
+ QML_ADDED_IN_VERSION(2, 6)
QML_ATTACHED(QQuickEnterKeyAttached)
public:
@@ -844,6 +852,7 @@ class QQuickKeysAttached : public QObject, public QQuickItemKeyFilter
Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged)
QML_NAMED_ELEMENT(Keys)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("Keys is only available via attached properties")
QML_ATTACHED(QQuickKeysAttached)
diff --git a/src/quick/items/qquickitemanimation_p.h b/src/quick/items/qquickitemanimation_p.h
index 28c18c874d..ee4df1b6ca 100644
--- a/src/quick/items/qquickitemanimation_p.h
+++ b/src/quick/items/qquickitemanimation_p.h
@@ -67,6 +67,7 @@ class Q_AUTOTEST_EXPORT QQuickParentAnimation : public QQuickAnimationGroup
Q_PROPERTY(QQuickItem *newParent READ newParent WRITE setNewParent NOTIFY newParentChanged)
Q_PROPERTY(QQuickItem *via READ via WRITE setVia NOTIFY viaChanged)
QML_NAMED_ELEMENT(ParentAnimation)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickParentAnimation(QObject *parent=nullptr);
@@ -102,6 +103,7 @@ class Q_AUTOTEST_EXPORT QQuickAnchorAnimation : public QQuickAbstractAnimation
Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
QML_NAMED_ELEMENT(AnchorAnimation)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickAnchorAnimation(QObject *parent=nullptr);
@@ -146,6 +148,7 @@ class Q_AUTOTEST_EXPORT QQuickPathAnimation : public QQuickAbstractAnimation
Q_PROPERTY(int orientationExitDuration READ orientationExitDuration WRITE setOrientationExitDuration NOTIFY orientationExitDurationChanged)
Q_PROPERTY(qreal endRotation READ endRotation WRITE setEndRotation NOTIFY endRotationChanged)
QML_NAMED_ELEMENT(PathAnimation)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickPathAnimation(QObject *parent=nullptr);
diff --git a/src/quick/items/qquickitemgrabresult.cpp b/src/quick/items/qquickitemgrabresult.cpp
index f298803c7f..00e84536e9 100644
--- a/src/quick/items/qquickitemgrabresult.cpp
+++ b/src/quick/items/qquickitemgrabresult.cpp
@@ -195,6 +195,7 @@ bool QQuickItemGrabResult::saveToFile(const QString &fileName) const
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#if QT_DEPRECATED_SINCE(5, 15)
/*!
* \overload
* \internal
@@ -203,6 +204,7 @@ bool QQuickItemGrabResult::saveToFile(const QString &fileName)
{
return qAsConst(*this).saveToFile(fileName);
}
+#endif
#endif // < Qt 6
QUrl QQuickItemGrabResult::url() const
diff --git a/src/quick/items/qquickitemgrabresult.h b/src/quick/items/qquickitemgrabresult.h
index c92a8c52f4..96d18b907b 100644
--- a/src/quick/items/qquickitemgrabresult.h
+++ b/src/quick/items/qquickitemgrabresult.h
@@ -62,13 +62,17 @@ class Q_QUICK_EXPORT QQuickItemGrabResult : public QObject
Q_PROPERTY(QImage image READ image CONSTANT)
Q_PROPERTY(QUrl url READ url CONSTANT)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QImage image() const;
QUrl url() const;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
- Q_INVOKABLE bool saveToFile(const QString &fileName); // ### Qt 6: remove
+#if QT_DEPRECATED_SINCE(5, 15)
+ QT_DEPRECATED_X("This overload is deprecated. Use the const member function instead")
+ Q_INVOKABLE bool saveToFile(const QString &fileName);
+#endif
#endif
Q_INVOKABLE bool saveToFile(const QString &fileName) const;
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp
index bd6b9d741e..125518e51b 100644
--- a/src/quick/items/qquickitemsmodule.cpp
+++ b/src/quick/items/qquickitemsmodule.cpp
@@ -183,13 +183,6 @@ static void qt_quickitems_defineModule()
qRegisterMetaType<QQuickAnchorLine>("QQuickAnchorLine");
qRegisterMetaType<QPointingDeviceUniqueId>("QPointingDeviceUniqueId");
qRegisterMetaType<QQuickHandlerPoint>();
-
-#if !QT_CONFIG(quick_animatedimage)
- qmlRegisterTypeNotAvailable(
- "QtQuick", 2, 15, "AnimatedImage",
- QCoreApplication::translate("QQuickAnimatedImage",
- "Qt was built without support for QMovie"));
-#endif
}
static void initResources()
diff --git a/src/quick/items/qquickitemsmodule_p.h b/src/quick/items/qquickitemsmodule_p.h
index 6ceb0d56e6..f7081f6ece 100644
--- a/src/quick/items/qquickitemsmodule_p.h
+++ b/src/quick/items/qquickitemsmodule_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
#include <QtGui/qevent.h>
#include <qqml.h>
@@ -67,10 +68,21 @@ struct QPointingDeviceUniqueIdForeign
Q_GADGET
QML_FOREIGN(QPointingDeviceUniqueId)
QML_NAMED_ELEMENT(PointingDeviceUniqueId)
- QML_ADDED_IN_MINOR_VERSION(9)
+ QML_ADDED_IN_VERSION(2, 9)
QML_UNCREATABLE("PointingDeviceUniqueId is only available via read-only properties.")
};
+#if !QT_CONFIG(quick_animatedimage)
+struct QQuickAnimatedImageNotAvailable
+{
+ Q_GADGET
+ QML_UNAVAILABLE
+ QML_NAMED_ELEMENT(AnimatedImage)
+ QML_ADDED_IN_VERSION(2, 0)
+ QML_UNCREATABLE("Qt was built without support for QMovie.")
+};
+#endif
+
QT_END_NAMESPACE
#endif // QQUICKITEMSMODULE_P_H
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index 0d30606ef7..7fb392233e 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -197,8 +197,10 @@ void QQuickItemView::setModel(const QVariant &m)
disconnect(d->model, SIGNAL(initItem(int,QObject*)), this, SLOT(initItem(int,QObject*)));
disconnect(d->model, SIGNAL(createdItem(int,QObject*)), this, SLOT(createdItem(int,QObject*)));
disconnect(d->model, SIGNAL(destroyingItem(QObject*)), this, SLOT(destroyingItem(QObject*)));
- disconnect(d->model, SIGNAL(itemPooled(int, QObject *)), this, SLOT(onItemPooled(int, QObject *)));
- disconnect(d->model, SIGNAL(itemReused(int, QObject *)), this, SLOT(onItemReused(int, QObject *)));
+ if (QQmlDelegateModel *delegateModel = qobject_cast<QQmlDelegateModel*>(d->model)) {
+ disconnect(delegateModel, SIGNAL(itemPooled(int, QObject *)), this, SLOT(onItemPooled(int, QObject *)));
+ disconnect(delegateModel, SIGNAL(itemReused(int, QObject *)), this, SLOT(onItemReused(int, QObject *)));
+ }
}
QQmlInstanceModel *oldModel = d->model;
@@ -234,8 +236,10 @@ void QQuickItemView::setModel(const QVariant &m)
connect(d->model, SIGNAL(createdItem(int,QObject*)), this, SLOT(createdItem(int,QObject*)));
connect(d->model, SIGNAL(initItem(int,QObject*)), this, SLOT(initItem(int,QObject*)));
connect(d->model, SIGNAL(destroyingItem(QObject*)), this, SLOT(destroyingItem(QObject*)));
- connect(d->model, SIGNAL(itemPooled(int, QObject *)), this, SLOT(onItemPooled(int, QObject *)));
- connect(d->model, SIGNAL(itemReused(int, QObject *)), this, SLOT(onItemReused(int, QObject *)));
+ if (QQmlDelegateModel *delegateModel = qobject_cast<QQmlDelegateModel*>(d->model)) {
+ connect(delegateModel, SIGNAL(itemPooled(int, QObject *)), this, SLOT(onItemPooled(int, QObject *)));
+ connect(delegateModel, SIGNAL(itemReused(int, QObject *)), this, SLOT(onItemReused(int, QObject *)));
+ }
if (isComponentComplete()) {
d->updateSectionCriteria();
d->refill();
diff --git a/src/quick/items/qquickitemview_p.h b/src/quick/items/qquickitemview_p.h
index 521580d292..d8d5678ad0 100644
--- a/src/quick/items/qquickitemview_p.h
+++ b/src/quick/items/qquickitemview_p.h
@@ -79,10 +79,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickItemView : public QQuickFlickable
Q_PROPERTY(QQuickItem *currentItem READ currentItem NOTIFY currentItemChanged)
Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled NOTIFY keyNavigationWrapsChanged)
- Q_PROPERTY(bool keyNavigationEnabled READ isKeyNavigationEnabled WRITE setKeyNavigationEnabled NOTIFY keyNavigationEnabledChanged REVISION 7)
+ Q_PROPERTY(bool keyNavigationEnabled READ isKeyNavigationEnabled WRITE setKeyNavigationEnabled NOTIFY keyNavigationEnabledChanged REVISION(2, 7))
Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged)
- Q_PROPERTY(int displayMarginBeginning READ displayMarginBeginning WRITE setDisplayMarginBeginning NOTIFY displayMarginBeginningChanged REVISION 3)
- Q_PROPERTY(int displayMarginEnd READ displayMarginEnd WRITE setDisplayMarginEnd NOTIFY displayMarginEndChanged REVISION 3)
+ Q_PROPERTY(int displayMarginBeginning READ displayMarginBeginning WRITE setDisplayMarginBeginning NOTIFY displayMarginBeginningChanged REVISION(2, 3))
+ Q_PROPERTY(int displayMarginEnd READ displayMarginEnd WRITE setDisplayMarginEnd NOTIFY displayMarginEndChanged REVISION(2, 3))
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged)
Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged)
@@ -110,11 +110,11 @@ class Q_QUICK_PRIVATE_EXPORT QQuickItemView : public QQuickFlickable
Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged RESET resetPreferredHighlightEnd)
Q_PROPERTY(int highlightMoveDuration READ highlightMoveDuration WRITE setHighlightMoveDuration NOTIFY highlightMoveDurationChanged)
- Q_PROPERTY(bool reuseItems READ reuseItems WRITE setReuseItems NOTIFY reuseItemsChanged REVISION 15)
+ Q_PROPERTY(bool reuseItems READ reuseItems WRITE setReuseItems NOTIFY reuseItemsChanged REVISION(2, 15))
QML_NAMED_ELEMENT(ItemView)
QML_UNCREATABLE("ItemView is an abstract base class.")
- QML_ADDED_IN_MINOR_VERSION(1)
+ QML_ADDED_IN_VERSION(2, 1)
public:
// this holds all layout enum values so they can be referred to by other enums
@@ -237,10 +237,10 @@ public:
Q_INVOKABLE void positionViewAtIndex(int index, int mode);
Q_INVOKABLE int indexAt(qreal x, qreal y) const;
Q_INVOKABLE QQuickItem *itemAt(qreal x, qreal y) const;
- Q_REVISION(13) Q_INVOKABLE QQuickItem *itemAtIndex(int index) const;
+ Q_REVISION(2, 13) Q_INVOKABLE QQuickItem *itemAtIndex(int index) const;
Q_INVOKABLE void positionViewAtBeginning();
Q_INVOKABLE void positionViewAtEnd();
- Q_REVISION(1) Q_INVOKABLE void forceLayout();
+ Q_REVISION(2, 1) Q_INVOKABLE void forceLayout();
void setContentX(qreal pos) override;
void setContentY(qreal pos) override;
@@ -255,7 +255,7 @@ Q_SIGNALS:
void currentItemChanged();
void keyNavigationWrapsChanged();
- Q_REVISION(7) void keyNavigationEnabledChanged();
+ Q_REVISION(2, 7) void keyNavigationEnabledChanged();
void cacheBufferChanged();
void displayMarginBeginningChanged();
void displayMarginEndChanged();
@@ -286,7 +286,7 @@ Q_SIGNALS:
void preferredHighlightEndChanged();
void highlightMoveDurationChanged();
- Q_REVISION(15) void reuseItemsChanged();
+ Q_REVISION(2, 15) void reuseItemsChanged();
protected:
void updatePolish() override;
@@ -303,8 +303,8 @@ protected Q_SLOTS:
virtual void initItem(int index, QObject *item);
void modelUpdated(const QQmlChangeSet &changeSet, bool reset);
void destroyingItem(QObject *item);
- void onItemPooled(int modelIndex, QObject *object);
- void onItemReused(int modelIndex, QObject *object);
+ Q_REVISION(2, 15) void onItemPooled(int modelIndex, QObject *object);
+ Q_REVISION(2, 15) void onItemReused(int modelIndex, QObject *object);
void animStopped();
void trackedPositionChanged();
diff --git a/src/quick/items/qquickitemviewtransition_p.h b/src/quick/items/qquickitemviewtransition_p.h
index 5f4e74171e..43858db688 100644
--- a/src/quick/items/qquickitemviewtransition_p.h
+++ b/src/quick/items/qquickitemviewtransition_p.h
@@ -195,6 +195,7 @@ class QQuickViewTransitionAttached : public QObject
Q_PROPERTY(QQmlListProperty<QObject> targetItems READ targetItems NOTIFY targetItemsChanged)
QML_NAMED_ELEMENT(ViewTransition)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("ViewTransition is only available via attached properties.")
QML_ATTACHED(QQuickViewTransitionAttached)
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index badd2efe29..b91e705ad0 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -141,6 +141,8 @@ public:
QQuickItemViewAttached *getAttachedObject(const QObject *object) const override;
+ void fixupHeader();
+ void fixupHeaderCompleted();
QQuickListView::Orientation orient;
qreal visiblePos;
qreal averageSize;
@@ -169,6 +171,12 @@ public:
QString nextSection;
qreal overshootDist;
+
+ qreal desiredViewportPosition;
+ qreal fixupHeaderPosition;
+ bool headerNeedsSeparateFixup : 1;
+ bool desiredHeaderVisible : 1;
+
bool correctFlick : 1;
bool inFlickCorrection : 1;
@@ -182,7 +190,9 @@ public:
, highlightPosAnimator(nullptr), highlightWidthAnimator(nullptr), highlightHeightAnimator(nullptr)
, highlightMoveVelocity(400), highlightResizeVelocity(400), highlightResizeDuration(-1)
, sectionCriteria(nullptr), currentSectionItem(nullptr), nextSectionItem(nullptr)
- , overshootDist(0.0), correctFlick(false), inFlickCorrection(false)
+ , overshootDist(0.0), desiredViewportPosition(0.0), fixupHeaderPosition(0.0)
+ , headerNeedsSeparateFixup(false), desiredHeaderVisible(false)
+ , correctFlick(false), inFlickCorrection(false)
{
highlightMoveDuration = -1; //override default value set in base class
}
@@ -1402,6 +1412,31 @@ void QQuickListViewPrivate::updateFooter()
emit q->footerItemChanged();
}
+void QQuickListViewPrivate::fixupHeaderCompleted()
+{
+ headerNeedsSeparateFixup = false;
+ QObjectPrivate::disconnect(&timeline, &QQuickTimeLine::updated, this, &QQuickListViewPrivate::fixupHeader);
+}
+
+void QQuickListViewPrivate::fixupHeader()
+{
+ FxListItemSG *listItem = static_cast<FxListItemSG*>(header);
+ const bool fixingUp = (orient == QQuickListView::Vertical ? vData : hData).fixingUp;
+ if (fixingUp && headerPositioning == QQuickListView::PullBackHeader && visibleItems.count()) {
+ int fixupDura = timeline.duration();
+ if (fixupDura < 0)
+ fixupDura = fixupDuration/2;
+ const int t = timeline.time();
+
+ const qreal progress = qreal(t)/fixupDura;
+ const qreal ultimateHeaderPosition = desiredHeaderVisible ? desiredViewportPosition : desiredViewportPosition - headerSize();
+ const qreal headerPosition = fixupHeaderPosition * (1 - progress) + ultimateHeaderPosition * progress;
+ const qreal viewPos = isContentFlowReversed() ? -position() - size() : position();
+ const qreal clampedPos = qBound(originPosition() - headerSize(), headerPosition, lastPosition() - size());
+ listItem->setPosition(qBound(viewPos - headerSize(), clampedPos, viewPos));
+ }
+}
+
void QQuickListViewPrivate::updateHeader()
{
Q_Q(QQuickListView);
@@ -1419,9 +1454,14 @@ void QQuickListViewPrivate::updateHeader()
if (headerPositioning == QQuickListView::OverlayHeader) {
listItem->setPosition(isContentFlowReversed() ? -position() - size() : position());
} else if (visibleItems.count()) {
+ const bool fixingUp = (orient == QQuickListView::Vertical ? vData : hData).fixingUp;
if (headerPositioning == QQuickListView::PullBackHeader) {
- qreal viewPos = isContentFlowReversed() ? -position() - size() : position();
- qreal clampedPos = qBound(originPosition() - headerSize(), listItem->position(), lastPosition() - headerSize() - size());
+ qreal headerPosition = listItem->position();
+ const qreal viewPos = isContentFlowReversed() ? -position() - size() : position();
+ // Make sure the header is not shown if we absolutely do not have any plans to show it
+ if (fixingUp && !headerNeedsSeparateFixup)
+ headerPosition = viewPos - headerSize();
+ qreal clampedPos = qBound(originPosition() - headerSize(), headerPosition, lastPosition() - size());
listItem->setPosition(qBound(viewPos - headerSize(), clampedPos, viewPos));
} else {
qreal startPos = originPosition();
@@ -1539,13 +1579,46 @@ void QQuickListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExte
bias = -bias;
tempPosition -= bias;
}
- FxViewItem *topItem = snapItemAt(tempPosition+highlightRangeStart);
+
+ qreal snapOffset = 0;
+ qreal overlayHeaderOffset = 0;
+ bool isHeaderWithinBounds = false;
+ if (header) {
+ qreal visiblePartOfHeader = header->position() + header->size() - tempPosition;
+ isHeaderWithinBounds = visiblePartOfHeader > 0;
+ switch (headerPositioning) {
+ case QQuickListView::OverlayHeader:
+ snapOffset = header->size();
+ overlayHeaderOffset = header->size();
+ break;
+ case QQuickListView::InlineHeader:
+ if (isHeaderWithinBounds && tempPosition < originPosition())
+ // For the inline header, we want to snap to the first item
+ // if we're more than halfway down the inline header.
+ // So if we look for an item halfway down of the header
+ snapOffset = header->size() / 2;
+ break;
+ case QQuickListView::PullBackHeader:
+ desiredHeaderVisible = visiblePartOfHeader > header->size()/2;
+ if (qFuzzyCompare(header->position(), tempPosition)) {
+ // header was pulled down; make sure it remains visible and snap items to bottom of header
+ snapOffset = header->size();
+ } else if (desiredHeaderVisible) {
+ // More than 50% of the header is shown. Show it fully.
+ // Scroll the view so the next item snaps to the header.
+ snapOffset = header->size();
+ overlayHeaderOffset = header->size();
+ }
+ break;
+ }
+ }
+ FxViewItem *topItem = snapItemAt(tempPosition + snapOffset + highlightRangeStart);
if (strictHighlightRange && currentItem && (!topItem || (topItem->index != currentIndex && fixupMode == Immediate))) {
// StrictlyEnforceRange always keeps an item in range
updateHighlight();
topItem = currentItem;
}
- FxViewItem *bottomItem = snapItemAt(tempPosition+highlightRangeEnd);
+ FxViewItem *bottomItem = snapItemAt(tempPosition + snapOffset + highlightRangeEnd);
if (strictHighlightRange && currentItem && (!bottomItem || (bottomItem->index != currentIndex && fixupMode == Immediate))) {
// StrictlyEnforceRange always keeps an item in range
updateHighlight();
@@ -1553,27 +1626,92 @@ void QQuickListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExte
}
qreal pos;
bool isInBounds = -position() > maxExtent && -position() <= minExtent;
- if (topItem && (isInBounds || strictHighlightRange)) {
- if (topItem->index == 0 && header && tempPosition+highlightRangeStart < header->position()+header->size()/2 && !strictHighlightRange) {
- pos = isContentFlowReversed() ? - header->position() + highlightRangeStart - size() : header->position() - highlightRangeStart;
+
+ if (header && !topItem && isInBounds) {
+ // We are trying to pull back further than needed
+ switch (headerPositioning) {
+ case QQuickListView::OverlayHeader:
+ pos = startPosition() - overlayHeaderOffset;
+ break;
+ case QQuickListView::InlineHeader:
+ pos = isContentFlowReversed() ? header->size() - size() : header->position();
+ break;
+ case QQuickListView::PullBackHeader:
+ pos = isContentFlowReversed() ? -size() : startPosition();
+ break;
+ }
+ } else if (topItem && (isInBounds || strictHighlightRange)) {
+ if (topItem->index == 0 && header && !hasStickyHeader() && tempPosition+highlightRangeStart < header->position()+header->size()/2 && !strictHighlightRange) {
+ pos = isContentFlowReversed() ? -header->position() + highlightRangeStart - size() : (header->position() - highlightRangeStart + header->size());
} else {
- if (isContentFlowReversed())
- pos = qMax(qMin(-static_cast<FxListItemSG*>(topItem)->itemPosition() + highlightRangeStart - size(), -maxExtent), -minExtent);
- else
- pos = qMax(qMin(static_cast<FxListItemSG*>(topItem)->itemPosition() - highlightRangeStart, -maxExtent), -minExtent);
+ if (header && headerPositioning == QQuickListView::PullBackHeader) {
+ // We pulled down the header. If it isn't pulled all way down, we need to snap
+ // the header.
+ if (qFuzzyCompare(tempPosition, header->position())) {
+ // It is pulled all way down. Scroll-snap the content, but not the header.
+ if (isContentFlowReversed())
+ pos = -static_cast<FxListItemSG*>(topItem)->itemPosition() + highlightRangeStart - size() + snapOffset;
+ else
+ pos = static_cast<FxListItemSG*>(topItem)->itemPosition() - highlightRangeStart - snapOffset;
+ } else {
+ // Header is not pulled all way down, make it completely visible or hide it.
+ // Depends on how much of the header is visible.
+ if (desiredHeaderVisible) {
+ // More than half of the header is visible - show it.
+ // Scroll so that the topItem is aligned to a fully visible header
+ if (isContentFlowReversed())
+ pos = -static_cast<FxListItemSG*>(topItem)->itemPosition() + highlightRangeStart - size() + headerSize();
+ else
+ pos = static_cast<FxListItemSG*>(topItem)->itemPosition() - highlightRangeStart - headerSize();
+ } else {
+ // Less than half is visible - hide the header. Scroll so
+ // that the topItem is aligned to the top of the view
+ if (isContentFlowReversed())
+ pos = -static_cast<FxListItemSG*>(topItem)->itemPosition() + highlightRangeStart - size();
+ else
+ pos = static_cast<FxListItemSG*>(topItem)->itemPosition() - highlightRangeStart;
+ }
+ }
+
+ headerNeedsSeparateFixup = isHeaderWithinBounds || desiredHeaderVisible;
+ if (headerNeedsSeparateFixup) {
+ // We need to animate the header independently if it starts visible or should end as visible,
+ // since the header should not necessarily follow the content.
+ // Store the desired viewport position.
+ // Also store the header position so we know where to animate the header from (fixupHeaderPosition).
+ // We deduce the desired header position from the desiredViewportPosition variable.
+ pos = qBound(-minExtent, pos, -maxExtent);
+ desiredViewportPosition = isContentFlowReversed() ? -pos - size() : pos;
+
+ FxListItemSG *headerItem = static_cast<FxListItemSG*>(header);
+ fixupHeaderPosition = headerItem->position();
+
+ // follow the same fixup timeline
+ QObjectPrivate::connect(&timeline, &QQuickTimeLine::updated, this, &QQuickListViewPrivate::fixupHeader);
+ QObjectPrivate::connect(&timeline, &QQuickTimeLine::completed, this, &QQuickListViewPrivate::fixupHeaderCompleted);
+ }
+ } else if (isContentFlowReversed()) {
+ pos = -static_cast<FxListItemSG*>(topItem)->itemPosition() + highlightRangeStart - size() + overlayHeaderOffset;
+ } else {
+ pos = static_cast<FxListItemSG*>(topItem)->itemPosition() - highlightRangeStart - overlayHeaderOffset;
+ }
}
} else if (bottomItem && isInBounds) {
if (isContentFlowReversed())
- pos = qMax(qMin(-static_cast<FxListItemSG*>(bottomItem)->itemPosition() + highlightRangeEnd - size(), -maxExtent), -minExtent);
+ pos = -static_cast<FxListItemSG*>(bottomItem)->itemPosition() + highlightRangeEnd - size() + overlayHeaderOffset;
else
- pos = qMax(qMin(static_cast<FxListItemSG*>(bottomItem)->itemPosition() - highlightRangeEnd, -maxExtent), -minExtent);
+ pos = static_cast<FxListItemSG*>(bottomItem)->itemPosition() - highlightRangeEnd - overlayHeaderOffset;
} else {
QQuickItemViewPrivate::fixup(data, minExtent, maxExtent);
return;
}
+ pos = qBound(-minExtent, pos, -maxExtent);
qreal dist = qAbs(data.move + pos);
- if (dist > 0) {
+ if (dist >= 0) {
+ // Even if dist == 0 we still start the timeline, because we use the same timeline for
+ // moving the header. And we might need to move the header while the content does not
+ // need moving
timeline.reset(data.move);
if (fixupMode != Immediate) {
timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
diff --git a/src/quick/items/qquicklistview_p.h b/src/quick/items/qquicklistview_p.h
index be21b93155..5e3dbac3a7 100644
--- a/src/quick/items/qquicklistview_p.h
+++ b/src/quick/items/qquicklistview_p.h
@@ -71,6 +71,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickViewSection : public QObject
Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_PROPERTY(int labelPositioning READ labelPositioning WRITE setLabelPositioning NOTIFY labelPositioningChanged)
QML_NAMED_ELEMENT(ViewSection)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickViewSection(QQuickListView *parent=nullptr);
@@ -127,11 +128,12 @@ class Q_QUICK_PRIVATE_EXPORT QQuickListView : public QQuickItemView
Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged)
- Q_PROPERTY(HeaderPositioning headerPositioning READ headerPositioning WRITE setHeaderPositioning NOTIFY headerPositioningChanged REVISION 4)
- Q_PROPERTY(FooterPositioning footerPositioning READ footerPositioning WRITE setFooterPositioning NOTIFY footerPositioningChanged REVISION 4)
+ Q_PROPERTY(HeaderPositioning headerPositioning READ headerPositioning WRITE setHeaderPositioning NOTIFY headerPositioningChanged REVISION(2, 4))
+ Q_PROPERTY(FooterPositioning footerPositioning READ footerPositioning WRITE setFooterPositioning NOTIFY footerPositioningChanged REVISION(2, 4))
Q_CLASSINFO("DefaultProperty", "data")
QML_NAMED_ELEMENT(ListView)
+ QML_ADDED_IN_VERSION(2, 0)
QML_ATTACHED(QQuickListViewAttached)
public:
@@ -193,8 +195,8 @@ Q_SIGNALS:
void highlightResizeVelocityChanged();
void highlightResizeDurationChanged();
void snapModeChanged();
- Q_REVISION(4) void headerPositioningChanged();
- Q_REVISION(4) void footerPositioningChanged();
+ Q_REVISION(2, 4) void headerPositioningChanged();
+ Q_REVISION(2, 4) void footerPositioningChanged();
protected:
void viewportMoved(Qt::Orientations orient) override;
diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp
index 8722a45373..1fb71272b1 100644
--- a/src/quick/items/qquickloader.cpp
+++ b/src/quick/items/qquickloader.cpp
@@ -56,7 +56,7 @@ static const QQuickItemPrivate::ChangeTypes watchedChanges
QQuickLoaderPrivate::QQuickLoaderPrivate()
: item(nullptr), object(nullptr), itemContext(nullptr), incubator(nullptr), updatingSize(false),
- active(true), loadingFromSource(false), asynchronous(false)
+ active(true), loadingFromSource(false), asynchronous(false), status(computeStatus())
{
}
@@ -379,7 +379,7 @@ void QQuickLoader::setActive(bool newVal)
d->object = nullptr;
emit itemChanged();
}
- emit statusChanged();
+ d->updateStatus();
}
emit activeChanged();
}
@@ -432,7 +432,7 @@ void QQuickLoader::loadFromSource()
Q_D(QQuickLoader);
if (d->source.isEmpty()) {
emit sourceChanged();
- emit statusChanged();
+ d->updateStatus();
emit progressChanged();
emit itemChanged();
return;
@@ -503,7 +503,7 @@ void QQuickLoader::loadFromSourceComponent()
Q_D(QQuickLoader);
if (!d->component) {
emit sourceComponentChanged();
- emit statusChanged();
+ d->updateStatus();
emit progressChanged();
emit itemChanged();
return;
@@ -619,7 +619,7 @@ void QQuickLoaderPrivate::load()
q, SLOT(_q_sourceLoaded()));
QObject::connect(component, SIGNAL(progressChanged(qreal)),
q, SIGNAL(progressChanged()));
- emit q->statusChanged();
+ updateStatus();
emit q->progressChanged();
if (loadingFromSource)
emit q->sourceChanged();
@@ -707,7 +707,7 @@ void QQuickLoaderPrivate::incubatorStateChanged(QQmlIncubator::Status status)
emit q->sourceChanged();
else
emit q->sourceComponentChanged();
- emit q->statusChanged();
+ updateStatus();
emit q->progressChanged();
if (status == QQmlIncubator::Ready)
emit q->loaded();
@@ -724,7 +724,7 @@ void QQuickLoaderPrivate::_q_sourceLoaded()
emit q->sourceChanged();
else
emit q->sourceComponentChanged();
- emit q->statusChanged();
+ updateStatus();
emit q->progressChanged();
emit q->itemChanged(); //Like clearing source, emit itemChanged even if previous item was also null
disposeInitialPropertyValues(); // cleanup
@@ -742,7 +742,7 @@ void QQuickLoaderPrivate::_q_sourceLoaded()
component->create(*incubator, itemContext);
if (incubator && incubator->status() == QQmlIncubator::Loading)
- emit q->statusChanged();
+ updateStatus();
}
/*!
@@ -789,37 +789,7 @@ QQuickLoader::Status QQuickLoader::status() const
{
Q_D(const QQuickLoader);
- if (!d->active)
- return Null;
-
- if (d->component) {
- switch (d->component->status()) {
- case QQmlComponent::Loading:
- return Loading;
- case QQmlComponent::Error:
- return Error;
- case QQmlComponent::Null:
- return Null;
- default:
- break;
- }
- }
-
- if (d->incubator) {
- switch (d->incubator->status()) {
- case QQmlIncubator::Loading:
- return Loading;
- case QQmlIncubator::Error:
- return Error;
- default:
- break;
- }
- }
-
- if (d->object)
- return Ready;
-
- return d->source.isEmpty() ? Null : Error;
+ return static_cast<Status>(d->status);
}
void QQuickLoader::componentComplete()
@@ -1020,6 +990,51 @@ QV4::ReturnedValue QQuickLoaderPrivate::extractInitialPropertyValues(QQmlV4Funct
return valuemap->asReturnedValue();
}
+QQuickLoader::Status QQuickLoaderPrivate::computeStatus() const
+{
+ if (!active)
+ return QQuickLoader::Status::Null;
+
+ if (component) {
+ switch (component->status()) {
+ case QQmlComponent::Loading:
+ return QQuickLoader::Status::Loading;
+ case QQmlComponent::Error:
+ return QQuickLoader::Status::Error;
+ case QQmlComponent::Null:
+ return QQuickLoader::Status::Null;
+ default:
+ break;
+ }
+ }
+
+ if (incubator) {
+ switch (incubator->status()) {
+ case QQmlIncubator::Loading:
+ return QQuickLoader::Status::Loading;
+ case QQmlIncubator::Error:
+ return QQuickLoader::Status::Error;
+ default:
+ break;
+ }
+ }
+
+ if (object)
+ return QQuickLoader::Status::Ready;
+
+ return source.isEmpty() ? QQuickLoader::Status::Null : QQuickLoader::Status::Error;
+}
+
+void QQuickLoaderPrivate::updateStatus()
+{
+ Q_Q(QQuickLoader);
+ auto newStatus = computeStatus();
+ if (status != newStatus) {
+ status = newStatus;
+ emit q->statusChanged();
+ }
+}
+
#include <moc_qquickloader_p.cpp>
QT_END_NAMESPACE
diff --git a/src/quick/items/qquickloader_p.h b/src/quick/items/qquickloader_p.h
index 2d560fb856..8f061d3139 100644
--- a/src/quick/items/qquickloader_p.h
+++ b/src/quick/items/qquickloader_p.h
@@ -68,6 +68,7 @@ class Q_AUTOTEST_EXPORT QQuickLoader : public QQuickImplicitSizeItem
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
Q_PROPERTY(bool asynchronous READ asynchronous WRITE setAsynchronous NOTIFY asynchronousChanged)
QML_NAMED_ELEMENT(Loader)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickLoader(QQuickItem *parent = nullptr);
diff --git a/src/quick/items/qquickloader_p_p.h b/src/quick/items/qquickloader_p_p.h
index 349b5c6c06..39d50280c5 100644
--- a/src/quick/items/qquickloader_p_p.h
+++ b/src/quick/items/qquickloader_p_p.h
@@ -96,6 +96,8 @@ public:
void disposeInitialPropertyValues();
static QUrl resolveSourceUrl(QQmlV4Function *args);
QV4::ReturnedValue extractInitialPropertyValues(QQmlV4Function *args, QObject *loader, bool *error);
+ QQuickLoader::Status computeStatus() const;
+ void updateStatus();
qreal getImplicitWidth() const override;
qreal getImplicitHeight() const override;
@@ -112,6 +114,11 @@ public:
bool active : 1;
bool loadingFromSource : 1;
bool asynchronous : 1;
+ // We need to use char instead of QQuickLoader::Status
+ // as otherwise the size of the class would increase
+ // on 32-bit systems, as sizeof(Status) == sizeof(int)
+ // and sizeof(int) > remaining padding on 32 bit
+ char status;
void _q_sourceLoaded();
void _q_updateSize(bool loaderGeometryChanged = true);
diff --git a/src/quick/items/qquickmousearea_p.h b/src/quick/items/qquickmousearea_p.h
index 806cc41369..02ad56fd79 100644
--- a/src/quick/items/qquickmousearea_p.h
+++ b/src/quick/items/qquickmousearea_p.h
@@ -71,7 +71,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickMouseArea : public QQuickItem
Q_PROPERTY(bool containsMouse READ hovered NOTIFY hoveredChanged)
Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
- Q_PROPERTY(bool scrollGestureEnabled READ isScrollGestureEnabled WRITE setScrollGestureEnabled NOTIFY scrollGestureEnabledChanged REVISION 5)
+ Q_PROPERTY(bool scrollGestureEnabled READ isScrollGestureEnabled WRITE setScrollGestureEnabled NOTIFY scrollGestureEnabledChanged REVISION(2, 5))
Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedButtonsChanged)
Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
Q_PROPERTY(bool hoverEnabled READ hoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged)
@@ -83,9 +83,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickMouseArea : public QQuickItem
#if QT_CONFIG(cursor)
Q_PROPERTY(Qt::CursorShape cursorShape READ cursorShape WRITE setCursorShape RESET unsetCursor NOTIFY cursorShapeChanged)
#endif
- Q_PROPERTY(bool containsPress READ containsPress NOTIFY containsPressChanged REVISION 4)
- Q_PROPERTY(int pressAndHoldInterval READ pressAndHoldInterval WRITE setPressAndHoldInterval NOTIFY pressAndHoldIntervalChanged RESET resetPressAndHoldInterval REVISION 9)
+ Q_PROPERTY(bool containsPress READ containsPress NOTIFY containsPressChanged REVISION(2, 4))
+ Q_PROPERTY(int pressAndHoldInterval READ pressAndHoldInterval WRITE setPressAndHoldInterval NOTIFY pressAndHoldIntervalChanged RESET resetPressAndHoldInterval REVISION(2, 9))
QML_NAMED_ELEMENT(MouseArea)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickMouseArea(QQuickItem *parent=nullptr);
@@ -135,7 +136,7 @@ Q_SIGNALS:
void hoveredChanged();
void pressedChanged();
void enabledChanged();
- Q_REVISION(5) void scrollGestureEnabledChanged();
+ Q_REVISION(2, 5) void scrollGestureEnabledChanged();
void pressedButtonsChanged();
void acceptedButtonsChanged();
void hoverEnabledChanged();
@@ -157,8 +158,8 @@ Q_SIGNALS:
void entered();
void exited();
void canceled();
- Q_REVISION(4) void containsPressChanged();
- Q_REVISION(9) void pressAndHoldIntervalChanged();
+ Q_REVISION(2, 4) void containsPressChanged();
+ Q_REVISION(2, 9) void pressAndHoldIntervalChanged();
protected:
void setHovered(bool);
diff --git a/src/quick/items/qquickmultipointtoucharea.cpp b/src/quick/items/qquickmultipointtoucharea.cpp
index 9a371207ce..3a807d3c66 100644
--- a/src/quick/items/qquickmultipointtoucharea.cpp
+++ b/src/quick/items/qquickmultipointtoucharea.cpp
@@ -88,20 +88,18 @@ void QQuickTouchPoint::setPointId(int id)
These properties hold the current position of the touch point.
*/
-void QQuickTouchPoint::setX(qreal x)
+void QQuickTouchPoint::setPosition(QPointF p)
{
- if (_x == x)
+ bool xch = (_x != p.x());
+ bool ych = (_y != p.y());
+ if (!xch && !ych)
return;
- _x = x;
- emit xChanged();
-}
-
-void QQuickTouchPoint::setY(qreal y)
-{
- if (_y == y)
- return;
- _y = y;
- emit yChanged();
+ _x = p.x();
+ _y = p.y();
+ if (xch)
+ emit xChanged();
+ if (ych)
+ emit yChanged();
}
/*!
@@ -798,8 +796,7 @@ void QQuickMultiPointTouchArea::updateTouchPoint(QQuickTouchPoint *dtp, const QT
//TODO: if !qmlDefined, could bypass setters.
// also, should only emit signals after all values have been set
dtp->setUniqueId(p->uniqueId());
- dtp->setX(p->pos().x());
- dtp->setY(p->pos().y());
+ dtp->setPosition(p->pos());
dtp->setEllipseDiameters(p->ellipseDiameters());
dtp->setPressure(p->pressure());
dtp->setRotation(p->rotation());
@@ -817,8 +814,7 @@ void QQuickMultiPointTouchArea::updateTouchPoint(QQuickTouchPoint *dtp, const QM
{
dtp->setPreviousX(dtp->x());
dtp->setPreviousY(dtp->y());
- dtp->setX(e->localPos().x());
- dtp->setY(e->localPos().y());
+ dtp->setPosition(e->localPos());
if (e->type() == QEvent::MouseButtonPress) {
dtp->setStartX(e->localPos().x());
dtp->setStartY(e->localPos().y());
diff --git a/src/quick/items/qquickmultipointtoucharea_p.h b/src/quick/items/qquickmultipointtoucharea_p.h
index 363e62593b..d37cc6df7e 100644
--- a/src/quick/items/qquickmultipointtoucharea_p.h
+++ b/src/quick/items/qquickmultipointtoucharea_p.h
@@ -67,13 +67,13 @@ class Q_AUTOTEST_EXPORT QQuickTouchPoint : public QObject
{
Q_OBJECT
Q_PROPERTY(int pointId READ pointId NOTIFY pointIdChanged)
- Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId NOTIFY uniqueIdChanged REVISION 9)
+ Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId NOTIFY uniqueIdChanged REVISION(2, 9))
Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
Q_PROPERTY(qreal x READ x NOTIFY xChanged)
Q_PROPERTY(qreal y READ y NOTIFY yChanged)
- Q_PROPERTY(QSizeF ellipseDiameters READ ellipseDiameters NOTIFY ellipseDiametersChanged REVISION 9)
+ Q_PROPERTY(QSizeF ellipseDiameters READ ellipseDiameters NOTIFY ellipseDiametersChanged REVISION(2, 9))
Q_PROPERTY(qreal pressure READ pressure NOTIFY pressureChanged)
- Q_PROPERTY(qreal rotation READ rotation NOTIFY rotationChanged REVISION 9)
+ Q_PROPERTY(qreal rotation READ rotation NOTIFY rotationChanged REVISION(2, 9))
Q_PROPERTY(QVector2D velocity READ velocity NOTIFY velocityChanged)
Q_PROPERTY(QRectF area READ area NOTIFY areaChanged)
@@ -84,6 +84,7 @@ class Q_AUTOTEST_EXPORT QQuickTouchPoint : public QObject
Q_PROPERTY(qreal sceneX READ sceneX NOTIFY sceneXChanged)
Q_PROPERTY(qreal sceneY READ sceneY NOTIFY sceneYChanged)
QML_NAMED_ELEMENT(TouchPoint)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickTouchPoint(bool qmlDefined = true)
@@ -97,10 +98,8 @@ public:
void setUniqueId(const QPointingDeviceUniqueId &id);
qreal x() const { return _x; }
- void setX(qreal x);
-
qreal y() const { return _y; }
- void setY(qreal y);
+ void setPosition(QPointF pos);
QSizeF ellipseDiameters() const { return _ellipseDiameters; }
void setEllipseDiameters(const QSizeF &d);
@@ -146,12 +145,12 @@ public:
Q_SIGNALS:
void pressedChanged();
void pointIdChanged();
- Q_REVISION(9) void uniqueIdChanged();
+ Q_REVISION(2, 9) void uniqueIdChanged();
void xChanged();
void yChanged();
- Q_REVISION(9) void ellipseDiametersChanged();
+ Q_REVISION(2, 9) void ellipseDiametersChanged();
void pressureChanged();
- Q_REVISION(9) void rotationChanged();
+ Q_REVISION(2, 9) void rotationChanged();
void velocityChanged();
void areaChanged();
void startXChanged();
@@ -189,6 +188,7 @@ class QQuickGrabGestureEvent : public QObject
Q_PROPERTY(QQmlListProperty<QObject> touchPoints READ touchPoints CONSTANT)
Q_PROPERTY(qreal dragThreshold READ dragThreshold CONSTANT)
QML_NAMED_ELEMENT(GestureEvent)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("GestureEvent is only available in the context of handling the gestureStarted signal from MultiPointTouchArea.")
public:
@@ -218,6 +218,7 @@ class Q_AUTOTEST_EXPORT QQuickMultiPointTouchArea : public QQuickItem
Q_PROPERTY(int maximumTouchPoints READ maximumTouchPoints WRITE setMaximumTouchPoints NOTIFY maximumTouchPointsChanged)
Q_PROPERTY(bool mouseEnabled READ mouseEnabled WRITE setMouseEnabled NOTIFY mouseEnabledChanged)
QML_NAMED_ELEMENT(MultiPointTouchArea)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickMultiPointTouchArea(QQuickItem *parent=nullptr);
diff --git a/src/quick/items/qquickopenglinfo_p.h b/src/quick/items/qquickopenglinfo_p.h
index b733d205e3..e0c2572b8d 100644
--- a/src/quick/items/qquickopenglinfo_p.h
+++ b/src/quick/items/qquickopenglinfo_p.h
@@ -72,7 +72,7 @@ class QQuickOpenGLInfo : public QObject
QML_NAMED_ELEMENT(OpenGLInfo)
QML_UNCREATABLE("OpenGLInfo is only available via attached properties.")
- QML_ADDED_IN_MINOR_VERSION(4)
+ QML_ADDED_IN_VERSION(2, 4)
QML_ATTACHED(QQuickOpenGLInfo)
public:
diff --git a/src/quick/items/qquickopenglshadereffect.cpp b/src/quick/items/qquickopenglshadereffect.cpp
index e217fdb5d0..280cdbf831 100644
--- a/src/quick/items/qquickopenglshadereffect.cpp
+++ b/src/quick/items/qquickopenglshadereffect.cpp
@@ -52,8 +52,9 @@
#include "qquickshadereffectmesh_p.h"
#include <QtQml/qqmlfile.h>
-#include <QtCore/qsignalmapper.h>
+#include <QtCore/qfile.h>
#include <QtCore/qfileselector.h>
+#include <QtCore/qsignalmapper.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/items/qquickopenglshadereffectnode.cpp b/src/quick/items/qquickopenglshadereffectnode.cpp
index 5721f116e8..71cfe96462 100644
--- a/src/quick/items/qquickopenglshadereffectnode.cpp
+++ b/src/quick/items/qquickopenglshadereffectnode.cpp
@@ -45,7 +45,7 @@
#include <QtQuick/private/qsgshadersourcebuilder_p.h>
#include <QtQuick/private/qsgtexture_p.h>
#include <QtCore/qmutex.h>
-#include <QtGui/qopenglfunctions.h>
+#include <qopenglfunctions.h>
#ifndef GL_TEXTURE_EXTERNAL_OES
#define GL_TEXTURE_EXTERNAL_OES 0x8D65
diff --git a/src/quick/items/qquickpainteditem.cpp b/src/quick/items/qquickpainteditem.cpp
index df5ec0c3f2..1eb852f6bf 100644
--- a/src/quick/items/qquickpainteditem.cpp
+++ b/src/quick/items/qquickpainteditem.cpp
@@ -44,6 +44,9 @@
#include <QtQuick/private/qsgcontext_p.h>
#include <private/qsgadaptationlayer_p.h>
#include <qsgtextureprovider.h>
+#if QT_CONFIG(opengl)
+#include <QOpenGLContext>
+#endif // QT_CONFIG(opengl)
#include <qmath.h>
diff --git a/src/quick/items/qquickpainteditem.h b/src/quick/items/qquickpainteditem.h
index 4821a409be..a6a78f6166 100644
--- a/src/quick/items/qquickpainteditem.h
+++ b/src/quick/items/qquickpainteditem.h
@@ -57,6 +57,7 @@ class Q_QUICK_EXPORT QQuickPaintedItem : public QQuickItem
Q_PROPERTY(QSize textureSize READ textureSize WRITE setTextureSize NOTIFY textureSizeChanged)
QML_NAMED_ELEMENT(PaintedItem)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("Cannot create instance of abstract class PaintedItem.")
public:
diff --git a/src/quick/items/qquickpathview_p.h b/src/quick/items/qquickpathview_p.h
index c12358e4f6..0c5a6578c3 100644
--- a/src/quick/items/qquickpathview_p.h
+++ b/src/quick/items/qquickpathview_p.h
@@ -97,10 +97,11 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathView : public QQuickItem
Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount RESET resetPathItemCount NOTIFY pathItemCountChanged)
Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged)
- Q_PROPERTY(MovementDirection movementDirection READ movementDirection WRITE setMovementDirection NOTIFY movementDirectionChanged REVISION 7)
+ Q_PROPERTY(MovementDirection movementDirection READ movementDirection WRITE setMovementDirection NOTIFY movementDirectionChanged REVISION(2, 7))
Q_PROPERTY(int cacheItemCount READ cacheItemCount WRITE setCacheItemCount NOTIFY cacheItemCountChanged)
QML_NAMED_ELEMENT(PathView)
+ QML_ADDED_IN_VERSION(2, 0)
QML_ATTACHED(QQuickPathViewAttached)
public:
@@ -182,7 +183,7 @@ public:
Q_INVOKABLE void positionViewAtIndex(int index, int mode);
Q_INVOKABLE int indexAt(qreal x, qreal y) const;
Q_INVOKABLE QQuickItem *itemAt(qreal x, qreal y) const;
- Q_REVISION(13) Q_INVOKABLE QQuickItem *itemAtIndex(int index) const;
+ Q_REVISION(2, 13) Q_INVOKABLE QQuickItem *itemAtIndex(int index) const;
static QQuickPathViewAttached *qmlAttachedProperties(QObject *);
@@ -215,7 +216,7 @@ Q_SIGNALS:
void highlightMoveDurationChanged();
void movementStarted();
void movementEnded();
- Q_REVISION(7) void movementDirectionChanged();
+ Q_REVISION(2, 7) void movementDirectionChanged();
void flickStarted();
void flickEnded();
void dragStarted();
diff --git a/src/quick/items/qquickpincharea_p.h b/src/quick/items/qquickpincharea_p.h
index d7f814cc8a..27f895612a 100644
--- a/src/quick/items/qquickpincharea_p.h
+++ b/src/quick/items/qquickpincharea_p.h
@@ -71,6 +71,7 @@ class Q_AUTOTEST_EXPORT QQuickPinch : public QObject
Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged)
Q_PROPERTY(bool active READ active NOTIFY activeChanged)
QML_NAMED_ELEMENT(Pinch)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickPinch();
@@ -212,6 +213,7 @@ class Q_AUTOTEST_EXPORT QQuickPinchEvent : public QObject
Q_PROPERTY(int pointCount READ pointCount)
Q_PROPERTY(bool accepted READ accepted WRITE setAccepted)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickPinchEvent(QPointF c, qreal s, qreal a, qreal r)
@@ -271,6 +273,7 @@ class Q_AUTOTEST_EXPORT QQuickPinchArea : public QQuickItem
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(QQuickPinch *pinch READ pinch CONSTANT)
QML_NAMED_ELEMENT(PinchArea)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickPinchArea(QQuickItem *parent=nullptr);
@@ -286,7 +289,7 @@ Q_SIGNALS:
void pinchStarted(QQuickPinchEvent *pinch);
void pinchUpdated(QQuickPinchEvent *pinch);
void pinchFinished(QQuickPinchEvent *pinch);
- Q_REVISION(5) void smartZoom(QQuickPinchEvent *pinch);
+ Q_REVISION(2, 5) void smartZoom(QQuickPinchEvent *pinch);
protected:
bool childMouseEventFilter(QQuickItem *i, QEvent *e) override;
diff --git a/src/quick/items/qquickpositioners.cpp b/src/quick/items/qquickpositioners.cpp
index 512f59d799..65c48c583a 100644
--- a/src/quick/items/qquickpositioners.cpp
+++ b/src/quick/items/qquickpositioners.cpp
@@ -1609,6 +1609,7 @@ Qt::LayoutDirection QQuickGrid::effectiveLayoutDirection() const
\qmlproperty enumeration QtQuick::Grid::horizontalItemAlignment
\qmlproperty enumeration QtQuick::Grid::verticalItemAlignment
\qmlproperty enumeration QtQuick::Grid::effectiveHorizontalItemAlignment
+ \since 5.1
Sets the horizontal and vertical alignment of items in the Grid. By default,
the items are vertically aligned to the top. Horizontal
diff --git a/src/quick/items/qquickpositioners_p.h b/src/quick/items/qquickpositioners_p.h
index b924cb9c12..2c3aa674c6 100644
--- a/src/quick/items/qquickpositioners_p.h
+++ b/src/quick/items/qquickpositioners_p.h
@@ -107,13 +107,14 @@ class Q_QUICK_PRIVATE_EXPORT QQuickBasePositioner : public QQuickImplicitSizeIte
Q_PROPERTY(QQuickTransition *move READ move WRITE setMove NOTIFY moveChanged)
Q_PROPERTY(QQuickTransition *add READ add WRITE setAdd NOTIFY addChanged)
- Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged REVISION 6)
- Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged REVISION 6)
- Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged REVISION 6)
- Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged REVISION 6)
- Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged REVISION 6)
+ Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged REVISION(2, 6))
+ Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged REVISION(2, 6))
+ Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged REVISION(2, 6))
+ Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged REVISION(2, 6))
+ Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged REVISION(2, 6))
QML_NAMED_ELEMENT(Positioner)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("Positioner is an abstract type that is only available as an attached property.")
QML_ATTACHED(QQuickPositionerAttached)
@@ -159,7 +160,7 @@ public:
void setBottomPadding(qreal padding);
void resetBottomPadding();
- Q_REVISION(9) Q_INVOKABLE void forceLayout();
+ Q_REVISION(2, 9) Q_INVOKABLE void forceLayout();
protected:
QQuickBasePositioner(QQuickBasePositionerPrivate &dd, PositionerType at, QQuickItem *parent);
@@ -173,12 +174,12 @@ Q_SIGNALS:
void populateChanged();
void moveChanged();
void addChanged();
- Q_REVISION(6) void paddingChanged();
- Q_REVISION(6) void topPaddingChanged();
- Q_REVISION(6) void leftPaddingChanged();
- Q_REVISION(6) void rightPaddingChanged();
- Q_REVISION(6) void bottomPaddingChanged();
- Q_REVISION(9) void positioningComplete();
+ Q_REVISION(2, 6) void paddingChanged();
+ Q_REVISION(2, 6) void topPaddingChanged();
+ Q_REVISION(2, 6) void leftPaddingChanged();
+ Q_REVISION(2, 6) void rightPaddingChanged();
+ Q_REVISION(2, 6) void bottomPaddingChanged();
+ Q_REVISION(2, 9) void positioningComplete();
protected Q_SLOTS:
void prePositioning();
@@ -236,6 +237,7 @@ class Q_AUTOTEST_EXPORT QQuickColumn : public QQuickBasePositioner
{
Q_OBJECT
QML_NAMED_ELEMENT(Column)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickColumn(QQuickItem *parent=nullptr);
@@ -253,6 +255,7 @@ class Q_AUTOTEST_EXPORT QQuickRow: public QQuickBasePositioner
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged)
Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged)
QML_NAMED_ELEMENT(Row)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickRow(QQuickItem *parent=nullptr);
@@ -284,10 +287,11 @@ class Q_AUTOTEST_EXPORT QQuickGrid : public QQuickBasePositioner
Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged)
Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged)
- Q_PROPERTY(HAlignment horizontalItemAlignment READ hItemAlign WRITE setHItemAlign NOTIFY horizontalAlignmentChanged REVISION 1)
- Q_PROPERTY(HAlignment effectiveHorizontalItemAlignment READ effectiveHAlign NOTIFY effectiveHorizontalAlignmentChanged REVISION 1)
- Q_PROPERTY(VAlignment verticalItemAlignment READ vItemAlign WRITE setVItemAlign NOTIFY verticalAlignmentChanged REVISION 1)
+ Q_PROPERTY(HAlignment horizontalItemAlignment READ hItemAlign WRITE setHItemAlign NOTIFY horizontalAlignmentChanged REVISION(2, 1))
+ Q_PROPERTY(HAlignment effectiveHorizontalItemAlignment READ effectiveHAlign NOTIFY effectiveHorizontalAlignmentChanged REVISION(2, 1))
+ Q_PROPERTY(VAlignment verticalItemAlignment READ vItemAlign WRITE setVItemAlign NOTIFY verticalAlignmentChanged REVISION(2, 1))
QML_NAMED_ELEMENT(Grid)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickGrid(QQuickItem *parent=nullptr);
@@ -339,9 +343,9 @@ Q_SIGNALS:
void effectiveLayoutDirectionChanged();
void rowSpacingChanged();
void columnSpacingChanged();
- Q_REVISION(1) void horizontalAlignmentChanged(HAlignment alignment);
- Q_REVISION(1) void effectiveHorizontalAlignmentChanged(HAlignment alignment);
- Q_REVISION(1) void verticalAlignmentChanged(VAlignment alignment);
+ Q_REVISION(2, 1) void horizontalAlignmentChanged(HAlignment alignment);
+ Q_REVISION(2, 1) void effectiveHorizontalAlignmentChanged(HAlignment alignment);
+ Q_REVISION(2, 1) void verticalAlignmentChanged(VAlignment alignment);
protected:
void doPositioning(QSizeF *contentSize) override;
@@ -369,6 +373,7 @@ class Q_AUTOTEST_EXPORT QQuickFlow: public QQuickBasePositioner
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged)
Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged)
QML_NAMED_ELEMENT(Flow)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickFlow(QQuickItem *parent=nullptr);
diff --git a/src/quick/items/qquickrectangle_p.h b/src/quick/items/qquickrectangle_p.h
index 934300b63b..c4f03de770 100644
--- a/src/quick/items/qquickrectangle_p.h
+++ b/src/quick/items/qquickrectangle_p.h
@@ -67,6 +67,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPen : public QObject
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY penChanged)
Q_PROPERTY(bool pixelAligned READ pixelAligned WRITE setPixelAligned NOTIFY penChanged)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickPen(QObject *parent=nullptr);
@@ -98,6 +99,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickGradientStop : public QObject
Q_PROPERTY(qreal position READ position WRITE setPosition)
Q_PROPERTY(QColor color READ color WRITE setColor)
QML_NAMED_ELEMENT(GradientStop)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickGradientStop(QObject *parent=nullptr);
@@ -121,9 +123,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickGradient : public QObject
Q_OBJECT
Q_PROPERTY(QQmlListProperty<QQuickGradientStop> stops READ stops)
- Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged REVISION 12)
+ Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged REVISION(2, 12))
Q_CLASSINFO("DefaultProperty", "stops")
QML_NAMED_ELEMENT(Gradient)
+ QML_ADDED_IN_VERSION(2, 0)
Q_ENUMS(QGradient::Preset)
public:
@@ -165,6 +168,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickRectangle : public QQuickItem
Q_PROPERTY(QQuickPen * border READ border CONSTANT)
Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged)
QML_NAMED_ELEMENT(Rectangle)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickRectangle(QQuickItem *parent=nullptr);
diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp
index 9f9777f199..08d04d3b11 100644
--- a/src/quick/items/qquickrendercontrol.cpp
+++ b/src/quick/items/qquickrendercontrol.cpp
@@ -45,7 +45,7 @@
#include <QtQuick/private/qquickanimatorcontroller_p.h>
#if QT_CONFIG(opengl)
-# include <QtGui/QOpenGLContext>
+# include <QOpenGLContext>
# include <QtQuick/private/qsgdefaultrendercontext_p.h>
#if QT_CONFIG(quick_shadereffect)
# include <QtQuick/private/qquickopenglshadereffectnode_p.h>
diff --git a/src/quick/items/qquickrepeater_p.h b/src/quick/items/qquickrepeater_p.h
index 20984fa23e..652651efb9 100644
--- a/src/quick/items/qquickrepeater_p.h
+++ b/src/quick/items/qquickrepeater_p.h
@@ -71,6 +71,7 @@ class Q_AUTOTEST_EXPORT QQuickRepeater : public QQuickItem
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_CLASSINFO("DefaultProperty", "delegate")
QML_NAMED_ELEMENT(Repeater)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickRepeater(QQuickItem *parent=nullptr);
diff --git a/src/quick/items/qquickscalegrid_p_p.h b/src/quick/items/qquickscalegrid_p_p.h
index 56b0ee86ab..1eb6c05ef1 100644
--- a/src/quick/items/qquickscalegrid_p_p.h
+++ b/src/quick/items/qquickscalegrid_p_p.h
@@ -70,6 +70,7 @@ class Q_AUTOTEST_EXPORT QQuickScaleGrid : public QObject
Q_PROPERTY(int right READ right WRITE setRight NOTIFY rightBorderChanged)
Q_PROPERTY(int bottom READ bottom WRITE setBottom NOTIFY bottomBorderChanged)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickScaleGrid(QObject *parent=nullptr);
diff --git a/src/quick/items/qquickscreen_p.h b/src/quick/items/qquickscreen_p.h
index b4266d78c7..dc1c820309 100644
--- a/src/quick/items/qquickscreen_p.h
+++ b/src/quick/items/qquickscreen_p.h
@@ -68,9 +68,9 @@ class Q_QUICK_PRIVATE_EXPORT QQuickScreenInfo : public QObject
{
Q_OBJECT
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
- Q_PROPERTY(QString manufacturer READ manufacturer NOTIFY manufacturerChanged REVISION 10)
- Q_PROPERTY(QString model READ model NOTIFY modelChanged REVISION 10)
- Q_PROPERTY(QString serialNumber READ serialNumber NOTIFY serialNumberChanged REVISION 10)
+ Q_PROPERTY(QString manufacturer READ manufacturer NOTIFY manufacturerChanged REVISION(2, 10))
+ Q_PROPERTY(QString model READ model NOTIFY modelChanged REVISION(2, 10))
+ Q_PROPERTY(QString serialNumber READ serialNumber NOTIFY serialNumberChanged REVISION(2, 10))
Q_PROPERTY(int width READ width NOTIFY widthChanged)
Q_PROPERTY(int height READ height NOTIFY heightChanged)
Q_PROPERTY(int desktopAvailableWidth READ desktopAvailableWidth NOTIFY desktopGeometryChanged)
@@ -83,8 +83,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickScreenInfo : public QObject
// TODO Qt 6 Remove this orientation -> incomplete device orientation -> better use OrientationSensor
Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation NOTIFY orientationChanged)
- Q_PROPERTY(int virtualX READ virtualX NOTIFY virtualXChanged REVISION 3)
- Q_PROPERTY(int virtualY READ virtualY NOTIFY virtualYChanged REVISION 3)
+ Q_PROPERTY(int virtualX READ virtualX NOTIFY virtualXChanged REVISION(2, 3))
+ Q_PROPERTY(int virtualY READ virtualY NOTIFY virtualYChanged REVISION(2, 3))
public:
QQuickScreenInfo(QObject *parent = nullptr, QScreen *wrappedScreen = nullptr);
@@ -110,9 +110,9 @@ public:
Q_SIGNALS:
void nameChanged();
- Q_REVISION(10) void manufacturerChanged();
- Q_REVISION(10) void modelChanged();
- Q_REVISION(10) void serialNumberChanged();
+ Q_REVISION(2, 10) void manufacturerChanged();
+ Q_REVISION(2, 10) void modelChanged();
+ Q_REVISION(2, 10) void serialNumberChanged();
void widthChanged();
void heightChanged();
void desktopGeometryChanged();
@@ -121,8 +121,8 @@ Q_SIGNALS:
void devicePixelRatioChanged();
void primaryOrientationChanged();
void orientationChanged();
- Q_REVISION(3) void virtualXChanged();
- Q_REVISION(3) void virtualYChanged();
+ Q_REVISION(2, 3) void virtualXChanged();
+ Q_REVISION(2, 3) void virtualYChanged();
protected:
QPointer<QScreen> m_screen;
diff --git a/src/quick/items/qquickshadereffect_p.h b/src/quick/items/qquickshadereffect_p.h
index c14907092c..16eb252add 100644
--- a/src/quick/items/qquickshadereffect_p.h
+++ b/src/quick/items/qquickshadereffect_p.h
@@ -74,8 +74,9 @@ class Q_QUICK_PRIVATE_EXPORT QQuickShaderEffect : public QQuickItem
Q_PROPERTY(CullMode cullMode READ cullMode WRITE setCullMode NOTIFY cullModeChanged)
Q_PROPERTY(QString log READ log NOTIFY logChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
- Q_PROPERTY(bool supportsAtlasTextures READ supportsAtlasTextures WRITE setSupportsAtlasTextures NOTIFY supportsAtlasTexturesChanged REVISION 4)
+ Q_PROPERTY(bool supportsAtlasTextures READ supportsAtlasTextures WRITE setSupportsAtlasTextures NOTIFY supportsAtlasTexturesChanged REVISION(2, 4))
QML_NAMED_ELEMENT(ShaderEffect)
+ QML_ADDED_IN_VERSION(2, 0)
public:
enum CullMode {
diff --git a/src/quick/items/qquickshadereffectmesh_p.h b/src/quick/items/qquickshadereffectmesh_p.h
index 710d37c275..4cd885a740 100644
--- a/src/quick/items/qquickshadereffectmesh_p.h
+++ b/src/quick/items/qquickshadereffectmesh_p.h
@@ -78,6 +78,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickShaderEffectMesh : public QObject
Q_OBJECT
QML_NAMED_ELEMENT(ShaderEffectMesh)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("Cannot create instance of abstract class ShaderEffectMesh.")
public:
@@ -102,6 +103,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickGridMesh : public QQuickShaderEffectMesh
Q_OBJECT
Q_PROPERTY(QSize resolution READ resolution WRITE setResolution NOTIFY resolutionChanged)
QML_NAMED_ELEMENT(GridMesh)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickGridMesh(QObject *parent = nullptr);
bool validateAttributes(const QVector<QByteArray> &attributes, int *posIndex) override;
@@ -131,7 +133,7 @@ class QQuickBorderImageMesh : public QQuickShaderEffectMesh
Q_PROPERTY(TileMode verticalTileMode READ verticalTileMode WRITE setVerticalTileMode NOTIFY verticalTileModeChanged)
QML_NAMED_ELEMENT(BorderImageMesh)
- QML_ADDED_IN_MINOR_VERSION(8)
+ QML_ADDED_IN_VERSION(2, 8)
public:
QQuickBorderImageMesh(QObject *parent = nullptr);
diff --git a/src/quick/items/qquickshadereffectsource.cpp b/src/quick/items/qquickshadereffectsource.cpp
index f9f3e5cfa3..b298ed74da 100644
--- a/src/quick/items/qquickshadereffectsource.cpp
+++ b/src/quick/items/qquickshadereffectsource.cpp
@@ -161,10 +161,6 @@ public:
\l sourceItem while still handling input. For this, you can use
the \l hideSource property.
- \note If \l sourceItem is a \l Rectangle with border, by default half the
- border width falls outside the texture. To get the whole border, you can
- extend the \l sourceRect.
-
\note The ShaderEffectSource relies on FBO multisampling support
to antialias edges. If the underlying hardware does not support this,
which is the case for most embedded graphics chips, edges rendered
diff --git a/src/quick/items/qquickshadereffectsource_p.h b/src/quick/items/qquickshadereffectsource_p.h
index c0a1ccab78..fe419e5959 100644
--- a/src/quick/items/qquickshadereffectsource_p.h
+++ b/src/quick/items/qquickshadereffectsource_p.h
@@ -87,9 +87,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickShaderEffectSource : public QQuickItem, publi
Q_PROPERTY(bool hideSource READ hideSource WRITE setHideSource NOTIFY hideSourceChanged)
Q_PROPERTY(bool mipmap READ mipmap WRITE setMipmap NOTIFY mipmapChanged)
Q_PROPERTY(bool recursive READ recursive WRITE setRecursive NOTIFY recursiveChanged)
- Q_PROPERTY(TextureMirroring textureMirroring READ textureMirroring WRITE setTextureMirroring NOTIFY textureMirroringChanged REVISION 6)
- Q_PROPERTY(int samples READ samples WRITE setSamples NOTIFY samplesChanged REVISION 9)
+ Q_PROPERTY(TextureMirroring textureMirroring READ textureMirroring WRITE setTextureMirroring NOTIFY textureMirroringChanged REVISION(2, 6))
+ Q_PROPERTY(int samples READ samples WRITE setSamples NOTIFY samplesChanged REVISION(2, 9))
QML_NAMED_ELEMENT(ShaderEffectSource)
+ QML_ADDED_IN_VERSION(2, 0)
public:
enum WrapMode {
diff --git a/src/quick/items/qquicksprite_p.h b/src/quick/items/qquicksprite_p.h
index 98e5b82db8..328dc74f47 100644
--- a/src/quick/items/qquicksprite_p.h
+++ b/src/quick/items/qquicksprite_p.h
@@ -87,6 +87,7 @@ class Q_QUICK_EXPORT QQuickSprite : public QQuickStochasticState
Q_PROPERTY(int frameDuration READ frameDuration WRITE setFrameDuration NOTIFY frameDurationChanged RESET resetFrameDuration)
Q_PROPERTY(int frameDurationVariation READ frameDurationVariation WRITE setFrameDurationVariation NOTIFY frameDurationVariationChanged)
QML_NAMED_ELEMENT(Sprite)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickSprite(QObject *parent = nullptr);
diff --git a/src/quick/items/qquickspriteengine.cpp b/src/quick/items/qquickspriteengine.cpp
index 8c52703938..3e4ed8707b 100644
--- a/src/quick/items/qquickspriteengine.cpp
+++ b/src/quick/items/qquickspriteengine.cpp
@@ -45,7 +45,7 @@
#include <QPainter>
#include <QRandomGenerator>
#include <QSet>
-#include <QtGui/qopengl.h>
+#include <qopengl.h>
#include <QOpenGLFunctions>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/items/qquickspriteengine_p.h b/src/quick/items/qquickspriteengine_p.h
index d76055c831..5ad33389de 100644
--- a/src/quick/items/qquickspriteengine_p.h
+++ b/src/quick/items/qquickspriteengine_p.h
@@ -330,6 +330,18 @@ inline int spriteCount(QQmlListProperty<QQuickSprite> *p)
return reinterpret_cast<QList<QQuickSprite *> *>(p->data)->count();
}
+inline void spriteReplace(QQmlListProperty<QQuickSprite> *p, int idx, QQuickSprite *s)
+{
+ reinterpret_cast<QList<QQuickSprite *> *>(p->data)->replace(idx, s);
+ p->object->metaObject()->invokeMethod(p->object, "createEngine");
+}
+
+inline void spriteRemoveLast(QQmlListProperty<QQuickSprite> *p)
+{
+ reinterpret_cast<QList<QQuickSprite *> *>(p->data)->removeLast();
+ p->object->metaObject()->invokeMethod(p->object, "createEngine");
+}
+
QT_END_NAMESPACE
#endif // QQUICKSPRITEENGINE_P_H
diff --git a/src/quick/items/qquickspritesequence.cpp b/src/quick/items/qquickspritesequence.cpp
index eb4b5335e7..c29938a1bb 100644
--- a/src/quick/items/qquickspritesequence.cpp
+++ b/src/quick/items/qquickspritesequence.cpp
@@ -162,7 +162,9 @@ void QQuickSpriteSequence::setInterpolate(bool arg)
QQmlListProperty<QQuickSprite> QQuickSpriteSequence::sprites()
{
Q_D(QQuickSpriteSequence);
- return QQmlListProperty<QQuickSprite>(this, &d->m_sprites, spriteAppend, spriteCount, spriteAt, spriteClear);
+ return QQmlListProperty<QQuickSprite>(this, &d->m_sprites,
+ spriteAppend, spriteCount, spriteAt,
+ spriteClear, spriteReplace, spriteRemoveLast);
}
bool QQuickSpriteSequence::running() const
diff --git a/src/quick/items/qquickspritesequence_p.h b/src/quick/items/qquickspritesequence_p.h
index 8361f7832a..39b536daae 100644
--- a/src/quick/items/qquickspritesequence_p.h
+++ b/src/quick/items/qquickspritesequence_p.h
@@ -75,6 +75,7 @@ class Q_AUTOTEST_EXPORT QQuickSpriteSequence : public QQuickItem
Q_PROPERTY(QQmlListProperty<QQuickSprite> sprites READ sprites)
Q_CLASSINFO("DefaultProperty", "sprites")
QML_NAMED_ELEMENT(SpriteSequence)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickSpriteSequence(QQuickItem *parent = nullptr);
diff --git a/src/quick/items/qquickstateoperations_p.h b/src/quick/items/qquickstateoperations_p.h
index d451dc6f77..5ba5400367 100644
--- a/src/quick/items/qquickstateoperations_p.h
+++ b/src/quick/items/qquickstateoperations_p.h
@@ -75,6 +75,7 @@ class Q_AUTOTEST_EXPORT QQuickParentChange : public QQuickStateOperation, public
Q_PROPERTY(QQmlScriptString scale READ scale WRITE setScale)
Q_PROPERTY(QQmlScriptString rotation READ rotation WRITE setRotation)
QML_NAMED_ELEMENT(ParentChange)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickParentChange(QObject *parent=nullptr);
~QQuickParentChange();
@@ -138,6 +139,7 @@ class Q_AUTOTEST_EXPORT QQuickAnchorSet : public QObject
Q_PROPERTY(QQmlScriptString verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter)
Q_PROPERTY(QQmlScriptString baseline READ baseline WRITE setBaseline RESET resetBaseline)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickAnchorSet(QObject *parent=nullptr);
@@ -188,6 +190,7 @@ class Q_AUTOTEST_EXPORT QQuickAnchorChanges : public QQuickStateOperation, publi
Q_PROPERTY(QQuickItem *target READ object WRITE setObject)
Q_PROPERTY(QQuickAnchorSet *anchors READ anchors CONSTANT)
QML_NAMED_ELEMENT(AnchorChanges)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickAnchorChanges(QObject *parent=nullptr);
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
index 66e89f0a09..9b1704421c 100644
--- a/src/quick/items/qquicktableview.cpp
+++ b/src/quick/items/qquicktableview.cpp
@@ -82,7 +82,7 @@
The following example shows how to create a model from C++ with multiple
columns:
- \snippet qml/tableview/cpp-tablemodel.cpp 0
+ \snippet qml/tableview/cpp-tablemodel.h 0
And then how to use it from QML:
@@ -441,7 +441,16 @@ QQuickTableViewPrivate::QQuickTableViewPrivate()
QQuickTableViewPrivate::~QQuickTableViewPrivate()
{
- releaseLoadedItems(QQmlTableInstanceModel::NotReusable);
+ for (auto *fxTableItem : loadedItems) {
+ if (auto item = fxTableItem->item) {
+ if (fxTableItem->ownItem)
+ delete item;
+ else if (tableModel)
+ tableModel->dispose(item);
+ }
+ delete fxTableItem;
+ }
+
if (tableModel)
delete tableModel;
}
@@ -2121,15 +2130,17 @@ void QQuickTableViewPrivate::fixup(QQuickFlickablePrivate::AxisData &data, qreal
QQuickFlickablePrivate::fixup(data, minExtent, maxExtent);
}
-int QQuickTableViewPrivate::resolveImportVersion()
+QTypeRevision QQuickTableViewPrivate::resolveImportVersion()
{
const auto data = QQmlData::get(q_func());
if (!data || !data->propertyCache)
- return 0;
+ return QTypeRevision::zero();
const auto cppMetaObject = data->propertyCache->firstCppMetaObject();
const auto qmlTypeView = QQmlMetaType::qmlType(cppMetaObject);
- return qmlTypeView.minorVersion();
+
+ // TODO: did we rather want qmlTypeView.revision() here?
+ return qmlTypeView.metaObjectRevision();
}
void QQuickTableViewPrivate::createWrapperModel()
@@ -2350,14 +2361,11 @@ void QQuickTableViewPrivate::connectToModel()
QObjectPrivate::connect(model, &QQmlInstanceModel::createdItem, this, &QQuickTableViewPrivate::itemCreatedCallback);
QObjectPrivate::connect(model, &QQmlInstanceModel::initItem, this, &QQuickTableViewPrivate::initItemCallback);
+ QObjectPrivate::connect(model, &QQmlTableInstanceModel::itemPooled, this, &QQuickTableViewPrivate::itemPooledCallback);
+ QObjectPrivate::connect(model, &QQmlTableInstanceModel::itemReused, this, &QQuickTableViewPrivate::itemReusedCallback);
- if (tableModel) {
- const auto tm = tableModel.data();
- QObjectPrivate::connect(tm, &QQmlTableInstanceModel::itemPooled, this, &QQuickTableViewPrivate::itemPooledCallback);
- QObjectPrivate::connect(tm, &QQmlTableInstanceModel::itemReused, this, &QQuickTableViewPrivate::itemReusedCallback);
- // Connect atYEndChanged to a function that fetches data if more is available
- QObjectPrivate::connect(q, &QQuickTableView::atYEndChanged, this, &QQuickTableViewPrivate::fetchMoreData);
- }
+ // Connect atYEndChanged to a function that fetches data if more is available
+ QObjectPrivate::connect(q, &QQuickTableView::atYEndChanged, this, &QQuickTableViewPrivate::fetchMoreData);
if (auto const aim = model->abstractItemModel()) {
// When the model exposes a QAIM, we connect to it directly. This means that if the current model is
@@ -2385,13 +2393,10 @@ void QQuickTableViewPrivate::disconnectFromModel()
QObjectPrivate::disconnect(model, &QQmlInstanceModel::createdItem, this, &QQuickTableViewPrivate::itemCreatedCallback);
QObjectPrivate::disconnect(model, &QQmlInstanceModel::initItem, this, &QQuickTableViewPrivate::initItemCallback);
+ QObjectPrivate::disconnect(model, &QQmlTableInstanceModel::itemPooled, this, &QQuickTableViewPrivate::itemPooledCallback);
+ QObjectPrivate::disconnect(model, &QQmlTableInstanceModel::itemReused, this, &QQuickTableViewPrivate::itemReusedCallback);
- if (tableModel) {
- const auto tm = tableModel.data();
- QObjectPrivate::disconnect(tm, &QQmlTableInstanceModel::itemPooled, this, &QQuickTableViewPrivate::itemPooledCallback);
- QObjectPrivate::disconnect(tm, &QQmlTableInstanceModel::itemReused, this, &QQuickTableViewPrivate::itemReusedCallback);
- QObjectPrivate::disconnect(q, &QQuickTableView::atYEndChanged, this, &QQuickTableViewPrivate::fetchMoreData);
- }
+ QObjectPrivate::disconnect(q, &QQuickTableView::atYEndChanged, this, &QQuickTableViewPrivate::fetchMoreData);
if (auto const aim = model->abstractItemModel()) {
disconnect(aim, &QAbstractItemModel::rowsMoved, this, &QQuickTableViewPrivate::rowsMovedCallback);
diff --git a/src/quick/items/qquicktableview_p.h b/src/quick/items/qquicktableview_p.h
index d549aaddf7..c71e74bfdc 100644
--- a/src/quick/items/qquicktableview_p.h
+++ b/src/quick/items/qquicktableview_p.h
@@ -79,11 +79,11 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTableView : public QQuickFlickable
Q_PROPERTY(bool reuseItems READ reuseItems WRITE setReuseItems NOTIFY reuseItemsChanged)
Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged)
Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged)
- Q_PROPERTY(QQuickTableView *syncView READ syncView WRITE setSyncView NOTIFY syncViewChanged REVISION 14)
- Q_PROPERTY(Qt::Orientations syncDirection READ syncDirection WRITE setSyncDirection NOTIFY syncDirectionChanged REVISION 14)
+ Q_PROPERTY(QQuickTableView *syncView READ syncView WRITE setSyncView NOTIFY syncViewChanged REVISION(2, 14))
+ Q_PROPERTY(Qt::Orientations syncDirection READ syncDirection WRITE setSyncDirection NOTIFY syncDirectionChanged REVISION(2, 14))
QML_NAMED_ELEMENT(TableView)
- QML_ADDED_IN_MINOR_VERSION(12)
+ QML_ADDED_IN_VERSION(2, 12)
QML_ATTACHED(QQuickTableViewAttached)
public:
@@ -136,8 +136,8 @@ Q_SIGNALS:
void modelChanged();
void delegateChanged();
void reuseItemsChanged();
- Q_REVISION(14) void syncViewChanged();
- Q_REVISION(14) void syncDirectionChanged();
+ Q_REVISION(2, 14) void syncViewChanged();
+ Q_REVISION(2, 14) void syncDirectionChanged();
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h
index c629ae0a5d..a3cc39419f 100644
--- a/src/quick/items/qquicktableview_p_p.h
+++ b/src/quick/items/qquicktableview_p_p.h
@@ -91,7 +91,7 @@ private:
Q_DECLARE_PRIVATE(QQuickTableSectionSizeProvider)
};
-class Q_QML_AUTOTEST_EXPORT QQuickTableViewPrivate : public QQuickFlickablePrivate
+class Q_QUICK_PRIVATE_EXPORT QQuickTableViewPrivate : public QQuickFlickablePrivate
{
Q_DECLARE_PUBLIC(QQuickTableView)
@@ -395,7 +395,7 @@ public:
void scheduleRebuildTable(QQuickTableViewPrivate::RebuildOptions options);
- int resolveImportVersion();
+ QTypeRevision resolveImportVersion();
void createWrapperModel();
void initItemCallback(int modelIndex, QObject *item);
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index 2a6337cdb3..c8f3f113dd 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -40,6 +40,9 @@
#include "qquicktext_p.h"
#include "qquicktext_p_p.h"
+#include <private/qqmldebugserviceinterfaces_p.h>
+#include <private/qqmldebugconnector_p.h>
+
#include <QtQuick/private/qsgcontext_p.h>
#include <private/qqmlglobal_p.h>
#include <private/qsgadaptationlayer_p.h>
@@ -1146,6 +1149,10 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline)
elideLayout->setFont(layout.font());
elideLayout->setTextOption(layout.textOption());
+ if (QQmlDebugTranslationService *service
+ = QQmlDebugConnector::service<QQmlDebugTranslationService>()) {
+ elideText = service->foundElidedText(q, layoutText, elideText);
+ }
elideLayout->setText(elideText);
elideLayout->beginLayout();
@@ -1212,7 +1219,7 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal
if (!image->pix) {
QUrl url = q->baseUrl().resolved(image->url);
- image->pix = new QQuickPixmap(qmlEngine(q), url, image->size);
+ image->pix = new QQuickPixmap(qmlEngine(q), url, QRect(), image->size);
if (image->pix->isLoading()) {
image->pix->connectFinished(q, SLOT(imageDownloadFinished()));
if (!extra.isAllocated() || !extra->nbActiveDownloads)
@@ -2642,6 +2649,12 @@ void QQuickText::setLineHeightMode(LineHeightMode mode)
If the text does not fit within the item bounds with the minimum font size
the text will be elided as per the \l elide property.
+
+ If the \l textFormat property is set to \l Text.RichText, this will have no effect at all as the
+ property will be ignored completely. If \l textFormat is set to \l Text.StyledText, then the
+ property will be respected provided there is no font size tags inside the text. If there are
+ font size tags, the property will still respect those. This can cause it to not fully comply with
+ the fontSizeMode setting.
*/
QQuickText::FontSizeMode QQuickText::fontSizeMode() const
@@ -2961,6 +2974,8 @@ void QQuickText::setRenderType(QQuickText::RenderType renderType)
d->updateLayout();
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#if QT_DEPRECATED_SINCE(5, 15)
/*!
\qmlmethod QtQuick::Text::doLayout()
\deprecated
@@ -2972,6 +2987,8 @@ void QQuickText::doLayout()
forceLayout();
}
+#endif
+#endif
/*!
\qmlmethod QtQuick::Text::forceLayout()
\since 5.9
diff --git a/src/quick/items/qquicktext_p.h b/src/quick/items/qquicktext_p.h
index d310db508e..6c04f63ca9 100644
--- a/src/quick/items/qquicktext_p.h
+++ b/src/quick/items/qquicktext_p.h
@@ -90,17 +90,18 @@ class Q_QUICK_PRIVATE_EXPORT QQuickText : public QQuickImplicitSizeItem
Q_PROPERTY(int minimumPointSize READ minimumPointSize WRITE setMinimumPointSize NOTIFY minimumPointSizeChanged)
Q_PROPERTY(FontSizeMode fontSizeMode READ fontSizeMode WRITE setFontSizeMode NOTIFY fontSizeModeChanged)
Q_PROPERTY(RenderType renderType READ renderType WRITE setRenderType NOTIFY renderTypeChanged)
- Q_PROPERTY(QString hoveredLink READ hoveredLink NOTIFY linkHovered REVISION 2)
+ Q_PROPERTY(QString hoveredLink READ hoveredLink NOTIFY linkHovered REVISION(2, 2))
- Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged REVISION 6)
- Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged REVISION 6)
- Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged REVISION 6)
- Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged REVISION 6)
- Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged REVISION 6)
+ Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged REVISION(2, 6))
+ Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged REVISION(2, 6))
+ Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged REVISION(2, 6))
+ Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged REVISION(2, 6))
+ Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged REVISION(2, 6))
- Q_PROPERTY(QJSValue fontInfo READ fontInfo NOTIFY fontInfoChanged REVISION 9)
- Q_PROPERTY(QSizeF advance READ advance NOTIFY contentSizeChanged REVISION 10)
+ Q_PROPERTY(QJSValue fontInfo READ fontInfo NOTIFY fontInfoChanged REVISION(2, 9))
+ Q_PROPERTY(QSizeF advance READ advance NOTIFY contentSizeChanged REVISION(2, 10))
QML_NAMED_ELEMENT(Text)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickText(QQuickItem *parent=nullptr);
@@ -223,15 +224,20 @@ public:
QRectF boundingRect() const override;
QRectF clipRect() const override;
- Q_INVOKABLE void doLayout(); // ### Qt 6: remove
- Q_REVISION(9) Q_INVOKABLE void forceLayout();
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+#if QT_DEPRECATED_SINCE(5, 15)
+ QT_DEPRECATED_X("Use forceLayout() instead")
+ Q_INVOKABLE void doLayout();
+#endif
+#endif
+ Q_REVISION(2, 9) Q_INVOKABLE void forceLayout();
RenderType renderType() const;
void setRenderType(RenderType renderType);
QString hoveredLink() const;
- Q_REVISION(3) Q_INVOKABLE QString linkAt(qreal x, qreal y) const;
+ Q_REVISION(2, 3) Q_INVOKABLE QString linkAt(qreal x, qreal y) const;
qreal padding() const;
void setPadding(qreal padding);
@@ -259,7 +265,7 @@ public:
Q_SIGNALS:
void textChanged(const QString &text);
void linkActivated(const QString &link);
- Q_REVISION(2) void linkHovered(const QString &link);
+ Q_REVISION(2, 2) void linkHovered(const QString &link);
void fontChanged(const QFont &font);
void colorChanged();
void linkColorChanged();
@@ -274,7 +280,7 @@ Q_SIGNALS:
void textFormatChanged(QQuickText::TextFormat textFormat);
void elideModeChanged(QQuickText::TextElideMode mode);
void contentSizeChanged();
- // The next two signals should be marked as Q_REVISION(12). See QTBUG-71247
+ // The next two signals should be marked as Q_REVISION(2, 12). See QTBUG-71247
void contentWidthChanged(qreal contentWidth);
void contentHeightChanged(qreal contentHeight);
@@ -287,12 +293,12 @@ Q_SIGNALS:
void lineLaidOut(QQuickTextLine *line);
void baseUrlChanged();
void renderTypeChanged();
- Q_REVISION(6) void paddingChanged();
- Q_REVISION(6) void topPaddingChanged();
- Q_REVISION(6) void leftPaddingChanged();
- Q_REVISION(6) void rightPaddingChanged();
- Q_REVISION(6) void bottomPaddingChanged();
- Q_REVISION(9) void fontInfoChanged();
+ Q_REVISION(2, 6) void paddingChanged();
+ Q_REVISION(2, 6) void topPaddingChanged();
+ Q_REVISION(2, 6) void leftPaddingChanged();
+ Q_REVISION(2, 6) void rightPaddingChanged();
+ Q_REVISION(2, 6) void bottomPaddingChanged();
+ Q_REVISION(2, 9) void fontInfoChanged();
protected:
QQuickText(QQuickTextPrivate &dd, QQuickItem *parent = nullptr);
@@ -330,9 +336,10 @@ class QQuickTextLine : public QObject
Q_PROPERTY(qreal height READ height WRITE setHeight)
Q_PROPERTY(qreal x READ x WRITE setX)
Q_PROPERTY(qreal y READ y WRITE setY)
- Q_PROPERTY(qreal implicitWidth READ implicitWidth)
- Q_PROPERTY(bool isLast READ isLast)
+ Q_PROPERTY(qreal implicitWidth READ implicitWidth REVISION(2, 15))
+ Q_PROPERTY(bool isLast READ isLast REVISION(2, 15))
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickTextLine();
diff --git a/src/quick/items/qquicktextdocument.h b/src/quick/items/qquicktextdocument.h
index bf9162755c..aadc4ca8c0 100644
--- a/src/quick/items/qquicktextdocument.h
+++ b/src/quick/items/qquicktextdocument.h
@@ -50,6 +50,7 @@ class Q_QUICK_EXPORT QQuickTextDocument : public QObject
{
Q_OBJECT
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickTextDocument(QQuickItem *parent);
diff --git a/src/quick/items/qquicktextedit_p.h b/src/quick/items/qquicktextedit_p.h
index 227d8cbf51..37610ed7e6 100644
--- a/src/quick/items/qquicktextedit_p.h
+++ b/src/quick/items/qquicktextedit_p.h
@@ -94,7 +94,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTextEdit : public QQuickImplicitSizeItem
Q_PROPERTY(bool persistentSelection READ persistentSelection WRITE setPersistentSelection NOTIFY persistentSelectionChanged)
Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin NOTIFY textMarginChanged)
Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints NOTIFY inputMethodHintsChanged)
- Q_PROPERTY(bool selectByKeyboard READ selectByKeyboard WRITE setSelectByKeyboard NOTIFY selectByKeyboardChanged REVISION 1)
+ Q_PROPERTY(bool selectByKeyboard READ selectByKeyboard WRITE setSelectByKeyboard NOTIFY selectByKeyboardChanged REVISION(2, 1))
Q_PROPERTY(bool selectByMouse READ selectByMouse WRITE setSelectByMouse NOTIFY selectByMouseChanged)
Q_PROPERTY(SelectionMode mouseSelectionMode READ mouseSelectionMode WRITE setMouseSelectionMode NOTIFY mouseSelectionModeChanged)
Q_PROPERTY(bool canPaste READ canPaste NOTIFY canPasteChanged)
@@ -103,16 +103,17 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTextEdit : public QQuickImplicitSizeItem
Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged)
Q_PROPERTY(QUrl baseUrl READ baseUrl WRITE setBaseUrl RESET resetBaseUrl NOTIFY baseUrlChanged)
Q_PROPERTY(RenderType renderType READ renderType WRITE setRenderType NOTIFY renderTypeChanged)
- Q_PROPERTY(QQuickTextDocument *textDocument READ textDocument CONSTANT FINAL REVISION 1)
- Q_PROPERTY(QString hoveredLink READ hoveredLink NOTIFY linkHovered REVISION 2)
- Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged REVISION 6)
- Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged REVISION 6)
- Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged REVISION 6)
- Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged REVISION 6)
- Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged REVISION 6)
- Q_PROPERTY(QString preeditText READ preeditText NOTIFY preeditTextChanged REVISION 7)
- Q_PROPERTY(qreal tabStopDistance READ tabStopDistance WRITE setTabStopDistance NOTIFY tabStopDistanceChanged REVISION 10)
+ Q_PROPERTY(QQuickTextDocument *textDocument READ textDocument CONSTANT FINAL REVISION(2, 1))
+ Q_PROPERTY(QString hoveredLink READ hoveredLink NOTIFY linkHovered REVISION(2, 2))
+ Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged REVISION(2, 6))
+ Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged REVISION(2, 6))
+ Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged REVISION(2, 6))
+ Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged REVISION(2, 6))
+ Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged REVISION(2, 6))
+ Q_PROPERTY(QString preeditText READ preeditText NOTIFY preeditTextChanged REVISION(2, 7))
+ Q_PROPERTY(qreal tabStopDistance READ tabStopDistance WRITE setTabStopDistance NOTIFY tabStopDistanceChanged REVISION(2, 10))
QML_NAMED_ELEMENT(TextEdit)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickTextEdit(QQuickItem *parent=nullptr);
@@ -162,7 +163,7 @@ public:
QString text() const;
void setText(const QString &);
- Q_REVISION(7) QString preeditText() const;
+ Q_REVISION(2, 7) QString preeditText() const;
TextFormat textFormat() const;
void setTextFormat(TextFormat format);
@@ -247,7 +248,7 @@ public:
#if QT_CONFIG(im)
QVariant inputMethodQuery(Qt::InputMethodQuery property) const override;
- Q_REVISION(4) Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const;
+ Q_REVISION(2, 4) Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const;
#endif
qreal contentWidth() const;
@@ -277,7 +278,7 @@ public:
QString hoveredLink() const;
- Q_REVISION(3) Q_INVOKABLE QString linkAt(qreal x, qreal y) const;
+ Q_REVISION(2, 3) Q_INVOKABLE QString linkAt(qreal x, qreal y) const;
qreal padding() const;
void setPadding(qreal padding);
@@ -304,7 +305,7 @@ public:
Q_SIGNALS:
void textChanged();
- Q_REVISION(7) void preeditTextChanged();
+ Q_REVISION(2, 7) void preeditTextChanged();
void contentSizeChanged();
void cursorPositionChanged();
void cursorRectangleChanged();
@@ -327,11 +328,11 @@ Q_SIGNALS:
void activeFocusOnPressChanged(bool activeFocusOnPressed);
void persistentSelectionChanged(bool isPersistentSelection);
void textMarginChanged(qreal textMargin);
- Q_REVISION(1) void selectByKeyboardChanged(bool selectByKeyboard);
+ Q_REVISION(2, 1) void selectByKeyboardChanged(bool selectByKeyboard);
void selectByMouseChanged(bool selectByMouse);
void mouseSelectionModeChanged(QQuickTextEdit::SelectionMode mode);
void linkActivated(const QString &link);
- Q_REVISION(2) void linkHovered(const QString &link);
+ Q_REVISION(2, 2) void linkHovered(const QString &link);
void canPasteChanged();
void canUndoChanged();
void canRedoChanged();
@@ -340,13 +341,13 @@ Q_SIGNALS:
void baseUrlChanged();
void inputMethodHintsChanged();
void renderTypeChanged();
- Q_REVISION(6) void editingFinished();
- Q_REVISION(6) void paddingChanged();
- Q_REVISION(6) void topPaddingChanged();
- Q_REVISION(6) void leftPaddingChanged();
- Q_REVISION(6) void rightPaddingChanged();
- Q_REVISION(6) void bottomPaddingChanged();
- Q_REVISION(10) void tabStopDistanceChanged(qreal distance);
+ Q_REVISION(2, 6) void editingFinished();
+ Q_REVISION(2, 6) void paddingChanged();
+ Q_REVISION(2, 6) void topPaddingChanged();
+ Q_REVISION(2, 6) void leftPaddingChanged();
+ Q_REVISION(2, 6) void rightPaddingChanged();
+ Q_REVISION(2, 6) void bottomPaddingChanged();
+ Q_REVISION(2, 10) void tabStopDistanceChanged(qreal distance);
public Q_SLOTS:
void selectAll();
@@ -363,8 +364,8 @@ public Q_SLOTS:
void redo();
void insert(int position, const QString &text);
void remove(int start, int end);
- Q_REVISION(2) void append(const QString &text);
- Q_REVISION(7) void clear();
+ Q_REVISION(2, 2) void append(const QString &text);
+ Q_REVISION(2, 7) void clear();
private Q_SLOTS:
void q_textChanged();
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index 1f6f24e419..b204cb3417 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -4694,6 +4694,18 @@ void QQuickTextInput::clear()
These properties hold the padding around the content. This space is reserved
in addition to the contentWidth and contentHeight.
+
+ The individual padding properties assume the value of the \c padding
+ property unless they are set explicitly. For example, if \c padding is
+ set to \c 4 and \c leftPadding to \c 8, \c 8 will be used as the left
+ padding.
+
+ \note If an explicit width or height is given to a TextInput, care must be
+ taken to ensure it is large enough to accommodate the relevant padding
+ values. For example: if \c topPadding and \c bottomPadding are set to
+ \c 10, but the height of the TextInput is only set to \c 20, the text will
+ not have enough vertical space in which to be rendered, and will appear
+ clipped.
*/
qreal QQuickTextInput::padding() const
{
diff --git a/src/quick/items/qquicktextinput_p.h b/src/quick/items/qquicktextinput_p.h
index 9f7b82b168..234ebc2a0a 100644
--- a/src/quick/items/qquicktextinput_p.h
+++ b/src/quick/items/qquicktextinput_p.h
@@ -93,9 +93,9 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTextInput : public QQuickImplicitSizeItem
Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode NOTIFY echoModeChanged)
Q_PROPERTY(bool activeFocusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY activeFocusOnPressChanged)
Q_PROPERTY(QString passwordCharacter READ passwordCharacter WRITE setPasswordCharacter NOTIFY passwordCharacterChanged)
- Q_PROPERTY(int passwordMaskDelay READ passwordMaskDelay WRITE setPasswordMaskDelay RESET resetPasswordMaskDelay NOTIFY passwordMaskDelayChanged REVISION 4)
+ Q_PROPERTY(int passwordMaskDelay READ passwordMaskDelay WRITE setPasswordMaskDelay RESET resetPasswordMaskDelay NOTIFY passwordMaskDelayChanged REVISION(2, 4))
Q_PROPERTY(QString displayText READ displayText NOTIFY displayTextChanged)
- Q_PROPERTY(QString preeditText READ preeditText NOTIFY preeditTextChanged REVISION 7)
+ Q_PROPERTY(QString preeditText READ preeditText NOTIFY preeditTextChanged REVISION(2, 7))
Q_PROPERTY(bool autoScroll READ autoScroll WRITE setAutoScroll NOTIFY autoScrollChanged)
Q_PROPERTY(bool selectByMouse READ selectByMouse WRITE setSelectByMouse NOTIFY selectByMouseChanged)
Q_PROPERTY(SelectionMode mouseSelectionMode READ mouseSelectionMode WRITE setMouseSelectionMode NOTIFY mouseSelectionModeChanged)
@@ -108,12 +108,13 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTextInput : public QQuickImplicitSizeItem
Q_PROPERTY(qreal contentHeight READ contentHeight NOTIFY contentSizeChanged)
Q_PROPERTY(RenderType renderType READ renderType WRITE setRenderType NOTIFY renderTypeChanged)
- Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged REVISION 6)
- Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged REVISION 6)
- Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged REVISION 6)
- Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged REVISION 6)
- Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged REVISION 6)
+ Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged REVISION(2, 6))
+ Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged REVISION(2, 6))
+ Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged REVISION(2, 6))
+ Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged REVISION(2, 6))
+ Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged REVISION(2, 6))
QML_NAMED_ELEMENT(TextInput)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickTextInput(QQuickItem * parent=nullptr);
@@ -242,7 +243,7 @@ public:
void resetPasswordMaskDelay();
QString displayText() const;
- Q_REVISION(7) QString preeditText() const;
+ Q_REVISION(2, 7) QString preeditText() const;
QQmlComponent* cursorDelegate() const;
void setCursorDelegate(QQmlComponent*);
@@ -269,7 +270,7 @@ public:
#if QT_CONFIG(im)
QVariant inputMethodQuery(Qt::InputMethodQuery property) const override;
- Q_REVISION(4) Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, const QVariant &argument) const;
+ Q_REVISION(2, 4) Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, const QVariant &argument) const;
#endif
QRectF boundingRect() const override;
@@ -319,8 +320,8 @@ Q_SIGNALS:
void selectedTextChanged();
void accepted();
void acceptableInputChanged();
- Q_REVISION(2) void editingFinished();
- Q_REVISION(9) void textEdited();
+ Q_REVISION(2, 2) void editingFinished();
+ Q_REVISION(2, 9) void textEdited();
void colorChanged();
void selectionColorChanged();
void selectedTextColorChanged();
@@ -337,9 +338,9 @@ Q_SIGNALS:
void inputMaskChanged(const QString &inputMask);
void echoModeChanged(QQuickTextInput::EchoMode echoMode);
void passwordCharacterChanged();
- Q_REVISION(4) void passwordMaskDelayChanged(int delay);
+ Q_REVISION(2, 4) void passwordMaskDelayChanged(int delay);
void displayTextChanged();
- Q_REVISION(7) void preeditTextChanged();
+ Q_REVISION(2, 7) void preeditTextChanged();
void activeFocusOnPressChanged(bool activeFocusOnPress);
void autoScrollChanged(bool autoScroll);
void selectByMouseChanged(bool selectByMouse);
@@ -353,11 +354,11 @@ Q_SIGNALS:
void contentSizeChanged();
void inputMethodHintsChanged();
void renderTypeChanged();
- Q_REVISION(6) void paddingChanged();
- Q_REVISION(6) void topPaddingChanged();
- Q_REVISION(6) void leftPaddingChanged();
- Q_REVISION(6) void rightPaddingChanged();
- Q_REVISION(6) void bottomPaddingChanged();
+ Q_REVISION(2, 6) void paddingChanged();
+ Q_REVISION(2, 6) void topPaddingChanged();
+ Q_REVISION(2, 6) void leftPaddingChanged();
+ Q_REVISION(2, 6) void rightPaddingChanged();
+ Q_REVISION(2, 6) void bottomPaddingChanged();
private:
void invalidateFontCaches();
@@ -400,8 +401,8 @@ public Q_SLOTS:
void redo();
void insert(int position, const QString &text);
void remove(int start, int end);
- Q_REVISION(4) void ensureVisible(int position);
- Q_REVISION(7) void clear();
+ Q_REVISION(2, 4) void ensureVisible(int position);
+ Q_REVISION(2, 7) void clear();
private Q_SLOTS:
void selectionChanged();
diff --git a/src/quick/items/qquicktranslate_p.h b/src/quick/items/qquicktranslate_p.h
index aeda6ca589..9832989e73 100644
--- a/src/quick/items/qquicktranslate_p.h
+++ b/src/quick/items/qquicktranslate_p.h
@@ -65,6 +65,7 @@ class Q_AUTOTEST_EXPORT QQuickTranslate : public QQuickTransform
Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged)
Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged)
QML_NAMED_ELEMENT(Translate)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickTranslate(QObject *parent = nullptr);
@@ -97,6 +98,7 @@ class Q_AUTOTEST_EXPORT QQuickScale : public QQuickTransform
Q_PROPERTY(qreal yScale READ yScale WRITE setYScale NOTIFY yScaleChanged)
Q_PROPERTY(qreal zScale READ zScale WRITE setZScale NOTIFY zScaleChanged)
QML_NAMED_ELEMENT(Scale)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickScale(QObject *parent = nullptr);
~QQuickScale();
@@ -135,6 +137,7 @@ class Q_AUTOTEST_EXPORT QQuickRotation : public QQuickTransform
Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged)
Q_PROPERTY(QVector3D axis READ axis WRITE setAxis NOTIFY axisChanged)
QML_NAMED_ELEMENT(Rotation)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickRotation(QObject *parent = nullptr);
~QQuickRotation();
@@ -167,7 +170,7 @@ class Q_AUTOTEST_EXPORT QQuickMatrix4x4 : public QQuickTransform
Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix NOTIFY matrixChanged)
QML_NAMED_ELEMENT(Matrix4x4)
- QML_ADDED_IN_MINOR_VERSION(3)
+ QML_ADDED_IN_VERSION(2, 3)
public:
QQuickMatrix4x4(QObject *parent = nullptr);
~QQuickMatrix4x4();
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 2eee98a738..39f238e4ed 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -78,8 +78,11 @@
#include <private/qqmldebugserviceinterfaces_p.h>
#include <private/qqmldebugconnector_p.h>
#if QT_CONFIG(opengl)
-# include <private/qopenglvertexarrayobject_p.h>
-# include <private/qsgdefaultrendercontext_p.h>
+#include <private/qopenglvertexarrayobject_p.h>
+#include <private/qsgdefaultrendercontext_p.h>
+#include <private/qopengl_p.h>
+#include <QOpenGLContext>
+#include <QOpenGLFramebufferObject>
#endif
#ifndef QT_NO_DEBUG_STREAM
#include <private/qdebug_p.h>
@@ -93,6 +96,7 @@ Q_LOGGING_CATEGORY(DBG_TOUCH, "qt.quick.touch")
Q_LOGGING_CATEGORY(DBG_TOUCH_TARGET, "qt.quick.touch.target")
Q_LOGGING_CATEGORY(DBG_MOUSE, "qt.quick.mouse")
Q_LOGGING_CATEGORY(DBG_MOUSE_TARGET, "qt.quick.mouse.target")
+Q_LOGGING_CATEGORY(lcTablet, "qt.quick.tablet")
Q_LOGGING_CATEGORY(lcWheelTarget, "qt.quick.wheel.target")
Q_LOGGING_CATEGORY(lcGestureTarget, "qt.quick.gesture.target")
Q_LOGGING_CATEGORY(DBG_HOVER_TRACE, "qt.quick.hover.trace")
@@ -547,7 +551,7 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size, const QSize &surfa
else
context->endNextFrame(renderer);
- if (renderer->hasCustomRenderModeWithContinuousUpdate()) {
+ if (renderer && renderer->hasCustomRenderModeWithContinuousUpdate()) {
// For the overdraw visualizer. This update is not urgent so avoid a
// direct update() call, this is only here to keep the overdraw
// visualization box rotating even when the scene is static.
@@ -560,6 +564,7 @@ QQuickWindowPrivate::QQuickWindowPrivate()
, activeFocusItem(nullptr)
#if QT_CONFIG(cursor)
, cursorItem(nullptr)
+ , cursorHandler(nullptr)
#endif
#if QT_CONFIG(quick_draganddrop)
, dragGrabber(nullptr)
@@ -681,10 +686,13 @@ void QQuickWindow::handleApplicationStateChanged(Qt::ApplicationState state)
QQmlListProperty<QObject> QQuickWindowPrivate::data()
{
- return QQmlListProperty<QObject>(q_func(), nullptr, QQuickWindowPrivate::data_append,
- QQuickWindowPrivate::data_count,
- QQuickWindowPrivate::data_at,
- QQuickWindowPrivate::data_clear);
+ return QQmlListProperty<QObject>(q_func(), nullptr,
+ QQuickWindowPrivate::data_append,
+ QQuickWindowPrivate::data_count,
+ QQuickWindowPrivate::data_at,
+ QQuickWindowPrivate::data_clear,
+ QQuickWindowPrivate::data_replace,
+ QQuickWindowPrivate::data_removeLast);
}
static QMouseEvent *touchToMouseEvent(QEvent::Type type, const QTouchEvent::TouchPoint &p, QTouchEvent *event, QQuickItem *item, bool transformNeeded = true)
@@ -1762,6 +1770,10 @@ bool QQuickWindow::event(QEvent *e)
if (d->activeFocusItem)
QCoreApplication::sendEvent(d->activeFocusItem, e);
return true;
+ case QEvent::LanguageChange:
+ if (d->contentItem)
+ QCoreApplication::sendEvent(d->contentItem, e);
+ break;
default:
break;
}
@@ -2118,6 +2130,17 @@ void QQuickWindow::wheelEvent(QWheelEvent *event)
}
#endif // wheelevent
+#if QT_CONFIG(tabletevent)
+/*! \reimp */
+void QQuickWindow::tabletEvent(QTabletEvent *event)
+{
+ Q_D(QQuickWindow);
+ qCDebug(lcTablet) << event;
+ // TODO Qt 6: make sure TabletEnterProximity and TabletLeaveProximity are delivered here
+ d->deliverPointerEvent(d->pointerEventInstance(event));
+}
+#endif // tabletevent
+
bool QQuickWindowPrivate::deliverTouchCancelEvent(QTouchEvent *event)
{
qCDebug(DBG_TOUCH) << event;
@@ -2396,8 +2419,14 @@ QQuickPointerEvent *QQuickWindowPrivate::pointerEventInstance(QQuickPointerDevic
#endif
ev = new QQuickPointerTouchEvent(q, device);
break;
+#if QT_CONFIG(tabletevent)
+ case QQuickPointerDevice::Stylus:
+ case QQuickPointerDevice::Airbrush:
+ case QQuickPointerDevice::Puck:
+ ev = new QQuickPointerTabletEvent(q, device);
+ break;
+#endif
default:
- // TODO tablet event types
break;
}
pointerEventInstances << ev;
@@ -2428,7 +2457,15 @@ QQuickPointerEvent *QQuickWindowPrivate::pointerEventInstance(QEvent *event) con
case QEvent::TouchCancel:
dev = QQuickPointerDevice::touchDevice(static_cast<QTouchEvent *>(event)->device());
break;
- // TODO tablet event types
+#if QT_CONFIG(tabletevent)
+ case QEvent::TabletPress:
+ case QEvent::TabletMove:
+ case QEvent::TabletRelease:
+ case QEvent::TabletEnterProximity:
+ case QEvent::TabletLeaveProximity:
+ dev = QQuickPointerDevice::tabletDevice(static_cast<QTabletEvent *>(event));
+ break;
+#endif
#if QT_CONFIG(gestures)
case QEvent::NativeGesture:
dev = QQuickPointerDevice::touchDevice(static_cast<QNativeGestureEvent *>(event)->device());
@@ -2463,6 +2500,11 @@ void QQuickWindowPrivate::deliverPointerEvent(QQuickPointerEvent *event)
deliverTouchEvent(event->asPointerTouchEvent());
} else {
deliverSinglePointEventUntilAccepted(event);
+ // If any handler got interested in the tablet event, we don't want to receive a synth-mouse event from QtGui
+ // TODO Qt 6: QTabletEvent will be accepted by default, like other events
+ if (event->asPointerTabletEvent() &&
+ (!event->point(0)->passiveGrabbers().isEmpty() || event->point(0)->exclusiveGrabber()))
+ event->setAccepted(true);
}
event->reset(nullptr);
@@ -2967,26 +3009,27 @@ void QQuickWindowPrivate::updateCursor(const QPointF &scenePos)
{
Q_Q(QQuickWindow);
- QQuickItem *oldCursorItem = cursorItem;
- cursorItem = findCursorItem(contentItem, scenePos);
+ auto cursorItemAndHandler = findCursorItemAndHandler(contentItem, scenePos);
- if (cursorItem != oldCursorItem) {
+ if (cursorItem != cursorItemAndHandler.first || cursorHandler != cursorItemAndHandler.second) {
QWindow *renderWindow = QQuickRenderControl::renderWindowFor(q);
QWindow *window = renderWindow ? renderWindow : q;
+ cursorItem = cursorItemAndHandler.first;
+ cursorHandler = cursorItemAndHandler.second;
if (cursorItem)
- window->setCursor(cursorItem->cursor());
+ window->setCursor(QQuickItemPrivate::get(cursorItem)->effectiveCursor(cursorHandler));
else
window->unsetCursor();
}
}
-QQuickItem *QQuickWindowPrivate::findCursorItem(QQuickItem *item, const QPointF &scenePos)
+QPair<QQuickItem*, QQuickPointerHandler*> QQuickWindowPrivate::findCursorItemAndHandler(QQuickItem *item, const QPointF &scenePos) const
{
QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
if (itemPrivate->flags & QQuickItem::ItemClipsChildrenToShape) {
QPointF p = item->mapFromScene(scenePos);
if (!item->contains(p))
- return nullptr;
+ return {nullptr, nullptr};
}
if (itemPrivate->subtreeCursorEnabled) {
@@ -2995,17 +3038,24 @@ QQuickItem *QQuickWindowPrivate::findCursorItem(QQuickItem *item, const QPointF
QQuickItem *child = children.at(ii);
if (!child->isVisible() || !child->isEnabled() || QQuickItemPrivate::get(child)->culled)
continue;
- if (QQuickItem *cursorItem = findCursorItem(child, scenePos))
- return cursorItem;
+ auto ret = findCursorItemAndHandler(child, scenePos);
+ if (ret.first)
+ return ret;
+ }
+ if (itemPrivate->hasCursor || itemPrivate->hasCursorHandler) {
+ QPointF p = item->mapFromScene(scenePos);
+ if (!item->contains(p))
+ return {nullptr, nullptr};
+ if (itemPrivate->hasCursorHandler) {
+ if (auto handler = itemPrivate->effectiveCursorHandler())
+ return {item, handler};
+ }
+ if (itemPrivate->hasCursor)
+ return {item, nullptr};
}
}
- if (itemPrivate->hasCursor) {
- QPointF p = item->mapFromScene(scenePos);
- if (item->contains(p))
- return item;
- }
- return nullptr;
+ return {nullptr, nullptr};
}
#endif
@@ -3248,6 +3298,20 @@ void QQuickWindowPrivate::data_clear(QQmlListProperty<QObject> *property)
itemProperty.clear(&itemProperty);
}
+void QQuickWindowPrivate::data_replace(QQmlListProperty<QObject> *property, int i, QObject *o)
+{
+ QQuickWindow *win = static_cast<QQuickWindow*>(property->object);
+ QQmlListProperty<QObject> itemProperty = QQuickItemPrivate::get(win->contentItem())->data();
+ itemProperty.replace(&itemProperty, i, o);
+}
+
+void QQuickWindowPrivate::data_removeLast(QQmlListProperty<QObject> *property)
+{
+ QQuickWindow *win = static_cast<QQuickWindow*>(property->object);
+ QQmlListProperty<QObject> itemProperty = QQuickItemPrivate::get(win->contentItem())->data();
+ itemProperty.removeLast(&itemProperty);
+}
+
bool QQuickWindowPrivate::isRenderable() const
{
Q_Q(const QQuickWindow);
@@ -4377,7 +4441,7 @@ QQmlIncubationController *QQuickWindow::incubationController() const
OpenGL context is actually created.
QQuickWindow::openglContext() will still return 0 for this window
- until after the QQuickWindow::sceneGraphInitialize() has been
+ until after the QQuickWindow::sceneGraphInitialized() has been
emitted.
\note
@@ -4513,7 +4577,7 @@ QSGTexture *QQuickWindow::createTextureFromImage(const QImage &image, CreateText
}
-
+#if QT_DEPRECATED_SINCE(5, 15)
/*!
Creates a new QSGTexture object from an existing OpenGL texture \a id and \a size.
@@ -4535,6 +4599,8 @@ QSGTexture *QQuickWindow::createTextureFromImage(const QImage &image, CreateText
\note This function has no effect when running on the RHI graphics
abstraction. Use createTextureFromNativeObject() instead.
+ \obsolete
+
\sa sceneGraphInitialized(), QSGTexture
*/
QSGTexture *QQuickWindow::createTextureFromId(uint id, const QSize &size, CreateTextureOptions options) const
@@ -4561,6 +4627,7 @@ QSGTexture *QQuickWindow::createTextureFromId(uint id, const QSize &size, Create
#endif
return nullptr;
}
+#endif
/*!
\enum QQuickWindow::NativeObjectType
diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h
index 56d50cec2a..bba8c014c8 100644
--- a/src/quick/items/qquickwindow.h
+++ b/src/quick/items/qquickwindow.h
@@ -43,7 +43,7 @@
#include <QtQuick/qtquickglobal.h>
#include <QtQuick/qsgrendererinterface.h>
#include <QtCore/qmetatype.h>
-#include <QtGui/qopengl.h>
+#include <qopengl.h>
#include <QtGui/qwindow.h>
#include <QtGui/qevent.h>
#include <QtQml/qqml.h>
@@ -74,7 +74,7 @@ class Q_QUICK_EXPORT QQuickWindow : public QWindow
Q_PRIVATE_PROPERTY(QQuickWindow::d_func(), QQmlListProperty<QObject> data READ data DESIGNABLE false)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
Q_PROPERTY(QQuickItem* contentItem READ contentItem CONSTANT)
- Q_PROPERTY(QQuickItem* activeFocusItem READ activeFocusItem NOTIFY activeFocusItemChanged REVISION 1)
+ Q_PROPERTY(QQuickItem* activeFocusItem READ activeFocusItem NOTIFY activeFocusItemChanged REVISION(2, 1))
Q_CLASSINFO("DefaultProperty", "data")
Q_DECLARE_PRIVATE(QQuickWindow)
public:
@@ -157,7 +157,12 @@ public:
// Scene graph specific functions
QSGTexture *createTextureFromImage(const QImage &image) const;
QSGTexture *createTextureFromImage(const QImage &image, CreateTextureOptions options) const;
+
+#if QT_DEPRECATED_SINCE(5, 15)
+ QT_DEPRECATED_X("Use createTextureFromNativeObject() instead")
QSGTexture *createTextureFromId(uint id, const QSize &size, CreateTextureOptions options = CreateTextureOption()) const;
+#endif
+
QSGTexture *createTextureFromNativeObject(NativeObjectType type,
const void *nativeObjectPtr,
int nativeLayout,
@@ -201,23 +206,23 @@ public:
Q_SIGNALS:
void frameSwapped();
- Q_REVISION(2) void openglContextCreated(QOpenGLContext *context);
+ Q_REVISION(2, 2) void openglContextCreated(QOpenGLContext *context);
void sceneGraphInitialized();
void sceneGraphInvalidated();
void beforeSynchronizing();
- Q_REVISION(2) void afterSynchronizing();
+ Q_REVISION(2, 2) void afterSynchronizing();
void beforeRendering();
void afterRendering();
- Q_REVISION(2) void afterAnimating();
- Q_REVISION(2) void sceneGraphAboutToStop();
+ Q_REVISION(2, 2) void afterAnimating();
+ Q_REVISION(2, 2) void sceneGraphAboutToStop();
- Q_REVISION(1) void closing(QQuickCloseEvent *close);
+ Q_REVISION(2, 1) void closing(QQuickCloseEvent *close);
void colorChanged(const QColor &);
- Q_REVISION(1) void activeFocusItemChanged();
- Q_REVISION(2) void sceneGraphError(QQuickWindow::SceneGraphError error, const QString &message);
+ Q_REVISION(2, 1) void activeFocusItemChanged();
+ Q_REVISION(2, 2) void sceneGraphError(QQuickWindow::SceneGraphError error, const QString &message);
- Q_REVISION(14) void beforeRenderPassRecording();
- Q_REVISION(14) void afterRenderPassRecording();
+ Q_REVISION(2, 14) void beforeRenderPassRecording();
+ Q_REVISION(2, 14) void afterRenderPassRecording();
public Q_SLOTS:
void update();
@@ -247,6 +252,9 @@ protected:
#if QT_CONFIG(wheelevent)
void wheelEvent(QWheelEvent *) override;
#endif
+#if QT_CONFIG(tabletevent)
+ void tabletEvent(QTabletEvent *) override;
+#endif
private Q_SLOTS:
void maybeUpdate();
diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h
index ef10ba3fe8..8e4ecbc178 100644
--- a/src/quick/items/qquickwindow_p.h
+++ b/src/quick/items/qquickwindow_p.h
@@ -62,9 +62,6 @@
#include <QtCore/qwaitcondition.h>
#include <QtCore/qrunnable.h>
#include <private/qwindow_p.h>
-#include <private/qopengl_p.h>
-#include <qopenglcontext.h>
-#include <QtGui/qopenglframebufferobject.h>
#include <QtGui/qevent.h>
#include <QtGui/qstylehints.h>
#include <QtGui/qguiapplication.h>
@@ -88,7 +85,7 @@ class QRhiRenderBuffer;
class QRhiRenderPassDescriptor;
//Make it easy to identify and customize the root item if needed
-class QQuickRootItem : public QQuickItem
+class Q_QUICK_PRIVATE_EXPORT QQuickRootItem : public QQuickItem
{
Q_OBJECT
public:
@@ -134,6 +131,7 @@ public:
// Keeps track of the item currently receiving mouse events
#if QT_CONFIG(cursor)
QQuickItem *cursorItem;
+ QQuickPointerHandler *cursorHandler;
#endif
#if QT_CONFIG(quick_draganddrop)
QQuickDragGrabber *dragGrabber;
@@ -197,7 +195,7 @@ public:
#endif
#if QT_CONFIG(cursor)
void updateCursor(const QPointF &scenePos);
- QQuickItem *findCursorItem(QQuickItem *item, const QPointF &scenePos);
+ QPair<QQuickItem*, QQuickPointerHandler*> findCursorItemAndHandler(QQuickItem *item, const QPointF &scenePos) const;
#endif
QList<QQuickItem*> hoverItems;
@@ -298,6 +296,8 @@ public:
static int data_count(QQmlListProperty<QObject> *);
static QObject *data_at(QQmlListProperty<QObject> *, int);
static void data_clear(QQmlListProperty<QObject> *);
+ static void data_replace(QQmlListProperty<QObject> *, int, QObject *);
+ static void data_removeLast(QQmlListProperty<QObject> *);
static void contextCreationFailureMessage(const QSurfaceFormat &format,
QString *translatedMessage,
diff --git a/src/quick/items/qquickwindowmodule_p.h b/src/quick/items/qquickwindowmodule_p.h
index d0bf5c29b3..2f05b987d1 100644
--- a/src/quick/items/qquickwindowmodule_p.h
+++ b/src/quick/items/qquickwindowmodule_p.h
@@ -67,7 +67,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickWindowQmlImpl : public QQuickWindow, public Q
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged)
- Q_PROPERTY(QObject *screen READ screen WRITE setScreen NOTIFY screenChanged REVISION 3)
+ Q_PROPERTY(QObject *screen READ screen WRITE setScreen NOTIFY screenChanged REVISION(2, 3))
QML_ATTACHED(QQuickWindowAttached)
public:
@@ -84,7 +84,7 @@ public:
Q_SIGNALS:
void visibleChanged(bool arg);
void visibilityChanged(QWindow::Visibility visibility);
- Q_REVISION(3) void screenChanged();
+ Q_REVISION(2, 3) void screenChanged();
protected:
void classBegin() override;
diff --git a/src/quick/qtquickglobal_p.h b/src/quick/qtquickglobal_p.h
index f6376a6d17..80e59563c7 100644
--- a/src/quick/qtquickglobal_p.h
+++ b/src/quick/qtquickglobal_p.h
@@ -61,6 +61,8 @@
#define Q_QUICK_PRIVATE_EXPORT Q_QUICK_EXPORT
+void Q_QUICK_PRIVATE_EXPORT qml_register_types_QtQuick();
+
QT_BEGIN_NAMESPACE
void QQuick_initializeProviders();
diff --git a/src/quick/quick.pro b/src/quick/quick.pro
index 6db2ae884e..77517a45e0 100644
--- a/src/quick/quick.pro
+++ b/src/quick/quick.pro
@@ -3,8 +3,10 @@ TARGET = QtQuick
QT = core-private gui-private qml-private qmlmodels-private
qtConfig(qml-network): \
QT_PRIVATE += network
-qtConfig(opengl): \
+qtConfig(opengl) {
QT_PRIVATE += opengl-private
+ QT += opengl
+}
TRACEPOINT_PROVIDER = $$PWD/qtquick.tracepoints
CONFIG += qt_tracepoints
@@ -23,13 +25,10 @@ exists("qqml_enable_gcov") {
QMAKE_DOCS = $$PWD/doc/qtquick.qdocconf
-ANDROID_LIB_DEPENDENCIES = \
- lib/libQt5QuickParticles.so
MODULE_PLUGIN_TYPES += \
scenegraph
ANDROID_BUNDLED_FILES += \
- qml \
- lib/libQt5QuickParticles.so
+ qml
include(util/util.pri)
include(scenegraph/scenegraph.pri)
@@ -56,5 +55,5 @@ load(qt_module)
QMLTYPES_FILENAME = plugins.qmltypes
QMLTYPES_INSTALL_DIR = $$[QT_INSTALL_QML]/QtQuick
QML_IMPORT_NAME = QtQuick
-IMPORT_VERSION = 2.15
+QML_IMPORT_VERSION = $$QT_VERSION
CONFIG += qmltypes install_qmltypes install_metatypes
diff --git a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp
index b59d490250..45d7a65555 100644
--- a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp
+++ b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp
@@ -136,12 +136,12 @@ Texture::Texture(Atlas *atlas, const QRect &textureRect, const QByteArray &data,
{
float w = atlas->size().width();
float h = atlas->size().height();
- QRect nopad = atlasSubRect();
+ const QRect &r = atlasSubRect();
// offset by half-pixel to prevent bleeding when scaling
- m_texture_coords_rect = QRectF((nopad.x() + .5) / w,
- (nopad.y() + .5) / h,
- (nopad.width() - 1.) / w,
- (nopad.height() - 1.) / h);
+ m_texture_coords_rect = QRectF((r.x() + .5) / w,
+ (r.y() + .5) / h,
+ (size.width() - 1.) / w,
+ (size.height() - 1.) / h);
}
Texture::~Texture()
@@ -151,7 +151,7 @@ Texture::~Texture()
bool Texture::hasAlphaChannel() const
{
- return QSGCompressedTexture::formatIsOpaque(static_cast<Atlas*>(m_atlas)->format());
+ return !QSGCompressedTexture::formatIsOpaque(static_cast<Atlas*>(m_atlas)->format());
}
QSGTexture *Texture::removedFromAtlas() const
diff --git a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture_p.h b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture_p.h
index 78051778f5..aec7dbf976 100644
--- a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture_p.h
+++ b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture_p.h
@@ -53,7 +53,7 @@
#include <QtCore/QSize>
-#include <QtGui/qopengl.h>
+#include <qopengl.h>
#include <QtQuick/QSGTexture>
#include <QtQuick/private/qsgareaallocator_p.h>
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
index 5310e76dae..f9e6ba03a8 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
@@ -138,6 +138,7 @@ struct QMatrix4x4_Accessor
static bool isScale(const QMatrix4x4 &m) { return ((const QMatrix4x4_Accessor &) m).flagBits <= 0x2; }
static bool is2DSafe(const QMatrix4x4 &m) { return ((const QMatrix4x4_Accessor &) m).flagBits < 0x8; }
};
+Q_STATIC_ASSERT(sizeof(QMatrix4x4_Accessor) == sizeof(QMatrix4x4));
const float OPAQUE_LIMIT = 0.999f;
@@ -480,8 +481,6 @@ Updater::Updater(Renderer *r)
m_roots.add(0);
m_combined_matrix_stack.add(&m_identityMatrix);
m_rootMatrices.add(m_identityMatrix);
-
- Q_ASSERT(sizeof(QMatrix4x4_Accessor) == sizeof(QMatrix4x4));
}
void Updater::updateStates(QSGNode *n)
diff --git a/src/quick/scenegraph/coreapi/qsggeometry.h b/src/quick/scenegraph/coreapi/qsggeometry.h
index d17915a842..9c60876597 100644
--- a/src/quick/scenegraph/coreapi/qsggeometry.h
+++ b/src/quick/scenegraph/coreapi/qsggeometry.h
@@ -41,7 +41,7 @@
#define QSGGEOMETRY_H
#include <QtQuick/qtquickglobal.h>
-#include <QtGui/qopengl.h>
+#include <qopengl.h>
#include <QtCore/QRectF>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp b/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp
index d614f9be4c..9049dd5826 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp
+++ b/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp
@@ -44,8 +44,8 @@
# include <private/qsgshadersourcebuilder_p.h>
# include <private/qsgdefaultcontext_p.h>
# include <private/qsgdefaultrendercontext_p.h>
-# include <QtGui/QOpenGLFunctions>
-# include <QtGui/QOpenGLContext>
+# include <QOpenGLFunctions>
+# include <QOpenGLContext>
#endif
QT_BEGIN_NAMESPACE
diff --git a/src/quick/scenegraph/coreapi/qsgmaterialshader.h b/src/quick/scenegraph/coreapi/qsgmaterialshader.h
index d7ee23384f..6783b3f890 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterialshader.h
+++ b/src/quick/scenegraph/coreapi/qsgmaterialshader.h
@@ -42,7 +42,7 @@
#include <QtQuick/qtquickglobal.h>
#if QT_CONFIG(opengl)
-# include <QtGui/qopenglshaderprogram.h>
+# include <qopenglshaderprogram.h>
#endif
#include <QtGui/QMatrix4x4>
#include <QtCore/QRect>
diff --git a/src/quick/scenegraph/coreapi/qsgrenderer.cpp b/src/quick/scenegraph/coreapi/qsgrenderer.cpp
index 90090e1cc0..cd16014d41 100644
--- a/src/quick/scenegraph/coreapi/qsgrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgrenderer.cpp
@@ -40,9 +40,9 @@
#include "qsgrenderer_p.h"
#include "qsgnodeupdater_p.h"
#if QT_CONFIG(opengl)
-# include <QtGui/QOpenGLFramebufferObject>
-# include <QtGui/QOpenGLContext>
-# include <QtGui/QOpenGLFunctions>
+# include <QOpenGLFramebufferObject>
+# include <QOpenGLContext>
+# include <QOpenGLFunctions>
#endif
#include <private/qquickprofiler_p.h>
#include <qtquick_tracepoints_p.h>
diff --git a/src/quick/scenegraph/coreapi/qsgtexture.cpp b/src/quick/scenegraph/coreapi/qsgtexture.cpp
index 715633fdba..486fe50190 100644
--- a/src/quick/scenegraph/coreapi/qsgtexture.cpp
+++ b/src/quick/scenegraph/coreapi/qsgtexture.cpp
@@ -39,8 +39,8 @@
#include "qsgtexture_p.h"
#if QT_CONFIG(opengl)
-# include <QtGui/qopenglcontext.h>
-# include <QtGui/qopenglfunctions.h>
+# include <qopenglcontext.h>
+# include <qopenglfunctions.h>
#endif
#include <private/qqmlglobal_p.h>
#include <private/qsgmaterialshader_p.h>
diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp
index eab0369be7..e0d9d5db68 100644
--- a/src/quick/scenegraph/qsgadaptationlayer.cpp
+++ b/src/quick/scenegraph/qsgadaptationlayer.cpp
@@ -329,7 +329,7 @@ void QSGDistanceFieldGlyphCache::updateRhiTexture(QRhiTexture *oldTex, QRhiTextu
}
#if defined(QSG_DISTANCEFIELD_CACHE_DEBUG)
-#include <QtGui/qopenglfunctions.h>
+#include <qopenglfunctions.h>
void QSGDistanceFieldGlyphCache::saveTexture(GLuint textureId, int width, int height) const
{
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.h b/src/quick/scenegraph/qsgdefaultglyphnode_p.h
index 4cff2d3d24..f70d51d1ee 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.h
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.h
@@ -53,7 +53,6 @@
#include <private/qsgadaptationlayer_p.h>
#include <private/qsgbasicglyphnode_p.h>
-#include <qlinkedlist.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp b/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp
index 500d4e6e95..167d2b01dd 100644
--- a/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp
@@ -41,7 +41,7 @@
#include <private/qsgdefaultrendercontext_p.h>
#include <private/qsgmaterialshader_p.h>
#include <private/qsgtexturematerial_p.h>
-#include <QtGui/qopenglfunctions.h>
+#include <qopenglfunctions.h>
#include <QtCore/qmath.h>
#include <QtGui/private/qrhi_p.h>
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
index e8e9f76d04..a25daa6070 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
@@ -39,7 +39,7 @@
#include "qsgdistancefieldglyphnode_p_p.h"
#include "qsgrhidistancefieldglyphcache_p.h"
-#include <QtGui/qopenglfunctions.h>
+#include <qopenglfunctions.h>
#include <QtGui/qsurface.h>
#include <QtGui/qwindow.h>
#include <qmath.h>
diff --git a/src/quick/scenegraph/qsgopengldistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgopengldistancefieldglyphcache.cpp
index fc8ec25053..2f9b1e4ce6 100644
--- a/src/quick/scenegraph/qsgopengldistancefieldglyphcache.cpp
+++ b/src/quick/scenegraph/qsgopengldistancefieldglyphcache.cpp
@@ -54,7 +54,7 @@
#if !defined(QT_OPENGL_ES_2)
-#include <QtGui/qopenglfunctions_3_2_core.h>
+#include <qopenglfunctions_3_2_core.h>
#endif
QT_BEGIN_NAMESPACE
diff --git a/src/quick/scenegraph/qsgopengldistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgopengldistancefieldglyphcache_p.h
index e78e735b6f..2e7b5baae2 100644
--- a/src/quick/scenegraph/qsgopengldistancefieldglyphcache_p.h
+++ b/src/quick/scenegraph/qsgopengldistancefieldglyphcache_p.h
@@ -52,7 +52,7 @@
//
#include "qsgadaptationlayer_p.h"
-#include <QtGui/qopenglfunctions.h>
+#include <qopenglfunctions.h>
#include <qopenglshaderprogram.h>
#include <qopenglbuffer.h>
#include <qopenglvertexarrayobject.h>
diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp
index 9194d3e730..cf30cb3f9a 100644
--- a/src/quick/scenegraph/qsgrhisupport.cpp
+++ b/src/quick/scenegraph/qsgrhisupport.cpp
@@ -157,6 +157,8 @@ void QSGRhiSupport::applySettings()
} else if (rhiBackend == QByteArrayLiteral("null")) {
m_rhiBackend = QRhi::Null;
} else {
+ if (!rhiBackend.isEmpty())
+ qWarning("Unknown key \"%s\" for QSG_RHI_BACKEND, falling back to default backend.", qPrintable(rhiBackend));
#if defined(Q_OS_WIN)
m_rhiBackend = QRhi::D3D11;
#elif defined(Q_OS_MACOS) || defined(Q_OS_IOS)
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
index 4777f46f0a..9b288029b4 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp
+++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
@@ -660,6 +660,11 @@ void QSGRenderThread::sync(bool inExpose, bool inGrab)
qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- window has bad size, sync aborted");
}
+ // Two special cases: For grabs we do not care about blocking the gui
+ // (main) thread. When this is from an expose, we will keep locked until
+ // the frame is rendered (submitted), so in that case waking happens later
+ // in syncAndRender(). Otherwise, wake now and let the main thread go on
+ // while we render.
if (!inExpose && !inGrab) {
qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- sync complete, waking Gui");
waitCondition.wakeOne();
@@ -756,13 +761,11 @@ void QSGRenderThread::syncAndRender(QImage *grabImage)
QCoreApplication::postEvent(window, new QEvent(QEvent::Type(QQuickWindowPrivate::FullUpdateRequest)));
// Before returning we need to ensure the same wake up logic that
// would have happened if beginFrame() had suceeded.
- if (exposeRequested) {
+ if (syncRequested && !grabRequested) {
+ // Lock like sync() would do. Note that exposeRequested always includes syncRequested.
qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- bailing out due to failed beginFrame, wake Gui");
- waitCondition.wakeOne();
- mutex.unlock();
- } else if (syncRequested && !grabRequested) {
- qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- bailing out due to failed beginFrame, wake Gui like sync would do");
mutex.lock();
+ // Go ahead with waking because we will return right after this.
waitCondition.wakeOne();
mutex.unlock();
}
@@ -885,7 +888,8 @@ void QSGRenderThread::syncAndRender(QImage *grabImage)
// has started rendering with a bad window, causing makeCurrent to
// fail or if the window has a bad size.
if (exposeRequested) {
- qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- wake Gui after initial expose");
+ // With expose sync() did not wake gui, do it now.
+ qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- wake Gui after expose");
waitCondition.wakeOne();
mutex.unlock();
}
diff --git a/src/quick/scenegraph/util/qsgengine.cpp b/src/quick/scenegraph/util/qsgengine.cpp
index 4880d98871..13c97e8615 100644
--- a/src/quick/scenegraph/util/qsgengine.cpp
+++ b/src/quick/scenegraph/util/qsgengine.cpp
@@ -45,7 +45,7 @@
#include <private/qsgplaintexture_p.h>
#if QT_CONFIG(opengl)
-# include <QtGui/QOpenGLContext>
+# include <QOpenGLContext>
# include <private/qsgdefaultrendercontext_p.h>
#endif
diff --git a/src/quick/scenegraph/util/qsgopenglatlastexture_p.h b/src/quick/scenegraph/util/qsgopenglatlastexture_p.h
index f8dd7cdf02..379c4c7fff 100644
--- a/src/quick/scenegraph/util/qsgopenglatlastexture_p.h
+++ b/src/quick/scenegraph/util/qsgopenglatlastexture_p.h
@@ -53,7 +53,7 @@
#include <QtCore/QSize>
-#include <QtGui/qopengl.h>
+#include <qopengl.h>
#include <QtQuick/QSGTexture>
#include <QtQuick/private/qsgplaintexture_p.h>
diff --git a/src/quick/scenegraph/util/qsgshadersourcebuilder.cpp b/src/quick/scenegraph/util/qsgshadersourcebuilder.cpp
index 93fc213f2e..77fded6c21 100644
--- a/src/quick/scenegraph/util/qsgshadersourcebuilder.cpp
+++ b/src/quick/scenegraph/util/qsgshadersourcebuilder.cpp
@@ -39,8 +39,8 @@
#include "qsgshadersourcebuilder_p.h"
-#include <QtGui/qopenglcontext.h>
-#include <QtGui/qopenglshaderprogram.h>
+#include <qopenglcontext.h>
+#include <qopenglshaderprogram.h>
#include <QtCore/qdebug.h>
#include <QtCore/qfile.h>
diff --git a/src/quick/scenegraph/util/qsgtexturematerial.cpp b/src/quick/scenegraph/util/qsgtexturematerial.cpp
index 67b8748119..b4ac0c4d1d 100644
--- a/src/quick/scenegraph/util/qsgtexturematerial.cpp
+++ b/src/quick/scenegraph/util/qsgtexturematerial.cpp
@@ -40,8 +40,8 @@
#include "qsgtexturematerial_p.h"
#include <private/qsgtexture_p.h>
#if QT_CONFIG(opengl)
-# include <QtGui/qopenglshaderprogram.h>
-# include <QtGui/qopenglfunctions.h>
+# include <qopenglshaderprogram.h>
+# include <qopenglfunctions.h>
#endif
#include <QtGui/private/qrhi_p.h>
diff --git a/src/quick/util/qquickanimation_p.h b/src/quick/util/qquickanimation_p.h
index 7bad9d50c4..b86533eb3f 100644
--- a/src/quick/util/qquickanimation_p.h
+++ b/src/quick/util/qquickanimation_p.h
@@ -81,6 +81,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickAbstractAnimation : public QObject, public QQ
Q_CLASSINFO("DefaultMethod", "start()")
QML_NAMED_ELEMENT(Animation)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("Animation is an abstract class")
public:
@@ -129,7 +130,7 @@ Q_SIGNALS:
void pausedChanged(bool);
void alwaysRunToEndChanged(bool);
void loopCountChanged(int);
- Q_REVISION(12) void finished();
+ Q_REVISION(2, 12) void finished();
public Q_SLOTS:
void restart();
@@ -169,6 +170,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPauseAnimation : public QQuickAbstractAnimati
Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
QML_NAMED_ELEMENT(PauseAnimation)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickPauseAnimation(QObject *parent=nullptr);
@@ -196,6 +198,7 @@ class QQuickScriptAction : public QQuickAbstractAnimation
Q_PROPERTY(QQmlScriptString script READ script WRITE setScript)
Q_PROPERTY(QString scriptName READ stateChangeScriptName WRITE setStateChangeScriptName)
QML_NAMED_ELEMENT(ScriptAction)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickScriptAction(QObject *parent=nullptr);
@@ -227,6 +230,7 @@ class QQuickPropertyAction : public QQuickAbstractAnimation
Q_PROPERTY(QQmlListProperty<QObject> exclude READ exclude)
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
QML_NAMED_ELEMENT(PropertyAction)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickPropertyAction(QObject *parent=nullptr);
@@ -276,6 +280,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPropertyAnimation : public QQuickAbstractAnim
Q_PROPERTY(QQmlListProperty<QObject> targets READ targets)
Q_PROPERTY(QQmlListProperty<QObject> exclude READ exclude)
QML_NAMED_ELEMENT(PropertyAnimation)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickPropertyAnimation(QObject *parent=nullptr);
@@ -332,6 +337,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickColorAnimation : public QQuickPropertyAnimati
Q_PROPERTY(QColor from READ from WRITE setFrom)
Q_PROPERTY(QColor to READ to WRITE setTo)
QML_NAMED_ELEMENT(ColorAnimation)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickColorAnimation(QObject *parent=nullptr);
@@ -352,6 +358,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickNumberAnimation : public QQuickPropertyAnimat
Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged)
Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged)
QML_NAMED_ELEMENT(NumberAnimation)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickNumberAnimation(QObject *parent=nullptr);
@@ -378,6 +385,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickVector3dAnimation : public QQuickPropertyAnim
Q_PROPERTY(QVector3D from READ from WRITE setFrom NOTIFY fromChanged)
Q_PROPERTY(QVector3D to READ to WRITE setTo NOTIFY toChanged)
QML_NAMED_ELEMENT(Vector3dAnimation)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickVector3dAnimation(QObject *parent=nullptr);
@@ -400,6 +408,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickRotationAnimation : public QQuickPropertyAnim
Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged)
Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
QML_NAMED_ELEMENT(RotationAnimation)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickRotationAnimation(QObject *parent=nullptr);
@@ -445,6 +454,7 @@ class QQuickSequentialAnimation : public QQuickAnimationGroup
Q_OBJECT
Q_DECLARE_PRIVATE(QQuickAnimationGroup)
QML_NAMED_ELEMENT(SequentialAnimation)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickSequentialAnimation(QObject *parent=nullptr);
@@ -463,6 +473,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickParallelAnimation : public QQuickAnimationGro
Q_OBJECT
Q_DECLARE_PRIVATE(QQuickAnimationGroup)
QML_NAMED_ELEMENT(ParallelAnimation)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickParallelAnimation(QObject *parent=nullptr);
diff --git a/src/quick/util/qquickanimationcontroller_p.h b/src/quick/util/qquickanimationcontroller_p.h
index da6df6038a..de308735ef 100644
--- a/src/quick/util/qquickanimationcontroller_p.h
+++ b/src/quick/util/qquickanimationcontroller_p.h
@@ -65,6 +65,7 @@ class Q_AUTOTEST_EXPORT QQuickAnimationController : public QObject, public QQmlP
Q_DECLARE_PRIVATE(QQuickAnimationController)
Q_CLASSINFO("DefaultProperty", "animation")
QML_NAMED_ELEMENT(AnimationController)
+ QML_ADDED_IN_VERSION(2, 0)
Q_PROPERTY(qreal progress READ progress WRITE setProgress NOTIFY progressChanged)
Q_PROPERTY(QQuickAbstractAnimation *animation READ animation WRITE setAnimation NOTIFY animationChanged)
diff --git a/src/quick/util/qquickanimator_p.h b/src/quick/util/qquickanimator_p.h
index 9f7aaafcb0..0bcf4c40a4 100644
--- a/src/quick/util/qquickanimator_p.h
+++ b/src/quick/util/qquickanimator_p.h
@@ -70,7 +70,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickAnimator : public QQuickAbstractAnimation
Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged)
QML_NAMED_ELEMENT(Animator)
- QML_ADDED_IN_MINOR_VERSION(2)
+ QML_ADDED_IN_VERSION(2, 2)
QML_UNCREATABLE("Animator is an abstract class")
public:
@@ -114,7 +114,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickScaleAnimator : public QQuickAnimator
{
Q_OBJECT
QML_NAMED_ELEMENT(ScaleAnimator)
- QML_ADDED_IN_MINOR_VERSION(2)
+ QML_ADDED_IN_VERSION(2, 2)
public:
QQuickScaleAnimator(QObject *parent = nullptr);
protected:
@@ -126,7 +126,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickXAnimator : public QQuickAnimator
{
Q_OBJECT
QML_NAMED_ELEMENT(XAnimator)
- QML_ADDED_IN_MINOR_VERSION(2)
+ QML_ADDED_IN_VERSION(2, 2)
public:
QQuickXAnimator(QObject *parent = nullptr);
protected:
@@ -138,7 +138,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickYAnimator : public QQuickAnimator
{
Q_OBJECT
QML_NAMED_ELEMENT(YAnimator)
- QML_ADDED_IN_MINOR_VERSION(2)
+ QML_ADDED_IN_VERSION(2, 2)
public:
QQuickYAnimator(QObject *parent = nullptr);
protected:
@@ -150,7 +150,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickOpacityAnimator : public QQuickAnimator
{
Q_OBJECT
QML_NAMED_ELEMENT(OpacityAnimator)
- QML_ADDED_IN_MINOR_VERSION(2)
+ QML_ADDED_IN_VERSION(2, 2)
public:
QQuickOpacityAnimator(QObject *parent = nullptr);
protected:
@@ -165,7 +165,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickRotationAnimator : public QQuickAnimator
Q_DECLARE_PRIVATE(QQuickRotationAnimator)
Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
QML_NAMED_ELEMENT(RotationAnimator)
- QML_ADDED_IN_MINOR_VERSION(2)
+ QML_ADDED_IN_VERSION(2, 2)
public:
enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise };
@@ -192,7 +192,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickUniformAnimator : public QQuickAnimator
Q_DECLARE_PRIVATE(QQuickUniformAnimator)
Q_PROPERTY(QString uniform READ uniform WRITE setUniform NOTIFY uniformChanged)
QML_NAMED_ELEMENT(UniformAnimator)
- QML_ADDED_IN_MINOR_VERSION(2)
+ QML_ADDED_IN_VERSION(2, 2)
public:
QQuickUniformAnimator(QObject *parent = nullptr);
diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp
index 0112a4b337..7b6b8bc878 100644
--- a/src/quick/util/qquickanimatorjob.cpp
+++ b/src/quick/util/qquickanimatorjob.cpp
@@ -48,6 +48,7 @@
# include <private/qquickopenglshadereffectnode_p.h>
# include <private/qquickopenglshadereffect_p.h>
# include <private/qquickshadereffect_p.h>
+# include <QOpenGLContext>
#endif
#include <private/qanimationgroupjob_p.h>
diff --git a/src/quick/util/qquickapplication_p.h b/src/quick/util/qquickapplication_p.h
index b0eb6fa604..a740067bf3 100644
--- a/src/quick/util/qquickapplication_p.h
+++ b/src/quick/util/qquickapplication_p.h
@@ -72,6 +72,7 @@ class Q_AUTOTEST_EXPORT QQuickApplication : public QQmlApplication
Q_PROPERTY(QQmlListProperty<QQuickScreenInfo> screens READ screens NOTIFY screensChanged)
QML_NAMED_ELEMENT(Application)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("Application is an abstract class.")
public:
diff --git a/src/quick/util/qquickbehavior.cpp b/src/quick/util/qquickbehavior.cpp
index eee8562a2a..ceda5589b2 100644
--- a/src/quick/util/qquickbehavior.cpp
+++ b/src/quick/util/qquickbehavior.cpp
@@ -185,6 +185,80 @@ QVariant QQuickBehavior::targetValue() const
return d->targetValue;
}
+/*!
+ \readonly
+ \qmlpropertygroup QtQuick::Behavior::targetProperty
+ \qmlproperty string QtQuick::Behavior::targetProperty.name
+ \qmlproperty Object QtQuick::Behavior::targetProperty.object
+
+ \table
+ \header
+ \li Property
+ \li Description
+ \row
+ \li name
+ \li This property holds the name of the property being controlled by this Behavior.
+ \row
+ \li object
+ \li This property holds the object of the property being controlled by this Behavior.
+ \endtable
+
+ This property can be used to define custom behaviors based on the name or the object of
+ the property being controlled.
+
+ The following example defines a Behavior fading out and fading in its target object
+ when the property it controls changes:
+ \qml
+ // FadeBehavior.qml
+ import QtQuick 2.15
+
+ Behavior {
+ id: root
+ property Item fadeTarget: targetProperty.object
+ SequentialAnimation {
+ NumberAnimation {
+ target: root.fadeTarget
+ property: "opacity"
+ to: 0
+ easing.type: Easing.InQuad
+ }
+ PropertyAction { } // actually change the controlled property between the 2 other animations
+ NumberAnimation {
+ target: root.fadeTarget
+ property: "opacity"
+ to: 1
+ easing.type: Easing.OutQuad
+ }
+ }
+ }
+ \endqml
+
+ This can be used to animate a text when it changes:
+ \qml
+ import QtQuick 2.15
+
+ Text {
+ id: root
+ property int counter
+ text: counter
+ FadeBehavior on text {}
+ Timer {
+ running: true
+ repeat: true
+ interval: 1000
+ onTriggered: ++root.counter
+ }
+ }
+ \endqml
+
+ \since QtQuick 2.15
+*/
+QQmlProperty QQuickBehavior::targetProperty() const
+{
+ Q_D(const QQuickBehavior);
+ return d->property;
+}
+
void QQuickBehavior::write(const QVariant &value)
{
Q_D(QQuickBehavior);
@@ -265,6 +339,8 @@ void QQuickBehavior::setTarget(const QQmlProperty &property)
if (finalizedIdx < 0)
finalizedIdx = metaObject()->indexOfSlot("componentFinalized()");
engPriv->registerFinalizeCallback(this, finalizedIdx);
+
+ Q_EMIT targetPropertyChanged();
}
void QQuickBehavior::componentFinalized()
diff --git a/src/quick/util/qquickbehavior_p.h b/src/quick/util/qquickbehavior_p.h
index fa9cf6d6bc..1ce687ac44 100644
--- a/src/quick/util/qquickbehavior_p.h
+++ b/src/quick/util/qquickbehavior_p.h
@@ -69,9 +69,11 @@ class Q_QUICK_PRIVATE_EXPORT QQuickBehavior : public QObject, public QQmlPropert
Q_CLASSINFO("DefaultProperty", "animation")
Q_PROPERTY(QQuickAbstractAnimation *animation READ animation WRITE setAnimation)
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
- Q_PROPERTY(QVariant targetValue READ targetValue NOTIFY targetValueChanged REVISION 13)
+ Q_PROPERTY(QVariant targetValue READ targetValue NOTIFY targetValueChanged REVISION(2, 13))
+ Q_PROPERTY(QQmlProperty targetProperty READ targetProperty NOTIFY targetPropertyChanged REVISION(2, 15))
Q_CLASSINFO("DeferredPropertyNames", "animation")
QML_NAMED_ELEMENT(Behavior)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickBehavior(QObject *parent=nullptr);
@@ -88,9 +90,12 @@ public:
QVariant targetValue() const;
+ QQmlProperty targetProperty() const;
+
Q_SIGNALS:
void enabledChanged();
void targetValueChanged();
+ void targetPropertyChanged();
private Q_SLOTS:
void componentFinalized();
diff --git a/src/quick/util/qquickfontloader.cpp b/src/quick/util/qquickfontloader.cpp
index addf8b0c18..63aba04c34 100644
--- a/src/quick/util/qquickfontloader.cpp
+++ b/src/quick/util/qquickfontloader.cpp
@@ -121,7 +121,7 @@ void QQuickFontObject::replyFinished()
}
redirectCount = 0;
- if (!reply->networkError()) {
+ if (!reply->error()) {
id = QFontDatabase::addApplicationFontFromData(reply->readAll());
if (id != -1)
emit fontDownloaded(QFontDatabase::applicationFontFamilies(id).at(0), QQuickFontLoader::Ready);
diff --git a/src/quick/util/qquickfontloader_p.h b/src/quick/util/qquickfontloader_p.h
index c0247cee3a..8d831dac4d 100644
--- a/src/quick/util/qquickfontloader_p.h
+++ b/src/quick/util/qquickfontloader_p.h
@@ -68,6 +68,7 @@ class Q_AUTOTEST_EXPORT QQuickFontLoader : public QObject
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
QML_NAMED_ELEMENT(FontLoader)
+ QML_ADDED_IN_VERSION(2, 0)
public:
enum Status { Null = 0, Ready, Loading, Error };
diff --git a/src/quick/util/qquickfontmetrics_p.h b/src/quick/util/qquickfontmetrics_p.h
index ee6d679649..59f4aa8355 100644
--- a/src/quick/util/qquickfontmetrics_p.h
+++ b/src/quick/util/qquickfontmetrics_p.h
@@ -80,7 +80,7 @@ class Q_AUTOTEST_EXPORT QQuickFontMetrics : public QObject
Q_PROPERTY(qreal strikeOutPosition READ strikeOutPosition NOTIFY fontChanged)
Q_PROPERTY(qreal lineWidth READ lineWidth NOTIFY fontChanged)
QML_NAMED_ELEMENT(FontMetrics)
- QML_ADDED_IN_MINOR_VERSION(4)
+ QML_ADDED_IN_VERSION(2, 4)
public:
explicit QQuickFontMetrics(QObject *parent = nullptr);
~QQuickFontMetrics();
diff --git a/src/quick/util/qquickforeignutils_p.h b/src/quick/util/qquickforeignutils_p.h
index 7e51bc4f82..9802420780 100644
--- a/src/quick/util/qquickforeignutils_p.h
+++ b/src/quick/util/qquickforeignutils_p.h
@@ -73,6 +73,7 @@ struct QValidatorForeign
Q_GADGET
QML_FOREIGN(QValidator)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
};
struct QRegExpValidatorForeign
@@ -80,6 +81,7 @@ struct QRegExpValidatorForeign
Q_GADGET
QML_FOREIGN(QRegExpValidator)
QML_NAMED_ELEMENT(RegExpValidator)
+ QML_ADDED_IN_VERSION(2, 0)
};
#if QT_CONFIG(regularexpression)
@@ -88,7 +90,7 @@ struct QRegularExpressionValidatorForeign
Q_GADGET
QML_FOREIGN(QRegularExpressionValidator)
QML_NAMED_ELEMENT(RegularExpressionValidator)
- QML_ADDED_IN_MINOR_VERSION(14)
+ QML_ADDED_IN_VERSION(2, 14)
};
#endif // QT_CONFIG(regularexpression)
@@ -100,6 +102,7 @@ struct QInputMethodForeign
Q_GADGET
QML_FOREIGN(QInputMethod)
QML_NAMED_ELEMENT(InputMethod)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("InputMethod is an abstract class.")
};
#endif // QT_CONFIG(im)
@@ -110,7 +113,7 @@ struct QKeySequenceForeign
Q_GADGET
QML_FOREIGN(QKeySequence)
QML_NAMED_ELEMENT(StandardKey)
- QML_ADDED_IN_MINOR_VERSION(2)
+ QML_ADDED_IN_VERSION(2, 2)
QML_UNCREATABLE("Cannot create an instance of StandardKey.")
};
#endif // QT_CONFIG(shortcut)
diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp
index 85bc78dee8..3ea2f88712 100644
--- a/src/quick/util/qquickglobal.cpp
+++ b/src/quick/util/qquickglobal.cpp
@@ -273,6 +273,52 @@ public:
return QMatrix4x4();
}
+ static QColorSpace colorSpaceFromObject(const QV4::Value &object, QV4::ExecutionEngine *v4, bool *ok)
+ {
+ if (ok)
+ *ok = false;
+ QColorSpace retn;
+ QV4::Scope scope(v4);
+ QV4::ScopedObject obj(scope, object);
+ if (!obj) {
+ if (ok)
+ *ok = false;
+ return retn;
+ }
+
+ QV4::ScopedString s(scope);
+
+ QV4::ScopedValue vName(scope, obj->get((s = v4->newString(QStringLiteral("namedColorSpace")))));
+ if (vName->isInt32()) {
+ if (ok)
+ *ok = true;
+ return QColorSpace((QColorSpace::NamedColorSpace)vName->toInt32());
+ }
+
+ QV4::ScopedValue vPri(scope, obj->get((s = v4->newString(QStringLiteral("primaries")))));
+ QV4::ScopedValue vTra(scope, obj->get((s = v4->newString(QStringLiteral("transferFunction")))));
+ if (!vPri->isInt32() || !vTra->isInt32()) {
+ if (ok)
+ *ok = false;
+ return retn;
+ }
+
+ QColorSpace::Primaries pri = static_cast<QColorSpace::Primaries>(vPri->integerValue());
+ QColorSpace::TransferFunction tra = static_cast<QColorSpace::TransferFunction>(vTra->integerValue());
+ float gamma = 0.0f;
+ if (tra == QColorSpace::TransferFunction::Gamma) {
+ QV4::ScopedValue vGam(scope, obj->get((s = v4->newString(QStringLiteral("gamma")))));
+ if (!vGam->isNumber()) {
+ if (ok)
+ *ok = false;
+ return retn;
+ }
+ gamma = vGam->toNumber();
+ }
+ if (ok) *ok = true;
+ return QColorSpace(pri, tra, gamma);
+ }
+
static QFont fontFromObject(const QV4::Value &object, QV4::ExecutionEngine *v4, bool *ok)
{
if (ok)
@@ -402,6 +448,8 @@ public:
switch (type) {
case QMetaType::QColor:
return &QQuickColorValueType::staticMetaObject;
+ case QMetaType::QColorSpace:
+ return &QQuickColorSpaceValueType::staticMetaObject;
case QMetaType::QFont:
return &QQuickFontValueType::staticMetaObject;
case QMetaType::QVector2D:
@@ -427,6 +475,9 @@ public:
case QMetaType::QColor:
dst.setValue<QColor>(QColor());
return true;
+ case QMetaType::QColorSpace:
+ dst.setValue<QColorSpace>(QColorSpace());
+ return true;
case QMetaType::QFont:
dst.setValue<QFont>(QFont());
return true;
@@ -647,6 +698,9 @@ public:
#endif
bool ok = false;
switch (type) {
+ case QMetaType::QColorSpace:
+ *v = QVariant::fromValue(colorSpaceFromObject(object, v4, &ok));
+ break;
case QMetaType::QFont:
*v = QVariant::fromValue(fontFromObject(object, v4, &ok));
break;
@@ -669,6 +723,8 @@ public:
switch (type) {
case QMetaType::QColor:
return typedEqual<QColor>(lhs, rhs);
+ case QMetaType::QColorSpace:
+ return typedEqual<QColorSpace>(lhs, rhs);
case QMetaType::QFont:
return typedEqual<QFont>(lhs, rhs);
case QMetaType::QVector2D:
@@ -732,6 +788,8 @@ public:
switch (dstType) {
case QMetaType::QColor:
return typedRead<QColor>(src, dstType, dst);
+ case QMetaType::QColorSpace:
+ return typedRead<QColorSpace>(src, dstType, dst);
case QMetaType::QFont:
return typedRead<QFont>(src, dstType, dst);
case QMetaType::QVector2D:
@@ -766,6 +824,8 @@ public:
switch (type) {
case QMetaType::QColor:
return typedWrite<QColor>(src, dst);
+ case QMetaType::QColorSpace:
+ return typedWrite<QColorSpace>(src, dst);
case QMetaType::QFont:
return typedWrite<QFont>(src, dst);
case QMetaType::QVector2D:
diff --git a/src/quick/util/qquickimageprovider.cpp b/src/quick/util/qquickimageprovider.cpp
index db82b2d807..80873e2ad5 100644
--- a/src/quick/util/qquickimageprovider.cpp
+++ b/src/quick/util/qquickimageprovider.cpp
@@ -43,6 +43,7 @@
#include "qquickpixmapcache_p.h"
#include <QtQuick/private/qsgcontext_p.h>
#include <private/qqmlglobal_p.h>
+#include <QtGui/qcolorspace.h>
QT_BEGIN_NAMESPACE
@@ -510,6 +511,7 @@ public:
{
}
+ QColorSpace targetColorSpace;
QQuickImageProviderOptions::AutoTransform autoTransform = QQuickImageProviderOptions::UsePluginDefaultTransform;
bool preserveAspectRatioCrop = false;
bool preserveAspectRatioFit = false;
@@ -558,7 +560,8 @@ bool QQuickImageProviderOptions::operator==(const QQuickImageProviderOptions &ot
{
return d->autoTransform == other.d->autoTransform &&
d->preserveAspectRatioCrop == other.d->preserveAspectRatioCrop &&
- d->preserveAspectRatioFit == other.d->preserveAspectRatioFit;
+ d->preserveAspectRatioFit == other.d->preserveAspectRatioFit &&
+ d->targetColorSpace == other.d->targetColorSpace;
}
/*!
@@ -602,6 +605,19 @@ void QQuickImageProviderOptions::setPreserveAspectRatioFit(bool preserveAspectRa
d->preserveAspectRatioFit = preserveAspectRatioFit;
}
+/*!
+ Returns the color space the image provider should return the image in.
+*/
+QColorSpace QQuickImageProviderOptions::targetColorSpace() const
+{
+ return d->targetColorSpace;
+}
+
+void QQuickImageProviderOptions::setTargetColorSpace(const QColorSpace &colorSpace)
+{
+ d->targetColorSpace = colorSpace;
+}
+
QQuickImageProviderWithOptions::QQuickImageProviderWithOptions(ImageType type, Flags flags)
: QQuickAsyncImageProvider()
{
diff --git a/src/quick/util/qquickpath.cpp b/src/quick/util/qquickpath.cpp
index 375d0265e8..74ee52b1d3 100644
--- a/src/quick/util/qquickpath.cpp
+++ b/src/quick/util/qquickpath.cpp
@@ -2827,11 +2827,11 @@ void QQuickPathText::updatePath() const
if (!_path.isEmpty())
return;
- _path.addText(_x, _y, _font, _text);
+ _path.addText(0.0, 0.0, _font, _text);
// Account for distance from baseline to top, since addText() takes baseline position
QRectF brect = _path.boundingRect();
- _path.translate(0.0, -brect.y());
+ _path.translate(_x, _y - brect.y());
}
void QQuickPathText::addToPath(QPainterPath &path)
diff --git a/src/quick/util/qquickpath_p.h b/src/quick/util/qquickpath_p.h
index 159c46d13c..8660537587 100644
--- a/src/quick/util/qquickpath_p.h
+++ b/src/quick/util/qquickpath_p.h
@@ -79,6 +79,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathElement : public QObject
{
Q_OBJECT
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickPathElement(QObject *parent=nullptr) : QObject(parent) {}
Q_SIGNALS:
@@ -92,6 +93,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathAttribute : public QQuickPathElement
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged)
QML_NAMED_ELEMENT(PathAttribute)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickPathAttribute(QObject *parent=nullptr) : QQuickPathElement(parent) {}
@@ -120,6 +122,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickCurve : public QQuickPathElement
Q_PROPERTY(qreal relativeX READ relativeX WRITE setRelativeX NOTIFY relativeXChanged)
Q_PROPERTY(qreal relativeY READ relativeY WRITE setRelativeY NOTIFY relativeYChanged)
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickCurve(QObject *parent=nullptr) : QQuickPathElement(parent) {}
@@ -158,6 +161,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathLine : public QQuickCurve
{
Q_OBJECT
QML_NAMED_ELEMENT(PathLine)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickPathLine(QObject *parent=nullptr) : QQuickCurve(parent) {}
@@ -168,7 +172,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathMove : public QQuickCurve
{
Q_OBJECT
QML_NAMED_ELEMENT(PathMove)
- QML_ADDED_IN_MINOR_VERSION(9)
+ QML_ADDED_IN_VERSION(2, 9)
public:
QQuickPathMove(QObject *parent=nullptr) : QQuickCurve(parent) {}
@@ -185,6 +189,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathQuad : public QQuickCurve
Q_PROPERTY(qreal relativeControlY READ relativeControlY WRITE setRelativeControlY NOTIFY relativeControlYChanged)
QML_NAMED_ELEMENT(PathQuad)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickPathQuad(QObject *parent=nullptr) : QQuickCurve(parent) {}
@@ -230,6 +235,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathCubic : public QQuickCurve
Q_PROPERTY(qreal relativeControl2X READ relativeControl2X WRITE setRelativeControl2X NOTIFY relativeControl2XChanged)
Q_PROPERTY(qreal relativeControl2Y READ relativeControl2Y WRITE setRelativeControl2Y NOTIFY relativeControl2YChanged)
QML_NAMED_ELEMENT(PathCubic)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickPathCubic(QObject *parent=nullptr) : QQuickCurve(parent) {}
@@ -288,6 +294,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathCatmullRomCurve : public QQuickCurve
{
Q_OBJECT
QML_NAMED_ELEMENT(PathCurve)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickPathCatmullRomCurve(QObject *parent=nullptr) : QQuickCurve(parent) {}
@@ -301,8 +308,9 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathArc : public QQuickCurve
Q_PROPERTY(qreal radiusY READ radiusY WRITE setRadiusY NOTIFY radiusYChanged)
Q_PROPERTY(bool useLargeArc READ useLargeArc WRITE setUseLargeArc NOTIFY useLargeArcChanged)
Q_PROPERTY(ArcDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
- Q_PROPERTY(qreal xAxisRotation READ xAxisRotation WRITE setXAxisRotation NOTIFY xAxisRotationChanged REVISION 9)
+ Q_PROPERTY(qreal xAxisRotation READ xAxisRotation WRITE setXAxisRotation NOTIFY xAxisRotationChanged REVISION(2, 9))
QML_NAMED_ELEMENT(PathArc)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickPathArc(QObject *parent=nullptr)
@@ -333,7 +341,7 @@ Q_SIGNALS:
void radiusYChanged();
void useLargeArcChanged();
void directionChanged();
- Q_REVISION(9) void xAxisRotationChanged();
+ Q_REVISION(2, 9) void xAxisRotationChanged();
private:
qreal _radiusX = 0;
@@ -355,7 +363,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathAngleArc : public QQuickCurve
Q_PROPERTY(bool moveToStart READ moveToStart WRITE setMoveToStart NOTIFY moveToStartChanged)
QML_NAMED_ELEMENT(PathAngleArc)
- QML_ADDED_IN_MINOR_VERSION(11)
+ QML_ADDED_IN_VERSION(2, 11)
public:
QQuickPathAngleArc(QObject *parent=nullptr)
@@ -408,6 +416,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathSvg : public QQuickCurve
Q_OBJECT
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
QML_NAMED_ELEMENT(PathSvg)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickPathSvg(QObject *parent=nullptr) : QQuickCurve(parent) {}
@@ -428,6 +437,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathPercent : public QQuickPathElement
Q_OBJECT
Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged)
QML_NAMED_ELEMENT(PathPercent)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickPathPercent(QObject *parent=nullptr) : QQuickPathElement(parent) {}
@@ -447,7 +457,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathPolyline : public QQuickCurve
Q_PROPERTY(QPointF start READ start NOTIFY startChanged)
Q_PROPERTY(QVariant path READ path WRITE setPath NOTIFY pathChanged)
QML_NAMED_ELEMENT(PathPolyline)
- QML_ADDED_IN_MINOR_VERSION(14)
+ QML_ADDED_IN_VERSION(2, 14)
public:
QQuickPathPolyline(QObject *parent=nullptr);
@@ -471,7 +481,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathMultiline : public QQuickCurve
Q_PROPERTY(QPointF start READ start NOTIFY startChanged)
Q_PROPERTY(QVariant paths READ paths WRITE setPaths NOTIFY pathsChanged)
QML_NAMED_ELEMENT(PathMultiline)
- QML_ADDED_IN_MINOR_VERSION(14)
+ QML_ADDED_IN_VERSION(2, 14)
public:
QQuickPathMultiline(QObject *parent=nullptr);
@@ -512,9 +522,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPath : public QObject, public QQmlParserStatu
Q_PROPERTY(qreal startX READ startX WRITE setStartX NOTIFY startXChanged)
Q_PROPERTY(qreal startY READ startY WRITE setStartY NOTIFY startYChanged)
Q_PROPERTY(bool closed READ isClosed NOTIFY changed)
- Q_PROPERTY(QSizeF scale READ scale WRITE setScale NOTIFY scaleChanged REVISION 14)
+ Q_PROPERTY(QSizeF scale READ scale WRITE setScale NOTIFY scaleChanged REVISION(2, 14))
Q_CLASSINFO("DefaultProperty", "pathElements")
QML_NAMED_ELEMENT(Path)
+ QML_ADDED_IN_VERSION(2, 0)
Q_INTERFACES(QQmlParserStatus)
public:
QQuickPath(QObject *parent=nullptr);
@@ -535,7 +546,7 @@ public:
QPainterPath path() const;
QStringList attributes() const;
qreal attributeAt(const QString &, qreal) const;
- Q_REVISION(14) Q_INVOKABLE QPointF pointAtPercent(qreal t) const;
+ Q_REVISION(2, 14) Q_INVOKABLE QPointF pointAtPercent(qreal t) const;
QPointF sequentialPointAt(qreal p, qreal *angle = nullptr) const;
void invalidateSequentialHistory() const;
@@ -546,7 +557,7 @@ Q_SIGNALS:
void changed();
void startXChanged();
void startYChanged();
- Q_REVISION(14) void scaleChanged();
+ Q_REVISION(2, 14) void scaleChanged();
protected:
QQuickPath(QQuickPathPrivate &dd, QObject *parent = nullptr);
@@ -609,7 +620,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathText : public QQuickPathElement
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
QML_NAMED_ELEMENT(PathText)
- QML_ADDED_IN_MINOR_VERSION(15)
+ QML_ADDED_IN_VERSION(2, 15)
public:
QQuickPathText(QObject *parent=nullptr) : QQuickPathElement(parent)
{
diff --git a/src/quick/util/qquickpathinterpolator_p.h b/src/quick/util/qquickpathinterpolator_p.h
index 440ea06841..70fb0935e8 100644
--- a/src/quick/util/qquickpathinterpolator_p.h
+++ b/src/quick/util/qquickpathinterpolator_p.h
@@ -70,6 +70,7 @@ class Q_AUTOTEST_EXPORT QQuickPathInterpolator : public QObject
Q_PROPERTY(qreal y READ y NOTIFY yChanged)
Q_PROPERTY(qreal angle READ angle NOTIFY angleChanged)
QML_NAMED_ELEMENT(PathInterpolator)
+ QML_ADDED_IN_VERSION(2, 0)
public:
explicit QQuickPathInterpolator(QObject *parent = nullptr);
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
index d47719389b..d96ebe70b2 100644
--- a/src/quick/util/qquickpixmapcache.cpp
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -86,6 +86,8 @@ QT_BEGIN_NAMESPACE
const QLatin1String QQuickPixmap::itemGrabberScheme = QLatin1String("itemgrabber");
+Q_LOGGING_CATEGORY(lcImg, "qt.quick.image")
+
#ifndef QT_NO_DEBUG
static const bool qsg_leak_check = !qEnvironmentVariableIsEmpty("QML_LEAK_CHECK");
#endif
@@ -137,6 +139,7 @@ public:
QQuickPixmapData *data;
QQmlEngine *engineForReader; // always access reader inside readerMutex
+ QRect requestRegion;
QSize requestSize;
QUrl url;
@@ -240,9 +243,10 @@ public:
class QQuickPixmapData
{
public:
- QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QSize &s, const QQuickImageProviderOptions &po, const QString &e)
+ QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QRect &r, const QSize &rs,
+ const QQuickImageProviderOptions &po, const QString &e)
: refCount(1), frameCount(1), frame(0), inCache(false), pixmapStatus(QQuickPixmap::Error),
- url(u), errorString(e), requestSize(s),
+ url(u), errorString(e), requestRegion(r), requestSize(rs),
providerOptions(po), appliedTransform(QQuickImageProviderOptions::UsePluginDefaultTransform),
textureFactory(nullptr), reply(nullptr), prevUnreferenced(nullptr),
prevUnreferencedPtr(nullptr), nextUnreferenced(nullptr)
@@ -250,9 +254,10 @@ public:
declarativePixmaps.insert(pixmap);
}
- QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QSize &r, const QQuickImageProviderOptions &po, QQuickImageProviderOptions::AutoTransform aTransform, int frame=0, int frameCount=1)
+ QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QRect &r, const QSize &s, const QQuickImageProviderOptions &po,
+ QQuickImageProviderOptions::AutoTransform aTransform, int frame=0, int frameCount=1)
: refCount(1), frameCount(frameCount), frame(frame), inCache(false), pixmapStatus(QQuickPixmap::Loading),
- url(u), requestSize(r),
+ url(u), requestRegion(r), requestSize(s),
providerOptions(po), appliedTransform(aTransform),
textureFactory(nullptr), reply(nullptr), prevUnreferenced(nullptr), prevUnreferencedPtr(nullptr),
nextUnreferenced(nullptr)
@@ -261,9 +266,10 @@ public:
}
QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, QQuickTextureFactory *texture,
- const QSize &s, const QSize &r, const QQuickImageProviderOptions &po, QQuickImageProviderOptions::AutoTransform aTransform, int frame=0, int frameCount=1)
+ const QSize &s, const QRect &r, const QSize &rs, const QQuickImageProviderOptions &po,
+ QQuickImageProviderOptions::AutoTransform aTransform, int frame=0, int frameCount=1)
: refCount(1), frameCount(frameCount), frame(frame), inCache(false), pixmapStatus(QQuickPixmap::Ready),
- url(u), implicitSize(s), requestSize(r),
+ url(u), implicitSize(s), requestRegion(r), requestSize(rs),
providerOptions(po), appliedTransform(aTransform),
textureFactory(texture), reply(nullptr), prevUnreferenced(nullptr),
prevUnreferencedPtr(nullptr), nextUnreferenced(nullptr)
@@ -308,9 +314,11 @@ public:
QUrl url;
QString errorString;
QSize implicitSize;
+ QRect requestRegion;
QSize requestSize;
QQuickImageProviderOptions providerOptions;
QQuickImageProviderOptions::AutoTransform appliedTransform;
+ QColorSpace targetColorSpace;
QQuickTextureFactory *textureFactory;
@@ -399,7 +407,7 @@ static void maybeRemoveAlpha(QImage *image)
}
static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *errorString, QSize *impsize, int *frameCount,
- const QSize &requestSize, const QQuickImageProviderOptions &providerOptions,
+ const QRect &requestRegion, const QSize &requestSize, const QQuickImageProviderOptions &providerOptions,
QQuickImageProviderOptions::AutoTransform *appliedTransform = nullptr, int frame = 0)
{
QImageReader imgio(dev);
@@ -417,14 +425,25 @@ static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *e
QSize scSize = QQuickImageProviderWithOptions::loadSize(imgio.size(), requestSize, imgio.format(), providerOptions);
if (scSize.isValid())
imgio.setScaledSize(scSize);
+ if (!requestRegion.isNull())
+ imgio.setScaledClipRect(requestRegion);
+ const QSize originalSize = imgio.size();
+ qCDebug(lcImg) << url << "frame" << frame << "of" << imgio.imageCount()
+ << "requestRegion" << requestRegion << "QImageReader size" << originalSize << "-> scSize" << scSize;
if (impsize)
- *impsize = imgio.size();
+ *impsize = originalSize;
if (imgio.read(image)) {
maybeRemoveAlpha(image);
if (impsize && impsize->width() < 0)
*impsize = image->size();
+ if (providerOptions.targetColorSpace().isValid()) {
+ if (image->colorSpace().isValid())
+ image->convertToColorSpace(providerOptions.targetColorSpace());
+ else
+ image->setColorSpace(providerOptions.targetColorSpace());
+ }
return true;
} else {
if (errorString)
@@ -559,7 +578,7 @@ void QQuickPixmapReader::networkRequestDone(QNetworkReply *reply)
QQuickPixmapReply::ReadError error = QQuickPixmapReply::NoError;
QString errorString;
QSize readSize;
- if (reply->networkError()) {
+ if (reply->error()) {
error = QQuickPixmapReply::Loading;
errorString = reply->errorString();
} else {
@@ -568,7 +587,8 @@ void QQuickPixmapReader::networkRequestDone(QNetworkReply *reply)
buff.open(QIODevice::ReadOnly);
int frameCount;
int const frame = job->data ? job->data->frame : 0;
- if (!readImage(reply->url(), &buff, &image, &errorString, &readSize, &frameCount, job->requestSize, job->providerOptions, nullptr, frame))
+ if (!readImage(reply->url(), &buff, &image, &errorString, &readSize, &frameCount,
+ job->requestRegion, job->requestSize, job->providerOptions, nullptr, frame))
error = QQuickPixmapReply::Decoding;
else if (job->data)
job->data->frameCount = frameCount;
@@ -884,7 +904,8 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u
} else {
int frameCount;
int const frame = runningJob->data ? runningJob->data->frame : 0;
- if ( !readImage(url, &f, &image, &errorStr, &readSize, &frameCount, runningJob->requestSize, runningJob->providerOptions, nullptr, frame)) {
+ if (!readImage(url, &f, &image, &errorStr, &readSize, &frameCount, runningJob->requestRegion, runningJob->requestSize,
+ runningJob->providerOptions, nullptr, frame)) {
errorCode = QQuickPixmapReply::Loading;
if (f.fileName() != localFile)
errorStr += QString::fromLatin1(" (%1)").arg(f.fileName());
@@ -997,6 +1018,7 @@ class QQuickPixmapKey
{
public:
const QUrl *url;
+ const QRect *region;
const QSize *size;
int frame;
QQuickImageProviderOptions options;
@@ -1004,12 +1026,20 @@ public:
inline bool operator==(const QQuickPixmapKey &lhs, const QQuickPixmapKey &rhs)
{
- return *lhs.size == *rhs.size && *lhs.url == *rhs.url && lhs.options == rhs.options && lhs.frame == rhs.frame;
+ return *lhs.url == *rhs.url &&
+ *lhs.region == *rhs.region &&
+ *lhs.size == *rhs.size &&
+ lhs.frame == rhs.frame &&
+ lhs.options == rhs.options;
}
inline uint qHash(const QQuickPixmapKey &key)
{
- return qHash(*key.url) ^ (key.size->width()*7) ^ (key.size->height()*17) ^ (key.frame*23) ^ (key.options.autoTransform() * 0x5c5c5c5c);
+ return qHash(*key.url) ^ (key.size->width()*7) ^ (key.size->height()*17) ^ (key.frame*23) ^
+ (key.region->x()*29) ^ (key.region->y()*31) ^ (key.options.autoTransform() * 0x5c5c5c5c);
+ // key.region.width() and height() are not included, because the hash function should be simple,
+ // and they are more likely to be held constant for some batches of images
+ // (e.g. tiles, or repeatedly cropping to the same viewport at different positions).
}
class QQuickPixmapStore : public QObject
@@ -1176,7 +1206,8 @@ void QQuickPixmap::purgeCache()
}
QQuickPixmapReply::QQuickPixmapReply(QQuickPixmapData *d)
-: data(d), engineForReader(nullptr), requestSize(d->requestSize), url(d->url), loading(false), providerOptions(d->providerOptions), redirectCount(0)
+ : data(d), engineForReader(nullptr), requestRegion(d->requestRegion), requestSize(d->requestSize),
+ url(d->url), loading(false), providerOptions(d->providerOptions), redirectCount(0)
{
if (finishedIndex == -1) {
finishedIndex = QMetaMethod::fromSignal(&QQuickPixmapReply::finished).methodIndex();
@@ -1271,7 +1302,7 @@ void QQuickPixmapData::release()
void QQuickPixmapData::addToCache()
{
if (!inCache) {
- QQuickPixmapKey key = { &url, &requestSize, frame, providerOptions };
+ QQuickPixmapKey key = { &url, &requestRegion, &requestSize, frame, providerOptions };
pixmapStore()->m_cache.insert(key, this);
inCache = true;
PIXMAP_PROFILE(pixmapCountChanged<QQuickProfiler::PixmapCacheCountChanged>(
@@ -1282,7 +1313,7 @@ void QQuickPixmapData::addToCache()
void QQuickPixmapData::removeFromCache()
{
if (inCache) {
- QQuickPixmapKey key = { &url, &requestSize, frame, providerOptions };
+ QQuickPixmapKey key = { &url, &requestRegion, &requestSize, frame, providerOptions };
pixmapStore()->m_cache.remove(key);
inCache = false;
PIXMAP_PROFILE(pixmapCountChanged<QQuickProfiler::PixmapCacheCountChanged>(
@@ -1290,7 +1321,9 @@ void QQuickPixmapData::removeFromCache()
}
}
-static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, QQmlEngine *engine, const QUrl &url, const QSize &requestSize, const QQuickImageProviderOptions &providerOptions, int frame, bool *ok)
+static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, QQmlEngine *engine, const QUrl &url,
+ const QRect &requestRegion, const QSize &requestSize,
+ const QQuickImageProviderOptions &providerOptions, int frame, bool *ok)
{
if (url.scheme() == QLatin1String("image")) {
QSize readSize;
@@ -1305,7 +1338,7 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q
switch (imageType) {
case QQuickImageProvider::Invalid:
- return new QQuickPixmapData(declarativePixmap, url, requestSize, providerOptions,
+ return new QQuickPixmapData(declarativePixmap, url, requestRegion, requestSize, providerOptions,
QQuickPixmap::tr("Invalid image provider: %1").arg(url.toString()));
case QQuickImageProvider::Texture:
{
@@ -1313,7 +1346,8 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q
: provider->requestTexture(imageId(url), &readSize, requestSize);
if (texture) {
*ok = true;
- return new QQuickPixmapData(declarativePixmap, url, texture, readSize, requestSize, providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform, frame);
+ return new QQuickPixmapData(declarativePixmap, url, texture, readSize, requestRegion, requestSize,
+ providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform, frame);
}
break;
}
@@ -1324,7 +1358,9 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q
: provider->requestImage(imageId(url), &readSize, requestSize);
if (!image.isNull()) {
*ok = true;
- return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(image), readSize, requestSize, providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform, frame);
+ return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(image),
+ readSize, requestRegion, requestSize, providerOptions,
+ QQuickImageProviderOptions::UsePluginDefaultTransform, frame);
}
break;
}
@@ -1334,7 +1370,9 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q
: provider->requestPixmap(imageId(url), &readSize, requestSize);
if (!pixmap.isNull()) {
*ok = true;
- return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(pixmap.toImage()), readSize, requestSize, providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform, frame);
+ return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(pixmap.toImage()),
+ readSize, requestRegion, requestSize, providerOptions,
+ QQuickImageProviderOptions::UsePluginDefaultTransform, frame);
}
break;
}
@@ -1346,7 +1384,7 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q
}
// provider has bad image type, or provider returned null image
- return new QQuickPixmapData(declarativePixmap, url, requestSize, providerOptions,
+ return new QQuickPixmapData(declarativePixmap, url, requestRegion, requestSize, providerOptions,
QQuickPixmap::tr("Failed to get image from provider: %1").arg(url.toString()));
}
@@ -1364,7 +1402,8 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q
QQuickTextureFactory *factory = texReader.read();
if (factory) {
*ok = true;
- return new QQuickPixmapData(declarativePixmap, url, factory, factory->textureSize(), requestSize, providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform, frame);
+ return new QQuickPixmapData(declarativePixmap, url, factory, factory->textureSize(), requestRegion, requestSize,
+ providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform, frame);
} else {
errorString = QQuickPixmap::tr("Error decoding: %1").arg(url.toString());
if (f.fileName() != localFile)
@@ -1374,9 +1413,10 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q
QImage image;
QQuickImageProviderOptions::AutoTransform appliedTransform = providerOptions.autoTransform();
int frameCount;
- if (readImage(url, &f, &image, &errorString, &readSize, &frameCount, requestSize, providerOptions, &appliedTransform, frame)) {
+ if (readImage(url, &f, &image, &errorString, &readSize, &frameCount, requestRegion, requestSize, providerOptions, &appliedTransform, frame)) {
*ok = true;
- return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(image), readSize, requestSize, providerOptions, appliedTransform, frame, frameCount);
+ return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(image), readSize, requestRegion, requestSize,
+ providerOptions, appliedTransform, frame, frameCount);
} else if (f.fileName() != localFile) {
errorString += QString::fromLatin1(" (%1)").arg(f.fileName());
}
@@ -1384,12 +1424,13 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q
} else {
errorString = QQuickPixmap::tr("Cannot open: %1").arg(url.toString());
}
- return new QQuickPixmapData(declarativePixmap, url, requestSize, providerOptions, errorString);
+ return new QQuickPixmapData(declarativePixmap, url, requestRegion, requestSize, providerOptions, errorString);
}
struct QQuickPixmapNull {
QUrl url;
+ QRect region;
QSize size;
};
Q_GLOBAL_STATIC(QQuickPixmapNull, nullPixmap);
@@ -1405,15 +1446,16 @@ QQuickPixmap::QQuickPixmap(QQmlEngine *engine, const QUrl &url)
load(engine, url);
}
-QQuickPixmap::QQuickPixmap(QQmlEngine *engine, const QUrl &url, const QSize &size)
+QQuickPixmap::QQuickPixmap(QQmlEngine *engine, const QUrl &url, const QRect &region, const QSize &size)
: d(nullptr)
{
- load(engine, url, size);
+ load(engine, url, region, size);
}
QQuickPixmap::QQuickPixmap(const QUrl &url, const QImage &image)
{
- d = new QQuickPixmapData(this, url, new QQuickDefaultTextureFactory(image), image.size(), QSize(), QQuickImageProviderOptions(), QQuickImageProviderOptions::UsePluginDefaultTransform);
+ d = new QQuickPixmapData(this, url, new QQuickDefaultTextureFactory(image), image.size(), QRect(), QSize(),
+ QQuickImageProviderOptions(), QQuickImageProviderOptions::UsePluginDefaultTransform);
d->addToCache();
}
@@ -1486,6 +1528,14 @@ const QSize &QQuickPixmap::requestSize() const
return nullPixmap()->size;
}
+const QRect &QQuickPixmap::requestRegion() const
+{
+ if (d)
+ return d->requestRegion;
+ else
+ return nullPixmap()->region;
+}
+
QQuickImageProviderOptions::AutoTransform QQuickPixmap::autoTransform() const
{
if (d)
@@ -1561,25 +1611,26 @@ QRect QQuickPixmap::rect() const
void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url)
{
- load(engine, url, QSize(), QQuickPixmap::Cache);
+ load(engine, url, QRect(), QSize(), QQuickPixmap::Cache);
}
void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, QQuickPixmap::Options options)
{
- load(engine, url, QSize(), options);
+ load(engine, url, QRect(), QSize(), options);
}
-void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &size)
+void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QRect &requestRegion, const QSize &requestSize)
{
- load(engine, url, size, QQuickPixmap::Cache);
+ load(engine, url, requestRegion, requestSize, QQuickPixmap::Cache);
}
-void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &requestSize, QQuickPixmap::Options options)
+void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QRect &requestRegion, const QSize &requestSize, QQuickPixmap::Options options)
{
- load(engine, url, requestSize, options, QQuickImageProviderOptions());
+ load(engine, url, requestRegion, requestSize, options, QQuickImageProviderOptions());
}
-void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &requestSize, QQuickPixmap::Options options, const QQuickImageProviderOptions &providerOptions, int frame, int frameCount)
+void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QRect &requestRegion, const QSize &requestSize,
+ QQuickPixmap::Options options, const QQuickImageProviderOptions &providerOptions, int frame, int frameCount)
{
if (d) {
d->declarativePixmaps.remove(this);
@@ -1587,7 +1638,7 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &reques
d = nullptr;
}
- QQuickPixmapKey key = { &url, &requestSize, frame, providerOptions };
+ QQuickPixmapKey key = { &url, &requestRegion, &requestSize, frame, providerOptions };
QQuickPixmapStore *store = pixmapStore();
QHash<QQuickPixmapKey, QQuickPixmapData *>::Iterator iter = store->m_cache.end();
@@ -1596,10 +1647,11 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &reques
// cached version. Unless it's an itemgrabber url, since the cache is used to pass
// the result between QQuickItemGrabResult and QQuickImage.
if (url.scheme() == itemGrabberScheme) {
- QSize dummy;
- if (requestSize != dummy)
+ QRect dummyRegion;
+ QSize dummySize;
+ if (requestSize != dummySize)
qWarning() << "Ignoring sourceSize request for image url that came from grabToImage. Use the targetSize parameter of the grabToImage() function instead.";
- const QQuickPixmapKey grabberKey = { &url, &dummy, 0, QQuickImageProviderOptions() };
+ const QQuickPixmapKey grabberKey = { &url, &dummyRegion, &dummySize, 0, QQuickImageProviderOptions() };
iter = store->m_cache.find(grabberKey);
} else if (options & QQuickPixmap::Cache)
iter = store->m_cache.find(key);
@@ -1621,7 +1673,7 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &reques
if (!(options & QQuickPixmap::Asynchronous)) {
bool ok = false;
PIXMAP_PROFILE(pixmapStateChanged<QQuickProfiler::PixmapLoadingStarted>(url));
- d = createPixmapDataSync(this, engine, url, requestSize, providerOptions, frame, &ok);
+ d = createPixmapDataSync(this, engine, url, requestRegion, requestSize, providerOptions, frame, &ok);
if (ok) {
PIXMAP_PROFILE(pixmapLoadingFinished(url, QSize(width(), height())));
if (options & QQuickPixmap::Cache)
@@ -1638,7 +1690,8 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &reques
return;
- d = new QQuickPixmapData(this, url, requestSize, providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform, frame, frameCount);
+ d = new QQuickPixmapData(this, url, requestRegion, requestSize, providerOptions,
+ QQuickImageProviderOptions::UsePluginDefaultTransform, frame, frameCount);
if (options & QQuickPixmap::Cache)
d->addToCache();
@@ -1672,9 +1725,10 @@ void QQuickPixmap::clear(QObject *obj)
}
}
-bool QQuickPixmap::isCached(const QUrl &url, const QSize &requestSize, const int frame, const QQuickImageProviderOptions &options)
+bool QQuickPixmap::isCached(const QUrl &url, const QRect &requestRegion, const QSize &requestSize,
+ const int frame, const QQuickImageProviderOptions &options)
{
- QQuickPixmapKey key = { &url, &requestSize, frame, options };
+ QQuickPixmapKey key = { &url, &requestRegion, &requestSize, frame, options };
QQuickPixmapStore *store = pixmapStore();
return store->m_cache.contains(key);
@@ -1720,6 +1774,13 @@ bool QQuickPixmap::connectDownloadProgress(QObject *object, int method)
return QMetaObject::connect(d->reply, QQuickPixmapReply::downloadProgressIndex, object, method);
}
+QColorSpace QQuickPixmap::colorSpace() const
+{
+ if (!d || !d->textureFactory)
+ return QColorSpace();
+ return d->textureFactory->image().colorSpace();
+}
+
QT_END_NAMESPACE
#include <qquickpixmapcache.moc>
diff --git a/src/quick/util/qquickpixmapcache_p.h b/src/quick/util/qquickpixmapcache_p.h
index c4f4d1a101..87724d6210 100644
--- a/src/quick/util/qquickpixmapcache_p.h
+++ b/src/quick/util/qquickpixmapcache_p.h
@@ -117,6 +117,9 @@ public:
bool preserveAspectRatioFit() const;
void setPreserveAspectRatioFit(bool preserveAspectRatioFit);
+ QColorSpace targetColorSpace() const;
+ void setTargetColorSpace(const QColorSpace &colorSpace);
+
private:
QSharedDataPointer<QQuickImageProviderOptionsPrivate> d;
};
@@ -127,7 +130,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPixmap
public:
QQuickPixmap();
QQuickPixmap(QQmlEngine *, const QUrl &);
- QQuickPixmap(QQmlEngine *, const QUrl &, const QSize &);
+ QQuickPixmap(QQmlEngine *, const QUrl &, const QRect &region, const QSize &);
QQuickPixmap(const QUrl &, const QImage &image);
~QQuickPixmap();
@@ -148,6 +151,7 @@ public:
QString error() const;
const QUrl &url() const;
const QSize &implicitSize() const;
+ const QRect &requestRegion() const;
const QSize &requestSize() const;
QQuickImageProviderOptions::AutoTransform autoTransform() const;
int frameCount() const;
@@ -155,6 +159,8 @@ public:
void setImage(const QImage &);
void setPixmap(const QQuickPixmap &other);
+ QColorSpace colorSpace() const;
+
QQuickTextureFactory *textureFactory() const;
QRect rect() const;
@@ -163,9 +169,10 @@ public:
void load(QQmlEngine *, const QUrl &);
void load(QQmlEngine *, const QUrl &, QQuickPixmap::Options options);
- void load(QQmlEngine *, const QUrl &, const QSize &);
- void load(QQmlEngine *, const QUrl &, const QSize &, QQuickPixmap::Options options);
- void load(QQmlEngine *, const QUrl &, const QSize &, QQuickPixmap::Options options, const QQuickImageProviderOptions &providerOptions, int frame = 0, int frameCount = 1);
+ void load(QQmlEngine *, const QUrl &, const QRect &requestRegion, const QSize &requestSize);
+ void load(QQmlEngine *, const QUrl &, const QRect &requestRegion, const QSize &requestSize, QQuickPixmap::Options options);
+ void load(QQmlEngine *, const QUrl &, const QRect &requestRegion, const QSize &requestSize,
+ QQuickPixmap::Options options, const QQuickImageProviderOptions &providerOptions, int frame = 0, int frameCount = 1);
void clear();
void clear(QObject *);
@@ -176,7 +183,8 @@ public:
bool connectDownloadProgress(QObject *, int);
static void purgeCache();
- static bool isCached(const QUrl &url, const QSize &requestSize, const int frame, const QQuickImageProviderOptions &options);
+ static bool isCached(const QUrl &url, const QRect &requestRegion, const QSize &requestSize,
+ const int frame, const QQuickImageProviderOptions &options);
static const QLatin1String itemGrabberScheme;
diff --git a/src/quick/util/qquickpropertychanges_p.h b/src/quick/util/qquickpropertychanges_p.h
index 27a00420af..ff48de96c6 100644
--- a/src/quick/util/qquickpropertychanges_p.h
+++ b/src/quick/util/qquickpropertychanges_p.h
@@ -66,6 +66,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPropertyChanges : public QQuickStateOperation
Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues)
Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit)
QML_NAMED_ELEMENT(PropertyChanges)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickPropertyChanges();
diff --git a/src/quick/util/qquickshortcut_p.h b/src/quick/util/qquickshortcut_p.h
index 0e66a38e75..67dab928b7 100644
--- a/src/quick/util/qquickshortcut_p.h
+++ b/src/quick/util/qquickshortcut_p.h
@@ -67,14 +67,14 @@ class QQuickShortcut : public QObject, public QQmlParserStatus
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QVariant sequence READ sequence WRITE setSequence NOTIFY sequenceChanged FINAL)
- Q_PROPERTY(QVariantList sequences READ sequences WRITE setSequences NOTIFY sequencesChanged FINAL REVISION 9)
- Q_PROPERTY(QString nativeText READ nativeText NOTIFY sequenceChanged FINAL REVISION 6)
- Q_PROPERTY(QString portableText READ portableText NOTIFY sequenceChanged FINAL REVISION 6)
+ Q_PROPERTY(QVariantList sequences READ sequences WRITE setSequences NOTIFY sequencesChanged FINAL REVISION(2, 9))
+ Q_PROPERTY(QString nativeText READ nativeText NOTIFY sequenceChanged FINAL REVISION(2, 6))
+ Q_PROPERTY(QString portableText READ portableText NOTIFY sequenceChanged FINAL REVISION(2, 6))
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged FINAL)
Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY autoRepeatChanged FINAL)
Q_PROPERTY(Qt::ShortcutContext context READ context WRITE setContext NOTIFY contextChanged FINAL)
QML_NAMED_ELEMENT(Shortcut)
- QML_ADDED_IN_MINOR_VERSION(5)
+ QML_ADDED_IN_VERSION(2, 5)
public:
explicit QQuickShortcut(QObject *parent = nullptr);
@@ -100,7 +100,7 @@ public:
Q_SIGNALS:
void sequenceChanged();
- Q_REVISION(9) void sequencesChanged();
+ Q_REVISION(2, 9) void sequencesChanged();
void enabledChanged();
void autoRepeatChanged();
void contextChanged();
diff --git a/src/quick/util/qquicksmoothedanimation_p.h b/src/quick/util/qquicksmoothedanimation_p.h
index d7e637446d..4a53a4406f 100644
--- a/src/quick/util/qquicksmoothedanimation_p.h
+++ b/src/quick/util/qquicksmoothedanimation_p.h
@@ -69,6 +69,7 @@ class Q_AUTOTEST_EXPORT QQuickSmoothedAnimation : public QQuickNumberAnimation
Q_PROPERTY(ReversingMode reversingMode READ reversingMode WRITE setReversingMode NOTIFY reversingModeChanged)
Q_PROPERTY(qreal maximumEasingTime READ maximumEasingTime WRITE setMaximumEasingTime NOTIFY maximumEasingTimeChanged)
QML_NAMED_ELEMENT(SmoothedAnimation)
+ QML_ADDED_IN_VERSION(2, 0)
public:
enum ReversingMode { Eased, Immediate, Sync };
diff --git a/src/quick/util/qquickspringanimation_p.h b/src/quick/util/qquickspringanimation_p.h
index 771b746622..c09806e0ec 100644
--- a/src/quick/util/qquickspringanimation_p.h
+++ b/src/quick/util/qquickspringanimation_p.h
@@ -72,6 +72,7 @@ class Q_AUTOTEST_EXPORT QQuickSpringAnimation : public QQuickNumberAnimation
Q_PROPERTY(qreal modulus READ modulus WRITE setModulus NOTIFY modulusChanged)
Q_PROPERTY(qreal mass READ mass WRITE setMass NOTIFY massChanged)
QML_NAMED_ELEMENT(SpringAnimation)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickSpringAnimation(QObject *parent=nullptr);
diff --git a/src/quick/util/qquickstate.cpp b/src/quick/util/qquickstate.cpp
index c106528f45..71ab1f4d62 100644
--- a/src/quick/util/qquickstate.cpp
+++ b/src/quick/util/qquickstate.cpp
@@ -267,9 +267,13 @@ void QQuickState::setExtends(const QString &extends)
QQmlListProperty<QQuickStateOperation> QQuickState::changes()
{
Q_D(QQuickState);
- return QQmlListProperty<QQuickStateOperation>(this, &d->operations, QQuickStatePrivate::operations_append,
- QQuickStatePrivate::operations_count, QQuickStatePrivate::operations_at,
- QQuickStatePrivate::operations_clear);
+ return QQmlListProperty<QQuickStateOperation>(this, &d->operations,
+ QQuickStatePrivate::operations_append,
+ QQuickStatePrivate::operations_count,
+ QQuickStatePrivate::operations_at,
+ QQuickStatePrivate::operations_clear,
+ QQuickStatePrivate::operations_replace,
+ QQuickStatePrivate::operations_removeLast);
}
int QQuickState::operationCount() const
diff --git a/src/quick/util/qquickstate_p.h b/src/quick/util/qquickstate_p.h
index af49bb1c2f..ee9aa92bbd 100644
--- a/src/quick/util/qquickstate_p.h
+++ b/src/quick/util/qquickstate_p.h
@@ -126,6 +126,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickStateOperation : public QObject
{
Q_OBJECT
QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickStateOperation(QObject *parent = nullptr)
: QObject(parent) {}
@@ -159,6 +160,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickState : public QObject
Q_CLASSINFO("DefaultProperty", "changes")
Q_CLASSINFO("DeferredPropertyNames", "changes")
QML_NAMED_ELEMENT(State)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickState(QObject *parent=nullptr);
diff --git a/src/quick/util/qquickstate_p_p.h b/src/quick/util/qquickstate_p_p.h
index 2fa5321165..ae4ed291b5 100644
--- a/src/quick/util/qquickstate_p_p.h
+++ b/src/quick/util/qquickstate_p_p.h
@@ -244,6 +244,23 @@ public:
QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
return list->at(index);
}
+ static void operations_replace(QQmlListProperty<QQuickStateOperation> *prop, int index,
+ QQuickStateOperation *op) {
+ QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
+ auto &guard = list->at(index);
+ if (guard.object() == op) {
+ op->setState(qobject_cast<QQuickState*>(prop->object));
+ } else {
+ list->at(index)->setState(nullptr);
+ op->setState(qobject_cast<QQuickState*>(prop->object));
+ list->replace(index, OperationGuard(op, list));
+ }
+ }
+ static void operations_removeLast(QQmlListProperty<QQuickStateOperation> *prop) {
+ QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
+ list->last()->setState(nullptr);
+ list->removeLast();
+ }
QQuickTransitionManager transitionManager;
diff --git a/src/quick/util/qquickstatechangescript_p.h b/src/quick/util/qquickstatechangescript_p.h
index 931baaca4e..62f4910606 100644
--- a/src/quick/util/qquickstatechangescript_p.h
+++ b/src/quick/util/qquickstatechangescript_p.h
@@ -65,6 +65,7 @@ class Q_AUTOTEST_EXPORT QQuickStateChangeScript : public QQuickStateOperation, p
Q_PROPERTY(QQmlScriptString script READ script WRITE setScript)
Q_PROPERTY(QString name READ name WRITE setName)
QML_NAMED_ELEMENT(StateChangeScript)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickStateChangeScript(QObject *parent=nullptr);
diff --git a/src/quick/util/qquickstategroup.cpp b/src/quick/util/qquickstategroup.cpp
index 46e7d62fc1..2109aafc10 100644
--- a/src/quick/util/qquickstategroup.cpp
+++ b/src/quick/util/qquickstategroup.cpp
@@ -70,6 +70,8 @@ public:
static int count_state(QQmlListProperty<QQuickState> *list);
static QQuickState *at_state(QQmlListProperty<QQuickState> *list, int index);
static void clear_states(QQmlListProperty<QQuickState> *list);
+ static void replace_states(QQmlListProperty<QQuickState> *list, int index, QQuickState *state);
+ static void removeLast_states(QQmlListProperty<QQuickState> *list);
static void append_transition(QQmlListProperty<QQuickTransition> *list, QQuickTransition *state);
static int count_transitions(QQmlListProperty<QQuickTransition> *list);
@@ -163,10 +165,13 @@ QList<QQuickState *> QQuickStateGroup::states() const
QQmlListProperty<QQuickState> QQuickStateGroup::statesProperty()
{
Q_D(QQuickStateGroup);
- return QQmlListProperty<QQuickState>(this, &d->states, &QQuickStateGroupPrivate::append_state,
- &QQuickStateGroupPrivate::count_state,
- &QQuickStateGroupPrivate::at_state,
- &QQuickStateGroupPrivate::clear_states);
+ return QQmlListProperty<QQuickState>(this, &d->states,
+ &QQuickStateGroupPrivate::append_state,
+ &QQuickStateGroupPrivate::count_state,
+ &QQuickStateGroupPrivate::at_state,
+ &QQuickStateGroupPrivate::clear_states,
+ &QQuickStateGroupPrivate::replace_states,
+ &QQuickStateGroupPrivate::removeLast_states);
}
void QQuickStateGroupPrivate::append_state(QQmlListProperty<QQuickState> *list, QQuickState *state)
@@ -201,6 +206,29 @@ void QQuickStateGroupPrivate::clear_states(QQmlListProperty<QQuickState> *list)
_this->d_func()->states.clear();
}
+void QQuickStateGroupPrivate::replace_states(QQmlListProperty<QQuickState> *list, int index, QQuickState *state)
+{
+ auto *self = qobject_cast<QQuickStateGroup *>(list->object);
+ auto *d = self->d_func();
+ auto *oldState = d->states.at(index);
+ if (oldState != state) {
+ oldState->setStateGroup(nullptr);
+ state->setStateGroup(self);
+ d->states.replace(index, state);
+ if (d->currentState == oldState->name())
+ d->setCurrentStateInternal(state->name(), true);
+ }
+}
+
+void QQuickStateGroupPrivate::removeLast_states(QQmlListProperty<QQuickState> *list)
+{
+ auto *d = qobject_cast<QQuickStateGroup *>(list->object)->d_func();
+ if (d->currentState == d->states.last()->name())
+ d->setCurrentStateInternal(d->states.length() > 1 ? d->states.first()->name() : QString(), true);
+ d->states.last()->setStateGroup(nullptr);
+ d->states.removeLast();
+}
+
/*!
\qmlproperty list<Transition> QtQuick::StateGroup::transitions
This property holds a list of transitions defined by the state group.
diff --git a/src/quick/util/qquickstategroup_p.h b/src/quick/util/qquickstategroup_p.h
index 11a0c5f442..c3d66fd824 100644
--- a/src/quick/util/qquickstategroup_p.h
+++ b/src/quick/util/qquickstategroup_p.h
@@ -66,6 +66,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickStateGroup : public QObject, public QQmlParse
Q_PROPERTY(QQmlListProperty<QQuickState> states READ statesProperty DESIGNABLE false)
Q_PROPERTY(QQmlListProperty<QQuickTransition> transitions READ transitionsProperty DESIGNABLE false)
QML_NAMED_ELEMENT(StateGroup)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickStateGroup(QObject * = nullptr);
diff --git a/src/quick/util/qquickstyledtext.cpp b/src/quick/util/qquickstyledtext.cpp
index 08d06c66ab..660852ba83 100644
--- a/src/quick/util/qquickstyledtext.cpp
+++ b/src/quick/util/qquickstyledtext.cpp
@@ -706,7 +706,7 @@ void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QStri
// to avoid a relayout later on.
QUrl url = baseUrl.resolved(image->url);
if (url.isLocalFile()) {
- image->pix = new QQuickPixmap(context->engine(), url, image->size);
+ image->pix = new QQuickPixmap(context->engine(), url, QRect(), image->size);
if (image->pix && image->pix->isReady()) {
image->size = image->pix->implicitSize();
} else {
diff --git a/src/quick/util/qquicksystempalette_p.h b/src/quick/util/qquicksystempalette_p.h
index c6d9fc2604..43d7277bea 100644
--- a/src/quick/util/qquicksystempalette_p.h
+++ b/src/quick/util/qquicksystempalette_p.h
@@ -80,6 +80,7 @@ class Q_AUTOTEST_EXPORT QQuickSystemPalette : public QObject
Q_PROPERTY(QColor highlight READ highlight NOTIFY paletteChanged)
Q_PROPERTY(QColor highlightedText READ highlightedText NOTIFY paletteChanged)
QML_NAMED_ELEMENT(SystemPalette)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickSystemPalette(QObject *parent=nullptr);
diff --git a/src/quick/util/qquicktextmetrics_p.h b/src/quick/util/qquicktextmetrics_p.h
index a1d64e3d0a..33c64073c2 100644
--- a/src/quick/util/qquicktextmetrics_p.h
+++ b/src/quick/util/qquicktextmetrics_p.h
@@ -75,7 +75,7 @@ class Q_AUTOTEST_EXPORT QQuickTextMetrics : public QObject
Q_PROPERTY(Qt::TextElideMode elide READ elide WRITE setElide NOTIFY elideChanged FINAL)
Q_PROPERTY(qreal elideWidth READ elideWidth WRITE setElideWidth NOTIFY elideWidthChanged FINAL)
QML_NAMED_ELEMENT(TextMetrics)
- QML_ADDED_IN_MINOR_VERSION(4)
+ QML_ADDED_IN_VERSION(2, 4)
public:
explicit QQuickTextMetrics(QObject *parent = 0);
diff --git a/src/quick/util/qquicktimeline_p_p.h b/src/quick/util/qquicktimeline_p_p.h
index abb5369b7b..fc5bd15ed1 100644
--- a/src/quick/util/qquicktimeline_p_p.h
+++ b/src/quick/util/qquicktimeline_p_p.h
@@ -52,6 +52,7 @@
//
#include <QtCore/QObject>
+#include <private/qtquickglobal_p.h>
#include "private/qabstractanimationjob_p.h"
QT_BEGIN_NAMESPACE
@@ -61,7 +62,7 @@ class QQuickTimeLineValue;
class QQuickTimeLineCallback;
struct QQuickTimeLinePrivate;
class QQuickTimeLineObject;
-class Q_AUTOTEST_EXPORT QQuickTimeLine : public QObject, QAbstractAnimationJob
+class Q_QUICK_PRIVATE_EXPORT QQuickTimeLine : public QObject, QAbstractAnimationJob
{
Q_OBJECT
public:
diff --git a/src/quick/util/qquicktransition_p.h b/src/quick/util/qquicktransition_p.h
index 6e45143126..bfb7d75821 100644
--- a/src/quick/util/qquicktransition_p.h
+++ b/src/quick/util/qquicktransition_p.h
@@ -104,6 +104,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTransition : public QObject
Q_CLASSINFO("DefaultProperty", "animations")
Q_CLASSINFO("DeferredPropertyNames", "animations")
QML_NAMED_ELEMENT(Transition)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickTransition(QObject *parent=nullptr);
diff --git a/src/quick/util/qquickvalidator_p.h b/src/quick/util/qquickvalidator_p.h
index a0dc2cd5ba..029737e10b 100644
--- a/src/quick/util/qquickvalidator_p.h
+++ b/src/quick/util/qquickvalidator_p.h
@@ -62,6 +62,7 @@ class Q_AUTOTEST_EXPORT QQuickIntValidator : public QIntValidator
Q_OBJECT
Q_PROPERTY(QString locale READ localeName WRITE setLocaleName RESET resetLocaleName NOTIFY localeNameChanged)
QML_NAMED_ELEMENT(IntValidator)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickIntValidator(QObject *parent = nullptr);
@@ -78,6 +79,7 @@ class Q_AUTOTEST_EXPORT QQuickDoubleValidator : public QDoubleValidator
Q_OBJECT
Q_PROPERTY(QString locale READ localeName WRITE setLocaleName RESET resetLocaleName NOTIFY localeNameChanged)
QML_NAMED_ELEMENT(DoubleValidator)
+ QML_ADDED_IN_VERSION(2, 0)
public:
QQuickDoubleValidator(QObject *parent = nullptr);
diff --git a/src/quick/util/qquickvaluetypes.cpp b/src/quick/util/qquickvaluetypes.cpp
index f9cd28cb24..517ed5da38 100644
--- a/src/quick/util/qquickvaluetypes.cpp
+++ b/src/quick/util/qquickvaluetypes.cpp
@@ -41,6 +41,7 @@
#include <qtquickglobal.h>
#include <private/qqmlvaluetype_p.h>
+#include <private/qcolorspace_p.h>
#include <private/qfont_p.h>
@@ -784,6 +785,47 @@ void QQuickFontValueType::setPreferShaping(bool enable)
v.setStyleStrategy(static_cast<QFont::StyleStrategy>(v.styleStrategy() | QFont::PreferNoShaping));
}
+QQuickColorSpaceValueType::NamedColorSpace QQuickColorSpaceValueType::namedColorSpace() const noexcept
+{
+ if (const auto *p = QColorSpacePrivate::get(v))
+ return (QQuickColorSpaceValueType::NamedColorSpace)p->namedColorSpace;
+ return QQuickColorSpaceValueType::Unknown;
+}
+void QQuickColorSpaceValueType::setNamedColorSpace(QQuickColorSpaceValueType::NamedColorSpace namedColorSpace)
+{
+ v = { (QColorSpace::NamedColorSpace)namedColorSpace };
+}
+
+QQuickColorSpaceValueType::Primaries QQuickColorSpaceValueType::primaries() const noexcept
+{
+ return (QQuickColorSpaceValueType::Primaries)v.primaries();
+}
+
+void QQuickColorSpaceValueType::setPrimaries(QQuickColorSpaceValueType::Primaries primariesId)
+{
+ v.setPrimaries((QColorSpace::Primaries)primariesId);
+}
+
+QQuickColorSpaceValueType::TransferFunction QQuickColorSpaceValueType::transferFunction() const noexcept
+{
+ return (QQuickColorSpaceValueType::TransferFunction)v.transferFunction();
+}
+
+void QQuickColorSpaceValueType::setTransferFunction(QQuickColorSpaceValueType::TransferFunction transferFunction)
+{
+ v.setTransferFunction((QColorSpace::TransferFunction)transferFunction, v.gamma());
+}
+
+float QQuickColorSpaceValueType::gamma() const noexcept
+{
+ return v.gamma();
+}
+
+void QQuickColorSpaceValueType::setGamma(float gamma)
+{
+ v.setTransferFunction(v.transferFunction(), gamma);
+}
+
QT_END_NAMESPACE
#include "moc_qquickvaluetypes_p.cpp"
diff --git a/src/quick/util/qquickvaluetypes_p.h b/src/quick/util/qquickvaluetypes_p.h
index 91a5ea83e5..ccd9eefe47 100644
--- a/src/quick/util/qquickvaluetypes_p.h
+++ b/src/quick/util/qquickvaluetypes_p.h
@@ -56,6 +56,7 @@
#include <private/qqmlvaluetype_p.h>
#include <QtGui/QColor>
+#include <QtGui/QColorSpace>
#include <QtGui/QVector2D>
#include <QtGui/QVector3D>
#include <QtGui/QVector4D>
@@ -329,6 +330,7 @@ class QQuickFontValueType
Q_PROPERTY(bool preferShaping READ preferShaping WRITE setPreferShaping FINAL)
QML_NAMED_ELEMENT(Font)
+ QML_ADDED_IN_VERSION(2, 0)
QML_UNCREATABLE("Element is not creatable.")
public:
@@ -408,6 +410,58 @@ public:
void setPreferShaping(bool b);
};
+class QQuickColorSpaceValueType
+{
+ QColorSpace v;
+ Q_GADGET
+
+ Q_PROPERTY(NamedColorSpace namedColorSpace READ namedColorSpace WRITE setNamedColorSpace FINAL)
+ Q_PROPERTY(Primaries primaries READ primaries WRITE setPrimaries FINAL)
+ Q_PROPERTY(TransferFunction transferFunction READ transferFunction WRITE setTransferFunction FINAL)
+ Q_PROPERTY(float gamma READ gamma WRITE setGamma FINAL)
+
+ QML_NAMED_ELEMENT(ColorSpace)
+ QML_ADDED_IN_VERSION(2, 15)
+ Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
+
+public:
+ enum NamedColorSpace {
+ Unknown = 0,
+ SRgb,
+ SRgbLinear,
+ AdobeRgb,
+ DisplayP3,
+ ProPhotoRgb
+ };
+ Q_ENUM(NamedColorSpace)
+
+ enum class Primaries {
+ Custom = 0,
+ SRgb,
+ AdobeRgb,
+ DciP3D65,
+ ProPhotoRgb
+ };
+ Q_ENUM(Primaries)
+ enum class TransferFunction {
+ Custom = 0,
+ Linear,
+ Gamma,
+ SRgb,
+ ProPhotoRgb
+ };
+ Q_ENUM(TransferFunction)
+
+ NamedColorSpace namedColorSpace() const noexcept;
+ void setNamedColorSpace(NamedColorSpace namedColorSpace);
+ Primaries primaries() const noexcept;
+ void setPrimaries(Primaries primariesId);
+ TransferFunction transferFunction() const noexcept;
+ void setTransferFunction(TransferFunction transferFunction);
+ float gamma() const noexcept;
+ void setGamma(float gamma);
+};
+
QT_END_NAMESPACE
#endif // QQUICKVALUETYPES_P_H
diff --git a/src/quickshapes/qquickshape_p.h b/src/quickshapes/qquickshape_p.h
index f86f2b03d6..ca72c628c5 100644
--- a/src/quickshapes/qquickshape_p.h
+++ b/src/quickshapes/qquickshape_p.h
@@ -76,6 +76,7 @@ class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShapeGradient : public QQuickGradient
Q_CLASSINFO("DefaultProperty", "stops")
QML_NAMED_ELEMENT(ShapeGradient)
+ QML_ADDED_IN_VERSION(1, 0)
QML_UNCREATABLE("ShapeGradient is an abstract base class.");
public:
@@ -107,6 +108,7 @@ class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShapeLinearGradient : public QQuickShap
Q_PROPERTY(qreal y2 READ y2 WRITE setY2 NOTIFY y2Changed)
Q_CLASSINFO("DefaultProperty", "stops")
QML_NAMED_ELEMENT(LinearGradient)
+ QML_ADDED_IN_VERSION(1, 0)
public:
QQuickShapeLinearGradient(QObject *parent = nullptr);
@@ -142,6 +144,7 @@ class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShapeRadialGradient : public QQuickShap
Q_PROPERTY(qreal focalRadius READ focalRadius WRITE setFocalRadius NOTIFY focalRadiusChanged)
Q_CLASSINFO("DefaultProperty", "stops")
QML_NAMED_ELEMENT(RadialGradient)
+ QML_ADDED_IN_VERSION(1, 0)
public:
QQuickShapeRadialGradient(QObject *parent = nullptr);
@@ -187,6 +190,7 @@ class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShapeConicalGradient : public QQuickSha
Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged)
Q_CLASSINFO("DefaultProperty", "stops")
QML_NAMED_ELEMENT(ConicalGradient)
+ QML_ADDED_IN_VERSION(1, 0)
public:
QQuickShapeConicalGradient(QObject *parent = nullptr);
@@ -225,8 +229,9 @@ class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShapePath : public QQuickPath
Q_PROPERTY(qreal dashOffset READ dashOffset WRITE setDashOffset NOTIFY dashOffsetChanged)
Q_PROPERTY(QVector<qreal> dashPattern READ dashPattern WRITE setDashPattern NOTIFY dashPatternChanged)
Q_PROPERTY(QQuickShapeGradient *fillGradient READ fillGradient WRITE setFillGradient RESET resetFillGradient)
- Q_PROPERTY(QSizeF scale READ scale WRITE setScale NOTIFY scaleChanged REVISION 14)
+ Q_PROPERTY(QSizeF scale READ scale WRITE setScale NOTIFY scaleChanged REVISION(1, 14))
QML_NAMED_ELEMENT(ShapePath)
+ QML_ADDED_IN_VERSION(1, 0)
public:
enum FillRule {
@@ -318,10 +323,11 @@ class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShape : public QQuickItem
Q_PROPERTY(bool asynchronous READ asynchronous WRITE setAsynchronous NOTIFY asynchronousChanged)
Q_PROPERTY(bool vendorExtensionsEnabled READ vendorExtensionsEnabled WRITE setVendorExtensionsEnabled NOTIFY vendorExtensionsEnabledChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
- Q_PROPERTY(ContainsMode containsMode READ containsMode WRITE setContainsMode NOTIFY containsModeChanged REVISION 11)
+ Q_PROPERTY(ContainsMode containsMode READ containsMode WRITE setContainsMode NOTIFY containsModeChanged REVISION(1, 11))
Q_PROPERTY(QQmlListProperty<QObject> data READ data)
Q_CLASSINFO("DefaultProperty", "data")
QML_NAMED_ELEMENT(Shape)
+ QML_ADDED_IN_VERSION(1, 0)
public:
enum RendererType {
@@ -377,7 +383,7 @@ Q_SIGNALS:
void asynchronousChanged();
void vendorExtensionsEnabledChanged();
void statusChanged();
- Q_REVISION(11) void containsModeChanged();
+ Q_REVISION(1, 11) void containsModeChanged();
private:
Q_DISABLE_COPY(QQuickShape)
diff --git a/src/quickshapes/qquickshapesglobal_p.h b/src/quickshapes/qquickshapesglobal_p.h
index 2f559b45a0..40f6cfbdcf 100644
--- a/src/quickshapes/qquickshapesglobal_p.h
+++ b/src/quickshapes/qquickshapesglobal_p.h
@@ -59,5 +59,6 @@ QT_BEGIN_NAMESPACE
QT_END_NAMESPACE
+void Q_QUICKSHAPES_PRIVATE_EXPORT qml_register_types_QtQuick_Shapes();
#endif // QQUICKSHAPESGLOBAL_P_H
diff --git a/src/quickshapes/quickshapes.pro b/src/quickshapes/quickshapes.pro
index 7c71aa4f4a..7b77391d92 100644
--- a/src/quickshapes/quickshapes.pro
+++ b/src/quickshapes/quickshapes.pro
@@ -35,5 +35,5 @@ load(qt_module)
QMLTYPES_FILENAME = plugins.qmltypes
QMLTYPES_INSTALL_DIR = $$[QT_INSTALL_QML]/QtQuick/Shapes
QML_IMPORT_NAME = QtQuick.Shapes
-IMPORT_VERSION = 1.15
+QML_IMPORT_VERSION = $$QT_VERSION
CONFIG += qmltypes install_qmltypes install_metatypes
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index dbb103973c..db7ae22767 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -59,9 +59,11 @@
#include <QtGui/qpa/qplatformintegration.h>
#if QT_CONFIG(opengl)
+#include <private/qopenglcontext_p.h>
+#include <private/qopenglextensions_p.h>
+#include <QOpenGLFramebufferObject>
#include <QOpenGLContext>
#include <QOpenGLFunctions>
-#include <private/qopenglextensions_p.h>
#endif
#include <QtGui/QPainter>
diff --git a/src/src.pro b/src/src.pro
index 2855102eff..c9de88e942 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -4,9 +4,6 @@ include($$OUT_PWD/qml/qtqml-config.pri)
include($$OUT_PWD/quick/qtquick-config.pri)
QT_FOR_CONFIG += qml qml-private quick-private
-# Otherwise we cannot compile qmltyperegistrar
-requires(qtConfig(commandlineparser))
-
# We need qmltyperegistrar for all type registrations, even in qml
SUBDIRS += \
qmltyperegistrar \