aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2016-11-17 16:24:33 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2016-11-17 16:24:33 +0100
commit0beb79fb0e9ed814b3e9447ccd97a0c099af9e4b (patch)
tree28f7411dc50f099ef0812c830525b4f50ed7ecf4 /src
parent12a3eff085bc7eb30a5283e32009d2899b464278 (diff)
parenta7fd83cd0cecb789006baecabfc6a49c49b7f48c (diff)
Merge branch remote-tracking branch 'origin/dev' into wip/pointerhandler
We no longer have any hope of getting this into 5.8. Change-Id: I2decfa47e589ba7ae2d6b951c6517a2c311d0192
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/masm/wtf/MathExtras.h2
-rw-r--r--src/imports/folderlistmodel/fileinfothread_p.h2
-rw-r--r--src/imports/folderlistmodel/fileproperty_p.h20
-rw-r--r--src/imports/folderlistmodel/qquickfolderlistmodel.h12
-rw-r--r--src/imports/imports.pro3
-rw-r--r--src/imports/layouts/qquickgridlayoutengine_p.h6
-rw-r--r--src/imports/layouts/qquicklinearlayout.cpp30
-rw-r--r--src/imports/layouts/qquicklinearlayout_p.h4
-rw-r--r--src/imports/localstorage/plugin.cpp2
-rw-r--r--src/imports/settings/qqmlsettings_p.h6
-rw-r--r--src/imports/settings/settings.pro3
-rw-r--r--src/imports/statemachine/state.h4
-rw-r--r--src/imports/statemachine/statemachine.h4
-rw-r--r--src/imports/statemachine/timeouttransition.h4
-rw-r--r--src/imports/xmllistmodel/qqmlxmllistmodel.cpp4
-rw-r--r--src/imports/xmllistmodel/qqmlxmllistmodel_p.h14
-rw-r--r--src/particles/qquickage_p.h3
-rw-r--r--src/particles/qquickangledirection.cpp2
-rw-r--r--src/particles/qquickangledirection_p.h2
-rw-r--r--src/particles/qquickcumulativedirection.cpp2
-rw-r--r--src/particles/qquickcumulativedirection_p.h2
-rw-r--r--src/particles/qquickcustomaffector_p.h5
-rw-r--r--src/particles/qquickcustomparticle_p.h14
-rw-r--r--src/particles/qquickdirection.cpp2
-rw-r--r--src/particles/qquickdirection_p.h2
-rw-r--r--src/particles/qquickellipseextruder_p.h4
-rw-r--r--src/particles/qquickfriction_p.h2
-rw-r--r--src/particles/qquickgravity_p.h3
-rw-r--r--src/particles/qquickgroupgoal_p.h2
-rw-r--r--src/particles/qquickimageparticle_p.h12
-rw-r--r--src/particles/qquickitemparticle_p.h10
-rw-r--r--src/particles/qquicklineextruder_p.h6
-rw-r--r--src/particles/qquickmaskextruder_p.h4
-rw-r--r--src/particles/qquickparticleaffector.cpp2
-rw-r--r--src/particles/qquickparticleaffector_p.h4
-rw-r--r--src/particles/qquickparticleemitter_p.h2
-rw-r--r--src/particles/qquickparticlegroup_p.h4
-rw-r--r--src/particles/qquickparticlepainter_p.h4
-rw-r--r--src/particles/qquickparticlesystem_p.h6
-rw-r--r--src/particles/qquickpointattractor_p.h3
-rw-r--r--src/particles/qquickpointdirection.cpp2
-rw-r--r--src/particles/qquickpointdirection_p.h2
-rw-r--r--src/particles/qquickrectangleextruder_p.h4
-rw-r--r--src/particles/qquickspritegoal_p.h3
-rw-r--r--src/particles/qquicktargetdirection.cpp2
-rw-r--r--src/particles/qquicktargetdirection_p.h2
-rw-r--r--src/particles/qquicktrailemitter_p.h4
-rw-r--r--src/particles/qquickturbulence_p.h6
-rw-r--r--src/particles/qquickv4particledata.cpp2
-rw-r--r--src/particles/qquickv4particledata_p.h2
-rw-r--r--src/particles/qquickwander_p.h3
-rw-r--r--src/plugins/plugins.pro2
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp14
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp39
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp16
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp4
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h14
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp33
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp23
-rw-r--r--src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp10
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp4
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp51
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp10
-rw-r--r--src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp12
-rw-r--r--src/plugins/qmltooling/qmltooling.pro47
-rw-r--r--src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials.cpp2
-rw-r--r--src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp14
-rw-r--r--src/plugins/scenegraph/d3d12/qsgd3d12renderer.cpp9
-rw-r--r--src/plugins/scenegraph/d3d12/qsgd3d12spritenode.cpp4
-rw-r--r--src/plugins/scenegraph/scenegraph.pro3
-rw-r--r--src/qml/animations/qanimationgroupjob_p.h2
-rw-r--r--src/qml/animations/qparallelanimationgroupjob_p.h12
-rw-r--r--src/qml/compiler/compiler.pri15
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp24
-rw-r--r--src/qml/compiler/qqmlirbuilder_p.h40
-rw-r--r--src/qml/compiler/qqmltypecompiler.cpp10
-rw-r--r--src/qml/compiler/qqmltypecompiler_p.h3
-rw-r--r--src/qml/compiler/qv4codegen_p.h228
-rw-r--r--src/qml/compiler/qv4compileddata.cpp75
-rw-r--r--src/qml/compiler/qv4compileddata_p.h22
-rw-r--r--src/qml/compiler/qv4compiler.cpp10
-rw-r--r--src/qml/compiler/qv4instr_moth_p.h6
-rw-r--r--src/qml/compiler/qv4isel_moth.cpp43
-rw-r--r--src/qml/compiler/qv4isel_moth_p.h125
-rw-r--r--src/qml/compiler/qv4ssa.cpp124
-rw-r--r--src/qml/compiler/qv4ssa_p.h15
-rw-r--r--src/qml/configure.json37
-rw-r--r--src/qml/debugger/qqmldebug.cpp18
-rw-r--r--src/qml/debugger/qqmldebugconnector.cpp8
-rw-r--r--src/qml/debugger/qqmlmemoryprofiler.cpp37
-rw-r--r--src/qml/debugger/qqmlmemoryprofiler_p.h48
-rw-r--r--src/qml/doc/src/cppclasses/topic.qdoc4
-rw-r--r--src/qml/doc/src/cppintegration/data.qdoc4
-rw-r--r--src/qml/doc/src/cppintegration/exposecppattributes.qdoc2
-rw-r--r--src/qml/doc/src/javascript/dynamicobjectcreation.qdoc2
-rw-r--r--src/qml/doc/src/javascript/functionlist.qdoc2
-rw-r--r--src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc8
-rw-r--r--src/qml/doc/src/qmllanguageref/documents/scope.qdoc2
-rw-r--r--src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc5
-rw-r--r--src/qml/doc/src/qmllanguageref/syntax/signals.qdoc3
-rw-r--r--src/qml/jit/qv4assembler.cpp38
-rw-r--r--src/qml/jit/qv4assembler_p.h5
-rw-r--r--src/qml/jit/qv4isel_masm.cpp125
-rw-r--r--src/qml/jit/qv4isel_masm_p.h7
-rw-r--r--src/qml/jit/qv4regalloc.cpp124
-rw-r--r--src/qml/jsruntime/jsruntime.pri11
-rw-r--r--src/qml/jsruntime/qv4arraydata.cpp33
-rw-r--r--src/qml/jsruntime/qv4arrayobject.cpp89
-rw-r--r--src/qml/jsruntime/qv4arrayobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4engine.cpp10
-rw-r--r--src/qml/jsruntime/qv4executableallocator.cpp2
-rw-r--r--src/qml/jsruntime/qv4include.cpp14
-rw-r--r--src/qml/jsruntime/qv4include_p.h4
-rw-r--r--src/qml/jsruntime/qv4internalclass.cpp12
-rw-r--r--src/qml/jsruntime/qv4jsonobject.cpp5
-rw-r--r--src/qml/jsruntime/qv4lookup.cpp2
-rw-r--r--src/qml/jsruntime/qv4managed_p.h16
-rw-r--r--src/qml/jsruntime/qv4numberobject.cpp24
-rw-r--r--src/qml/jsruntime/qv4object_p.h16
-rw-r--r--src/qml/jsruntime/qv4persistent.cpp28
-rw-r--r--src/qml/jsruntime/qv4persistent_p.h25
-rw-r--r--src/qml/jsruntime/qv4profiling.cpp2
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp34
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper_p.h11
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp2
-rw-r--r--src/qml/jsruntime/qv4scopedvalue_p.h2
-rw-r--r--src/qml/jsruntime/qv4script.cpp6
-rw-r--r--src/qml/jsruntime/qv4sequenceobject.cpp33
-rw-r--r--src/qml/jsruntime/qv4util_p.h6
-rw-r--r--src/qml/jsruntime/qv4value_p.h270
-rw-r--r--src/qml/jsruntime/qv4variantobject.cpp7
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp26
-rw-r--r--src/qml/jsruntime/qv4vme_moth_p.h3
-rw-r--r--src/qml/memory/qv4mm.cpp13
-rw-r--r--src/qml/memory/qv4mm_p.h1
-rw-r--r--src/qml/parser/qqmljsast_p.h554
-rw-r--r--src/qml/qml.pro10
-rw-r--r--src/qml/qml/ftw/qqmlthread.cpp6
-rw-r--r--src/qml/qml/ftw/qqmlthread_p.h24
-rw-r--r--src/qml/qml/qqmlapplicationengine.cpp17
-rw-r--r--src/qml/qml/qqmlapplicationengine.h6
-rw-r--r--src/qml/qml/qqmlbinding.cpp2
-rw-r--r--src/qml/qml/qqmlbinding_p.h4
-rw-r--r--src/qml/qml/qqmlboundsignal.cpp2
-rw-r--r--src/qml/qml/qqmlboundsignal_p.h4
-rw-r--r--src/qml/qml/qqmlcomponent.cpp8
-rw-r--r--src/qml/qml/qqmlcomponent_p.h4
-rw-r--r--src/qml/qml/qqmlcontext_p.h4
-rw-r--r--src/qml/qml/qqmldata_p.h15
-rw-r--r--src/qml/qml/qqmlengine.cpp48
-rw-r--r--src/qml/qml/qqmlengine.h6
-rw-r--r--src/qml/qml/qqmlengine_p.h2
-rw-r--r--src/qml/qml/qqmlexpression.cpp2
-rw-r--r--src/qml/qml/qqmlexpression_p.h4
-rw-r--r--src/qml/qml/qqmlextensionplugin.h4
-rw-r--r--src/qml/qml/qqmlfile.cpp20
-rw-r--r--src/qml/qml/qqmlfile.h2
-rw-r--r--src/qml/qml/qqmlfileselector_p.h2
-rw-r--r--src/qml/qml/qqmlimport.cpp72
-rw-r--r--src/qml/qml/qqmlincubator.cpp2
-rw-r--r--src/qml/qml/qqmljavascriptexpression_p.h2
-rw-r--r--src/qml/qml/qqmlloggingcategory.cpp2
-rw-r--r--src/qml/qml/qqmlmetatype.cpp10
-rw-r--r--src/qml/qml/qqmlmetatype_p.h4
-rw-r--r--src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp4
-rw-r--r--src/qml/qml/qqmlnetworkaccessmanagerfactory.h4
-rw-r--r--src/qml/qml/qqmlnotifier_p.h12
-rw-r--r--src/qml/qml/qqmlobjectcreator_p.h6
-rw-r--r--src/qml/qml/qqmlopenmetaobject_p.h4
-rw-r--r--src/qml/qml/qqmlproperty.cpp9
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp38
-rw-r--r--src/qml/qml/qqmlpropertycache_p.h32
-rw-r--r--src/qml/qml/qqmlproxymetaobject_p.h4
-rw-r--r--src/qml/qml/qqmltypeloader.cpp76
-rw-r--r--src/qml/qml/qqmltypeloader_p.h47
-rw-r--r--src/qml/qml/qqmltypenamecache.cpp8
-rw-r--r--src/qml/qml/qqmltypenamecache_p.h14
-rw-r--r--src/qml/qml/qqmlvaluetype_p.h6
-rw-r--r--src/qml/qml/qqmlvaluetypeproxybinding.cpp2
-rw-r--r--src/qml/qml/qqmlvaluetypeproxybinding_p.h6
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp4
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper_p.h2
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp34
-rw-r--r--src/qml/qml/qqmlvmemetaobject_p.h36
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp13
-rw-r--r--src/qml/qml/qqmlxmlhttprequest_p.h4
-rw-r--r--src/qml/qml/v8/qv8engine.cpp6
-rw-r--r--src/qml/qml/v8/qv8engine_p.h8
-rw-r--r--src/qml/qtqmlglobal.h4
-rw-r--r--src/qml/qtqmlglobal_p.h4
-rw-r--r--src/qml/types/qqmlbind_p.h6
-rw-r--r--src/qml/types/qqmlconnections.cpp2
-rw-r--r--src/qml/types/qqmlconnections_p.h8
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp18
-rw-r--r--src/qml/types/qqmldelegatemodel_p.h24
-rw-r--r--src/qml/types/qqmldelegatemodel_p_p.h34
-rw-r--r--src/qml/types/qqmlinstantiator.cpp6
-rw-r--r--src/qml/types/qqmlinstantiator_p.h6
-rw-r--r--src/qml/types/qqmllistmodel.cpp61
-rw-r--r--src/qml/types/qqmllistmodel_p.h12
-rw-r--r--src/qml/types/qqmllistmodel_p_p.h20
-rw-r--r--src/qml/types/qqmllistmodelworkeragent_p.h2
-rw-r--r--src/qml/types/qqmlobjectmodel.cpp2
-rw-r--r--src/qml/types/qqmlobjectmodel_p.h16
-rw-r--r--src/qml/types/qqmltimer.cpp4
-rw-r--r--src/qml/types/qqmltimer_p.h6
-rw-r--r--src/qml/types/qquickworkerscript.cpp16
-rw-r--r--src/qml/types/qquickworkerscript_p.h12
-rw-r--r--src/qml/util/qqmladaptormodel.cpp4
-rw-r--r--src/qml/util/qqmlchangeset.cpp12
-rw-r--r--src/qml/util/qqmllistcompositor.cpp4
-rw-r--r--src/qml/util/qqmlpropertymap.cpp8
-rw-r--r--src/qmltest/quicktestevent.cpp14
-rw-r--r--src/qmltest/quicktestresult.cpp7
-rw-r--r--src/quick/accessible/qaccessiblequickitem.cpp8
-rw-r--r--src/quick/accessible/qaccessiblequickview_p.h20
-rw-r--r--src/quick/configure.json157
-rw-r--r--src/quick/designer/qqmldesignermetaobject_p.h2
-rw-r--r--src/quick/designer/qquickdesignercustomparserobject_p.h11
-rw-r--r--src/quick/designer/qquickdesignersupport.cpp3
-rw-r--r--src/quick/designer/qquickdesignerwindowmanager_p.h22
-rw-r--r--src/quick/doc/snippets/qml/localstorage/dbtransaction.js31
-rw-r--r--src/quick/doc/src/concepts/input/focus.qdoc12
-rw-r--r--src/quick/doc/src/includes/layout.qdocinc18
-rw-r--r--src/quick/items/context2d/qquickcanvascontext_p.h5
-rw-r--r--src/quick/items/context2d/qquickcanvasitem.cpp44
-rw-r--r--src/quick/items/context2d/qquickcanvasitem_p.h6
-rw-r--r--src/quick/items/context2d/qquickcontext2d_p.h23
-rw-r--r--src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h8
-rw-r--r--src/quick/items/context2d/qquickcontext2dtexture.cpp12
-rw-r--r--src/quick/items/context2d/qquickcontext2dtexture_p.h20
-rw-r--r--src/quick/items/context2d/qquickcontext2dtile_p.h12
-rw-r--r--src/quick/items/items.pri166
-rw-r--r--src/quick/items/qquickaccessibleattached_p.h2
-rw-r--r--src/quick/items/qquickanchors.cpp4
-rw-r--r--src/quick/items/qquickanchors_p_p.h4
-rw-r--r--src/quick/items/qquickanimatedimage.cpp14
-rw-r--r--src/quick/items/qquickanimatedimage_p.h8
-rw-r--r--src/quick/items/qquickanimatedimage_p_p.h14
-rw-r--r--src/quick/items/qquickanimatedsprite.cpp32
-rw-r--r--src/quick/items/qquickanimatedsprite_p.h5
-rw-r--r--src/quick/items/qquickanimatedsprite_p_p.h4
-rw-r--r--src/quick/items/qquickborderimage.cpp13
-rw-r--r--src/quick/items/qquickborderimage_p.h2
-rw-r--r--src/quick/items/qquickborderimage_p_p.h6
-rw-r--r--src/quick/items/qquickdrag.cpp2
-rw-r--r--src/quick/items/qquickdrag_p.h2
-rw-r--r--src/quick/items/qquickdroparea.cpp2
-rw-r--r--src/quick/items/qquickdroparea_p.h2
-rw-r--r--src/quick/items/qquickevents.cpp2
-rw-r--r--src/quick/items/qquickflickable.cpp19
-rw-r--r--src/quick/items/qquickflickable_p.h2
-rw-r--r--src/quick/items/qquickflickable_p_p.h6
-rw-r--r--src/quick/items/qquickflipable.cpp2
-rw-r--r--src/quick/items/qquickflipable_p.h6
-rw-r--r--src/quick/items/qquickframebufferobject.cpp2
-rw-r--r--src/quick/items/qquickgenericshadereffect.cpp4
-rw-r--r--src/quick/items/qquickgridview_p.h5
-rw-r--r--src/quick/items/qquickimage.cpp15
-rw-r--r--src/quick/items/qquickimagebase.cpp13
-rw-r--r--src/quick/items/qquickimagebase_p_p.h3
-rw-r--r--src/quick/items/qquickitem.cpp169
-rw-r--r--src/quick/items/qquickitem.h8
-rw-r--r--src/quick/items/qquickitem_p.h17
-rw-r--r--src/quick/items/qquickitemanimation.cpp6
-rw-r--r--src/quick/items/qquickitemanimation_p.h6
-rw-r--r--src/quick/items/qquickitemanimation_p_p.h9
-rw-r--r--src/quick/items/qquickitemgrabresult.cpp21
-rw-r--r--src/quick/items/qquickitemgrabresult.h7
-rw-r--r--src/quick/items/qquickitemsmodule.cpp89
-rw-r--r--src/quick/items/qquickitemview.cpp56
-rw-r--r--src/quick/items/qquickitemview_p.h6
-rw-r--r--src/quick/items/qquickitemview_p_p.h8
-rw-r--r--src/quick/items/qquickitemviewtransition.cpp2
-rw-r--r--src/quick/items/qquickitemviewtransition_p.h5
-rw-r--r--src/quick/items/qquicklistview.cpp2
-rw-r--r--src/quick/items/qquicklistview_p.h6
-rw-r--r--src/quick/items/qquickloader_p_p.h2
-rw-r--r--src/quick/items/qquickmousearea.cpp3
-rw-r--r--src/quick/items/qquickopenglshadereffect.cpp16
-rw-r--r--src/quick/items/qquickopenglshadereffect_p.h4
-rw-r--r--src/quick/items/qquickopenglshadereffectnode.cpp6
-rw-r--r--src/quick/items/qquickopenglshadereffectnode_p.h4
-rw-r--r--src/quick/items/qquickpainteditem.cpp3
-rw-r--r--src/quick/items/qquickpathview.cpp86
-rw-r--r--src/quick/items/qquickpathview_p.h10
-rw-r--r--src/quick/items/qquickpathview_p_p.h6
-rw-r--r--src/quick/items/qquickpositioners.cpp8
-rw-r--r--src/quick/items/qquickpositioners_p.h4
-rw-r--r--src/quick/items/qquickpositioners_p_p.h4
-rw-r--r--src/quick/items/qquickrectangle.cpp2
-rw-r--r--src/quick/items/qquickrendercontrol.cpp4
-rw-r--r--src/quick/items/qquickscreen.cpp195
-rw-r--r--src/quick/items/qquickscreen_p.h48
-rw-r--r--src/quick/items/qquickshadereffect_p.h4
-rw-r--r--src/quick/items/qquickshadereffectmesh.cpp19
-rw-r--r--src/quick/items/qquickshadereffectmesh_p.h6
-rw-r--r--src/quick/items/qquickshadereffectsource.cpp2
-rw-r--r--src/quick/items/qquickshadereffectsource_p.h4
-rw-r--r--src/quick/items/qquicksprite_p.h5
-rw-r--r--src/quick/items/qquickspriteengine.cpp4
-rw-r--r--src/quick/items/qquickspriteengine_p.h14
-rw-r--r--src/quick/items/qquickspritesequence_p.h4
-rw-r--r--src/quick/items/qquickspritesequence_p_p.h4
-rw-r--r--src/quick/items/qquickstateoperations.cpp8
-rw-r--r--src/quick/items/qquickstateoperations_p.h4
-rw-r--r--src/quick/items/qquicktext.cpp6
-rw-r--r--src/quick/items/qquicktextcontrol.cpp4
-rw-r--r--src/quick/items/qquicktextcontrol_p.h6
-rw-r--r--src/quick/items/qquicktextdocument.cpp2
-rw-r--r--src/quick/items/qquicktextdocument_p.h8
-rw-r--r--src/quick/items/qquicktextedit.cpp2
-rw-r--r--src/quick/items/qquicktextinput.cpp55
-rw-r--r--src/quick/items/qquickview.cpp26
-rw-r--r--src/quick/items/qquickview_p.h30
-rw-r--r--src/quick/items/qquickwindow.cpp29
-rw-r--r--src/quick/items/qquickwindow.h1
-rw-r--r--src/quick/items/qquickwindow_p.h4
-rw-r--r--src/quick/items/qquickwindowmodule.cpp33
-rw-r--r--src/quick/items/qquickwindowmodule_p.h5
-rw-r--r--src/quick/qtquick2.cpp26
-rw-r--r--src/quick/qtquickglobal.h4
-rw-r--r--src/quick/qtquickglobal_p.h4
-rw-r--r--src/quick/quick.pro11
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareadaptation.cpp2
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp4
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarecontext_p.h2
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp8
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h4
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater.cpp2
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater_p.h2
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder.cpp2
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder_p.h2
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarespritenode_p.h4
-rw-r--r--src/quick/scenegraph/adaptations/software/software.pri9
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h2
-rw-r--r--src/quick/scenegraph/coreapi/qsggeometry.cpp73
-rw-r--r--src/quick/scenegraph/coreapi/qsggeometry.h125
-rw-r--r--src/quick/scenegraph/coreapi/qsgnode.cpp2
-rw-r--r--src/quick/scenegraph/coreapi/qsgnode.h2
-rw-r--r--src/quick/scenegraph/coreapi/qsgrenderer_p.h6
-rw-r--r--src/quick/scenegraph/coreapi/qsgshaderrewriter.cpp14
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer.cpp2
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer_p.h6
-rw-r--r--src/quick/scenegraph/qsgbasicinternalimagenode.cpp10
-rw-r--r--src/quick/scenegraph/qsgbasicinternalrectanglenode.cpp6
-rw-r--r--src/quick/scenegraph/qsgcontext.cpp4
-rw-r--r--src/quick/scenegraph/qsgcontext_p.h2
-rw-r--r--src/quick/scenegraph/qsgcontextplugin.cpp2
-rw-r--r--src/quick/scenegraph/qsgdefaultcontext.cpp4
-rw-r--r--src/quick/scenegraph/qsgdefaultcontext_p.h2
-rw-r--r--src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h10
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.cpp3
-rw-r--r--src/quick/scenegraph/qsgdefaultrendercontext.cpp6
-rw-r--r--src/quick/scenegraph/qsgdefaultspritenode.cpp4
-rw-r--r--src/quick/scenegraph/qsgdefaultspritenode_p.h4
-rw-r--r--src/quick/scenegraph/qsgrenderloop.cpp10
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop.cpp4
-rw-r--r--src/quick/scenegraph/qsgwindowsrenderloop.cpp15
-rw-r--r--src/quick/scenegraph/scenegraph.pri9
-rw-r--r--src/quick/scenegraph/util/qsgatlastexture_p.h16
-rw-r--r--src/quick/scenegraph/util/qsgdefaultpainternode.cpp16
-rw-r--r--src/quick/scenegraph/util/qsgdefaultpainternode_p.h30
-rw-r--r--src/quick/scenegraph/util/qsgdepthstencilbuffer_p.h2
-rw-r--r--src/quick/scenegraph/util/qsgflatcolormaterial.h6
-rw-r--r--src/quick/scenegraph/util/qsgshadersourcebuilder.cpp11
-rw-r--r--src/quick/scenegraph/util/qsgsimplematerial.h4
-rw-r--r--src/quick/scenegraph/util/qsgtexture_p.h10
-rw-r--r--src/quick/scenegraph/util/qsgtexturematerial.h10
-rw-r--r--src/quick/scenegraph/util/qsgtexturematerial_p.h10
-rw-r--r--src/quick/scenegraph/util/qsgvertexcolormaterial.h6
-rw-r--r--src/quick/util/qquickanimation.cpp4
-rw-r--r--src/quick/util/qquickanimation_p.h32
-rw-r--r--src/quick/util/qquickanimation_p_p.h30
-rw-r--r--src/quick/util/qquickanimationcontroller.cpp4
-rw-r--r--src/quick/util/qquickanimationcontroller_p.h4
-rw-r--r--src/quick/util/qquickanimator.cpp3
-rw-r--r--src/quick/util/qquickanimator_p.h33
-rw-r--r--src/quick/util/qquickanimatorcontroller.cpp268
-rw-r--r--src/quick/util/qquickanimatorcontroller_p.h50
-rw-r--r--src/quick/util/qquickanimatorjob.cpp432
-rw-r--r--src/quick/util/qquickanimatorjob_p.h102
-rw-r--r--src/quick/util/qquickapplication.cpp46
-rw-r--r--src/quick/util/qquickapplication_p.h13
-rw-r--r--src/quick/util/qquickbehavior.cpp2
-rw-r--r--src/quick/util/qquickbehavior_p.h4
-rw-r--r--src/quick/util/qquickfontloader.cpp16
-rw-r--r--src/quick/util/qquickimageprovider.cpp169
-rw-r--r--src/quick/util/qquickimageprovider.h17
-rw-r--r--src/quick/util/qquickpath_p.h20
-rw-r--r--src/quick/util/qquickpath_p_p.h4
-rw-r--r--src/quick/util/qquickpathinterpolator_p.h4
-rw-r--r--src/quick/util/qquickpixmapcache.cpp203
-rw-r--r--src/quick/util/qquickpixmapcache_p.h76
-rw-r--r--src/quick/util/qquickpropertychanges.cpp20
-rw-r--r--src/quick/util/qquickpropertychanges_p.h6
-rw-r--r--src/quick/util/qquickshortcut.cpp196
-rw-r--r--src/quick/util/qquickshortcut_p.h27
-rw-r--r--src/quick/util/qquicksmoothedanimation_p.h8
-rw-r--r--src/quick/util/qquicksmoothedanimation_p_p.h8
-rw-r--r--src/quick/util/qquickspringanimation.cpp8
-rw-r--r--src/quick/util/qquickspringanimation_p.h4
-rw-r--r--src/quick/util/qquickstatechangescript_p.h6
-rw-r--r--src/quick/util/qquickstategroup_p.h4
-rw-r--r--src/quick/util/qquickstyledtext.cpp3
-rw-r--r--src/quick/util/qquicktimeline_p_p.h8
-rw-r--r--src/quick/util/qquicktransition.cpp4
-rw-r--r--src/quick/util/qquickutilmodule.cpp4
-rw-r--r--src/quick/util/util.pri15
-rw-r--r--src/src.pro5
412 files changed, 5066 insertions, 3260 deletions
diff --git a/src/3rdparty/masm/wtf/MathExtras.h b/src/3rdparty/masm/wtf/MathExtras.h
index 9c38af6b16..75e3670367 100644
--- a/src/3rdparty/masm/wtf/MathExtras.h
+++ b/src/3rdparty/masm/wtf/MathExtras.h
@@ -152,7 +152,7 @@ inline long lroundf(float num) { return static_cast<long>(roundf(num)); }
inline long long abs(long num) { return labs(num); }
#endif
-#if COMPILER(MSVC)
+#if COMPILER(MSVC) && COMPILER(MSVC12_OR_LOWER)
// MSVC's math.h does not currently supply log2 or log2f.
inline double log2(double num)
{
diff --git a/src/imports/folderlistmodel/fileinfothread_p.h b/src/imports/folderlistmodel/fileinfothread_p.h
index 8a154f264e..56058fd6be 100644
--- a/src/imports/folderlistmodel/fileinfothread_p.h
+++ b/src/imports/folderlistmodel/fileinfothread_p.h
@@ -94,7 +94,7 @@ public Q_SLOTS:
#endif
protected:
- void run();
+ void run() override;
void getFileInfos(const QString &path);
void findChangeRange(const QList<FileProperty> &list, int &fromIndex, int &toIndex);
diff --git a/src/imports/folderlistmodel/fileproperty_p.h b/src/imports/folderlistmodel/fileproperty_p.h
index f385cdfdb4..48be4a3d85 100644
--- a/src/imports/folderlistmodel/fileproperty_p.h
+++ b/src/imports/folderlistmodel/fileproperty_p.h
@@ -57,17 +57,17 @@
class FileProperty
{
public:
- FileProperty(const QFileInfo &info)
+ FileProperty(const QFileInfo &info) :
+ mFileName(info.fileName()),
+ mFilePath(info.filePath()),
+ mBaseName(info.baseName()),
+ mSuffix(info.completeSuffix()),
+ mSize(info.size()),
+ mIsDir(info.isDir()),
+ mIsFile(info.isFile()),
+ mLastModified(info.lastModified()),
+ mLastRead(info.lastRead())
{
- mFileName = info.fileName();
- mFilePath = info.filePath();
- mBaseName = info.baseName();
- mSize = info.size();
- mSuffix = info.completeSuffix();
- mIsDir = info.isDir();
- mIsFile = info.isFile();
- mLastModified = info.lastModified();
- mLastRead = info.lastRead();
}
~FileProperty()
{}
diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.h b/src/imports/folderlistmodel/qquickfolderlistmodel.h
index aae6df452d..dee73dff3e 100644
--- a/src/imports/folderlistmodel/qquickfolderlistmodel.h
+++ b/src/imports/folderlistmodel/qquickfolderlistmodel.h
@@ -94,10 +94,10 @@ public:
FileUrlRole = Qt::UserRole + 9
};
- virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
- virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
- virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- virtual QHash<int, QByteArray> roleNames() const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ QHash<int, QByteArray> roleNames() const override;
//![abslistmodel]
//![count]
@@ -144,8 +144,8 @@ public:
Q_INVOKABLE int indexOf(const QUrl &file) const;
//![parserstatus]
- virtual void classBegin();
- virtual void componentComplete();
+ void classBegin() override;
+ void componentComplete() override;
//![parserstatus]
int roleFromString(const QString &roleName) const;
diff --git a/src/imports/imports.pro b/src/imports/imports.pro
index 28345d049a..7d5596e86e 100644
--- a/src/imports/imports.pro
+++ b/src/imports/imports.pro
@@ -6,9 +6,10 @@ SUBDIRS += \
folderlistmodel \
localstorage \
models \
- settings \
statemachine
+qtConfig(settings): SUBDIRS += settings
+
qtHaveModule(quick) {
SUBDIRS += \
handlers \
diff --git a/src/imports/layouts/qquickgridlayoutengine_p.h b/src/imports/layouts/qquickgridlayoutengine_p.h
index 86f56a5af4..2810e2e5d0 100644
--- a/src/imports/layouts/qquickgridlayoutengine_p.h
+++ b/src/imports/layouts/qquickgridlayoutengine_p.h
@@ -67,7 +67,7 @@ public:
: QGridLayoutItem(row, column, rowSpan, columnSpan, alignment), m_item(item), sizeHintCacheDirty(true), useFallbackToWidthOrHeight(true) {}
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const override
{
Q_UNUSED(constraint); // Quick Layouts does not support constraint atm
return effectiveSizeHints()[which];
@@ -99,12 +99,12 @@ public:
sizeHintCacheDirty = true;
}
- QLayoutPolicy::Policy sizePolicy(Qt::Orientation orientation) const
+ QLayoutPolicy::Policy sizePolicy(Qt::Orientation orientation) const override
{
return QQuickLayout::effectiveSizePolicy_helper(m_item, orientation, attachedLayoutObject(m_item, false));
}
- void setGeometry(const QRectF &rect)
+ void setGeometry(const QRectF &rect) override
{
QQuickLayoutAttached *info = attachedLayoutObject(m_item, false);
const QRectF r = info ? rect.marginsRemoved(info->qMargins()) : rect;
diff --git a/src/imports/layouts/qquicklinearlayout.cpp b/src/imports/layouts/qquicklinearlayout.cpp
index fdf8479133..7fad395a29 100644
--- a/src/imports/layouts/qquicklinearlayout.cpp
+++ b/src/imports/layouts/qquicklinearlayout.cpp
@@ -56,15 +56,7 @@
Items in a RowLayout support these attached properties:
\list
- \li \l{Layout::minimumWidth}{Layout.minimumWidth}
- \li \l{Layout::minimumHeight}{Layout.minimumHeight}
- \li \l{Layout::preferredWidth}{Layout.preferredWidth}
- \li \l{Layout::preferredHeight}{Layout.preferredHeight}
- \li \l{Layout::maximumWidth}{Layout.maximumWidth}
- \li \l{Layout::maximumHeight}{Layout.maximumHeight}
- \li \l{Layout::fillWidth}{Layout.fillWidth}
- \li \l{Layout::fillHeight}{Layout.fillHeight}
- \li \l{Layout::alignment}{Layout.alignment}
+ \input layout.qdocinc attached-properties
\endlist
\image rowlayout.png
@@ -118,15 +110,7 @@
Items in a ColumnLayout support these attached properties:
\list
- \li \l{Layout::minimumWidth}{Layout.minimumWidth}
- \li \l{Layout::minimumHeight}{Layout.minimumHeight}
- \li \l{Layout::preferredWidth}{Layout.preferredWidth}
- \li \l{Layout::preferredHeight}{Layout.preferredHeight}
- \li \l{Layout::maximumWidth}{Layout.maximumWidth}
- \li \l{Layout::maximumHeight}{Layout.maximumHeight}
- \li \l{Layout::fillWidth}{Layout.fillWidth}
- \li \l{Layout::fillHeight}{Layout.fillHeight}
- \li \l{Layout::alignment}{Layout.alignment}
+ \input layout.qdocinc attached-properties
\endlist
\image columnlayout.png
@@ -220,15 +204,7 @@
\li \l{Layout::column}{Layout.column}
\li \l{Layout::rowSpan}{Layout.rowSpan}
\li \l{Layout::columnSpan}{Layout.columnSpan}
- \li \l{Layout::minimumWidth}{Layout.minimumWidth}
- \li \l{Layout::minimumHeight}{Layout.minimumHeight}
- \li \l{Layout::preferredWidth}{Layout.preferredWidth}
- \li \l{Layout::preferredHeight}{Layout.preferredHeight}
- \li \l{Layout::maximumWidth}{Layout.maximumWidth}
- \li \l{Layout::maximumHeight}{Layout.maximumHeight}
- \li \l{Layout::fillWidth}{Layout.fillWidth}
- \li \l{Layout::fillHeight}{Layout.fillHeight}
- \li \l{Layout::alignment}{Layout.alignment}
+ \input layout.qdocinc attached-properties
\endlist
Read more about attached properties \l{QML Object Attributes}{here}.
diff --git a/src/imports/layouts/qquicklinearlayout_p.h b/src/imports/layouts/qquicklinearlayout_p.h
index 86404f8d79..ca8b867824 100644
--- a/src/imports/layouts/qquicklinearlayout_p.h
+++ b/src/imports/layouts/qquicklinearlayout_p.h
@@ -158,7 +158,7 @@ public:
Flow flow() const;
void setFlow(Flow flow);
- void insertLayoutItems();
+ void insertLayoutItems() override;
signals:
void columnSpacingChanged();
@@ -200,7 +200,7 @@ public:
qreal spacing() const;
void setSpacing(qreal spacing);
- void insertLayoutItems();
+ void insertLayoutItems() override;
signals:
void spacingChanged();
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
index bf70fd1050..b8fd307215 100644
--- a/src/imports/localstorage/plugin.cpp
+++ b/src/imports/localstorage/plugin.cpp
@@ -794,7 +794,7 @@ public:
}
void registerTypes(const char *uri) Q_DECL_OVERRIDE
{
- Q_ASSERT(QLatin1String(uri) == "QtQuick.LocalStorage");
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.LocalStorage"));
qmlRegisterSingletonType<QQuickLocalStorage>(uri, 2, 0, "LocalStorage", module_api_factory);
}
};
diff --git a/src/imports/settings/qqmlsettings_p.h b/src/imports/settings/qqmlsettings_p.h
index 0ed55579dd..ce942d7564 100644
--- a/src/imports/settings/qqmlsettings_p.h
+++ b/src/imports/settings/qqmlsettings_p.h
@@ -74,10 +74,10 @@ public:
void setCategory(const QString &category);
protected:
- void timerEvent(QTimerEvent *event);
+ void timerEvent(QTimerEvent *event) override;
- void classBegin();
- void componentComplete();
+ void classBegin() override;
+ void componentComplete() override;
private:
Q_DISABLE_COPY(QQmlSettings)
diff --git a/src/imports/settings/settings.pro b/src/imports/settings/settings.pro
index 3d7c9c31b8..29229f59cb 100644
--- a/src/imports/settings/settings.pro
+++ b/src/imports/settings/settings.pro
@@ -1,6 +1,3 @@
-load(qfeatures)
-requires(!contains(QT_DISABLED_FEATURES, settings))
-
CXX_MODULE = qml
TARGET = qmlsettingsplugin
TARGETPATH = Qt/labs/settings
diff --git a/src/imports/statemachine/state.h b/src/imports/statemachine/state.h
index 73e4ecda6b..8e8cefab19 100644
--- a/src/imports/statemachine/state.h
+++ b/src/imports/statemachine/state.h
@@ -58,8 +58,8 @@ class State : public QState, public QQmlParserStatus
public:
explicit State(QState *parent = 0);
- void classBegin() {}
- void componentComplete();
+ void classBegin() override {}
+ void componentComplete() override;
QQmlListProperty<QObject> children();
diff --git a/src/imports/statemachine/statemachine.h b/src/imports/statemachine/statemachine.h
index 59a810f387..cb0ab43f8b 100644
--- a/src/imports/statemachine/statemachine.h
+++ b/src/imports/statemachine/statemachine.h
@@ -62,8 +62,8 @@ class StateMachine : public QStateMachine, public QQmlParserStatus
public:
explicit StateMachine(QObject *parent = 0);
- void classBegin() {}
- void componentComplete();
+ void classBegin() override {}
+ void componentComplete() override;
QQmlListProperty<QObject> children();
bool isRunning() const;
diff --git a/src/imports/statemachine/timeouttransition.h b/src/imports/statemachine/timeouttransition.h
index 5d71e86bb4..0e5f5377e3 100644
--- a/src/imports/statemachine/timeouttransition.h
+++ b/src/imports/statemachine/timeouttransition.h
@@ -59,8 +59,8 @@ public:
int timeout() const;
void setTimeout(int timeout);
- void classBegin() {}
- void componentComplete();
+ void classBegin() override {}
+ void componentComplete() override;
Q_SIGNALS:
void timeoutChanged();
diff --git a/src/imports/xmllistmodel/qqmlxmllistmodel.cpp b/src/imports/xmllistmodel/qqmlxmllistmodel.cpp
index 6e9e57a046..4306f477e9 100644
--- a/src/imports/xmllistmodel/qqmlxmllistmodel.cpp
+++ b/src/imports/xmllistmodel/qqmlxmllistmodel.cpp
@@ -176,7 +176,7 @@ public:
QQuickXmlQueryThreadObject(QQuickXmlQueryEngine *);
void processJobs();
- virtual bool event(QEvent *e);
+ bool event(QEvent *e) override;
private:
QQuickXmlQueryEngine *m_queryEngine;
@@ -202,7 +202,7 @@ signals:
void error(void*, const QString&);
protected:
- void run();
+ void run() override;
private:
void processQuery(XmlQueryJob *job);
diff --git a/src/imports/xmllistmodel/qqmlxmllistmodel_p.h b/src/imports/xmllistmodel/qqmlxmllistmodel_p.h
index f0096a9125..3a4487a085 100644
--- a/src/imports/xmllistmodel/qqmlxmllistmodel_p.h
+++ b/src/imports/xmllistmodel/qqmlxmllistmodel_p.h
@@ -95,10 +95,10 @@ public:
QQuickXmlListModel(QObject *parent = 0);
~QQuickXmlListModel();
- QModelIndex index(int row, int column, const QModelIndex &parent) const;
- int rowCount(const QModelIndex &parent) const;
- QVariant data(const QModelIndex &index, int role) const;
- QHash<int, QByteArray> roleNames() const;
+ QModelIndex index(int row, int column, const QModelIndex &parent) const override;
+ int rowCount(const QModelIndex &parent) const override;
+ QVariant data(const QModelIndex &index, int role) const override;
+ QHash<int, QByteArray> roleNames() const override;
int count() const;
@@ -124,8 +124,8 @@ public:
Q_INVOKABLE QString errorString() const;
- virtual void classBegin();
- virtual void componentComplete();
+ void classBegin() override;
+ void componentComplete() override;
Q_SIGNALS:
void statusChanged(QQuickXmlListModel::Status);
@@ -194,7 +194,7 @@ public:
Q_EMIT isKeyChanged();
}
- bool isValid() {
+ bool isValid() const {
return !m_name.isEmpty() && !m_query.isEmpty();
}
diff --git a/src/particles/qquickage_p.h b/src/particles/qquickage_p.h
index f6e277f8a7..5db6167dc1 100644
--- a/src/particles/qquickage_p.h
+++ b/src/particles/qquickage_p.h
@@ -74,7 +74,8 @@ public:
}
protected:
- virtual bool affectParticle(QQuickParticleData *d, qreal dt);
+ bool affectParticle(QQuickParticleData *d, qreal dt) override;
+
Q_SIGNALS:
void lifeLeftChanged(int arg);
void advancePositionChanged(bool arg);
diff --git a/src/particles/qquickangledirection.cpp b/src/particles/qquickangledirection.cpp
index 09aa047670..6f30e24a26 100644
--- a/src/particles/qquickangledirection.cpp
+++ b/src/particles/qquickangledirection.cpp
@@ -104,7 +104,7 @@ QQuickAngleDirection::QQuickAngleDirection(QObject *parent) :
}
-const QPointF QQuickAngleDirection::sample(const QPointF &from)
+QPointF QQuickAngleDirection::sample(const QPointF &from)
{
Q_UNUSED(from);
QPointF ret;
diff --git a/src/particles/qquickangledirection_p.h b/src/particles/qquickangledirection_p.h
index 3e981c5f9e..66290fb19e 100644
--- a/src/particles/qquickangledirection_p.h
+++ b/src/particles/qquickangledirection_p.h
@@ -62,7 +62,7 @@ class QQuickAngleDirection : public QQuickDirection
Q_PROPERTY(qreal magnitudeVariation READ magnitudeVariation WRITE setMagnitudeVariation NOTIFY magnitudeVariationChanged)
public:
explicit QQuickAngleDirection(QObject *parent = 0);
- const QPointF sample(const QPointF &from);
+ QPointF sample(const QPointF &from) override;
qreal angle() const
{
return m_angle;
diff --git a/src/particles/qquickcumulativedirection.cpp b/src/particles/qquickcumulativedirection.cpp
index b6b3e76f69..6fbd53df48 100644
--- a/src/particles/qquickcumulativedirection.cpp
+++ b/src/particles/qquickcumulativedirection.cpp
@@ -59,7 +59,7 @@ QQmlListProperty<QQuickDirection> QQuickCumulativeDirection::directions()
return QQmlListProperty<QQuickDirection>(this, m_directions);//TODO: Proper list property
}
-const QPointF QQuickCumulativeDirection::sample(const QPointF &from)
+QPointF QQuickCumulativeDirection::sample(const QPointF &from)
{
QPointF ret;
foreach (QQuickDirection* dir, m_directions)
diff --git a/src/particles/qquickcumulativedirection_p.h b/src/particles/qquickcumulativedirection_p.h
index 9af86bd39e..39f8ab8a24 100644
--- a/src/particles/qquickcumulativedirection_p.h
+++ b/src/particles/qquickcumulativedirection_p.h
@@ -62,7 +62,7 @@ class QQuickCumulativeDirection : public QQuickDirection
public:
explicit QQuickCumulativeDirection(QObject *parent = 0);
QQmlListProperty<QQuickDirection> directions();
- const QPointF sample(const QPointF &from);
+ QPointF sample(const QPointF &from) override;
private:
QList<QQuickDirection*> m_directions;
};
diff --git a/src/particles/qquickcustomaffector_p.h b/src/particles/qquickcustomaffector_p.h
index a383b196c2..c1745798c3 100644
--- a/src/particles/qquickcustomaffector_p.h
+++ b/src/particles/qquickcustomaffector_p.h
@@ -69,7 +69,7 @@ class QQuickCustomAffector : public QQuickParticleAffector
public:
explicit QQuickCustomAffector(QQuickItem *parent = 0);
- virtual void affectSystem(qreal dt);
+ void affectSystem(qreal dt) override;
QQuickDirection * position() const
{
@@ -153,7 +153,8 @@ public Q_SLOTS:
protected:
bool isAffectConnected();
- virtual bool affectParticle(QQuickParticleData *d, qreal dt);
+ bool affectParticle(QQuickParticleData *d, qreal dt) override;
+
private:
void affectProperties(const QList<QQuickParticleData*> particles, qreal dt);
QQuickDirection * m_position;
diff --git a/src/particles/qquickcustomparticle_p.h b/src/particles/qquickcustomparticle_p.h
index e9d68cbe5c..1d48786a41 100644
--- a/src/particles/qquickcustomparticle_p.h
+++ b/src/particles/qquickcustomparticle_p.h
@@ -84,18 +84,18 @@ Q_SIGNALS:
void vertexShaderChanged();
protected:
- virtual void initialize(int gIdx, int pIdx);
- virtual void commit(int gIdx, int pIdx);
+ void initialize(int gIdx, int pIdx) override;
+ void commit(int gIdx, int pIdx) override;
- QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
+ QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
QQuickOpenGLShaderEffectNode *prepareNextFrame(QQuickOpenGLShaderEffectNode *rootNode);
- void reset();
+ void reset() override;
void resize(int oldCount, int newCount);
- virtual void componentComplete();
+ void componentComplete() override;
QQuickOpenGLShaderEffectNode *buildCustomNodes();
- void sceneGraphInvalidated();
- void itemChange(ItemChange change, const ItemChangeData &value);
+ void sceneGraphInvalidated() override;
+ void itemChange(ItemChange change, const ItemChangeData &value) override;
private Q_SLOTS:
void sourceDestroyed(QObject *object);
diff --git a/src/particles/qquickdirection.cpp b/src/particles/qquickdirection.cpp
index da1edfb3c3..fd94c8945c 100644
--- a/src/particles/qquickdirection.cpp
+++ b/src/particles/qquickdirection.cpp
@@ -56,7 +56,7 @@ QQuickDirection::QQuickDirection(QObject *parent) :
{
}
-const QPointF QQuickDirection::sample(const QPointF &from)
+QPointF QQuickDirection::sample(const QPointF &from)
{
Q_UNUSED(from);
return QPointF();
diff --git a/src/particles/qquickdirection_p.h b/src/particles/qquickdirection_p.h
index f7029488f7..10960f9920 100644
--- a/src/particles/qquickdirection_p.h
+++ b/src/particles/qquickdirection_p.h
@@ -62,7 +62,7 @@ class QQuickDirection : public QObject
public:
explicit QQuickDirection(QObject *parent = 0);
- virtual const QPointF sample(const QPointF &from);
+ virtual QPointF sample(const QPointF &from);
Q_SIGNALS:
public Q_SLOTS:
diff --git a/src/particles/qquickellipseextruder_p.h b/src/particles/qquickellipseextruder_p.h
index 1df7e32c83..0af7f4d94f 100644
--- a/src/particles/qquickellipseextruder_p.h
+++ b/src/particles/qquickellipseextruder_p.h
@@ -60,8 +60,8 @@ class QQuickEllipseExtruder : public QQuickParticleExtruder
Q_PROPERTY(bool fill READ fill WRITE setFill NOTIFY fillChanged)//###Use base class? If it's still box
public:
explicit QQuickEllipseExtruder(QObject *parent = 0);
- virtual QPointF extrude(const QRectF &);
- virtual bool contains(const QRectF &bounds, const QPointF &point);
+ QPointF extrude(const QRectF &) override;
+ bool contains(const QRectF &bounds, const QPointF &point) override;
bool fill() const
{
diff --git a/src/particles/qquickfriction_p.h b/src/particles/qquickfriction_p.h
index b67de631be..05ae7a38d5 100644
--- a/src/particles/qquickfriction_p.h
+++ b/src/particles/qquickfriction_p.h
@@ -73,7 +73,7 @@ public:
}
protected:
- virtual bool affectParticle(QQuickParticleData *d, qreal dt);
+ bool affectParticle(QQuickParticleData *d, qreal dt) override;
Q_SIGNALS:
diff --git a/src/particles/qquickgravity_p.h b/src/particles/qquickgravity_p.h
index 7c071c932d..d3a7f6665c 100644
--- a/src/particles/qquickgravity_p.h
+++ b/src/particles/qquickgravity_p.h
@@ -72,7 +72,8 @@ public:
return m_angle;
}
protected:
- virtual bool affectParticle(QQuickParticleData *d, qreal dt);
+ bool affectParticle(QQuickParticleData *d, qreal dt) override;
+
Q_SIGNALS:
void magnitudeChanged(qreal arg);
diff --git a/src/particles/qquickgroupgoal_p.h b/src/particles/qquickgroupgoal_p.h
index 0b935fc1d1..9a56ef5cce 100644
--- a/src/particles/qquickgroupgoal_p.h
+++ b/src/particles/qquickgroupgoal_p.h
@@ -75,7 +75,7 @@ public:
}
protected:
- virtual bool affectParticle(QQuickParticleData *d, qreal dt);
+ bool affectParticle(QQuickParticleData *d, qreal dt) override;
Q_SIGNALS:
diff --git a/src/particles/qquickimageparticle_p.h b/src/particles/qquickimageparticle_p.h
index 492ec23c07..95323c25a6 100644
--- a/src/particles/qquickimageparticle_p.h
+++ b/src/particles/qquickimageparticle_p.h
@@ -347,15 +347,15 @@ public Q_SLOTS:
void setEntryEffect(EntryEffect arg);
protected:
- void reset();
- virtual void initialize(int gIdx, int pIdx);
- virtual void commit(int gIdx, int pIdx);
+ void reset() override;
+ void initialize(int gIdx, int pIdx) override;
+ void commit(int gIdx, int pIdx) override;
- QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
+ QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
void prepareNextFrame(QSGNode**);
void buildParticleNodes(QSGNode**);
- void sceneGraphInvalidated();
+ void sceneGraphInvalidated() override;
private Q_SLOTS:
void createEngine(); //### method invoked by sprite list changing (in engine.h) - pretty nasty
@@ -440,7 +440,7 @@ private:
}
template<class MaterialData>
- MaterialData* getState(QSGMaterial* m){
+ static MaterialData* getState(QSGMaterial* m) {
return static_cast<QSGSimpleMaterial<MaterialData> *>(m)->state();
}
EntryEffect m_entryEffect;
diff --git a/src/particles/qquickitemparticle_p.h b/src/particles/qquickitemparticle_p.h
index 0edd05dfc7..9e6c7deaea 100644
--- a/src/particles/qquickitemparticle_p.h
+++ b/src/particles/qquickitemparticle_p.h
@@ -70,7 +70,7 @@ public:
bool fade() const { return m_fade; }
- virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
+ QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
static QQuickItemParticleAttached *qmlAttachedProperties(QObject *object);
QQmlComponent* delegate() const
@@ -100,9 +100,9 @@ public Q_SLOTS:
}
protected:
- virtual void reset();
- virtual void commit(int gIdx, int pIdx);
- virtual void initialize(int gIdx, int pIdx);
+ void reset() override;
+ void commit(int gIdx, int pIdx) override;
+ void initialize(int gIdx, int pIdx) override;
void prepareNextFrame();
private:
void processDeletables();
@@ -131,7 +131,7 @@ public:
QQuickItemParticleAttached(QObject* parent)
: QObject(parent), m_mp(0)
{;}
- QQuickItemParticle* particle() {return m_mp;}
+ QQuickItemParticle* particle() const { return m_mp; }
void detach(){Q_EMIT detached();}
void attach(){Q_EMIT attached();}
private:
diff --git a/src/particles/qquicklineextruder_p.h b/src/particles/qquicklineextruder_p.h
index 72d2300dce..306f3a1dd6 100644
--- a/src/particles/qquicklineextruder_p.h
+++ b/src/particles/qquicklineextruder_p.h
@@ -56,11 +56,11 @@ class QQuickLineExtruder : public QQuickParticleExtruder
{
Q_OBJECT
//Default is topleft to bottom right. Flipped makes it topright to bottom left
- Q_PROPERTY(bool mirrored READ mirrored WRITE setmirrored NOTIFY mirroredChanged)
+ Q_PROPERTY(bool mirrored READ mirrored WRITE setMirrored NOTIFY mirroredChanged)
public:
explicit QQuickLineExtruder(QObject *parent = 0);
- virtual QPointF extrude(const QRectF &);
+ QPointF extrude(const QRectF &) override;
bool mirrored() const
{
return m_mirrored;
@@ -72,7 +72,7 @@ Q_SIGNALS:
public Q_SLOTS:
- void setmirrored(bool arg)
+ void setMirrored(bool arg)
{
if (m_mirrored != arg) {
m_mirrored = arg;
diff --git a/src/particles/qquickmaskextruder_p.h b/src/particles/qquickmaskextruder_p.h
index 32ace521da..0fc0331db8 100644
--- a/src/particles/qquickmaskextruder_p.h
+++ b/src/particles/qquickmaskextruder_p.h
@@ -63,8 +63,8 @@ class QQuickMaskExtruder : public QQuickParticleExtruder
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
public:
explicit QQuickMaskExtruder(QObject *parent = 0);
- virtual QPointF extrude(const QRectF &);
- virtual bool contains(const QRectF &bounds, const QPointF &point);
+ QPointF extrude(const QRectF &) override;
+ bool contains(const QRectF &bounds, const QPointF &point) override;
QUrl source() const
{
diff --git a/src/particles/qquickparticleaffector.cpp b/src/particles/qquickparticleaffector.cpp
index 6ed0d9e14a..31bcfb82af 100644
--- a/src/particles/qquickparticleaffector.cpp
+++ b/src/particles/qquickparticleaffector.cpp
@@ -244,7 +244,7 @@ void QQuickParticleAffector::updateOffsets()
m_offset = m_system->mapFromItem(this, QPointF(0, 0));
}
-bool QQuickParticleAffector::isColliding(QQuickParticleData *d)
+bool QQuickParticleAffector::isColliding(QQuickParticleData *d) const
{
qreal myCurX = d->curX(m_system);
qreal myCurY = d->curY(m_system);
diff --git a/src/particles/qquickparticleaffector_p.h b/src/particles/qquickparticleaffector_p.h
index c42c0b4cba..5c9652bc32 100644
--- a/src/particles/qquickparticleaffector_p.h
+++ b/src/particles/qquickparticleaffector_p.h
@@ -185,7 +185,7 @@ protected:
bool activeGroup(int g);
bool shouldAffect(QQuickParticleData* datum);//Call to do the logic on whether it is affecting that datum
void postAffect(QQuickParticleData* datum);//Call to do the post-affect logic on particles which WERE affected(once off, needs reset, affected signal)
- virtual void componentComplete();
+ void componentComplete() override;
bool isAffectedConnected();
static const qreal simulationDelta;
static const qreal simulationCutoff;
@@ -200,7 +200,7 @@ private:
QStringList m_whenCollidingWith;
- bool isColliding(QQuickParticleData* d);
+ bool isColliding(QQuickParticleData* d) const;
};
QT_END_NAMESPACE
diff --git a/src/particles/qquickparticleemitter_p.h b/src/particles/qquickparticleemitter_p.h
index b3f96ae3e6..4f7e12da44 100644
--- a/src/particles/qquickparticleemitter_p.h
+++ b/src/particles/qquickparticleemitter_p.h
@@ -133,7 +133,7 @@ public:
qreal velocityFromMovement() const { return m_velocity_from_movement; }
void setVelocityFromMovement(qreal s);
- virtual void componentComplete();
+ void componentComplete() override;
Q_SIGNALS:
void emitParticles(QQmlV4Handle particles);
void particlesPerSecondChanged(qreal);
diff --git a/src/particles/qquickparticlegroup_p.h b/src/particles/qquickparticlegroup_p.h
index 25cc2130b1..0314234569 100644
--- a/src/particles/qquickparticlegroup_p.h
+++ b/src/particles/qquickparticlegroup_p.h
@@ -104,8 +104,8 @@ Q_SIGNALS:
void systemChanged(QQuickParticleSystem* arg);
protected:
- virtual void componentComplete();
- virtual void classBegin(){;}
+ void componentComplete() override;
+ void classBegin() override {}
private:
diff --git a/src/particles/qquickparticlepainter_p.h b/src/particles/qquickparticlepainter_p.h
index 064ce27fe8..ac14a18103 100644
--- a/src/particles/qquickparticlepainter_p.h
+++ b/src/particles/qquickparticlepainter_p.h
@@ -98,7 +98,7 @@ public:
return m_groupIds;
}
- void itemChange(ItemChange, const ItemChangeData &);
+ void itemChange(ItemChange, const ItemChangeData &) override;
Q_SIGNALS:
void countChanged();
@@ -123,7 +123,7 @@ protected:
*/
virtual void reset();
- virtual void componentComplete();
+ void componentComplete() override;
virtual void initialize(int gIdx, int pIdx){//Called from main thread
Q_UNUSED(gIdx);
Q_UNUSED(pIdx);
diff --git a/src/particles/qquickparticlesystem_p.h b/src/particles/qquickparticlesystem_p.h
index b57d55bd98..de39b436e2 100644
--- a/src/particles/qquickparticlesystem_p.h
+++ b/src/particles/qquickparticlesystem_p.h
@@ -389,7 +389,7 @@ public Q_SLOTS:
protected:
//This one only once per frame (effectively)
- void componentComplete();
+ void componentComplete() override;
private Q_SLOTS:
void emittersChanged();
@@ -477,12 +477,12 @@ public:
: QAbstractAnimation(static_cast<QObject*>(system)), m_system(system)
{ }
protected:
- virtual void updateCurrentTime( int t )
+ void updateCurrentTime(int t) override
{
m_system->updateCurrentTime(t);
}
- virtual int duration() const
+ int duration() const override
{
return -1;
}
diff --git a/src/particles/qquickpointattractor_p.h b/src/particles/qquickpointattractor_p.h
index 99fae300c6..47985b5e82 100644
--- a/src/particles/qquickpointattractor_p.h
+++ b/src/particles/qquickpointattractor_p.h
@@ -160,7 +160,8 @@ void setProportionalToDistance(Proportion arg)
}
protected:
- virtual bool affectParticle(QQuickParticleData *d, qreal dt);
+ bool affectParticle(QQuickParticleData *d, qreal dt) override;
+
private:
qreal m_strength;
qreal m_x;
diff --git a/src/particles/qquickpointdirection.cpp b/src/particles/qquickpointdirection.cpp
index dbd15148ba..9038ce0aa0 100644
--- a/src/particles/qquickpointdirection.cpp
+++ b/src/particles/qquickpointdirection.cpp
@@ -75,7 +75,7 @@ QQuickPointDirection::QQuickPointDirection(QObject *parent) :
{
}
-const QPointF QQuickPointDirection::sample(const QPointF &)
+QPointF QQuickPointDirection::sample(const QPointF &)
{
QPointF ret;
ret.setX(m_x - m_xVariation + rand() / float(RAND_MAX) * m_xVariation * 2);
diff --git a/src/particles/qquickpointdirection_p.h b/src/particles/qquickpointdirection_p.h
index b01dc7ea4e..a80be928ad 100644
--- a/src/particles/qquickpointdirection_p.h
+++ b/src/particles/qquickpointdirection_p.h
@@ -63,7 +63,7 @@ class QQuickPointDirection : public QQuickDirection
Q_PROPERTY(qreal yVariation READ yVariation WRITE setYVariation NOTIFY yVariationChanged)
public:
explicit QQuickPointDirection(QObject *parent = 0);
- virtual const QPointF sample(const QPointF &from);
+ QPointF sample(const QPointF &from) override;
qreal x() const
{
return m_x;
diff --git a/src/particles/qquickrectangleextruder_p.h b/src/particles/qquickrectangleextruder_p.h
index 001031c711..630cf3050d 100644
--- a/src/particles/qquickrectangleextruder_p.h
+++ b/src/particles/qquickrectangleextruder_p.h
@@ -62,8 +62,8 @@ class QQuickRectangleExtruder : public QQuickParticleExtruder
public:
explicit QQuickRectangleExtruder(QObject *parent = 0);
- virtual QPointF extrude(const QRectF &);
- virtual bool contains(const QRectF &bounds, const QPointF &point);
+ QPointF extrude(const QRectF &) override;
+ bool contains(const QRectF &bounds, const QPointF &point) override;
bool fill() const
{
return m_fill;
diff --git a/src/particles/qquickspritegoal_p.h b/src/particles/qquickspritegoal_p.h
index 7174fd2318..2b15d0b8bb 100644
--- a/src/particles/qquickspritegoal_p.h
+++ b/src/particles/qquickspritegoal_p.h
@@ -81,7 +81,8 @@ public:
}
protected:
- virtual bool affectParticle(QQuickParticleData *d, qreal dt);
+ bool affectParticle(QQuickParticleData *d, qreal dt) override;
+
Q_SIGNALS:
void goalStateChanged(const QString &arg);
diff --git a/src/particles/qquicktargetdirection.cpp b/src/particles/qquicktargetdirection.cpp
index f9bcfbc564..012c9a151b 100644
--- a/src/particles/qquicktargetdirection.cpp
+++ b/src/particles/qquicktargetdirection.cpp
@@ -94,7 +94,7 @@ QQuickTargetDirection::QQuickTargetDirection(QObject *parent) :
{
}
-const QPointF QQuickTargetDirection::sample(const QPointF &from)
+QPointF QQuickTargetDirection::sample(const QPointF &from)
{
//###This approach loses interpolating the last position of the target (like we could with the emitter) is it worthwhile?
QPointF ret;
diff --git a/src/particles/qquicktargetdirection_p.h b/src/particles/qquicktargetdirection_p.h
index 4de5867336..13e826743e 100644
--- a/src/particles/qquicktargetdirection_p.h
+++ b/src/particles/qquicktargetdirection_p.h
@@ -71,7 +71,7 @@ class QQuickTargetDirection : public QQuickDirection
public:
explicit QQuickTargetDirection(QObject *parent = 0);
- virtual const QPointF sample(const QPointF &from);
+ QPointF sample(const QPointF &from) override;
qreal targetX() const
{
diff --git a/src/particles/qquicktrailemitter_p.h b/src/particles/qquicktrailemitter_p.h
index b70f34999a..99464436ba 100644
--- a/src/particles/qquicktrailemitter_p.h
+++ b/src/particles/qquicktrailemitter_p.h
@@ -71,8 +71,8 @@ public:
};
Q_ENUM(EmitSize)
explicit QQuickTrailEmitter(QQuickItem *parent = 0);
- virtual void emitWindow(int timeStamp);
- virtual void reset();
+ void emitWindow(int timeStamp) override;
+ void reset() override;
int particlesPerParticlePerSecond() const
{
diff --git a/src/particles/qquickturbulence_p.h b/src/particles/qquickturbulence_p.h
index 7a6be1719e..e73f3ba153 100644
--- a/src/particles/qquickturbulence_p.h
+++ b/src/particles/qquickturbulence_p.h
@@ -65,7 +65,7 @@ class QQuickTurbulenceAffector : public QQuickParticleAffector
public:
explicit QQuickTurbulenceAffector(QQuickItem *parent = 0);
~QQuickTurbulenceAffector();
- virtual void affectSystem(qreal dt);
+ void affectSystem(qreal dt) override;
qreal strength() const
{
@@ -102,8 +102,8 @@ public Q_SLOTS:
}
protected:
- virtual void geometryChanged(const QRectF &newGeometry,
- const QRectF &oldGeometry);
+ void geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry) override;
private:
void ensureInit();
void mapUpdate();
diff --git a/src/particles/qquickv4particledata.cpp b/src/particles/qquickv4particledata.cpp
index bd43d45c38..967652f31a 100644
--- a/src/particles/qquickv4particledata.cpp
+++ b/src/particles/qquickv4particledata.cpp
@@ -525,7 +525,7 @@ QQuickV4ParticleData::~QQuickV4ParticleData()
{
}
-QQmlV4Handle QQuickV4ParticleData::v4Value()
+QQmlV4Handle QQuickV4ParticleData::v4Value() const
{
return QQmlV4Handle(m_v4Value.value());
}
diff --git a/src/particles/qquickv4particledata_p.h b/src/particles/qquickv4particledata_p.h
index 437491ff42..d73e3b644d 100644
--- a/src/particles/qquickv4particledata_p.h
+++ b/src/particles/qquickv4particledata_p.h
@@ -63,7 +63,7 @@ class QQuickV4ParticleData {
public:
QQuickV4ParticleData(QV8Engine*, QQuickParticleData*, QQuickParticleSystem *system);
~QQuickV4ParticleData();
- QQmlV4Handle v4Value();
+ QQmlV4Handle v4Value() const;
private:
QV4::PersistentValue m_v4Value;
};
diff --git a/src/particles/qquickwander_p.h b/src/particles/qquickwander_p.h
index 6461444cd1..0ad19d4d13 100644
--- a/src/particles/qquickwander_p.h
+++ b/src/particles/qquickwander_p.h
@@ -105,7 +105,8 @@ public:
}
protected:
- virtual bool affectParticle(QQuickParticleData *d, qreal dt);
+ bool affectParticle(QQuickParticleData *d, qreal dt) override;
+
Q_SIGNALS:
void xVarianceChanged(qreal arg);
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 11c8641e21..2467239be2 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -1,4 +1,4 @@
TEMPLATE = subdirs
!contains(QT_CONFIG, no-qml-debug):SUBDIRS += qmltooling
-SUBDIRS += scenegraph
+qtHaveModule(quick):SUBDIRS += scenegraph
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.cpp
index 31873f7915..b0f59717ac 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.cpp
@@ -70,7 +70,7 @@ void QDebugMessageServiceImpl::sendDebugMessage(QtMsgType type,
//We just eavesdrop and forward the messages to a port
//only if a client is connected to it.
QQmlDebugPacket ws;
- ws << QByteArray("MESSAGE") << type << buf.toUtf8();
+ ws << QByteArray("MESSAGE") << int(type) << buf.toUtf8();
ws << QByteArray(ctxt.file) << ctxt.line << QByteArray(ctxt.function);
ws << QByteArray(ctxt.category) << timer.nsecsElapsed();
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp
index f72b8a51f9..fe88d686fc 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp
@@ -289,10 +289,12 @@ void QQmlEngineDebugServiceImpl::buildObjectDump(QDataStream &message,
prop.value = expr->expression();
QObject *scope = expr->scopeObject();
if (scope) {
- QString methodName = QString::fromLatin1(QMetaObjectPrivate::signal(scope->metaObject(), signalHandler->signalIndex()).name());
- if (!methodName.isEmpty()) {
- prop.name = QLatin1String("on") + methodName[0].toUpper()
- + methodName.mid(1);
+ const QByteArray methodName = QMetaObjectPrivate::signal(scope->metaObject(),
+ signalHandler->signalIndex()).name();
+ const QLatin1String methodNameStr(methodName);
+ if (methodNameStr.size() != 0) {
+ prop.name = QLatin1String("on") + QChar(methodNameStr.at(0)).toUpper()
+ + methodNameStr.mid(1);
}
}
}
@@ -520,12 +522,12 @@ void QQmlEngineDebugServiceImpl::processMessage(const QByteArray &message)
ds >> file >> lineNumber >> columnNumber >> recurse >> dumpProperties;
- QList<QObject*> objects = objectForLocationInfo(file, lineNumber, columnNumber);
+ const QList<QObject*> objects = objectForLocationInfo(file, lineNumber, columnNumber);
rs << QByteArray("FETCH_OBJECTS_FOR_LOCATION_R") << queryId
<< objects.count();
- foreach (QObject *object, objects) {
+ for (QObject *object : objects) {
if (recurse)
prepareDeferredObjects(object);
buildObjectDump(rs, object, recurse, dumpProperties);
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp
index 5b96163b48..9c198a8afc 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp
@@ -287,7 +287,7 @@ void NativeDebugger::signalEmitted(const QString &signal)
//Normalize to Lower case.
QString signalName = signal.left(signal.indexOf(QLatin1Char('('))).toLower();
- foreach (const QString &signal, breakOnSignals) {
+ for (const QString &signal : qAsConst(breakOnSignals)) {
if (signal == signalName) {
// TODO: pause debugger
break;
@@ -340,16 +340,16 @@ void NativeDebugger::handleBacktrace(QJsonObject *response, const QJsonObject &a
if (heapFunctionObject) {
QJsonObject frame;
- frame[QStringLiteral("language")] = QStringLiteral("js");
- frame[QStringLiteral("context")] = encodeContext(executionContext);
+ frame.insert(QStringLiteral("language"), QStringLiteral("js"));
+ frame.insert(QStringLiteral("context"), encodeContext(executionContext));
if (QV4::Function *function = heapFunctionObject->function) {
if (QV4::Heap::String *functionName = function->name())
- frame[QStringLiteral("function")] = functionName->toQString();
- frame[QStringLiteral("file")] = function->sourceFile();
+ frame.insert(QStringLiteral("function"), functionName->toQString());
+ frame.insert(QStringLiteral("file"), function->sourceFile());
}
int line = executionContext->d()->lineNumber;
- frame[QStringLiteral("line")] = (line < 0 ? -line : line);
+ frame.insert(QStringLiteral("line"), (line < 0 ? -line : line));
frameArray.push_back(frame);
}
@@ -475,8 +475,8 @@ void NativeDebugger::handleVariables(QJsonObject *response, const QJsonObject &a
TRACE_PROTOCOL("Engine: " << engine);
Collector collector(engine);
- QJsonArray expanded = arguments.value(QLatin1String("expanded")).toArray();
- foreach (const QJsonValue &ex, expanded)
+ const QJsonArray expanded = arguments.value(QLatin1String("expanded")).toArray();
+ for (const QJsonValue &ex : expanded)
collector.m_expanded.append(ex.toString());
TRACE_PROTOCOL("Expanded: " << collector.m_expanded);
@@ -527,16 +527,16 @@ void NativeDebugger::handleExpressions(QJsonObject *response, const QJsonObject
TRACE_PROTOCOL("Engines: " << engine << m_engine);
Collector collector(engine);
- QJsonArray expanded = arguments.value(QLatin1String("expanded")).toArray();
- foreach (const QJsonValue &ex, expanded)
+ const QJsonArray expanded = arguments.value(QLatin1String("expanded")).toArray();
+ for (const QJsonValue &ex : expanded)
collector.m_expanded.append(ex.toString());
TRACE_PROTOCOL("Expanded: " << collector.m_expanded);
QJsonArray output;
QV4::Scope scope(engine);
- QJsonArray expressions = arguments.value(QLatin1String("expressions")).toArray();
- foreach (const QJsonValue &expr, expressions) {
+ const QJsonArray expressions = arguments.value(QLatin1String("expressions")).toArray();
+ for (const QJsonValue &expr : expressions) {
QString expression = expr.toObject().value(QLatin1String("expression")).toString();
QString name = expr.toObject().value(QLatin1String("name")).toString();
TRACE_PROTOCOL("Evaluate expression: " << expression);
@@ -548,15 +548,15 @@ void NativeDebugger::handleExpressions(QJsonObject *response, const QJsonObject
m_runningJob = false;
if (result->isUndefined()) {
QJsonObject dict;
- dict[QStringLiteral("name")] = name;
- dict[QStringLiteral("valueencoded")] = QStringLiteral("undefined");
+ dict.insert(QStringLiteral("name"), name);
+ dict.insert(QStringLiteral("valueencoded"), QStringLiteral("undefined"));
output.append(dict);
} else if (result.ptr && result.ptr->rawValue()) {
collector.collect(&output, QString(), name, *result);
} else {
QJsonObject dict;
- dict[QStringLiteral("name")] = name;
- dict[QStringLiteral("valueencoded")] = QStringLiteral("notaccessible");
+ dict.insert(QStringLiteral("name"), name);
+ dict.insert(QStringLiteral("valueencoded"), QStringLiteral("notaccessible"));
output.append(dict);
}
TRACE_PROTOCOL("EXCEPTION: " << engine->hasException);
@@ -748,7 +748,8 @@ void QQmlNativeDebugServiceImpl::engineAboutToBeRemoved(QJSEngine *engine)
TRACE_PROTOCOL("Removing engine" << engine);
if (engine) {
QV4::ExecutionEngine *executionEngine = QV8Engine::getV4(engine->handle());
- foreach (NativeDebugger *debugger, m_debuggers) {
+ const auto debuggersCopy = m_debuggers;
+ for (NativeDebugger *debugger : debuggersCopy) {
if (debugger->engine() == executionEngine)
m_debuggers.removeAll(debugger);
}
@@ -759,7 +760,7 @@ void QQmlNativeDebugServiceImpl::engineAboutToBeRemoved(QJSEngine *engine)
void QQmlNativeDebugServiceImpl::stateAboutToBeChanged(QQmlDebugService::State state)
{
if (state == Enabled) {
- foreach (NativeDebugger *debugger, m_debuggers) {
+ for (NativeDebugger *debugger : qAsConst(m_debuggers)) {
QV4::ExecutionEngine *engine = debugger->engine();
if (!engine->debugger())
engine->setDebugger(debugger);
@@ -783,7 +784,7 @@ void QQmlNativeDebugServiceImpl::messageReceived(const QByteArray &message)
} else if (cmd == QLatin1String("echo")) {
response.insert(QStringLiteral("result"), arguments);
} else {
- foreach (NativeDebugger *debugger, m_debuggers)
+ for (NativeDebugger *debugger : qAsConst(m_debuggers))
if (debugger)
debugger->handleCommand(&response, cmd, arguments);
}
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp
index 756b6b28be..773bc937f5 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp
@@ -52,7 +52,7 @@ QV4DebuggerAgent::QV4DebuggerAgent(QV4DebugServiceImpl *debugService)
QV4Debugger *QV4DebuggerAgent::pausedDebugger() const
{
- foreach (QV4Debugger *debugger, m_debuggers) {
+ for (QV4Debugger *debugger : m_debuggers) {
if (debugger->state() == QV4Debugger::Paused)
return debugger;
}
@@ -147,13 +147,13 @@ void QV4DebuggerAgent::pause(QV4Debugger *debugger) const
void QV4DebuggerAgent::pauseAll() const
{
- foreach (QV4Debugger *debugger, m_debuggers)
+ for (QV4Debugger *debugger : m_debuggers)
pause(debugger);
}
void QV4DebuggerAgent::resumeAll() const
{
- foreach (QV4Debugger *debugger, m_debuggers)
+ for (QV4Debugger *debugger : m_debuggers)
if (debugger->state() == QV4Debugger::Paused)
debugger->resume(QV4Debugger::FullThrottle);
}
@@ -161,7 +161,7 @@ void QV4DebuggerAgent::resumeAll() const
int QV4DebuggerAgent::addBreakPoint(const QString &fileName, int lineNumber, bool enabled, const QString &condition)
{
if (enabled)
- foreach (QV4Debugger *debugger, m_debuggers)
+ for (QV4Debugger *debugger : qAsConst(m_debuggers))
debugger->addBreakPoint(fileName, lineNumber, condition);
int id = m_breakPoints.size();
@@ -178,7 +178,7 @@ void QV4DebuggerAgent::removeBreakPoint(int id)
m_breakPoints.remove(id);
if (breakPoint.enabled)
- foreach (QV4Debugger *debugger, m_debuggers)
+ for (QV4Debugger *debugger : qAsConst(m_debuggers))
debugger->removeBreakPoint(breakPoint.fileName, breakPoint.lineNr);
}
@@ -195,7 +195,7 @@ void QV4DebuggerAgent::enableBreakPoint(int id, bool onoff)
return;
breakPoint.enabled = onoff;
- foreach (QV4Debugger *debugger, m_debuggers) {
+ for (QV4Debugger *debugger : qAsConst(m_debuggers)) {
if (onoff)
debugger->addBreakPoint(breakPoint.fileName, breakPoint.lineNr, breakPoint.condition);
else
@@ -218,14 +218,14 @@ void QV4DebuggerAgent::setBreakOnThrow(bool onoff)
{
if (onoff != m_breakOnThrow) {
m_breakOnThrow = onoff;
- foreach (QV4Debugger *debugger, m_debuggers)
+ for (QV4Debugger *debugger : qAsConst(m_debuggers))
debugger->setBreakOnThrow(onoff);
}
}
void QV4DebuggerAgent::clearAllPauseRequests()
{
- foreach (QV4Debugger *debugger, m_debuggers)
+ for (QV4Debugger *debugger : qAsConst(m_debuggers))
debugger->clearPauseRequest();
}
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp
index a2d2fff72b..4e4048f6ad 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp
@@ -205,7 +205,7 @@ void ValueLookupJob::run()
QQmlContextData::get(engine->qmlEngine()->rootContext()),
scopeObject.data()));
}
- foreach (const QJsonValue &handle, handles) {
+ for (const QJsonValue &handle : handles) {
QV4DataCollector::Ref ref = handle.toInt();
if (!collector->isValidRef(ref)) {
exception = QString::fromLatin1("Invalid Ref: %1").arg(ref);
@@ -258,7 +258,7 @@ GatherSourcesJob::GatherSourcesJob(QV4::ExecutionEngine *engine)
void GatherSourcesJob::run()
{
- foreach (QV4::CompiledData::CompilationUnit *unit, engine->compilationUnits) {
+ for (QV4::CompiledData::CompilationUnit *unit : qAsConst(engine->compilationUnits)) {
QString fileName = unit->fileName();
if (!fileName.isEmpty())
sources.append(fileName);
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h
index 721f42b7c2..aff2ea1b6c 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h
@@ -65,7 +65,7 @@ class JavaScriptJob : public QV4DebugJob
public:
JavaScriptJob(QV4::ExecutionEngine *engine, int frameNr, const QString &script);
- void run();
+ void run() override;
bool hasExeption() const;
protected:
@@ -90,7 +90,7 @@ class BacktraceJob: public CollectJob
int toFrame;
public:
BacktraceJob(QV4DataCollector *collector, int fromFrame, int toFrame);
- void run();
+ void run() override;
};
class FrameJob: public CollectJob
@@ -100,7 +100,7 @@ class FrameJob: public CollectJob
public:
FrameJob(QV4DataCollector *collector, int frameNr);
- void run();
+ void run() override;
bool wasSuccessful() const;
};
@@ -123,7 +123,7 @@ class ValueLookupJob: public CollectJob
public:
ValueLookupJob(const QJsonArray &handles, QV4DataCollector *collector);
- void run();
+ void run() override;
const QString &exceptionMessage() const;
};
@@ -137,7 +137,7 @@ class ExpressionEvalJob: public JavaScriptJob
public:
ExpressionEvalJob(QV4::ExecutionEngine *engine, int frameNr, const QString &expression,
QV4DataCollector *collector);
- virtual void handleResult(QV4::ScopedValue &value);
+ void handleResult(QV4::ScopedValue &value) override;
const QString &exceptionMessage() const;
const QJsonObject &returnValue() const;
const QJsonArray &refs() const;
@@ -150,7 +150,7 @@ class GatherSourcesJob: public QV4DebugJob
public:
GatherSourcesJob(QV4::ExecutionEngine *engine);
- void run();
+ void run() override;
const QStringList &result() const;
};
@@ -161,7 +161,7 @@ class EvalJob: public JavaScriptJob
public:
EvalJob(QV4::ExecutionEngine *engine, const QString &script);
- virtual void handleResult(QV4::ScopedValue &result);
+ void handleResult(QV4::ScopedValue &result) override;
bool resultAsBoolean() const;
};
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp
index 00c5c1ad77..de97b5437b 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp
@@ -152,7 +152,7 @@ class UnknownV8CommandHandler: public V8CommandHandler
public:
UnknownV8CommandHandler(): V8CommandHandler(QString()) {}
- virtual void handleRequest()
+ void handleRequest() override
{
QString msg = QLatin1String("unimplemented command \"")
+ req.value(QLatin1String("command")).toString()
@@ -167,7 +167,7 @@ class V8VersionRequest: public V8CommandHandler
public:
V8VersionRequest(): V8CommandHandler(QStringLiteral("version")) {}
- virtual void handleRequest()
+ void handleRequest() override
{
addCommand();
addRequestSequence();
@@ -186,7 +186,7 @@ class V8SetBreakPointRequest: public V8CommandHandler
public:
V8SetBreakPointRequest(): V8CommandHandler(QStringLiteral("setbreakpoint")) {}
- virtual void handleRequest()
+ void handleRequest() override
{
// decypher the payload:
QJsonObject args = req.value(QLatin1String("arguments")).toObject();
@@ -237,7 +237,7 @@ class V8ClearBreakPointRequest: public V8CommandHandler
public:
V8ClearBreakPointRequest(): V8CommandHandler(QStringLiteral("clearbreakpoint")) {}
- virtual void handleRequest()
+ void handleRequest() override
{
// decypher the payload:
QJsonObject args = req.value(QLatin1String("arguments")).toObject();
@@ -270,7 +270,7 @@ class V8BacktraceRequest: public V8CommandHandler
public:
V8BacktraceRequest(): V8CommandHandler(QStringLiteral("backtrace")) {}
- virtual void handleRequest()
+ void handleRequest() override
{
// decypher the payload:
@@ -303,7 +303,7 @@ class V8FrameRequest: public V8CommandHandler
public:
V8FrameRequest(): V8CommandHandler(QStringLiteral("frame")) {}
- virtual void handleRequest()
+ void handleRequest() override
{
// decypher the payload:
QJsonObject arguments = req.value(QLatin1String("arguments")).toObject();
@@ -345,7 +345,7 @@ class V8ScopeRequest: public V8CommandHandler
public:
V8ScopeRequest(): V8CommandHandler(QStringLiteral("scope")) {}
- virtual void handleRequest()
+ void handleRequest() override
{
// decypher the payload:
QJsonObject arguments = req.value(QLatin1String("arguments")).toObject();
@@ -390,7 +390,7 @@ class V8LookupRequest: public V8CommandHandler
public:
V8LookupRequest(): V8CommandHandler(QStringLiteral("lookup")) {}
- virtual void handleRequest()
+ void handleRequest() override
{
// decypher the payload:
QJsonObject arguments = req.value(QLatin1String("arguments")).toObject();
@@ -430,7 +430,7 @@ class V8ContinueRequest: public V8CommandHandler
public:
V8ContinueRequest(): V8CommandHandler(QStringLiteral("continue")) {}
- virtual void handleRequest()
+ void handleRequest() override
{
// decypher the payload:
QJsonObject arguments = req.value(QLatin1String("arguments")).toObject();
@@ -476,7 +476,7 @@ class V8DisconnectRequest: public V8CommandHandler
public:
V8DisconnectRequest(): V8CommandHandler(QStringLiteral("disconnect")) {}
- virtual void handleRequest()
+ void handleRequest() override
{
debugService->debuggerAgent.removeAllBreakPoints();
debugService->debuggerAgent.resumeAll();
@@ -494,7 +494,7 @@ class V8SetExceptionBreakRequest: public V8CommandHandler
public:
V8SetExceptionBreakRequest(): V8CommandHandler(QStringLiteral("setexceptionbreak")) {}
- virtual void handleRequest()
+ void handleRequest() override
{
bool wasEnabled = debugService->debuggerAgent.breakOnThrow();
@@ -534,7 +534,7 @@ class V8ScriptsRequest: public V8CommandHandler
public:
V8ScriptsRequest(): V8CommandHandler(QStringLiteral("scripts")) {}
- virtual void handleRequest()
+ void handleRequest() override
{
//decypher the payload:
QJsonObject arguments = req.value(QLatin1String("arguments")).toObject();
@@ -558,7 +558,7 @@ public:
debugger->runInEngine(&job);
QJsonArray body;
- foreach (const QString &source, job.result()) {
+ for (const QString &source : job.result()) {
QJsonObject src;
src[QLatin1String("name")] = source;
src[QLatin1String("scriptType")] = 4;
@@ -606,7 +606,7 @@ class V8EvaluateRequest: public V8CommandHandler
public:
V8EvaluateRequest(): V8CommandHandler(QStringLiteral("evaluate")) {}
- virtual void handleRequest()
+ void handleRequest() override
{
QJsonObject arguments = req.value(QLatin1String("arguments")).toObject();
QString expression = arguments.value(QLatin1String("expression")).toString();
@@ -718,7 +718,8 @@ void QV4DebugServiceImpl::stateAboutToBeChanged(State state)
{
QMutexLocker lock(&m_configMutex);
if (state == Enabled) {
- foreach (QV4Debugger *debugger, debuggerAgent.debuggers()) {
+ const auto debuggers = debuggerAgent.debuggers();
+ for (QV4Debugger *debugger : debuggers) {
QV4::ExecutionEngine *ee = debugger->engine();
if (!ee->debugger())
ee->setDebugger(debugger);
@@ -737,7 +738,7 @@ void QV4DebugServiceImpl::signalEmitted(const QString &signal)
//Normalize to Lower case.
QString signalName = signal.left(signal.indexOf(QLatin1Char('('))).toLower();
- foreach (const QString &signal, breakOnSignals) {
+ for (const QString &signal : qAsConst(breakOnSignals)) {
if (signal == signalName) {
// TODO: pause debugger
break;
diff --git a/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp
index 107d54c626..eb254ca1e0 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp
@@ -92,7 +92,7 @@ void GlobalInspector::setSelectedItems(const QList<QQuickItem *> &items)
QList<QObject*> objectList;
objectList.reserve(items.count());
- foreach (QQuickItem *item, items)
+ for (QQuickItem *item : items)
objectList << item;
sendCurrentObjects(objectList);
@@ -113,7 +113,7 @@ void GlobalInspector::sendCurrentObjects(const QList<QObject*> &objects)
QList<int> debugIds;
debugIds.reserve(objects.count());
- foreach (QObject *object, objects)
+ for (QObject *object : objects)
debugIds << QQmlDebugService::idForObject(object);
ds << debugIds;
@@ -194,7 +194,7 @@ bool GlobalInspector::createQmlObject(int requestId, const QString &qml, QObject
return false;
QString imports;
- foreach (const QString &s, importList)
+ for (const QString &s : importList)
imports += s + QLatin1Char('\n');
ObjectCreator *objectCreator = new ObjectCreator(requestId, parentContext->engine(), parent);
@@ -223,7 +223,7 @@ void GlobalInspector::removeWindow(QQuickWindow *window)
void GlobalInspector::setParentWindow(QQuickWindow *window, QWindow *parentWindow)
{
- foreach (QmlJSDebugger::QQuickWindowInspector *inspector, m_windowInspectors) {
+ for (QmlJSDebugger::QQuickWindowInspector *inspector : qAsConst(m_windowInspectors)) {
if (inspector->quickWindow() == window)
inspector->setParentWindow(parentWindow);
}
@@ -234,7 +234,8 @@ bool GlobalInspector::syncSelectedItems(const QList<QQuickItem *> &items)
bool selectionChanged = false;
// Disconnect and remove items that are no longer selected
- foreach (const QPointer<QQuickItem> &item, m_selectedItems) {
+ const auto selectedItemsCopy = m_selectedItems;
+ for (const QPointer<QQuickItem> &item : selectedItemsCopy) {
if (!item) // Don't see how this can happen due to handling of destroyed()
continue;
if (items.contains(item))
@@ -247,14 +248,14 @@ bool GlobalInspector::syncSelectedItems(const QList<QQuickItem *> &items)
}
// Connect and add newly selected items
- foreach (QQuickItem *item, items) {
+ for (QQuickItem *item : items) {
if (m_selectedItems.contains(item))
continue;
selectionChanged = true;
connect(item, &QObject::destroyed, this, &GlobalInspector::removeFromSelectedItems);
m_selectedItems.append(item);
- foreach (QQuickWindowInspector *inspector, m_windowInspectors) {
+ for (QQuickWindowInspector *inspector : qAsConst(m_windowInspectors)) {
if (inspector->isEnabled() && inspector->quickWindow() == item->window()) {
m_highlightItems.insert(item, new SelectionHighlight(titleForItem(item), item,
inspector->overlay()));
@@ -314,12 +315,12 @@ void GlobalInspector::processMessage(const QByteArray &message)
ds >> requestId >> command;
if (command == ENABLE) {
- foreach (QQuickWindowInspector *inspector, m_windowInspectors)
+ for (QQuickWindowInspector *inspector : qAsConst(m_windowInspectors))
inspector->setEnabled(true);
success = !m_windowInspectors.isEmpty();
} else if (command == DISABLE) {
setSelectedItems(QList<QQuickItem*>());
- foreach (QQuickWindowInspector *inspector, m_windowInspectors)
+ for (QQuickWindowInspector *inspector : qAsConst(m_windowInspectors))
inspector->setEnabled(false);
success = !m_windowInspectors.isEmpty();
} else if (command == SELECT) {
@@ -327,7 +328,7 @@ void GlobalInspector::processMessage(const QByteArray &message)
ds >> debugIds;
QList<QQuickItem *> selectedObjects;
- foreach (int debugId, debugIds) {
+ for (int debugId : qAsConst(debugIds)) {
if (QQuickItem *obj =
qobject_cast<QQuickItem *>(QQmlDebugService::objectForId(debugId)))
selectedObjects << obj;
@@ -341,7 +342,7 @@ void GlobalInspector::processMessage(const QByteArray &message)
} else if (command == SHOW_APP_ON_TOP) {
bool showOnTop;
ds >> showOnTop;
- foreach (QmlJSDebugger::QQuickWindowInspector *inspector, m_windowInspectors)
+ for (QmlJSDebugger::QQuickWindowInspector *inspector : qAsConst(m_windowInspectors))
inspector->setShowAppOnTop(showOnTop);
success = !m_windowInspectors.isEmpty();
} else if (command == CREATE_OBJECT) {
diff --git a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
index 3145601612..9eeb285951 100644
--- a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
+++ b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
@@ -205,7 +205,7 @@ QQmlNativeDebugConnector::QQmlNativeDebugConnector()
QQmlNativeDebugConnector::~QQmlNativeDebugConnector()
{
- foreach (QQmlDebugService *service, m_services) {
+ for (QQmlDebugService *service : qAsConst(m_services)) {
service->stateAboutToBeChanged(QQmlDebugService::NotConnected);
service->setState(QQmlDebugService::NotConnected);
service->stateChanged(QQmlDebugService::NotConnected);
@@ -232,12 +232,12 @@ void QQmlNativeDebugConnector::addEngine(QJSEngine *engine)
Q_ASSERT(!m_engines.contains(engine));
TRACE_PROTOCOL("Add engine to connector:" << engine);
- foreach (QQmlDebugService *service, m_services)
+ for (QQmlDebugService *service : qAsConst(m_services))
service->engineAboutToBeAdded(engine);
announceObjectAvailability(QLatin1String("qmlengine"), engine, true);
- foreach (QQmlDebugService *service, m_services)
+ for (QQmlDebugService *service : qAsConst(m_services))
service->engineAdded(engine);
m_engines.append(engine);
@@ -248,12 +248,12 @@ void QQmlNativeDebugConnector::removeEngine(QJSEngine *engine)
Q_ASSERT(m_engines.contains(engine));
TRACE_PROTOCOL("Remove engine from connector:" << engine);
- foreach (QQmlDebugService *service, m_services)
+ for (QQmlDebugService *service : qAsConst(m_services))
service->engineAboutToBeRemoved(engine);
announceObjectAvailability(QLatin1String("qmlengine"), engine, false);
- foreach (QQmlDebugService *service, m_services)
+ for (QQmlDebugService *service : qAsConst(m_services))
service->engineRemoved(engine);
m_engines.removeOne(engine);
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp
index 6b653d5a54..0ed13d5105 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp
@@ -122,10 +122,10 @@ void QQmlEngineControlServiceImpl::stateChanged(State)
{
// We flush everything for any kind of state change, to avoid complicated timing issues.
QMutexLocker lock(&dataMutex);
- foreach (QJSEngine *engine, startingEngines)
+ for (QJSEngine *engine : qAsConst(startingEngines))
emit attachedToEngine(engine);
startingEngines.clear();
- foreach (QJSEngine *engine, stoppingEngines)
+ for (QJSEngine *engine : qAsConst(stoppingEngines))
emit detachedFromEngine(engine);
stoppingEngines.clear();
}
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp
index a4320098c0..90e817e2fc 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp
@@ -101,7 +101,7 @@ static void qQmlProfilerDataToByteArrays(const QQmlProfilerData &d,
ds << static_cast<qint64>(d.locationId);
messages.append(ds.squeezedData());
ds.clear();
- ds << d.time << QQmlProfilerDefinitions::RangeData
+ ds << d.time << int(QQmlProfilerDefinitions::RangeData)
<< static_cast<quint32>(d.detailType)
<< (i->location.sourceFile.isEmpty() ? i->url.toString() :
i->location.sourceFile);
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp
index dba2fd3cc3..c1f6f93ef1 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp
@@ -51,6 +51,8 @@
#include <QtCore/qthread.h>
#include <QtCore/qcoreapplication.h>
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
Q_QML_DEBUG_PLUGIN_LOADER(QQmlAbstractProfilerAdapter)
@@ -92,16 +94,18 @@ void QQmlProfilerServiceImpl::dataReady(QQmlAbstractProfilerAdapter *profiler)
m_startTimes.insert(0, profiler);
if (dataComplete) {
QList<QJSEngine *> enginesToRelease;
- foreach (QJSEngine *engine, m_stoppingEngines) {
- foreach (QQmlAbstractProfilerAdapter *engineProfiler, m_engineProfilers.values(engine)) {
- if (m_startTimes.values().contains(engineProfiler)) {
+ for (QJSEngine *engine : qAsConst(m_stoppingEngines)) {
+ const auto range = qAsConst(m_engineProfilers).equal_range(engine);
+ const auto startTimesEnd = m_startTimes.cend();
+ for (auto it = range.first; it != range.second; ++it) {
+ if (std::find(m_startTimes.cbegin(), startTimesEnd, *it) != startTimesEnd) {
enginesToRelease.append(engine);
break;
}
}
}
sendMessages();
- foreach (QJSEngine *engine, enginesToRelease) {
+ for (QJSEngine *engine : qAsConst(enginesToRelease)) {
m_stoppingEngines.removeOne(engine);
emit detachedFromEngine(engine);
}
@@ -130,8 +134,9 @@ void QQmlProfilerServiceImpl::engineAdded(QJSEngine *engine)
"QML profilers have to be added from the engine thread");
QMutexLocker lock(&m_configMutex);
- foreach (QQmlAbstractProfilerAdapter *profiler, m_engineProfilers.values(engine))
- profiler->stopWaiting();
+ const auto range = qAsConst(m_engineProfilers).equal_range(engine);
+ for (auto it = range.first; it != range.second; ++it)
+ (*it)->stopWaiting();
}
void QQmlProfilerServiceImpl::engineAboutToBeRemoved(QJSEngine *engine)
@@ -141,7 +146,9 @@ void QQmlProfilerServiceImpl::engineAboutToBeRemoved(QJSEngine *engine)
QMutexLocker lock(&m_configMutex);
bool isRunning = false;
- foreach (QQmlAbstractProfilerAdapter *profiler, m_engineProfilers.values(engine)) {
+ const auto range = qAsConst(m_engineProfilers).equal_range(engine);
+ for (auto it = range.first; it != range.second; ++it) {
+ QQmlAbstractProfilerAdapter *profiler = *it;
if (profiler->isRunning())
isRunning = true;
profiler->startWaiting();
@@ -160,7 +167,9 @@ void QQmlProfilerServiceImpl::engineRemoved(QJSEngine *engine)
"QML profilers have to be removed from the engine thread");
QMutexLocker lock(&m_configMutex);
- foreach (QQmlAbstractProfilerAdapter *profiler, m_engineProfilers.values(engine)) {
+ const auto range = qAsConst(m_engineProfilers).equal_range(engine);
+ for (auto it = range.first; it != range.second; ++it) {
+ QQmlAbstractProfilerAdapter *profiler = *it;
removeProfilerFromStartTimes(profiler);
delete profiler;
}
@@ -183,7 +192,7 @@ void QQmlProfilerServiceImpl::addGlobalProfiler(QQmlAbstractProfilerAdapter *pro
// Global profilers are started whenever any engine profiler is started and stopped when
// all engine profilers are stopped.
quint64 features = 0;
- foreach (QQmlAbstractProfilerAdapter *engineProfiler, m_engineProfilers)
+ for (QQmlAbstractProfilerAdapter *engineProfiler : qAsConst(m_engineProfilers))
features |= engineProfiler->features();
if (features != 0)
@@ -231,7 +240,9 @@ void QQmlProfilerServiceImpl::startProfiling(QJSEngine *engine, quint64 features
d << m_timer.nsecsElapsed() << (int)Event << (int)StartTrace;
bool startedAny = false;
if (engine != 0) {
- foreach (QQmlAbstractProfilerAdapter *profiler, m_engineProfilers.values(engine)) {
+ const auto range = qAsConst(m_engineProfilers).equal_range(engine);
+ for (auto it = range.first; it != range.second; ++it) {
+ QQmlAbstractProfilerAdapter *profiler = *it;
if (!profiler->isRunning()) {
profiler->startProfiling(features);
startedAny = true;
@@ -249,12 +260,12 @@ void QQmlProfilerServiceImpl::startProfiling(QJSEngine *engine, quint64 features
startedAny = true;
}
}
- foreach (QJSEngine *profiledEngine, engines)
+ for (QJSEngine *profiledEngine : qAsConst(engines))
d << idForObject(profiledEngine);
}
if (startedAny) {
- foreach (QQmlAbstractProfilerAdapter *profiler, m_globalProfilers) {
+ for (QQmlAbstractProfilerAdapter *profiler : qAsConst(m_globalProfilers)) {
if (!profiler->isRunning())
profiler->startProfiling(features);
}
@@ -294,7 +305,7 @@ void QQmlProfilerServiceImpl::stopProfiling(QJSEngine *engine)
if (stopping.isEmpty())
return;
- foreach (QQmlAbstractProfilerAdapter *profiler, m_globalProfilers) {
+ for (QQmlAbstractProfilerAdapter *profiler : qAsConst(m_globalProfilers)) {
if (!profiler->isRunning())
continue;
m_startTimes.insert(-1, profiler);
@@ -308,10 +319,10 @@ void QQmlProfilerServiceImpl::stopProfiling(QJSEngine *engine)
emit stopFlushTimer();
m_waitingForStop = true;
- foreach (QQmlAbstractProfilerAdapter *profiler, reporting)
+ for (QQmlAbstractProfilerAdapter *profiler : qAsConst(reporting))
profiler->reportData(m_useMessageTypes);
- foreach (QQmlAbstractProfilerAdapter *profiler, stopping)
+ for (QQmlAbstractProfilerAdapter *profiler : qAsConst(stopping))
profiler->stopProfiling();
}
@@ -327,7 +338,7 @@ void QQmlProfilerServiceImpl::sendMessages()
traceEnd << m_timer.nsecsElapsed() << (int)Event << (int)EndTrace;
QSet<QJSEngine *> seen;
- foreach (QQmlAbstractProfilerAdapter *profiler, m_startTimes) {
+ for (QQmlAbstractProfilerAdapter *profiler : qAsConst(m_startTimes)) {
for (QMultiHash<QJSEngine *, QQmlAbstractProfilerAdapter *>::iterator i(m_engineProfilers.begin());
i != m_engineProfilers.end(); ++i) {
if (i.value() == profiler && !seen.contains(i.key())) {
@@ -367,7 +378,7 @@ void QQmlProfilerServiceImpl::sendMessages()
emit messagesToClient(name(), messages);
// Restart flushing if any profilers are still running
- foreach (const QQmlAbstractProfilerAdapter *profiler, m_engineProfilers) {
+ for (const QQmlAbstractProfilerAdapter *profiler : qAsConst(m_engineProfilers)) {
if (profiler->isRunning()) {
emit startFlushTimer();
break;
@@ -438,21 +449,21 @@ void QQmlProfilerServiceImpl::flush()
QMutexLocker lock(&m_configMutex);
QList<QQmlAbstractProfilerAdapter *> reporting;
- foreach (QQmlAbstractProfilerAdapter *profiler, m_engineProfilers) {
+ for (QQmlAbstractProfilerAdapter *profiler : qAsConst(m_engineProfilers)) {
if (profiler->isRunning()) {
m_startTimes.insert(-1, profiler);
reporting.append(profiler);
}
}
- foreach (QQmlAbstractProfilerAdapter *profiler, m_globalProfilers) {
+ for (QQmlAbstractProfilerAdapter *profiler : qAsConst(m_globalProfilers)) {
if (profiler->isRunning()) {
m_startTimes.insert(-1, profiler);
reporting.append(profiler);
}
}
- foreach (QQmlAbstractProfilerAdapter *profiler, reporting)
+ for (QQmlAbstractProfilerAdapter *profiler : qAsConst(reporting))
profiler->reportData(m_useMessageTypes);
}
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp
index eee1dd7eae..eae5e0a795 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp
+++ b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp
@@ -76,7 +76,7 @@ qint64 QV4ProfilerAdapter::appendMemoryEvents(qint64 until, QList<QByteArray> &m
while (memoryData.length() > m_memoryPos && memoryData[m_memoryPos].timestamp <= until) {
const QV4::Profiling::MemoryAllocationProperties &props = memoryData[m_memoryPos];
- d << props.timestamp << MemoryAllocation << props.type << props.size;
+ d << props.timestamp << int(MemoryAllocation) << int(props.type) << props.size;
++m_memoryPos;
messages.append(d.squeezedData());
d.clear();
@@ -120,7 +120,7 @@ qint64 QV4ProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &message
return finalizeMessages(until, messages, m_stack.top(), d);
appendMemoryEvents(m_stack.top(), messages, d);
- d << m_stack.pop() << RangeEnd << Javascript;
+ d << m_stack.pop() << int(RangeEnd) << int(Javascript);
messages.append(d.squeezedData());
d.clear();
}
@@ -134,19 +134,19 @@ qint64 QV4ProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &message
appendMemoryEvents(props.start, messages, d);
auto location = m_functionLocations.find(props.id);
- d << props.start << RangeStart << Javascript;
+ d << props.start << int(RangeStart) << int(Javascript);
if (trackLocations)
d << static_cast<qint64>(props.id);
if (location != m_functionLocations.end()) {
messages.push_back(d.squeezedData());
d.clear();
- d << props.start << RangeLocation << Javascript << location->file << location->line
+ d << props.start << int(RangeLocation) << int(Javascript) << location->file << location->line
<< location->column;
if (trackLocations)
d << static_cast<qint64>(props.id);
messages.push_back(d.squeezedData());
d.clear();
- d << props.start << RangeData << Javascript << location->name;
+ d << props.start << int(RangeData) << int(Javascript) << location->name;
if (trackLocations) {
d << static_cast<qint64>(props.id);
diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
index 96b3455790..f449989598 100644
--- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
+++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
@@ -589,12 +589,12 @@ void QQmlDebugServerImpl::addEngine(QJSEngine *engine)
QMutexLocker locker(&m_helloMutex);
Q_ASSERT(!m_engineConditions.contains(engine));
- foreach (QQmlDebugService *service, m_plugins)
+ for (QQmlDebugService *service : qAsConst(m_plugins))
service->engineAboutToBeAdded(engine);
m_engineConditions[engine].waitForServices(&m_helloMutex, m_plugins.count());
- foreach (QQmlDebugService *service, m_plugins)
+ for (QQmlDebugService *service : qAsConst(m_plugins))
service->engineAdded(engine);
}
@@ -606,12 +606,12 @@ void QQmlDebugServerImpl::removeEngine(QJSEngine *engine)
QMutexLocker locker(&m_helloMutex);
Q_ASSERT(m_engineConditions.contains(engine));
- foreach (QQmlDebugService *service, m_plugins)
+ for (QQmlDebugService *service : qAsConst(m_plugins))
service->engineAboutToBeRemoved(engine);
m_engineConditions[engine].waitForServices(&m_helloMutex, m_plugins.count());
- foreach (QQmlDebugService *service, m_plugins)
+ for (QQmlDebugService *service : qAsConst(m_plugins))
service->engineRemoved(engine);
m_engineConditions.remove(engine);
@@ -703,11 +703,11 @@ void QQmlDebugServerImpl::sendMessages(const QString &name, const QList<QByteArr
if (m_clientSupportsMultiPackets) {
QQmlDebugPacket out;
out << name;
- foreach (const QByteArray &message, messages)
+ for (const QByteArray &message : messages)
out << message;
m_protocol->send(out.data());
} else {
- foreach (const QByteArray &message, messages)
+ for (const QByteArray &message : messages)
doSendMessage(name, message);
}
m_connection->flush();
diff --git a/src/plugins/qmltooling/qmltooling.pro b/src/plugins/qmltooling/qmltooling.pro
index 7682e7b075..907fbe9273 100644
--- a/src/plugins/qmltooling/qmltooling.pro
+++ b/src/plugins/qmltooling/qmltooling.pro
@@ -1,32 +1,35 @@
TEMPLATE = subdirs
+QT_FOR_CONFIG += qml
-!no_network {
- # Utilities
- SUBDIRS += \
- packetprotocol
+# Utilities
+SUBDIRS += \
+ packetprotocol
+
+# Connectors
+SUBDIRS += \
+ qmldbg_native \
+ qmldbg_server
- # Connectors
+qtConfig(qml-network) {
SUBDIRS += \
- qmldbg_native \
- qmldbg_server \
qmldbg_local \
qmldbg_tcp
+}
- # Services
- SUBDIRS += \
- qmldbg_debugger \
- qmldbg_profiler
+# Services
+SUBDIRS += \
+ qmldbg_debugger \
+ qmldbg_profiler
- qmldbg_server.depends = packetprotocol
- qmldbg_native.depends = packetprotocol
- qmldbg_debugger.depends = packetprotocol
- qmldbg_profiler.depends = packetprotocol
+qmldbg_server.depends = packetprotocol
+qmldbg_native.depends = packetprotocol
+qmldbg_debugger.depends = packetprotocol
+qmldbg_profiler.depends = packetprotocol
- qtHaveModule(quick) {
- SUBDIRS += \
- qmldbg_inspector \
- qmldbg_quickprofiler
- qmldbg_inspector.depends = packetprotocol
- qmldbg_quickprofiler.depends = packetprotocol
- }
+qtHaveModule(quick) {
+ SUBDIRS += \
+ qmldbg_inspector \
+ qmldbg_quickprofiler
+ qmldbg_inspector.depends = packetprotocol
+ qmldbg_quickprofiler.depends = packetprotocol
}
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials.cpp
index fc3ea4e22e..3351486bc6 100644
--- a/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials.cpp
+++ b/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials.cpp
@@ -679,7 +679,7 @@ void QSGD3D12TextMaterial::populate(const QPointF &p,
float glyphCacheInverseScaleX = 1.0 / glyphCacheScaleX;
float glyphCacheInverseScaleY = 1.0 / glyphCacheScaleY;
- Q_ASSERT(geometry->indexType() == QSGGeometry::TypeUnsignedShort);
+ Q_ASSERT(geometry->indexType() == QSGGeometry::UnsignedShortType);
geometry->allocate(glyphIndexes.size() * 4, glyphIndexes.size() * 6);
QVector4D *vp = reinterpret_cast<QVector4D *>(geometry->vertexDataAsTexturedPoint2D());
Q_ASSERT(geometry->sizeOfVertex() == sizeof(QVector4D));
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp
index 2644c693ce..a318ce23f7 100644
--- a/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp
+++ b/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp
@@ -585,31 +585,31 @@ QSGD3D12Format QSGD3D12Engine::toDXGIFormat(QSGGeometry::Type sgtype, int tupleS
FmtFloat4 };
switch (sgtype) {
- case QSGGeometry::TypeUnsignedByte:
+ case QSGGeometry::UnsignedByteType:
format = formatMap_ub[tupleSize];
if (size)
*size = tupleSize;
break;
- case QSGGeometry::TypeFloat:
+ case QSGGeometry::FloatType:
format = formatMap_f[tupleSize];
if (size)
*size = sizeof(float) * tupleSize;
break;
- case QSGGeometry::TypeUnsignedShort:
+ case QSGGeometry::UnsignedShortType:
format = FmtUnsignedShort;
if (size)
*size = sizeof(ushort) * tupleSize;
break;
- case QSGGeometry::TypeUnsignedInt:
+ case QSGGeometry::UnsignedIntType:
format = FmtUnsignedInt;
if (size)
*size = sizeof(uint) * tupleSize;
break;
- case QSGGeometry::TypeByte:
- case QSGGeometry::TypeInt:
- case QSGGeometry::TypeShort:
+ case QSGGeometry::ByteType:
+ case QSGGeometry::IntType:
+ case QSGGeometry::ShortType:
qWarning("no mapping for GL type 0x%x", sgtype);
break;
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12renderer.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12renderer.cpp
index ce633ae996..c0f111ee83 100644
--- a/src/plugins/scenegraph/d3d12/qsgd3d12renderer.cpp
+++ b/src/plugins/scenegraph/d3d12/qsgd3d12renderer.cpp
@@ -561,10 +561,11 @@ void QSGD3D12Renderer::setInputLayout(const QSGGeometry *g, QSGD3D12PipelineStat
QSGD3D12InputElement &ie(pipelineState->inputElements[i]);
static const char *semanticNames[] = { "UNKNOWN", "POSITION", "COLOR", "TEXCOORD", "TEXCOORD", "TEXCOORD" };
static const int semanticIndices[] = { 0, 0, 0, 0, 1, 2 };
- Q_ASSERT(attrs[i].semantic >= 1 && attrs[i].semantic < _countof(semanticNames));
+ const int semantic = attrs[i].attributeType;
+ Q_ASSERT(semantic >= 1 && semantic < _countof(semanticNames));
const int tupleSize = attrs[i].tupleSize;
- ie.semanticName = semanticNames[attrs[i].semantic];
- ie.semanticIndex = semanticIndices[attrs[i].semantic];
+ ie.semanticName = semanticNames[semantic];
+ ie.semanticIndex = semanticIndices[semantic];
ie.offset = offset;
int bytesPerTuple = 0;
ie.format = QSGD3D12Engine::toDXGIFormat(QSGGeometry::Type(attrs[i].type), tupleSize, &bytesPerTuple);
@@ -718,7 +719,7 @@ void QSGD3D12Renderer::renderStencilClip(const QSGClipNode *clip, int elementInd
const QSGGeometry *g = clip->geometry();
Q_ASSERT(g->attributeCount() == 1);
Q_ASSERT(g->attributes()[0].tupleSize == 2);
- Q_ASSERT(g->attributes()[0].type == QSGGeometry::TypeFloat);
+ Q_ASSERT(g->attributes()[0].type == QSGGeometry::FloatType);
setInputLayout(g, &sps);
m_engine->finalizePipeline(sps);
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12spritenode.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12spritenode.cpp
index bad222dbaa..807fbcdcec 100644
--- a/src/plugins/scenegraph/d3d12/qsgd3d12spritenode.cpp
+++ b/src/plugins/scenegraph/d3d12/qsgd3d12spritenode.cpp
@@ -166,8 +166,8 @@ QSGD3D12Material::UpdateResults QSGD3D12SpriteMaterial::updatePipeline(const QSG
}
static QSGGeometry::Attribute Sprite_Attributes[] = {
- QSGGeometry::Attribute::createWithSemantic(0, 2, QSGGeometry::TypeFloat, QSGGeometry::Attribute::POSITION),
- QSGGeometry::Attribute::createWithSemantic(1, 2, QSGGeometry::TypeFloat, QSGGeometry::Attribute::TEXCOORD),
+ QSGGeometry::Attribute::createWithAttributeType(0, 2, QSGGeometry::FloatType, QSGGeometry::PositionAttribute),
+ QSGGeometry::Attribute::createWithAttributeType(1, 2, QSGGeometry::FloatType, QSGGeometry::TexCoordAttribute),
};
static QSGGeometry::AttributeSet Sprite_AttributeSet = { 2, 4 * sizeof(float), Sprite_Attributes };
diff --git a/src/plugins/scenegraph/scenegraph.pro b/src/plugins/scenegraph/scenegraph.pro
index 2cf05165c4..a90e8d4814 100644
--- a/src/plugins/scenegraph/scenegraph.pro
+++ b/src/plugins/scenegraph/scenegraph.pro
@@ -1,2 +1,3 @@
TEMPLATE = subdirs
-config_d3d12: SUBDIRS += d3d12
+QT_FOR_CONFIG += quick
+qtConfig(d3d12): SUBDIRS += d3d12
diff --git a/src/qml/animations/qanimationgroupjob_p.h b/src/qml/animations/qanimationgroupjob_p.h
index 9bcd63127a..26965c0264 100644
--- a/src/qml/animations/qanimationgroupjob_p.h
+++ b/src/qml/animations/qanimationgroupjob_p.h
@@ -75,7 +75,7 @@ public:
//called by QAbstractAnimationJob
virtual void uncontrolledAnimationFinished(QAbstractAnimationJob *animation);
protected:
- void topLevelAnimationLoopChanged();
+ void topLevelAnimationLoopChanged() override;
virtual void animationInserted(QAbstractAnimationJob*) { }
virtual void animationRemoved(QAbstractAnimationJob*, QAbstractAnimationJob*, QAbstractAnimationJob*);
diff --git a/src/qml/animations/qparallelanimationgroupjob_p.h b/src/qml/animations/qparallelanimationgroupjob_p.h
index 3e914c3e76..358b95ce53 100644
--- a/src/qml/animations/qparallelanimationgroupjob_p.h
+++ b/src/qml/animations/qparallelanimationgroupjob_p.h
@@ -62,14 +62,14 @@ public:
QParallelAnimationGroupJob();
~QParallelAnimationGroupJob();
- int duration() const;
+ int duration() const override;
protected:
- void updateCurrentTime(int currentTime);
- void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState);
- void updateDirection(QAbstractAnimationJob::Direction direction);
- void uncontrolledAnimationFinished(QAbstractAnimationJob *animation);
- void debugAnimation(QDebug d) const;
+ void updateCurrentTime(int currentTime) override;
+ void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override;
+ void updateDirection(QAbstractAnimationJob::Direction direction) override;
+ void uncontrolledAnimationFinished(QAbstractAnimationJob *animation) override;
+ void debugAnimation(QDebug d) const override;
private:
bool shouldAnimationStart(QAbstractAnimationJob *animation, bool startIfAtEnd) const;
diff --git a/src/qml/compiler/compiler.pri b/src/qml/compiler/compiler.pri
index e49f5c40a5..1de5dfa6fa 100644
--- a/src/qml/compiler/compiler.pri
+++ b/src/qml/compiler/compiler.pri
@@ -25,8 +25,6 @@ SOURCES += \
HEADERS += \
$$PWD/qqmltypecompiler_p.h \
- $$PWD/qv4isel_moth_p.h \
- $$PWD/qv4instr_moth_p.h \
$$PWD/qqmlpropertycachecreator_p.h \
$$PWD/qqmlpropertyvalidator_p.h \
$$PWD/qv4compilationunitmapper_p.h
@@ -34,8 +32,6 @@ HEADERS += \
SOURCES += \
$$PWD/qqmltypecompiler.cpp \
- $$PWD/qv4instr_moth.cpp \
- $$PWD/qv4isel_moth.cpp \
$$PWD/qqmlpropertycachecreator.cpp \
$$PWD/qqmlpropertyvalidator.cpp \
$$PWD/qv4compilationunitmapper.cpp
@@ -43,4 +39,15 @@ SOURCES += \
unix: SOURCES += $$PWD/qv4compilationunitmapper_unix.cpp
else: SOURCES += $$PWD/qv4compilationunitmapper_win.cpp
+qtConfig(qml-interpreter) {
+ HEADERS += \
+ $$PWD/qv4instr_moth_p.h \
+ $$PWD/qv4isel_moth_p.h
+ SOURCES += \
+ $$PWD/qv4instr_moth.cpp \
+ $$PWD/qv4isel_moth.cpp
+}
+
+
+qtConfig(private_tests): LIBS_PRIVATE += $$QMAKE_LIBS_DYNLOAD
}
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index 31b964897f..e66e8ccbff 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -362,10 +362,11 @@ bool IRBuilder::generateFromQml(const QString &code, const QString &url, Documen
QQmlJS::Parser parser(&output->jsParserEngine);
- if (! parser.parse() || !parser.diagnosticMessages().isEmpty()) {
-
+ const bool parseResult = parser.parse();
+ const auto diagnosticMessages = parser.diagnosticMessages();
+ if (!parseResult || !diagnosticMessages.isEmpty()) {
// Extract errors from the parser
- foreach (const QQmlJS::DiagnosticMessage &m, parser.diagnosticMessages()) {
+ for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) {
if (m.isWarning()) {
qWarning("%s:%d : %s", qPrintable(url), m.loc.startLine, qPrintable(m.message));
@@ -1018,7 +1019,8 @@ void IRBuilder::setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST
CompiledFunctionOrExpression *expr = New<CompiledFunctionOrExpression>();
expr->node = statement;
- expr->nameIndex = registerString(QStringLiteral("expression for ") + stringAt(binding->propertyNameIndex));
+ expr->nameIndex = registerString(QLatin1String("expression for ")
+ + stringAt(binding->propertyNameIndex));
expr->disableAcceleratedLookups = false;
const int index = bindingsTarget()->functionsAndExpressions->append(expr);
binding->value.compiledScriptIndex = index;
@@ -1246,7 +1248,7 @@ bool IRBuilder::resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, O
// If it's a namespace, prepend the qualifier and we'll resolve it later to the correct type.
QString currentName = qualifiedIdElement->name.toString();
if (qualifiedIdElement->next) {
- foreach (const QV4::CompiledData::Import* import, _imports)
+ for (const QV4::CompiledData::Import* import : qAsConst(_imports))
if (import->qualifierIndex != emptyStringIndex
&& stringAt(import->qualifierIndex) == currentName) {
qualifiedIdElement = qualifiedIdElement->next;
@@ -1371,7 +1373,7 @@ QV4::CompiledData::Unit *QmlUnitGenerator::generate(Document &output, QQmlEngine
QHash<const Object*, quint32> objectOffsets;
int objectsSize = 0;
- foreach (Object *o, output.objects) {
+ for (Object *o : qAsConst(output.objects)) {
objectOffsets.insert(o, unitSize + importSize + objectOffsetTableSize + objectsSize);
objectsSize += QV4::CompiledData::Object::calculateSizeExcludingSignals(o->functionCount(), o->propertyCount(), o->aliasCount(), o->signalCount(), o->bindingCount(), o->namedObjectsInComponent.count);
@@ -1417,7 +1419,7 @@ QV4::CompiledData::Unit *QmlUnitGenerator::generate(Document &output, QQmlEngine
// write imports
char *importPtr = data + qmlUnit->offsetToImports;
- foreach (const QV4::CompiledData::Import *imp, output.imports) {
+ for (const QV4::CompiledData::Import *imp : qAsConst(output.imports)) {
QV4::CompiledData::Import *importToWrite = reinterpret_cast<QV4::CompiledData::Import*>(importPtr);
*importToWrite = *imp;
importPtr += sizeof(QV4::CompiledData::Import);
@@ -1522,7 +1524,7 @@ QV4::CompiledData::Unit *QmlUnitGenerator::generate(Document &output, QQmlEngine
}
// enable flag if we encountered pragma Singleton
- foreach (Pragma *p, output.pragmas) {
+ for (Pragma *p : qAsConst(output.pragmas)) {
if (p->type == Pragma::PragmaSingleton) {
qmlUnit->flags |= QV4::CompiledData::Unit::IsSingleton;
break;
@@ -1531,6 +1533,8 @@ QV4::CompiledData::Unit *QmlUnitGenerator::generate(Document &output, QQmlEngine
output.jsGenerator.stringTable.serialize(qmlUnit);
+ qmlUnit->generateChecksum();
+
return qmlUnit;
}
@@ -1586,7 +1590,7 @@ QVector<int> JSCodeGen::generateJSCodeForFunctionsAndBindings(const QList<Compil
ScanFunctions scan(this, sourceCode, GlobalCode);
scan.enterEnvironment(0, QmlBinding);
scan.enterQmlScope(qmlRoot, QStringLiteral("context scope"));
- foreach (const CompiledFunctionOrExpression &f, functions) {
+ for (const CompiledFunctionOrExpression &f : functions) {
Q_ASSERT(f.node != qmlRoot);
QQmlJS::AST::FunctionDeclaration *function = QQmlJS::AST::cast<QQmlJS::AST::FunctionDeclaration*>(f.node);
@@ -1921,7 +1925,7 @@ QV4::IR::Expr *JSCodeGen::fallbackNameLookup(const QString &name, int line, int
// with the correct QML context.
// Look for IDs first.
- foreach (const IdMapping &mapping, _idObjects)
+ for (const IdMapping &mapping : qAsConst(_idObjects))
if (name == mapping.name) {
if (_function->isQmlBinding)
_function->idObjectDependencies.insert(mapping.idIndex);
diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h
index cc16dc2104..95756845c3 100644
--- a/src/qml/compiler/qqmlirbuilder_p.h
+++ b/src/qml/compiler/qqmlirbuilder_p.h
@@ -453,9 +453,9 @@ struct Q_QML_PRIVATE_EXPORT ScriptDirectivesCollector : public QQmlJS::Directive
QList<const QV4::CompiledData::Import *> imports;
bool hasPragmaLibrary;
- virtual void pragmaLibrary();
- virtual void importFile(const QString &jsfile, const QString &module, int lineNumber, int column);
- virtual void importModule(const QString &uri, const QString &version, const QString &module, int lineNumber, int column);
+ void pragmaLibrary() override;
+ void importFile(const QString &jsfile, const QString &module, int lineNumber, int column) override;
+ void importModule(const QString &uri, const QString &version, const QString &module, int lineNumber, int column) override;
};
struct Q_QML_PRIVATE_EXPORT IRBuilder : public QQmlJS::AST::Visitor
@@ -470,21 +470,21 @@ public:
using QQmlJS::AST::Visitor::visit;
using QQmlJS::AST::Visitor::endVisit;
- virtual bool visit(QQmlJS::AST::UiArrayMemberList *ast);
- virtual bool visit(QQmlJS::AST::UiImport *ast);
- virtual bool visit(QQmlJS::AST::UiPragma *ast);
- virtual bool visit(QQmlJS::AST::UiHeaderItemList *ast);
- virtual bool visit(QQmlJS::AST::UiObjectInitializer *ast);
- virtual bool visit(QQmlJS::AST::UiObjectMemberList *ast);
- virtual bool visit(QQmlJS::AST::UiParameterList *ast);
- virtual bool visit(QQmlJS::AST::UiProgram *);
- virtual bool visit(QQmlJS::AST::UiQualifiedId *ast);
- virtual bool visit(QQmlJS::AST::UiArrayBinding *ast);
- virtual bool visit(QQmlJS::AST::UiObjectBinding *ast);
- virtual bool visit(QQmlJS::AST::UiObjectDefinition *ast);
- virtual bool visit(QQmlJS::AST::UiPublicMember *ast);
- virtual bool visit(QQmlJS::AST::UiScriptBinding *ast);
- virtual bool visit(QQmlJS::AST::UiSourceElement *ast);
+ bool visit(QQmlJS::AST::UiArrayMemberList *ast) override;
+ bool visit(QQmlJS::AST::UiImport *ast) override;
+ bool visit(QQmlJS::AST::UiPragma *ast) override;
+ bool visit(QQmlJS::AST::UiHeaderItemList *ast) override;
+ bool visit(QQmlJS::AST::UiObjectInitializer *ast) override;
+ bool visit(QQmlJS::AST::UiObjectMemberList *ast) override;
+ bool visit(QQmlJS::AST::UiParameterList *ast) override;
+ bool visit(QQmlJS::AST::UiProgram *) override;
+ bool visit(QQmlJS::AST::UiQualifiedId *ast) override;
+ bool visit(QQmlJS::AST::UiArrayBinding *ast) override;
+ bool visit(QQmlJS::AST::UiObjectBinding *ast) override;
+ bool visit(QQmlJS::AST::UiObjectDefinition *ast) override;
+ bool visit(QQmlJS::AST::UiPublicMember *ast) override;
+ bool visit(QQmlJS::AST::UiScriptBinding *ast) override;
+ bool visit(QQmlJS::AST::UiSourceElement *ast) override;
void accept(QQmlJS::AST::Node *node);
@@ -602,8 +602,8 @@ struct Q_QML_PRIVATE_EXPORT JSCodeGen : public QQmlJS::Codegen
QVector<int> generateJSCodeForFunctionsAndBindings(const QList<CompiledFunctionOrExpression> &functions);
protected:
- virtual void beginFunctionBodyHook();
- virtual QV4::IR::Expr *fallbackNameLookup(const QString &name, int line, int col);
+ void beginFunctionBodyHook() override;
+ QV4::IR::Expr *fallbackNameLookup(const QString &name, int line, int col) override;
private:
QQmlPropertyData *lookupQmlCompliantProperty(QQmlPropertyCache *cache, const QString &name, bool *propertyExistsButForceNameLookup = 0);
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp
index 2308e66609..5e05485b93 100644
--- a/src/qml/compiler/qqmltypecompiler.cpp
+++ b/src/qml/compiler/qqmltypecompiler.cpp
@@ -471,7 +471,7 @@ bool SignalHandlerConverter::convertSignalHandlerExpressionsToFunctionDeclaratio
QQmlJS::MemoryPool *pool = compiler->memoryPool();
QQmlJS::AST::FormalParameterList *paramList = 0;
- foreach (const QString &param, parameters) {
+ for (const QString &param : qAsConst(parameters)) {
QStringRef paramNameRef = compiler->newStringRef(param);
if (paramList)
@@ -1348,9 +1348,9 @@ bool QQmlJSCodeGenerator::compileJavaScriptCodeInObjectsRecursively(int objectIn
functionsToCompile << *foe;
}
const QVector<int> runtimeFunctionIndices = v4CodeGen->generateJSCodeForFunctionsAndBindings(functionsToCompile);
- QList<QQmlError> jsErrors = v4CodeGen->qmlErrors();
+ const QList<QQmlError> jsErrors = v4CodeGen->qmlErrors();
if (!jsErrors.isEmpty()) {
- foreach (const QQmlError &e, jsErrors)
+ for (const QQmlError &e : jsErrors)
compiler->recordError(e);
return false;
}
@@ -1733,7 +1733,7 @@ void QQmlIRFunctionCleanser::clean()
module->functions = newFunctions;
- foreach (QV4::IR::Function *function, module->functions) {
+ for (QV4::IR::Function *function : qAsConst(module->functions)) {
for (QV4::IR::BasicBlock *block : function->basicBlocks()) {
for (QV4::IR::Stmt *s : block->statements()) {
visit(s);
@@ -1741,7 +1741,7 @@ void QQmlIRFunctionCleanser::clean()
}
}
- foreach (QmlIR::Object *obj, *compiler->qmlObjects()) {
+ for (QmlIR::Object *obj : qAsConst(*compiler->qmlObjects())) {
for (int i = 0; i < obj->runtimeFunctionIndices.count; ++i)
obj->runtimeFunctionIndices[i] = newFunctionIndices[obj->runtimeFunctionIndices.at(i)];
}
diff --git a/src/qml/compiler/qqmltypecompiler_p.h b/src/qml/compiler/qqmltypecompiler_p.h
index 6ad6ad8557..de6abb4ced 100644
--- a/src/qml/compiler/qqmltypecompiler_p.h
+++ b/src/qml/compiler/qqmltypecompiler_p.h
@@ -285,7 +285,8 @@ protected:
// indices of the objects that are actually Component {}
QVector<quint32> componentRoots;
- QHash<int, int> _idToObjectIndex;
+ // Deliberate choice of map over hash here to ensure stable generated output.
+ QMap<int, int> _idToObjectIndex;
QVector<int> _objectsWithAliases;
QV4::CompiledData::ResolvedTypeReferenceMap *resolvedTypes;
diff --git a/src/qml/compiler/qv4codegen_p.h b/src/qml/compiler/qv4codegen_p.h
index 59199183bd..742ee79648 100644
--- a/src/qml/compiler/qv4codegen_p.h
+++ b/src/qml/compiler/qv4codegen_p.h
@@ -331,103 +331,103 @@ protected:
virtual void beginFunctionBodyHook() {}
// nodes
- virtual bool visit(AST::ArgumentList *ast);
- virtual bool visit(AST::CaseBlock *ast);
- virtual bool visit(AST::CaseClause *ast);
- virtual bool visit(AST::CaseClauses *ast);
- virtual bool visit(AST::Catch *ast);
- virtual bool visit(AST::DefaultClause *ast);
- virtual bool visit(AST::ElementList *ast);
- virtual bool visit(AST::Elision *ast);
- virtual bool visit(AST::Finally *ast);
- virtual bool visit(AST::FormalParameterList *ast);
- virtual bool visit(AST::FunctionBody *ast);
- virtual bool visit(AST::Program *ast);
- virtual bool visit(AST::PropertyNameAndValue *ast);
- virtual bool visit(AST::PropertyAssignmentList *ast);
- virtual bool visit(AST::PropertyGetterSetter *ast);
- virtual bool visit(AST::SourceElements *ast);
- virtual bool visit(AST::StatementList *ast);
- virtual bool visit(AST::UiArrayMemberList *ast);
- virtual bool visit(AST::UiImport *ast);
- virtual bool visit(AST::UiHeaderItemList *ast);
- virtual bool visit(AST::UiPragma *ast);
- virtual bool visit(AST::UiObjectInitializer *ast);
- virtual bool visit(AST::UiObjectMemberList *ast);
- virtual bool visit(AST::UiParameterList *ast);
- virtual bool visit(AST::UiProgram *ast);
- virtual bool visit(AST::UiQualifiedId *ast);
- virtual bool visit(AST::UiQualifiedPragmaId *ast);
- virtual bool visit(AST::VariableDeclaration *ast);
- virtual bool visit(AST::VariableDeclarationList *ast);
+ bool visit(AST::ArgumentList *ast) override;
+ bool visit(AST::CaseBlock *ast) override;
+ bool visit(AST::CaseClause *ast) override;
+ bool visit(AST::CaseClauses *ast) override;
+ bool visit(AST::Catch *ast) override;
+ bool visit(AST::DefaultClause *ast) override;
+ bool visit(AST::ElementList *ast) override;
+ bool visit(AST::Elision *ast) override;
+ bool visit(AST::Finally *ast) override;
+ bool visit(AST::FormalParameterList *ast) override;
+ bool visit(AST::FunctionBody *ast) override;
+ bool visit(AST::Program *ast) override;
+ bool visit(AST::PropertyNameAndValue *ast) override;
+ bool visit(AST::PropertyAssignmentList *ast) override;
+ bool visit(AST::PropertyGetterSetter *ast) override;
+ bool visit(AST::SourceElements *ast) override;
+ bool visit(AST::StatementList *ast) override;
+ bool visit(AST::UiArrayMemberList *ast) override;
+ bool visit(AST::UiImport *ast) override;
+ bool visit(AST::UiHeaderItemList *ast) override;
+ bool visit(AST::UiPragma *ast) override;
+ bool visit(AST::UiObjectInitializer *ast) override;
+ bool visit(AST::UiObjectMemberList *ast) override;
+ bool visit(AST::UiParameterList *ast) override;
+ bool visit(AST::UiProgram *ast) override;
+ bool visit(AST::UiQualifiedId *ast) override;
+ bool visit(AST::UiQualifiedPragmaId *ast) override;
+ bool visit(AST::VariableDeclaration *ast) override;
+ bool visit(AST::VariableDeclarationList *ast) override;
// expressions
- virtual bool visit(AST::Expression *ast);
- virtual bool visit(AST::ArrayLiteral *ast);
- virtual bool visit(AST::ArrayMemberExpression *ast);
- virtual bool visit(AST::BinaryExpression *ast);
- virtual bool visit(AST::CallExpression *ast);
- virtual bool visit(AST::ConditionalExpression *ast);
- virtual bool visit(AST::DeleteExpression *ast);
- virtual bool visit(AST::FalseLiteral *ast);
- virtual bool visit(AST::FieldMemberExpression *ast);
- virtual bool visit(AST::FunctionExpression *ast);
- virtual bool visit(AST::IdentifierExpression *ast);
- virtual bool visit(AST::NestedExpression *ast);
- virtual bool visit(AST::NewExpression *ast);
- virtual bool visit(AST::NewMemberExpression *ast);
- virtual bool visit(AST::NotExpression *ast);
- virtual bool visit(AST::NullExpression *ast);
- virtual bool visit(AST::NumericLiteral *ast);
- virtual bool visit(AST::ObjectLiteral *ast);
- virtual bool visit(AST::PostDecrementExpression *ast);
- virtual bool visit(AST::PostIncrementExpression *ast);
- virtual bool visit(AST::PreDecrementExpression *ast);
- virtual bool visit(AST::PreIncrementExpression *ast);
- virtual bool visit(AST::RegExpLiteral *ast);
- virtual bool visit(AST::StringLiteral *ast);
- virtual bool visit(AST::ThisExpression *ast);
- virtual bool visit(AST::TildeExpression *ast);
- virtual bool visit(AST::TrueLiteral *ast);
- virtual bool visit(AST::TypeOfExpression *ast);
- virtual bool visit(AST::UnaryMinusExpression *ast);
- virtual bool visit(AST::UnaryPlusExpression *ast);
- virtual bool visit(AST::VoidExpression *ast);
- virtual bool visit(AST::FunctionDeclaration *ast);
+ bool visit(AST::Expression *ast) override;
+ bool visit(AST::ArrayLiteral *ast) override;
+ bool visit(AST::ArrayMemberExpression *ast) override;
+ bool visit(AST::BinaryExpression *ast) override;
+ bool visit(AST::CallExpression *ast) override;
+ bool visit(AST::ConditionalExpression *ast) override;
+ bool visit(AST::DeleteExpression *ast) override;
+ bool visit(AST::FalseLiteral *ast) override;
+ bool visit(AST::FieldMemberExpression *ast) override;
+ bool visit(AST::FunctionExpression *ast) override;
+ bool visit(AST::IdentifierExpression *ast) override;
+ bool visit(AST::NestedExpression *ast) override;
+ bool visit(AST::NewExpression *ast) override;
+ bool visit(AST::NewMemberExpression *ast) override;
+ bool visit(AST::NotExpression *ast) override;
+ bool visit(AST::NullExpression *ast) override;
+ bool visit(AST::NumericLiteral *ast) override;
+ bool visit(AST::ObjectLiteral *ast) override;
+ bool visit(AST::PostDecrementExpression *ast) override;
+ bool visit(AST::PostIncrementExpression *ast) override;
+ bool visit(AST::PreDecrementExpression *ast) override;
+ bool visit(AST::PreIncrementExpression *ast) override;
+ bool visit(AST::RegExpLiteral *ast) override;
+ bool visit(AST::StringLiteral *ast) override;
+ bool visit(AST::ThisExpression *ast) override;
+ bool visit(AST::TildeExpression *ast) override;
+ bool visit(AST::TrueLiteral *ast) override;
+ bool visit(AST::TypeOfExpression *ast) override;
+ bool visit(AST::UnaryMinusExpression *ast) override;
+ bool visit(AST::UnaryPlusExpression *ast) override;
+ bool visit(AST::VoidExpression *ast) override;
+ bool visit(AST::FunctionDeclaration *ast) override;
// source elements
- virtual bool visit(AST::FunctionSourceElement *ast);
- virtual bool visit(AST::StatementSourceElement *ast);
+ bool visit(AST::FunctionSourceElement *ast) override;
+ bool visit(AST::StatementSourceElement *ast) override;
// statements
- virtual bool visit(AST::Block *ast);
- virtual bool visit(AST::BreakStatement *ast);
- virtual bool visit(AST::ContinueStatement *ast);
- virtual bool visit(AST::DebuggerStatement *ast);
- virtual bool visit(AST::DoWhileStatement *ast);
- virtual bool visit(AST::EmptyStatement *ast);
- virtual bool visit(AST::ExpressionStatement *ast);
- virtual bool visit(AST::ForEachStatement *ast);
- virtual bool visit(AST::ForStatement *ast);
- virtual bool visit(AST::IfStatement *ast);
- virtual bool visit(AST::LabelledStatement *ast);
- virtual bool visit(AST::LocalForEachStatement *ast);
- virtual bool visit(AST::LocalForStatement *ast);
- virtual bool visit(AST::ReturnStatement *ast);
- virtual bool visit(AST::SwitchStatement *ast);
- virtual bool visit(AST::ThrowStatement *ast);
- virtual bool visit(AST::TryStatement *ast);
- virtual bool visit(AST::VariableStatement *ast);
- virtual bool visit(AST::WhileStatement *ast);
- virtual bool visit(AST::WithStatement *ast);
+ bool visit(AST::Block *ast) override;
+ bool visit(AST::BreakStatement *ast) override;
+ bool visit(AST::ContinueStatement *ast) override;
+ bool visit(AST::DebuggerStatement *ast) override;
+ bool visit(AST::DoWhileStatement *ast) override;
+ bool visit(AST::EmptyStatement *ast) override;
+ bool visit(AST::ExpressionStatement *ast) override;
+ bool visit(AST::ForEachStatement *ast) override;
+ bool visit(AST::ForStatement *ast) override;
+ bool visit(AST::IfStatement *ast) override;
+ bool visit(AST::LabelledStatement *ast) override;
+ bool visit(AST::LocalForEachStatement *ast) override;
+ bool visit(AST::LocalForStatement *ast) override;
+ bool visit(AST::ReturnStatement *ast) override;
+ bool visit(AST::SwitchStatement *ast) override;
+ bool visit(AST::ThrowStatement *ast) override;
+ bool visit(AST::TryStatement *ast) override;
+ bool visit(AST::VariableStatement *ast) override;
+ bool visit(AST::WhileStatement *ast) override;
+ bool visit(AST::WithStatement *ast) override;
// ui object members
- virtual bool visit(AST::UiArrayBinding *ast);
- virtual bool visit(AST::UiObjectBinding *ast);
- virtual bool visit(AST::UiObjectDefinition *ast);
- virtual bool visit(AST::UiPublicMember *ast);
- virtual bool visit(AST::UiScriptBinding *ast);
- virtual bool visit(AST::UiSourceElement *ast);
+ bool visit(AST::UiArrayBinding *ast) override;
+ bool visit(AST::UiObjectBinding *ast) override;
+ bool visit(AST::UiObjectDefinition *ast) override;
+ bool visit(AST::UiPublicMember *ast) override;
+ bool visit(AST::UiScriptBinding *ast) override;
+ bool visit(AST::UiSourceElement *ast) override;
bool throwSyntaxErrorOnEvalOrArgumentsInStrictMode(QV4::IR::Expr* expr, const AST::SourceLocation &loc);
virtual void throwSyntaxError(const AST::SourceLocation &loc, const QString &detail);
@@ -486,39 +486,39 @@ protected:
void checkName(const QStringRef &name, const AST::SourceLocation &loc);
void checkForArguments(AST::FormalParameterList *parameters);
- virtual bool visit(AST::Program *ast);
- virtual void endVisit(AST::Program *);
+ bool visit(AST::Program *ast) override;
+ void endVisit(AST::Program *) override;
- virtual bool visit(AST::CallExpression *ast);
- virtual bool visit(AST::NewMemberExpression *ast);
- virtual bool visit(AST::ArrayLiteral *ast);
- virtual bool visit(AST::VariableDeclaration *ast);
- virtual bool visit(AST::IdentifierExpression *ast);
- virtual bool visit(AST::ExpressionStatement *ast);
- virtual bool visit(AST::FunctionExpression *ast);
+ bool visit(AST::CallExpression *ast) override;
+ bool visit(AST::NewMemberExpression *ast) override;
+ bool visit(AST::ArrayLiteral *ast) override;
+ bool visit(AST::VariableDeclaration *ast) override;
+ bool visit(AST::IdentifierExpression *ast) override;
+ bool visit(AST::ExpressionStatement *ast) override;
+ bool visit(AST::FunctionExpression *ast) override;
void enterFunction(AST::FunctionExpression *ast, bool enterName, bool isExpression = true);
- virtual void endVisit(AST::FunctionExpression *);
+ void endVisit(AST::FunctionExpression *) override;
- virtual bool visit(AST::ObjectLiteral *ast);
+ bool visit(AST::ObjectLiteral *ast) override;
- virtual bool visit(AST::PropertyGetterSetter *ast);
- virtual void endVisit(AST::PropertyGetterSetter *);
+ bool visit(AST::PropertyGetterSetter *ast) override;
+ void endVisit(AST::PropertyGetterSetter *) override;
- virtual bool visit(AST::FunctionDeclaration *ast);
- virtual void endVisit(AST::FunctionDeclaration *);
+ bool visit(AST::FunctionDeclaration *ast) override;
+ void endVisit(AST::FunctionDeclaration *) override;
- virtual bool visit(AST::WithStatement *ast);
+ bool visit(AST::WithStatement *ast) override;
- virtual bool visit(AST::DoWhileStatement *ast);
- virtual bool visit(AST::ForStatement *ast);
- virtual bool visit(AST::LocalForStatement *ast);
- virtual bool visit(AST::ForEachStatement *ast);
- virtual bool visit(AST::LocalForEachStatement *ast);
- virtual bool visit(AST::ThisExpression *ast);
+ bool visit(AST::DoWhileStatement *ast) override;
+ bool visit(AST::ForStatement *ast) override;
+ bool visit(AST::LocalForStatement *ast) override;
+ bool visit(AST::ForEachStatement *ast) override;
+ bool visit(AST::LocalForEachStatement *ast) override;
+ bool visit(AST::ThisExpression *ast) override;
- virtual bool visit(AST::Block *ast);
+ bool visit(AST::Block *ast) override;
protected:
void enterFunction(AST::Node *ast, const QString &name, AST::FormalParameterList *formals, AST::FunctionBody *body, AST::FunctionExpression *expr, bool isExpression);
@@ -544,8 +544,8 @@ public:
, engine(engine)
{}
- virtual void throwSyntaxError(const AST::SourceLocation &loc, const QString &detail);
- virtual void throwReferenceError(const AST::SourceLocation &loc, const QString &detail);
+ void throwSyntaxError(const AST::SourceLocation &loc, const QString &detail) override;
+ void throwReferenceError(const AST::SourceLocation &loc, const QString &detail) override;
private:
QV4::ExecutionEngine *engine;
};
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp
index 35f61b4f69..e815c41a86 100644
--- a/src/qml/compiler/qv4compileddata.cpp
+++ b/src/qml/compiler/qv4compileddata.cpp
@@ -65,6 +65,12 @@
#include <algorithm>
+#if defined(QT_BUILD_INTERNAL)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_DYNAMIC_CAST)
+#include <dlfcn.h>
+#endif
+#endif
+
QT_BEGIN_NAMESPACE
namespace QV4 {
@@ -571,6 +577,17 @@ QQmlPropertyCache *ResolvedTypeReference::createPropertyCache(QQmlEngine *engine
}
}
+bool ResolvedTypeReference::addToHash(QCryptographicHash *hash, QQmlEngine *engine)
+{
+ if (type) {
+ bool ok = false;
+ hash->addData(createPropertyCache(engine)->checksum(&ok));
+ return ok;
+ }
+ hash->addData(compilationUnit->data->md5Checksum, sizeof(compilationUnit->data->md5Checksum));
+ return true;
+}
+
template <typename T>
bool qtTypeInherits(const QMetaObject *mo) {
while (mo) {
@@ -593,20 +610,70 @@ void ResolvedTypeReference::doDynamicTypeCheck()
isFullyDynamicType = qtTypeInherits<QQmlPropertyMap>(mo);
}
+#if defined(QT_BUILD_INTERNAL)
+
+static QByteArray ownLibraryChecksum()
+{
+ static QByteArray libraryChecksum;
+ static bool checksumInitialized = false;
+ if (checksumInitialized)
+ return libraryChecksum;
+ checksumInitialized = true;
+#if defined(Q_OS_UNIX) && !defined(QT_NO_DYNAMIC_CAST)
+ Dl_info libInfo;
+ if (dladdr(reinterpret_cast<const void *>(&ownLibraryChecksum), &libInfo) != 0) {
+ QFile library(QFile::decodeName(libInfo.dli_fname));
+ if (library.open(QIODevice::ReadOnly)) {
+ QCryptographicHash hash(QCryptographicHash::Sha1);
+ hash.addData(&library);
+ libraryChecksum = hash.result();
+ }
+ }
+#else
+ // Not implemented.
+#endif
+ return libraryChecksum;
+}
+
+#endif
+
bool ResolvedTypeReferenceMap::addToHash(QCryptographicHash *hash, QQmlEngine *engine) const
{
for (auto it = constBegin(), end = constEnd(); it != end; ++it) {
- QQmlPropertyCache *pc = it.value()->createPropertyCache(engine);
- bool ok = false;
- hash->addData(pc->checksum(&ok));
- if (!ok)
+ if (!it.value()->addToHash(hash, engine))
return false;
}
+
+ // This is a bit of a hack to make development easier. When hacking on the code generator
+ // the cache files may end up being re-used. To avoid that we also add the checksum of
+ // the QtQml library.
+#if defined(QT_BUILD_INTERNAL)
+ hash->addData(ownLibraryChecksum());
+#endif
+
return true;
}
#endif
+void Unit::generateChecksum()
+{
+#ifndef V4_BOOTSTRAP
+ QCryptographicHash hash(QCryptographicHash::Md5);
+
+ const int checksummableDataOffset = qOffsetOf(QV4::CompiledData::Unit, md5Checksum) + sizeof(md5Checksum);
+
+ const char *dataPtr = reinterpret_cast<const char *>(this) + checksummableDataOffset;
+ hash.addData(dataPtr, unitSize - checksummableDataOffset);
+
+ QByteArray checksum = hash.result();
+ Q_ASSERT(checksum.size() == sizeof(md5Checksum));
+ memcpy(md5Checksum, checksum.constData(), sizeof(md5Checksum));
+#else
+ memset(md5Checksum, 0, sizeof(md5Checksum));
+#endif
+}
+
}
}
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h
index ae8677138e..90cbe04505 100644
--- a/src/qml/compiler/qv4compileddata_p.h
+++ b/src/qml/compiler/qv4compileddata_p.h
@@ -71,7 +71,7 @@
QT_BEGIN_NAMESPACE
// Bump this whenever the compiler data structures change in an incompatible way.
-#define QV4_DATA_STRUCTURE_VERSION 0x04
+#define QV4_DATA_STRUCTURE_VERSION 0x07
class QIODevice;
class QQmlPropertyCache;
@@ -202,6 +202,8 @@ struct String
}
};
+// Function is aligned on an 8-byte boundary to make sure there are no bus errors or penalties
+// for unaligned access. The ordering of the fields is also from largest to smallest.
struct Function
{
enum Flags : unsigned int {
@@ -212,6 +214,11 @@ struct Function
HasCatchOrWith = 0x10
};
+ // Absolute offset into file where the code for this function is located. Only used when the function
+ // is serialized.
+ LEUInt64 codeOffset;
+ LEUInt64 codeSize;
+
LEUInt32 nameIndex;
LEUInt32 nFormals;
LEUInt32 formalsOffset;
@@ -229,11 +236,6 @@ struct Function
LEUInt32 dependingScopePropertiesOffset; // Array of int pairs (property index and notify index)
// Qml Extensions End
- // Absolute offset into file where the code for this function is located. Only used when the function
- // is serialized.
- LEUInt64 codeOffset;
- LEUInt64 codeSize;
-
// quint32 formalsIndex[nFormals]
// quint32 localsIndex[nLocals]
// quint32 offsetForInnerFunctions[nInnerFunctions]
@@ -585,7 +587,7 @@ struct Import
ImportFile = 0x2,
ImportScript = 0x3
};
- quint8 type;
+ LEUInt32 type;
LEUInt32 uriIndex;
LEUInt32 qualifierIndex;
@@ -610,6 +612,9 @@ struct Unit
LEUInt32 unitSize; // Size of the Unit and any depending data.
// END DO NOT CHANGE THESE FIELDS EVER
+ char md5Checksum[16]; // checksum of all bytes following this field.
+ void generateChecksum();
+
LEUInt32 architectureIndex; // string index to QSysInfo::buildAbi()
LEUInt32 codeGeneratorIndex;
char dependencyMD5Checksum[16];
@@ -725,7 +730,7 @@ struct TypeReference
bool errorWhenNotFound: 1;
};
-// map from name index to location of first use
+// Map from name index to location of first use.
struct TypeReferenceMap : QHash<int, TypeReference>
{
TypeReference &add(int nameIndex, const Location &loc) {
@@ -789,6 +794,7 @@ struct ResolvedTypeReference
QQmlPropertyCache *propertyCache() const;
QQmlPropertyCache *createPropertyCache(QQmlEngine *);
+ bool addToHash(QCryptographicHash *hash, QQmlEngine *engine);
void doDynamicTypeCheck();
};
diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp
index 43347d246a..cd822a2614 100644
--- a/src/qml/compiler/qv4compiler.cpp
+++ b/src/qml/compiler/qv4compiler.cpp
@@ -44,6 +44,7 @@
#include <private/qv4value_p.h>
#include <private/qv4alloca_p.h>
#include <wtf/MathExtras.h>
+#include <QCryptographicHash>
QV4::Compiler::StringTableGenerator::StringTableGenerator()
{
@@ -211,7 +212,7 @@ int QV4::Compiler::JSUnitGenerator::registerJSClass(int count, IR::ExprList *arg
QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit(GeneratorOption option)
{
registerString(irModule->fileName);
- foreach (QV4::IR::Function *f, irModule->functions) {
+ for (QV4::IR::Function *f : qAsConst(irModule->functions)) {
registerString(*f->name);
for (int i = 0; i < f->formals.size(); ++i)
registerString(*f->formals.at(i));
@@ -227,6 +228,7 @@ QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit(GeneratorO
{
QV4::CompiledData::Unit tempHeader = generateHeader(option, functionOffsets, &jsClassDataOffset);
dataPtr = reinterpret_cast<char *>(malloc(tempHeader.unitSize));
+ memset(dataPtr, 0, tempHeader.unitSize);
memcpy(&unit, &dataPtr, sizeof(CompiledData::Unit*));
memcpy(unit, &tempHeader, sizeof(tempHeader));
}
@@ -242,7 +244,7 @@ QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit(GeneratorO
}
CompiledData::Lookup *lookupsToWrite = reinterpret_cast<CompiledData::Lookup*>(dataPtr + unit->offsetToLookupTable);
- foreach (const CompiledData::Lookup &l, lookups)
+ for (const CompiledData::Lookup &l : qAsConst(lookups))
*lookupsToWrite++ = l;
CompiledData::RegExp *regexpTable = reinterpret_cast<CompiledData::RegExp *>(dataPtr + unit->offsetToRegexpTable);
@@ -270,6 +272,8 @@ QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit(GeneratorO
if (option == GenerateWithStringTable)
stringTable.serialize(unit);
+ unit->generateChecksum();
+
return unit;
}
@@ -363,11 +367,13 @@ void QV4::Compiler::JSUnitGenerator::writeFunction(char *f, QV4::IR::Function *i
QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Compiler::JSUnitGenerator::GeneratorOption option, QJsonPrivate::q_littleendian<quint32> *functionOffsets, uint *jsClassDataOffset)
{
CompiledData::Unit unit;
+ memset(&unit, 0, sizeof(unit));
memcpy(unit.magic, CompiledData::magic_str, sizeof(unit.magic));
unit.flags = QV4::CompiledData::Unit::IsJavascript;
unit.flags |= irModule->unitFlags;
unit.version = QV4_DATA_STRUCTURE_VERSION;
unit.qtVersion = QT_VERSION;
+ memset(unit.md5Checksum, 0, sizeof(unit.md5Checksum));
unit.architectureIndex = registerString(QSysInfo::buildAbi());
unit.codeGeneratorIndex = registerString(codeGeneratorName);
memset(unit.dependencyMD5Checksum, 0, sizeof(unit.dependencyMD5Checksum));
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h
index beb43376ee..ca4e0b73d4 100644
--- a/src/qml/compiler/qv4instr_moth_p.h
+++ b/src/qml/compiler/qv4instr_moth_p.h
@@ -50,12 +50,13 @@
//
// We mean it.
//
-
-#include <QtCore/qglobal.h>
+#include <private/qv4global_p.h>
#include <private/qv4value_p.h>
#include <private/qv4function_p.h>
#include <private/qv4runtime_p.h>
+QT_REQUIRE_CONFIG(qml_interpreter);
+
QT_BEGIN_NAMESPACE
#ifdef QT_NO_QML_DEBUGGER
@@ -252,6 +253,7 @@ union Instr
{
enum Type {
FOR_EACH_MOTH_INSTR(MOTH_INSTR_ENUM)
+ LastInstruction
};
struct instr_common {
diff --git a/src/qml/compiler/qv4isel_moth.cpp b/src/qml/compiler/qv4isel_moth.cpp
index cd47f22205..1f5c22eb97 100644
--- a/src/qml/compiler/qv4isel_moth.cpp
+++ b/src/qml/compiler/qv4isel_moth.cpp
@@ -209,7 +209,7 @@ void InstructionSelection::run(int functionIndex)
ConvertTemps().toStackSlots(_function);
}
- QSet<IR::Jump *> removableJumps = opt.calculateOptionalJumps();
+ BitVector removableJumps = opt.calculateOptionalJumps();
qSwap(_removableJumps, removableJumps);
IR::Stmt *cs = 0;
@@ -292,7 +292,7 @@ QQmlRefPointer<QV4::CompiledData::CompilationUnit> InstructionSelection::backend
{
compilationUnit->codeRefs.resize(irModule->functions.size());
int i = 0;
- foreach (IR::Function *irFunction, irModule->functions)
+ for (IR::Function *irFunction : qAsConst(irModule->functions))
compilationUnit->codeRefs[i++] = codeRefs[irFunction];
QQmlRefPointer<QV4::CompiledData::CompilationUnit> result;
result.adopt(compilationUnit.take());
@@ -950,7 +950,7 @@ void InstructionSelection::visitJump(IR::Jump *s)
{
if (s->target == _nextBlock)
return;
- if (_removableJumps.contains(s))
+ if (_removableJumps.at(_block->index()))
return;
addDebugInstruction();
@@ -1477,6 +1477,17 @@ bool CompilationUnit::saveCodeToDisk(QIODevice *device, const CompiledData::Unit
QByteArray padding;
+#ifdef MOTH_THREADED_INTERPRETER
+ // Map from instruction label back to instruction type. Only needed when persisting
+ // already linked compilation units;
+ QHash<void*, int> reverseInstructionMapping;
+ if (engine) {
+ void **instructions = VME::instructionJumpTable();
+ for (int i = 0; i < Instr::LastInstruction; ++i)
+ reverseInstructionMapping.insert(instructions[i], i);
+ }
+#endif
+
for (int i = 0; i < codeRefs.size(); ++i) {
const CompiledData::Function *compiledFunction = unit->functionAt(i);
@@ -1493,8 +1504,30 @@ bool CompilationUnit::saveCodeToDisk(QIODevice *device, const CompiledData::Unit
return false;
}
- const void *codePtr = codeRefs.at(i).constData();
- written = device->write(reinterpret_cast<const char *>(codePtr), compiledFunction->codeSize);
+ QByteArray code = codeRefs.at(i);
+
+#ifdef MOTH_THREADED_INTERPRETER
+ if (!reverseInstructionMapping.isEmpty()) {
+ char *codePtr = code.data(); // detaches
+ int index = 0;
+ while (index < code.size()) {
+ Instr *genericInstr = reinterpret_cast<Instr *>(codePtr + index);
+
+ genericInstr->common.instructionType = reverseInstructionMapping.value(genericInstr->common.code);
+
+ switch (genericInstr->common.instructionType) {
+ #define REVERSE_INSTRUCTION(InstructionType, Member) \
+ case Instr::InstructionType: \
+ index += InstrMeta<(int)Instr::InstructionType>::Size; \
+ break;
+
+ FOR_EACH_MOTH_INSTR(REVERSE_INSTRUCTION)
+ }
+ }
+ }
+#endif
+
+ written = device->write(code.constData(), compiledFunction->codeSize);
if (written != qint64(compiledFunction->codeSize)) {
*errorString = device->errorString();
return false;
diff --git a/src/qml/compiler/qv4isel_moth_p.h b/src/qml/compiler/qv4isel_moth_p.h
index c304284cbc..afe5fe342e 100644
--- a/src/qml/compiler/qv4isel_moth_p.h
+++ b/src/qml/compiler/qv4isel_moth_p.h
@@ -54,10 +54,13 @@
#include <private/qv4global_p.h>
#include <private/qv4isel_p.h>
#include <private/qv4isel_util_p.h>
+#include <private/qv4util_p.h>
#include <private/qv4jsir_p.h>
#include <private/qv4value_p.h>
#include "qv4instr_moth_p.h"
+QT_REQUIRE_CONFIG(qml_interpreter);
+
QT_BEGIN_NAMESPACE
namespace QV4 {
@@ -83,68 +86,68 @@ public:
InstructionSelection(QQmlEnginePrivate *qmlEngine, QV4::ExecutableAllocator *execAllocator, IR::Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator, EvalISelFactory *iselFactory);
~InstructionSelection();
- virtual void run(int functionIndex);
+ void run(int functionIndex) override;
protected:
- virtual QQmlRefPointer<CompiledData::CompilationUnit> backendCompileStep();
-
- virtual void visitJump(IR::Jump *);
- virtual void visitCJump(IR::CJump *);
- virtual void visitRet(IR::Ret *);
-
- virtual void callBuiltinInvalid(IR::Name *func, IR::ExprList *args, IR::Expr *result);
- virtual void callBuiltinTypeofQmlContextProperty(IR::Expr *base, IR::Member::MemberKind kind, int propertyIndex, IR::Expr *result);
- virtual void callBuiltinTypeofMember(IR::Expr *base, const QString &name, IR::Expr *result);
- virtual void callBuiltinTypeofSubscript(IR::Expr *base, IR::Expr *index, IR::Expr *result);
- virtual void callBuiltinTypeofName(const QString &name, IR::Expr *result);
- virtual void callBuiltinTypeofValue(IR::Expr *value, IR::Expr *result);
- virtual void callBuiltinDeleteMember(IR::Expr *base, const QString &name, IR::Expr *result);
- virtual void callBuiltinDeleteSubscript(IR::Expr *base, IR::Expr *index, IR::Expr *result);
- virtual void callBuiltinDeleteName(const QString &name, IR::Expr *result);
- virtual void callBuiltinDeleteValue(IR::Expr *result);
- virtual void callBuiltinThrow(IR::Expr *arg);
- virtual void callBuiltinReThrow();
- virtual void callBuiltinUnwindException(IR::Expr *);
- virtual void callBuiltinPushCatchScope(const QString &exceptionName);
- virtual void callBuiltinForeachIteratorObject(IR::Expr *arg, IR::Expr *result);
- virtual void callBuiltinForeachNextPropertyname(IR::Expr *arg, IR::Expr *result);
- virtual void callBuiltinPushWithScope(IR::Expr *arg);
- virtual void callBuiltinPopScope();
- virtual void callBuiltinDeclareVar(bool deletable, const QString &name);
- virtual void callBuiltinDefineArray(IR::Expr *result, IR::ExprList *args);
- virtual void callBuiltinDefineObjectLiteral(IR::Expr *result, int keyValuePairCount, IR::ExprList *keyValuePairs, IR::ExprList *arrayEntries, bool needSparseArray);
- virtual void callBuiltinSetupArgumentObject(IR::Expr *result);
- virtual void callBuiltinConvertThisToObject();
- virtual void callValue(IR::Expr *value, IR::ExprList *args, IR::Expr *result);
- virtual void callQmlContextProperty(IR::Expr *base, IR::Member::MemberKind kind, int propertyIndex, IR::ExprList *args, IR::Expr *result);
- virtual void callProperty(IR::Expr *base, const QString &name, IR::ExprList *args, IR::Expr *result);
- virtual void callSubscript(IR::Expr *base, IR::Expr *index, IR::ExprList *args, IR::Expr *result);
- virtual void convertType(IR::Expr *source, IR::Expr *target);
- virtual void constructActivationProperty(IR::Name *func, IR::ExprList *args, IR::Expr *result);
- virtual void constructProperty(IR::Expr *base, const QString &name, IR::ExprList *args, IR::Expr *result);
- virtual void constructValue(IR::Expr *value, IR::ExprList *args, IR::Expr *result);
- virtual void loadThisObject(IR::Expr *e);
- virtual void loadQmlContext(IR::Expr *e);
- virtual void loadQmlImportedScripts(IR::Expr *e);
- virtual void loadQmlSingleton(const QString &name, IR::Expr *e);
- virtual void loadConst(IR::Const *sourceConst, IR::Expr *e);
- virtual void loadString(const QString &str, IR::Expr *target);
- virtual void loadRegexp(IR::RegExp *sourceRegexp, IR::Expr *target);
- virtual void getActivationProperty(const IR::Name *name, IR::Expr *target);
- virtual void setActivationProperty(IR::Expr *source, const QString &targetName);
- virtual void initClosure(IR::Closure *closure, IR::Expr *target);
- virtual void getProperty(IR::Expr *base, const QString &name, IR::Expr *target);
- virtual void setProperty(IR::Expr *source, IR::Expr *targetBase, const QString &targetName);
- virtual void setQmlContextProperty(IR::Expr *source, IR::Expr *targetBase, IR::Member::MemberKind kind, int propertyIndex);
- virtual void setQObjectProperty(IR::Expr *source, IR::Expr *targetBase, int propertyIndex);
- virtual void getQmlContextProperty(IR::Expr *source, IR::Member::MemberKind kind, int index, bool captureRequired, IR::Expr *target);
- virtual void getQObjectProperty(IR::Expr *base, int propertyIndex, bool captureRequired, bool isSingleton, int attachedPropertiesId, IR::Expr *target);
- virtual void getElement(IR::Expr *base, IR::Expr *index, IR::Expr *target);
- virtual void setElement(IR::Expr *source, IR::Expr *targetBase, IR::Expr *targetIndex);
- virtual void copyValue(IR::Expr *source, IR::Expr *target);
- virtual void swapValues(IR::Expr *source, IR::Expr *target);
- virtual void unop(IR::AluOp oper, IR::Expr *source, IR::Expr *target);
- virtual void binop(IR::AluOp oper, IR::Expr *leftSource, IR::Expr *rightSource, IR::Expr *target);
+ QQmlRefPointer<CompiledData::CompilationUnit> backendCompileStep() override;
+
+ void visitJump(IR::Jump *) override;
+ void visitCJump(IR::CJump *) override;
+ void visitRet(IR::Ret *) override;
+
+ void callBuiltinInvalid(IR::Name *func, IR::ExprList *args, IR::Expr *result) override;
+ void callBuiltinTypeofQmlContextProperty(IR::Expr *base, IR::Member::MemberKind kind, int propertyIndex, IR::Expr *result) override;
+ void callBuiltinTypeofMember(IR::Expr *base, const QString &name, IR::Expr *result) override;
+ void callBuiltinTypeofSubscript(IR::Expr *base, IR::Expr *index, IR::Expr *result) override;
+ void callBuiltinTypeofName(const QString &name, IR::Expr *result) override;
+ void callBuiltinTypeofValue(IR::Expr *value, IR::Expr *result) override;
+ void callBuiltinDeleteMember(IR::Expr *base, const QString &name, IR::Expr *result) override;
+ void callBuiltinDeleteSubscript(IR::Expr *base, IR::Expr *index, IR::Expr *result) override;
+ void callBuiltinDeleteName(const QString &name, IR::Expr *result) override;
+ void callBuiltinDeleteValue(IR::Expr *result) override;
+ void callBuiltinThrow(IR::Expr *arg) override;
+ void callBuiltinReThrow() override;
+ void callBuiltinUnwindException(IR::Expr *) override;
+ void callBuiltinPushCatchScope(const QString &exceptionName) override;
+ void callBuiltinForeachIteratorObject(IR::Expr *arg, IR::Expr *result) override;
+ void callBuiltinForeachNextPropertyname(IR::Expr *arg, IR::Expr *result) override;
+ void callBuiltinPushWithScope(IR::Expr *arg) override;
+ void callBuiltinPopScope() override;
+ void callBuiltinDeclareVar(bool deletable, const QString &name) override;
+ void callBuiltinDefineArray(IR::Expr *result, IR::ExprList *args) override;
+ void callBuiltinDefineObjectLiteral(IR::Expr *result, int keyValuePairCount, IR::ExprList *keyValuePairs, IR::ExprList *arrayEntries, bool needSparseArray) override;
+ void callBuiltinSetupArgumentObject(IR::Expr *result) override;
+ void callBuiltinConvertThisToObject() override;
+ void callValue(IR::Expr *value, IR::ExprList *args, IR::Expr *result) override;
+ void callQmlContextProperty(IR::Expr *base, IR::Member::MemberKind kind, int propertyIndex, IR::ExprList *args, IR::Expr *result) override;
+ void callProperty(IR::Expr *base, const QString &name, IR::ExprList *args, IR::Expr *result) override;
+ void callSubscript(IR::Expr *base, IR::Expr *index, IR::ExprList *args, IR::Expr *result) override;
+ void convertType(IR::Expr *source, IR::Expr *target) override;
+ void constructActivationProperty(IR::Name *func, IR::ExprList *args, IR::Expr *result) override;
+ void constructProperty(IR::Expr *base, const QString &name, IR::ExprList *args, IR::Expr *result) override;
+ void constructValue(IR::Expr *value, IR::ExprList *args, IR::Expr *result) override;
+ void loadThisObject(IR::Expr *e) override;
+ void loadQmlContext(IR::Expr *e) override;
+ void loadQmlImportedScripts(IR::Expr *e) override;
+ void loadQmlSingleton(const QString &name, IR::Expr *e) override;
+ void loadConst(IR::Const *sourceConst, IR::Expr *e) override;
+ void loadString(const QString &str, IR::Expr *target) override;
+ void loadRegexp(IR::RegExp *sourceRegexp, IR::Expr *target) override;
+ void getActivationProperty(const IR::Name *name, IR::Expr *target) override;
+ void setActivationProperty(IR::Expr *source, const QString &targetName) override;
+ void initClosure(IR::Closure *closure, IR::Expr *target) override;
+ void getProperty(IR::Expr *base, const QString &name, IR::Expr *target) override;
+ void setProperty(IR::Expr *source, IR::Expr *targetBase, const QString &targetName) override;
+ void setQmlContextProperty(IR::Expr *source, IR::Expr *targetBase, IR::Member::MemberKind kind, int propertyIndex) override;
+ void setQObjectProperty(IR::Expr *source, IR::Expr *targetBase, int propertyIndex) override;
+ void getQmlContextProperty(IR::Expr *source, IR::Member::MemberKind kind, int index, bool captureRequired, IR::Expr *target) override;
+ void getQObjectProperty(IR::Expr *base, int propertyIndex, bool captureRequired, bool isSingleton, int attachedPropertiesId, IR::Expr *target) override;
+ void getElement(IR::Expr *base, IR::Expr *index, IR::Expr *target) override;
+ void setElement(IR::Expr *source, IR::Expr *targetBase, IR::Expr *targetIndex) override;
+ void copyValue(IR::Expr *source, IR::Expr *target) override;
+ void swapValues(IR::Expr *source, IR::Expr *target) override;
+ void unop(IR::AluOp oper, IR::Expr *source, IR::Expr *target) override;
+ void binop(IR::AluOp oper, IR::Expr *leftSource, IR::Expr *rightSource, IR::Expr *target) override;
private:
Param binopHelper(IR::AluOp oper, IR::Expr *leftSource, IR::Expr *rightSource, IR::Expr *target);
@@ -197,7 +200,7 @@ private:
uchar *_codeNext;
uchar *_codeEnd;
- QSet<IR::Jump *> _removableJumps;
+ BitVector _removableJumps;
IR::Stmt *_currentStatement;
QScopedPointer<CompilationUnit> compilationUnit;
diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp
index e4eaeaa3f6..4fa0cf421b 100644
--- a/src/qml/compiler/qv4ssa.cpp
+++ b/src/qml/compiler/qv4ssa.cpp
@@ -1123,7 +1123,7 @@ public:
{
QVector<UntypedTemp> res;
res.reserve(tempCount());
- foreach (const DefUse &du, _defUses)
+ for (const DefUse &du : _defUses)
if (du.isValid())
res.append(UntypedTemp(du.temp));
return res;
@@ -1150,7 +1150,7 @@ public:
{
Q_ASSERT(static_cast<unsigned>(variable.index) < _defUses.size());
QVector<Stmt *> &uses = _defUses[variable.index].uses;
- foreach (Stmt *stmt, newUses)
+ for (Stmt *stmt : newUses)
if (std::find(uses.begin(), uses.end(), stmt) == uses.end())
uses.push_back(stmt);
}
@@ -1226,7 +1226,7 @@ public:
QVector<Stmt*> removeDefUses(Stmt *s)
{
QVector<Stmt*> defStmts;
- foreach (const Temp &usedVar, usedVars(s)) {
+ for (const Temp &usedVar : usedVars(s)) {
if (Stmt *ds = defStmt(usedVar))
defStmts += ds;
removeUse(s, usedVar);
@@ -1247,7 +1247,7 @@ public:
buf.open(QIODevice::WriteOnly);
QTextStream qout(&buf);
qout << "Defines and uses:" << endl;
- foreach (const DefUse &du, _defUses) {
+ for (const DefUse &du : _defUses) {
if (!du.isValid())
continue;
qout << '%' << du.temp.index;
@@ -1255,14 +1255,14 @@ public:
<< ", statement: " << du.defStmt->id()
<< endl;
qout << " uses:";
- foreach (Stmt *s, du.uses)
+ for (Stmt *s : du.uses)
qout << ' ' << s->id();
qout << endl;
}
qout << "Uses per statement:" << endl;
for (size_t i = 0, ei = _usesPerStatement.size(); i != ei; ++i) {
qout << " " << i << ":";
- foreach (const Temp &t, _usesPerStatement[i])
+ for (const Temp &t : _usesPerStatement[i])
qout << ' ' << t.index;
qout << endl;
}
@@ -1633,7 +1633,7 @@ bool hasPhiOnlyUses(Phi *phi, const DefUses &defUses, QBitArray &collectedPhis)
{
collectedPhis.setBit(phi->id());
- foreach (Stmt *use, defUses.uses(*phi->targetTemp)) {
+ for (Stmt *use : defUses.uses(*phi->targetTemp)) {
Phi *dependentPhi = use->asPhi();
if (!dependentPhi)
return false; // there is a use by a non-phi node
@@ -1679,7 +1679,7 @@ void cleanupPhis(DefUses &defUses)
const Temp &targetVar = *phi->targetTemp;
defUses.defStmtBlock(targetVar)->removeStatement(phi);
- foreach (const Temp &usedVar, defUses.usedVars(phi))
+ for (const Temp &usedVar : defUses.usedVars(phi))
defUses.removeUse(phi, usedVar);
defUses.removeDef(targetVar);
}
@@ -1729,7 +1729,7 @@ public:
worklist.assign(worklist.size(), false);
worklistSize = 0;
- foreach (Stmt *s, stmts) {
+ for (Stmt *s : stmts) {
if (!s)
continue;
@@ -1802,7 +1802,7 @@ public:
StatementWorklist &operator+=(const QVector<Stmt *> &stmts)
{
- foreach (Stmt *s, stmts)
+ for (Stmt *s : stmts)
this->operator+=(s);
return *this;
@@ -2092,7 +2092,7 @@ public:
theTemp = temp;
if (Stmt *defStmt = defUses.defStmt(temp.temp))
visit(defStmt);
- foreach (Stmt *use, defUses.uses(temp.temp))
+ for (Stmt *use : defUses.uses(temp.temp))
visit(use);
}
@@ -2246,7 +2246,7 @@ private:
it = ty;
if (DebugTypeInference) {
- foreach (Stmt *s, _defUses.uses(*t)) {
+ for (Stmt *s : _defUses.uses(*t)) {
QBuffer buf;
buf.open(QIODevice::WriteOnly);
QTextStream qout(&buf);
@@ -2606,7 +2606,7 @@ public:
}
PropagateTempTypes propagator(_defUses);
- foreach (const UntypedTemp &t, knownOk) {
+ for (const UntypedTemp &t : qAsConst(knownOk)) {
propagator.run(t, SInt32Type);
if (Stmt *defStmt = _defUses.defStmt(t.temp)) {
if (Move *m = defStmt->asMove()) {
@@ -2630,7 +2630,7 @@ private:
if (uses.isEmpty())
return false;
- foreach (Stmt *use, uses) {
+ for (Stmt *use : uses) {
if (Move *m = use->asMove()) {
Temp *targetTemp = m->target->asTemp();
@@ -3165,7 +3165,8 @@ public:
std::vector<BasicBlock *> backedges;
backedges.reserve(4);
- foreach (BasicBlock *bb, dt.calculateDFNodeIterOrder()) {
+ const auto order = dt.calculateDFNodeIterOrder();
+ for (BasicBlock *bb : order) {
Q_ASSERT(!bb->isRemoved());
backedges.clear();
@@ -3188,12 +3189,12 @@ public:
if (!DebugLoopDetection)
return;
- foreach (LoopInfo *info, loopInfos) {
+ for (const LoopInfo *info : loopInfos) {
qDebug() << "Loop header:" << info->loopHeader->index()
<< "for loop" << quint64(info);
- foreach (BasicBlock *bb, info->loopBody)
+ for (BasicBlock *bb : info->loopBody)
qDebug() << " " << bb->index();
- foreach (LoopInfo *nested, info->nestedLoops)
+ for (LoopInfo *nested : info->nestedLoops)
qDebug() << " sub loop:" << quint64(nested);
qDebug() << " parent loop:" << quint64(info->parentLoop);
}
@@ -3277,15 +3278,15 @@ private:
findLoop(loopHeader)->loopBody.append(bb);
}
- foreach (LoopInfo *info, loopInfos) {
- if (BasicBlock *containingLoopHeader = info->loopHeader->containingGroup())
- findLoop(containingLoopHeader)->addNestedLoop(info);
+ for (int i = 0, size = loopInfos.size(); i < size; ++i) {
+ if (BasicBlock *containingLoopHeader = loopInfos.at(i)->loopHeader->containingGroup())
+ findLoop(containingLoopHeader)->addNestedLoop(loopInfos.at(i));
}
}
LoopInfo *findLoop(BasicBlock *loopHeader)
{
- foreach (LoopInfo *info, loopInfos) {
+ for (LoopInfo *info : qAsConst(loopInfos)) {
if (info->loopHeader == loopHeader)
return info;
}
@@ -3459,8 +3460,8 @@ public:
};
#ifndef QT_NO_DEBUG
-void checkCriticalEdges(QVector<BasicBlock *> basicBlocks) {
- foreach (BasicBlock *bb, basicBlocks) {
+void checkCriticalEdges(const QVector<BasicBlock *> &basicBlocks) {
+ for (BasicBlock *bb : basicBlocks) {
if (bb && bb->out.size() > 1) {
for (BasicBlock *bb2 : bb->out) {
if (bb2 && bb2->in.size() > 1) {
@@ -3594,7 +3595,7 @@ public:
newUses->reserve(uses.size());
// qout << " " << uses.size() << " uses:"<<endl;
- foreach (Stmt *use, uses) {
+ for (Stmt *use : uses) {
// qout<<" ";use->dump(qout);qout<<"\n";
visit(use);
// qout<<" -> ";use->dump(qout);qout<<"\n";
@@ -3752,7 +3753,7 @@ void unlink(BasicBlock *from, BasicBlock *to, IR::Function *func, DefUses &defUs
return;
to->in.remove(idx);
- foreach (Stmt *outStmt, to->statements()) {
+ for (Stmt *outStmt : to->statements()) {
if (!outStmt)
continue;
if (Phi *phi = outStmt->asPhi()) {
@@ -3770,7 +3771,7 @@ void unlink(BasicBlock *from, BasicBlock *to, IR::Function *func, DefUses &defUs
static bool isReachable(BasicBlock *bb, const DominatorTree &dt)
{
- foreach (BasicBlock *in, bb->in) {
+ for (BasicBlock *in : bb->in) {
if (in->isRemoved())
continue;
if (dt.dominates(bb, in)) // a back-edge, not interesting
@@ -3940,13 +3941,13 @@ void cfg2dot(IR::Function *f, const QVector<LoopDetection::LoopInfo *> &loops =
struct Util {
QTextStream &qout;
Util(QTextStream &qout): qout(qout) {}
- void genLoop(LoopDetection::LoopInfo *loop)
+ void genLoop(const LoopDetection::LoopInfo *loop)
{
qout << " subgraph \"cluster" << quint64(loop) << "\" {\n";
qout << " L" << loop->loopHeader->index() << ";\n";
- foreach (BasicBlock *bb, loop->loopBody)
+ for (BasicBlock *bb : loop->loopBody)
qout << " L" << bb->index() << ";\n";
- foreach (LoopDetection::LoopInfo *nested, loop->nestedLoops)
+ for (LoopDetection::LoopInfo *nested : loop->nestedLoops)
genLoop(nested);
qout << " }\n";
}
@@ -3957,7 +3958,7 @@ void cfg2dot(IR::Function *f, const QVector<LoopDetection::LoopInfo *> &loops =
else name = QStringLiteral("%1").arg((unsigned long long)f);
qout << "digraph \"" << name << "\" { ordering=out;\n";
- foreach (LoopDetection::LoopInfo *l, loops) {
+ for (LoopDetection::LoopInfo *l : loops) {
if (l->parentLoop == 0)
Util(qout).genLoop(l);
}
@@ -4463,7 +4464,8 @@ public:
qout << "Life ranges:" << endl;
qout << "Intervals:" << endl;
- foreach (const LifeTimeInterval *range, _sortedIntervals->intervals()) {
+ const auto intervals = _sortedIntervals->intervals();
+ for (const LifeTimeInterval *range : intervals) {
range->dump(qout);
qout << endl;
}
@@ -4723,7 +4725,7 @@ private:
clonedStmt = phi;
phi->targetTemp = clone(p->targetTemp);
- foreach (Expr *in, p->incoming)
+ for (Expr *in : p->incoming)
phi->incoming.append(clone(in));
block->appendStatement(phi);
} else {
@@ -4753,7 +4755,7 @@ public:
void run(const QVector<LoopDetection::LoopInfo *> &loops)
{
- foreach (LoopDetection::LoopInfo *loopInfo, loops)
+ for (LoopDetection::LoopInfo *loopInfo : loops)
peelLoop(loopInfo);
}
@@ -4857,7 +4859,7 @@ private:
// The original loop is now peeled off, and won't jump back to the loop header. Meaning, it
// is not a loop anymore, so unmark it.
loop->loopHeader->markAsGroupStart(false);
- foreach (BasicBlock *bb, loop->loopBody)
+ for (BasicBlock *bb : qAsConst(loop->loopBody))
bb->setContainingGroup(loop->loopHeader->containingGroup());
// calculate the idoms in a separate loop, because addBasicBlock in the previous loop will
@@ -4875,7 +4877,7 @@ private:
}
BasicBlockSet siblings(f);
- foreach (BasicBlock *bb, loopExits)
+ for (BasicBlock *bb : qAsConst(loopExits))
dt.collectSiblings(bb, siblings);
dt.recalculateIDoms(siblings, loop->loopHeader);
@@ -5075,6 +5077,10 @@ void mergeBasicBlocks(IR::Function *function, DefUses *du, DominatorTree *dt)
BasicBlock *successor = bb->out.first();
if (successor->in.size() != 1) continue; // more than one incoming edge
+ // Loop header? No efficient way to update the other blocks that refer to this as containing group,
+ // so don't do merging yet.
+ if (successor->isGroupStart()) continue;
+
// Ok, we can merge the two basic blocks.
if (DebugBlockMerging) {
qDebug("Merging L%d into L%d", successor->index(), bb->index());
@@ -5518,14 +5524,30 @@ LifeTimeIntervals::Ptr Optimizer::lifeTimeIntervals() const
return lifeRanges.intervals();
}
-QSet<Jump *> Optimizer::calculateOptionalJumps()
+static int countPhis(BasicBlock *bb)
{
- QSet<Jump *> optional;
- QSet<BasicBlock *> reachableWithoutJump;
+ int count = 0;
+ for (Stmt *s : bb->statements()) {
+ if (s->isa<Phi>())
+ ++count;
+ else
+ break;
+ }
+ return count;
+}
+
+// Basic blocks can have only 1 terminator. This function returns a bit vector, where a 1 on a
+// certain index indicates that the terminator (jump) at the end of the basic block with that index
+// can be omitted.
+BitVector Optimizer::calculateOptionalJumps()
+{
const int maxSize = function->basicBlockCount();
- optional.reserve(maxSize);
- reachableWithoutJump.reserve(maxSize);
+ BitVector optional(maxSize, false);
+ if (maxSize < 2)
+ return optional;
+
+ BitVector reachableWithoutJump(maxSize, false);
for (int i = maxSize - 1; i >= 0; --i) {
BasicBlock *bb = function->basicBlock(i);
@@ -5533,17 +5555,17 @@ QSet<Jump *> Optimizer::calculateOptionalJumps()
continue;
if (Jump *jump = bb->statements().last()->asJump()) {
- if (reachableWithoutJump.contains(jump->target)) {
- if (bb->statements().size() > 1)
+ if (reachableWithoutJump.at(jump->target->index())) {
+ if (bb->statements().size() - countPhis(bb)> 1)
reachableWithoutJump.clear();
- optional.insert(jump);
- reachableWithoutJump.insert(bb);
+ optional.setBit(bb->index());
+ reachableWithoutJump.setBit(bb->index());
continue;
}
}
reachableWithoutJump.clear();
- reachableWithoutJump.insert(bb);
+ reachableWithoutJump.setBit(bb->index());
}
return optional;
@@ -5642,7 +5664,7 @@ QList<IR::Move *> MoveMapping::insertMoves(BasicBlock *bb, IR::Function *functio
newMoves.reserve(_moves.size());
int insertionPoint = atEnd ? bb->statements().size() - 1 : 0;
- foreach (const Move &m, _moves) {
+ for (const Move &m : _moves) {
IR::Move *move = function->NewStmt<IR::Move>();
move->init(clone(m.to, function), clone(m.from, function));
move->swap = m.needsSwap;
@@ -5661,7 +5683,7 @@ void MoveMapping::dump() const
QTextStream os(&buf);
IRPrinter printer(&os);
os << "Move mapping has " << _moves.size() << " moves..." << endl;
- foreach (const Move &m, _moves) {
+ for (const Move &m : _moves) {
os << "\t";
printer.print(m.to);
if (m.needsSwap)
@@ -5678,8 +5700,8 @@ void MoveMapping::dump() const
MoveMapping::Action MoveMapping::schedule(const Move &m, QList<Move> &todo, QList<Move> &delayed,
QList<Move> &output, QList<Move> &swaps) const
{
- Moves usages = sourceUsages(m.to, todo) + sourceUsages(m.to, delayed);
- foreach (const Move &dependency, usages) {
+ const Moves usages = sourceUsages(m.to, todo) + sourceUsages(m.to, delayed);
+ for (const Move &dependency : usages) {
if (!output.contains(dependency)) {
if (delayed.contains(dependency)) {
// We have a cycle! Break it by swapping instead of assigning.
@@ -5690,7 +5712,7 @@ MoveMapping::Action MoveMapping::schedule(const Move &m, QList<Move> &todo, QLis
QTextStream out(&buf);
IRPrinter printer(&out);
out<<"we have a cycle! temps:" << endl;
- foreach (const Move &m, delayed) {
+ for (const Move &m : qAsConst(delayed)) {
out<<"\t";
printer.print(m.to);
out<<" <- ";
diff --git a/src/qml/compiler/qv4ssa_p.h b/src/qml/compiler/qv4ssa_p.h
index 3a787f0347..db8b6edd1a 100644
--- a/src/qml/compiler/qv4ssa_p.h
+++ b/src/qml/compiler/qv4ssa_p.h
@@ -53,6 +53,7 @@
#include "qv4jsir_p.h"
#include "qv4isel_util_p.h"
+#include <private/qv4util_p.h>
#include <QtCore/QSharedPointer>
QT_BEGIN_NAMESPACE
@@ -246,7 +247,7 @@ public:
LifeTimeIntervals::Ptr lifeTimeIntervals() const;
- QSet<IR::Jump *> calculateOptionalJumps();
+ BitVector calculateOptionalJumps();
static void showMeTheCode(Function *function, const char *marker);
@@ -340,7 +341,7 @@ public:
}
protected:
- virtual int allocateFreeSlot()
+ int allocateFreeSlot() override
{
for (int i = 0, ei = _slotIsInUse.size(); i != ei; ++i) {
if (!_slotIsInUse[i]) {
@@ -357,7 +358,7 @@ protected:
return -1;
}
- virtual void process(IR::Stmt *s)
+ void process(IR::Stmt *s) override
{
// qDebug("L%d statement %d:", _currentBasicBlock->index, s->id);
@@ -411,8 +412,8 @@ protected:
}
}
moves.order();
- QList<IR::Move *> newMoves = moves.insertMoves(_currentBasicBlock, _function, true);
- foreach (IR::Move *move, newMoves)
+ const QList<IR::Move *> newMoves = moves.insertMoves(_currentBasicBlock, _function, true);
+ for (IR::Move *move : newMoves)
visit(move);
}
}
@@ -437,13 +438,13 @@ protected:
// qDebug() << "\t - force activating temp" << t.index << "on slot" << _stackSlotForTemp[t.index];
}
- virtual void visitPhi(IR::Phi *phi)
+ void visitPhi(IR::Phi *phi) override
{
Q_UNUSED(phi);
#if !defined(QT_NO_DEBUG)
Q_ASSERT(_stackSlotForTemp.contains(phi->targetTemp->index));
Q_ASSERT(_slotIsInUse[_stackSlotForTemp[phi->targetTemp->index]]);
- foreach (IR::Expr *e, phi->incoming) {
+ for (IR::Expr *e : phi->incoming) {
if (IR::Temp *t = e->asTemp())
Q_ASSERT(_stackSlotForTemp.contains(t->index));
}
diff --git a/src/qml/configure.json b/src/qml/configure.json
new file mode 100644
index 0000000000..d22ba3b8f0
--- /dev/null
+++ b/src/qml/configure.json
@@ -0,0 +1,37 @@
+{
+ "module": "qml",
+ "depends": [
+ "core-private",
+ "network-private"
+ ],
+
+ "commandline": {
+ "options": {
+ "qml-interpreter": "boolean",
+ "qml-network": "boolean"
+ }
+ },
+
+ "features": {
+ "qml-interpreter": {
+ "label": "QML interpreter",
+ "purpose": "Support for the QML interpreter",
+ "output": [ "privateFeature" ]
+ },
+ "qml-network": {
+ "label": "QML network support",
+ "purpose": "Provides network transparency for QML",
+ "output": [ "publicFeature" ]
+ }
+ },
+
+ "summary": [
+ {
+ "section": "Qt QML",
+ "entries": [
+ "qml-interpreter",
+ "qml-network"
+ ]
+ }
+ ]
+}
diff --git a/src/qml/debugger/qqmldebug.cpp b/src/qml/debugger/qqmldebug.cpp
index 386fb60b3a..b2c4b139ee 100644
--- a/src/qml/debugger/qqmldebug.cpp
+++ b/src/qml/debugger/qqmldebug.cpp
@@ -169,4 +169,22 @@ bool QQmlDebuggingEnabler::startDebugConnector(const QString &pluginName,
return connector ? connector->open(configuration) : false;
}
+enum { HookCount = 3 };
+
+// Only add to the end, and bump version if you do.
+quintptr Q_QML_EXPORT qtDeclarativeHookData[] = {
+ // Version of this Array. Bump if you add to end.
+ 1,
+
+ // Number of entries in this array.
+ HookCount,
+
+ // TypeInformationVersion, an integral value, bumped whenever private
+ // object sizes or member offsets that are used in Qt Creator's
+ // data structure "pretty printing" change.
+ 2
+};
+
+Q_STATIC_ASSERT(HookCount == sizeof(qtDeclarativeHookData) / sizeof(qtDeclarativeHookData[0]));
+
QT_END_NAMESPACE
diff --git a/src/qml/debugger/qqmldebugconnector.cpp b/src/qml/debugger/qqmldebugconnector.cpp
index 23440e7529..029df1e748 100644
--- a/src/qml/debugger/qqmldebugconnector.cpp
+++ b/src/qml/debugger/qqmldebugconnector.cpp
@@ -134,9 +134,11 @@ QQmlDebugConnector *QQmlDebugConnector::instance()
}
if (params->instance) {
- foreach (const QJsonObject &object, metaDataForQQmlDebugService()) {
- foreach (const QJsonValue &key, object.value(QLatin1String("MetaData")).toObject()
- .value(QLatin1String("Keys")).toArray()) {
+ const auto metaData = metaDataForQQmlDebugService();
+ for (const QJsonObject &object : metaData) {
+ const auto keys = object.value(QLatin1String("MetaData")).toObject()
+ .value(QLatin1String("Keys")).toArray();
+ for (const QJsonValue &key : keys) {
QString keyString = key.toString();
if (params->services.isEmpty() || params->services.contains(keyString))
loadQQmlDebugService(keyString);
diff --git a/src/qml/debugger/qqmlmemoryprofiler.cpp b/src/qml/debugger/qqmlmemoryprofiler.cpp
index 60f6d96eaf..53d4e7ab21 100644
--- a/src/qml/debugger/qqmlmemoryprofiler.cpp
+++ b/src/qml/debugger/qqmlmemoryprofiler.cpp
@@ -38,18 +38,11 @@
****************************************************************************/
#include "qqmlmemoryprofiler_p.h"
-#include <QUrl>
QT_BEGIN_NAMESPACE
-enum LibraryState
-{
- Unloaded,
- Failed,
- Loaded
-};
-static LibraryState state = Unloaded;
+QQmlMemoryScope::LibraryState QQmlMemoryScope::state = QQmlMemoryScope::Unloaded;
typedef void (qmlmemprofile_stats)(int *allocCount, int *bytesAllocated);
typedef void (qmlmemprofile_clear)();
@@ -73,7 +66,7 @@ static qmlmemprofile_is_enabled *memprofile_is_enabled;
extern QFunctionPointer qt_linux_find_symbol_sys(const char *symbol);
#endif
-static bool openLibrary()
+bool QQmlMemoryScope::doOpenLibrary()
{
#if defined(Q_OS_LINUX) && !defined(QT_NO_LIBRARY)
if (state == Unloaded) {
@@ -97,28 +90,22 @@ static bool openLibrary()
return state == Loaded;
}
-QQmlMemoryScope::QQmlMemoryScope(const QUrl &url)
- : QQmlMemoryScope(url.path().toUtf8().constData())
-{
-}
-
-QQmlMemoryScope::QQmlMemoryScope(const char *string) : pushed(false)
+void QQmlMemoryScope::init(const char *string)
{
- if (openLibrary() && memprofile_is_enabled()) {
+ if (memprofile_is_enabled()) {
memprofile_push_location(string, 0);
pushed = true;
}
}
-QQmlMemoryScope::~QQmlMemoryScope()
+void QQmlMemoryScope::done()
{
- if (pushed)
- memprofile_pop_location();
+ memprofile_pop_location();
}
bool QQmlMemoryProfiler::isEnabled()
{
- if (openLibrary())
+ if (QQmlMemoryScope::openLibrary())
return memprofile_is_enabled();
return false;
@@ -126,31 +113,31 @@ bool QQmlMemoryProfiler::isEnabled()
void QQmlMemoryProfiler::enable()
{
- if (openLibrary())
+ if (QQmlMemoryScope::openLibrary())
memprofile_enable();
}
void QQmlMemoryProfiler::disable()
{
- if (openLibrary())
+ if (QQmlMemoryScope::openLibrary())
memprofile_disable();
}
void QQmlMemoryProfiler::clear()
{
- if (openLibrary())
+ if (QQmlMemoryScope::openLibrary())
memprofile_clear();
}
void QQmlMemoryProfiler::stats(int *allocCount, int *bytesAllocated)
{
- if (openLibrary())
+ if (QQmlMemoryScope::openLibrary())
memprofile_stats(allocCount, bytesAllocated);
}
void QQmlMemoryProfiler::save(const char *filename)
{
- if (openLibrary())
+ if (QQmlMemoryScope::openLibrary())
memprofile_save(filename);
}
diff --git a/src/qml/debugger/qqmlmemoryprofiler_p.h b/src/qml/debugger/qqmlmemoryprofiler_p.h
index 59f08704ca..fb71c999c3 100644
--- a/src/qml/debugger/qqmlmemoryprofiler_p.h
+++ b/src/qml/debugger/qqmlmemoryprofiler_p.h
@@ -52,6 +52,7 @@
//
#include <private/qtqmlglobal_p.h>
+#include <QUrl>
QT_BEGIN_NAMESPACE
@@ -62,16 +63,53 @@ QT_BEGIN_NAMESPACE
#else
-class QUrl;
-
class Q_QML_PRIVATE_EXPORT QQmlMemoryScope
{
public:
- explicit QQmlMemoryScope(const QUrl &url);
- explicit QQmlMemoryScope(const char *string);
- ~QQmlMemoryScope();
+ explicit QQmlMemoryScope(const QUrl &url)
+ : pushed(false)
+ {
+ if (Q_UNLIKELY(openLibrary()))
+ init(url.path().toUtf8().constData());
+ }
+
+ explicit QQmlMemoryScope(const char *string)
+ : pushed(false)
+ {
+ if (Q_UNLIKELY(openLibrary()))
+ init(string);
+ }
+
+ ~QQmlMemoryScope()
+ {
+ if (Q_UNLIKELY(pushed))
+ done();
+ }
+
+ enum LibraryState
+ {
+ Unloaded,
+ Failed,
+ Loaded
+ };
+
+ static bool openLibrary()
+ {
+ if (Q_LIKELY(state == Loaded))
+ return true;
+ if (state == Failed)
+ return false;
+
+ return doOpenLibrary();
+ }
private:
+ Q_NEVER_INLINE void init(const char *string);
+ Q_NEVER_INLINE void done();
+ Q_NEVER_INLINE static bool doOpenLibrary();
+
+ static LibraryState state;
+
bool pushed;
};
diff --git a/src/qml/doc/src/cppclasses/topic.qdoc b/src/qml/doc/src/cppclasses/topic.qdoc
index ddb29fbb14..133f9bc72c 100644
--- a/src/qml/doc/src/cppclasses/topic.qdoc
+++ b/src/qml/doc/src/cppclasses/topic.qdoc
@@ -91,7 +91,7 @@ at run-time using a QQmlComponent. An instance of the QQmlComponent class can
be created in C++ directly, or via the \l{QtQml::Qt::createComponent()}
{Qt.createComponent()} function in imperative QML code. Arbitrary expressions
can be calculated in C++ via the QQmlExpression class, and such expressions
-can interact directly the QML context.
+can interact directly with the QML context.
\section2 The QQmlComponent Class
@@ -106,7 +106,7 @@ how to use QQmlComponent.
The QQmlExpression class provides a way for clients to evaluate JavaScript
expressions from C++, using a particular QML evaluation context. This allows
-clients to access QML objects by id, for example. The result of evaluation
+clients to access QML objects by id, for example. The result of the evaluation
is returned as a QVariant, and the conversion rules are defined by the QML
engine.
diff --git a/src/qml/doc/src/cppintegration/data.qdoc b/src/qml/doc/src/cppintegration/data.qdoc
index cc2fe90483..ac6600f38c 100644
--- a/src/qml/doc/src/cppintegration/data.qdoc
+++ b/src/qml/doc/src/cppintegration/data.qdoc
@@ -52,8 +52,8 @@ remain with C++ by invoking QQmlEngine::setObjectOwnership() with
QQmlEngine::CppOwnership specified.
Additionally, the QML engine respects the normal QObject parent ownership
-semantics of Qt C++ objects, and will not ever take ownership of a QObject
-instance which already has a parent.
+semantics of Qt C++ objects, and will never delete a QObject instance which
+has a parent.
\section1 Basic Qt Data Types
diff --git a/src/qml/doc/src/cppintegration/exposecppattributes.qdoc b/src/qml/doc/src/cppintegration/exposecppattributes.qdoc
index f5aea0b01a..ed0d049564 100644
--- a/src/qml/doc/src/cppintegration/exposecppattributes.qdoc
+++ b/src/qml/doc/src/cppintegration/exposecppattributes.qdoc
@@ -71,7 +71,7 @@ type that is supported by the QML engine.
By default, the engine supports a number of Qt C++ types and can automatically
convert them as appropriately when used from QML. Additionally, C++ classes
that are \l{Registering C++ types with the QML type system}{registered} with
-the QML type system can be can be used as data types, as can their enums if
+the QML type system can be used as data types, as can their enums if
appropriately registered. See \l{qtqml-cppintegration-data.html}{Data Type
Conversion Between QML and C++} for further information.
diff --git a/src/qml/doc/src/javascript/dynamicobjectcreation.qdoc b/src/qml/doc/src/javascript/dynamicobjectcreation.qdoc
index acd7188db7..fffa783851 100644
--- a/src/qml/doc/src/javascript/dynamicobjectcreation.qdoc
+++ b/src/qml/doc/src/javascript/dynamicobjectcreation.qdoc
@@ -143,7 +143,7 @@ If the string of QML imports files using relative paths, the path should be
relative to the file in which the parent object (the second argument to the
method) is defined.
-\important When building static QML applications, which is enforced on platforms like iOS,
+\important When building static QML applications,
QML files are scanned to detect import dependencies. That way, all
necessary plugins and resources are resolved at compile time.
However, only explicit import statements are considered (those found at
diff --git a/src/qml/doc/src/javascript/functionlist.qdoc b/src/qml/doc/src/javascript/functionlist.qdoc
index b9a25a2440..f5b1ed3cf1 100644
--- a/src/qml/doc/src/javascript/functionlist.qdoc
+++ b/src/qml/doc/src/javascript/functionlist.qdoc
@@ -143,6 +143,8 @@
\li toLocaleString()
\li concat([item1 [, item2 [, ...]]])
\li join(separator)
+ \li find(callbackfn [, thisArg]) // ECMAScript 6: Added in Qt 5.9
+ \li findIndex(callbackfn [, thisArg]) // ECMAScript 6: Added in Qt 5.9
\li pop()
\li push([item1 [, item2 [, ...]]])
\li reverse()
diff --git a/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc b/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc
index 4b4b25796c..03a7ddfb19 100644
--- a/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc
+++ b/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc
@@ -43,7 +43,8 @@ For example, below is a document that declares a \l Rectangle with a child \l Mo
import QtQuick 2.0
Rectangle {
- width: 100; height: 100
+ property int side: 100
+ width: side; height: side
color: "red"
MouseArea {
@@ -87,7 +88,7 @@ For example, the root object type in the \c SquareButton.qml file above is \l Re
import QtQuick 2.0
Column {
- SquareButton { width: 50; height: 50 }
+ SquareButton { side: 50 }
SquareButton { x: 50; color: "blue" }
SquareButton { radius: 10 }
}
@@ -112,7 +113,8 @@ Rectangle {
root.color = Qt.rgba(Math.random(), Math.random(), Math.random(), 1)
}
- width: 100; height: 100
+ property int side: 100
+ width: side; height: side
color: "red"
MouseArea {
diff --git a/src/qml/doc/src/qmllanguageref/documents/scope.qdoc b/src/qml/doc/src/qmllanguageref/documents/scope.qdoc
index 3e3bbaca98..eaf1747a6d 100644
--- a/src/qml/doc/src/qmllanguageref/documents/scope.qdoc
+++ b/src/qml/doc/src/qmllanguageref/documents/scope.qdoc
@@ -105,7 +105,7 @@ ListView {
\section1 Binding Scope Object
-An object which has a \l{Property Binding}{property binding} is known has the
+An object which has a \l{Property Binding}{property binding} is known as the
binding's \e{scope object}. In the following example, the \l Item object is
the binding's scope object.
diff --git a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc
index 3692605c18..030eb72b5f 100644
--- a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc
+++ b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc
@@ -191,7 +191,7 @@ which was then imported by the client), then a property of type
\section3 Assigning Values to Property Attributes
-The value of a property of an object instance may specified in two separate ways:
+The value of a property of an object instance may be specified in two separate ways:
\list
\li a value assignment on initialization
\li an imperative value assignment
@@ -724,7 +724,8 @@ Rectangle {
signal activated(real xPosition, real yPosition)
signal deactivated
- width: 100; height: 100
+ property int side: 100
+ width: side; height: side
MouseArea {
anchors.fill: parent
diff --git a/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc b/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc
index 602b202ed4..4a022f2b0b 100644
--- a/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc
+++ b/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc
@@ -187,7 +187,8 @@ Rectangle {
signal activated(real xPosition, real yPosition)
- width: 100; height: 100
+ property int side: 100
+ width: side; height: side
MouseArea {
anchors.fill: parent
diff --git a/src/qml/jit/qv4assembler.cpp b/src/qml/jit/qv4assembler.cpp
index 5e05f14192..e1acc33f82 100644
--- a/src/qml/jit/qv4assembler.cpp
+++ b/src/qml/jit/qv4assembler.cpp
@@ -196,8 +196,30 @@ void Assembler::generateCJumpOnNonZero(RegisterID reg, IR::BasicBlock *currentBl
generateCJumpOnCompare(NotEqual, reg, TrustedImm32(0), currentBlock, trueBlock, falseBlock);
}
-void Assembler::generateCJumpOnCompare(RelationalCondition cond, RegisterID left,TrustedImm32 right,
- IR::BasicBlock *currentBlock, IR::BasicBlock *trueBlock,
+#ifdef QV4_USE_64_BIT_VALUE_ENCODING
+void Assembler::generateCJumpOnCompare(RelationalCondition cond,
+ RegisterID left,
+ TrustedImm64 right,
+ IR::BasicBlock *currentBlock,
+ IR::BasicBlock *trueBlock,
+ IR::BasicBlock *falseBlock)
+{
+ if (trueBlock == _nextBlock) {
+ Jump target = branch64(invert(cond), left, right);
+ addPatch(falseBlock, target);
+ } else {
+ Jump target = branch64(cond, left, right);
+ addPatch(trueBlock, target);
+ jumpToBlock(currentBlock, falseBlock);
+ }
+}
+#endif
+
+void Assembler::generateCJumpOnCompare(RelationalCondition cond,
+ RegisterID left,
+ TrustedImm32 right,
+ IR::BasicBlock *currentBlock,
+ IR::BasicBlock *trueBlock,
IR::BasicBlock *falseBlock)
{
if (trueBlock == _nextBlock) {
@@ -210,8 +232,11 @@ void Assembler::generateCJumpOnCompare(RelationalCondition cond, RegisterID left
}
}
-void Assembler::generateCJumpOnCompare(RelationalCondition cond, RegisterID left, RegisterID right,
- IR::BasicBlock *currentBlock, IR::BasicBlock *trueBlock,
+void Assembler::generateCJumpOnCompare(RelationalCondition cond,
+ RegisterID left,
+ RegisterID right,
+ IR::BasicBlock *currentBlock,
+ IR::BasicBlock *trueBlock,
IR::BasicBlock *falseBlock)
{
if (trueBlock == _nextBlock) {
@@ -408,9 +433,8 @@ Assembler::Jump Assembler::genTryDoubleConversion(IR::Expr *src, Assembler::FPRe
// not an int, check if it's a double:
isNoInt.link(this);
#ifdef QV4_USE_64_BIT_VALUE_ENCODING
- and32(Assembler::TrustedImm32(Value::IsDouble_Mask), Assembler::ScratchRegister);
- Assembler::Jump isNoDbl = branch32(Assembler::Equal, Assembler::ScratchRegister,
- Assembler::TrustedImm32(0));
+ rshift32(TrustedImm32(Value::IsDoubleTag_Shift), ScratchRegister);
+ Assembler::Jump isNoDbl = branch32(Equal, ScratchRegister, TrustedImm32(0));
#else
and32(Assembler::TrustedImm32(Value::NotDouble_Mask), Assembler::ScratchRegister);
Assembler::Jump isNoDbl = branch32(Assembler::Equal, Assembler::ScratchRegister,
diff --git a/src/qml/jit/qv4assembler_p.h b/src/qml/jit/qv4assembler_p.h
index 7d4d90882a..94478cd9cd 100644
--- a/src/qml/jit/qv4assembler_p.h
+++ b/src/qml/jit/qv4assembler_p.h
@@ -319,6 +319,11 @@ public:
void addPatch(DataLabelPtr patch, IR::BasicBlock *target);
void generateCJumpOnNonZero(RegisterID reg, IR::BasicBlock *currentBlock,
IR::BasicBlock *trueBlock, IR::BasicBlock *falseBlock);
+#ifdef QV4_USE_64_BIT_VALUE_ENCODING
+ void generateCJumpOnCompare(RelationalCondition cond, RegisterID left, TrustedImm64 right,
+ IR::BasicBlock *currentBlock, IR::BasicBlock *trueBlock,
+ IR::BasicBlock *falseBlock);
+#endif
void generateCJumpOnCompare(RelationalCondition cond, RegisterID left, TrustedImm32 right,
IR::BasicBlock *currentBlock, IR::BasicBlock *trueBlock,
IR::BasicBlock *falseBlock);
diff --git a/src/qml/jit/qv4isel_masm.cpp b/src/qml/jit/qv4isel_masm.cpp
index d06d6907e5..515b8aea4d 100644
--- a/src/qml/jit/qv4isel_masm.cpp
+++ b/src/qml/jit/qv4isel_masm.cpp
@@ -113,8 +113,7 @@ static void printDisassembledOutputWithCalls(QByteArray processedOutput, const Q
{
for (QHash<void*, const char*>::ConstIterator it = functions.begin(), end = functions.end();
it != end; ++it) {
- QByteArray ptrString = QByteArray::number(quintptr(it.key()), 16);
- ptrString.prepend("0x");
+ const QByteArray ptrString = "0x" + QByteArray::number(quintptr(it.key()), 16);
int idx = processedOutput.indexOf(ptrString);
if (idx < 0)
continue;
@@ -191,11 +190,8 @@ JSC::MacroAssemblerCodeRef Assembler::link(int *codeSize)
WTF::setDataFile(new QIODevicePrintStream(&buf));
name = _function->name->toUtf8();
- if (name.isEmpty()) {
- name = QByteArray::number(quintptr(_function), 16);
- name.prepend("IR::Function(0x");
- name.append(')');
- }
+ if (name.isEmpty())
+ name = "IR::Function(0x" + QByteArray::number(quintptr(_function), 16) + ')';
codeRef = linkBuffer.finalizeCodeWithDisassembly("%s", name.data());
WTF::setDataFile(stderr);
@@ -232,11 +228,8 @@ JSC::MacroAssemblerCodeRef Assembler::link(int *codeSize)
// this may have been pre-populated, if QV4_SHOW_ASM was on
if (name.isEmpty()) {
name = _function->name->toUtf8();
- if (name.isEmpty()) {
- name = QByteArray::number(quintptr(_function), 16);
- name.prepend("IR::Function(0x");
- name.append(')');
- }
+ if (name.isEmpty())
+ name = "IR::Function(0x" + QByteArray::number(quintptr(_function), 16) + ')';
}
fprintf(pmap, "%llx %x %.*s\n",
@@ -288,7 +281,7 @@ void InstructionSelection::run(int functionIndex)
IR::Optimizer::showMeTheCode(_function, "After stack slot allocation");
calculateRegistersToSave(Assembler::getRegisterInfo()); // FIXME: this saves all registers. We can probably do with a subset: those that are not used by the register allocator.
}
- QSet<IR::Jump *> removableJumps = opt.calculateOptionalJumps();
+ BitVector removableJumps = opt.calculateOptionalJumps();
qSwap(_removableJumps, removableJumps);
Assembler* oldAssembler = _as;
@@ -693,7 +686,7 @@ void InstructionSelection::loadString(const QString &str, IR::Expr *target)
#else
_as->store32(Assembler::ReturnValueRegister, destAddr);
destAddr.offset += 4;
- _as->store32(Assembler::TrustedImm32(QV4::Value::Managed_Type), destAddr);
+ _as->store32(Assembler::TrustedImm32(QV4::Value::Managed_Type_Internal), destAddr);
#endif
}
@@ -955,7 +948,7 @@ void InstructionSelection::swapValues(IR::Expr *source, IR::Expr *target)
tag = QV4::Value::Integer_Type_Internal;
break;
default:
- tag = QV4::Value::Undefined_Type;
+ tag = 31337; // bogus value
Q_UNREACHABLE();
}
_as->store32(Assembler::TrustedImm32(tag), addr);
@@ -1099,7 +1092,7 @@ void InstructionSelection::convertTypeToDouble(IR::Expr *source, IR::Expr *targe
// not an int, check if it's NOT a double:
isNoInt.link(_as);
#ifdef QV4_USE_64_BIT_VALUE_ENCODING
- _as->and32(Assembler::TrustedImm32(Value::IsDouble_Mask), Assembler::ScratchRegister);
+ _as->rshift32(Assembler::TrustedImm32(Value::IsDoubleTag_Shift), Assembler::ScratchRegister);
Assembler::Jump isDbl = _as->branch32(Assembler::NotEqual, Assembler::ScratchRegister,
Assembler::TrustedImm32(0));
#else
@@ -1190,10 +1183,15 @@ void InstructionSelection::convertTypeToSInt32(IR::Expr *source, IR::Expr *targe
_as->load64(addr, Assembler::ScratchRegister);
_as->move(Assembler::ScratchRegister, Assembler::ReturnValueRegister);
- // check if it's a number
- _as->urshift64(Assembler::TrustedImm32(QV4::Value::IsNumber_Shift), Assembler::ScratchRegister);
- Assembler::Jump isInt = _as->branch32(Assembler::Equal, Assembler::ScratchRegister, Assembler::TrustedImm32(1));
- Assembler::Jump fallback = _as->branch32(Assembler::Equal, Assembler::ScratchRegister, Assembler::TrustedImm32(0));
+ // check if it's integer convertible
+ _as->urshift64(Assembler::TrustedImm32(QV4::Value::IsIntegerConvertible_Shift), Assembler::ScratchRegister);
+ Assembler::Jump isIntConvertible = _as->branch32(Assembler::Equal, Assembler::ScratchRegister, Assembler::TrustedImm32(3));
+
+ // nope, not integer convertible, so check for a double:
+ _as->urshift64(Assembler::TrustedImm32(
+ QV4::Value::IsDoubleTag_Shift - QV4::Value::IsIntegerConvertible_Shift),
+ Assembler::ScratchRegister);
+ Assembler::Jump fallback = _as->branch32(Assembler::GreaterThan, Assembler::ScratchRegister, Assembler::TrustedImm32(0));
// it's a double
_as->move(Assembler::TrustedImm64(QV4::Value::NaNEncodeMask), Assembler::ScratchRegister);
@@ -1208,7 +1206,7 @@ void InstructionSelection::convertTypeToSInt32(IR::Expr *source, IR::Expr *targe
generateRuntimeCall(Assembler::ReturnValueRegister, toInt,
_as->loadAddress(Assembler::ScratchRegister, source));
- isInt.link(_as);
+ isIntConvertible.link(_as);
success.link(_as);
IR::Temp *targetTemp = target->asTemp();
if (!targetTemp || targetTemp->kind == IR::Temp::StackSlot) {
@@ -1384,7 +1382,7 @@ void InstructionSelection::constructValue(IR::Expr *value, IR::ExprList *args, I
void InstructionSelection::visitJump(IR::Jump *s)
{
- if (!_removableJumps.contains(s))
+ if (!_removableJumps.at(_block->index()))
_as->jumpToBlock(_block, s->target);
}
@@ -1403,7 +1401,7 @@ void InstructionSelection::visitCJump(IR::CJump *s)
Address temp = _as->loadAddress(Assembler::ScratchRegister, s->cond);
Address tag = temp;
tag.offset += QV4::Value::tagOffset();
- Assembler::Jump booleanConversion = _as->branch32(Assembler::NotEqual, tag, Assembler::TrustedImm32(QV4::Value::Boolean_Type));
+ Assembler::Jump booleanConversion = _as->branch32(Assembler::NotEqual, tag, Assembler::TrustedImm32(QV4::Value::Boolean_Type_Internal));
Address data = temp;
data.offset += QV4::Value::valueOffset();
@@ -1570,7 +1568,7 @@ void InstructionSelection::visitRet(IR::Ret *s)
tag = QV4::Value::Boolean_Type_Internal;
break;
default:
- tag = QV4::Value::Undefined_Type;
+ tag = 31337; // bogus value
Q_UNREACHABLE();
}
_as->or64(Assembler::TrustedImm64(tag << 32),
@@ -1751,9 +1749,9 @@ void InstructionSelection::visitCJumpStrict(IR::Binop *binop, IR::BasicBlock *tr
{
Q_ASSERT(binop->op == IR::OpStrictEqual || binop->op == IR::OpStrictNotEqual);
- if (visitCJumpStrictNullUndefined(IR::NullType, binop, trueBlock, falseBlock))
+ if (visitCJumpStrictNull(binop, trueBlock, falseBlock))
return;
- if (visitCJumpStrictNullUndefined(IR::UndefinedType, binop, trueBlock, falseBlock))
+ if (visitCJumpStrictUndefined(binop, trueBlock, falseBlock))
return;
if (visitCJumpStrictBool(binop, trueBlock, falseBlock))
return;
@@ -1769,16 +1767,14 @@ void InstructionSelection::visitCJumpStrict(IR::Binop *binop, IR::BasicBlock *tr
}
// Only load the non-null temp.
-bool InstructionSelection::visitCJumpStrictNullUndefined(IR::Type nullOrUndef, IR::Binop *binop,
- IR::BasicBlock *trueBlock,
- IR::BasicBlock *falseBlock)
+bool InstructionSelection::visitCJumpStrictNull(IR::Binop *binop,
+ IR::BasicBlock *trueBlock,
+ IR::BasicBlock *falseBlock)
{
- Q_ASSERT(nullOrUndef == IR::NullType || nullOrUndef == IR::UndefinedType);
-
IR::Expr *varSrc = 0;
- if (binop->left->type == IR::VarType && binop->right->type == nullOrUndef)
+ if (binop->left->type == IR::VarType && binop->right->type == IR::NullType)
varSrc = binop->left;
- else if (binop->left->type == nullOrUndef && binop->right->type == IR::VarType)
+ else if (binop->left->type == IR::NullType && binop->right->type == IR::VarType)
varSrc = binop->right;
if (!varSrc)
return false;
@@ -1789,7 +1785,7 @@ bool InstructionSelection::visitCJumpStrictNullUndefined(IR::Type nullOrUndef, I
}
if (IR::Const *c = varSrc->asConst()) {
- if (c->type == nullOrUndef)
+ if (c->type == IR::NullType)
_as->jumpToBlock(_block, trueBlock);
else
_as->jumpToBlock(_block, falseBlock);
@@ -1802,9 +1798,54 @@ bool InstructionSelection::visitCJumpStrictNullUndefined(IR::Type nullOrUndef, I
_as->load32(tagAddr, tagReg);
Assembler::RelationalCondition cond = binop->op == IR::OpStrictEqual ? Assembler::Equal
- : Assembler::NotEqual;
- const Assembler::TrustedImm32 tag(nullOrUndef == IR::NullType ? int(QV4::Value::Null_Type_Internal)
- : int(QV4::Value::Undefined_Type));
+ : Assembler::NotEqual;
+ const Assembler::TrustedImm32 tag(QV4::Value::Null_Type_Internal);
+ _as->generateCJumpOnCompare(cond, tagReg, tag, _block, trueBlock, falseBlock);
+ return true;
+}
+
+bool InstructionSelection::visitCJumpStrictUndefined(IR::Binop *binop,
+ IR::BasicBlock *trueBlock,
+ IR::BasicBlock *falseBlock)
+{
+ IR::Expr *varSrc = 0;
+ if (binop->left->type == IR::VarType && binop->right->type == IR::UndefinedType)
+ varSrc = binop->left;
+ else if (binop->left->type == IR::UndefinedType && binop->right->type == IR::VarType)
+ varSrc = binop->right;
+ if (!varSrc)
+ return false;
+
+ if (varSrc->asTemp() && varSrc->asTemp()->kind == IR::Temp::PhysicalRegister) {
+ _as->jumpToBlock(_block, falseBlock);
+ return true;
+ }
+
+ if (IR::Const *c = varSrc->asConst()) {
+ if (c->type == IR::UndefinedType)
+ _as->jumpToBlock(_block, trueBlock);
+ else
+ _as->jumpToBlock(_block, falseBlock);
+ return true;
+ }
+
+ Assembler::RelationalCondition cond = binop->op == IR::OpStrictEqual ? Assembler::Equal
+ : Assembler::NotEqual;
+ const Assembler::RegisterID tagReg = Assembler::ScratchRegister;
+#ifdef QV4_USE_64_BIT_VALUE_ENCODING
+ Assembler::Pointer addr = _as->loadAddress(Assembler::ScratchRegister, varSrc);
+ _as->load64(addr, tagReg);
+ const Assembler::TrustedImm64 tag(0);
+#else // !QV4_USE_64_BIT_VALUE_ENCODING
+ Assembler::Pointer tagAddr = _as->loadAddress(Assembler::ScratchRegister, varSrc);
+ _as->load32(tagAddr, tagReg);
+ Assembler::Jump j = _as->branch32(Assembler::invert(cond), tagReg, Assembler::TrustedImm32(0));
+ _as->addPatch(falseBlock, j);
+
+ tagAddr.offset += 4;
+ _as->load32(tagAddr, tagReg);
+ const Assembler::TrustedImm32 tag(QV4::Value::Managed_Type_Internal);
+#endif
_as->generateCJumpOnCompare(cond, tagReg, tag, _block, trueBlock, falseBlock);
return true;
}
@@ -1895,10 +1936,14 @@ bool InstructionSelection::visitCJumpNullUndefined(IR::Type nullOrUndef, IR::Bin
if (binop->op == IR::OpNotEqual)
qSwap(trueBlock, falseBlock);
Assembler::Jump isNull = _as->branch32(Assembler::Equal, tagReg, Assembler::TrustedImm32(int(QV4::Value::Null_Type_Internal)));
- Assembler::Jump isUndefined = _as->branch32(Assembler::Equal, tagReg, Assembler::TrustedImm32(int(QV4::Value::Undefined_Type)));
+ Assembler::Jump isNotUndefinedTag = _as->branch32(Assembler::NotEqual, tagReg, Assembler::TrustedImm32(int(QV4::Value::Managed_Type_Internal)));
+ tagAddr.offset -= 4;
+ _as->load32(tagAddr, tagReg);
+ Assembler::Jump isNotUndefinedValue = _as->branch32(Assembler::NotEqual, tagReg, Assembler::TrustedImm32(0));
_as->addPatch(trueBlock, isNull);
- _as->addPatch(trueBlock, isUndefined);
- _as->jumpToBlock(_block, falseBlock);
+ _as->addPatch(falseBlock, isNotUndefinedTag);
+ _as->addPatch(falseBlock, isNotUndefinedValue);
+ _as->jumpToBlock(_block, trueBlock);
return true;
}
diff --git a/src/qml/jit/qv4isel_masm_p.h b/src/qml/jit/qv4isel_masm_p.h
index 88241bd503..5c693e0736 100644
--- a/src/qml/jit/qv4isel_masm_p.h
+++ b/src/qml/jit/qv4isel_masm_p.h
@@ -54,6 +54,7 @@
#include "private/qv4jsir_p.h"
#include "private/qv4isel_p.h"
#include "private/qv4isel_util_p.h"
+#include "private/qv4util_p.h"
#include "private/qv4value_p.h"
#include "private/qv4lookup_p.h"
@@ -171,8 +172,8 @@ protected:
bool visitCJumpSInt32(IR::AluOp op, IR::Expr *left, IR::Expr *right,
IR::BasicBlock *iftrue, IR::BasicBlock *iffalse);
void visitCJumpStrict(IR::Binop *binop, IR::BasicBlock *trueBlock, IR::BasicBlock *falseBlock);
- bool visitCJumpStrictNullUndefined(IR::Type nullOrUndef, IR::Binop *binop,
- IR::BasicBlock *trueBlock, IR::BasicBlock *falseBlock);
+ bool visitCJumpStrictNull(IR::Binop *binop, IR::BasicBlock *trueBlock, IR::BasicBlock *falseBlock);
+ bool visitCJumpStrictUndefined(IR::Binop *binop, IR::BasicBlock *trueBlock, IR::BasicBlock *falseBlock);
bool visitCJumpStrictBool(IR::Binop *binop, IR::BasicBlock *trueBlock, IR::BasicBlock *falseBlock);
bool visitCJumpNullUndefined(IR::Type nullOrUndef, IR::Binop *binop,
IR::BasicBlock *trueBlock, IR::BasicBlock *falseBlock);
@@ -272,7 +273,7 @@ private:
}
IR::BasicBlock *_block;
- QSet<IR::Jump *> _removableJumps;
+ BitVector _removableJumps;
Assembler* _as;
QScopedPointer<CompilationUnit> compilationUnit;
diff --git a/src/qml/jit/qv4regalloc.cpp b/src/qml/jit/qv4regalloc.cpp
index 406b9096ea..63d542b5c8 100644
--- a/src/qml/jit/qv4regalloc.cpp
+++ b/src/qml/jit/qv4regalloc.cpp
@@ -272,32 +272,32 @@ public:
}
protected: // IRDecoder
- virtual void callBuiltinInvalid(IR::Name *, IR::ExprList *, IR::Expr *) {}
- virtual void callBuiltinTypeofQmlContextProperty(IR::Expr *, IR::Member::MemberKind, int, IR::Expr *) {}
- virtual void callBuiltinTypeofMember(IR::Expr *, const QString &, IR::Expr *) {}
- virtual void callBuiltinTypeofSubscript(IR::Expr *, IR::Expr *, IR::Expr *) {}
- virtual void callBuiltinTypeofName(const QString &, IR::Expr *) {}
- virtual void callBuiltinTypeofValue(IR::Expr *, IR::Expr *) {}
- virtual void callBuiltinDeleteMember(IR::Expr *, const QString &, IR::Expr *) {}
- virtual void callBuiltinDeleteSubscript(IR::Expr *, IR::Expr *, IR::Expr *) {}
- virtual void callBuiltinDeleteName(const QString &, IR::Expr *) {}
- virtual void callBuiltinDeleteValue(IR::Expr *) {}
- virtual void callBuiltinThrow(IR::Expr *) {}
- virtual void callBuiltinReThrow() {}
- virtual void callBuiltinUnwindException(IR::Expr *) {}
- virtual void callBuiltinPushCatchScope(const QString &) {};
- virtual void callBuiltinForeachIteratorObject(IR::Expr *, IR::Expr *) {}
+ void callBuiltinInvalid(IR::Name *, IR::ExprList *, IR::Expr *) override {}
+ void callBuiltinTypeofQmlContextProperty(IR::Expr *, IR::Member::MemberKind, int, IR::Expr *) override {}
+ void callBuiltinTypeofMember(IR::Expr *, const QString &, IR::Expr *) override {}
+ void callBuiltinTypeofSubscript(IR::Expr *, IR::Expr *, IR::Expr *) override {}
+ void callBuiltinTypeofName(const QString &, IR::Expr *) override {}
+ void callBuiltinTypeofValue(IR::Expr *, IR::Expr *) override {}
+ void callBuiltinDeleteMember(IR::Expr *, const QString &, IR::Expr *) override {}
+ void callBuiltinDeleteSubscript(IR::Expr *, IR::Expr *, IR::Expr *) override {}
+ void callBuiltinDeleteName(const QString &, IR::Expr *) override {}
+ void callBuiltinDeleteValue(IR::Expr *) override {}
+ void callBuiltinThrow(IR::Expr *) override {}
+ void callBuiltinReThrow() override {}
+ void callBuiltinUnwindException(IR::Expr *) override {}
+ void callBuiltinPushCatchScope(const QString &) override {};
+ void callBuiltinForeachIteratorObject(IR::Expr *, IR::Expr *) override {}
virtual void callBuiltinForeachNextProperty(IR::Temp *, IR::Temp *) {}
- virtual void callBuiltinForeachNextPropertyname(IR::Expr *, IR::Expr *) {}
- virtual void callBuiltinPushWithScope(IR::Expr *) {}
- virtual void callBuiltinPopScope() {}
- virtual void callBuiltinDeclareVar(bool , const QString &) {}
- virtual void callBuiltinDefineArray(IR::Expr *, IR::ExprList *) {}
- virtual void callBuiltinDefineObjectLiteral(IR::Expr *, int, IR::ExprList *, IR::ExprList *, bool) {}
- virtual void callBuiltinSetupArgumentObject(IR::Expr *) {}
- virtual void callBuiltinConvertThisToObject() {}
+ void callBuiltinForeachNextPropertyname(IR::Expr *, IR::Expr *) override {}
+ void callBuiltinPushWithScope(IR::Expr *) override {}
+ void callBuiltinPopScope() override {}
+ void callBuiltinDeclareVar(bool , const QString &) override {}
+ void callBuiltinDefineArray(IR::Expr *, IR::ExprList *) override {}
+ void callBuiltinDefineObjectLiteral(IR::Expr *, int, IR::ExprList *, IR::ExprList *, bool) override {}
+ void callBuiltinSetupArgumentObject(IR::Expr *) override {}
+ void callBuiltinConvertThisToObject() override {}
- virtual void callValue(IR::Expr *value, IR::ExprList *args, IR::Expr *result)
+ void callValue(IR::Expr *value, IR::ExprList *args, IR::Expr *result) override
{
addDef(result);
if (IR::Temp *tempValue = value->asTemp())
@@ -306,7 +306,8 @@ protected: // IRDecoder
addCall();
}
- virtual void callQmlContextProperty(IR::Expr *base, IR::Member::MemberKind /*kind*/, int propertyIndex, IR::ExprList *args, IR::Expr *result)
+ void callQmlContextProperty(IR::Expr *base, IR::Member::MemberKind /*kind*/, int propertyIndex,
+ IR::ExprList *args, IR::Expr *result) override
{
Q_UNUSED(propertyIndex)
@@ -316,8 +317,8 @@ protected: // IRDecoder
addCall();
}
- virtual void callProperty(IR::Expr *base, const QString &name, IR::ExprList *args,
- IR::Expr *result)
+ void callProperty(IR::Expr *base, const QString &name, IR::ExprList *args,
+ IR::Expr *result) override
{
Q_UNUSED(name)
@@ -327,8 +328,8 @@ protected: // IRDecoder
addCall();
}
- virtual void callSubscript(IR::Expr *base, IR::Expr *index, IR::ExprList *args,
- IR::Expr *result)
+ void callSubscript(IR::Expr *base, IR::Expr *index, IR::ExprList *args,
+ IR::Expr *result) override
{
addDef(result);
addUses(base->asTemp(), Use::CouldHaveRegister);
@@ -337,7 +338,7 @@ protected: // IRDecoder
addCall();
}
- virtual void convertType(IR::Expr *source, IR::Expr *target)
+ void convertType(IR::Expr *source, IR::Expr *target) override
{
addDef(target);
@@ -410,14 +411,14 @@ protected: // IRDecoder
addHint(target->asTemp(), sourceTemp);
}
- virtual void constructActivationProperty(IR::Name *, IR::ExprList *args, IR::Expr *result)
+ void constructActivationProperty(IR::Name *, IR::ExprList *args, IR::Expr *result) override
{
addDef(result);
addUses(args, Use::CouldHaveRegister);
addCall();
}
- virtual void constructProperty(IR::Expr *base, const QString &, IR::ExprList *args, IR::Expr *result)
+ void constructProperty(IR::Expr *base, const QString &, IR::ExprList *args, IR::Expr *result) override
{
addDef(result);
addUses(base, Use::CouldHaveRegister);
@@ -425,7 +426,7 @@ protected: // IRDecoder
addCall();
}
- virtual void constructValue(IR::Expr *value, IR::ExprList *args, IR::Expr *result)
+ void constructValue(IR::Expr *value, IR::ExprList *args, IR::Expr *result) override
{
addDef(result);
addUses(value, Use::CouldHaveRegister);
@@ -433,24 +434,24 @@ protected: // IRDecoder
addCall();
}
- virtual void loadThisObject(IR::Expr *temp)
+ void loadThisObject(IR::Expr *temp) override
{
addDef(temp);
}
- virtual void loadQmlContext(IR::Expr *temp)
+ void loadQmlContext(IR::Expr *temp) override
{
addDef(temp);
addCall();
}
- virtual void loadQmlImportedScripts(IR::Expr *temp)
+ void loadQmlImportedScripts(IR::Expr *temp) override
{
addDef(temp);
addCall();
}
- virtual void loadQmlSingleton(const QString &/*name*/, Expr *temp)
+ void loadQmlSingleton(const QString &/*name*/, Expr *temp) override
{
Q_UNUSED(temp);
@@ -458,21 +459,21 @@ protected: // IRDecoder
addCall();
}
- virtual void loadConst(IR::Const *sourceConst, Expr *targetTemp)
+ void loadConst(IR::Const *sourceConst, Expr *targetTemp) override
{
Q_UNUSED(sourceConst);
addDef(targetTemp);
}
- virtual void loadString(const QString &str, Expr *targetTemp)
+ void loadString(const QString &str, Expr *targetTemp) override
{
Q_UNUSED(str);
addDef(targetTemp);
}
- virtual void loadRegexp(IR::RegExp *sourceRegexp, Expr *targetTemp)
+ void loadRegexp(IR::RegExp *sourceRegexp, Expr *targetTemp) override
{
Q_UNUSED(sourceRegexp);
@@ -480,19 +481,19 @@ protected: // IRDecoder
addCall();
}
- virtual void getActivationProperty(const IR::Name *, Expr *temp)
+ void getActivationProperty(const IR::Name *, Expr *temp) override
{
addDef(temp);
addCall();
}
- virtual void setActivationProperty(IR::Expr *source, const QString &)
+ void setActivationProperty(IR::Expr *source, const QString &) override
{
addUses(source->asTemp(), Use::CouldHaveRegister);
addCall();
}
- virtual void initClosure(IR::Closure *closure, Expr *target)
+ void initClosure(IR::Closure *closure, Expr *target) override
{
Q_UNUSED(closure);
@@ -500,49 +501,52 @@ protected: // IRDecoder
addCall();
}
- virtual void getProperty(IR::Expr *base, const QString &, Expr *target)
+ void getProperty(IR::Expr *base, const QString &, Expr *target) override
{
addDef(target);
addUses(base->asTemp(), Use::CouldHaveRegister);
addCall();
}
- virtual void setProperty(IR::Expr *source, IR::Expr *targetBase, const QString &)
+ void setProperty(IR::Expr *source, IR::Expr *targetBase, const QString &) override
{
addUses(source->asTemp(), Use::CouldHaveRegister);
addUses(targetBase->asTemp(), Use::CouldHaveRegister);
addCall();
}
- virtual void setQmlContextProperty(IR::Expr *source, IR::Expr *targetBase, IR::Member::MemberKind /*kind*/, int /*propertyIndex*/)
+ void setQmlContextProperty(IR::Expr *source, IR::Expr *targetBase,
+ IR::Member::MemberKind /*kind*/, int /*propertyIndex*/) override
{
addUses(source->asTemp(), Use::CouldHaveRegister);
addUses(targetBase->asTemp(), Use::CouldHaveRegister);
addCall();
}
- virtual void setQObjectProperty(IR::Expr *source, IR::Expr *targetBase, int /*propertyIndex*/)
+ void setQObjectProperty(IR::Expr *source, IR::Expr *targetBase, int /*propertyIndex*/) override
{
addUses(source->asTemp(), Use::CouldHaveRegister);
addUses(targetBase->asTemp(), Use::CouldHaveRegister);
addCall();
}
- virtual void getQmlContextProperty(IR::Expr *base, IR::Member::MemberKind /*kind*/, int /*index*/, bool /*captureRequired*/, IR::Expr *target)
+ void getQmlContextProperty(IR::Expr *base, IR::Member::MemberKind /*kind*/, int /*index*/,
+ bool /*captureRequired*/, IR::Expr *target) override
{
addDef(target);
addUses(base->asTemp(), Use::CouldHaveRegister);
addCall();
}
- virtual void getQObjectProperty(IR::Expr *base, int /*propertyIndex*/, bool /*captureRequired*/, bool /*isSingleton*/, int /*attachedPropertiesId*/, IR::Expr *target)
+ void getQObjectProperty(IR::Expr *base, int /*propertyIndex*/, bool /*captureRequired*/,
+ bool /*isSingleton*/, int /*attachedPropertiesId*/, IR::Expr *target) override
{
addDef(target);
addUses(base->asTemp(), Use::CouldHaveRegister);
addCall();
}
- virtual void getElement(IR::Expr *base, IR::Expr *index, Expr *target)
+ void getElement(IR::Expr *base, IR::Expr *index, Expr *target) override
{
addDef(target);
addUses(base->asTemp(), Use::CouldHaveRegister);
@@ -550,7 +554,7 @@ protected: // IRDecoder
addCall();
}
- virtual void setElement(IR::Expr *source, IR::Expr *targetBase, IR::Expr *targetIndex)
+ void setElement(IR::Expr *source, IR::Expr *targetBase, IR::Expr *targetIndex) override
{
addUses(source->asTemp(), Use::CouldHaveRegister);
addUses(targetBase->asTemp(), Use::CouldHaveRegister);
@@ -558,7 +562,7 @@ protected: // IRDecoder
addCall();
}
- virtual void copyValue(Expr *source, Expr *target)
+ void copyValue(Expr *source, Expr *target) override
{
addDef(target);
Temp *sourceTemp = source->asTemp();
@@ -570,13 +574,13 @@ protected: // IRDecoder
addHint(targetTemp, sourceTemp);
}
- virtual void swapValues(Expr *, Expr *)
+ void swapValues(Expr *, Expr *) override
{
// Inserted by the register allocator, so it cannot occur here.
Q_UNREACHABLE();
}
- virtual void unop(AluOp oper, Expr *source, Expr *target)
+ void unop(AluOp oper, Expr *source, Expr *target) override
{
addDef(target);
@@ -612,7 +616,7 @@ protected: // IRDecoder
}
}
- virtual void binop(AluOp oper, Expr *leftSource, Expr *rightSource, Expr *target)
+ void binop(AluOp oper, Expr *leftSource, Expr *rightSource, Expr *target) override
{
bool needsCall = true;
@@ -675,8 +679,8 @@ protected: // IRDecoder
}
}
- virtual void visitJump(IR::Jump *) {}
- virtual void visitCJump(IR::CJump *s)
+ void visitJump(IR::Jump *) override {}
+ void visitCJump(IR::CJump *s) override
{
if (Temp *t = s->cond->asTemp()) {
#if 0 // TODO: change masm to generate code
@@ -696,10 +700,10 @@ protected: // IRDecoder
}
}
- virtual void visitRet(IR::Ret *s)
+ void visitRet(IR::Ret *s) override
{ addUses(s->expr->asTemp(), Use::CouldHaveRegister); }
- virtual void visitPhi(IR::Phi *s)
+ void visitPhi(IR::Phi *s) override
{
addDef(s->targetTemp, true);
for (int i = 0, ei = s->incoming.size(); i < ei; ++i) {
@@ -716,7 +720,7 @@ protected: // IRDecoder
}
protected:
- virtual void callBuiltin(IR::Call *c, IR::Expr *result)
+ void callBuiltin(IR::Call *c, IR::Expr *result) override
{
addDef(result);
addUses(c->base, Use::CouldHaveRegister);
diff --git a/src/qml/jsruntime/jsruntime.pri b/src/qml/jsruntime/jsruntime.pri
index e72b06359e..4343924436 100644
--- a/src/qml/jsruntime/jsruntime.pri
+++ b/src/qml/jsruntime/jsruntime.pri
@@ -38,7 +38,6 @@ SOURCES += \
$$PWD/qv4sequenceobject.cpp \
$$PWD/qv4include.cpp \
$$PWD/qv4qobjectwrapper.cpp \
- $$PWD/qv4vme_moth.cpp \
$$PWD/qv4arraybuffer.cpp \
$$PWD/qv4typedarray.cpp \
$$PWD/qv4dataview.cpp
@@ -83,17 +82,22 @@ HEADERS += \
$$PWD/qv4serialize_p.h \
$$PWD/qv4script_p.h \
$$PWD/qv4scopedvalue_p.h \
- $$PWD/qv4util_p.h \
$$PWD/qv4executableallocator_p.h \
$$PWD/qv4sequenceobject_p.h \
$$PWD/qv4include_p.h \
$$PWD/qv4qobjectwrapper_p.h \
- $$PWD/qv4vme_moth_p.h \
$$PWD/qv4profiling_p.h \
$$PWD/qv4arraybuffer_p.h \
$$PWD/qv4typedarray_p.h \
$$PWD/qv4dataview_p.h
+qtConfig(qml-interpreter) {
+ HEADERS += \
+ $$PWD/qv4vme_moth_p.h
+ SOURCES += \
+ $$PWD/qv4vme_moth.cpp
+}
+
}
@@ -102,6 +106,7 @@ HEADERS += \
$$PWD/qv4runtimeapi_p.h \
$$PWD/qv4value_p.h \
$$PWD/qv4string_p.h \
+ $$PWD/qv4util_p.h \
$$PWD/qv4value_p.h
SOURCES += \
diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp
index 74c83b1940..bfeb3d4699 100644
--- a/src/qml/jsruntime/qv4arraydata.cpp
+++ b/src/qml/jsruntime/qv4arraydata.cpp
@@ -46,6 +46,8 @@
using namespace QV4;
+QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_ON
+
const QV4::VTable QV4::ArrayData::static_vtbl = {
0,
QV4::ArrayData::IsExecutionContext,
@@ -94,13 +96,15 @@ const ArrayVTable SparseArrayData::static_vtbl =
SparseArrayData::length
};
+QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_OFF
+
Q_STATIC_ASSERT(sizeof(Heap::ArrayData) == sizeof(Heap::SimpleArrayData));
Q_STATIC_ASSERT(sizeof(Heap::ArrayData) == sizeof(Heap::SparseArrayData));
static Q_ALWAYS_INLINE void storeValue(ReturnedValue *target, uint value)
{
Value v;
- v.setTagValue(Value::fromReturnedValue(*target).tag(), value);
+ v.setEmpty(value);
*target = v.asReturnedValue();
}
@@ -189,6 +193,7 @@ void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAtt
} else {
sparse->sparse = new SparseArray;
lastFree = &sparse->freeList;
+ storeValue(lastFree, 0);
for (uint i = 0; i < toCopy; ++i) {
if (!sparse->arrayData[i].isEmpty()) {
SparseArrayNode *n = sparse->sparse->insert(i);
@@ -209,6 +214,8 @@ void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAtt
}
storeValue(lastFree, UINT_MAX);
}
+
+ Q_ASSERT(Value::fromReturnedValue(sparse->freeList).isEmpty());
// ### Could explicitly free the old data
}
@@ -357,12 +364,12 @@ void SparseArrayData::free(Heap::ArrayData *d, uint idx)
Value *v = d->arrayData + idx;
if (d->attrs && d->attrs[idx].isAccessor()) {
// double slot, free both. Order is important, so we have a double slot for allocation again afterwards.
- v[1].setTagValue(Value::Empty_Type, Value::fromReturnedValue(d->freeList).value());
- v[0].setTagValue(Value::Empty_Type, idx + 1);
+ v[1].setEmpty(Value::fromReturnedValue(d->freeList).emptyValue());
+ v[0].setEmpty(idx + 1);
} else {
- v->setTagValue(Value::Empty_Type, Value::fromReturnedValue(d->freeList).value());
+ v->setEmpty(Value::fromReturnedValue(d->freeList).emptyValue());
}
- d->freeList = idx;
+ d->freeList = Primitive::emptyValue(idx).asReturnedValue();
if (d->attrs)
d->attrs[idx].clear();
}
@@ -400,9 +407,9 @@ uint SparseArrayData::allocate(Object *o, bool doubleSlot)
Q_ASSERT(dd->arrayData[Value::fromReturnedValue(*last).value()].value() != Value::fromReturnedValue(*last).value());
if (dd->arrayData[Value::fromReturnedValue(*last).value()].value() == (Value::fromReturnedValue(*last).value() + 1)) {
// found two slots in a row
- uint idx = Value::fromReturnedValue(*last).uint_32();
+ uint idx = Value::fromReturnedValue(*last).emptyValue();
Value lastV = Value::fromReturnedValue(*last);
- lastV.setTagValue(lastV.tag(), dd->arrayData[lastV.value() + 1].value());
+ lastV.setEmpty(dd->arrayData[lastV.emptyValue() + 1].value());
*last = lastV.rawValue();
dd->attrs[idx] = Attr_Accessor;
return idx;
@@ -416,7 +423,8 @@ uint SparseArrayData::allocate(Object *o, bool doubleSlot)
}
uint idx = Value::fromReturnedValue(dd->freeList).value();
Q_ASSERT(idx != UINT_MAX);
- dd->freeList = dd->arrayData[idx].uint_32();
+ dd->freeList = dd->arrayData[idx].asReturnedValue();
+ Q_ASSERT(Value::fromReturnedValue(dd->freeList).isEmpty());
if (dd->attrs)
dd->attrs[idx] = Attr_Data;
return idx;
@@ -471,13 +479,14 @@ bool SparseArrayData::del(Object *o, uint index)
if (isAccessor) {
// free up both indices
- dd->arrayData[pidx + 1].setTagValue(Value::Empty_Type, Value::fromReturnedValue(dd->freeList).value());
- dd->arrayData[pidx].setTagValue(Value::Undefined_Type, pidx + 1);
+ dd->arrayData[pidx + 1].setEmpty(Value::fromReturnedValue(dd->freeList).emptyValue());
+ dd->arrayData[pidx].setEmpty(pidx + 1);
} else {
- dd->arrayData[pidx].setTagValue(Value::Empty_Type, Value::fromReturnedValue(dd->freeList).value());
+ Q_ASSERT(dd->type == Heap::ArrayData::Sparse);
+ dd->arrayData[pidx].setEmpty(Value::fromReturnedValue(dd->freeList).emptyValue());
}
- dd->freeList = pidx;
+ dd->freeList = Primitive::emptyValue(pidx).asReturnedValue();
dd->sparse->erase(n);
return true;
}
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp
index 76faef137f..20ba11fd75 100644
--- a/src/qml/jsruntime/qv4arrayobject.cpp
+++ b/src/qml/jsruntime/qv4arrayobject.cpp
@@ -96,6 +96,8 @@ void ArrayPrototype::init(ExecutionEngine *engine, Object *ctor)
defineDefaultProperty(engine->id_toString(), method_toString, 0);
defineDefaultProperty(QStringLiteral("toLocaleString"), method_toLocaleString, 0);
defineDefaultProperty(QStringLiteral("concat"), method_concat, 1);
+ defineDefaultProperty(QStringLiteral("find"), method_find, 1);
+ defineDefaultProperty(QStringLiteral("findIndex"), method_findIndex, 1);
defineDefaultProperty(QStringLiteral("join"), method_join, 1);
defineDefaultProperty(QStringLiteral("pop"), method_pop, 0);
defineDefaultProperty(QStringLiteral("push"), method_push, 1);
@@ -182,10 +184,88 @@ ReturnedValue ArrayPrototype::method_concat(CallContext *ctx)
return result.asReturnedValue();
}
+ReturnedValue ArrayPrototype::method_find(CallContext *ctx)
+{
+ Scope scope(ctx);
+ ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine));
+ if (!instance)
+ return Encode::undefined();
+
+ uint len = instance->getLength();
+
+ ScopedFunctionObject callback(scope, ctx->argument(0));
+ if (!callback)
+ return ctx->engine()->throwTypeError();
+
+ ScopedCallData callData(scope, 3);
+ callData->thisObject = ctx->argument(1);
+ callData->args[2] = instance;
+
+ ScopedValue v(scope);
+
+ for (uint k = 0; k < len; ++k) {
+ v = instance->getIndexed(k);
+ if (scope.hasException())
+ return Encode::undefined();
+
+ callData->args[0] = v;
+ callData->args[1] = Primitive::fromDouble(k);
+ callback->call(scope, callData);
+
+ if (scope.hasException())
+ return Encode::undefined();
+ else if (scope.result.toBoolean())
+ return v->asReturnedValue();
+ }
+
+ return Encode::undefined();
+}
+
+ReturnedValue ArrayPrototype::method_findIndex(CallContext *ctx)
+{
+ Scope scope(ctx);
+ ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine));
+ if (!instance)
+ return Encode::undefined();
+
+ uint len = instance->getLength();
+
+ ScopedFunctionObject callback(scope, ctx->argument(0));
+ if (!callback)
+ return ctx->engine()->throwTypeError();
+
+ ScopedCallData callData(scope, 3);
+ callData->thisObject = ctx->argument(1);
+ callData->args[2] = instance;
+
+ ScopedValue v(scope);
+
+ for (uint k = 0; k < len; ++k) {
+ v = instance->getIndexed(k);
+ if (scope.hasException())
+ return Encode::undefined();
+
+ callData->args[0] = v;
+ callData->args[1] = Primitive::fromDouble(k);
+ callback->call(scope, callData);
+
+ if (scope.hasException())
+ return Encode::undefined();
+ else if (scope.result.toBoolean())
+ return Encode(k);
+ }
+
+ return Encode(-1);
+}
+
ReturnedValue ArrayPrototype::method_join(CallContext *ctx)
{
Scope scope(ctx);
ScopedValue arg(scope, ctx->argument(0));
+ ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine));
+
+ if (!instance)
+ return ctx->d()->engine->newString()->asReturnedValue();
QString r4;
if (arg->isUndefined())
@@ -193,8 +273,7 @@ ReturnedValue ArrayPrototype::method_join(CallContext *ctx)
else
r4 = arg->toQString();
- ScopedObject self(scope, ctx->thisObject());
- ScopedValue length(scope, self->get(ctx->d()->engine->id_length()));
+ ScopedValue length(scope, instance->get(ctx->d()->engine->id_length()));
const quint32 r2 = length->isUndefined() ? 0 : length->toUInt32();
if (!r2)
@@ -203,7 +282,7 @@ ReturnedValue ArrayPrototype::method_join(CallContext *ctx)
QString R;
// ### FIXME
- if (ArrayObject *a = self->as<ArrayObject>()) {
+ if (ArrayObject *a = instance->as<ArrayObject>()) {
ScopedValue e(scope);
for (uint i = 0; i < a->getLength(); ++i) {
if (i)
@@ -220,7 +299,7 @@ ReturnedValue ArrayPrototype::method_join(CallContext *ctx)
// crazy!
//
ScopedString name(scope, ctx->d()->engine->newString(QStringLiteral("0")));
- ScopedValue r6(scope, self->get(name));
+ ScopedValue r6(scope, instance->get(name));
if (!r6->isNullOrUndefined())
R = r6->toQString();
@@ -229,7 +308,7 @@ ReturnedValue ArrayPrototype::method_join(CallContext *ctx)
R += r4;
name = Primitive::fromDouble(k).toString(scope.engine);
- r12 = self->get(name);
+ r12 = instance->get(name);
if (scope.hasException())
return Encode::undefined();
diff --git a/src/qml/jsruntime/qv4arrayobject_p.h b/src/qml/jsruntime/qv4arrayobject_p.h
index 9a05bb8681..f00c0c0249 100644
--- a/src/qml/jsruntime/qv4arrayobject_p.h
+++ b/src/qml/jsruntime/qv4arrayobject_p.h
@@ -82,6 +82,8 @@ struct ArrayPrototype: ArrayObject
static ReturnedValue method_toString(CallContext *ctx);
static ReturnedValue method_toLocaleString(CallContext *ctx);
static ReturnedValue method_concat(CallContext *ctx);
+ static ReturnedValue method_find(CallContext *ctx);
+ static ReturnedValue method_findIndex(CallContext *ctx);
static ReturnedValue method_join(CallContext *ctx);
static ReturnedValue method_pop(CallContext *ctx);
static ReturnedValue method_push(CallContext *ctx);
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index f630dfaee0..7265952f72 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -86,7 +86,9 @@
#include "qv4isel_masm_p.h"
#endif // V4_ENABLE_JIT
+#if QT_CONFIG(qml_interpreter)
#include "qv4isel_moth_p.h"
+#endif
#if USE(PTHREADS)
# include <pthread.h>
@@ -160,6 +162,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
MemoryManager::GCBlocker gcBlocker(memoryManager);
if (!factory) {
+#if QT_CONFIG(qml_interpreter)
bool jitDisabled = true;
#ifdef V4_ENABLE_JIT
@@ -180,6 +183,9 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
"very slow. Visit https://wiki.qt.io/V4 to learn about possible "
"solutions for your platform.");
}
+#else
+ factory = new JIT::ISelFactory;
+#endif
}
iselFactory.reset(factory);
@@ -457,7 +463,7 @@ ExecutionEngine::~ExecutionEngine()
QSet<QV4::CompiledData::CompilationUnit*> remainingUnits;
qSwap(compilationUnits, remainingUnits);
- foreach (QV4::CompiledData::CompilationUnit *unit, remainingUnits)
+ for (QV4::CompiledData::CompilationUnit *unit : qAsConst(remainingUnits))
unit->unlink();
emptyClass->destroy();
@@ -1022,7 +1028,7 @@ ReturnedValue ExecutionEngine::throwURIError(const Value &msg)
ReturnedValue ExecutionEngine::throwUnimplemented(const QString &message)
{
Scope scope(this);
- ScopedValue v(scope, newString(QStringLiteral("Unimplemented ") + message));
+ ScopedValue v(scope, newString(QLatin1String("Unimplemented ") + message));
v = newErrorObject(v);
return throwError(v);
}
diff --git a/src/qml/jsruntime/qv4executableallocator.cpp b/src/qml/jsruntime/qv4executableallocator.cpp
index 6fe25f192d..64ac1267ce 100644
--- a/src/qml/jsruntime/qv4executableallocator.cpp
+++ b/src/qml/jsruntime/qv4executableallocator.cpp
@@ -147,7 +147,7 @@ ExecutableAllocator::ExecutableAllocator()
ExecutableAllocator::~ExecutableAllocator()
{
- foreach (ChunkOfPages *chunk, chunks) {
+ for (ChunkOfPages *chunk : qAsConst(chunks)) {
for (Allocation *allocation = chunk->firstAllocation; allocation; allocation = allocation->next)
if (!allocation->free)
allocation->invalidate();
diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp
index c33d2cad11..be8057e9f5 100644
--- a/src/qml/jsruntime/qv4include.cpp
+++ b/src/qml/jsruntime/qv4include.cpp
@@ -41,7 +41,7 @@
#include "qv4scopedvalue_p.h"
#include <QtQml/qjsengine.h>
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
#include <QtNetwork/qnetworkrequest.h>
#include <QtNetwork/qnetworkreply.h>
#endif
@@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
QV4Include::QV4Include(const QUrl &url, QV4::ExecutionEngine *engine,
QV4::QmlContext *qmlContext, const QV4::Value &callback)
: v4(engine), m_url(url)
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
, m_redirectCount(0), m_network(0) , m_reply(0)
#endif
{
@@ -71,7 +71,7 @@ QV4Include::QV4Include(const QUrl &url, QV4::ExecutionEngine *engine,
m_resultObject.set(v4, resultValue(v4));
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
m_network = engine->v8Engine->networkAccessManager();
QNetworkRequest request;
@@ -86,7 +86,7 @@ QV4Include::QV4Include(const QUrl &url, QV4::ExecutionEngine *engine,
QV4Include::~QV4Include()
{
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
delete m_reply;
m_reply = 0;
#endif
@@ -135,7 +135,7 @@ QV4::ReturnedValue QV4Include::result()
#define INCLUDE_MAXIMUM_REDIRECT_RECURSION 15
void QV4Include::finished()
{
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
m_redirectCount++;
if (m_redirectCount < INCLUDE_MAXIMUM_REDIRECT_RECURSION) {
@@ -184,7 +184,7 @@ void QV4Include::finished()
QV4::ScopedObject resultObj(scope, m_resultObject.value());
QV4::ScopedString status(scope, v4->newString(QStringLiteral("status")));
resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(NetworkError)));
-#endif //QT_NO_NETWORK
+#endif // qml_network
QV4::ScopedValue cb(scope, m_callbackFunction.value());
callback(cb, resultObj);
@@ -211,7 +211,7 @@ QV4::ReturnedValue QV4Include::method_include(QV4::CallContext *ctx)
if (ctx->argc() >= 2 && ctx->args()[1].as<QV4::FunctionObject>())
callbackFunction = ctx->args()[1];
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QUrl url(scope.engine->resolvedUrl(ctx->args()[0].toQStringNoThrow()));
if (scope.engine->qmlEngine() && scope.engine->qmlEngine()->urlInterceptor())
url = scope.engine->qmlEngine()->urlInterceptor()->intercept(url, QQmlAbstractUrlInterceptor::JavaScriptFile);
diff --git a/src/qml/jsruntime/qv4include_p.h b/src/qml/jsruntime/qv4include_p.h
index 1750e6a7e1..4c601a5e7b 100644
--- a/src/qml/jsruntime/qv4include_p.h
+++ b/src/qml/jsruntime/qv4include_p.h
@@ -62,7 +62,7 @@
QT_BEGIN_NAMESPACE
class QQmlEngine;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
class QNetworkAccessManager;
#endif
class QNetworkReply;
@@ -94,7 +94,7 @@ private:
QV4::ExecutionEngine *v4;
QUrl m_url;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
int m_redirectCount;
QNetworkAccessManager *m_network;
QPointer<QNetworkReply> m_reply;
diff --git a/src/qml/jsruntime/qv4internalclass.cpp b/src/qml/jsruntime/qv4internalclass.cpp
index bac45e18c8..d17da9af0c 100644
--- a/src/qml/jsruntime/qv4internalclass.cpp
+++ b/src/qml/jsruntime/qv4internalclass.cpp
@@ -132,16 +132,20 @@ static void insertHoleIntoPropertyData(Object *object, int idx)
int icSize = object->internalClass()->size;
int from = qMax(idx, inlineSize);
int to = from + 1;
- if (from < icSize)
- memmove(object->propertyData(to), object->propertyData(from), icSize - from - 1);
+ if (from < icSize) {
+ memmove(object->propertyData(to), object->propertyData(from),
+ (icSize - from - 1) * sizeof(Value));
+ }
if (from == idx)
return;
if (inlineSize < icSize)
*object->propertyData(inlineSize) = *object->propertyData(inlineSize - 1);
from = idx;
to = from + 1;
- if (from < inlineSize - 1)
- memmove(object->propertyData(to), object->propertyData(from), inlineSize - from - 1);
+ if (from < inlineSize - 1) {
+ memmove(object->propertyData(to), object->propertyData(from),
+ (inlineSize - from - 1) * sizeof(Value));
+ }
}
static void removeFromPropertyData(Object *object, int idx, bool accessor = false)
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp
index 9636fefc14..94a6e4daa1 100644
--- a/src/qml/jsruntime/qv4jsonobject.cpp
+++ b/src/qml/jsruntime/qv4jsonobject.cpp
@@ -44,6 +44,7 @@
#include <qv4objectiterator_p.h>
#include <qv4scopedvalue_p.h>
#include <qv4runtime_p.h>
+#include <qv4variantobject_p.h>
#include "qv4string_p.h"
#include <qstack.h>
@@ -734,6 +735,10 @@ QString Stringify::Str(const QString &key, const Value &v)
return std::isfinite(d) ? scope.result.toQString() : QStringLiteral("null");
}
+ if (const QV4::VariantObject *v = scope.result.as<QV4::VariantObject>()) {
+ return v->d()->data().toString();
+ }
+
o = scope.result.asReturnedValue();
if (o) {
if (!o->as<FunctionObject>()) {
diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp
index 42e561bc7c..84755a6402 100644
--- a/src/qml/jsruntime/qv4lookup.cpp
+++ b/src/qml/jsruntime/qv4lookup.cpp
@@ -306,7 +306,7 @@ ReturnedValue Lookup::getterTwoClasses(Lookup *l, ExecutionEngine *engine, const
ReturnedValue v = o->getLookup(l);
Lookup l2 = *l;
- if (l2.getter == Lookup::getter0 || l2.getter == Lookup::getter1) {
+ if (l->index != UINT_MAX && (l2.getter == Lookup::getter0 || l2.getter == Lookup::getter1)) {
// if we have a getter0, make sure it comes first
if (l2.getter == Lookup::getter0)
qSwap(l1, l2);
diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h
index 0359559f34..1fff5a45da 100644
--- a/src/qml/jsruntime/qv4managed_p.h
+++ b/src/qml/jsruntime/qv4managed_p.h
@@ -106,6 +106,18 @@ inline void qYouForgotTheQ_MANAGED_Macro(T1, T2) {}
#define Q_VTABLE_FUNCTION(classname, func) \
(classname::func == QV4::Managed::func ? 0 : classname::func)
+// Q_VTABLE_FUNCTION triggers a bogus tautological-compare warning in GCC6+
+#if defined(Q_CC_GNU) && Q_CC_GNU >= 600
+#define QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_ON \
+ QT_WARNING_PUSH; \
+ QT_WARNING_DISABLE_GCC("-Wtautological-compare")
+
+#define QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_OFF \
+ ;QT_WARNING_POP
+#else
+#define QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_ON
+#define QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_OFF
+#endif
#define DEFINE_MANAGED_VTABLE_INT(classname, parentVTable) \
{ \
@@ -125,7 +137,9 @@ inline void qYouForgotTheQ_MANAGED_Macro(T1, T2) {}
}
#define DEFINE_MANAGED_VTABLE(classname) \
-const QV4::VTable classname::static_vtbl = DEFINE_MANAGED_VTABLE_INT(classname, 0)
+QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_ON \
+const QV4::VTable classname::static_vtbl = DEFINE_MANAGED_VTABLE_INT(classname, 0) \
+QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_OFF
struct Q_QML_PRIVATE_EXPORT Managed : Value
{
diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp
index 1733df34ae..9b1f72bc17 100644
--- a/src/qml/jsruntime/qv4numberobject.cpp
+++ b/src/qml/jsruntime/qv4numberobject.cpp
@@ -63,7 +63,9 @@ NumberLocale::NumberLocale() : QLocale(QLocale::C),
// -128 means shortest string that can accurately represent the number.
defaultDoublePrecision(0xffffff80)
{
- setNumberOptions(QLocale::OmitGroupSeparator | QLocale::OmitLeadingZeroInExponent);
+ setNumberOptions(QLocale::OmitGroupSeparator |
+ QLocale::OmitLeadingZeroInExponent |
+ QLocale::IncludeTrailingZeroesAfterDot);
}
const NumberLocale *NumberLocale::instance()
@@ -291,24 +293,6 @@ ReturnedValue NumberPrototype::method_toPrecision(CallContext *ctx)
return ctx->engine()->throwRangeError(error);
}
- // TODO: Once we get a NumberOption to retain trailing zeroes, replace the code below with:
- // QString result = NumberLocale::instance()->toString(v->asDouble(), 'g', precision);
- QByteArray format = "%#." + QByteArray::number(precision) + "g";
- QString result = QString::asprintf(format.constData(), v->asDouble());
- if (result.endsWith(QLatin1Char('.'))) {
- // This is 'f' notation, not 'e'.
- result.chop(1);
- } else {
- int ePos = result.indexOf(QLatin1Char('e'));
- if (ePos != -1) {
- Q_ASSERT(ePos + 2 < result.length()); // always '+' or '-', and number, after 'e'
- Q_ASSERT(ePos > 0); // 'e' is not the first character
-
- if (result.at(ePos + 2) == QLatin1Char('0')) // Drop leading zeroes in exponent
- result = result.remove(ePos + 2, 1);
- if (result.at(ePos - 1) == QLatin1Char('.')) // Drop trailing dots before 'e'
- result = result.remove(ePos - 1, 1);
- }
- }
+ QString result = NumberLocale::instance()->toString(v->asDouble(), 'g', precision);
return scope.engine->newString(result)->asReturnedValue();
}
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h
index e13a701b0f..161c7746da 100644
--- a/src/qml/jsruntime/qv4object_p.h
+++ b/src/qml/jsruntime/qv4object_p.h
@@ -58,7 +58,7 @@
#include "qv4value_p.h"
#include "qv4internalclass_p.h"
-#include <QtCore/qtypetraits.h>
+#include <type_traits>
QT_BEGIN_NAMESPACE
@@ -144,10 +144,10 @@ struct ObjectVTable
void (*advanceIterator)(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes);
};
-#define DEFINE_OBJECT_VTABLE(classname) \
+#define DEFINE_OBJECT_VTABLE_BASE(classname) \
const QV4::ObjectVTable classname::static_vtbl = \
{ \
- DEFINE_MANAGED_VTABLE_INT(classname, (QT_PREPEND_NAMESPACE(QtPrivate)::is_same<classname::SuperClass, Object>::value) ? Q_NULLPTR : &classname::SuperClass::static_vtbl.vTable), \
+ DEFINE_MANAGED_VTABLE_INT(classname, (std::is_same<classname::SuperClass, Object>::value) ? Q_NULLPTR : &classname::SuperClass::static_vtbl.vTable), \
call, \
construct, \
get, \
@@ -164,7 +164,15 @@ const QV4::ObjectVTable classname::static_vtbl = \
advanceIterator \
}
-
+#define DEFINE_OBJECT_VTABLE(classname) \
+QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_ON \
+DEFINE_OBJECT_VTABLE_BASE(classname) \
+QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_OFF
+
+#define DEFINE_OBJECT_TEMPLATE_VTABLE(classname) \
+QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_ON \
+template<> DEFINE_OBJECT_VTABLE_BASE(classname) \
+QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_OFF
struct Q_QML_EXPORT Object: Managed {
V4_OBJECT2(Object, Object)
diff --git a/src/qml/jsruntime/qv4persistent.cpp b/src/qml/jsruntime/qv4persistent.cpp
index 7ca0692804..987c322e47 100644
--- a/src/qml/jsruntime/qv4persistent.cpp
+++ b/src/qml/jsruntime/qv4persistent.cpp
@@ -139,7 +139,7 @@ PersistentValueStorage::Iterator &PersistentValueStorage::Iterator::operator++()
while (p) {
while (index < kEntriesPerPage - 1) {
++index;
- if (static_cast<Page *>(p)->values[index].tag() != QV4::Value::Empty_Type)
+ if (!static_cast<Page *>(p)->values[index].isEmpty())
return *this;
}
index = -1;
@@ -358,14 +358,14 @@ WeakValue::WeakValue(const WeakValue &other)
: val(0)
{
if (other.val) {
- val = other.engine()->memoryManager->m_weakValues->allocate();
+ allocVal(other.engine());
*val = *other.val;
}
}
WeakValue::WeakValue(ExecutionEngine *engine, const Value &value)
{
- val = engine->memoryManager->m_weakValues->allocate();
+ allocVal(engine);
*val = value;
}
@@ -374,7 +374,7 @@ WeakValue &WeakValue::operator=(const WeakValue &other)
if (!val) {
if (!other.val)
return *this;
- val = other.engine()->memoryManager->m_weakValues->allocate();
+ allocVal(other.engine());
}
Q_ASSERT(engine() == other.engine());
@@ -388,25 +388,9 @@ WeakValue::~WeakValue()
free();
}
-void WeakValue::set(ExecutionEngine *engine, const Value &value)
-{
- if (!val)
- val = engine->memoryManager->m_weakValues->allocate();
- *val = value;
-}
-
-void WeakValue::set(ExecutionEngine *engine, ReturnedValue value)
-{
- if (!val)
- val = engine->memoryManager->m_weakValues->allocate();
- *val = value;
-}
-
-void WeakValue::set(ExecutionEngine *engine, Heap::Base *obj)
+void WeakValue::allocVal(ExecutionEngine *engine)
{
- if (!val)
- val = engine->memoryManager->m_weakValues->allocate();
- *val = obj;
+ val = engine->memoryManager->m_weakValues->allocate();
}
void WeakValue::markOnce(ExecutionEngine *e)
diff --git a/src/qml/jsruntime/qv4persistent_p.h b/src/qml/jsruntime/qv4persistent_p.h
index a0ade2068f..c1cd1f34df 100644
--- a/src/qml/jsruntime/qv4persistent_p.h
+++ b/src/qml/jsruntime/qv4persistent_p.h
@@ -154,9 +154,26 @@ public:
WeakValue &operator=(const WeakValue &other);
~WeakValue();
- void set(ExecutionEngine *engine, const Value &value);
- void set(ExecutionEngine *engine, ReturnedValue value);
- void set(ExecutionEngine *engine, Heap::Base *obj);
+ void set(ExecutionEngine *engine, const Value &value)
+ {
+ if (!val)
+ allocVal(engine);
+ *val = value;
+ }
+
+ void set(ExecutionEngine *engine, ReturnedValue value)
+ {
+ if (!val)
+ allocVal(engine);
+ *val = value;
+ }
+
+ void set(ExecutionEngine *engine, Heap::Base *obj)
+ {
+ if (!val)
+ allocVal(engine);
+ *val = obj;
+ }
ReturnedValue value() const {
return (val ? val->asReturnedValue() : Encode::undefined());
@@ -192,6 +209,8 @@ private:
Value *val;
private:
+ Q_NEVER_INLINE void allocVal(ExecutionEngine *engine);
+
void free();
};
diff --git a/src/qml/jsruntime/qv4profiling.cpp b/src/qml/jsruntime/qv4profiling.cpp
index 349ec48e06..8862cbef8e 100644
--- a/src/qml/jsruntime/qv4profiling.cpp
+++ b/src/qml/jsruntime/qv4profiling.cpp
@@ -96,7 +96,7 @@ void Profiler::reportData(bool trackLocations)
FunctionLocationHash locations;
properties.reserve(m_data.size());
- foreach (const FunctionCall &call, m_data) {
+ for (const FunctionCall &call : qAsConst(m_data)) {
properties.append(call.properties());
Function *function = call.function();
SentMarker &marker = m_sentLocations[reinterpret_cast<quintptr>(function)];
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index fc3d147c1d..6b87f282cf 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -195,12 +195,6 @@ static QV4::ReturnedValue loadProperty(QV4::ExecutionEngine *v4, QObject *object
}
}
-void Heap::QObjectWrapper::init(QObject *object)
-{
- Object::init();
- qObj.init(object);
-}
-
void QObjectWrapper::initializeBindings(ExecutionEngine *engine)
{
engine->functionPrototype()->defineDefaultProperty(QStringLiteral("connect"), method_connect);
@@ -614,8 +608,14 @@ bool QObjectWrapper::isEqualTo(Managed *a, Managed *b)
ReturnedValue QObjectWrapper::create(ExecutionEngine *engine, QObject *object)
{
- if (engine->jsEngine())
- QQmlData::ensurePropertyCache(engine->jsEngine(), object);
+ if (QJSEngine *jsEngine = engine->jsEngine()) {
+ if (QQmlPropertyCache *cache = QQmlData::ensurePropertyCache(jsEngine, object)) {
+ ReturnedValue result = QV4::Encode::null();
+ void *args[] = { &result, &engine };
+ if (cache->callJSFactoryMethod(object, args))
+ return result;
+ }
+ }
return (engine->memoryManager->allocObject<QV4::QObjectWrapper>(object))->asReturnedValue();
}
@@ -979,6 +979,10 @@ void QObjectWrapper::destroyObject(bool lastCall)
delete h->object();
else
h->object()->deleteLater();
+ } else {
+ // If the object is C++-owned, we still have to release the weak reference we have
+ // to it.
+ ddata->jsWrapper.clear();
}
}
}
@@ -1303,9 +1307,8 @@ static QV4::ReturnedValue CallPrecise(const QQmlObjectOrGadget &object, const QQ
int returnType = object.methodReturnType(data, &unknownTypeError);
if (returnType == QMetaType::UnknownType) {
- QString typeName = QString::fromLatin1(unknownTypeError);
- QString error = QStringLiteral("Unknown method return type: %1").arg(typeName);
- return engine->throwError(error);
+ return engine->throwError(QLatin1String("Unknown method return type: ")
+ + QLatin1String(unknownTypeError));
}
if (data.hasArguments()) {
@@ -1320,9 +1323,8 @@ static QV4::ReturnedValue CallPrecise(const QQmlObjectOrGadget &object, const QQ
args = object.methodParameterTypes(data.coreIndex(), &storage, &unknownTypeError);
if (!args) {
- QString typeName = QString::fromLatin1(unknownTypeError);
- QString error = QStringLiteral("Unknown method parameter type: %1").arg(typeName);
- return engine->throwError(error);
+ return engine->throwError(QLatin1String("Unknown method parameter type: ")
+ + QLatin1String(unknownTypeError));
}
if (args[0] > callArgs->argc) {
@@ -1911,8 +1913,8 @@ ReturnedValue QMetaObjectWrapper::constructInternal(CallData * callData) const {
ExecutionEngine *v4 = engine();
const QMetaObject* mo = d()->metaObject;
if (d()->constructorCount == 0) {
- return v4->throwTypeError(QStringLiteral("%1 has no invokable constructor")
- .arg(QLatin1String(mo->className())));
+ return v4->throwTypeError(QLatin1String(mo->className())
+ + QLatin1String(" has no invokable constructor"));
}
Scope scope(v4);
diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h
index a32244c8de..504f6a69b8 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper_p.h
+++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h
@@ -77,8 +77,13 @@ namespace Heap {
struct QQmlValueTypeWrapper;
-struct QObjectWrapper : Object {
- void init(QObject *object);
+struct Q_QML_EXPORT QObjectWrapper : Object {
+ void init(QObject *object)
+ {
+ Object::init();
+ qObj.init(object);
+ }
+
void destroy() {
qObj.destroy();
Object::destroy();
@@ -196,7 +201,7 @@ protected:
static ReturnedValue method_disconnect(CallContext *ctx);
private:
- static ReturnedValue wrap_slowPath(ExecutionEngine *engine, QObject *object);
+ Q_NEVER_INLINE static ReturnedValue wrap_slowPath(ExecutionEngine *engine, QObject *object);
};
inline ReturnedValue QObjectWrapper::wrap(ExecutionEngine *engine, QObject *object)
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 0a71f0000a..fffa6b8009 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -176,7 +176,7 @@ struct RuntimeCounters::Data {
}
std::sort(lines.begin(), lines.end(), Line::less);
outs << lines.size() << " counters:" << endl;
- foreach (const Line &line, lines)
+ for (const Line &line : qAsConst(lines))
outs << qSetFieldWidth(10) << line.count << qSetFieldWidth(0)
<< " | " << line.func
<< " | " << pretty(line.tag1)
diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h
index 44d171e087..5022d7c3bc 100644
--- a/src/qml/jsruntime/qv4scopedvalue_p.h
+++ b/src/qml/jsruntime/qv4scopedvalue_p.h
@@ -324,7 +324,7 @@ struct ScopedCallData {
{
int size = qMax(argc, (int)QV4::Global::ReservedArgumentCount) + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value);
ptr = reinterpret_cast<CallData *>(scope.alloc(size));
- ptr->tag = QV4::Value::Integer_Type;
+ ptr->tag = QV4::Value::Integer_Type_Internal;
ptr->argc = argc;
}
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index 787047806a..552171256f 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -158,7 +158,8 @@ void Script::parse()
const bool parsed = parser.parseProgram();
- foreach (const QQmlJS::DiagnosticMessage &m, parser.diagnosticMessages()) {
+ const auto diagnosticMessages = parser.diagnosticMessages();
+ for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) {
if (m.isError()) {
valueScope.engine->throwSyntaxError(m.message, sourceFile, m.loc.startLine, m.loc.startColumn);
return;
@@ -260,7 +261,8 @@ QQmlRefPointer<QV4::CompiledData::CompilationUnit> Script::precompile(IR::Module
QList<QQmlError> errors;
- foreach (const QQmlJS::DiagnosticMessage &m, parser.diagnosticMessages()) {
+ const auto diagnosticMessages = parser.diagnosticMessages();
+ for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) {
if (m.isWarning()) {
qWarning("%s:%d : %s", qPrintable(url.toString()), m.loc.startLine, qPrintable(m.message));
continue;
diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp
index 24890fdb18..58da7b9f68 100644
--- a/src/qml/jsruntime/qv4sequenceobject.cpp
+++ b/src/qml/jsruntime/qv4sequenceobject.cpp
@@ -592,38 +592,27 @@ void Heap::QQmlSequence<Container>::init(QObject *object, int propertyIndex)
namespace QV4 {
typedef QQmlSequence<QVector<int> > QQmlIntVectorList;
-template<>
-DEFINE_OBJECT_VTABLE(QQmlIntVectorList);
+DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlIntVectorList);
typedef QQmlSequence<QVector<qreal> > QQmlRealVectorList;
-template<>
-DEFINE_OBJECT_VTABLE(QQmlRealVectorList);
+DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlRealVectorList);
typedef QQmlSequence<QVector<bool> > QQmlBoolVectorList;
-template<>
-DEFINE_OBJECT_VTABLE(QQmlBoolVectorList);
+DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlBoolVectorList);
typedef QQmlSequence<QStringList> QQmlQStringList;
-template<>
-DEFINE_OBJECT_VTABLE(QQmlQStringList);
+DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlQStringList);
typedef QQmlSequence<QList<QString> > QQmlStringList;
-template<>
-DEFINE_OBJECT_VTABLE(QQmlStringList);
+DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlStringList);
typedef QQmlSequence<QList<int> > QQmlIntList;
-template<>
-DEFINE_OBJECT_VTABLE(QQmlIntList);
+DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlIntList);
typedef QQmlSequence<QList<QUrl> > QQmlUrlList;
-template<>
-DEFINE_OBJECT_VTABLE(QQmlUrlList);
+DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlUrlList);
typedef QQmlSequence<QModelIndexList> QQmlQModelIndexList;
-template<>
-DEFINE_OBJECT_VTABLE(QQmlQModelIndexList);
+DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlQModelIndexList);
typedef QQmlSequence<QItemSelection> QQmlQItemSelectionRangeList;
-template<>
-DEFINE_OBJECT_VTABLE(QQmlQItemSelectionRangeList);
+DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlQItemSelectionRangeList);
typedef QQmlSequence<QList<bool> > QQmlBoolList;
-template<>
-DEFINE_OBJECT_VTABLE(QQmlBoolList);
+DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlBoolList);
typedef QQmlSequence<QList<qreal> > QQmlRealList;
-template<>
-DEFINE_OBJECT_VTABLE(QQmlRealList);
+DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlRealList);
}
diff --git a/src/qml/jsruntime/qv4util_p.h b/src/qml/jsruntime/qv4util_p.h
index 59c12c5e46..2669a3e4bf 100644
--- a/src/qml/jsruntime/qv4util_p.h
+++ b/src/qml/jsruntime/qv4util_p.h
@@ -90,6 +90,9 @@ public:
: bits(size, value)
{}
+ void clear()
+ { bits = std::vector<bool>(bits.size(), false); }
+
void reserve(int size)
{ bits.reserve(size); }
@@ -153,6 +156,9 @@ public:
: bits(size, value)
{}
+ void clear()
+ { bits = QBitArray(bits.size(), false); }
+
void reserve(int size)
{ Q_UNUSED(size); }
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index 6e28e21887..6d5cff4ecc 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -76,23 +76,85 @@ private:
/*
We use two different ways of encoding JS values. One for 32bit and one for 64bit systems.
- In both cases, we use 8 bytes for a value and a different variant of NaN boxing. A Double NaN (actually -qNaN)
- is indicated by a number that has the top 13 bits set. The other values are usually set to 0 by the
- processor, and are thus free for us to store other data. We keep pointers in there for managed objects,
- and encode the other types using the free space given to use by the unused bits for NaN values. This also
- works for pointers on 64 bit systems, as they all currently only have 48 bits of addressable memory.
-
- On 32bit, we store doubles as doubles. All other values, have the high 32bits set to a value that
- will make the number a NaN. The Masks below are used for encoding the other types.
-
- On 64 bit, we xor Doubles with (0xffff8000 << 32). That has the effect that no doubles will get encoded
- with the 13 highest bits all 0. We are now using special values for bits 14-17 to encode our values. These
- can be used, as the highest valid pointer on a 64 bit system is 2^48-1.
-
- If they are all 0, we have a pointer to a Managed object. If bit 14 is set we have an integer.
- This makes testing for pointers and numbers very fast (we have a number if any of the highest 14 bits is set).
-
- Bit 15-17 is then used to encode other immediates.
+ In both cases, we use 8 bytes for a value and a different variant of NaN boxing. A Double
+ NaN (actually -qNaN) is indicated by a number that has the top 13 bits set, and for a
+ signalling NaN it is the top 14 bits. The other values are usually set to 0 by the
+ processor, and are thus free for us to store other data. We keep pointers in there for
+ managed objects, and encode the other types using the free space given to use by the unused
+ bits for NaN values. This also works for pointers on 64 bit systems, as they all currently
+ only have 48 bits of addressable memory. (Note: we do leave the lower 49 bits available for
+ pointers.)
+
+ On 32bit, we store doubles as doubles. All other values, have the high 32bits set to a value
+ that will make the number a NaN. The Masks below are used for encoding the other types.
+
+ On 64 bit, we xor Doubles with (0xffff8000 << 32). That has the effect that no doubles will
+ get encoded with bits 63-49 all set to 0. We then use bit 48 to distinguish between
+ managed/undefined (0), or Null/Int/Bool/Empty (1). So, storing a 49 bit pointer will leave
+ the top 15 bits 0, which is exactly the 'natural' representation of pointers. If bit 49 is
+ set, bit 48 indicates Empty (0) or integer-convertible (1). Then the 3 bit below that are
+ used to encode Null/Int/Bool.
+
+ On both 32bit and 64bit, Undefined is encoded as a managed pointer with value 0. This is
+ the same as a nullptr.
+
+ Specific bit-sequences:
+ 0 = always 0
+ 1 = always 1
+ x = stored value
+ a,b,c,d = specific bit values, see notes
+
+ 64bit:
+
+ 32109876 54321098 76543210 98765432 10987654 32109876 54321098 76543210 |
+ 66665555 55555544 44444444 33333333 33222222 22221111 11111100 00000000 | JS Value
+ ------------------------------------------------------------------------+--------------
+ 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 | Undefined
+ 00000000 0000000x xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx | Managed (heap pointer)
+ a0000000 0000bc00 00000000 00000000 00000000 00000000 00000000 00000000 | NaN/Inf
+ dddddddd ddddddxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx | double
+ 00000000 00000010 00000000 00000000 00000000 00000000 00000000 00000000 | empty (non-sparse array hole)
+ 00000000 00000011 10000000 00000000 00000000 00000000 00000000 00000000 | Null
+ 00000000 00000011 01000000 00000000 00000000 00000000 00000000 0000000x | Bool
+ 00000000 00000011 00100000 00000000 xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx | Int
+
+ Notes:
+ - a: xor-ed signbit, always 1 for NaN
+ - bc, xor-ed values: 11 = inf, 10 = sNaN, 01 = qNaN, 00 = boxed value
+ - d: xor-ed bits, where at least one bit is set, so: (val >> (64-14)) > 0
+ - Undefined maps to C++ nullptr, so the "default" initialization is the same for both C++
+ and JS
+ - Managed has the left 15 bits set to 0, so: (val >> (64-15)) == 0
+ - empty, Null, Bool, and Int have the left 14 bits set to 0, and bit 49 set to 1,
+ so: (val >> (64-15)) == 1
+ - Null, Bool, and Int have bit 48 set, indicating integer-convertible
+ - xoring _val with NaNEncodeMask will convert to a double in "natural" representation, where
+ any non double results in a NaN
+
+ 32bit:
+
+ 32109876 54321098 76543210 98765432 10987654 32109876 54321098 76543210 |
+ 66665555 55555544 44444444 33333333 33222222 22221111 11111100 00000000 | JS Value
+ ------------------------------------------------------------------------+--------------
+ 01111111 11111100 00000000 00000000 00000000 00000000 00000000 00000000 | Undefined
+ 01111111 11111100 00000000 00000000 xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx | Managed (heap pointer)
+ a1111111 1111bc00 00000000 00000000 00000000 00000000 00000000 00000000 | NaN/Inf
+ xddddddd ddddddxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx | double
+ 01111111 11111110 00000000 00000000 00000000 00000000 00000000 00000000 | empty (non-sparse array hole)
+ 01111111 11111111 10000000 00000000 00000000 00000000 00000000 00000000 | Null
+ 01111111 11111111 01000000 00000000 00000000 00000000 00000000 0000000x | Bool
+ 01111111 11111111 00100000 00000000 xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx | Int
+
+ Notes:
+ - the upper 32 bits are the tag, the lower 32 bits the value
+ - Undefined has a nullptr in the value, Managed has a non-nullptr stored in the value
+ - a: sign bit, always 0 for NaN
+ - b,c: 00=inf, 01 = sNaN, 10 = qNaN, 11 = boxed value
+ - d: stored double value, as long as not *all* of them are 1, because that's a boxed value
+ (see above)
+ - empty, Null, Bool, and Int have bit 63 set to 0, bits 62-50 set to 1 (same as undefined
+ and managed), and bit 49 set to 1 (where undefined and managed have it set to 0)
+ - Null, Bool, and Int have bit 48 set, indicating integer-convertible
*/
quint64 _val;
@@ -113,10 +175,7 @@ public:
Q_ALWAYS_INLINE quint32 value() const { return _val & quint64(~quint32(0)); }
Q_ALWAYS_INLINE quint32 tag() const { return _val >> 32; }
-#if defined(V4_BOOTSTRAP)
- Q_ALWAYS_INLINE Heap::Base *m() const { Q_UNREACHABLE(); return Q_NULLPTR; }
- Q_ALWAYS_INLINE void setM(Heap::Base *b) { Q_UNUSED(b); Q_UNREACHABLE(); }
-#elif defined(QV4_USE_64_BIT_VALUE_ENCODING)
+#if defined(QV4_USE_64_BIT_VALUE_ENCODING)
Q_ALWAYS_INLINE Heap::Base *m() const
{
Heap::Base *b;
@@ -140,7 +199,7 @@ public:
{
quint32 v;
memcpy(&v, &b, 4);
- setTagValue(Managed_Type, v);
+ setTagValue(Managed_Type_Internal, v);
}
#endif
@@ -156,12 +215,43 @@ public:
Q_ALWAYS_INLINE void setEmpty()
{
- setTagValue(Empty_Type, value());
+ setTagValue(Empty_Type_Internal, value());
}
Q_ALWAYS_INLINE void setEmpty(int i)
{
- setTagValue(Empty_Type, quint32(i));
+ setTagValue(Empty_Type_Internal, quint32(i));
+ }
+
+ Q_ALWAYS_INLINE void setEmpty(quint32 i)
+ {
+ setTagValue(Empty_Type_Internal, i);
+ }
+
+ Q_ALWAYS_INLINE quint32 emptyValue()
+ {
+ Q_ASSERT(isEmpty());
+ return quint32(value());
+ }
+
+ enum Type {
+ Undefined_Type,
+ Managed_Type,
+ Empty_Type,
+ Integer_Type,
+ Boolean_Type,
+ Null_Type,
+ Double_Type
+ };
+
+ inline Type type() const {
+ if (isUndefined()) return Undefined_Type;
+ if (isManaged()) return Managed_Type;
+ if (isEmpty()) return Empty_Type;
+ if (isInteger()) return Integer_Type;
+ if (isBoolean()) return Boolean_Type;
+ if (isNull()) return Null_Type;
+ Q_ASSERT(isDouble()); return Double_Type;
}
#ifndef QV4_USE_64_BIT_VALUE_ENCODING
@@ -169,101 +259,64 @@ public:
SilentNaNBit = 0x00040000,
NaN_Mask = 0x7ff80000,
NotDouble_Mask = 0x7ffa0000,
- Type_Mask = 0xffffc000,
- Immediate_Mask = NotDouble_Mask | 0x00004000 | SilentNaNBit,
- IsNullOrUndefined_Mask = Immediate_Mask | 0x08000,
+ Immediate_Mask = NotDouble_Mask | 0x00020000u | SilentNaNBit,
Tag_Shift = 32
};
- enum ValueType {
- Undefined_Type = Immediate_Mask | 0x00000,
- Null_Type = Immediate_Mask | 0x10000,
- Boolean_Type = Immediate_Mask | 0x08000,
- Integer_Type = Immediate_Mask | 0x18000,
- Managed_Type = NotDouble_Mask | 0x00000 | SilentNaNBit,
- Empty_Type = NotDouble_Mask | 0x18000 | SilentNaNBit
- };
-
- enum ImmediateFlags {
- ConvertibleToInt = Immediate_Mask | 0x1
- };
-
- enum ValueTypeInternal {
- Null_Type_Internal = Null_Type | ConvertibleToInt,
- Boolean_Type_Internal = Boolean_Type | ConvertibleToInt,
- Integer_Type_Internal = Integer_Type | ConvertibleToInt,
+ enum {
+ Managed_Type_Internal = NotDouble_Mask
};
#else
- static const quint64 NaNEncodeMask = 0xffff800000000000ll;
- static const quint64 IsInt32Mask = 0x0002000000000000ll;
- static const quint64 IsDoubleMask = 0xfffc000000000000ll;
- static const quint64 IsNumberMask = IsInt32Mask|IsDoubleMask;
- static const quint64 IsNullOrUndefinedMask = 0x0000800000000000ll;
- static const quint64 IsNullOrBooleanMask = 0x0001000000000000ll;
- static const quint64 IsConvertibleToIntMask = IsInt32Mask|IsNullOrBooleanMask;
+ static const quint64 NaNEncodeMask = 0xfffc000000000000ll;
+ static const quint64 Immediate_Mask = 0x00020000u; // bit 49
enum Masks {
NaN_Mask = 0x7ff80000,
- Type_Mask = 0xffff8000,
- IsDouble_Mask = 0xfffc0000,
- Immediate_Mask = 0x00018000,
- IsNullOrUndefined_Mask = 0x00008000,
- IsNullOrBoolean_Mask = 0x00010000,
- Tag_Shift = 32
- };
- enum ValueType {
- Undefined_Type = IsNullOrUndefined_Mask,
- Null_Type = IsNullOrUndefined_Mask|IsNullOrBoolean_Mask,
- Boolean_Type = IsNullOrBoolean_Mask,
- Integer_Type = 0x20000|IsNullOrBoolean_Mask,
- Managed_Type = 0,
- Empty_Type = Undefined_Type | 0x4000
};
enum {
IsDouble_Shift = 64-14,
- IsNumber_Shift = 64-15,
- IsConvertibleToInt_Shift = 64-16,
- IsManaged_Shift = 64-17
+ IsManagedOrUndefined_Shift = 64-15,
+ IsIntegerConvertible_Shift = 64-16,
+ Tag_Shift = 32,
+ IsDoubleTag_Shift = IsDouble_Shift - Tag_Shift,
+ Managed_Type_Internal = 0
};
-
-
+#endif
enum ValueTypeInternal {
- Null_Type_Internal = Null_Type,
- Boolean_Type_Internal = Boolean_Type,
- Integer_Type_Internal = Integer_Type
+ Empty_Type_Internal = Immediate_Mask | 0,
+ ConvertibleToInt = Immediate_Mask | 0x10000u, // bit 48
+ Null_Type_Internal = ConvertibleToInt | 0x08000u,
+ Boolean_Type_Internal = ConvertibleToInt | 0x04000u,
+ Integer_Type_Internal = ConvertibleToInt | 0x02000u
};
-#endif
-
- inline unsigned type() const {
- return tag() & Type_Mask;
- }
// used internally in property
- inline bool isEmpty() const { return tag() == Empty_Type; }
-
- inline bool isUndefined() const { return tag() == Undefined_Type; }
+ inline bool isEmpty() const { return tag() == Empty_Type_Internal; }
inline bool isNull() const { return tag() == Null_Type_Internal; }
- inline bool isBoolean() const { return tag ()== Boolean_Type_Internal; }
+ inline bool isBoolean() const { return tag() == Boolean_Type_Internal; }
+ inline bool isInteger() const { return tag() == Integer_Type_Internal; }
+ inline bool isNullOrUndefined() const { return isNull() || isUndefined(); }
+ inline bool isNumber() const { return isDouble() || isInteger(); }
+
#ifdef QV4_USE_64_BIT_VALUE_ENCODING
- inline bool isInteger() const { return (_val >> IsNumber_Shift) == 1; }
+ inline bool isUndefined() const { return _val == 0; }
inline bool isDouble() const { return (_val >> IsDouble_Shift); }
- inline bool isNumber() const { return (_val >> IsNumber_Shift); }
- inline bool isManaged() const { return !(_val >> IsManaged_Shift); }
- inline bool isNullOrUndefined() const { return ((_val >> IsManaged_Shift) & ~2) == 1; }
- inline bool integerCompatible() const { return ((_val >> IsConvertibleToInt_Shift) & ~2) == 1; }
+ inline bool isManaged() const { return !isUndefined() && ((_val >> IsManagedOrUndefined_Shift) == 0); }
+
+ inline bool integerCompatible() const {
+ return (_val >> IsIntegerConvertible_Shift) == 3;
+ }
static inline bool integerCompatible(Value a, Value b) {
return a.integerCompatible() && b.integerCompatible();
}
static inline bool bothDouble(Value a, Value b) {
return a.isDouble() && b.isDouble();
}
- inline bool isNaN() const { return (tag() & 0x7fff8000) == 0x00078000; }
+ inline bool isNaN() const { return (tag() & 0x7ffc0000 ) == 0x00040000; }
#else
- inline bool isInteger() const { return tag() == Integer_Type_Internal; }
+ inline bool isUndefined() const { return tag() == Managed_Type_Internal && value() == 0; }
inline bool isDouble() const { return (tag() & NotDouble_Mask) != NotDouble_Mask; }
- inline bool isNumber() const { return tag() == Integer_Type_Internal || (tag() & NotDouble_Mask) != NotDouble_Mask; }
- inline bool isManaged() const { return tag() == Managed_Type; }
- inline bool isNullOrUndefined() const { return (tag() & IsNullOrUndefined_Mask) == Undefined_Type; }
+ inline bool isManaged() const { return tag() == Managed_Type_Internal && !isUndefined(); }
inline bool integerCompatible() const { return (tag() & ConvertibleToInt) == ConvertibleToInt; }
static inline bool integerCompatible(Value a, Value b) {
return ((a.tag() & b.tag()) & ConvertibleToInt) == ConvertibleToInt;
@@ -491,6 +544,7 @@ ReturnedValue Heap::Base::asReturnedValue() const
struct Q_QML_PRIVATE_EXPORT Primitive : public Value
{
inline static Primitive emptyValue();
+ inline static Primitive emptyValue(uint v);
static inline Primitive fromBoolean(bool b);
static inline Primitive fromInt32(int i);
inline static Primitive undefinedValue();
@@ -509,14 +563,21 @@ struct Q_QML_PRIVATE_EXPORT Primitive : public Value
inline Primitive Primitive::undefinedValue()
{
Primitive v;
- v.setTagValue(Undefined_Type, 0);
+ v.setM(Q_NULLPTR);
return v;
}
inline Primitive Primitive::emptyValue()
{
Primitive v;
- v.setTagValue(Value::Empty_Type, 0);
+ v.setEmpty(0);
+ return v;
+}
+
+inline Primitive Primitive::emptyValue(uint e)
+{
+ Primitive v;
+ v.setEmpty(e);
return v;
}
@@ -544,7 +605,6 @@ inline Primitive Primitive::fromDouble(double d)
inline Primitive Primitive::fromInt32(int i)
{
Primitive v;
- v.setTagValue(Integer_Type_Internal, 0);
v.setInt_32(i);
return v;
}
@@ -562,31 +622,23 @@ inline Primitive Primitive::fromUInt32(uint i)
struct Encode {
static ReturnedValue undefined() {
- return quint64(Value::Undefined_Type) << Value::Tag_Shift;
+ return Primitive::undefinedValue().rawValue();
}
static ReturnedValue null() {
- return quint64(Value::Null_Type_Internal) << Value::Tag_Shift;
+ return Primitive::nullValue().rawValue();
}
Encode(bool b) {
- val = (quint64(Value::Boolean_Type_Internal) << Value::Tag_Shift) | (uint)b;
+ val = Primitive::fromBoolean(b).rawValue();
}
Encode(double d) {
- Value v;
- v.setDouble(d);
- val = v.rawValue();
+ val = Primitive::fromDouble(d).rawValue();
}
Encode(int i) {
- val = (quint64(Value::Integer_Type_Internal) << Value::Tag_Shift) | (uint)i;
+ val = Primitive::fromInt32(i).rawValue();
}
Encode(uint i) {
- if (i <= INT_MAX) {
- val = (quint64(Value::Integer_Type_Internal) << Value::Tag_Shift) | i;
- } else {
- Value v;
- v.setDouble(i);
- val = v.rawValue();
- }
+ val = Primitive::fromUInt32(i).rawValue();
}
Encode(ReturnedValue v) {
val = v;
diff --git a/src/qml/jsruntime/qv4variantobject.cpp b/src/qml/jsruntime/qv4variantobject.cpp
index b26dd27913..455a7ccb65 100644
--- a/src/qml/jsruntime/qv4variantobject.cpp
+++ b/src/qml/jsruntime/qv4variantobject.cpp
@@ -141,8 +141,11 @@ QV4::ReturnedValue VariantPrototype::method_toString(CallContext *ctx)
if (!o)
return Encode::undefined();
QString result = o->d()->data().toString();
- if (result.isEmpty() && !o->d()->data().canConvert(QVariant::String))
- result = QStringLiteral("QVariant(%0)").arg(QString::fromLatin1(o->d()->data().typeName()));
+ if (result.isEmpty() && !o->d()->data().canConvert(QVariant::String)) {
+ result = QLatin1String("QVariant(")
+ + QLatin1String(o->d()->data().typeName())
+ + QLatin1Char(')');
+ }
return Encode(ctx->d()->engine->newString(result));
}
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index 9d18713253..0f7f6b1f75 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -571,7 +571,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code
#endif // DO_TRACE_INSTR
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
- callData->tag = QV4::Value::Integer_Type;
+ callData->tag = QV4::Value::Integer_Type_Internal;
callData->argc = instr.argc;
callData->thisObject = QV4::Primitive::undefinedValue();
STOREVALUE(instr.result, engine->runtime.callValue(engine, VALUE(instr.dest), callData));
@@ -581,7 +581,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code
TRACE(property name, "%s, args=%u, argc=%u, this=%s", qPrintable(runtimeStrings[instr.name]->toQString()), instr.callData, instr.argc, (VALUE(instr.base)).toString(context)->toQString().toUtf8().constData());
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
- callData->tag = QV4::Value::Integer_Type;
+ callData->tag = QV4::Value::Integer_Type_Internal;
callData->argc = instr.argc;
callData->thisObject = VALUE(instr.base);
STOREVALUE(instr.result, engine->runtime.callProperty(engine, instr.name, callData));
@@ -590,7 +590,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code
MOTH_BEGIN_INSTR(CallPropertyLookup)
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
- callData->tag = QV4::Value::Integer_Type;
+ callData->tag = QV4::Value::Integer_Type_Internal;
callData->argc = instr.argc;
callData->thisObject = VALUE(instr.base);
STOREVALUE(instr.result, engine->runtime.callPropertyLookup(engine, instr.lookupIndex, callData));
@@ -600,7 +600,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code
TRACE(property name, "%s, args=%u, argc=%u, this=%s", qPrintable(runtimeStrings[instr.name]->toQString()), instr.callData, instr.argc, (VALUE(instr.base)).toString(context)->toQString().toUtf8().constData());
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
- callData->tag = QV4::Value::Integer_Type;
+ callData->tag = QV4::Value::Integer_Type_Internal;
callData->argc = instr.argc;
callData->thisObject = VALUE(instr.base);
STOREVALUE(instr.result, engine->runtime.callQmlScopeObjectProperty(engine, instr.index, callData));
@@ -610,7 +610,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code
TRACE(property name, "%s, args=%u, argc=%u, this=%s", qPrintable(runtimeStrings[instr.name]->toQString()), instr.callData, instr.argc, (VALUE(instr.base)).toString(context)->toQString().toUtf8().constData());
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
- callData->tag = QV4::Value::Integer_Type;
+ callData->tag = QV4::Value::Integer_Type_Internal;
callData->argc = instr.argc;
callData->thisObject = VALUE(instr.base);
STOREVALUE(instr.result, engine->runtime.callQmlContextObjectProperty(engine, instr.index, callData));
@@ -619,7 +619,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code
MOTH_BEGIN_INSTR(CallElement)
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
- callData->tag = QV4::Value::Integer_Type;
+ callData->tag = QV4::Value::Integer_Type_Internal;
callData->argc = instr.argc;
callData->thisObject = VALUE(instr.base);
STOREVALUE(instr.result, engine->runtime.callElement(engine, VALUE(instr.index), callData));
@@ -628,7 +628,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code
MOTH_BEGIN_INSTR(CallActivationProperty)
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
- callData->tag = QV4::Value::Integer_Type;
+ callData->tag = QV4::Value::Integer_Type_Internal;
callData->argc = instr.argc;
callData->thisObject = QV4::Primitive::undefinedValue();
STOREVALUE(instr.result, engine->runtime.callActivationProperty(engine, instr.name, callData));
@@ -637,7 +637,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code
MOTH_BEGIN_INSTR(CallGlobalLookup)
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
- callData->tag = QV4::Value::Integer_Type;
+ callData->tag = QV4::Value::Integer_Type_Internal;
callData->argc = instr.argc;
callData->thisObject = QV4::Primitive::undefinedValue();
STOREVALUE(instr.result, Runtime::method_callGlobalLookup(engine, instr.index, callData));
@@ -743,7 +743,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code
MOTH_BEGIN_INSTR(CreateValue)
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
- callData->tag = QV4::Value::Integer_Type;
+ callData->tag = QV4::Value::Integer_Type_Internal;
callData->argc = instr.argc;
callData->thisObject = QV4::Primitive::undefinedValue();
STOREVALUE(instr.result, engine->runtime.constructValue(engine, VALUE(instr.func), callData));
@@ -752,7 +752,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code
MOTH_BEGIN_INSTR(CreateProperty)
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
- callData->tag = QV4::Value::Integer_Type;
+ callData->tag = QV4::Value::Integer_Type_Internal;
callData->argc = instr.argc;
callData->thisObject = VALUE(instr.base);
STOREVALUE(instr.result, engine->runtime.constructProperty(engine, instr.name, callData));
@@ -761,7 +761,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code
MOTH_BEGIN_INSTR(ConstructPropertyLookup)
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
- callData->tag = QV4::Value::Integer_Type;
+ callData->tag = QV4::Value::Integer_Type_Internal;
callData->argc = instr.argc;
callData->thisObject = VALUE(instr.base);
STOREVALUE(instr.result, engine->runtime.constructPropertyLookup(engine, instr.index, callData));
@@ -770,7 +770,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code
MOTH_BEGIN_INSTR(CreateActivationProperty)
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
- callData->tag = QV4::Value::Integer_Type;
+ callData->tag = QV4::Value::Integer_Type_Internal;
callData->argc = instr.argc;
callData->thisObject = QV4::Primitive::undefinedValue();
STOREVALUE(instr.result, engine->runtime.constructActivationProperty(engine, instr.name, callData));
@@ -779,7 +779,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code
MOTH_BEGIN_INSTR(ConstructGlobalLookup)
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
- callData->tag = QV4::Value::Integer_Type;
+ callData->tag = QV4::Value::Integer_Type_Internal;
callData->argc = instr.argc;
callData->thisObject = QV4::Primitive::undefinedValue();
STOREVALUE(instr.result, engine->runtime.constructGlobalLookup(engine, instr.index, callData));
diff --git a/src/qml/jsruntime/qv4vme_moth_p.h b/src/qml/jsruntime/qv4vme_moth_p.h
index cd8d335f1c..f8893509d9 100644
--- a/src/qml/jsruntime/qv4vme_moth_p.h
+++ b/src/qml/jsruntime/qv4vme_moth_p.h
@@ -51,9 +51,12 @@
// We mean it.
//
+#include <private/qv4global_p.h>
#include <private/qv4runtime_p.h>
#include <private/qv4instr_moth_p.h>
+QT_REQUIRE_CONFIG(qml_interpreter);
+
QT_BEGIN_NAMESPACE
namespace QV4 {
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp
index ad4ecfe76d..6ef2380561 100644
--- a/src/qml/memory/qv4mm.cpp
+++ b/src/qml/memory/qv4mm.cpp
@@ -46,7 +46,7 @@
#include "PageAllocation.h"
#include "StdLibExtras.h"
-#include <QTime>
+#include <QElapsedTimer>
#include <QMap>
#include <QScopedValueRollback>
@@ -234,7 +234,7 @@ bool sweepChunk(MemoryManager::Data::ChunkHeader *header, uint *itemsInUse, Exec
m->_checkIsDestroyed();
}
- memset(m, 0, header->itemSize);
+ memset(m, 0, sizeof(Heap::Base));
#ifdef V4_USE_VALGRIND
VALGRIND_DISABLE_ERROR_REPORTING;
VALGRIND_MEMPOOL_FREE(engine->memoryManager, m);
@@ -484,7 +484,7 @@ void MemoryManager::sweep(bool lastSweep)
remainingWeakQObjectWrappers.reserve(pendingCount);
for (int i = 0; i < pendingCount; ++i) {
Value *v = m_pendingFreedObjectWrapperValue.at(i);
- if (v->tag() == Value::Undefined_Type)
+ if (v->isUndefined() || v->isEmpty())
PersistentValueStorage::free(v);
else
remainingWeakQObjectWrappers.append(v);
@@ -596,18 +596,17 @@ void MemoryManager::runGC()
} else {
const size_t totalMem = getAllocatedMem();
- QTime t;
+ QElapsedTimer t;
t.start();
mark();
- int markTime = t.elapsed();
- t.restart();
+ qint64 markTime = t.restart();
const size_t usedBefore = getUsedMem();
const size_t largeItemsBefore = getLargeItemsMem();
size_t chunksBefore = m_d->heapChunks.size();
sweep();
const size_t usedAfter = getUsedMem();
const size_t largeItemsAfter = getLargeItemsMem();
- int sweepTime = t.elapsed();
+ qint64 sweepTime = t.elapsed();
qDebug() << "========== GC ==========";
qDebug() << "Marked object in" << markTime << "ms.";
diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h
index e68fc07a46..dfa0d85dff 100644
--- a/src/qml/memory/qv4mm_p.h
+++ b/src/qml/memory/qv4mm_p.h
@@ -111,6 +111,7 @@ public:
V4_ASSERT_IS_TRIVIAL(typename ManagedType::Data)
size = align(size);
Heap::Base *o = allocData(size, unmanagedSize);
+ memset(o, 0, size);
o->setVtable(ManagedType::staticVTable());
return static_cast<typename ManagedType::Data *>(o);
}
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index 2ca4e883d6..846ea42571 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -273,12 +273,12 @@ public:
: expression(expression)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return lparenToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rparenToken; }
// attributes
@@ -294,12 +294,12 @@ public:
ThisExpression() { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return thisToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return thisToken; }
// attributes
@@ -314,12 +314,12 @@ public:
IdentifierExpression(const QStringRef &n):
name (n) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return identifierToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return identifierToken; }
// attributes
@@ -334,12 +334,12 @@ public:
NullExpression() { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return nullToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return nullToken; }
// attributes
@@ -353,12 +353,12 @@ public:
TrueLiteral() { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return trueToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return trueToken; }
// attributes
@@ -372,12 +372,12 @@ public:
FalseLiteral() { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return falseToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return falseToken; }
// attributes
@@ -392,12 +392,12 @@ public:
NumericLiteral(double v):
value(v) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return literalToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return literalToken; }
// attributes:
@@ -413,12 +413,12 @@ public:
StringLiteral(const QStringRef &v):
value (v) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return literalToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return literalToken; }
// attributes:
@@ -434,12 +434,12 @@ public:
RegExpLiteral(const QStringRef &p, int f):
pattern (p), flags (f) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return literalToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return literalToken; }
// attributes:
@@ -465,12 +465,12 @@ public:
elements (elts), elision (e)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return lbracketToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rbracketToken; }
// attributes
@@ -492,12 +492,12 @@ public:
ObjectLiteral(PropertyAssignmentList *plist):
properties (plist) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return lbraceToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rbraceToken; }
// attributes
@@ -521,12 +521,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return commaToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : commaToken; }
inline Elision *finish ()
@@ -565,16 +565,16 @@ public:
return front;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{
if (elision)
return elision->firstSourceLocation();
return expression->firstSourceLocation();
}
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{
if (next)
return next->lastSourceLocation();
@@ -595,10 +595,10 @@ public:
PropertyName() { kind = K; }
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return propertyNameToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return propertyNameToken; }
virtual QString asString() const = 0;
@@ -642,12 +642,12 @@ public:
return front;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return assignment->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : assignment->lastSourceLocation(); }
// attributes
@@ -665,12 +665,12 @@ public:
: PropertyAssignment(n), value(v)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return name->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return value->lastSourceLocation(); }
// attributes
@@ -697,12 +697,12 @@ public:
: PropertyAssignment(n), type(Setter), formals(f), functionBody (b)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return getSetToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rbraceToken; }
// attributes
@@ -724,9 +724,9 @@ public:
IdentifierPropertyName(const QStringRef &n):
id (n) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual QString asString() const { return id.toString(); }
+ QString asString() const override { return id.toString(); }
// attributes
QStringRef id;
@@ -740,9 +740,9 @@ public:
StringLiteralPropertyName(const QStringRef &n):
id (n) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual QString asString() const { return id.toString(); }
+ QString asString() const override { return id.toString(); }
// attributes
QStringRef id;
@@ -756,9 +756,9 @@ public:
NumericLiteralPropertyName(double n):
id (n) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual QString asString() const { return QString::number(id, 'g', 16); }
+ QString asString() const override { return QString::number(id, 'g', 16); }
// attributes
double id;
@@ -773,12 +773,12 @@ public:
base (b), expression (e)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return base->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rbracketToken; }
// attributes
@@ -797,12 +797,12 @@ public:
base (b), name (n)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return base->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return identifierToken; }
// attributes
@@ -821,12 +821,12 @@ public:
base (b), arguments (a)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return newToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rparenToken; }
// attributes
@@ -845,12 +845,12 @@ public:
NewExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return newToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -867,12 +867,12 @@ public:
base (b), arguments (a)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return base->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rparenToken; }
// attributes
@@ -899,12 +899,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return expression->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{
if (next)
return next->lastSourceLocation();
@@ -932,12 +932,12 @@ public:
PostIncrementExpression(ExpressionNode *b):
base (b) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return base->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return incrementToken; }
// attributes
@@ -953,12 +953,12 @@ public:
PostDecrementExpression(ExpressionNode *b):
base (b) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return base->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return decrementToken; }
// attributes
@@ -974,12 +974,12 @@ public:
DeleteExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return deleteToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -995,12 +995,12 @@ public:
VoidExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return voidToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -1016,12 +1016,12 @@ public:
TypeOfExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return typeofToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -1037,12 +1037,12 @@ public:
PreIncrementExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return incrementToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -1058,12 +1058,12 @@ public:
PreDecrementExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return decrementToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -1079,12 +1079,12 @@ public:
UnaryPlusExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return plusToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -1100,12 +1100,12 @@ public:
UnaryMinusExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return minusToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -1121,12 +1121,12 @@ public:
TildeExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return tildeToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -1142,12 +1142,12 @@ public:
NotExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return notToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -1164,14 +1164,14 @@ public:
left (l), op (o), right (r)
{ kind = K; }
- virtual BinaryExpression *binaryExpressionCast();
+ BinaryExpression *binaryExpressionCast() override;
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return left->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return right->lastSourceLocation(); }
// attributes
@@ -1190,12 +1190,12 @@ public:
expression (e), ok (t), ko (f)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return expression->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return ko->lastSourceLocation(); }
// attributes
@@ -1214,12 +1214,12 @@ public:
Expression(ExpressionNode *l, ExpressionNode *r):
left (l), right (r) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return left->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return right->lastSourceLocation(); }
// attributes
@@ -1236,12 +1236,12 @@ public:
Block(StatementList *slist):
statements (slist) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return lbraceToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rbraceToken; }
// attributes
@@ -1267,12 +1267,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return statement->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : statement->lastSourceLocation(); }
inline StatementList *finish ()
@@ -1296,12 +1296,12 @@ public:
declarations (vlist)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return declarationKindToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -1319,12 +1319,12 @@ public:
name (n), expression (e), readOnly(false)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return identifierToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression ? expression->lastSourceLocation() : identifierToken; }
// attributes
@@ -1351,12 +1351,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return declaration->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{
if (next)
return next->lastSourceLocation();
@@ -1388,12 +1388,12 @@ public:
EmptyStatement() { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return semicolonToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -1408,12 +1408,12 @@ public:
ExpressionStatement(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return expression->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -1430,12 +1430,12 @@ public:
expression (e), ok (t), ko (f)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return ifToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{
if (ko)
return ko->lastSourceLocation();
@@ -1462,12 +1462,12 @@ public:
statement (stmt), expression (e)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return doToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -1489,12 +1489,12 @@ public:
expression (e), statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return whileToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
// attributes
@@ -1514,12 +1514,12 @@ public:
initialiser (i), condition (c), expression (e), statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return forToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
// attributes
@@ -1543,12 +1543,12 @@ public:
declarations (vlist), condition (c), expression (e), statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return forToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
// attributes
@@ -1573,12 +1573,12 @@ public:
initialiser (i), expression (e), statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return forToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
// attributes
@@ -1600,12 +1600,12 @@ public:
declaration (v), expression (e), statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return forToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
// attributes
@@ -1627,12 +1627,12 @@ public:
ContinueStatement(const QStringRef &l = QStringRef()):
label (l) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return continueToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -1650,12 +1650,12 @@ public:
BreakStatement(const QStringRef &l):
label (l) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return breakToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -1673,12 +1673,12 @@ public:
ReturnStatement(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return returnToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -1696,12 +1696,12 @@ public:
expression (e), statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return withToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
// attributes
@@ -1721,12 +1721,12 @@ public:
clauses (c), defaultClause (d), moreClauses (r)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return lbraceToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rbraceToken; }
// attributes
@@ -1746,12 +1746,12 @@ public:
expression (e), block (b)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return switchToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return block->rbraceToken; }
// attributes
@@ -1771,12 +1771,12 @@ public:
expression (e), statements (slist)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return caseToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statements ? statements->lastSourceLocation() : colonToken; }
// attributes
@@ -1803,12 +1803,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return clause->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : clause->lastSourceLocation(); }
inline CaseClauses *finish ()
@@ -1832,12 +1832,12 @@ public:
statements (slist)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return defaultToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statements ? statements->lastSourceLocation() : colonToken; }
// attributes
@@ -1855,12 +1855,12 @@ public:
label (l), statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return identifierToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
// attributes
@@ -1878,12 +1878,12 @@ public:
ThrowStatement(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return throwToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -1901,12 +1901,12 @@ public:
name (n), statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return catchToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
// attributes
@@ -1927,12 +1927,12 @@ public:
statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return finallyToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement ? statement->lastSourceLocation() : finallyToken; }
// attributes
@@ -1957,12 +1957,12 @@ public:
statement (stmt), catchExpression (c), finallyExpression (0)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return tryToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{
if (finallyExpression)
return finallyExpression->statement->rbraceToken;
@@ -1988,12 +1988,12 @@ public:
name (n), formals (f), body (b)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return functionToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rbraceToken; }
// attributes
@@ -2017,7 +2017,7 @@ public:
FunctionExpression(n, f, b)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
};
class QML_PARSER_EXPORT FormalParameterList: public Node
@@ -2037,12 +2037,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return identifierToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : identifierToken; }
inline FormalParameterList *finish ()
@@ -2085,12 +2085,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return element->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : element->lastSourceLocation(); }
inline SourceElements *finish ()
@@ -2114,12 +2114,12 @@ public:
elements (elts)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return elements ? elements->firstSourceLocation() : SourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return elements ? elements->lastSourceLocation() : SourceLocation(); }
// attributes
@@ -2135,12 +2135,12 @@ public:
elements (elts)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return elements ? elements->firstSourceLocation() : SourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return elements ? elements->lastSourceLocation() : SourceLocation(); }
// attributes
@@ -2156,12 +2156,12 @@ public:
declaration (f)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return declaration->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return declaration->lastSourceLocation(); }
// attributes
@@ -2177,12 +2177,12 @@ public:
statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return statement->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
// attributes
@@ -2197,12 +2197,12 @@ public:
DebuggerStatement()
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return debuggerToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -2234,12 +2234,12 @@ public:
return head;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return identifierToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : identifierToken; }
// attributes
@@ -2261,12 +2261,12 @@ public:
: importUri(uri)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return importToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -2284,10 +2284,10 @@ public:
class QML_PARSER_EXPORT UiObjectMember: public Node
{
public:
- virtual SourceLocation firstSourceLocation() const = 0;
- virtual SourceLocation lastSourceLocation() const = 0;
+ SourceLocation firstSourceLocation() const override = 0;
+ SourceLocation lastSourceLocation() const override = 0;
- virtual UiObjectMember *uiObjectMemberCast();
+ UiObjectMember *uiObjectMemberCast() override;
};
class QML_PARSER_EXPORT UiObjectMemberList: public Node
@@ -2307,12 +2307,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return member->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : member->lastSourceLocation(); }
UiObjectMemberList *finish()
@@ -2351,12 +2351,12 @@ public:
return head;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return identifierToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : identifierToken; }
// attributes
@@ -2374,12 +2374,12 @@ public:
: pragmaType(type)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return pragmaToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -2424,12 +2424,12 @@ public:
return head;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return headerItem->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : headerItem->lastSourceLocation(); }
// attributes
@@ -2446,9 +2446,9 @@ public:
: headers(headers), members(members)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{
if (headers)
return headers->firstSourceLocation();
@@ -2457,7 +2457,7 @@ public:
return SourceLocation();
}
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{
if (members)
return members->lastSourceLocation();
@@ -2488,12 +2488,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return member->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : member->lastSourceLocation(); }
UiArrayMemberList *finish()
@@ -2518,12 +2518,12 @@ public:
: members(members)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return lbraceToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rbraceToken; }
// attributes
@@ -2549,12 +2549,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *);
+ void accept0(Visitor *) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return propertyTypeToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : identifierToken; }
inline UiParameterList *finish ()
@@ -2589,9 +2589,9 @@ public:
: type(Property), memberType(memberType), name(name), statement(statement), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{
if (defaultToken.isValid())
return defaultToken;
@@ -2601,7 +2601,7 @@ public:
return propertyToken;
}
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{
if (binding)
return binding->lastSourceLocation();
@@ -2641,12 +2641,12 @@ public:
: qualifiedTypeNameId(qualifiedTypeNameId), initializer(initializer)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return qualifiedTypeNameId->identifierToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return initializer->rbraceToken; }
// attributes
@@ -2663,7 +2663,7 @@ public:
: sourceElement(sourceElement)
{ kind = K; }
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{
if (FunctionDeclaration *funDecl = cast<FunctionDeclaration *>(sourceElement))
return funDecl->firstSourceLocation();
@@ -2673,7 +2673,7 @@ public:
return SourceLocation();
}
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{
if (FunctionDeclaration *funDecl = cast<FunctionDeclaration *>(sourceElement))
return funDecl->lastSourceLocation();
@@ -2683,7 +2683,7 @@ public:
return SourceLocation();
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
// attributes
@@ -2704,7 +2704,7 @@ public:
hasOnToken(false)
{ kind = K; }
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{
if (hasOnToken && qualifiedTypeNameId)
return qualifiedTypeNameId->identifierToken;
@@ -2712,10 +2712,10 @@ public:
return qualifiedId->identifierToken;
}
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return initializer->rbraceToken; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
// attributes
@@ -2737,13 +2737,13 @@ public:
statement(statement)
{ kind = K; }
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return qualifiedId->identifierToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
// attributes
UiQualifiedId *qualifiedId;
@@ -2762,13 +2762,13 @@ public:
members(members)
{ kind = K; }
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return qualifiedId->identifierToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rbracketToken; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
// attributes
UiQualifiedId *qualifiedId;
diff --git a/src/qml/qml.pro b/src/qml/qml.pro
index 13e00d8812..826a074701 100644
--- a/src/qml/qml.pro
+++ b/src/qml/qml.pro
@@ -1,11 +1,8 @@
TARGET = QtQml
QT = core-private
-no_network {
- DEFINES += QT_NO_NETWORK
-} else {
+qtConfig(qml-network): \
QT += network
-}
DEFINES += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES
@@ -22,11 +19,6 @@ exists("qqml_enable_gcov") {
LIBS_PRIVATE += -lgcov
}
-gcc:!intel_icc:greaterThan(QT_GCC_MAJOR_VERSION, 5) {
- # Our code is bad. Temporary workaround.
- QMAKE_CXXFLAGS += -fno-delete-null-pointer-checks -fno-lifetime-dse
-}
-
# QTBUG-55238, disable new optimizer for MSVC 2015/Update 3.
release:win32-msvc*:equals(QT_CL_MAJOR_VERSION, 19):equals(QT_CL_MINOR_VERSION, 00): \
greaterThan(QT_CL_PATCH_VERSION, 24212):QMAKE_CXXFLAGS += -d2SSAOptimizer-
diff --git a/src/qml/qml/ftw/qqmlthread.cpp b/src/qml/qml/ftw/qqmlthread.cpp
index 1523817c9e..ffa6e29290 100644
--- a/src/qml/qml/ftw/qqmlthread.cpp
+++ b/src/qml/qml/ftw/qqmlthread.cpp
@@ -55,7 +55,7 @@ public:
QQmlThreadPrivate(QQmlThread *);
QQmlThread *q;
- virtual void run();
+ void run() override;
inline void lock() { _mutex.lock(); }
inline void unlock() { _mutex.unlock(); }
@@ -81,12 +81,12 @@ public:
void threadEvent();
protected:
- virtual bool event(QEvent *);
+ bool event(QEvent *) override;
private:
struct MainObject : public QObject {
MainObject(QQmlThreadPrivate *p);
- virtual bool event(QEvent *e);
+ bool event(QEvent *e) override;
QQmlThreadPrivate *p;
};
MainObject m_mainObject;
diff --git a/src/qml/qml/ftw/qqmlthread_p.h b/src/qml/qml/ftw/qqmlthread_p.h
index 9f180b1f14..295235e255 100644
--- a/src/qml/qml/ftw/qqmlthread_p.h
+++ b/src/qml/qml/ftw/qqmlthread_p.h
@@ -142,7 +142,7 @@ void QQmlThread::callMethodInThread(void (O::*Member)())
struct I : public Message {
void (O::*Member)();
I(void (O::*Member)()) : Member(Member) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)();
}
@@ -157,7 +157,7 @@ void QQmlThread::callMethodInThread(void (O::*Member)(V), const T &arg)
void (O::*Member)(V);
T arg;
I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)(arg);
}
@@ -173,7 +173,7 @@ void QQmlThread::callMethodInThread(void (O::*Member)(V, V2), const T &arg, cons
T arg;
T2 arg2;
I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)(arg, arg2);
}
@@ -187,7 +187,7 @@ void QQmlThread::callMethodInMain(void (O::*Member)())
struct I : public Message {
void (O::*Member)();
I(void (O::*Member)()) : Member(Member) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)();
}
@@ -202,7 +202,7 @@ void QQmlThread::callMethodInMain(void (O::*Member)(V), const T &arg)
void (O::*Member)(V);
T arg;
I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)(arg);
}
@@ -218,7 +218,7 @@ void QQmlThread::callMethodInMain(void (O::*Member)(V, V2), const T &arg, const
T arg;
T2 arg2;
I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)(arg, arg2);
}
@@ -232,7 +232,7 @@ void QQmlThread::postMethodToThread(void (O::*Member)())
struct I : public Message {
void (O::*Member)();
I(void (O::*Member)()) : Member(Member) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)();
}
@@ -247,7 +247,7 @@ void QQmlThread::postMethodToThread(void (O::*Member)(V), const T &arg)
void (O::*Member)(V);
T arg;
I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)(arg);
}
@@ -263,7 +263,7 @@ void QQmlThread::postMethodToThread(void (O::*Member)(V, V2), const T &arg, cons
T arg;
T2 arg2;
I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)(arg, arg2);
}
@@ -277,7 +277,7 @@ void QQmlThread::postMethodToMain(void (O::*Member)())
struct I : public Message {
void (O::*Member)();
I(void (O::*Member)()) : Member(Member) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)();
}
@@ -292,7 +292,7 @@ void QQmlThread::postMethodToMain(void (O::*Member)(V), const T &arg)
void (O::*Member)(V);
T arg;
I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)(arg);
}
@@ -308,7 +308,7 @@ void QQmlThread::postMethodToMain(void (O::*Member)(V, V2), const T &arg, const
T arg;
T2 arg2;
I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {}
- virtual void call(QQmlThread *thread) {
+ void call(QQmlThread *thread) override {
O *me = static_cast<O *>(thread);
(me->*Member)(arg, arg2);
}
diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp
index fef2da753b..1a912d53e6 100644
--- a/src/qml/qml/qqmlapplicationengine.cpp
+++ b/src/qml/qml/qqmlapplicationengine.cpp
@@ -287,14 +287,27 @@ void QQmlApplicationEngine::loadData(const QByteArray &data, const QUrl &url)
Returns a list of all the root objects instantiated by the
QQmlApplicationEngine. This will only contain objects loaded via load() or a
convenience constructor.
+
+ \note In Qt versions prior to 5.9, this function is marked as non-\c{const}.
*/
-QList<QObject *> QQmlApplicationEngine::rootObjects()
+QList<QObject *> QQmlApplicationEngine::rootObjects() const
{
- Q_D(QQmlApplicationEngine);
+ Q_D(const QQmlApplicationEngine);
return d->objects;
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+/*!
+ \overload
+ \internal
+*/
+QList<QObject *> QQmlApplicationEngine::rootObjects()
+{
+ return qAsConst(*this).rootObjects();
+}
+#endif // < Qt 6
+
QT_END_NAMESPACE
#include "moc_qqmlapplicationengine.cpp"
diff --git a/src/qml/qml/qqmlapplicationengine.h b/src/qml/qml/qqmlapplicationengine.h
index ff7dce5f8b..e64d7495cd 100644
--- a/src/qml/qml/qqmlapplicationengine.h
+++ b/src/qml/qml/qqmlapplicationengine.h
@@ -58,7 +58,11 @@ public:
QQmlApplicationEngine(const QString &filePath, QObject *parent = Q_NULLPTR);
~QQmlApplicationEngine();
- QList<QObject*> rootObjects();
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ QList<QObject*> rootObjects(); // ### Qt 6: remove
+#endif
+ QList<QObject*> rootObjects() const;
+
public Q_SLOTS:
void load(const QUrl &url);
void load(const QString &filePath);
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index 203bfec838..4fe76ddf29 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -449,7 +449,7 @@ QVariant QQmlBinding::evaluate()
return scope.engine->toVariant(scope.result, qMetaTypeId<QList<QObject*> >());
}
-QString QQmlBinding::expressionIdentifier()
+QString QQmlBinding::expressionIdentifier() const
{
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context()->engine);
QV4::Scope scope(ep->v4engine());
diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h
index 6d42a8ea8a..be23a96d01 100644
--- a/src/qml/qml/qqmlbinding_p.h
+++ b/src/qml/qml/qqmlbinding_p.h
@@ -98,8 +98,8 @@ public:
QVariant evaluate();
- QString expressionIdentifier() Q_DECL_OVERRIDE;
- void expressionChanged() Q_DECL_OVERRIDE;
+ QString expressionIdentifier() const override;
+ void expressionChanged() override;
protected:
virtual void doUpdate(const DeleteWatcher &watcher,
diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp
index 4e63790290..dfb1b98ca0 100644
--- a/src/qml/qml/qqmlboundsignal.cpp
+++ b/src/qml/qml/qqmlboundsignal.cpp
@@ -146,7 +146,7 @@ QQmlBoundSignalExpression::~QQmlBoundSignalExpression()
{
}
-QString QQmlBoundSignalExpression::expressionIdentifier()
+QString QQmlBoundSignalExpression::expressionIdentifier() const
{
QQmlSourceLocation loc = sourceLocation();
return loc.sourceFile + QLatin1Char(':') + QString::number(loc.line);
diff --git a/src/qml/qml/qqmlboundsignal_p.h b/src/qml/qml/qqmlboundsignal_p.h
index 10c59b07c1..4356c6cbfa 100644
--- a/src/qml/qml/qqmlboundsignal_p.h
+++ b/src/qml/qml/qqmlboundsignal_p.h
@@ -79,8 +79,8 @@ public:
QQmlContextData *ctxt, QObject *scope, QV4::Function *runtimeFunction);
// inherited from QQmlJavaScriptExpression.
- virtual QString expressionIdentifier();
- virtual void expressionChanged();
+ QString expressionIdentifier() const override;
+ void expressionChanged() override;
// evaluation of a bound signal expression doesn't return any value
void evaluate(void **a);
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 8be5172cd4..6ebcd142fb 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -376,7 +376,7 @@ QQmlComponent::~QQmlComponent()
if (isError()) {
qWarning() << "This may have been caused by one of the following errors:";
- foreach (const QQmlError &error, d->state.errors)
+ for (const QQmlError &error : qAsConst(d->state.errors))
qWarning().nospace().noquote() << QLatin1String(" ") << error;
}
@@ -709,7 +709,7 @@ QString QQmlComponent::errorString() const
QString ret;
if(!isError())
return ret;
- foreach(const QQmlError &e, d->state.errors) {
+ for (const QQmlError &e : d->state.errors) {
ret += e.url().toString() + QLatin1Char(':') +
QString::number(e.line()) + QLatin1Char(' ') +
e.description() + QLatin1Char('\n');
@@ -1098,13 +1098,13 @@ public:
, incubatorObject(inc)
{}
- virtual void statusChanged(Status s) {
+ void statusChanged(Status s) override {
QV4::Scope scope(incubatorObject->internalClass->engine);
QV4::Scoped<QV4::QmlIncubatorObject> i(scope, incubatorObject);
i->statusChanged(s);
}
- virtual void setInitialState(QObject *o) {
+ void setInitialState(QObject *o) override {
QV4::Scope scope(incubatorObject->internalClass->engine);
QV4::Scoped<QV4::QmlIncubatorObject> i(scope, incubatorObject);
i->setInitialState(o);
diff --git a/src/qml/qml/qqmlcomponent_p.h b/src/qml/qml/qqmlcomponent_p.h
index 3a84e724da..d01a987acc 100644
--- a/src/qml/qml/qqmlcomponent_p.h
+++ b/src/qml/qml/qqmlcomponent_p.h
@@ -89,8 +89,8 @@ public:
static void setInitialProperties(QV4::ExecutionEngine *engine, QV4::QmlContext *qmlContext, const QV4::Value &o, const QV4::Value &v);
QQmlTypeData *typeData;
- virtual void typeDataReady(QQmlTypeData *);
- virtual void typeDataProgress(QQmlTypeData *, qreal);
+ void typeDataReady(QQmlTypeData *) override;
+ void typeDataProgress(QQmlTypeData *, qreal) override;
void fromTypeData(QQmlTypeData *data);
diff --git a/src/qml/qml/qqmlcontext_p.h b/src/qml/qml/qqmlcontext_p.h
index 62cd3d4877..162fbcc8f6 100644
--- a/src/qml/qml/qqmlcontext_p.h
+++ b/src/qml/qml/qqmlcontext_p.h
@@ -235,7 +235,7 @@ public:
inline QQmlGuardedContextData(QQmlContextData *);
inline ~QQmlGuardedContextData();
- inline QQmlContextData *contextData();
+ inline QQmlContextData *contextData() const;
inline void setContextData(QQmlContextData *);
inline bool isNull() const { return !m_contextData; }
@@ -285,7 +285,7 @@ void QQmlGuardedContextData::setContextData(QQmlContextData *contextData)
}
}
-QQmlContextData *QQmlGuardedContextData::contextData()
+QQmlContextData *QQmlGuardedContextData::contextData() const
{
return m_contextData;
}
diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h
index dce75c51aa..e271598c2d 100644
--- a/src/qml/qml/qqmldata_p.h
+++ b/src/qml/qml/qqmldata_p.h
@@ -207,8 +207,7 @@ public:
} else if (priv->declarativeData) {
return static_cast<QQmlData *>(priv->declarativeData);
} else if (create) {
- priv->declarativeData = new QQmlData;
- return static_cast<QQmlData *>(priv->declarativeData);
+ return createQQmlData(priv);
} else {
return 0;
}
@@ -231,12 +230,22 @@ public:
static inline void flushPendingBinding(QObject *, QQmlPropertyIndex propertyIndex);
- static QQmlPropertyCache *ensurePropertyCache(QJSEngine *engine, QObject *object);
+ static QQmlPropertyCache *ensurePropertyCache(QJSEngine *engine, QObject *object)
+ {
+ Q_ASSERT(engine);
+ QQmlData *ddata = QQmlData::get(object, /*create*/true);
+ if (Q_LIKELY(ddata->propertyCache))
+ return ddata->propertyCache;
+ return createPropertyCache(engine, object);
+ }
private:
// For attachedProperties
mutable QQmlDataExtended *extendedData;
+ Q_NEVER_INLINE static QQmlData *createQQmlData(QObjectPrivate *priv);
+ Q_NEVER_INLINE static QQmlPropertyCache *createPropertyCache(QJSEngine *engine, QObject *object);
+
void flushPendingBindingImpl(QQmlPropertyIndex index);
Q_ALWAYS_INLINE bool hasBitSet(int bit) const
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index cb51c18925..3fa5838e10 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -70,7 +70,7 @@
#include <QtCore/qthread.h>
#include <private/qthread_p.h>
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
#include "qqmlnetworkaccessmanagerfactory.h"
#include <QNetworkAccessManager>
#include <QtNetwork/qnetworkconfigmanager.h>
@@ -537,6 +537,10 @@ The following functions are also on the Qt object.
\li This is the application name set on the QCoreApplication instance. This property can be written
to in order to set the application name.
\row
+ \li \c application.displayName (since Qt 5.9)
+ \li This is the application display name set on the QGuiApplication instance. This property can be written
+ to in order to set the application display name.
+ \row
\li \c application.version
\li This is the application version set on the QCoreApplication instance. This property can be written
to in order to set the application version.
@@ -554,6 +558,18 @@ The following functions are also on the Qt object.
\li This read-only property can be used to determine whether or not the
platform supports multiple windows. Some embedded platforms do not support
multiple windows, for example.
+
+ \row
+ \li \c application.screens
+ \li An array containing the descriptions of all connected screens. The
+ elements of the array are objects with the same properties as the
+ \l{Screen} attached object. In practice the array corresponds to the screen
+ list returned by QGuiApplication::screens(). In addition to examining
+ properties like name, width, height, etc., the array elements can also be
+ assigned to the targetScreen property of Window items, thus serving as an
+ alternative to the C++ side's QWindow::setScreen(). This property has been
+ added in Qt 5.9.
+
\endtable
The object also has one signal, aboutToQuit(), which is the same as \l QCoreApplication::aboutToQuit().
@@ -570,6 +586,8 @@ The following functions are also on the Qt object.
\li application.layoutDirection
\li application.font
\endlist
+
+ \sa Screen, Window, Window.targetScreen
*/
/*!
@@ -646,7 +664,7 @@ QQmlEnginePrivate::QQmlEnginePrivate(QQmlEngine *e)
cleanup(0), erroredBindings(0), inProgressCreations(0),
workerScriptEngine(0),
activeObjectCreator(0),
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
networkAccessManager(0), networkAccessManagerFactory(0),
#endif
urlInterceptor(0), scarceResourcesRefCount(0), importDatabase(e), typeLoader(e),
@@ -1006,8 +1024,8 @@ QQmlEngine::~QQmlEngine()
// we do this here and not in the private dtor since otherwise a crash can
// occur (if we are the QObject parent of the QObject singleton instance)
// XXX TODO: performance -- store list of singleton types separately?
- QList<QQmlType*> singletonTypes = QQmlMetaType::qmlSingletonTypes();
- foreach (QQmlType *currType, singletonTypes)
+ const QList<QQmlType*> singletonTypes = QQmlMetaType::qmlSingletonTypes();
+ for (QQmlType *currType : singletonTypes)
currType->singletonInstanceInfo()->destroy(this);
delete d->rootContext;
@@ -1129,7 +1147,7 @@ void QQmlEnginePrivate::registerFinalizeCallback(QObject *obj, int index)
}
}
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
/*!
Sets the \a factory to use for creating QNetworkAccessManager(s).
@@ -1196,7 +1214,7 @@ QNetworkAccessManager *QQmlEngine::networkAccessManager() const
Q_D(const QQmlEngine);
return d->getNetworkAccessManager();
}
-#endif // QT_NO_NETWORK
+#endif // qml_network
/*!
@@ -1861,15 +1879,19 @@ void QQmlData::setPendingBindingBit(QObject *obj, int coreIndex)
QQmlData_setBit(this, obj, coreIndex * 2 + 1);
}
-QQmlPropertyCache *QQmlData::ensurePropertyCache(QJSEngine *engine, QObject *object)
+QQmlData *QQmlData::createQQmlData(QObjectPrivate *priv)
+{
+ Q_ASSERT(priv);
+ priv->declarativeData = new QQmlData;
+ return static_cast<QQmlData *>(priv->declarativeData);
+}
+
+QQmlPropertyCache *QQmlData::createPropertyCache(QJSEngine *engine, QObject *object)
{
- Q_ASSERT(engine);
QQmlData *ddata = QQmlData::get(object, /*create*/true);
- if (!ddata->propertyCache) {
- ddata->propertyCache = QJSEnginePrivate::get(engine)->cache(object);
- if (ddata->propertyCache)
- ddata->propertyCache->addref();
- }
+ ddata->propertyCache = QJSEnginePrivate::get(engine)->cache(object);
+ if (ddata->propertyCache)
+ ddata->propertyCache->addref();
return ddata->propertyCache;
}
diff --git a/src/qml/qml/qqmlengine.h b/src/qml/qml/qqmlengine.h
index bbb9c36ce9..3102a20fac 100644
--- a/src/qml/qml/qqmlengine.h
+++ b/src/qml/qml/qqmlengine.h
@@ -87,7 +87,7 @@ class QQmlExpression;
class QQmlContext;
class QQmlType;
class QUrl;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
class QNetworkAccessManager;
class QQmlNetworkAccessManagerFactory;
#endif
@@ -117,7 +117,7 @@ public:
bool importPlugin(const QString &filePath, const QString &uri, QList<QQmlError> *errors);
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
void setNetworkAccessManagerFactory(QQmlNetworkAccessManagerFactory *);
QQmlNetworkAccessManagerFactory *networkAccessManagerFactory() const;
@@ -151,7 +151,7 @@ public:
static ObjectOwnership objectOwnership(QObject *);
protected:
QQmlEngine(QQmlEnginePrivate &dd, QObject *p);
- virtual bool event(QEvent *);
+ bool event(QEvent *) override;
Q_SIGNALS:
void quit();
diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h
index 713b03dbf3..916566b6c7 100644
--- a/src/qml/qml/qqmlengine_p.h
+++ b/src/qml/qml/qqmlengine_p.h
@@ -162,7 +162,7 @@ public:
void registerFinalizeCallback(QObject *obj, int index);
QQmlObjectCreator *activeObjectCreator;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QNetworkAccessManager *createNetworkAccessManager(QObject *parent) const;
QNetworkAccessManager *getNetworkAccessManager() const;
mutable QNetworkAccessManager *networkAccessManager;
diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp
index 6afbd05e3e..01d4722ca6 100644
--- a/src/qml/qml/qqmlexpression.cpp
+++ b/src/qml/qml/qqmlexpression.cpp
@@ -434,7 +434,7 @@ void QQmlExpressionPrivate::expressionChanged()
emit q->valueChanged();
}
-QString QQmlExpressionPrivate::expressionIdentifier()
+QString QQmlExpressionPrivate::expressionIdentifier() const
{
return QLatin1Char('"') + expression + QLatin1Char('"');
}
diff --git a/src/qml/qml/qqmlexpression_p.h b/src/qml/qml/qqmlexpression_p.h
index 809a57b169..44342a957b 100644
--- a/src/qml/qml/qqmlexpression_p.h
+++ b/src/qml/qml/qqmlexpression_p.h
@@ -85,8 +85,8 @@ public:
bool expressionFunctionValid:1;
// Inherited from QQmlJavaScriptExpression
- virtual QString expressionIdentifier();
- virtual void expressionChanged();
+ QString expressionIdentifier() const override;
+ void expressionChanged() override;
QString expression;
diff --git a/src/qml/qml/qqmlextensionplugin.h b/src/qml/qml/qqmlextensionplugin.h
index de482d0352..c0915c0abe 100644
--- a/src/qml/qml/qqmlextensionplugin.h
+++ b/src/qml/qml/qqmlextensionplugin.h
@@ -63,8 +63,8 @@ public:
QUrl baseUrl() const;
- virtual void registerTypes(const char *uri) = 0;
- virtual void initializeEngine(QQmlEngine *engine, const char *uri);
+ void registerTypes(const char *uri) override = 0;
+ void initializeEngine(QQmlEngine *engine, const char *uri) override;
private:
Q_DISABLE_COPY(QQmlExtensionPlugin)
diff --git a/src/qml/qml/qqmlfile.cpp b/src/qml/qml/qqmlfile.cpp
index 4769402855..4e4db086b0 100644
--- a/src/qml/qml/qqmlfile.cpp
+++ b/src/qml/qml/qqmlfile.cpp
@@ -68,7 +68,7 @@ static char assets_string[] = "assets";
class QQmlFilePrivate;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
class QQmlFileNetworkReply : public QObject
{
Q_OBJECT
@@ -117,12 +117,12 @@ public:
Error error;
QString errorString;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QQmlFileNetworkReply *reply;
#endif
};
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
int QQmlFileNetworkReply::finishedIndex = -1;
int QQmlFileNetworkReply::downloadProgressIndex = -1;
int QQmlFileNetworkReply::networkFinishedIndex = -1;
@@ -205,11 +205,11 @@ void QQmlFileNetworkReply::networkDownloadProgress(qint64 a, qint64 b)
{
emit downloadProgress(a, b);
}
-#endif // QT_NO_NETWORK
+#endif // qml_network
QQmlFilePrivate::QQmlFilePrivate()
: error(None)
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
, reply(0)
#endif
{
@@ -233,7 +233,7 @@ QQmlFile::QQmlFile(QQmlEngine *e, const QString &url)
QQmlFile::~QQmlFile()
{
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
delete d->reply;
#endif
delete d;
@@ -273,7 +273,7 @@ QQmlFile::Status QQmlFile::status() const
{
if (d->url.isEmpty() && d->urlString.isEmpty())
return Null;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
else if (d->reply)
return Loading;
#endif
@@ -333,7 +333,7 @@ void QQmlFile::load(QQmlEngine *engine, const QUrl &url)
d->error = QQmlFilePrivate::NotFound;
}
} else {
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
d->reply = new QQmlFileNetworkReply(engine, d, url);
#else
d->error = QQmlFilePrivate::NotFound;
@@ -364,7 +364,7 @@ void QQmlFile::load(QQmlEngine *engine, const QString &url)
d->error = QQmlFilePrivate::NotFound;
}
} else {
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QUrl qurl(url);
d->url = qurl;
d->urlString = QString();
@@ -388,7 +388,7 @@ void QQmlFile::clear(QObject *)
clear();
}
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
bool QQmlFile::connectFinished(QObject *object, const char *method)
{
if (!d || !d->reply) {
diff --git a/src/qml/qml/qqmlfile.h b/src/qml/qml/qqmlfile.h
index 3dd683a2cd..aec0981a95 100644
--- a/src/qml/qml/qqmlfile.h
+++ b/src/qml/qml/qqmlfile.h
@@ -80,7 +80,7 @@ public:
void clear();
void clear(QObject *);
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
bool connectFinished(QObject *, const char *);
bool connectFinished(QObject *, int);
bool connectDownloadProgress(QObject *, const char *);
diff --git a/src/qml/qml/qqmlfileselector_p.h b/src/qml/qml/qqmlfileselector_p.h
index 57ef194c10..a7360f83d9 100644
--- a/src/qml/qml/qqmlfileselector_p.h
+++ b/src/qml/qml/qqmlfileselector_p.h
@@ -80,7 +80,7 @@ public:
QQmlFileSelectorInterceptor(QQmlFileSelectorPrivate* pd);
QQmlFileSelectorPrivate* d;
protected:
- virtual QUrl intercept(const QUrl &path, DataType type);
+ QUrl intercept(const QUrl &path, DataType type) override;
};
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index 98e2f9eefd..4ded0f93bb 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -57,6 +57,7 @@
#include <QtCore/qjsonarray.h>
#include <algorithm>
+#include <functional>
QT_BEGIN_NAMESPACE
@@ -229,7 +230,7 @@ public:
};
QList<Import *> imports;
- Import *findImport(const QString &uri);
+ Import *findImport(const QString &uri) const;
bool resolveType(QQmlTypeLoader *typeLoader, const QHashedStringRef& type,
int *vmajor, int *vminor, QQmlType** type_return,
@@ -453,7 +454,7 @@ QList<QQmlImports::ScriptReference> QQmlImports::resolvedScripts() const
for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
const QQmlImportNamespace::Import *import = set.imports.at(ii);
- foreach (const QQmlDirParser::Script &script, import->qmlDirScripts) {
+ for (const QQmlDirParser::Script &script : import->qmlDirScripts) {
ScriptReference ref;
ref.nameSpace = script.nameSpace;
ref.location = QUrl(import->url).resolved(QUrl(script.fileName));
@@ -467,7 +468,7 @@ QList<QQmlImports::ScriptReference> QQmlImports::resolvedScripts() const
for (int ii = set.imports.count() - 1; ii >= 0; --ii) {
const QQmlImportNamespace::Import *import = set.imports.at(ii);
- foreach (const QQmlDirParser::Script &script, import->qmlDirScripts) {
+ for (const QQmlDirParser::Script &script : import->qmlDirScripts) {
ScriptReference ref;
ref.nameSpace = script.nameSpace;
ref.qualifier = set.prefix;
@@ -784,14 +785,13 @@ bool QQmlImportsPrivate::resolveType(const QHashedStringRef& type, int *vmajor,
return false;
}
-QQmlImportNamespace::Import *QQmlImportNamespace::findImport(const QString &uri)
+QQmlImportNamespace::Import *QQmlImportNamespace::findImport(const QString &uri) const
{
- for (QList<Import *>::iterator it = imports.begin(), end = imports.end(); it != end; ++it) {
- if ((*it)->uri == uri)
- return *it;
+ for (Import *import : imports) {
+ if (import->uri == uri)
+ return import;
}
-
- return 0;
+ return nullptr;
}
bool QQmlImportNamespace::resolveType(QQmlTypeLoader *typeLoader, const QHashedStringRef &type,
@@ -898,6 +898,21 @@ static QStringList versionUriList(const QString &uri, int vmaj, int vmin)
}
#ifndef QT_NO_LIBRARY
+static QVector<QStaticPlugin> makePlugins()
+{
+ QVector<QStaticPlugin> plugins;
+ // To avoid traversing all static plugins for all imports, we cut down
+ // the list the first time called to only contain QML plugins:
+ const auto staticPlugins = QPluginLoader::staticPlugins();
+ for (const QStaticPlugin &plugin : staticPlugins) {
+ if (plugin.metaData().value(QLatin1String("IID")).toString()
+ == QLatin1String(QQmlExtensionInterface_iid)) {
+ plugins.append(plugin);
+ }
+ }
+ return plugins;
+}
+
/*!
Get all static plugins that are QML plugins and has a meta data URI that matches with one of
\a versionUris, which is a list of all possible versioned URI combinations - see versionUriList()
@@ -906,17 +921,8 @@ static QStringList versionUriList(const QString &uri, int vmaj, int vmin)
bool QQmlImportsPrivate::populatePluginPairVector(QVector<StaticPluginPair> &result, const QString &uri, const QStringList &versionUris,
const QString &qmldirPath, QList<QQmlError> *errors)
{
- static QVector<QStaticPlugin> plugins;
- if (plugins.isEmpty()) {
- // To avoid traversing all static plugins for all imports, we cut down
- // the list the first time called to only contain QML plugins:
- foreach (const QStaticPlugin &plugin, QPluginLoader::staticPlugins()) {
- if (plugin.metaData().value(QLatin1String("IID")).toString() == QLatin1String(QQmlExtensionInterface_iid))
- plugins.append(plugin);
- }
- }
-
- foreach (const QStaticPlugin &plugin, plugins) {
+ static const QVector<QStaticPlugin> plugins = makePlugins();
+ for (const QStaticPlugin &plugin : plugins) {
// Since a module can list more than one plugin, we keep iterating even after we found a match.
if (QQmlExtensionPlugin *instance = qobject_cast<QQmlExtensionPlugin *>(plugin.instance())) {
const QJsonArray metaTagsUriList = plugin.metaData().value(QLatin1String("uri")).toArray();
@@ -931,7 +937,7 @@ bool QQmlImportsPrivate::populatePluginPairVector(QVector<StaticPluginPair> &res
return false;
}
// A plugin can be set up to handle multiple URIs, so go through the list:
- foreach (const QJsonValue &metaTagUri, metaTagsUriList) {
+ for (const QJsonValue &metaTagUri : metaTagsUriList) {
if (versionUris.contains(metaTagUri.toString())) {
result.append(qMakePair(plugin, metaTagsUriList));
break;
@@ -998,7 +1004,8 @@ bool QQmlImportsPrivate::importExtension(const QString &qmldirFilePath,
int staticPluginsFound = 0;
#if defined(QT_SHARED)
- foreach (const QQmlDirParser::Plugin &plugin, qmldir->plugins()) {
+ const auto qmldirPlugins = qmldir->plugins();
+ for (const QQmlDirParser::Plugin &plugin : qmldirPlugins) {
QString resolvedFilePath = database->resolvePlugin(typeLoader, qmldirPath, plugin.path, plugin.name);
if (!resolvedFilePath.isEmpty()) {
dynamicPluginsFound++;
@@ -1032,8 +1039,8 @@ bool QQmlImportsPrivate::importExtension(const QString &qmldirFilePath,
const QString basePath = QFileInfo(qmldirPath).absoluteFilePath();
for (const QString &versionUri : versionUris) {
- foreach (const StaticPluginPair &pair, pluginPairs) {
- foreach (const QJsonValue &metaTagUri, pair.second) {
+ for (const StaticPluginPair &pair : qAsConst(pluginPairs)) {
+ for (const QJsonValue &metaTagUri : pair.second) {
if (versionUri == metaTagUri.toString()) {
staticPluginsFound++;
QObject *instance = pair.first.instance();
@@ -1117,20 +1124,16 @@ bool QQmlImportsPrivate::getQmldirContent(const QString &qmldirIdentifier, const
QString QQmlImportsPrivate::resolvedUri(const QString &dir_arg, QQmlImportDatabase *database)
{
- struct I { static bool greaterThan(const QString &s1, const QString &s2) {
- return s1 > s2;
- } };
-
QString dir = dir_arg;
if (dir.endsWith(Slash) || dir.endsWith(Backslash))
dir.chop(1);
QStringList paths = database->fileImportPath;
if (!paths.isEmpty())
- std::sort(paths.begin(), paths.end(), I::greaterThan); // Ensure subdirs preceed their parents.
+ std::sort(paths.begin(), paths.end(), std::greater<QString>()); // Ensure subdirs preceed their parents.
QString stableRelativePath = dir;
- foreach(const QString &path, paths) {
+ for (const QString &path : qAsConst(paths)) {
if (dir.startsWith(path)) {
stableRelativePath = dir.mid(path.length()+1);
break;
@@ -1671,8 +1674,7 @@ QString QQmlImportDatabase::resolvePlugin(QQmlTypeLoader *typeLoader,
if (!qmldirPluginPathIsRelative)
searchPaths.prepend(qmldirPluginPath);
- foreach (const QString &pluginPath, searchPaths) {
-
+ for (const QString &pluginPath : qAsConst(searchPaths)) {
QString resolvedPath;
if (pluginPath == QLatin1String(".")) {
if (qmldirPluginPathIsRelative && !qmldirPluginPath.isEmpty() && qmldirPluginPath != QLatin1String("."))
@@ -1694,7 +1696,7 @@ QString QQmlImportDatabase::resolvePlugin(QQmlTypeLoader *typeLoader,
resolvedPath += Slash;
resolvedPath += prefix + baseName;
- foreach (const QString &suffix, suffixes) {
+ for (const QString &suffix : suffixes) {
const QString absolutePath = typeLoader->absoluteFilePath(resolvedPath + suffix);
if (!absolutePath.isEmpty())
return absolutePath;
@@ -1836,7 +1838,7 @@ QStringList QQmlImportDatabase::importPathList(PathType type) const
return fileImportPath;
QStringList list;
- foreach (const QString &path, fileImportPath) {
+ for (const QString &path : fileImportPath) {
bool localPath = isPathAbsolute(path) || QQmlFile::isLocalFile(path);
if (localPath == (type == Local))
list.append(path);
@@ -1930,7 +1932,7 @@ bool QQmlImportDatabase::registerPluginTypes(QObject *instance, const QString &b
if (!registrationFailures.isEmpty()) {
if (errors) {
- foreach (const QString &failure, registrationFailures) {
+ for (const QString &failure : qAsConst(registrationFailures)) {
QQmlError error;
error.setDescription(failure);
errors->prepend(error);
diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp
index 0ce769aaea..963638ca34 100644
--- a/src/qml/qml/qqmlincubator.cpp
+++ b/src/qml/qml/qqmlincubator.cpp
@@ -206,7 +206,7 @@ public:
}
protected:
- virtual void timerEvent(QTimerEvent *) {
+ void timerEvent(QTimerEvent *) override {
incubateFor(5);
}
};
diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h
index 5f9cffb56d..a0735d91de 100644
--- a/src/qml/qml/qqmljavascriptexpression_p.h
+++ b/src/qml/qml/qqmljavascriptexpression_p.h
@@ -100,7 +100,7 @@ public:
QQmlJavaScriptExpression();
virtual ~QQmlJavaScriptExpression();
- virtual QString expressionIdentifier() = 0;
+ virtual QString expressionIdentifier() const = 0;
virtual void expressionChanged() = 0;
void evaluate(QV4::CallData *callData, bool *isUndefined, QV4::Scope &scope);
diff --git a/src/qml/qml/qqmlloggingcategory.cpp b/src/qml/qml/qqmlloggingcategory.cpp
index 88cf14cba0..fd8fb477c7 100644
--- a/src/qml/qml/qqmlloggingcategory.cpp
+++ b/src/qml/qml/qqmlloggingcategory.cpp
@@ -81,7 +81,7 @@
\note This property needs to be set when declaring the LoggingCategory
and cannot be changed later.
- \sa QLoggingCategory::name()
+ \sa QLoggingCategory::categoryName()
*/
QQmlLoggingCategory::QQmlLoggingCategory(QObject *parent)
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index ce0f4b798a..7b758566b7 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -1049,7 +1049,7 @@ void QQmlTypeModulePrivate::add(QQmlType *type)
list.append(type);
}
-QQmlType *QQmlTypeModule::type(const QHashedStringRef &name, int minor)
+QQmlType *QQmlTypeModule::type(const QHashedStringRef &name, int minor) const
{
QMutexLocker lock(metaTypeDataLock());
@@ -1063,7 +1063,7 @@ QQmlType *QQmlTypeModule::type(const QHashedStringRef &name, int minor)
return 0;
}
-QQmlType *QQmlTypeModule::type(const QV4::String *name, int minor)
+QQmlType *QQmlTypeModule::type(const QV4::String *name, int minor) const
{
QMutexLocker lock(metaTypeDataLock());
@@ -1444,11 +1444,11 @@ bool qmlProtectModule(const char *uri, int majVersion)
bool QQmlMetaType::namespaceContainsRegistrations(const QString &uri, int majorVersion)
{
- QQmlMetaTypeData *data = metaTypeData();
+ const QQmlMetaTypeData *data = metaTypeData();
// Has any type previously been installed to this namespace?
QHashedString nameSpace(uri);
- foreach (const QQmlType *type, data->types)
+ for (const QQmlType *type : data->types)
if (type->module() == nameSpace && type->majorVersion() == majorVersion)
return true;
@@ -1957,7 +1957,7 @@ QString QQmlMetaType::prettyTypeName(const QObject *object)
marker = typeName.indexOf(QLatin1String("_QML_"));
if (marker != -1) {
- typeName = typeName.left(marker) + QLatin1Char('*');
+ typeName = typeName.leftRef(marker) + QLatin1Char('*');
type = QQmlMetaType::qmlType(QMetaType::type(typeName.toLatin1()));
if (type) {
typeName = type->qmlTypeName();
diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h
index 9afe4825dc..cc0e0ad71e 100644
--- a/src/qml/qml/qqmlmetatype_p.h
+++ b/src/qml/qml/qqmlmetatype_p.h
@@ -259,8 +259,8 @@ public:
int minimumMinorVersion() const;
int maximumMinorVersion() const;
- QQmlType *type(const QHashedStringRef &, int);
- QQmlType *type(const QV4::String *, int);
+ QQmlType *type(const QHashedStringRef &, int) const;
+ QQmlType *type(const QV4::String *, int) const;
QList<QQmlType*> singletonTypes(int) const;
diff --git a/src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp b/src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp
index c94db8e168..1680253d73 100644
--- a/src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp
+++ b/src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp
@@ -41,7 +41,7 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
/*!
\class QQmlNetworkAccessManagerFactory
@@ -103,6 +103,6 @@ QQmlNetworkAccessManagerFactory::~QQmlNetworkAccessManagerFactory()
implementation of this method is reentrant.
*/
-#endif //QT_NO_NETWORK
+#endif // qml_network
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlnetworkaccessmanagerfactory.h b/src/qml/qml/qqmlnetworkaccessmanagerfactory.h
index ba3561b9f4..57dec1da29 100644
--- a/src/qml/qml/qqmlnetworkaccessmanagerfactory.h
+++ b/src/qml/qml/qqmlnetworkaccessmanagerfactory.h
@@ -45,7 +45,7 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
class QNetworkAccessManager;
class Q_QML_EXPORT QQmlNetworkAccessManagerFactory
@@ -56,7 +56,7 @@ public:
};
-#endif //QT_NO_NETWORK
+#endif // qml_network
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlnotifier_p.h b/src/qml/qml/qqmlnotifier_p.h
index eff9684558..4db0dd038a 100644
--- a/src/qml/qml/qqmlnotifier_p.h
+++ b/src/qml/qml/qqmlnotifier_p.h
@@ -94,9 +94,9 @@ public:
inline QQmlNotifierEndpoint(Callback callback);
inline ~QQmlNotifierEndpoint();
- inline bool isConnected();
- inline bool isConnected(QObject *source, int sourceSignal);
- inline bool isConnected(QQmlNotifier *);
+ inline bool isConnected() const;
+ inline bool isConnected(QObject *source, int sourceSignal) const;
+ inline bool isConnected(QQmlNotifier *) const;
void connect(QObject *source, int sourceSignal, QQmlEngine *engine);
inline void connect(QQmlNotifier *);
@@ -162,7 +162,7 @@ QQmlNotifierEndpoint::~QQmlNotifierEndpoint()
disconnect();
}
-bool QQmlNotifierEndpoint::isConnected()
+bool QQmlNotifierEndpoint::isConnected() const
{
return prev != 0;
}
@@ -171,13 +171,13 @@ bool QQmlNotifierEndpoint::isConnected()
\a sourceSignal MUST be in the signal index range (see QObjectPrivate::signalIndex()).
This is different from QMetaMethod::methodIndex().
*/
-bool QQmlNotifierEndpoint::isConnected(QObject *source, int sourceSignal)
+bool QQmlNotifierEndpoint::isConnected(QObject *source, int sourceSignal) const
{
return this->sourceSignal != -1 && senderAsObject() == source &&
this->sourceSignal == sourceSignal;
}
-bool QQmlNotifierEndpoint::isConnected(QQmlNotifier *notifier)
+bool QQmlNotifierEndpoint::isConnected(QQmlNotifier *notifier) const
{
return sourceSignal == -1 && senderAsNotifier() == notifier;
}
diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h
index e3312f9df5..caee7b9d1d 100644
--- a/src/qml/qml/qqmlobjectcreator_p.h
+++ b/src/qml/qml/qqmlobjectcreator_p.h
@@ -92,13 +92,13 @@ public:
QQmlContextData *finalize(QQmlInstantiationInterrupt &interrupt);
void clear();
- QQmlComponentAttached **componentAttachment() { return &sharedState->componentAttached; }
+ QQmlComponentAttached **componentAttachment() const { return &sharedState->componentAttached; }
- QList<QQmlEnginePrivate::FinalizeCallback> *finalizeCallbacks() { return &sharedState->finalizeCallbacks; }
+ QList<QQmlEnginePrivate::FinalizeCallback> *finalizeCallbacks() const { return &sharedState->finalizeCallbacks; }
QList<QQmlError> errors;
- QQmlContextData *parentContextData() { return parentContext.contextData(); }
+ QQmlContextData *parentContextData() const { return parentContext.contextData(); }
QFiniteStack<QPointer<QObject> > &allCreatedObjects() const { return sharedState->allCreatedObjects; }
private:
diff --git a/src/qml/qml/qqmlopenmetaobject_p.h b/src/qml/qml/qqmlopenmetaobject_p.h
index f1562131fc..183baec941 100644
--- a/src/qml/qml/qqmlopenmetaobject_p.h
+++ b/src/qml/qml/qqmlopenmetaobject_p.h
@@ -122,8 +122,8 @@ public:
void emitPropertyNotification(const QByteArray &propertyName);
protected:
- virtual int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a);
- virtual int createProperty(const char *, const char *);
+ int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a) override;
+ int createProperty(const char *, const char *) override;
virtual void propertyRead(int);
virtual void propertyWrite(int);
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp
index c62fef7c3d..df336f0803 100644
--- a/src/qml/qml/qqmlproperty.cpp
+++ b/src/qml/qml/qqmlproperty.cpp
@@ -285,7 +285,7 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name)
QQmlPropertyData local;
QQmlPropertyData *property =
- QQmlPropertyCache::property(engine, currentObject, pathName.toString(), context, local);
+ QQmlPropertyCache::property(engine, currentObject, pathName, context, local);
if (!property) return; // Not a property
if (property->isFunction())
@@ -350,7 +350,7 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name)
// Try property
if (signalName.endsWith(QLatin1String("Changed"))) {
- QString propName = signalName.mid(0, signalName.length() - 7);
+ const QStringRef propName = signalName.midRef(0, signalName.length() - 7);
QQmlPropertyData *d = ddata->propertyCache->property(propName, currentObject, context);
while (d && d->isFunction())
d = ddata->propertyCache->overrideData(d);
@@ -374,14 +374,13 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name)
}
// Property
- const QString terminalString = terminal.toString();
QQmlPropertyData local;
QQmlPropertyData *property =
- QQmlPropertyCache::property(engine, currentObject, terminalString, context, local);
+ QQmlPropertyCache::property(engine, currentObject, terminal, context, local);
if (property && !property->isFunction()) {
object = currentObject;
core = *property;
- nameCache = terminalString;
+ nameCache = terminal.toString();
isNameCached = true;
}
}
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index 337c37b5be..b645d47c39 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -193,7 +193,7 @@ void QQmlPropertyData::load(const QMetaMethod &m)
if (m.parameterCount()) {
_flags.hasArguments = true;
- if ((m.parameterCount() == 1) && (m.parameterTypes().first() == "QQmlV4Function*")) {
+ if ((m.parameterCount() == 1) && (m.parameterTypes().constFirst() == "QQmlV4Function*")) {
_flags.isV4Function = true;
}
}
@@ -228,7 +228,7 @@ void QQmlPropertyData::lazyLoad(const QMetaMethod &m)
const int paramCount = m.parameterCount();
if (paramCount) {
_flags.hasArguments = true;
- if ((paramCount == 1) && (m.parameterTypes().first() == "QQmlV4Function*")) {
+ if ((paramCount == 1) && (m.parameterTypes().constFirst() == "QQmlV4Function*")) {
_flags.isV4Function = true;
}
}
@@ -246,7 +246,7 @@ Creates a new empty QQmlPropertyCache.
QQmlPropertyCache::QQmlPropertyCache(QV4::ExecutionEngine *e)
: engine(e), _parent(0), propertyIndexCacheStart(0), methodIndexCacheStart(0),
signalHandlerIndexCacheStart(0), _hasPropertyOverrides(false), _ownMetaObject(false),
- _metaObject(0), argumentsCache(0)
+ _metaObject(0), argumentsCache(0), _jsFactoryMethodIndex(-1)
{
Q_ASSERT(engine);
}
@@ -269,8 +269,8 @@ QQmlPropertyCache::~QQmlPropertyCache()
QQmlPropertyCacheMethodArguments *args = argumentsCache;
while (args) {
QQmlPropertyCacheMethodArguments *next = args->next;
- if (args->signalParameterStringForJS) delete args->signalParameterStringForJS;
- if (args->names) delete args->names;
+ delete args->signalParameterStringForJS;
+ delete args->names;
free(args);
args = next;
}
@@ -507,6 +507,11 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject,
const char *name = mci.name();
if (0 == qstrcmp(name, "DefaultProperty")) {
_defaultPropertyName = QString::fromUtf8(mci.value());
+ } else if (0 == qstrcmp(name, "qt_QmlJSWrapperFactoryMethod")) {
+ const char * const factoryMethod = mci.value();
+ _jsFactoryMethodIndex = metaObject->indexOfSlot(factoryMethod);
+ if (_jsFactoryMethodIndex != -1)
+ _jsFactoryMethodIndex -= metaObject->methodOffset();
}
}
}
@@ -973,7 +978,7 @@ int QQmlPropertyCache::originalClone(QObject *object, int index)
return index;
}
-QQmlPropertyData qQmlPropertyCacheCreate(const QMetaObject *metaObject, const QString &property)
+static QQmlPropertyData qQmlPropertyCacheCreate(const QMetaObject *metaObject, const QStringRef &property)
{
Q_ASSERT(metaObject);
@@ -1033,12 +1038,17 @@ QQmlPropertyData qQmlPropertyCacheCreate(const QMetaObject *metaObject, const QS
return rv;
}
-inline const QString &qQmlPropertyCacheToString(const QString &string)
+static inline QQmlPropertyData qQmlPropertyCacheCreate(const QMetaObject *metaObject, const QString &property)
+{
+ return qQmlPropertyCacheCreate(metaObject, QStringRef(&property));
+}
+
+static inline const QStringRef &qQmlPropertyCacheToString(const QStringRef &string)
{
return string;
}
-inline QString qQmlPropertyCacheToString(const QV4::String *string)
+static inline QString qQmlPropertyCacheToString(const QV4::String *string)
{
return string->toQString();
}
@@ -1085,10 +1095,10 @@ QQmlPropertyCache::property(QJSEngine *engine, QObject *obj, const QV4::String *
}
QQmlPropertyData *
-QQmlPropertyCache::property(QJSEngine *engine, QObject *obj,
- const QString &name, QQmlContextData *context, QQmlPropertyData &local)
+QQmlPropertyCache::property(QJSEngine *engine, QObject *obj, const QStringRef &name,
+ QQmlContextData *context, QQmlPropertyData &local)
{
- return qQmlPropertyCacheProperty<const QString &>(engine, obj, name, context, local);
+ return qQmlPropertyCacheProperty<const QStringRef &>(engine, obj, name, context, local);
}
// these two functions are copied from qmetaobject.cpp
@@ -1424,6 +1434,12 @@ QByteArray QQmlPropertyCache::checksum(bool *ok)
return _checksum;
}
+ // Generate a checksum on the meta-object data only on C++ types.
+ if (!_metaObject || _ownMetaObject) {
+ *ok = false;
+ return _checksum;
+ }
+
QCryptographicHash hash(QCryptographicHash::Md5);
if (_parent) {
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h
index 4da02037fa..d34d1bf387 100644
--- a/src/qml/qml/qqmlpropertycache_p.h
+++ b/src/qml/qml/qqmlpropertycache_p.h
@@ -406,11 +406,17 @@ public:
inline QQmlPropertyData *overrideData(QQmlPropertyData *) const;
inline bool isAllowedInRevision(QQmlPropertyData *) const;
- static QQmlPropertyData *property(QJSEngine *, QObject *, const QString &,
+ static QQmlPropertyData *property(QJSEngine *, QObject *, const QStringRef &,
QQmlContextData *, QQmlPropertyData &);
static QQmlPropertyData *property(QJSEngine *, QObject *, const QV4::String *,
QQmlContextData *, QQmlPropertyData &);
+ static QQmlPropertyData *property(QJSEngine *engine, QObject *obj, const QString &name,
+ QQmlContextData *context, QQmlPropertyData &local)
+ {
+ return property(engine, obj, QStringRef(&name), context, local);
+ }
+
//see QMetaObjectPrivate::originalClone
int originalClone(int index);
static int originalClone(QObject *, int index);
@@ -431,14 +437,16 @@ public:
void toMetaObjectBuilder(QMetaObjectBuilder &);
+ inline bool callJSFactoryMethod(QObject *object, void **args) const;
+
static bool determineMetaObjectSizes(const QMetaObject &mo, int *fieldCount, int *stringCount);
static bool addToHash(QCryptographicHash &hash, const QMetaObject &mo);
QByteArray checksum(bool *ok);
protected:
- virtual void destroy();
- virtual void clear();
+ void destroy() override;
+ void clear() override;
private:
friend class QQmlEnginePrivate;
@@ -466,11 +474,11 @@ private:
QQmlPropertyData *ensureResolved(QQmlPropertyData*) const;
- void resolve(QQmlPropertyData *) const;
+ Q_NEVER_INLINE void resolve(QQmlPropertyData *) const;
void updateRecur(const QMetaObject *);
template<typename K>
- QQmlPropertyData *findNamedProperty(const K &key)
+ QQmlPropertyData *findNamedProperty(const K &key) const
{
StringCache::mapped_type *it = stringCache.value(key);
return it ? it->second : 0;
@@ -505,6 +513,7 @@ private:
QByteArray _dynamicStringData;
QString _defaultPropertyName;
QQmlPropertyCacheMethodArguments *argumentsCache;
+ int _jsFactoryMethodIndex;
QByteArray _checksum;
};
@@ -674,7 +683,7 @@ bool QQmlPropertyData::operator==(const QQmlPropertyRawData &other)
inline QQmlPropertyData *QQmlPropertyCache::ensureResolved(QQmlPropertyData *p) const
{
- if (p && p->notFullyResolved())
+ if (p && Q_UNLIKELY(p->notFullyResolved()))
resolve(p);
return p;
@@ -806,6 +815,17 @@ int QQmlPropertyCache::signalOffset() const
return signalHandlerIndexCacheStart;
}
+bool QQmlPropertyCache::callJSFactoryMethod(QObject *object, void **args) const
+{
+ if (_jsFactoryMethodIndex != -1) {
+ _metaObject->d.static_metacall(object, QMetaObject::InvokeMetaMethod, _jsFactoryMethodIndex, args);
+ return true;
+ }
+ if (_parent)
+ return _parent->callJSFactoryMethod(object, args);
+ return false;
+}
+
QQmlMetaObject::QQmlMetaObject()
{
}
diff --git a/src/qml/qml/qqmlproxymetaobject_p.h b/src/qml/qml/qqmlproxymetaobject_p.h
index 7083f88fa7..2b7a980361 100644
--- a/src/qml/qml/qqmlproxymetaobject_p.h
+++ b/src/qml/qml/qqmlproxymetaobject_p.h
@@ -74,10 +74,10 @@ public:
};
QQmlProxyMetaObject(QObject *, QList<ProxyData> *);
- virtual ~QQmlProxyMetaObject();
+ ~QQmlProxyMetaObject();
protected:
- virtual int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a);
+ int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a) override;
private:
QList<ProxyData> *metaObjects;
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 87100d785e..3885e6ea0b 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -123,7 +123,7 @@ namespace {
};
}
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
// This is a lame object that we need to ensure that slots connected to
// QNetworkReply get called in the correct thread (the loader thread).
// As QQmlTypeLoader lives in the main thread, and we can't use
@@ -143,7 +143,7 @@ public slots:
private:
QQmlTypeLoader *l;
};
-#endif // QT_NO_NETWORK
+#endif // qml_network
class QQmlTypeLoaderThread : public QQmlThread
{
@@ -151,10 +151,10 @@ class QQmlTypeLoaderThread : public QQmlThread
public:
QQmlTypeLoaderThread(QQmlTypeLoader *loader);
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QNetworkAccessManager *networkAccessManager() const;
QQmlTypeLoaderNetworkReplyProxy *networkReplyProxy() const;
-#endif // QT_NO_NETWORK
+#endif // qml_network
void load(QQmlDataBlob *b);
void loadAsync(QQmlDataBlob *b);
void loadWithStaticData(QQmlDataBlob *b, const QByteArray &);
@@ -166,7 +166,7 @@ public:
void initializeEngine(QQmlExtensionInterface *, const char *);
protected:
- virtual void shutdownThread();
+ void shutdownThread() override;
private:
void loadThread(QQmlDataBlob *b);
@@ -177,13 +177,13 @@ private:
void initializeEngineMain(QQmlExtensionInterface *iface, const char *uri);
QQmlTypeLoader *m_loader;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
mutable QNetworkAccessManager *m_networkAccessManager;
mutable QQmlTypeLoaderNetworkReplyProxy *m_networkReplyProxy;
-#endif // QT_NO_NETWORK
+#endif // qml_network
};
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QQmlTypeLoaderNetworkReplyProxy::QQmlTypeLoaderNetworkReplyProxy(QQmlTypeLoader *l)
: l(l)
{
@@ -212,7 +212,7 @@ void QQmlTypeLoaderNetworkReplyProxy::manualFinished(QNetworkReply *reply)
l->networkReplyProgress(reply, replySize, replySize);
l->networkReplyFinished(reply);
}
-#endif // QT_NO_NETWORK
+#endif // qml_network
/*!
\class QQmlDataBlob
@@ -529,7 +529,7 @@ void QQmlDataBlob::done()
{
}
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
/*!
Invoked if there is a network error while fetching this blob.
@@ -582,7 +582,7 @@ void QQmlDataBlob::networkError(QNetworkReply::NetworkError networkError)
setError(error);
}
-#endif // QT_NO_NETWORK
+#endif // qml_network
/*!
Called if \a blob, which was previously waited for, has an error.
@@ -782,15 +782,15 @@ void QQmlDataBlob::ThreadData::setProgress(quint8 v)
QQmlTypeLoaderThread::QQmlTypeLoaderThread(QQmlTypeLoader *loader)
: m_loader(loader)
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
, m_networkAccessManager(0), m_networkReplyProxy(0)
-#endif // QT_NO_NETWORK
+#endif // qml_network
{
// Do that after initializing all the members.
startup();
}
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QNetworkAccessManager *QQmlTypeLoaderThread::networkAccessManager() const
{
Q_ASSERT(isThisThread());
@@ -808,7 +808,7 @@ QQmlTypeLoaderNetworkReplyProxy *QQmlTypeLoaderThread::networkReplyProxy() const
Q_ASSERT(m_networkReplyProxy); // Must call networkAccessManager() first
return m_networkReplyProxy;
}
-#endif // QT_NO_NETWORK
+#endif // qml_network
void QQmlTypeLoaderThread::load(QQmlDataBlob *b)
{
@@ -866,12 +866,12 @@ void QQmlTypeLoaderThread::initializeEngine(QQmlExtensionInterface *iface,
void QQmlTypeLoaderThread::shutdownThread()
{
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
delete m_networkAccessManager;
m_networkAccessManager = 0;
delete m_networkReplyProxy;
m_networkReplyProxy = 0;
-#endif // QT_NO_NETWORK
+#endif // qml_network
}
void QQmlTypeLoaderThread::loadThread(QQmlDataBlob *b)
@@ -957,14 +957,14 @@ void QQmlTypeLoader::invalidate()
m_thread = 0;
}
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
// Need to delete the network replies after
// the loader thread is shutdown as it could be
// getting new replies while we clear them
for (NetworkReplies::Iterator iter = m_networkReplies.begin(); iter != m_networkReplies.end(); ++iter)
(*iter)->release();
m_networkReplies.clear();
-#endif // QT_NO_NETWORK
+#endif // qml_network
}
void QQmlTypeLoader::lock()
@@ -1138,7 +1138,7 @@ void QQmlTypeLoader::loadThread(QQmlDataBlob *blob)
setData(blob, fileName);
} else {
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QNetworkReply *reply = m_thread->networkAccessManager()->get(QNetworkRequest(blob->m_url));
QQmlTypeLoaderNetworkReplyProxy *nrp = m_thread->networkReplyProxy();
blob->addref();
@@ -1156,14 +1156,14 @@ void QQmlTypeLoader::loadThread(QQmlDataBlob *blob)
#ifdef DATABLOB_DEBUG
qWarning("QQmlDataBlob: requested %s", qPrintable(blob->url().toString()));
#endif // DATABLOB_DEBUG
-#endif // QT_NO_NETWORK
+#endif // qml_network
}
}
#define DATALOADER_MAXIMUM_REDIRECT_RECURSION 16
#define TYPELOADER_MINIMUM_TRIM_THRESHOLD 64
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
void QQmlTypeLoader::networkReplyFinished(QNetworkReply *reply)
{
Q_ASSERT(m_thread->isThisThread());
@@ -1219,7 +1219,7 @@ void QQmlTypeLoader::networkReplyProgress(QNetworkReply *reply,
m_thread->callDownloadProgressChanged(blob, blob->m_data.progress());
}
}
-#endif // QT_NO_NETWORK
+#endif // qml_network
/*!
Return the QQmlEngine associated with this loader
@@ -1364,7 +1364,8 @@ bool QQmlTypeLoader::Blob::updateQmldir(QQmlQmldirData *data, const QV4::Compile
// Does this library contain any qualified scripts?
QUrl libraryUrl(qmldirUrl);
const QmldirContent *qmldir = typeLoader()->qmldirContent(qmldirIdentifier);
- foreach (const QQmlDirParser::Script &script, qmldir->scripts()) {
+ const auto qmldirScripts = qmldir->scripts();
+ for (const QQmlDirParser::Script &script : qmldirScripts) {
QUrl scriptUrl = libraryUrl.resolved(QUrl(script.fileName));
QQmlScriptBlob *blob = typeLoader()->getScript(scriptUrl);
addDependency(blob);
@@ -1411,7 +1412,8 @@ bool QQmlTypeLoader::Blob::addImport(const QV4::CompiledData::Import *import, QL
// Does this library contain any qualified scripts?
QUrl libraryUrl(qmldirUrl);
const QmldirContent *qmldir = typeLoader()->qmldirContent(qmldirFilePath);
- foreach (const QQmlDirParser::Script &script, qmldir->scripts()) {
+ const auto qmldirScripts = qmldir->scripts();
+ for (const QQmlDirParser::Script &script : qmldirScripts) {
QUrl scriptUrl = libraryUrl.resolved(QUrl(script.fileName));
QQmlScriptBlob *blob = typeLoader()->getScript(scriptUrl);
addDependency(blob);
@@ -1616,7 +1618,7 @@ QQmlTypeLoader::~QQmlTypeLoader()
invalidate();
}
-QQmlImportDatabase *QQmlTypeLoader::importDatabase()
+QQmlImportDatabase *QQmlTypeLoader::importDatabase() const
{
return &QQmlEnginePrivate::get(engine())->importDatabase;
}
@@ -2230,6 +2232,7 @@ void QQmlTypeData::done()
// verify if any dependencies changed if we're using a cache
if (m_document.isNull() && !m_compiledData->verifyChecksum(engine, resolvedTypeCache)) {
+ qCDebug(DBG_DISK_CACHE) << "Checksum mismatch for cached version of" << m_compiledData->url().toString();
if (!loadFromSource())
return;
m_backupSourceCode.clear();
@@ -2381,7 +2384,7 @@ bool QQmlTypeData::loadFromSource()
if (!compiler.generateFromQml(code, finalUrlString(), m_document.data())) {
QList<QQmlError> errors;
errors.reserve(compiler.errors.count());
- foreach (const QQmlJS::DiagnosticMessage &msg, compiler.errors) {
+ for (const QQmlJS::DiagnosticMessage &msg : qAsConst(compiler.errors)) {
QQmlError e;
e.setUrl(finalUrl());
e.setLine(msg.loc.startLine);
@@ -2516,8 +2519,8 @@ void QQmlTypeData::compile(const QQmlRefPointer<QQmlTypeNameCache> &importCache,
void QQmlTypeData::resolveTypes()
{
// Add any imported scripts to our resolved set
- foreach (const QQmlImports::ScriptReference &script, m_importCache.resolvedScripts())
- {
+ const auto resolvedScripts = m_importCache.resolvedScripts();
+ for (const QQmlImports::ScriptReference &script : resolvedScripts) {
QQmlScriptBlob *blob = typeLoader()->getScript(script.location);
addDependency(blob);
@@ -2537,7 +2540,8 @@ void QQmlTypeData::resolveTypes()
}
// Lets handle resolved composite singleton types
- foreach (const QQmlImports::CompositeSingletonReference &csRef, m_importCache.resolvedCompositeSingletons()) {
+ const auto resolvedCompositeSingletons = m_importCache.resolvedCompositeSingletons();
+ for (const QQmlImports::CompositeSingletonReference &csRef : resolvedCompositeSingletons) {
TypeReference ref;
QString typeName;
if (!csRef.prefix.isEmpty()) {
@@ -2887,7 +2891,7 @@ QQmlScriptData *QQmlScriptBlob::scriptData() const
struct EmptyCompilationUnit : public QV4::CompiledData::CompilationUnit
{
- virtual void linkBackendToEngine(QV4::ExecutionEngine *) {}
+ void linkBackendToEngine(QV4::ExecutionEngine *) override {}
};
void QQmlScriptBlob::dataReceived(const Data &data)
@@ -3102,8 +3106,14 @@ QByteArray QQmlDataBlob::Data::readAll(QString *error, qint64 *sourceTimeStamp)
*error = f.errorString();
return QByteArray();
}
- if (sourceTimeStamp)
- *sourceTimeStamp = QFileInfo(f).lastModified().toMSecsSinceEpoch();
+ if (sourceTimeStamp) {
+ QDateTime timeStamp = QFileInfo(f).lastModified();
+ // Files from the resource system do not have any time stamps, so fall back to the application
+ // executable.
+ if (!timeStamp.isValid())
+ timeStamp = QFileInfo(QCoreApplication::applicationFilePath()).lastModified();
+ *sourceTimeStamp = timeStamp.toMSecsSinceEpoch();
+ }
QByteArray data(f.size(), Qt::Uninitialized);
if (f.read(data.data(), data.length()) != data.length()) {
*error = f.errorString();
diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h
index 5c779e450d..abbbf89ea2 100644
--- a/src/qml/qml/qqmltypeloader_p.h
+++ b/src/qml/qml/qqmltypeloader_p.h
@@ -51,9 +51,10 @@
// We mean it.
//
+#include <QtQml/qtqmlglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qatomic.h>
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
#include <QtNetwork/qnetworkreply.h>
#endif
#include <QtQml/qqmlerror.h>
@@ -154,7 +155,7 @@ protected:
virtual void dataReceived(const Data &) = 0;
virtual void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit*) = 0;
virtual void done();
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
virtual void networkError(QNetworkReply::NetworkError);
#endif
virtual void dependencyError(QQmlDataBlob *);
@@ -242,8 +243,8 @@ public:
virtual void scriptImported(QQmlScriptBlob *, const QV4::CompiledData::Location &, const QString &, const QString &) {}
- virtual void dependencyError(QQmlDataBlob *);
- virtual void dependencyComplete(QQmlDataBlob *);
+ void dependencyError(QQmlDataBlob *) override;
+ void dependencyComplete(QQmlDataBlob *) override;
protected:
virtual QString stringAt(int) const { return QString(); }
@@ -286,7 +287,7 @@ public:
QQmlTypeLoader(QQmlEngine *);
~QQmlTypeLoader();
- QQmlImportDatabase *importDatabase();
+ QQmlImportDatabase *importDatabase() const;
QQmlTypeData *getType(const QUrl &url, Mode mode = PreferSynchronous);
QQmlTypeData *getType(const QByteArray &, const QUrl &url, Mode mode = PreferSynchronous);
@@ -320,16 +321,16 @@ public:
private:
friend class QQmlDataBlob;
friend class QQmlTypeLoaderThread;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
friend class QQmlTypeLoaderNetworkReplyProxy;
-#endif // QT_NO_NETWORK
+#endif // qml_network
void shutdownThread();
void loadThread(QQmlDataBlob *);
void loadWithStaticDataThread(QQmlDataBlob *, const QByteArray &);
void loadWithCachedUnitThread(QQmlDataBlob *blob, const QQmlPrivate::CachedQmlUnit *unit);
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
void networkReplyFinished(QNetworkReply *);
void networkReplyProgress(QNetworkReply *, qint64, qint64);
@@ -366,7 +367,7 @@ private:
QQmlEngine *m_engine;
QQmlTypeLoaderThread *m_thread;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
NetworkReplies m_networkReplies;
#endif
TypeCache m_typeCache;
@@ -433,14 +434,14 @@ public:
void unregisterCallback(TypeDataCallback *);
protected:
- virtual void done();
- virtual void completed();
- virtual void dataReceived(const Data &);
- virtual void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit);
- virtual void allDependenciesDone();
- virtual void downloadProgressChanged(qreal);
+ void done() override;
+ void completed() override;
+ void dataReceived(const Data &) override;
+ void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit) override;
+ void allDependenciesDone() override;
+ void downloadProgressChanged(qreal) override;
- virtual QString stringAt(int index) const;
+ QString stringAt(int index) const override;
private:
bool tryLoadFromDiskCache();
@@ -457,7 +458,7 @@ private:
const QV4::CompiledData::ResolvedTypeReferenceMap &resolvedTypeCache);
bool resolveType(const QString &typeName, int &majorVersion, int &minorVersion, TypeReference &ref);
- virtual void scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace);
+ void scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace) override;
qint64 m_sourceTimeStamp = 0;
@@ -509,7 +510,7 @@ public:
QV4::ReturnedValue scriptValueForContext(QQmlContextData *parentCtxt);
protected:
- virtual void clear(); // From QQmlCleanup
+ void clear() override; // From QQmlCleanup
private:
friend class QQmlScriptBlob;
@@ -545,14 +546,14 @@ public:
QQmlScriptData *scriptData() const;
protected:
- virtual void dataReceived(const Data &);
- virtual void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit);
- virtual void done();
+ void dataReceived(const Data &) override;
+ void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit) override;
+ void done() override;
- virtual QString stringAt(int index) const;
+ QString stringAt(int index) const override;
private:
- virtual void scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace);
+ void scriptImported(QQmlScriptBlob *blob, const QV4::CompiledData::Location &location, const QString &qualifier, const QString &nameSpace) override;
void initializeFromCompilationUnit(QV4::CompiledData::CompilationUnit *unit);
QList<ScriptReference> m_scripts;
diff --git a/src/qml/qml/qqmltypenamecache.cpp b/src/qml/qml/qqmltypenamecache.cpp
index 34e1fc87f2..c2098bc9a1 100644
--- a/src/qml/qml/qqmltypenamecache.cpp
+++ b/src/qml/qml/qqmltypenamecache.cpp
@@ -84,7 +84,7 @@ void QQmlTypeNameCache::add(const QHashedString &name, int importedScriptIndex,
m_namedImports.insert(name, import);
}
-QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name)
+QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name) const
{
Result result = query(m_namedImports, name);
@@ -98,7 +98,7 @@ QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name)
}
QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name,
- const void *importNamespace)
+ const void *importNamespace) const
{
Q_ASSERT(importNamespace);
const Import *i = static_cast<const Import *>(importNamespace);
@@ -112,7 +112,7 @@ QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name,
return result;
}
-QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QV4::String *name)
+QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QV4::String *name) const
{
Result result = query(m_namedImports, name);
@@ -125,7 +125,7 @@ QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QV4::String *name)
return result;
}
-QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QV4::String *name, const void *importNamespace)
+QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QV4::String *name, const void *importNamespace) const
{
Q_ASSERT(importNamespace);
const Import *i = static_cast<const Import *>(importNamespace);
diff --git a/src/qml/qml/qqmltypenamecache_p.h b/src/qml/qml/qqmltypenamecache_p.h
index 7591075102..8a387bed5f 100644
--- a/src/qml/qml/qqmltypenamecache_p.h
+++ b/src/qml/qml/qqmltypenamecache_p.h
@@ -87,10 +87,10 @@ public:
const void *importNamespace;
int scriptIndex;
};
- Result query(const QHashedStringRef &);
- Result query(const QHashedStringRef &, const void *importNamespace);
- Result query(const QV4::String *);
- Result query(const QV4::String *, const void *importNamespace);
+ Result query(const QHashedStringRef &) const;
+ Result query(const QHashedStringRef &, const void *importNamespace) const;
+ Result query(const QV4::String *) const;
+ Result query(const QV4::String *, const void *importNamespace) const;
private:
friend class QQmlImports;
@@ -108,7 +108,7 @@ private:
};
template<typename Key>
- Result query(const QStringHash<Import> &imports, Key key)
+ Result query(const QStringHash<Import> &imports, Key key) const
{
Import *i = imports.value(key);
if (i) {
@@ -123,7 +123,7 @@ private:
}
template<typename Key>
- Result query(const QStringHash<QUrl> &urls, Key key)
+ Result query(const QStringHash<QUrl> &urls, Key key) const
{
QUrl *url = urls.value(key);
if (url) {
@@ -136,7 +136,7 @@ private:
}
template<typename Key>
- Result typeSearch(const QVector<QQmlTypeModuleVersion> &modules, Key key)
+ Result typeSearch(const QVector<QQmlTypeModuleVersion> &modules, Key key) const
{
QVector<QQmlTypeModuleVersion>::const_iterator end = modules.constEnd();
for (QVector<QQmlTypeModuleVersion>::const_iterator it = modules.constBegin(); it != end; ++it) {
diff --git a/src/qml/qml/qqmlvaluetype_p.h b/src/qml/qml/qqmlvaluetype_p.h
index 11e1dfdb00..0502a5d665 100644
--- a/src/qml/qml/qqmlvaluetype_p.h
+++ b/src/qml/qml/qqmlvaluetype_p.h
@@ -74,9 +74,9 @@ public:
void setValue(const QVariant &);
// ---- dynamic meta object data interface
- virtual QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *);
- virtual void objectDestroyed(QObject *);
- virtual int metaCall(QObject *obj, QMetaObject::Call type, int _id, void **argv);
+ QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *) override;
+ void objectDestroyed(QObject *) override;
+ int metaCall(QObject *obj, QMetaObject::Call type, int _id, void **argv) override;
// ----
private:
diff --git a/src/qml/qml/qqmlvaluetypeproxybinding.cpp b/src/qml/qml/qqmlvaluetypeproxybinding.cpp
index 56f073121e..4e2e7b06c7 100644
--- a/src/qml/qml/qqmlvaluetypeproxybinding.cpp
+++ b/src/qml/qml/qqmlvaluetypeproxybinding.cpp
@@ -72,7 +72,7 @@ bool QQmlValueTypeProxyBinding::isValueTypeProxy() const
return true;
}
-QQmlAbstractBinding *QQmlValueTypeProxyBinding::binding(QQmlPropertyIndex propertyIndex)
+QQmlAbstractBinding *QQmlValueTypeProxyBinding::binding(QQmlPropertyIndex propertyIndex) const
{
QQmlAbstractBinding *binding = m_bindings.data();
diff --git a/src/qml/qml/qqmlvaluetypeproxybinding_p.h b/src/qml/qml/qqmlvaluetypeproxybinding_p.h
index 9a487d6992..92b5470f39 100644
--- a/src/qml/qml/qqmlvaluetypeproxybinding_p.h
+++ b/src/qml/qml/qqmlvaluetypeproxybinding_p.h
@@ -60,11 +60,11 @@ class QQmlValueTypeProxyBinding : public QQmlAbstractBinding
public:
QQmlValueTypeProxyBinding(QObject *o, QQmlPropertyIndex coreIndex);
- QQmlAbstractBinding *binding(QQmlPropertyIndex targetPropertyIndex);
+ QQmlAbstractBinding *binding(QQmlPropertyIndex targetPropertyIndex) const;
void removeBindings(quint32 mask);
- virtual void setEnabled(bool, QQmlPropertyData::WriteFlags);
- virtual bool isValueTypeProxy() const;
+ void setEnabled(bool, QQmlPropertyData::WriteFlags) override;
+ bool isValueTypeProxy() const override;
protected:
~QQmlValueTypeProxyBinding();
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index b23bc033d1..43b9e4bd3b 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -275,9 +275,9 @@ void QQmlValueTypeWrapper::advanceIterator(Managed *m, ObjectIterator *it, Value
QV4::Object::advanceIterator(m, it, name, index, p, attributes);
}
-bool QQmlValueTypeWrapper::isEqual(const QVariant& value)
+bool QQmlValueTypeWrapper::isEqual(const QVariant& value) const
{
- if (QQmlValueTypeReference *ref = as<QQmlValueTypeReference>())
+ if (const QQmlValueTypeReference *ref = as<const QQmlValueTypeReference>())
if (!ref->readReferenceValue())
return false;
return (value == d()->toVariant());
diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h
index b8ca5a16f4..fec54df770 100644
--- a/src/qml/qml/qqmlvaluetypewrapper_p.h
+++ b/src/qml/qml/qqmlvaluetypewrapper_p.h
@@ -101,7 +101,7 @@ public:
QVariant toVariant() const;
bool toGadget(void *data) const;
- bool isEqual(const QVariant& value);
+ bool isEqual(const QVariant& value) const;
int typeId() const;
bool write(QObject *target, int propertyIndex) const;
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index b08a0e5087..791870b831 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -343,7 +343,7 @@ QQmlVMEMetaObject::~QQmlVMEMetaObject()
qDeleteAll(varObjectGuards);
}
-QV4::MemberData *QQmlVMEMetaObject::propertyAndMethodStorageAsMemberData()
+QV4::MemberData *QQmlVMEMetaObject::propertyAndMethodStorageAsMemberData() const
{
if (propertyAndMethodStorage.isUndefined()) {
if (propertyAndMethodStorage.valueRef())
@@ -442,7 +442,7 @@ void QQmlVMEMetaObject::writeProperty(int id, QObject* v)
guard->setGuardedValue(v, this, id);
}
-int QQmlVMEMetaObject::readPropertyAsInt(int id)
+int QQmlVMEMetaObject::readPropertyAsInt(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -455,7 +455,7 @@ int QQmlVMEMetaObject::readPropertyAsInt(int id)
return sv->integerValue();
}
-bool QQmlVMEMetaObject::readPropertyAsBool(int id)
+bool QQmlVMEMetaObject::readPropertyAsBool(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -468,7 +468,7 @@ bool QQmlVMEMetaObject::readPropertyAsBool(int id)
return sv->booleanValue();
}
-double QQmlVMEMetaObject::readPropertyAsDouble(int id)
+double QQmlVMEMetaObject::readPropertyAsDouble(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -481,7 +481,7 @@ double QQmlVMEMetaObject::readPropertyAsDouble(int id)
return sv->doubleValue();
}
-QString QQmlVMEMetaObject::readPropertyAsString(int id)
+QString QQmlVMEMetaObject::readPropertyAsString(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -494,7 +494,7 @@ QString QQmlVMEMetaObject::readPropertyAsString(int id)
return sv->stringValue()->toQString();
}
-QUrl QQmlVMEMetaObject::readPropertyAsUrl(int id)
+QUrl QQmlVMEMetaObject::readPropertyAsUrl(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -508,7 +508,7 @@ QUrl QQmlVMEMetaObject::readPropertyAsUrl(int id)
return v->d()->data().value<QUrl>();
}
-QDate QQmlVMEMetaObject::readPropertyAsDate(int id)
+QDate QQmlVMEMetaObject::readPropertyAsDate(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -536,7 +536,7 @@ QDateTime QQmlVMEMetaObject::readPropertyAsDateTime(int id)
return v->d()->data().value<QDateTime>();
}
-QSizeF QQmlVMEMetaObject::readPropertyAsSizeF(int id)
+QSizeF QQmlVMEMetaObject::readPropertyAsSizeF(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -550,7 +550,7 @@ QSizeF QQmlVMEMetaObject::readPropertyAsSizeF(int id)
return v->d()->data().value<QSizeF>();
}
-QPointF QQmlVMEMetaObject::readPropertyAsPointF(int id)
+QPointF QQmlVMEMetaObject::readPropertyAsPointF(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -564,7 +564,7 @@ QPointF QQmlVMEMetaObject::readPropertyAsPointF(int id)
return v->d()->data().value<QPointF>();
}
-QObject* QQmlVMEMetaObject::readPropertyAsQObject(int id)
+QObject* QQmlVMEMetaObject::readPropertyAsQObject(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -578,7 +578,7 @@ QObject* QQmlVMEMetaObject::readPropertyAsQObject(int id)
return wrapper->object();
}
-QList<QObject *> *QQmlVMEMetaObject::readPropertyAsList(int id)
+QList<QObject *> *QQmlVMEMetaObject::readPropertyAsList(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -594,7 +594,7 @@ QList<QObject *> *QQmlVMEMetaObject::readPropertyAsList(int id)
return static_cast<QList<QObject *> *>(v->d()->data().data());
}
-QRectF QQmlVMEMetaObject::readPropertyAsRectF(int id)
+QRectF QQmlVMEMetaObject::readPropertyAsRectF(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (!md)
@@ -976,7 +976,7 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void *
#pragma optimize("", on)
#endif
-QV4::ReturnedValue QQmlVMEMetaObject::method(int index)
+QV4::ReturnedValue QQmlVMEMetaObject::method(int index) const
{
if (!ctxt || !ctxt->isValid() || !compiledObject) {
qWarning("QQmlVMEMetaObject: Internal error - attempted to evaluate a function in an invalid context");
@@ -990,7 +990,7 @@ QV4::ReturnedValue QQmlVMEMetaObject::method(int index)
return (md->data() + index + compiledObject->nProperties)->asReturnedValue();
}
-QV4::ReturnedValue QQmlVMEMetaObject::readVarProperty(int id)
+QV4::ReturnedValue QQmlVMEMetaObject::readVarProperty(int id) const
{
Q_ASSERT(compiledObject && compiledObject->propertyTable()[id].type == QV4::CompiledData::Property::Var);
@@ -1000,7 +1000,7 @@ QV4::ReturnedValue QQmlVMEMetaObject::readVarProperty(int id)
return QV4::Primitive::undefinedValue().asReturnedValue();
}
-QVariant QQmlVMEMetaObject::readPropertyAsVariant(int id)
+QVariant QQmlVMEMetaObject::readPropertyAsVariant(int id) const
{
QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
if (md) {
@@ -1107,7 +1107,7 @@ void QQmlVMEMetaObject::writeProperty(int id, const QVariant &value)
}
}
-QV4::ReturnedValue QQmlVMEMetaObject::vmeMethod(int index)
+QV4::ReturnedValue QQmlVMEMetaObject::vmeMethod(int index) const
{
if (index < methodOffset()) {
Q_ASSERT(parentVMEMetaObject());
@@ -1139,7 +1139,7 @@ void QQmlVMEMetaObject::setVmeMethod(int index, const QV4::Value &function)
*(md->data() + methodIndex + compiledObject->nProperties) = function;
}
-QV4::ReturnedValue QQmlVMEMetaObject::vmeProperty(int index)
+QV4::ReturnedValue QQmlVMEMetaObject::vmeProperty(int index) const
{
if (index < propOffset()) {
Q_ASSERT(parentVMEMetaObject());
diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h
index 031bfdfb9b..9a13e0047d 100644
--- a/src/qml/qml/qqmlvmemetaobject_p.h
+++ b/src/qml/qml/qqmlvmemetaobject_p.h
@@ -148,9 +148,9 @@ public:
~QQmlVMEMetaObject();
bool aliasTarget(int index, QObject **target, int *coreIndex, int *valueTypeIndex) const;
- QV4::ReturnedValue vmeMethod(int index);
+ QV4::ReturnedValue vmeMethod(int index) const;
void setVmeMethod(int index, const QV4::Value &function);
- QV4::ReturnedValue vmeProperty(int index);
+ QV4::ReturnedValue vmeProperty(int index) const;
void setVMEProperty(int index, const QV4::Value &v);
void connectAliasSignal(int index, bool indexInSignalRange);
@@ -174,20 +174,20 @@ public:
QQmlVMEMetaObjectEndpoint *aliasEndpoints;
QV4::WeakValue propertyAndMethodStorage;
- QV4::MemberData *propertyAndMethodStorageAsMemberData();
-
- int readPropertyAsInt(int id);
- bool readPropertyAsBool(int id);
- double readPropertyAsDouble(int id);
- QString readPropertyAsString(int id);
- QSizeF readPropertyAsSizeF(int id);
- QPointF readPropertyAsPointF(int id);
- QUrl readPropertyAsUrl(int id);
- QDate readPropertyAsDate(int id);
+ QV4::MemberData *propertyAndMethodStorageAsMemberData() const;
+
+ int readPropertyAsInt(int id) const;
+ bool readPropertyAsBool(int id) const;
+ double readPropertyAsDouble(int id) const;
+ QString readPropertyAsString(int id) const;
+ QSizeF readPropertyAsSizeF(int id) const;
+ QPointF readPropertyAsPointF(int id) const;
+ QUrl readPropertyAsUrl(int id) const;
+ QDate readPropertyAsDate(int id) const;
QDateTime readPropertyAsDateTime(int id);
- QRectF readPropertyAsRectF(int id);
- QObject *readPropertyAsQObject(int id);
- QList<QObject *> *readPropertyAsList(int id);
+ QRectF readPropertyAsRectF(int id) const;
+ QObject *readPropertyAsQObject(int id) const;
+ QList<QObject *> *readPropertyAsList(int id) const;
void writeProperty(int id, int v);
void writeProperty(int id, bool v);
@@ -207,11 +207,11 @@ public:
void connectAlias(int aliasId);
- QV4::ReturnedValue method(int);
+ QV4::ReturnedValue method(int) const;
- QV4::ReturnedValue readVarProperty(int);
+ QV4::ReturnedValue readVarProperty(int) const;
void writeVarProperty(int, const QV4::Value &);
- QVariant readPropertyAsVariant(int);
+ QVariant readPropertyAsVariant(int) const;
void writeProperty(int, const QVariant &);
inline QQmlVMEMetaObject *parentVMEMetaObject() const;
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index f94946820f..b4be709b37 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -70,7 +70,7 @@
using namespace QV4;
-#if !defined(QT_NO_XMLSTREAMREADER) && !defined(QT_NO_NETWORK)
+#if !defined(QT_NO_XMLSTREAMREADER) && QT_CONFIG(qml_network)
#define V4THROW_REFERENCE(string) { \
ScopedObject error(scope, ctx->engine()->newReferenceErrorObject(QStringLiteral(string))); \
@@ -831,7 +831,8 @@ ReturnedValue Document::load(ExecutionEngine *v4, const QByteArray &data)
}
nodeStack.append(node);
- foreach (const QXmlStreamAttribute &a, reader.attributes()) {
+ const auto attributes = reader.attributes();
+ for (const QXmlStreamAttribute &a : attributes) {
NodeImpl *attr = new NodeImpl;
attr->document = document;
attr->type = NodeImpl::Attr;
@@ -1185,10 +1186,10 @@ QString QQmlXMLHttpRequest::headers() const
void QQmlXMLHttpRequest::fillHeadersList()
{
- QList<QByteArray> headerList = m_network->rawHeaderList();
+ const QList<QByteArray> headerList = m_network->rawHeaderList();
m_headersList.clear();
- foreach (const QByteArray &header, headerList) {
+ for (const QByteArray &header : headerList) {
HeaderPair pair (header.toLower(), m_network->rawHeader(header));
if (pair.first == "set-cookie" ||
pair.first == "set-cookie2")
@@ -1446,7 +1447,7 @@ void QQmlXMLHttpRequest::finished()
void QQmlXMLHttpRequest::readEncoding()
{
- foreach (const HeaderPair &header, m_headersList) {
+ for (const HeaderPair &header : qAsConst(m_headersList)) {
if (header.first == "content-type") {
int separatorIdx = header.second.indexOf(';');
if (separatorIdx == -1) {
@@ -2056,6 +2057,6 @@ void *qt_add_qmlxmlhttprequest(ExecutionEngine *v4)
QT_END_NAMESPACE
-#endif // QT_NO_XMLSTREAMREADER && QT_NO_NETWORK
+#endif // QT_NO_XMLSTREAMREADER && qml_network
#include <qqmlxmlhttprequest.moc>
diff --git a/src/qml/qml/qqmlxmlhttprequest_p.h b/src/qml/qml/qqmlxmlhttprequest_p.h
index df30873915..fdb6194537 100644
--- a/src/qml/qml/qqmlxmlhttprequest_p.h
+++ b/src/qml/qml/qqmlxmlhttprequest_p.h
@@ -55,7 +55,7 @@
#include <QtCore/qglobal.h>
#include <private/qqmlglobal_p.h>
-#if !defined(QT_NO_XMLSTREAMREADER) && !defined(QT_NO_NETWORK)
+#if !defined(QT_NO_XMLSTREAMREADER) && QT_CONFIG(qml_network)
QT_BEGIN_NAMESPACE
@@ -64,7 +64,7 @@ void qt_rem_qmlxmlhttprequest(QV4::ExecutionEngine *engine, void *);
QT_END_NAMESPACE
-#endif // QT_NO_XMLSTREAMREADER && QT_NO_NETWORK
+#endif // QT_NO_XMLSTREAMREADER && qml_network
#endif // QQMLXMLHTTPREQUEST_P_H
diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp
index f15020f6c9..b0599dd0a2 100644
--- a/src/qml/qml/v8/qv8engine.cpp
+++ b/src/qml/qml/v8/qv8engine.cpp
@@ -160,8 +160,10 @@ QV8Engine::~QV8Engine()
qDeleteAll(m_extensionData);
m_extensionData.clear();
+#if !defined(QT_NO_XMLSTREAMREADER) && QT_CONFIG(qml_network)
qt_rem_qmlxmlhttprequest(m_v4Engine, m_xmlHttpRequestData);
m_xmlHttpRequestData = 0;
+#endif
delete m_listModelData;
m_listModelData = 0;
@@ -169,7 +171,7 @@ QV8Engine::~QV8Engine()
delete m_v4Engine;
}
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QNetworkAccessManager *QV8Engine::networkAccessManager()
{
return QQmlEnginePrivate::get(m_engine)->getNetworkAccessManager();
@@ -193,7 +195,7 @@ void QV8Engine::initializeGlobal()
QQmlDateExtension::registerExtension(m_v4Engine);
QQmlNumberExtension::registerExtension(m_v4Engine);
-#if !defined(QT_NO_XMLSTREAMREADER) && !defined(QT_NO_NETWORK)
+#if !defined(QT_NO_XMLSTREAMREADER) && QT_CONFIG(qml_network)
qt_add_domexceptions(m_v4Engine);
m_xmlHttpRequestData = qt_add_qmlxmlhttprequest(m_v4Engine);
#endif
diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h
index 390831609b..3bd3517968 100644
--- a/src/qml/qml/v8/qv8engine_p.h
+++ b/src/qml/qml/v8/qv8engine_p.h
@@ -117,7 +117,7 @@ class QQmlV4Function
{
public:
int length() const { return callData->argc; }
- QV4::ReturnedValue operator[](int idx) { return (idx < callData->argc ? callData->args[idx].asReturnedValue() : QV4::Encode::undefined()); }
+ QV4::ReturnedValue operator[](int idx) const { return (idx < callData->argc ? callData->args[idx].asReturnedValue() : QV4::Encode::undefined()); }
void setReturnValue(QV4::ReturnedValue rv) { *retVal = rv; }
QV4::ExecutionEngine *v4engine() const { return e; }
private:
@@ -181,14 +181,14 @@ public:
QV4::ReturnedValue global();
QQmlDelayedCallQueue *delayedCallQueue() { return &m_delayedCallQueue; }
- void *xmlHttpRequestData() { return m_xmlHttpRequestData; }
+ void *xmlHttpRequestData() const { return m_xmlHttpRequestData; }
- Deletable *listModelData() { return m_listModelData; }
+ Deletable *listModelData() const { return m_listModelData; }
void setListModelData(Deletable *d) { if (m_listModelData) delete m_listModelData; m_listModelData = d; }
void freezeObject(const QV4::Value &value);
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
// Return the network access manager for this engine. By default this returns the network
// access manager of the QQmlEngine. It is overridden in the case of a threaded v8
// instance (like in WorkerScript).
diff --git a/src/qml/qtqmlglobal.h b/src/qml/qtqmlglobal.h
index 34191d06b2..89228b7777 100644
--- a/src/qml/qtqmlglobal.h
+++ b/src/qml/qtqmlglobal.h
@@ -41,6 +41,10 @@
#define QTQMLGLOBAL_H
#include <QtCore/qglobal.h>
+#include <QtQml/qtqml-config.h>
+#if QT_CONFIG(qml_network)
+#include <QtNetwork/qtnetworkglobal.h>
+#endif
QT_BEGIN_NAMESPACE
diff --git a/src/qml/qtqmlglobal_p.h b/src/qml/qtqmlglobal_p.h
index 1b0872298d..63585fd62e 100644
--- a/src/qml/qtqmlglobal_p.h
+++ b/src/qml/qtqmlglobal_p.h
@@ -51,7 +51,9 @@
// We mean it.
//
-#include "qtqmlglobal.h"
+#include <QtCore/private/qglobal_p.h>
+#include <QtQml/private/qtqml-config_p.h>
+#include <QtQml/qtqmlglobal.h>
#if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB)
# define Q_QML_PRIVATE_EXPORT
diff --git a/src/qml/types/qqmlbind_p.h b/src/qml/types/qqmlbind_p.h
index 77939a40bc..c9dd14b58a 100644
--- a/src/qml/types/qqmlbind_p.h
+++ b/src/qml/types/qqmlbind_p.h
@@ -90,9 +90,9 @@ public:
void setDelayed(bool);
protected:
- virtual void setTarget(const QQmlProperty &);
- virtual void classBegin();
- virtual void componentComplete();
+ void setTarget(const QQmlProperty &) override;
+ void classBegin() override;
+ void componentComplete() override;
private:
void prepareEval();
diff --git a/src/qml/types/qqmlconnections.cpp b/src/qml/types/qqmlconnections.cpp
index 84782114ac..1e9e0149dc 100644
--- a/src/qml/types/qqmlconnections.cpp
+++ b/src/qml/types/qqmlconnections.cpp
@@ -204,7 +204,7 @@ void QQmlConnections::setEnabled(bool enabled)
d->enabled = enabled;
- foreach (QQmlBoundSignal *s, d->boundsignals)
+ for (QQmlBoundSignal *s : qAsConst(d->boundsignals))
s->setEnabled(d->enabled);
emit enabledChanged();
diff --git a/src/qml/types/qqmlconnections_p.h b/src/qml/types/qqmlconnections_p.h
index d454affba8..580b6522de 100644
--- a/src/qml/types/qqmlconnections_p.h
+++ b/src/qml/types/qqmlconnections_p.h
@@ -91,15 +91,15 @@ Q_SIGNALS:
private:
void connectSignals();
- void classBegin();
- void componentComplete();
+ void classBegin() override;
+ void componentComplete() override;
};
class QQmlConnectionsParser : public QQmlCustomParser
{
public:
- virtual void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props);
- virtual void applyBindings(QObject *object, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings);
+ void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props) override;
+ void applyBindings(QObject *object, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
};
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index 9b58ec35f8..c4fabbedcc 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -1126,7 +1126,7 @@ void QQmlDelegateModelPrivate::itemsChanged(const QVector<Compositor::Change> &c
QVarLengthArray<QVector<QQmlChangeSet::Change>, Compositor::MaximumGroupCount> translatedChanges(m_groupCount);
- foreach (const Compositor::Change &change, changes) {
+ for (const Compositor::Change &change : changes) {
for (int i = 1; i < m_groupCount; ++i) {
if (change.inGroup(i)) {
translatedChanges[i].append(QQmlChangeSet::Change(change.index[i], change.count));
@@ -1175,7 +1175,7 @@ void QQmlDelegateModelPrivate::itemsInserted(
for (int i = 1; i < m_groupCount; ++i)
inserted[i] = 0;
- foreach (const Compositor::Insert &insert, inserts) {
+ for (const Compositor::Insert &insert : inserts) {
for (; cacheIndex < insert.cacheIndex; ++cacheIndex)
incrementIndexes(m_cache.at(cacheIndex), m_groupCount, inserted);
@@ -1267,7 +1267,7 @@ void QQmlDelegateModelPrivate::itemsRemoved(
for (int i = 1; i < m_groupCount; ++i)
removed[i] = 0;
- foreach (const Compositor::Remove &remove, removes) {
+ for (const Compositor::Remove &remove : removes) {
for (; cacheIndex < remove.cacheIndex; ++cacheIndex)
incrementIndexes(m_cache.at(cacheIndex), m_groupCount, removed);
@@ -1638,7 +1638,7 @@ bool QQmlDelegateModelPrivate::insert(Compositor::insert_iterator &before, const
cacheItem->groups = groups | Compositor::UnresolvedFlag | Compositor::CacheFlag;
// Must be before the new object is inserted into the cache or its indexes will be adjusted too.
- itemsInserted(QVector<Compositor::Insert>() << Compositor::Insert(before, 1, cacheItem->groups & ~Compositor::CacheFlag));
+ itemsInserted(QVector<Compositor::Insert>(1, Compositor::Insert(before, 1, cacheItem->groups & ~Compositor::CacheFlag)));
before = m_compositor.insert(before, 0, 0, 1, cacheItem->groups);
m_cache.insert(before.cacheIndex, cacheItem);
@@ -1749,7 +1749,7 @@ void QQmlDelegateModelItemMetaType::initializePrototype()
int QQmlDelegateModelItemMetaType::parseGroups(const QStringList &groups) const
{
int groupFlags = 0;
- foreach (const QString &groupName, groups) {
+ for (const QString &groupName : groups) {
int index = groupNames.indexOf(groupName);
if (index != -1)
groupFlags |= 2 << index;
@@ -2728,12 +2728,12 @@ void QQmlDelegateModelGroup::resolve(QQmlV4Function *args)
from += 1;
model->itemsMoved(
- QVector<Compositor::Remove>() << Compositor::Remove(fromIt, 1, unresolvedFlags, 0),
- QVector<Compositor::Insert>() << Compositor::Insert(toIt, 1, unresolvedFlags, 0));
+ QVector<Compositor::Remove>(1, Compositor::Remove(fromIt, 1, unresolvedFlags, 0)),
+ QVector<Compositor::Insert>(1, Compositor::Insert(toIt, 1, unresolvedFlags, 0)));
model->itemsInserted(
- QVector<Compositor::Insert>() << Compositor::Insert(toIt, 1, (resolvedFlags & ~unresolvedFlags) | Compositor::CacheFlag));
+ QVector<Compositor::Insert>(1, Compositor::Insert(toIt, 1, (resolvedFlags & ~unresolvedFlags) | Compositor::CacheFlag)));
toIt.incrementIndexes(1, resolvedFlags | unresolvedFlags);
- model->itemsRemoved(QVector<Compositor::Remove>() << Compositor::Remove(toIt, 1, resolvedFlags));
+ model->itemsRemoved(QVector<Compositor::Remove>(1, Compositor::Remove(toIt, 1, resolvedFlags)));
model->m_compositor.setFlags(toGroup, to, 1, unresolvedFlags & ~Compositor::UnresolvedFlag);
model->m_compositor.clearFlags(fromGroup, from, 1, unresolvedFlags);
diff --git a/src/qml/types/qqmldelegatemodel_p.h b/src/qml/types/qqmldelegatemodel_p.h
index 2986ec7ce5..186144d107 100644
--- a/src/qml/types/qqmldelegatemodel_p.h
+++ b/src/qml/types/qqmldelegatemodel_p.h
@@ -90,10 +90,10 @@ class Q_QML_PRIVATE_EXPORT QQmlDelegateModel : public QQmlInstanceModel, public
public:
QQmlDelegateModel();
QQmlDelegateModel(QQmlContext *, QObject *parent=0);
- virtual ~QQmlDelegateModel();
+ ~QQmlDelegateModel();
- void classBegin();
- void componentComplete();
+ void classBegin() override;
+ void componentComplete() override;
QVariant model() const;
void setModel(const QVariant &);
@@ -107,15 +107,15 @@ public:
Q_INVOKABLE QVariant modelIndex(int idx) const;
Q_INVOKABLE QVariant parentModelIndex() const;
- int count() const;
- bool isValid() const { return delegate() != 0; }
- QObject *object(int index, bool asynchronous=false);
- ReleaseFlags release(QObject *object);
- void cancel(int index);
- virtual QString stringValue(int index, const QString &role);
- virtual void setWatchedRoles(const QList<QByteArray> &roles);
+ int count() const override;
+ bool isValid() const override { return delegate() != 0; }
+ QObject *object(int index, bool asynchronous = false) override;
+ ReleaseFlags release(QObject *object) override;
+ void cancel(int index) override;
+ QString stringValue(int index, const QString &role) override;
+ void setWatchedRoles(const QList<QByteArray> &roles) override;
- int indexOf(QObject *object, QObject *objectContext) const;
+ int indexOf(QObject *object, QObject *objectContext) const override;
QString filterGroup() const;
void setFilterGroup(const QString &group);
@@ -126,7 +126,7 @@ public:
QQmlListProperty<QQmlDelegateModelGroup> groups();
QObject *parts();
- bool event(QEvent *);
+ bool event(QEvent *) override;
static QQmlDelegateModelAttached *qmlAttachedProperties(QObject *obj);
diff --git a/src/qml/types/qqmldelegatemodel_p_p.h b/src/qml/types/qqmldelegatemodel_p_p.h
index 6cb82fddfc..f4ffdf38aa 100644
--- a/src/qml/types/qqmldelegatemodel_p_p.h
+++ b/src/qml/types/qqmldelegatemodel_p_p.h
@@ -191,8 +191,8 @@ public:
, incubating(0)
, vdm(l) {}
- virtual void statusChanged(Status);
- virtual void setInitialState(QObject *);
+ void statusChanged(Status) override;
+ void setInitialState(QObject *) override;
QQmlDelegateModelItem *incubating;
QQmlDelegateModelPrivate *vdm;
@@ -354,21 +354,21 @@ public:
void updateFilterGroup();
void updateFilterGroup(Compositor::Group group, const QQmlChangeSet &changeSet);
- int count() const;
- bool isValid() const;
- QObject *object(int index, bool asynchronous=false);
- ReleaseFlags release(QObject *item);
- QString stringValue(int index, const QString &role);
+ int count() const override;
+ bool isValid() const override;
+ QObject *object(int index, bool asynchronous = false) override;
+ ReleaseFlags release(QObject *item) override;
+ QString stringValue(int index, const QString &role) override;
QList<QByteArray> watchedRoles() const { return m_watchedRoles; }
- void setWatchedRoles(const QList<QByteArray> &roles);
+ void setWatchedRoles(const QList<QByteArray> &roles) override;
- int indexOf(QObject *item, QObject *objectContext) const;
+ int indexOf(QObject *item, QObject *objectContext) const override;
- void emitModelUpdated(const QQmlChangeSet &changeSet, bool reset);
+ void emitModelUpdated(const QQmlChangeSet &changeSet, bool reset) override;
- void createdPackage(int index, QQuickPackage *package);
- void initPackage(int index, QQuickPackage *package);
- void destroyingPackage(QQuickPackage *package);
+ void createdPackage(int index, QQuickPackage *package) override;
+ void initPackage(int index, QQuickPackage *package) override;
+ void destroyingPackage(QQuickPackage *package) override;
Q_SIGNALS:
void filterGroupChanged();
@@ -391,8 +391,8 @@ public:
QQmlDelegateModelPartsMetaObject(QObject *parent)
: QQmlOpenMetaObject(parent) {}
- virtual void propertyCreated(int, QMetaPropertyBuilder &);
- virtual QVariant initialValue(int);
+ void propertyCreated(int, QMetaPropertyBuilder &) override;
+ QVariant initialValue(int) override;
};
class QQmlDelegateModelParts : public QObject
@@ -412,8 +412,8 @@ public:
QQmlDelegateModelItemMetaType *metaType, QMetaObject *metaObject);
~QQmlDelegateModelAttachedMetaObject();
- void objectDestroyed(QObject *);
- int metaCall(QObject *, QMetaObject::Call, int _id, void **);
+ void objectDestroyed(QObject *) override;
+ int metaCall(QObject *, QMetaObject::Call, int _id, void **) override;
private:
QQmlDelegateModelItemMetaType * const metaType;
diff --git a/src/qml/types/qqmlinstantiator.cpp b/src/qml/types/qqmlinstantiator.cpp
index 0cec39790d..2de5875deb 100644
--- a/src/qml/types/qqmlinstantiator.cpp
+++ b/src/qml/types/qqmlinstantiator.cpp
@@ -155,7 +155,8 @@ void QQmlInstantiatorPrivate::_q_modelUpdated(const QQmlChangeSet &changeSet, bo
int difference = 0;
QHash<int, QVector<QPointer<QObject> > > moved;
- foreach (const QQmlChangeSet::Change &remove, changeSet.removes()) {
+ const QVector<QQmlChangeSet::Change> &removes = changeSet.removes();
+ for (const QQmlChangeSet::Change &remove : removes) {
int index = qMin(remove.index, objects.count());
int count = qMin(remove.index + remove.count, objects.count()) - index;
if (remove.isMove()) {
@@ -174,7 +175,8 @@ void QQmlInstantiatorPrivate::_q_modelUpdated(const QQmlChangeSet &changeSet, bo
difference -= remove.count;
}
- foreach (const QQmlChangeSet::Change &insert, changeSet.inserts()) {
+ const QVector<QQmlChangeSet::Change> &inserts = changeSet.inserts();
+ for (const QQmlChangeSet::Change &insert : inserts) {
int index = qMin(insert.index, objects.count());
if (insert.isMove()) {
QVector<QPointer<QObject> > movedObjects = moved.value(insert.moveId);
diff --git a/src/qml/types/qqmlinstantiator_p.h b/src/qml/types/qqmlinstantiator_p.h
index dff69ee6b3..ee18daa48c 100644
--- a/src/qml/types/qqmlinstantiator_p.h
+++ b/src/qml/types/qqmlinstantiator_p.h
@@ -72,7 +72,7 @@ class Q_AUTOTEST_EXPORT QQmlInstantiator : public QObject, public QQmlParserStat
public:
QQmlInstantiator(QObject *parent = 0);
- virtual ~QQmlInstantiator();
+ ~QQmlInstantiator();
bool isActive() const;
void setActive(bool newVal);
@@ -92,8 +92,8 @@ public:
Q_INVOKABLE QObject *objectAt(int index) const;
- void classBegin();
- void componentComplete();
+ void classBegin() override;
+ void componentComplete() override;
Q_SIGNALS:
void modelChanged();
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp
index f7fdbf0d80..062f7a2a74 100644
--- a/src/qml/types/qqmllistmodel.cpp
+++ b/src/qml/types/qqmllistmodel.cpp
@@ -230,7 +230,7 @@ const ListLayout::Role *ListLayout::getRoleOrCreate(const QString &key, const QV
return &getRoleOrCreate(key, type);
}
-const ListLayout::Role *ListLayout::getExistingRole(const QString &key)
+const ListLayout::Role *ListLayout::getExistingRole(const QString &key) const
{
Role *r = 0;
QStringHash<Role *>::Node *node = roleHash.findNode(key);
@@ -239,7 +239,7 @@ const ListLayout::Role *ListLayout::getExistingRole(const QString &key)
return r;
}
-const ListLayout::Role *ListLayout::getExistingRole(QV4::String *key)
+const ListLayout::Role *ListLayout::getExistingRole(QV4::String *key) const
{
Role *r = 0;
QStringHash<Role *>::Node *node = roleHash.findNode(key);
@@ -600,11 +600,8 @@ int ListModel::setOrCreateProperty(int elementIndex, const QString &key, const Q
ModelNodeMetaObject *cache = e->objectCache();
- if (roleIndex != -1 && cache) {
- QVector<int> roles;
- roles << roleIndex;
- cache->updateValues(roles);
- }
+ if (roleIndex != -1 && cache)
+ cache->updateValues(QVector<int>(1, roleIndex));
}
}
@@ -1302,11 +1299,8 @@ void ModelNodeMetaObject::propertyWritten(int index)
QV4::ScopedValue v(scope, scope.engine->fromVariant(value));
int roleIndex = m_model->m_listModel->setExistingProperty(m_elementIndex, propName, v, scope.engine);
- if (roleIndex != -1) {
- QVector<int> roles;
- roles << roleIndex;
- m_model->emitItemsChanged(m_elementIndex, 1, roles);
- }
+ if (roleIndex != -1)
+ m_model->emitItemsChanged(m_elementIndex, 1, QVector<int>(1, roleIndex));
}
namespace QV4 {
@@ -1319,11 +1313,8 @@ void ModelObject::put(Managed *m, String *name, const Value &value)
const int elementIndex = that->d()->m_elementIndex;
const QString propName = name->toQString();
int roleIndex = that->d()->m_model->m_listModel->setExistingProperty(elementIndex, propName, value, eng);
- if (roleIndex != -1) {
- QVector<int> roles;
- roles << roleIndex;
- that->d()->m_model->emitItemsChanged(elementIndex, 1, roles);
- }
+ if (roleIndex != -1)
+ that->d()->m_model->emitItemsChanged(elementIndex, 1, QVector<int>(1, roleIndex));
ModelNodeMetaObject *mo = ModelNodeMetaObject::get(that->object());
if (mo->initialized())
@@ -1505,14 +1496,10 @@ void DynamicRoleModelNodeMetaObject::propertyWritten(int index)
}
int elementIndex = parentModel->m_modelObjects.indexOf(m_owner);
- int roleIndex = parentModel->m_roles.indexOf(QString::fromLatin1(name(index).constData()));
-
- if (elementIndex != -1 && roleIndex != -1) {
-
- QVector<int> roles;
- roles << roleIndex;
-
- parentModel->emitItemsChanged(elementIndex, 1, roles);
+ if (elementIndex != -1) {
+ int roleIndex = parentModel->m_roles.indexOf(QString::fromLatin1(name(index).constData()));
+ if (roleIndex != -1)
+ parentModel->emitItemsChanged(elementIndex, 1, QVector<int>(1, roleIndex));
}
}
@@ -1881,14 +1868,14 @@ bool QQmlListModel::setData(const QModelIndex &index, const QVariant &value, int
if (m_dynamicRoles) {
const QByteArray property = m_roles.at(role).toUtf8();
if (m_modelObjects[row]->setValue(property, value)) {
- emitItemsChanged(row, 1, QVector<int>() << role);
+ emitItemsChanged(row, 1, QVector<int>(1, role));
return true;
}
} else {
const ListLayout::Role &r = m_listModel->getExistingRole(role);
const int roleIndex = m_listModel->setOrCreateProperty(row, r.name, value);
if (roleIndex != -1) {
- emitItemsChanged(row, 1, QVector<int>() << role);
+ emitItemsChanged(row, 1, QVector<int>(1, role));
return true;
}
}
@@ -2356,20 +2343,12 @@ void QQmlListModel::setProperty(int index, const QString& property, const QVaria
roleIndex = m_roles.count();
m_roles.append(property);
}
- if (m_modelObjects[index]->setValue(property.toUtf8(), value)) {
- QVector<int> roles;
- roles << roleIndex;
- emitItemsChanged(index, 1, roles);
- }
+ if (m_modelObjects[index]->setValue(property.toUtf8(), value))
+ emitItemsChanged(index, 1, QVector<int>(1, roleIndex));
} else {
int roleIndex = m_listModel->setOrCreateProperty(index, property, value);
- if (roleIndex != -1) {
-
- QVector<int> roles;
- roles << roleIndex;
-
- emitItemsChanged(index, 1, roles);
- }
+ if (roleIndex != -1)
+ emitItemsChanged(index, 1, QVector<int>(1, roleIndex));
}
}
@@ -2498,7 +2477,7 @@ void QQmlListModelParser::verifyBindings(const QV4::CompiledData::Unit *qmlUnit,
{
listElementTypeName = QString(); // unknown
- foreach (const QV4::CompiledData::Binding *binding, bindings) {
+ for (const QV4::CompiledData::Binding *binding : bindings) {
QString propName = qmlUnit->stringAt(binding->propertyNameIndex);
if (!propName.isEmpty()) { // isn't default property
error(binding, QQmlListModel::tr("ListModel: undefined property '%1'").arg(propName));
@@ -2519,7 +2498,7 @@ void QQmlListModelParser::applyBindings(QObject *obj, QV4::CompiledData::Compila
bool setRoles = false;
- foreach (const QV4::CompiledData::Binding *binding, bindings) {
+ for (const QV4::CompiledData::Binding *binding : bindings) {
if (binding->type != QV4::CompiledData::Binding::Type_Object)
continue;
setRoles |= applyProperty(qmlUnit, binding, rv->m_listModel, /*outter element index*/-1);
diff --git a/src/qml/types/qqmllistmodel_p.h b/src/qml/types/qqmllistmodel_p.h
index 220b0e54b5..b750d30676 100644
--- a/src/qml/types/qqmllistmodel_p.h
+++ b/src/qml/types/qqmllistmodel_p.h
@@ -85,11 +85,11 @@ public:
QQmlListModel(QObject *parent=0);
~QQmlListModel();
- QModelIndex index(int row, int column, const QModelIndex &parent) const;
- int rowCount(const QModelIndex &parent) const;
- QVariant data(const QModelIndex &index, int role) const;
- bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
- QHash<int,QByteArray> roleNames() const;
+ QModelIndex index(int row, int column, const QModelIndex &parent) const override;
+ int rowCount(const QModelIndex &parent) const override;
+ QVariant data(const QModelIndex &index, int role) const override;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
+ QHash<int,QByteArray> roleNames() const override;
QVariant data(int index, int role) const;
int count() const;
@@ -195,7 +195,7 @@ private:
// returns true if a role was set
bool applyProperty(const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding, ListModel *model, int outterElementIndex);
- bool definesEmptyList(const QString &);
+ static bool definesEmptyList(const QString &);
QString listElementTypeName;
};
diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h
index 6e17b55e79..ddf77e52c0 100644
--- a/src/qml/types/qqmllistmodel_p_p.h
+++ b/src/qml/types/qqmllistmodel_p_p.h
@@ -71,8 +71,8 @@ public:
bool m_enabled;
protected:
- void propertyWrite(int index);
- void propertyWritten(int index);
+ void propertyWrite(int index) override;
+ void propertyWritten(int index) override;
private:
DynamicRoleModelNode *m_owner;
@@ -88,7 +88,7 @@ public:
void updateValues(const QVariantMap &object, QVector<int> &roles);
- QVariant getValue(const QString &name)
+ QVariant getValue(const QString &name) const
{
return m_meta->value(name.toUtf8());
}
@@ -124,7 +124,7 @@ public:
ModelNodeMetaObject(QObject *object, QQmlListModel *model, int elementIndex);
~ModelNodeMetaObject();
- virtual QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *object);
+ QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *object) override;
static ModelNodeMetaObject *get(QObject *obj);
@@ -138,7 +138,7 @@ public:
bool initialized() const { return m_initialized; }
protected:
- void propertyWritten(int index);
+ void propertyWritten(int index) override;
private:
using QQmlOpenMetaObject::setValue;
@@ -230,9 +230,9 @@ public:
const Role &getRoleOrCreate(QV4::String *key, Role::DataType type);
const Role &getRoleOrCreate(const QString &key, Role::DataType type);
- const Role &getExistingRole(int index) { return *roles.at(index); }
- const Role *getExistingRole(const QString &key);
- const Role *getExistingRole(QV4::String *key);
+ const Role &getExistingRole(int index) const { return *roles.at(index); }
+ const Role *getExistingRole(const QString &key) const;
+ const Role *getExistingRole(QV4::String *key) const;
int roleCount() const { return roles.count(); }
@@ -338,12 +338,12 @@ public:
return m_layout->roleCount();
}
- const ListLayout::Role &getExistingRole(int index)
+ const ListLayout::Role &getExistingRole(int index) const
{
return m_layout->getExistingRole(index);
}
- const ListLayout::Role *getExistingRole(QV4::String *key)
+ const ListLayout::Role *getExistingRole(QV4::String *key) const
{
return m_layout->getExistingRole(key);
}
diff --git a/src/qml/types/qqmllistmodelworkeragent_p.h b/src/qml/types/qqmllistmodelworkeragent_p.h
index 1a891c0f25..5a39651bf7 100644
--- a/src/qml/types/qqmllistmodelworkeragent_p.h
+++ b/src/qml/types/qqmllistmodelworkeragent_p.h
@@ -108,7 +108,7 @@ public:
void modelDestroyed();
protected:
- virtual bool event(QEvent *);
+ bool event(QEvent *) override;
private:
friend class QQuickWorkerScriptEnginePrivate;
diff --git a/src/qml/types/qqmlobjectmodel.cpp b/src/qml/types/qqmlobjectmodel.cpp
index 8c8005fb69..695043b592 100644
--- a/src/qml/types/qqmlobjectmodel.cpp
+++ b/src/qml/types/qqmlobjectmodel.cpp
@@ -154,7 +154,7 @@ public:
void clear() {
Q_Q(QQmlObjectModel);
- foreach (const Item &child, children)
+ for (const Item &child : qAsConst(children))
emit q->destroyingItem(child.item);
remove(0, children.count());
}
diff --git a/src/qml/types/qqmlobjectmodel_p.h b/src/qml/types/qqmlobjectmodel_p.h
index 97a56344d4..fc4c03874f 100644
--- a/src/qml/types/qqmlobjectmodel_p.h
+++ b/src/qml/types/qqmlobjectmodel_p.h
@@ -109,16 +109,16 @@ class Q_QML_PRIVATE_EXPORT QQmlObjectModel : public QQmlInstanceModel
public:
QQmlObjectModel(QObject *parent=0);
- virtual ~QQmlObjectModel() {}
+ ~QQmlObjectModel() {}
- virtual int count() const;
- virtual bool isValid() const;
- virtual QObject *object(int index, bool asynchronous=false);
- virtual ReleaseFlags release(QObject *object);
- virtual QString stringValue(int index, const QString &role);
- virtual void setWatchedRoles(const QList<QByteArray> &) {}
+ int count() const override;
+ bool isValid() const override;
+ QObject *object(int index, bool asynchronous = false) override;
+ ReleaseFlags release(QObject *object) override;
+ QString stringValue(int index, const QString &role) override;
+ void setWatchedRoles(const QList<QByteArray> &) override {}
- virtual int indexOf(QObject *object, QObject *objectContext) const;
+ int indexOf(QObject *object, QObject *objectContext) const override;
QQmlListProperty<QObject> children();
diff --git a/src/qml/types/qqmltimer.cpp b/src/qml/types/qqmltimer.cpp
index 889274b43e..7efdac4c22 100644
--- a/src/qml/types/qqmltimer.cpp
+++ b/src/qml/types/qqmltimer.cpp
@@ -60,8 +60,8 @@ public:
: interval(1000), running(false), repeating(false), triggeredOnStart(false)
, classBegun(false), componentComplete(false), firstTick(true), awaitingTick(false) {}
- virtual void animationFinished(QAbstractAnimationJob *);
- virtual void animationCurrentLoopChanged(QAbstractAnimationJob *) { maybeTick(); }
+ void animationFinished(QAbstractAnimationJob *) override;
+ void animationCurrentLoopChanged(QAbstractAnimationJob *) override { maybeTick(); }
void maybeTick() {
Q_Q(QQmlTimer);
diff --git a/src/qml/types/qqmltimer_p.h b/src/qml/types/qqmltimer_p.h
index 7ea2f098bf..7739dad2a6 100644
--- a/src/qml/types/qqmltimer_p.h
+++ b/src/qml/types/qqmltimer_p.h
@@ -87,10 +87,10 @@ public:
void setTriggeredOnStart(bool triggeredOnStart);
protected:
- void classBegin();
- void componentComplete();
+ void classBegin() override;
+ void componentComplete() override;
- bool event(QEvent *);
+ bool event(QEvent *) override;
public Q_SLOTS:
void start();
diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp
index 10666476fe..cdcc894da9 100644
--- a/src/qml/types/qquickworkerscript.cpp
+++ b/src/qml/types/qquickworkerscript.cpp
@@ -54,7 +54,7 @@
#include <QtCore/qdatetime.h>
#include <QtQml/qqmlinfo.h>
#include <QtQml/qqmlfile.h>
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
#include <QtNetwork/qnetworkaccessmanager.h>
#include "qqmlnetworkaccessmanagerfactory.h"
#endif
@@ -144,8 +144,8 @@ public:
void init();
-#ifndef QT_NO_NETWORK
- virtual QNetworkAccessManager *networkAccessManager();
+#if QT_CONFIG(qml_network)
+ QNetworkAccessManager *networkAccessManager() override;
#endif
QQuickWorkerScriptEnginePrivate *p;
@@ -155,7 +155,7 @@ public:
QV4::PersistentValue onmessage;
private:
QV4::PersistentValue createsend;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QNetworkAccessManager *accessManager;
#endif
};
@@ -192,7 +192,7 @@ signals:
void stopThread();
protected:
- virtual bool event(QEvent *);
+ bool event(QEvent *) override;
private:
void processMessage(int, const QByteArray &);
@@ -202,7 +202,7 @@ private:
QQuickWorkerScriptEnginePrivate::WorkerEngine::WorkerEngine(QQuickWorkerScriptEnginePrivate *parent)
: QV8Engine(0), p(parent)
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
, accessManager(0)
#endif
{
@@ -211,7 +211,7 @@ QQuickWorkerScriptEnginePrivate::WorkerEngine::WorkerEngine(QQuickWorkerScriptEn
QQuickWorkerScriptEnginePrivate::WorkerEngine::~WorkerEngine()
{
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
delete accessManager;
#endif
}
@@ -274,7 +274,7 @@ QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::WorkerEngine::sendFunction(i
return scope.result.asReturnedValue();
}
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QNetworkAccessManager *QQuickWorkerScriptEnginePrivate::WorkerEngine::networkAccessManager()
{
if (!accessManager) {
diff --git a/src/qml/types/qquickworkerscript_p.h b/src/qml/types/qquickworkerscript_p.h
index de6f3dc324..dce3acc3e1 100644
--- a/src/qml/types/qquickworkerscript_p.h
+++ b/src/qml/types/qquickworkerscript_p.h
@@ -68,7 +68,7 @@ class QQuickWorkerScriptEngine : public QThread
Q_OBJECT
public:
QQuickWorkerScriptEngine(QQmlEngine *parent = 0);
- virtual ~QQuickWorkerScriptEngine();
+ ~QQuickWorkerScriptEngine();
int registerWorkerScript(QQuickWorkerScript *);
void removeWorkerScript(int);
@@ -76,7 +76,7 @@ public:
void sendMessage(int, const QByteArray &);
protected:
- virtual void run();
+ void run() override;
private:
QQuickWorkerScriptEnginePrivate *d;
@@ -92,7 +92,7 @@ class Q_AUTOTEST_EXPORT QQuickWorkerScript : public QObject, public QQmlParserSt
Q_INTERFACES(QQmlParserStatus)
public:
QQuickWorkerScript(QObject *parent = 0);
- virtual ~QQuickWorkerScript();
+ ~QQuickWorkerScript();
QUrl source() const;
void setSource(const QUrl &);
@@ -105,9 +105,9 @@ Q_SIGNALS:
void message(const QQmlV4Handle &messageObject);
protected:
- virtual void classBegin();
- virtual void componentComplete();
- virtual bool event(QEvent *);
+ void classBegin() override;
+ void componentComplete() override;
+ bool event(QEvent *) override;
private:
QQuickWorkerScriptEngine *engine();
diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp
index 5fc2444b7c..b9d312d41f 100644
--- a/src/qml/util/qqmladaptormodel.cpp
+++ b/src/qml/util/qqmladaptormodel.cpp
@@ -146,7 +146,7 @@ public:
bool changed = roles.isEmpty() && !watchedRoles.isEmpty();
if (!changed && !watchedRoles.isEmpty() && watchedRoleIds.isEmpty()) {
QList<int> roleIds;
- foreach (const QByteArray &r, watchedRoles) {
+ for (const QByteArray &r : watchedRoles) {
QHash<QByteArray, int>::const_iterator it = roleNames.find(r);
if (it != roleNames.end())
roleIds << it.value();
@@ -190,7 +190,7 @@ public:
VDMModelDelegateDataType *dataType = const_cast<VDMModelDelegateDataType *>(this);
dataType->watchedRoleIds.clear();
- foreach (const QByteArray &oldRole, oldRoles)
+ for (const QByteArray &oldRole : oldRoles)
dataType->watchedRoles.removeOne(oldRole);
dataType->watchedRoles += newRoles;
}
diff --git a/src/qml/util/qqmlchangeset.cpp b/src/qml/util/qqmlchangeset.cpp
index 088ac5e8c0..79e3332331 100644
--- a/src/qml/util/qqmlchangeset.cpp
+++ b/src/qml/util/qqmlchangeset.cpp
@@ -558,9 +558,15 @@ void QQmlChangeSet::change(QVector<Change> *changes)
QDebug operator <<(QDebug debug, const QQmlChangeSet &set)
{
debug.nospace() << "QQmlChangeSet(";
- foreach (const QQmlChangeSet::Change &remove, set.removes()) debug << remove;
- foreach (const QQmlChangeSet::Change &insert, set.inserts()) debug << insert;
- foreach (const QQmlChangeSet::Change &change, set.changes()) debug << change;
+ const QVector<QQmlChangeSet::Change> &removes = set.removes();
+ for (const QQmlChangeSet::Change &remove : removes)
+ debug << remove;
+ const QVector<QQmlChangeSet::Change> &inserts = set.inserts();
+ for (const QQmlChangeSet::Change &insert : inserts)
+ debug << insert;
+ const QVector<QQmlChangeSet::Change> &changes = set.changes();
+ for (const QQmlChangeSet::Change &change : changes)
+ debug << change;
return debug.nospace() << ')';
}
diff --git a/src/qml/util/qqmllistcompositor.cpp b/src/qml/util/qqmllistcompositor.cpp
index 4cfdf77b2a..05a4eaac39 100644
--- a/src/qml/util/qqmllistcompositor.cpp
+++ b/src/qml/util/qqmllistcompositor.cpp
@@ -964,7 +964,7 @@ void QQmlListCompositor::listItemsInserted(
it.incrementIndexes(it->count);
continue;
}
- foreach (const QQmlChangeSet::Change &insertion, insertions) {
+ for (const QQmlChangeSet::Change &insertion : insertions) {
int offset = insertion.index - it->index;
if ((offset > 0 && offset < it->count)
|| (offset == 0 && it->prepend())
@@ -1301,7 +1301,7 @@ void QQmlListCompositor::listItemsChanged(
} else if (!it->inGroup()) {
continue;
}
- foreach (const QQmlChangeSet::Change &change, changes) {
+ for (const QQmlChangeSet::Change &change : changes) {
const int offset = change.index - it->index;
if (offset + change.count > 0 && offset < it->count) {
const int changeOffset = qMax(0, offset);
diff --git a/src/qml/util/qqmlpropertymap.cpp b/src/qml/util/qqmlpropertymap.cpp
index 69d3fc25e1..6e6554f2c3 100644
--- a/src/qml/util/qqmlpropertymap.cpp
+++ b/src/qml/util/qqmlpropertymap.cpp
@@ -54,10 +54,10 @@ public:
QQmlPropertyMapMetaObject(QQmlPropertyMap *obj, QQmlPropertyMapPrivate *objPriv, const QMetaObject *staticMetaObject);
protected:
- virtual QVariant propertyWriteValue(int, const QVariant &);
- virtual void propertyWritten(int index);
- virtual void propertyCreated(int, QMetaPropertyBuilder &);
- virtual int createProperty(const char *, const char *);
+ QVariant propertyWriteValue(int, const QVariant &) override;
+ void propertyWritten(int index) override;
+ void propertyCreated(int, QMetaPropertyBuilder &) override;
+ int createProperty(const char *, const char *) override;
const QString &propertyName(int index);
diff --git a/src/qmltest/quicktestevent.cpp b/src/qmltest/quicktestevent.cpp
index f722fab6c4..7a2ec30a5a 100644
--- a/src/qmltest/quicktestevent.cpp
+++ b/src/qmltest/quicktestevent.cpp
@@ -124,6 +124,8 @@ namespace QtQuickTest
{
enum MouseAction { MousePress, MouseRelease, MouseClick, MouseDoubleClick, MouseMove, MouseDoubleClickSequence };
+ int lastMouseTimestamp = 0;
+
static void mouseEvent(MouseAction action, QWindow *window,
QObject *item, Qt::MouseButton button,
Qt::KeyboardModifiers stateKey, QPointF _pos, int delay=-1)
@@ -133,8 +135,10 @@ namespace QtQuickTest
if (delay == -1 || delay < QTest::defaultMouseDelay())
delay = QTest::defaultMouseDelay();
- if (delay > 0)
+ if (delay > 0) {
QTest::qWait(delay);
+ lastMouseTimestamp += delay;
+ }
if (action == MouseClick) {
mouseEvent(MousePress, window, item, button, stateKey, _pos);
@@ -165,12 +169,16 @@ namespace QtQuickTest
{
case MousePress:
me = QMouseEvent(QEvent::MouseButtonPress, pos, window->mapToGlobal(pos), button, button, stateKey);
+ me.setTimestamp(++lastMouseTimestamp);
break;
case MouseRelease:
me = QMouseEvent(QEvent::MouseButtonRelease, pos, window->mapToGlobal(pos), button, 0, stateKey);
+ me.setTimestamp(++lastMouseTimestamp);
+ lastMouseTimestamp += 500; // avoid double clicks being generated
break;
case MouseDoubleClick:
me = QMouseEvent(QEvent::MouseButtonDblClick, pos, window->mapToGlobal(pos), button, button, stateKey);
+ me.setTimestamp(++lastMouseTimestamp);
break;
case MouseMove:
// with move event the button is NoButton, but 'buttons' holds the currently pressed buttons
@@ -317,6 +325,10 @@ bool QuickTestEvent::mouseMove
QWindow *QuickTestEvent::eventWindow(QObject *item)
{
+ QWindow * window = qobject_cast<QWindow *>(item);
+ if (window)
+ return window;
+
QQuickItem *quickItem = qobject_cast<QQuickItem *>(item);
if (quickItem)
return quickItem->window();
diff --git a/src/qmltest/quicktestresult.cpp b/src/qmltest/quicktestresult.cpp
index e05d29bc05..02d925d37d 100644
--- a/src/qmltest/quicktestresult.cpp
+++ b/src/qmltest/quicktestresult.cpp
@@ -46,6 +46,11 @@
#include <QtTest/private/qtestlog_p.h>
#include "qtestoptions_p.h"
#include <QtTest/qbenchmark.h>
+// qbenchmark_p.h pulls windows.h via 3rd party; prevent it from defining
+// the min/max macros which would clash with qnumeric_p.h's usage of min()/max().
+#if defined(Q_OS_WIN32) && !defined(NOMINMAX)
+# define NOMINMAX
+#endif
#include <QtTest/private/qbenchmark_p.h>
#include <QtCore/qset.h>
#include <QtCore/qmap.h>
@@ -519,7 +524,7 @@ void QuickTestResult::stringify(QQmlV4Function *args)
if (result.isEmpty()) {
QString tmp = value->toQStringNoThrow();
if (value->as<QV4::ArrayObject>())
- result.append(QString::fromLatin1("[%1]").arg(tmp));
+ result += QLatin1Char('[') + tmp + QLatin1Char(']');
else
result.append(tmp);
}
diff --git a/src/quick/accessible/qaccessiblequickitem.cpp b/src/quick/accessible/qaccessiblequickitem.cpp
index acea958e20..03236ce2f7 100644
--- a/src/quick/accessible/qaccessiblequickitem.cpp
+++ b/src/quick/accessible/qaccessiblequickitem.cpp
@@ -67,10 +67,6 @@ int QAccessibleQuickItem::childCount() const
QRect QAccessibleQuickItem::rect() const
{
const QRect r = itemScreenRect(item());
-
- if (!r.isValid()) {
- qWarning() << item()->metaObject()->className() << item()->property("accessibleText") << r;
- }
return r;
}
@@ -273,8 +269,8 @@ void QAccessibleQuickItem::doAction(const QString &actionName)
return;
// Look for and call the accessible[actionName]Action() function on the item.
// This allows for overriding the default action handling.
- const QByteArray functionName = QByteArrayLiteral("accessible") + actionName.toLatin1() + QByteArrayLiteral("Action");
- if (object()->metaObject()->indexOfMethod(QByteArray(functionName + QByteArrayLiteral("()"))) != -1) {
+ const QByteArray functionName = "accessible" + actionName.toLatin1() + "Action";
+ if (object()->metaObject()->indexOfMethod(QByteArray(functionName + "()")) != -1) {
QMetaObject::invokeMethod(object(), functionName);
return;
}
diff --git a/src/quick/accessible/qaccessiblequickview_p.h b/src/quick/accessible/qaccessiblequickview_p.h
index 457e8b456b..e9c150ac22 100644
--- a/src/quick/accessible/qaccessiblequickview_p.h
+++ b/src/quick/accessible/qaccessiblequickview_p.h
@@ -63,20 +63,20 @@ class QAccessibleQuickWindow : public QAccessibleObject
public:
QAccessibleQuickWindow(QQuickWindow *object);
- QAccessibleInterface *parent() const;
- QAccessibleInterface *child(int index) const;
+ QAccessibleInterface *parent() const override;
+ QAccessibleInterface *child(int index) const override;
- QAccessible::Role role() const;
- QAccessible::State state() const;
- QRect rect() const;
+ QAccessible::Role role() const override;
+ QAccessible::State state() const override;
+ QRect rect() const override;
- int childCount() const;
- int indexOfChild(const QAccessibleInterface *iface) const;
- QString text(QAccessible::Text text) const;
- QAccessibleInterface *childAt(int x, int y) const;
+ int childCount() const override;
+ int indexOfChild(const QAccessibleInterface *iface) const override;
+ QString text(QAccessible::Text text) const override;
+ QAccessibleInterface *childAt(int x, int y) const override;
private:
- QQuickWindow *window() const { return static_cast<QQuickWindow*>(object()); }
+ QQuickWindow *window() const override { return static_cast<QQuickWindow*>(object()); }
QList<QQuickItem *> rootItems() const;
};
diff --git a/src/quick/configure.json b/src/quick/configure.json
new file mode 100644
index 0000000000..4ed11e8318
--- /dev/null
+++ b/src/quick/configure.json
@@ -0,0 +1,157 @@
+{
+ "module": "quick",
+ "depends": [
+ "qml-private",
+ "gui-private"
+ ],
+ "testDir": "../../config.tests",
+
+ "commandline": {
+ "options": {
+ "d3d12": "boolean",
+ "quick-animatedimage": "boolean",
+ "quick-canvas": "boolean",
+ "quick-designer": "boolean",
+ "quick-flipable": "boolean",
+ "quick-gridview": "boolean",
+ "quick-listview": "boolean",
+ "quick-path": "boolean",
+ "quick-pathview": "boolean",
+ "quick-positioners": "boolean",
+ "quick-shadereffect": "boolean",
+ "quick-sprite": "boolean"
+ }
+ },
+
+ "tests": {
+ "d3d12": {
+ "label": "Direct3D 12",
+ "type": "compile",
+ "test": "d3d12"
+ }
+ },
+
+ "features": {
+ "d3d12": {
+ "label": "Direct3D 12",
+ "purpose": "Provides a Direct3D 12 backend for the Qt Quick Scenegraph",
+ "condition": "tests.d3d12",
+ "output": [
+ "publicFeature"
+ ]
+ },
+ "quick-animatedimage": {
+ "label": "AnimatedImage item",
+ "purpose": "Provides the Qt Quick AnimatedImage Item",
+ "condition": "features.movie",
+ "output": [
+ "privateFeature"
+ ]
+ },
+ "quick-canvas": {
+ "label": "Canvas item",
+ "purpose": "Provides the Qt Quick Canvas Item",
+ "output": [
+ "privateFeature"
+ ]
+ },
+ "quick-designer": {
+ "label": "Support for Quick Designer",
+ "purpose": "Provides support for the Qt Quick Designer in Qt Creator",
+ "output": [
+ "privateFeature"
+ ]
+ },
+ "quick-flipable": {
+ "label": "Flipable item",
+ "purpose": "Provides the Qt Quick Flipable Item",
+ "output": [
+ "privateFeature"
+ ]
+ },
+ "quick-gridview": {
+ "label": "GridView item",
+ "purpose": "Provides the Qt Quick GridView item",
+ "output": [
+ "privateFeature"
+ ]
+ },
+ "quick-itemview": {
+ "label": "ItemView item",
+ "condition": "features.quick-gridview || features.quick-listview",
+ "output": [
+ "privateFeature"
+ ]
+ },
+ "quick-viewtransitions": {
+ "label": "Transitions required for ItemViews and Positioners",
+ "condition": "features.quick-itemview || features.quick-positioners",
+ "output": [
+ "privateFeature"
+ ]
+ },
+ "quick-listview": {
+ "label": "ListView item",
+ "purpose": "Provides the Qt Quick ListView item",
+ "output": [
+ "privateFeature"
+ ]
+ },
+ "quick-path": {
+ "label": "Path support",
+ "purpose": "Provides Path elements in Qt Quick",
+ "output": [
+ "privateFeature"
+ ]
+ },
+ "quick-pathview": {
+ "label": "PathView item",
+ "purpose": "Provides the Qt Quick PathView item",
+ "condition": "features.quick-path",
+ "output": [
+ "privateFeature"
+ ]
+ },
+ "quick-positioners": {
+ "label": "Positioner items",
+ "purpose": "Provides Positioner items in Qt Quick",
+ "output": [
+ "privateFeature"
+ ]
+ },
+ "quick-shadereffect": {
+ "label": "ShaderEffect item",
+ "purpose": "Provides Shader effects in Qt Quick",
+ "output": [
+ "privateFeature"
+ ]
+ },
+ "quick-sprite": {
+ "label": "Sprite item",
+ "purpose": "Provides the Qt Quick Sprite Item",
+ "output": [
+ "privateFeature"
+ ]
+ }
+ },
+
+ "summary": [
+ {
+ "section": "Qt Quick",
+ "entries": [
+ "d3d12",
+ "quick-animatedimage",
+ "quick-canvas",
+ "quick-designer",
+ "quick-flipable",
+ "quick-gridview",
+ "quick-listview",
+ "quick-path",
+ "quick-pathview",
+ "quick-positioners",
+ "quick-shadereffect",
+ "quick-sprite"
+ ]
+ }
+ ]
+}
diff --git a/src/quick/designer/qqmldesignermetaobject_p.h b/src/quick/designer/qqmldesignermetaobject_p.h
index 01512f6af0..3c02c0d3f5 100644
--- a/src/quick/designer/qqmldesignermetaobject_p.h
+++ b/src/quick/designer/qqmldesignermetaobject_p.h
@@ -74,7 +74,7 @@ protected:
void createNewDynamicProperty(const QString &name);
int openMetaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a);
- int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a);
+ int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a) override;
void notifyPropertyChange(int id);
void setValue(int id, const QVariant &value);
QVariant propertyWriteValue(int, const QVariant &);
diff --git a/src/quick/designer/qquickdesignercustomparserobject_p.h b/src/quick/designer/qquickdesignercustomparserobject_p.h
index 06206443b2..e4d0765277 100644
--- a/src/quick/designer/qquickdesignercustomparserobject_p.h
+++ b/src/quick/designer/qquickdesignercustomparserobject_p.h
@@ -40,6 +40,17 @@
#ifndef QUICKDESIGNERCUSTOMPARSEROBJECT_H
#define QUICKDESIGNERCUSTOMPARSEROBJECT_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 <QObject>
#include <private/qqmlcustomparser_p.h>
diff --git a/src/quick/designer/qquickdesignersupport.cpp b/src/quick/designer/qquickdesignersupport.cpp
index 44be12bb78..3ff5a3ce96 100644
--- a/src/quick/designer/qquickdesignersupport.cpp
+++ b/src/quick/designer/qquickdesignersupport.cpp
@@ -40,7 +40,9 @@
#include "qquickdesignersupport_p.h"
#include <private/qquickitem_p.h>
+#if QT_CONFIG(quick_shadereffect)
#include <QtQuick/private/qquickshadereffectsource_p.h>
+#endif
#include <QtQuick/private/qquickrectangle_p.h>
#include <QtQml/private/qabstractanimationjob_p.h>
#include <private/qqmlengine_p.h>
@@ -51,6 +53,7 @@
#include <private/qqmlvme_p.h>
#include <private/qqmlcomponentattached_p.h>
#include <private/qqmldata_p.h>
+#include <private/qsgadaptationlayer_p.h>
#include "qquickdesignerwindowmanager_p.h"
diff --git a/src/quick/designer/qquickdesignerwindowmanager_p.h b/src/quick/designer/qquickdesignerwindowmanager_p.h
index a50f8aa49f..209d703d0a 100644
--- a/src/quick/designer/qquickdesignerwindowmanager_p.h
+++ b/src/quick/designer/qquickdesignerwindowmanager_p.h
@@ -75,24 +75,24 @@ class QQuickDesignerWindowManager : public QSGRenderLoop
public:
QQuickDesignerWindowManager();
- void show(QQuickWindow *window);
- void hide(QQuickWindow *window);
+ void show(QQuickWindow *window) override;
+ void hide(QQuickWindow *window) override;
- void windowDestroyed(QQuickWindow *window);
+ void windowDestroyed(QQuickWindow *window) override;
void makeOpenGLContext(QQuickWindow *window);
- void exposureChanged(QQuickWindow *window);
- QImage grab(QQuickWindow *window);
+ void exposureChanged(QQuickWindow *window) override;
+ QImage grab(QQuickWindow *window) override;
- void maybeUpdate(QQuickWindow *window);
- void update(QQuickWindow *window); // identical for this implementation.
+ void maybeUpdate(QQuickWindow *window) override;
+ void update(QQuickWindow *window) override; // identical for this implementation.
- void releaseResources(QQuickWindow *) { }
+ void releaseResources(QQuickWindow *) override { }
- QAnimationDriver *animationDriver() const { return 0; }
+ QAnimationDriver *animationDriver() const override { return nullptr; }
- QSGContext *sceneGraphContext() const;
- QSGRenderContext *createRenderContext(QSGContext *) const { return m_renderContext.data(); }
+ QSGContext *sceneGraphContext() const override;
+ QSGRenderContext *createRenderContext(QSGContext *) const override { return m_renderContext.data(); }
static void createOpenGLContext(QQuickWindow *window);
diff --git a/src/quick/doc/snippets/qml/localstorage/dbtransaction.js b/src/quick/doc/snippets/qml/localstorage/dbtransaction.js
index 07d8a5618b..40eb6d2804 100644
--- a/src/quick/doc/snippets/qml/localstorage/dbtransaction.js
+++ b/src/quick/doc/snippets/qml/localstorage/dbtransaction.js
@@ -39,30 +39,47 @@
****************************************************************************/
//![0]
+var db = LocalStorage.openDatabaseSync("ActivityTrackDB", "", "Database tracking sports activities", 1000000);
db.transaction(
try {
function(tx) {
- tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
+ tx.executeSql('INSERT INTO trip_log VALUES(?, ?, ?)',
+ [ '01/10/2016','Sylling - Vikersund', '53' ]);
}
} catch (err) {
- console.log("Error inserting into table Greeting");
+ console.log("Error inserting into table Greeting: " + err);
}
)
//![0]
//![1]
+// Retrieve activity date, description and distance based on minimum
+// distance parameter Pdistance
+function db_distance_select(Pdistance)
+{
+var db = LocalStorage.openDatabaseSync("ActivityTrackDB", "", "Database tracking sports activities", 1000000);
db.transaction(
function(tx) {
- var results = tx.executeSql('SELECT salutation FROM Greeting WHERE salutee=?;', 'world');
+ var results = tx.executeSql('SELECT rowid,
+ date,
+ trip_desc,
+ distance FROM trip_log
+ where distance >= ?',[Pdistance]');
+ for (var i = 0; i < results.rows.length; i++) {
+ listModel.append({"id": results.rows.item(i).rowid,
+ "date": results.rows.item(i).date,
+ "trip_desc": results.rows.item(i).trip_desc,
+ "distance": results.rows.item(i).distance});
+ }
}
- console.log("We greeted in this most respectful way: " + results.rows.item(0).value);
-)
+}
//![1]
//![2]
-var db = LocalStorage.openDatabaseSync("QQmlExampleDB", "", "The Example QML SQL!", 1000000);
+var db = LocalStorage.openDatabaseSync("ActivityTrackDB", "", "Database tracking sports activities", 1000000);
if (db.version == '0.1') {
db.changeVersion('0.1', '0.2', function(tx) {
- tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
+ tx.executeSql('INSERT INTO trip_log VALUES(?, ?, ?)',
+ [ '01/10/2016','Sylling - Vikersund', '53' ]);
}
});
//![2]
diff --git a/src/quick/doc/src/concepts/input/focus.qdoc b/src/quick/doc/src/concepts/input/focus.qdoc
index ec4e4ca2d9..fc1361f7ac 100644
--- a/src/quick/doc/src/concepts/input/focus.qdoc
+++ b/src/quick/doc/src/concepts/input/focus.qdoc
@@ -66,7 +66,7 @@ See also the \l {Keys}{Keys attached property} and \l {KeyNavigation}{KeyNavigat
\section1 Querying the Active Focus Item
Whether or not an \l Item has active focus can be queried through the
-property \c {Item::activeFocus} property. For example, here we have a \l Text
+\c {Item::activeFocus} property. For example, here we have a \l Text
type whose text is determined by whether or not it has active focus.
\snippet qml/focus/rectangle.qml active focus
@@ -98,17 +98,17 @@ The code that imports and creates two MyWidget instances:
The MyWidget code:
\snippet qml/focus/MyWidget.qml mywidget
-We would like to have the first MyWidget object to have the focus by setting its
+We want the first \c MyWidget object to have the focus, so we set its
\c focus property to \c true. However, by running the code, we can confirm that
the second widget receives the focus.
\image declarative-qmlfocus2.png
Looking at both \c MyWidget and \c window code, the problem is evident - there
-are three types that set the \c focus property set to \c true. The two
-MyWidget sets the \c focus to \c true and the \c window component also sets the
+are three types that set the \c focus property to \c true. The two
+\c {MyWidget}s set the \c focus to \c true and the \c window component also sets the
focus. Ultimately, only one type can have keyboard focus, and the system has
-to decide which type receives the focus. When the second MyWidget is created,
+to decide which type receives the focus. When the second \c MyWidget is created,
it receives the focus because it is the last type to set its \c focus
property to \c true.
@@ -190,7 +190,7 @@ print the name of the current list item.
\image declarative-qmlfocus5.png
-While the example is simple, there are a lot going on behind the scenes. Whenever
+While the example is simple, there is a lot going on behind the scenes. Whenever
the current item changes, the \l ListView sets the delegate's \c {Item::focus}
property. As the \l ListView is a focus scope, this doesn't affect the
rest of the application. However, if the \l ListView itself has
diff --git a/src/quick/doc/src/includes/layout.qdocinc b/src/quick/doc/src/includes/layout.qdocinc
new file mode 100644
index 0000000000..723fbc515a
--- /dev/null
+++ b/src/quick/doc/src/includes/layout.qdocinc
@@ -0,0 +1,18 @@
+//! [attached-properties]
+
+\li \l{Layout::minimumWidth}{Layout.minimumWidth}
+\li \l{Layout::minimumHeight}{Layout.minimumHeight}
+\li \l{Layout::preferredWidth}{Layout.preferredWidth}
+\li \l{Layout::preferredHeight}{Layout.preferredHeight}
+\li \l{Layout::maximumWidth}{Layout.maximumWidth}
+\li \l{Layout::maximumHeight}{Layout.maximumHeight}
+\li \l{Layout::fillWidth}{Layout.fillWidth}
+\li \l{Layout::fillHeight}{Layout.fillHeight}
+\li \l{Layout::alignment}{Layout.alignment}
+\li \l{Layout::margins}{Layout.margins}
+\li \l{Layout::topMargin}{Layout.leftMargin}
+\li \l{Layout::rightMargin}{Layout.rightMargin}
+\li \l{Layout::topMargin}{Layout.topMargin}
+\li \l{Layout::bottomMargin}{Layout.bottomMargin}
+
+//! [attached-properties]
diff --git a/src/quick/items/context2d/qquickcanvascontext_p.h b/src/quick/items/context2d/qquickcanvascontext_p.h
index 4f71770e1a..0746b7dcd3 100644
--- a/src/quick/items/context2d/qquickcanvascontext_p.h
+++ b/src/quick/items/context2d/qquickcanvascontext_p.h
@@ -51,10 +51,13 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_canvas);
+
#include <QtQuick/qquickitem.h>
#include <private/qv8engine_p.h>
-
QT_BEGIN_NAMESPACE
class QQuickCanvasItem;
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp
index 3b2b125c63..dcad719ef0 100644
--- a/src/quick/items/context2d/qquickcanvasitem.cpp
+++ b/src/quick/items/context2d/qquickcanvasitem.cpp
@@ -1095,6 +1095,27 @@ QImage QQuickCanvasItem::toImage(const QRectF& rect) const
return QImage();
}
+static const char* mimeToType(const QString &mime)
+{
+ const QLatin1String imagePrefix("image/");
+ if (!mime.startsWith(imagePrefix))
+ return nullptr;
+ const QStringRef mimeExt = mime.midRef(imagePrefix.size());
+ if (mimeExt == QLatin1String("png"))
+ return "png";
+ else if (mimeExt == QLatin1String("bmp"))
+ return "bmp";
+ else if (mimeExt == QLatin1String("jpeg"))
+ return "jpeg";
+ else if (mimeExt == QLatin1String("x-portable-pixmap"))
+ return "ppm";
+ else if (mimeExt == QLatin1String("tiff"))
+ return "tiff";
+ else if (mimeExt == QLatin1String("xpm"))
+ return "xpm";
+ return nullptr;
+}
+
/*!
\qmlmethod string QtQuick::Canvas::toDataURL(string mimeType)
@@ -1112,27 +1133,14 @@ QString QQuickCanvasItem::toDataURL(const QString& mimeType) const
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
- QString mime = mimeType.toLower();
- QString type;
- if (mime == QLatin1String("image/png")) {
- type = QStringLiteral("PNG");
- } else if (mime == QLatin1String("image/bmp"))
- type = QStringLiteral("BMP");
- else if (mime == QLatin1String("image/jpeg"))
- type = QStringLiteral("JPEG");
- else if (mime == QLatin1String("image/x-portable-pixmap"))
- type = QStringLiteral("PPM");
- else if (mime == QLatin1String("image/tiff"))
- type = QStringLiteral("TIFF");
- else if (mime == QLatin1String("image/xpm"))
- type = QStringLiteral("XPM");
- else
+ const QString mime = mimeType.toLower();
+ const char* type = mimeToType(mime);
+ if (!type)
return QStringLiteral("data:,");
- image.save(&buffer, type.toLatin1());
+ image.save(&buffer, type);
buffer.close();
- QString dataUrl = QStringLiteral("data:%1;base64,%2");
- return dataUrl.arg(mime).arg(QLatin1String(ba.toBase64().constData()));
+ return QLatin1String("data:") + mime + QLatin1String(";base64,") + QLatin1String(ba.toBase64().constData());
}
return QStringLiteral("data:,");
}
diff --git a/src/quick/items/context2d/qquickcanvasitem_p.h b/src/quick/items/context2d/qquickcanvasitem_p.h
index 4f94393a45..8af84d0e7c 100644
--- a/src/quick/items/context2d/qquickcanvasitem_p.h
+++ b/src/quick/items/context2d/qquickcanvasitem_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_canvas);
+
#include <QtQuick/qquickitem.h>
#include <private/qv8engine_p.h>
#include <private/qqmlrefcount_p.h>
@@ -191,7 +195,7 @@ private:
Q_INVOKABLE void delayedCreate();
bool createContext(const QString &contextType);
void initializeContext(QQuickCanvasContext *context, const QVariantMap &args = QVariantMap());
- QRect tiledRect(const QRectF &window, const QSize &tileSize);
+ static QRect tiledRect(const QRectF &window, const QSize &tileSize);
bool isPaintConnected();
};
diff --git a/src/quick/items/context2d/qquickcontext2d_p.h b/src/quick/items/context2d/qquickcontext2d_p.h
index b526c8320d..334bf08329 100644
--- a/src/quick/items/context2d/qquickcontext2d_p.h
+++ b/src/quick/items/context2d/qquickcontext2d_p.h
@@ -51,7 +51,10 @@
// We mean it.
//
-#include <QtQuick/qtquickglobal.h>
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_canvas);
+
#include <QtQml/qqml.h>
#include <QtQml/qqmlcomponent.h>
#include <private/qquickcanvascontext_p.h>
@@ -181,17 +184,17 @@ public:
QQuickContext2D(QObject *parent = 0);
~QQuickContext2D();
- QStringList contextNames() const;
- void init(QQuickCanvasItem *canvasItem, const QVariantMap &args);
- void prepare(const QSize& canvasSize, const QSize& tileSize, const QRect& canvasWindow, const QRect& dirtyRect, bool smooth, bool antialiasing);
- void flush();
+ QStringList contextNames() const override;
+ void init(QQuickCanvasItem *canvasItem, const QVariantMap &args) override;
+ void prepare(const QSize& canvasSize, const QSize& tileSize, const QRect& canvasWindow, const QRect& dirtyRect, bool smooth, bool antialiasing) override;
+ void flush() override;
void sync();
QThread *thread() const { return m_thread; }
QQuickContext2DTexture *texture() const;
- QImage toImage(const QRectF& bounds);
+ QImage toImage(const QRectF& bounds) override;
- QV4::ReturnedValue v4value() const;
- void setV4Engine(QV4::ExecutionEngine *eng);
+ QV4::ReturnedValue v4value() const override;
+ void setV4Engine(QV4::ExecutionEngine *eng) override;
QQuickCanvasItem* canvas() const { return m_canvas; }
QQuickContext2DCommandBuffer* buffer() const { return m_buffer; }
@@ -240,8 +243,8 @@ public:
QPainterPath createTextGlyphs(qreal x, qreal y, const QString& text);
QQmlRefPointer<QQuickCanvasPixmap> createPixmap(const QUrl& url);
- QOpenGLContext *glContext() { return m_glContext; }
- QSurface *surface() { return m_surface.data(); }
+ QOpenGLContext *glContext() const { return m_glContext; }
+ QSurface *surface() const { return m_surface.data(); }
void setGrabbedImage(const QImage& grab);
State state;
diff --git a/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h b/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h
index f281cec2d5..2a1ac7304e 100644
--- a/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h
+++ b/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_canvas);
+
#include <QtCore/qmutex.h>
#include "qquickcontext2d_p.h"
@@ -67,7 +71,7 @@ public:
void reset();
void clear();
- inline int size() {return commands.size();}
+ inline int size() const { return commands.size(); }
inline bool isEmpty() const {return commands.isEmpty(); }
inline bool hasNext() const {return cmdIdx < commands.size(); }
inline QQuickContext2D::PaintCommand takeNextCommand() { return commands.at(cmdIdx++); }
@@ -245,7 +249,7 @@ public:
void replay(QPainter* painter, QQuickContext2D::State& state, const QVector2D &scaleFactor);
private:
- QPen makePen(const QQuickContext2D::State& state);
+ static QPen makePen(const QQuickContext2D::State& state);
void setPainterState(QPainter* painter, const QQuickContext2D::State& state, const QPen& pen);
int cmdIdx;
int intIdx;
diff --git a/src/quick/items/context2d/qquickcontext2dtexture.cpp b/src/quick/items/context2d/qquickcontext2dtexture.cpp
index ddecf7c3d4..4435c0c37b 100644
--- a/src/quick/items/context2d/qquickcontext2dtexture.cpp
+++ b/src/quick/items/context2d/qquickcontext2dtexture.cpp
@@ -548,6 +548,9 @@ QPaintDevice* QQuickContext2DFBOTexture::beginPainting()
{
QQuickContext2DTexture::beginPainting();
+ const qreal devicePixelRatio = (m_item && m_item->window()) ?
+ m_item->window()->effectiveDevicePixelRatio() : qApp->devicePixelRatio();
+
if (m_canvasWindow.size().isEmpty()) {
delete m_fbo;
delete m_multisampledFbo;
@@ -562,7 +565,7 @@ QPaintDevice* QQuickContext2DFBOTexture::beginPainting()
delete m_paint_device;
m_paint_device = 0;
- m_fboSize = npotAdjustedSize(m_canvasWindow.size());
+ m_fboSize = npotAdjustedSize(m_canvasWindow.size() * devicePixelRatio);
m_canvasWindowChanged = false;
if (doMultisampling()) {
@@ -600,6 +603,7 @@ QPaintDevice* QQuickContext2DFBOTexture::beginPainting()
QOpenGLPaintDevice *gl_device = new QOpenGLPaintDevice(m_fbo->size());
gl_device->setPaintFlipped(true);
gl_device->setSize(m_fbo->size());
+ gl_device->setDevicePixelRatio(devicePixelRatio);
m_paint_device = gl_device;
}
@@ -705,8 +709,12 @@ QPaintDevice* QQuickContext2DImageTexture::beginPainting()
if (m_canvasWindow.size().isEmpty())
return 0;
+ const qreal devicePixelRatio = (m_item && m_item->window()) ?
+ m_item->window()->effectiveDevicePixelRatio() : qApp->devicePixelRatio();
+
if (m_canvasWindowChanged) {
- m_image = QImage(m_canvasWindow.size(), QImage::Format_ARGB32_Premultiplied);
+ m_image = QImage(m_canvasWindow.size() * devicePixelRatio, QImage::Format_ARGB32_Premultiplied);
+ m_image.setDevicePixelRatio(devicePixelRatio);
m_image.fill(0x00000000);
m_canvasWindowChanged = false;
}
diff --git a/src/quick/items/context2d/qquickcontext2dtexture_p.h b/src/quick/items/context2d/qquickcontext2dtexture_p.h
index ed38382892..678e33826d 100644
--- a/src/quick/items/context2d/qquickcontext2dtexture_p.h
+++ b/src/quick/items/context2d/qquickcontext2dtexture_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_canvas);
+
#include <QtQuick/qsgtexture.h>
#include "qquickcanvasitem_p.h"
#include "qquickcontext2d_p.h"
@@ -120,7 +124,7 @@ public:
// Called during sync() on the scene graph thread while GUI is blocked.
virtual QSGTexture *textureForNextFrame(QSGTexture *lastFrame, QQuickWindow *window) = 0;
- bool event(QEvent *e);
+ bool event(QEvent *e) override;
#ifndef QT_NO_OPENGL
void initializeOpenGL(QOpenGLContext *gl, QOffscreenSurface *s) {
m_gl = gl;
@@ -221,17 +225,17 @@ public:
QQuickContext2DImageTexture();
~QQuickContext2DImageTexture();
- virtual QQuickCanvasItem::RenderTarget renderTarget() const;
+ QQuickCanvasItem::RenderTarget renderTarget() const override;
- virtual QQuickContext2DTile* createTile() const;
- virtual QPaintDevice* beginPainting();
- virtual void endPainting();
- virtual void compositeTile(QQuickContext2DTile* tile);
+ QQuickContext2DTile* createTile() const override;
+ QPaintDevice* beginPainting() override;
+ void endPainting() override;
+ void compositeTile(QQuickContext2DTile* tile) override;
- virtual QSGTexture *textureForNextFrame(QSGTexture *lastFrame, QQuickWindow *window);
+ QSGTexture *textureForNextFrame(QSGTexture *lastFrame, QQuickWindow *window) override;
public Q_SLOTS:
- virtual void grabImage(const QRectF& region = QRectF());
+ void grabImage(const QRectF& region = QRectF()) override;
private:
QImage m_image;
diff --git a/src/quick/items/context2d/qquickcontext2dtile_p.h b/src/quick/items/context2d/qquickcontext2dtile_p.h
index a87202daae..02238a882b 100644
--- a/src/quick/items/context2d/qquickcontext2dtile_p.h
+++ b/src/quick/items/context2d/qquickcontext2dtile_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_canvas);
+
#include "qquickcontext2d_p.h"
#ifndef QT_NO_OPENGL
# include <QOpenGLFramebufferObject>
@@ -89,12 +93,12 @@ class QQuickContext2DFBOTile : public QQuickContext2DTile
public:
QQuickContext2DFBOTile();
~QQuickContext2DFBOTile();
- virtual void setRect(const QRect& r);
+ virtual void setRect(const QRect& r) override;
QOpenGLFramebufferObject* fbo() const {return m_fbo;}
- void drawFinished();
+ void drawFinished() override;
protected:
- void aboutToDraw();
+ void aboutToDraw() override;
private:
@@ -106,7 +110,7 @@ class QQuickContext2DImageTile : public QQuickContext2DTile
public:
QQuickContext2DImageTile();
~QQuickContext2DImageTile();
- void setRect(const QRect& r);
+ void setRect(const QRect& r) override;
const QImage& image() const {return m_image;}
private:
QImage m_image;
diff --git a/src/quick/items/items.pri b/src/quick/items/items.pri
index d91705451e..0f8061b5ef 100644
--- a/src/quick/items/items.pri
+++ b/src/quick/items/items.pri
@@ -41,19 +41,10 @@ HEADERS += \
$$PWD/qquickflickable_p.h \
$$PWD/qquickflickable_p_p.h \
$$PWD/qquickflickablebehavior_p.h \
- $$PWD/qquicklistview_p.h \
$$PWD/qquickrepeater_p.h \
$$PWD/qquickrepeater_p_p.h \
- $$PWD/qquickgridview_p.h \
- $$PWD/qquickpathview_p.h \
- $$PWD/qquickpathview_p_p.h \
- $$PWD/qquickpositioners_p.h \
- $$PWD/qquickpositioners_p_p.h \
$$PWD/qquickloader_p.h \
$$PWD/qquickloader_p_p.h \
- $$PWD/qquickanimatedimage_p.h \
- $$PWD/qquickanimatedimage_p_p.h \
- $$PWD/qquickflipable_p.h \
$$PWD/qquicktranslate_p.h \
$$PWD/qquickclipnode_p.h \
$$PWD/qquickview.h \
@@ -66,26 +57,13 @@ HEADERS += \
$$PWD/qquickdrag_p.h \
$$PWD/qquickdroparea_p.h \
$$PWD/qquickmultipointtoucharea_p.h \
- $$PWD/qquickitemview_p.h \
- $$PWD/qquickitemview_p_p.h \
- $$PWD/qquickitemviewtransition_p.h \
$$PWD/qquickscreen_p.h \
$$PWD/qquickwindowattached_p.h \
$$PWD/qquickwindowmodule_p.h \
- $$PWD/qquickshadereffectsource_p.h \
- $$PWD/qquickshadereffectmesh_p.h \
- $$PWD/qquickshadereffect_p.h \
- $$PWD/qquickgenericshadereffect_p.h \
$$PWD/qquickrendercontrol.h \
$$PWD/qquickrendercontrol_p.h \
$$PWD/qquickgraphicsinfo_p.h \
- $$PWD/qquickitemgrabresult.h \
- $$PWD/qquickspriteengine_p.h \
- $$PWD/qquicksprite_p.h \
- $$PWD/qquickspritesequence_p.h \
- $$PWD/qquickanimatedsprite_p.h \
- $$PWD/qquickanimatedsprite_p_p.h \
- $$PWD/qquickspritesequence_p_p.h
+ $$PWD/qquickitemgrabresult.h
SOURCES += \
$$PWD/qquickevents.cpp \
@@ -111,14 +89,8 @@ SOURCES += \
$$PWD/qquickmousearea.cpp \
$$PWD/qquickpincharea.cpp \
$$PWD/qquickflickable.cpp \
- $$PWD/qquicklistview.cpp \
$$PWD/qquickrepeater.cpp \
- $$PWD/qquickgridview.cpp \
- $$PWD/qquickpathview.cpp \
- $$PWD/qquickpositioners.cpp \
$$PWD/qquickloader.cpp \
- $$PWD/qquickanimatedimage.cpp \
- $$PWD/qquickflipable.cpp \
$$PWD/qquicktranslate.cpp \
$$PWD/qquickclipnode.cpp \
$$PWD/qquickview.cpp \
@@ -129,49 +101,133 @@ SOURCES += \
$$PWD/qquickdrag.cpp \
$$PWD/qquickdroparea.cpp \
$$PWD/qquickmultipointtoucharea.cpp \
- $$PWD/qquickitemview.cpp \
- $$PWD/qquickitemviewtransition.cpp \
$$PWD/qquickwindowmodule.cpp \
$$PWD/qquickscreen.cpp \
$$PWD/qquickwindowattached.cpp \
- $$PWD/qquickshadereffectsource.cpp \
- $$PWD/qquickshadereffectmesh.cpp \
- $$PWD/qquickshadereffect.cpp \
- $$PWD/qquickgenericshadereffect.cpp \
$$PWD/qquickrendercontrol.cpp \
$$PWD/qquickgraphicsinfo.cpp \
- $$PWD/qquickitemgrabresult.cpp \
- $$PWD/qquickspriteengine.cpp \
- $$PWD/qquicksprite.cpp \
- $$PWD/qquickspritesequence.cpp \
- $$PWD/qquickanimatedsprite.cpp
+ $$PWD/qquickitemgrabresult.cpp
+
+qtConfig(quick-animatedimage) {
+ HEADERS += \
+ $$PWD/qquickanimatedimage_p.h \
+ $$PWD/qquickanimatedimage_p_p.h
+ SOURCES += \
+ $$PWD/qquickanimatedimage.cpp
+}
+
+qtConfig(quick-gridview) {
+ HEADERS += \
+ $$PWD/qquickgridview_p.h
+ SOURCES += \
+ $$PWD/qquickgridview.cpp
+}
+
+qtConfig(quick-itemview) {
+ HEADERS += \
+ $$PWD/qquickitemview_p.h \
+ $$PWD/qquickitemview_p_p.h
+ SOURCES += \
+ $$PWD/qquickitemview.cpp
+}
+
+qtConfig(quick-viewtransitions) {
+ HEADERS += \
+ $$PWD/qquickitemviewtransition_p.h
+ SOURCES += \
+ $$PWD/qquickitemviewtransition.cpp
+}
+
+qtConfig(quick-listview) {
+ HEADERS += \
+ $$PWD/qquicklistview_p.h
+ SOURCES += \
+ $$PWD/qquicklistview.cpp
+}
+
+qtConfig(quick-pathview) {
+ HEADERS += \
+ $$PWD/qquickpathview_p.h \
+ $$PWD/qquickpathview_p_p.h
+ SOURCES += \
+ $$PWD/qquickpathview.cpp
+}
+
+qtConfig(quick-positioners) {
+ HEADERS += \
+ $$PWD/qquickpositioners_p.h \
+ $$PWD/qquickpositioners_p_p.h
+ SOURCES += \
+ $$PWD/qquickpositioners.cpp
+}
+
+qtConfig(quick-flipable) {
+ HEADERS += \
+ $$PWD/qquickflipable_p.h
+ SOURCES += \
+ $$PWD/qquickflipable.cpp
+}
+
+qtConfig(quick-shadereffect) {
+ HEADERS += \
+ $$PWD/qquickshadereffectsource_p.h \
+ $$PWD/qquickshadereffectmesh_p.h \
+ $$PWD/qquickshadereffect_p.h \
+ $$PWD/qquickgenericshadereffect_p.h
+ SOURCES += \
+ $$PWD/qquickshadereffectsource.cpp \
+ $$PWD/qquickshadereffectmesh.cpp \
+ $$PWD/qquickshadereffect.cpp \
+ $$PWD/qquickgenericshadereffect.cpp
+
+ qtConfig(opengl) {
+ SOURCES += \
+ $$PWD/qquickopenglshadereffect.cpp \
+ $$PWD/qquickopenglshadereffectnode.cpp
+ HEADERS += \
+ $$PWD/qquickopenglshadereffect_p.h \
+ $$PWD/qquickopenglshadereffectnode_p.h
+
+ OTHER_FILES += \
+ $$PWD/shaders/shadereffect.vert \
+ $$PWD/shaders/shadereffect.frag \
+ $$PWD/shaders/shadereffectfallback.vert \
+ $$PWD/shaders/shadereffectfallback.frag \
+ $$PWD/shaders/shadereffect_core.vert \
+ $$PWD/shaders/shadereffect_core.frag \
+ $$PWD/shaders/shadereffectfallback_core.vert \
+ $$PWD/shaders/shadereffectfallback_core.frag
+ }
+}
+
+qtConfig(quick-sprite) {
+ HEADERS += \
+ $$PWD/qquickspriteengine_p.h \
+ $$PWD/qquicksprite_p.h \
+ $$PWD/qquickspritesequence_p.h \
+ $$PWD/qquickanimatedsprite_p.h \
+ $$PWD/qquickanimatedsprite_p_p.h \
+ $$PWD/qquickspritesequence_p_p.h
+ SOURCES += \
+ $$PWD/qquickspriteengine.cpp \
+ $$PWD/qquicksprite.cpp \
+ $$PWD/qquickspritesequence.cpp \
+ $$PWD/qquickanimatedsprite.cpp
+}
# Items that depend on OpenGL Renderer
qtConfig(opengl(es1|es2)?) {
SOURCES += \
$$PWD/qquickopenglinfo.cpp \
- $$PWD/qquickopenglshadereffect.cpp \
- $$PWD/qquickopenglshadereffectnode.cpp \
$$PWD/qquickframebufferobject.cpp
HEADERS += \
$$PWD/qquickopenglinfo_p.h \
- $$PWD/qquickopenglshadereffect_p.h \
- $$PWD/qquickopenglshadereffectnode_p.h \
$$PWD/qquickframebufferobject.h
-
- OTHER_FILES += \
- $$PWD/shaders/shadereffect.vert \
- $$PWD/shaders/shadereffect.frag \
- $$PWD/shaders/shadereffectfallback.vert \
- $$PWD/shaders/shadereffectfallback.frag \
- $$PWD/shaders/shadereffect_core.vert \
- $$PWD/shaders/shadereffect_core.frag \
- $$PWD/shaders/shadereffectfallback_core.vert \
- $$PWD/shaders/shadereffectfallback_core.frag
}
RESOURCES += \
$$PWD/items.qrc
-include(context2d/context2d.pri)
+qtConfig(quick-canvas): \
+ include(context2d/context2d.pri)
diff --git a/src/quick/items/qquickaccessibleattached_p.h b/src/quick/items/qquickaccessibleattached_p.h
index 2c209ae664..7054d9d9c9 100644
--- a/src/quick/items/qquickaccessibleattached_p.h
+++ b/src/quick/items/qquickaccessibleattached_p.h
@@ -203,7 +203,7 @@ public:
return object;
}
- QAccessible::State state() { return m_state; }
+ QAccessible::State state() const { return m_state; }
bool ignored() const;
bool doAction(const QString &actionName);
void availableActions(QStringList *actions) const;
diff --git a/src/quick/items/qquickanchors.cpp b/src/quick/items/qquickanchors.cpp
index b6978e534e..a7a4a2b882 100644
--- a/src/quick/items/qquickanchors.cpp
+++ b/src/quick/items/qquickanchors.cpp
@@ -285,7 +285,7 @@ void QQuickAnchorsPrivate::clearItem(QQuickItem *item)
}
}
-QQuickGeometryChange QQuickAnchorsPrivate::calculateDependency(QQuickItem *controlItem)
+QQuickGeometryChange QQuickAnchorsPrivate::calculateDependency(QQuickItem *controlItem) const
{
QQuickGeometryChange dependency;
@@ -588,7 +588,7 @@ bool QQuickAnchorsPrivate::calcStretch(QQuickItem *edge1Item,
qreal offset1,
qreal offset2,
QQuickAnchors::Anchor line,
- qreal &stretch)
+ qreal &stretch) const
{
bool edge1IsParent = (edge1Item == readParentItem(item));
bool edge2IsParent = (edge2Item == readParentItem(item));
diff --git a/src/quick/items/qquickanchors_p_p.h b/src/quick/items/qquickanchors_p_p.h
index 3357e134bf..221b4ccb40 100644
--- a/src/quick/items/qquickanchors_p_p.h
+++ b/src/quick/items/qquickanchors_p_p.h
@@ -124,7 +124,7 @@ public:
void clearItem(QQuickItem *);
- QQuickGeometryChange calculateDependency(QQuickItem *);
+ QQuickGeometryChange calculateDependency(QQuickItem *) const;
void addDepend(QQuickItem *);
void remDepend(QQuickItem *);
bool isItemComplete() const;
@@ -150,7 +150,7 @@ public:
bool checkVAnchorValid(QQuickAnchorLine anchor) const;
bool calcStretch(QQuickItem *edge1Item, QQuickAnchors::Anchor edge1Line,
QQuickItem *edge2Item, QQuickAnchors::Anchor edge2Line,
- qreal offset1, qreal offset2, QQuickAnchors::Anchor line, qreal &stretch);
+ qreal offset1, qreal offset2, QQuickAnchors::Anchor line, qreal &stretch) const;
bool isMirrored() const;
void updateHorizontalAnchors();
diff --git a/src/quick/items/qquickanimatedimage.cpp b/src/quick/items/qquickanimatedimage.cpp
index 6f14bf15fe..81c649dbd5 100644
--- a/src/quick/items/qquickanimatedimage.cpp
+++ b/src/quick/items/qquickanimatedimage.cpp
@@ -40,14 +40,12 @@
#include "qquickanimatedimage_p.h"
#include "qquickanimatedimage_p_p.h"
-#ifndef QT_NO_MOVIE
-
#include <QtGui/qguiapplication.h>
#include <QtQml/qqmlinfo.h>
#include <QtQml/qqmlfile.h>
#include <QtQml/qqmlengine.h>
#include <QtGui/qmovie.h>
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
#include <QtNetwork/qnetworkrequest.h>
#include <QtNetwork/qnetworkreply.h>
#endif
@@ -146,7 +144,7 @@ QQuickAnimatedImage::QQuickAnimatedImage(QQuickItem *parent)
QQuickAnimatedImage::~QQuickAnimatedImage()
{
Q_D(QQuickAnimatedImage);
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
if (d->reply)
d->reply->deleteLater();
#endif
@@ -268,7 +266,7 @@ void QQuickAnimatedImage::setSource(const QUrl &url)
if (url == d->url)
return;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
if (d->reply) {
d->reply->deleteLater();
d->reply = 0;
@@ -325,7 +323,7 @@ void QQuickAnimatedImage::load()
d->_movie = new QMovie(lf);
movieRequestFinished();
} else {
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
if (d->status != Loading) {
d->status = Loading;
emit statusChanged(d->status);
@@ -354,7 +352,7 @@ void QQuickAnimatedImage::movieRequestFinished()
Q_D(QQuickAnimatedImage);
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
if (d->reply) {
d->redirectCount++;
if (d->redirectCount < ANIMATEDIMAGE_MAXIMUM_REDIRECT_RECURSION) {
@@ -493,5 +491,3 @@ void QQuickAnimatedImage::componentComplete()
}
QT_END_NAMESPACE
-
-#endif // QT_NO_MOVIE
diff --git a/src/quick/items/qquickanimatedimage_p.h b/src/quick/items/qquickanimatedimage_p.h
index 288a8379da..143fe8904d 100644
--- a/src/quick/items/qquickanimatedimage_p.h
+++ b/src/quick/items/qquickanimatedimage_p.h
@@ -51,9 +51,11 @@
// We mean it.
//
-#include "qquickimage_p.h"
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_animatedimage);
-#ifndef QT_NO_MOVIE
+#include "qquickimage_p.h"
QT_BEGIN_NAMESPACE
@@ -116,6 +118,4 @@ QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickAnimatedImage)
-#endif // QT_NO_MOVIE
-
#endif // QQUICKANIMATEDIMAGE_P_H
diff --git a/src/quick/items/qquickanimatedimage_p_p.h b/src/quick/items/qquickanimatedimage_p_p.h
index ed735d1c9c..9eff6a44e3 100644
--- a/src/quick/items/qquickanimatedimage_p_p.h
+++ b/src/quick/items/qquickanimatedimage_p_p.h
@@ -51,14 +51,16 @@
// We mean it.
//
-#include "qquickimage_p_p.h"
+#include <QtQuick/qtquickglobal.h>
+
+QT_REQUIRE_CONFIG(quick_animatedimage);
-#ifndef QT_NO_MOVIE
+#include "qquickimage_p_p.h"
QT_BEGIN_NAMESPACE
class QMovie;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
class QNetworkReply;
#endif
@@ -69,7 +71,7 @@ class QQuickAnimatedImagePrivate : public QQuickImagePrivate
public:
QQuickAnimatedImagePrivate()
: playing(true), paused(false), preset_currentframe(0), _movie(0), oldPlaying(false)
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
, reply(0), redirectCount(0)
#endif
, currentSourceSize(0, 0)
@@ -83,7 +85,7 @@ public:
int preset_currentframe;
QMovie *_movie;
bool oldPlaying;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QNetworkReply *reply;
int redirectCount;
#endif
@@ -93,6 +95,4 @@ public:
QT_END_NAMESPACE
-#endif // QT_NO_MOVIE
-
#endif // QQUICKANIMATEDIMAGE_P_P_H
diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp
index 991ca8519f..8aeef4ef4a 100644
--- a/src/quick/items/qquickanimatedsprite.cpp
+++ b/src/quick/items/qquickanimatedsprite.cpp
@@ -42,6 +42,7 @@
#include "qquicksprite_p.h"
#include "qquickspriteengine_p.h"
#include <QtQuick/private/qsgcontext_p.h>
+#include <QtQuick/private/qquickitem_p.h>
#include <private/qsgadaptationlayer_p.h>
#include <private/qqmlglobal_p.h>
#include <QtQuick/qsgnode.h>
@@ -349,7 +350,7 @@ void QQuickAnimatedSprite::start()
}
emit currentFrameChanged(0);
emit runningChanged(true);
- update();
+ maybeUpdate();
}
void QQuickAnimatedSprite::stop()
@@ -360,7 +361,7 @@ void QQuickAnimatedSprite::stop()
return;
d->m_pauseOffset = 0;
emit runningChanged(false);
- update();
+ maybeUpdate();
}
/*!
@@ -379,7 +380,15 @@ void QQuickAnimatedSprite::advance(int frames)
d->m_curFrame += d->m_spriteEngine->maxFrames();
d->m_curFrame = d->m_curFrame % d->m_spriteEngine->maxFrames();
emit currentFrameChanged(d->m_curFrame);
- update();
+ maybeUpdate();
+}
+
+void QQuickAnimatedSprite::maybeUpdate()
+{
+ QQuickItemPrivate *priv = QQuickItemPrivate::get(this);
+ const QLazilyAllocated<QQuickItemPrivate::ExtraData> &extraData = priv->extra;
+ if ((extraData.isAllocated() && extraData->effectRefCount > 0) || priv->effectiveVisible)
+ update();
}
/*!
@@ -399,7 +408,7 @@ void QQuickAnimatedSprite::pause()
d->m_pauseOffset = d->m_timestamp.elapsed();
d->m_paused = true;
emit pausedChanged(true);
- update();
+ maybeUpdate();
}
/*!
@@ -419,7 +428,7 @@ void QQuickAnimatedSprite::resume()
d->m_pauseOffset = d->m_pauseOffset - d->m_timestamp.elapsed();
d->m_paused = false;
emit pausedChanged(false);
- update();
+ maybeUpdate();
}
void QQuickAnimatedSprite::setRunning(bool arg)
@@ -610,7 +619,6 @@ void QQuickAnimatedSprite::createEngine()
d->m_spriteEngine = new QQuickSpriteEngine(QList<QQuickSprite*>(spriteList), this);
d->m_spriteEngine->startAssemblingImage();
reset();
- update();
}
QSGSpriteNode* QQuickAnimatedSprite::initNode()
@@ -622,10 +630,10 @@ QSGSpriteNode* QQuickAnimatedSprite::initNode()
return nullptr;
} else if (d->m_spriteEngine->status() == QQuickPixmap::Null) {
d->m_spriteEngine->startAssemblingImage();
- update();//Schedule another update, where we will check again
+ maybeUpdate();//Schedule another update, where we will check again
return nullptr;
} else if (d->m_spriteEngine->status() == QQuickPixmap::Loading) {
- update();//Schedule another update, where we will check again
+ maybeUpdate();//Schedule another update, where we will check again
return nullptr;
}
@@ -651,7 +659,7 @@ void QQuickAnimatedSprite::reset()
{
Q_D(QQuickAnimatedSprite);
d->m_pleaseReset = true;
- update();
+ maybeUpdate();
}
QSGNode *QQuickAnimatedSprite::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
@@ -673,7 +681,7 @@ QSGNode *QQuickAnimatedSprite::updatePaintNode(QSGNode *oldNode, UpdatePaintNode
prepareNextFrame(node);
if (d->m_running && !d->m_paused)
- update();
+ maybeUpdate();
return node;
}
@@ -726,7 +734,7 @@ void QQuickAnimatedSprite::prepareNextFrame(QSGSpriteNode *node)
frameAt = 0;
d->m_running = false;
emit runningChanged(false);
- update();
+ maybeUpdate();
}
} else {
frameAt = d->m_curFrame;
@@ -734,7 +742,7 @@ void QQuickAnimatedSprite::prepareNextFrame(QSGSpriteNode *node)
if (d->m_curFrame != lastFrame) {
if (isCurrentFrameChangedConnected())
emit currentFrameChanged(d->m_curFrame);
- update();
+ maybeUpdate();
}
qreal frameCount = d->m_spriteEngine->spriteFrames();
diff --git a/src/quick/items/qquickanimatedsprite_p.h b/src/quick/items/qquickanimatedsprite_p.h
index cbd6524c40..850461a011 100644
--- a/src/quick/items/qquickanimatedsprite_p.h
+++ b/src/quick/items/qquickanimatedsprite_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_sprite);
+
#include <QtQuick/QQuickItem>
#include <private/qquicksprite_p.h>
#include <QtCore/qelapsedtimer.h>
@@ -168,6 +172,7 @@ protected:
void componentComplete() Q_DECL_OVERRIDE;
QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE;
private:
+ void maybeUpdate();
bool isCurrentFrameChangedConnected();
void prepareNextFrame(QSGSpriteNode *node);
void reloadImage();
diff --git a/src/quick/items/qquickanimatedsprite_p_p.h b/src/quick/items/qquickanimatedsprite_p_p.h
index 0e4a1e9066..3610e58861 100644
--- a/src/quick/items/qquickanimatedsprite_p_p.h
+++ b/src/quick/items/qquickanimatedsprite_p_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <QtQuick/qtquickglobal.h>
+
+QT_REQUIRE_CONFIG(quick_sprite);
+
#include "qquickitem_p.h"
#include "qquicksprite_p.h"
diff --git a/src/quick/items/qquickborderimage.cpp b/src/quick/items/qquickborderimage.cpp
index ca5ad8dbbd..67b99bfbc6 100644
--- a/src/quick/items/qquickborderimage.cpp
+++ b/src/quick/items/qquickborderimage.cpp
@@ -43,7 +43,7 @@
#include <QtQml/qqmlinfo.h>
#include <QtQml/qqmlfile.h>
#include <QtQml/qqmlengine.h>
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
#include <QtNetwork/qnetworkreply.h>
#endif
#include <QtCore/qfile.h>
@@ -51,6 +51,7 @@
#include <QtGui/qguiapplication.h>
#include <private/qqmlglobal_p.h>
+#include <private/qsgadaptationlayer_p.h>
QT_BEGIN_NAMESPACE
@@ -171,7 +172,7 @@ QQuickBorderImage::QQuickBorderImage(QQuickItem *parent)
QQuickBorderImage::~QQuickBorderImage()
{
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
Q_D(QQuickBorderImage);
if (d->sciReply)
d->sciReply->deleteLater();
@@ -274,7 +275,7 @@ void QQuickBorderImage::setSource(const QUrl &url)
if (url == d->url)
return;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
if (d->sciReply) {
d->sciReply->deleteLater();
d->sciReply = 0;
@@ -317,7 +318,7 @@ void QQuickBorderImage::load()
setGridScaledImage(QQuickGridScaledImage(&file));
return;
} else {
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
if (d->progress != 0.0) {
d->progress = 0.0;
emit progressChanged(d->progress);
@@ -537,7 +538,7 @@ void QQuickBorderImage::requestFinished()
pixmapChange();
}
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
#define BORDERIMAGE_MAX_REDIRECT 16
void QQuickBorderImage::sciRequestFinished()
@@ -567,7 +568,7 @@ void QQuickBorderImage::sciRequestFinished()
setGridScaledImage(sci);
}
}
-#endif // QT_NO_NETWORK
+#endif // qml_network
void QQuickBorderImage::doUpdate()
{
diff --git a/src/quick/items/qquickborderimage_p.h b/src/quick/items/qquickborderimage_p.h
index f2764660f6..844f71e2c9 100644
--- a/src/quick/items/qquickborderimage_p.h
+++ b/src/quick/items/qquickborderimage_p.h
@@ -101,7 +101,7 @@ private:
private Q_SLOTS:
void doUpdate();
void requestFinished() Q_DECL_OVERRIDE;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
void sciRequestFinished();
#endif
diff --git a/src/quick/items/qquickborderimage_p_p.h b/src/quick/items/qquickborderimage_p_p.h
index 56fbbab049..0f4e7acc05 100644
--- a/src/quick/items/qquickborderimage_p_p.h
+++ b/src/quick/items/qquickborderimage_p_p.h
@@ -58,7 +58,7 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
class QNetworkReply;
#endif
class QQuickBorderImagePrivate : public QQuickImageBasePrivate
@@ -69,7 +69,7 @@ public:
QQuickBorderImagePrivate()
: border(0), horizontalTileMode(QQuickBorderImage::Stretch),
verticalTileMode(QQuickBorderImage::Stretch), pixmapChanged(false)
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
, sciReply(0), redirectCount(0)
#endif
{
@@ -108,7 +108,7 @@ public:
QQuickBorderImage::TileMode verticalTileMode;
bool pixmapChanged : 1;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QNetworkReply *sciReply;
int redirectCount;
#endif
diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp
index b943c28661..cbb052856e 100644
--- a/src/quick/items/qquickdrag.cpp
+++ b/src/quick/items/qquickdrag.cpp
@@ -749,7 +749,7 @@ void QQuickDragAttached::cancel()
*/
/*!
- \qmlattachedsignal QtQuick::Drag::dragFinished(DropAction action)
+ \qmlattachedsignal QtQuick::Drag::dragFinished(DropAction dropAction)
This signal is emitted when a drag finishes and the drag was started with the
\l startDrag() method or started automatically using the \l dragType property.
diff --git a/src/quick/items/qquickdrag_p.h b/src/quick/items/qquickdrag_p.h
index 17721251d9..f9faca55e0 100644
--- a/src/quick/items/qquickdrag_p.h
+++ b/src/quick/items/qquickdrag_p.h
@@ -290,7 +290,7 @@ public:
Q_INVOKABLE int drop();
- bool event(QEvent *event);
+ bool event(QEvent *event) override;
public Q_SLOTS:
void start(QQmlV4Function *);
diff --git a/src/quick/items/qquickdroparea.cpp b/src/quick/items/qquickdroparea.cpp
index 8dcc13971e..70d76c99a1 100644
--- a/src/quick/items/qquickdroparea.cpp
+++ b/src/quick/items/qquickdroparea.cpp
@@ -513,7 +513,7 @@ void QQuickDropArea::dropEvent(QDropEvent *event)
easily be translated into a QByteArray. \a format should be one contained in the \l formats property.
*/
-QObject *QQuickDropEvent::source()
+QObject *QQuickDropEvent::source() const
{
if (const QQuickDragMimeData *dragMime = qobject_cast<const QQuickDragMimeData *>(event->mimeData()))
return dragMime->source();
diff --git a/src/quick/items/qquickdroparea_p.h b/src/quick/items/qquickdroparea_p.h
index d3b37979da..ecd4da4367 100644
--- a/src/quick/items/qquickdroparea_p.h
+++ b/src/quick/items/qquickdroparea_p.h
@@ -86,7 +86,7 @@ public:
qreal x() const { return event->pos().x(); }
qreal y() const { return event->pos().y(); }
- QObject *source();
+ QObject *source() const;
Qt::DropActions supportedActions() const { return event->possibleActions(); }
Qt::DropActions proposedAction() const { return event->proposedAction(); }
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index 672aadd0e3..1fd9014408 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -1038,7 +1038,7 @@ Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const QQuickEventPoint *eve
dbg << "QQuickEventPoint(valid:" << event->isValid() << " accepted:" << event->isAccepted()
<< " state:";
QtDebugUtils::formatQEnum(dbg, event->state());
- dbg << " scenePos:" << event->scenePos() << " id:" << event->pointId()
+ dbg << " scenePos:" << event->scenePos() << " id:" << hex << event->pointId() << dec
<< " timeHeld:" << event->timeHeld() << ')';
return dbg;
}
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index 6160e1ca1a..ef5ece625e 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -278,7 +278,7 @@ void QQuickFlickablePrivate::init()
Returns the amount to overshoot by given a velocity.
Will be roughly in range 0 - size/4
*/
-qreal QQuickFlickablePrivate::overShootDistance(qreal size)
+qreal QQuickFlickablePrivate::overShootDistance(qreal size) const
{
if (maxVelocity <= 0)
return 0.0;
@@ -875,9 +875,9 @@ bool QQuickFlickable::isAtYBeginning() const
}
\endcode
*/
-QQuickItem *QQuickFlickable::contentItem()
+QQuickItem *QQuickFlickable::contentItem() const
{
- Q_D(QQuickFlickable);
+ Q_D(const QQuickFlickable);
return d->contentItem;
}
@@ -952,7 +952,7 @@ void QQuickFlickable::setPixelAligned(bool align)
}
}
-qint64 QQuickFlickablePrivate::computeCurrentTime(QInputEvent *event)
+qint64 QQuickFlickablePrivate::computeCurrentTime(QInputEvent *event) const
{
if (0 != event->timestamp())
return event->timestamp();
@@ -961,7 +961,7 @@ qint64 QQuickFlickablePrivate::computeCurrentTime(QInputEvent *event)
return timer.elapsed();
}
-qreal QQuickFlickablePrivate::devicePixelRatio()
+qreal QQuickFlickablePrivate::devicePixelRatio() const
{
return (window ? window->effectiveDevicePixelRatio() : qApp->devicePixelRatio());
}
@@ -1557,11 +1557,11 @@ void QQuickFlickablePrivate::replayDelayedPress()
// If we have the grab, release before delivering the event
if (QQuickWindow *w = q->window()) {
+ replayingPressEvent = true;
if (w->mouseGrabberItem() == q)
q->ungrabMouse();
// Use the event handler that will take care of finding the proper item to propagate the event
- replayingPressEvent = true;
QCoreApplication::sendEvent(w, mouseEvent.data());
replayingPressEvent = false;
}
@@ -1591,7 +1591,7 @@ void QQuickFlickable::timerEvent(QTimerEvent *event)
d->movementEndingTimer.stop();
d->pressed = false;
d->stealMouse = false;
- if (!d->velocityTimeline.isActive())
+ if (!d->velocityTimeline.isActive() && !d->timeline.isActive())
movementEnding(true, true);
}
}
@@ -1644,7 +1644,7 @@ void QQuickFlickable::viewportMoved(Qt::Orientations orient)
void QQuickFlickablePrivate::viewportAxisMoved(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
QQuickTimeLineCallback::Callback fixupCallback)
{
- if (pressed || calcVelocity) {
+ if (!scrollingPhase && (pressed || calcVelocity)) {
int elapsed = data.velocityTime.restart();
if (elapsed > 0) {
qreal velocity = (data.lastPos - data.move.value()) * 1000 / elapsed;
@@ -2219,7 +2219,8 @@ void QQuickFlickable::mouseUngrabEvent()
Q_D(QQuickFlickable);
// if our mouse grab has been removed (probably by another Flickable),
// fix our state
- d->cancelInteraction();
+ if (!d->replayingPressEvent)
+ d->cancelInteraction();
}
void QQuickFlickablePrivate::cancelInteraction()
diff --git a/src/quick/items/qquickflickable_p.h b/src/quick/items/qquickflickable_p.h
index 610bfd1427..2da4781f37 100644
--- a/src/quick/items/qquickflickable_p.h
+++ b/src/quick/items/qquickflickable_p.h
@@ -190,7 +190,7 @@ public:
bool isAtYEnd() const;
bool isAtYBeginning() const;
- QQuickItem *contentItem();
+ QQuickItem *contentItem() const;
enum FlickableDirection { AutoFlickDirection=0x0, HorizontalFlick=0x1, VerticalFlick=0x2, HorizontalAndVerticalFlick=0x3,
AutoFlickIfNeeded=0xc };
diff --git a/src/quick/items/qquickflickable_p_p.h b/src/quick/items/qquickflickable_p_p.h
index ac1e39d829..0c3bc21071 100644
--- a/src/quick/items/qquickflickable_p_p.h
+++ b/src/quick/items/qquickflickable_p_p.h
@@ -192,7 +192,7 @@ public:
void setViewportX(qreal x);
void setViewportY(qreal y);
- qreal overShootDistance(qreal size);
+ qreal overShootDistance(qreal size) const;
void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) Q_DECL_OVERRIDE;
@@ -260,8 +260,8 @@ public:
const QVector2D &deltas, bool overThreshold, bool momentum,
bool velocitySensitiveOverBounds, const QVector2D &velocity);
- qint64 computeCurrentTime(QInputEvent *event);
- qreal devicePixelRatio();
+ qint64 computeCurrentTime(QInputEvent *event) const;
+ qreal devicePixelRatio() const;
// flickableData property
static void data_append(QQmlListProperty<QObject> *, QObject *);
diff --git a/src/quick/items/qquickflipable.cpp b/src/quick/items/qquickflipable.cpp
index 342e6c07b8..6a6b6c00a9 100644
--- a/src/quick/items/qquickflipable.cpp
+++ b/src/quick/items/qquickflipable.cpp
@@ -143,7 +143,7 @@ QQuickFlipable::~QQuickFlipable()
The front and back sides of the flipable.
*/
-QQuickItem *QQuickFlipable::front()
+QQuickItem *QQuickFlipable::front() const
{
Q_D(const QQuickFlipable);
return d->front;
diff --git a/src/quick/items/qquickflipable_p.h b/src/quick/items/qquickflipable_p.h
index 189d94775a..a76977d4ac 100644
--- a/src/quick/items/qquickflipable_p.h
+++ b/src/quick/items/qquickflipable_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_flipable);
+
#include "qquickitem.h"
#include <QtGui/qtransform.h>
@@ -73,7 +77,7 @@ public:
QQuickFlipable(QQuickItem *parent=0);
~QQuickFlipable();
- QQuickItem *front();
+ QQuickItem *front() const;
void setFront(QQuickItem *);
QQuickItem *back();
diff --git a/src/quick/items/qquickframebufferobject.cpp b/src/quick/items/qquickframebufferobject.cpp
index 857cd44b15..18a6a58467 100644
--- a/src/quick/items/qquickframebufferobject.cpp
+++ b/src/quick/items/qquickframebufferobject.cpp
@@ -42,6 +42,8 @@
#include <QtGui/QOpenGLFramebufferObject>
#include <QtGui/QOpenGLFunctions>
#include <private/qquickitem_p.h>
+#include <private/qsgadaptationlayer_p.h>
+#include <qsgtextureprovider.h>
#include <QSGSimpleTextureNode>
#include <QSGRendererInterface>
diff --git a/src/quick/items/qquickgenericshadereffect.cpp b/src/quick/items/qquickgenericshadereffect.cpp
index 9714f39663..2f8d71fc11 100644
--- a/src/quick/items/qquickgenericshadereffect.cpp
+++ b/src/quick/items/qquickgenericshadereffect.cpp
@@ -510,9 +510,9 @@ void QQuickGenericShaderEffect::updateShaderVars(Shader shaderType)
QSGShaderEffectNode::VariableData &vd(m_shaders[shaderType].varData[i]);
const bool isSpecial = v.name.startsWith("qt_"); // special names not mapped to properties
if (isSpecial) {
- if (v.name == QByteArrayLiteral("qt_Opacity"))
+ if (v.name == "qt_Opacity")
vd.specialType = QSGShaderEffectNode::VariableData::Opacity;
- else if (v.name == QByteArrayLiteral("qt_Matrix"))
+ else if (v.name == "qt_Matrix")
vd.specialType = QSGShaderEffectNode::VariableData::Matrix;
else if (v.name.startsWith("qt_SubRect_"))
vd.specialType = QSGShaderEffectNode::VariableData::SubRect;
diff --git a/src/quick/items/qquickgridview_p.h b/src/quick/items/qquickgridview_p.h
index 44bc8444f2..aaf6e4a75b 100644
--- a/src/quick/items/qquickgridview_p.h
+++ b/src/quick/items/qquickgridview_p.h
@@ -51,8 +51,11 @@
// We mean it.
//
-#include "qquickitemview_p.h"
+#include <QtQuick/private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_gridview);
+#include "qquickitemview_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/quick/items/qquickimage.cpp b/src/quick/items/qquickimage.cpp
index e36c070248..f71a2fbdbd 100644
--- a/src/quick/items/qquickimage.cpp
+++ b/src/quick/items/qquickimage.cpp
@@ -69,7 +69,7 @@ public:
emit textureChanged();
}
- QSGTexture *texture() const {
+ QSGTexture *texture() const override {
if (m_texture) {
m_texture->setFiltering(m_smooth ? QSGTexture::Linear : QSGTexture::Nearest);
m_texture->setMipmapFiltering(m_mipmap ? QSGTexture::Linear : QSGTexture::None);
@@ -304,6 +304,15 @@ void QQuickImage::setFillMode(FillMode mode)
if (d->fillMode == mode)
return;
d->fillMode = mode;
+ if ((mode == PreserveAspectCrop) != d->providerOptions.preserveAspectRatioCrop()) {
+ d->providerOptions.setPreserveAspectRatioCrop(mode == PreserveAspectCrop);
+ if (isComponentComplete())
+ load();
+ } else if ((mode == PreserveAspectFit) != d->providerOptions.preserveAspectRatioFit()) {
+ d->providerOptions.setPreserveAspectRatioFit(mode == PreserveAspectFit);
+ if (isComponentComplete())
+ load();
+ }
update();
updatePaintedGeometry();
emit fillModeChanged();
@@ -423,7 +432,9 @@ qreal QQuickImage::paintedHeight() const
(The \l fillMode is independent of this.)
If both the sourceSize.width and sourceSize.height are set the image will be scaled
- down to fit within the specified size, maintaining the image's aspect ratio. The actual
+ 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
size of the image after scaling is available via \l Item::implicitWidth and \l Item::implicitHeight.
If the source is an intrinsically scalable image (eg. SVG), this property
diff --git a/src/quick/items/qquickimagebase.cpp b/src/quick/items/qquickimagebase.cpp
index a2b99b6395..a6bf6b4e8a 100644
--- a/src/quick/items/qquickimagebase.cpp
+++ b/src/quick/items/qquickimagebase.cpp
@@ -246,7 +246,7 @@ void QQuickImageBase::load()
resolve2xLocalFile(d->url, targetDevicePixelRatio, &loadUrl, &d->devicePixelRatio);
}
- d->pix.load(qmlEngine(this), loadUrl, d->sourcesize * d->devicePixelRatio, options, d->autoTransform);
+ d->pix.load(qmlEngine(this), loadUrl, d->sourcesize * d->devicePixelRatio, options, d->providerOptions);
if (d->pix.isLoading()) {
if (d->progress != 0.0) {
@@ -381,17 +381,18 @@ void QQuickImageBase::resolve2xLocalFile(const QUrl &url, qreal targetDevicePixe
bool QQuickImageBase::autoTransform() const
{
Q_D(const QQuickImageBase);
- if (d->autoTransform == UsePluginDefault)
- return d->pix.autoTransform() == ApplyTransform;
- return d->autoTransform == ApplyTransform;
+ if (d->providerOptions.autoTransform() == QQuickImageProviderOptions::UsePluginDefaultTransform)
+ return d->pix.autoTransform() == QQuickImageProviderOptions::ApplyTransform;
+ return d->providerOptions.autoTransform() == QQuickImageProviderOptions::ApplyTransform;
}
void QQuickImageBase::setAutoTransform(bool transform)
{
Q_D(QQuickImageBase);
- if (d->autoTransform != UsePluginDefault && transform == (d->autoTransform == ApplyTransform))
+ if (d->providerOptions.autoTransform() != QQuickImageProviderOptions::UsePluginDefaultTransform &&
+ transform == (d->providerOptions.autoTransform() == QQuickImageProviderOptions::ApplyTransform))
return;
- d->autoTransform = transform ? ApplyTransform : DoNotApplyTransform;
+ d->providerOptions.setAutoTransform(transform ? QQuickImageProviderOptions::ApplyTransform : QQuickImageProviderOptions::DoNotApplyTransform);
emitAutoTransformBaseChanged();
}
diff --git a/src/quick/items/qquickimagebase_p_p.h b/src/quick/items/qquickimagebase_p_p.h
index 1eb566a3c8..d9b609c7fe 100644
--- a/src/quick/items/qquickimagebase_p_p.h
+++ b/src/quick/items/qquickimagebase_p_p.h
@@ -68,7 +68,6 @@ public:
: status(QQuickImageBase::Null),
progress(0.0),
devicePixelRatio(1.0),
- autoTransform(UsePluginDefault),
async(false),
cache(true),
mirror(false),
@@ -83,7 +82,7 @@ public:
QSize sourcesize;
QSize oldSourceSize;
qreal devicePixelRatio;
- AutoTransform autoTransform;
+ QQuickImageProviderOptions providerOptions;
bool async : 1;
bool cache : 1;
bool mirror: 1;
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index a448a6e86c..3604dfde13 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -776,7 +776,7 @@ const SigMap sigMap[] = {
{ 0, 0 }
};
-const QByteArray QQuickKeysAttached::keyToSignal(int key)
+QByteArray QQuickKeysAttached::keyToSignal(int key)
{
QByteArray keySignal;
if (key >= Qt::Key_0 && key <= Qt::Key_9) {
@@ -791,9 +791,9 @@ const QByteArray QQuickKeysAttached::keyToSignal(int key)
return keySignal;
}
-bool QQuickKeysAttached::isConnected(const char *signalName)
+bool QQuickKeysAttached::isConnected(const char *signalName) const
{
- Q_D(QQuickKeysAttached);
+ Q_D(const QQuickKeysAttached);
int signal_index = d->signalIndex(signalName);
return d->isSignalConnected(signal_index);
}
@@ -2346,7 +2346,9 @@ QQuickItem::~QQuickItem()
if (d->extra.isAllocated()) {
delete d->extra->contents; d->extra->contents = 0;
+#if QT_CONFIG(quick_shadereffect)
delete d->extra->layer; d->extra->layer = 0;
+#endif
}
delete d->_anchors; d->_anchors = 0;
@@ -4299,12 +4301,12 @@ void QQuickItem::polish()
*/
void QQuickItem::mapFromItem(QQmlV4Function *args) const
{
+ QV4::ExecutionEngine *v4 = args->v4engine();
if (args->length() != 3 && args->length() != 5) {
- args->v4engine()->throwTypeError();
+ v4->throwTypeError();
return;
}
- QV4::ExecutionEngine *v4 = args->v4engine();
QV4::Scope scope(v4);
QV4::ScopedValue item(scope, (*args)[0]);
@@ -4318,7 +4320,7 @@ void QQuickItem::mapFromItem(QQmlV4Function *args) const
if (!itemObj && !item->isNull()) {
qmlInfo(this) << "mapFromItem() given argument \"" << item->toQStringNoThrow()
<< "\" which is neither null nor an Item";
- args->v4engine()->throwTypeError();
+ v4->throwTypeError();
return;
}
@@ -4326,7 +4328,7 @@ void QQuickItem::mapFromItem(QQmlV4Function *args) const
QV4::ScopedValue vy(scope, (*args)[2]);
if (!vx->isNumber() || !vy->isNumber()) {
- args->v4engine()->throwTypeError();
+ v4->throwTypeError();
return;
}
@@ -4339,7 +4341,7 @@ void QQuickItem::mapFromItem(QQmlV4Function *args) const
QV4::ScopedValue vw(scope, (*args)[3]);
QV4::ScopedValue vh(scope, (*args)[4]);
if (!vw->isNumber() || !vh->isNumber()) {
- args->v4engine()->throwTypeError();
+ v4->throwTypeError();
return;
}
qreal w = vw->asDouble();
@@ -4387,12 +4389,12 @@ QTransform QQuickItem::itemTransform(QQuickItem *other, bool *ok) const
*/
void QQuickItem::mapToItem(QQmlV4Function *args) const
{
+ QV4::ExecutionEngine *v4 = args->v4engine();
if (args->length() != 3 && args->length() != 5) {
- args->v4engine()->throwTypeError();
+ v4->throwTypeError();
return;
}
- QV4::ExecutionEngine *v4 = args->v4engine();
QV4::Scope scope(v4);
QV4::ScopedValue item(scope, (*args)[0]);
@@ -4406,7 +4408,7 @@ void QQuickItem::mapToItem(QQmlV4Function *args) const
if (!itemObj && !item->isNull()) {
qmlInfo(this) << "mapToItem() given argument \"" << item->toQStringNoThrow()
<< "\" which is neither null nor an Item";
- args->v4engine()->throwTypeError();
+ v4->throwTypeError();
return;
}
@@ -4414,7 +4416,7 @@ void QQuickItem::mapToItem(QQmlV4Function *args) const
QV4::ScopedValue vy(scope, (*args)[2]);
if (!vx->isNumber() || !vy->isNumber()) {
- args->v4engine()->throwTypeError();
+ v4->throwTypeError();
return;
}
@@ -4427,7 +4429,7 @@ void QQuickItem::mapToItem(QQmlV4Function *args) const
QV4::ScopedValue vw(scope, (*args)[3]);
QV4::ScopedValue vh(scope, (*args)[4]);
if (!vw->isNumber() || !vh->isNumber()) {
- args->v4engine()->throwTypeError();
+ v4->throwTypeError();
return;
}
qreal w = vw->asDouble();
@@ -4443,6 +4445,76 @@ void QQuickItem::mapToItem(QQmlV4Function *args) const
}
/*!
+ \since 5.7
+ \qmlmethod object QtQuick::Item::mapFromGlobal(real x, real y)
+
+ Maps the point (\a x, \a y), which is in the global coordinate system, to the
+ item's coordinate system, and returns a \l point matching the mapped coordinate.
+*/
+/*!
+ \internal
+ */
+void QQuickItem::mapFromGlobal(QQmlV4Function *args) const
+{
+ QV4::ExecutionEngine *v4 = args->v4engine();
+ if (args->length() != 2) {
+ v4->throwTypeError();
+ return;
+ }
+
+ QV4::Scope scope(v4);
+ QV4::ScopedValue vx(scope, (*args)[0]);
+ QV4::ScopedValue vy(scope, (*args)[1]);
+
+ if (!vx->isNumber() || !vy->isNumber()) {
+ v4->throwTypeError();
+ return;
+ }
+
+ qreal x = vx->asDouble();
+ qreal y = vy->asDouble();
+ QVariant result = mapFromGlobal(QPointF(x, y));
+
+ QV4::ScopedObject rv(scope, v4->fromVariant(result));
+ args->setReturnValue(rv.asReturnedValue());
+}
+
+/*!
+ \since 5.7
+ \qmlmethod object QtQuick::Item::mapToGlobal(real x, real y)
+
+ Maps the point (\a x, \a y), which is in this item's coordinate system, to the
+ global coordinate system, and returns a \l point matching the mapped coordinate.
+*/
+/*!
+ \internal
+ */
+void QQuickItem::mapToGlobal(QQmlV4Function *args) const
+{
+ QV4::ExecutionEngine *v4 = args->v4engine();
+ if (args->length() != 2) {
+ v4->throwTypeError();
+ return;
+ }
+
+ QV4::Scope scope(v4);
+ QV4::ScopedValue vx(scope, (*args)[0]);
+ QV4::ScopedValue vy(scope, (*args)[1]);
+
+ if (!vx->isNumber() || !vy->isNumber()) {
+ v4->throwTypeError();
+ return;
+ }
+
+ qreal x = vx->asDouble();
+ qreal y = vy->asDouble();
+ QVariant result = mapToGlobal(QPointF(x, y));
+
+ QV4::ScopedObject rv(scope, v4->fromVariant(result));
+ args->setReturnValue(rv.asReturnedValue());
+}
+
+/*!
\qmlmethod QtQuick::Item::forceActiveFocus()
Forces active focus on the item.
@@ -4778,8 +4850,10 @@ void QQuickItem::classBegin()
d->_stateGroup->classBegin();
if (d->_anchors)
d->_anchors->classBegin();
+#if QT_CONFIG(quick_shadereffect)
if (d->extra.isAllocated() && d->extra->layer)
d->extra->layer->classBegin();
+#endif
}
/*!
@@ -4799,8 +4873,10 @@ void QQuickItem::componentComplete()
}
if (d->extra.isAllocated()) {
+#if QT_CONFIG(quick_shadereffect)
if (d->extra->layer)
d->extra->layer->componentComplete();
+#endif
if (d->extra->keyHandler)
d->extra->keyHandler->componentComplete();
@@ -4856,8 +4932,10 @@ QPointF QQuickItemPrivate::computeTransformOrigin() const
void QQuickItemPrivate::transformChanged()
{
+#if QT_CONFIG(quick_shadereffect)
if (extra.isAllocated() && extra->layer)
extra->layer->updateMatrix();
+#endif
}
void QQuickItemPrivate::deliverKeyEvent(QKeyEvent *e)
@@ -5250,8 +5328,10 @@ void QQuickItem::setZ(qreal v)
emit zChanged();
+#if QT_CONFIG(quick_shadereffect)
if (d->extra.isAllocated() && d->extra->layer)
d->extra->layer->updateZ();
+#endif
}
/*!
@@ -6238,7 +6318,7 @@ QPointF QQuickItem::position() const
void QQuickItem::setX(qreal v)
{
Q_D(QQuickItem);
- if (qIsNaN(v))
+ if (qt_is_nan(v))
return;
if (d->x == v)
return;
@@ -6255,7 +6335,7 @@ void QQuickItem::setX(qreal v)
void QQuickItem::setY(qreal v)
{
Q_D(QQuickItem);
- if (qIsNaN(v))
+ if (qt_is_nan(v))
return;
if (d->y == v)
return;
@@ -7038,15 +7118,6 @@ void QQuickItemPrivate::setHasHoverInChild(bool hasHover)
}
}
-void QQuickItemPrivate::markObjects(QV4::ExecutionEngine *e)
-{
- Q_Q(QQuickItem);
- QV4::QObjectWrapper::markWrapper(q, e);
-
- for (QQuickItem *child : qAsConst(childItems))
- QQuickItemPrivate::get(child)->markObjects(e);
-}
-
#ifndef QT_NO_CURSOR
/*!
@@ -7662,9 +7733,13 @@ QDebug operator<<(QDebug debug, QQuickItem *item)
bool QQuickItem::isTextureProvider() const
{
+#if QT_CONFIG(quick_shadereffect)
Q_D(const QQuickItem);
return d->extra.isAllocated() && d->extra->layer && d->extra->layer->effectSource() ?
d->extra->layer->effectSource()->isTextureProvider() : false;
+#else
+ return false;
+#endif
}
/*!
@@ -7678,9 +7753,13 @@ bool QQuickItem::isTextureProvider() const
QSGTextureProvider *QQuickItem::textureProvider() const
{
+#if QT_CONFIG(quick_shadereffect)
Q_D(const QQuickItem);
return d->extra.isAllocated() && d->extra->layer && d->extra->layer->effectSource() ?
d->extra->layer->effectSource()->textureProvider() : 0;
+#else
+ return 0;
+#endif
}
/*!
@@ -7689,14 +7768,19 @@ QSGTextureProvider *QQuickItem::textureProvider() const
*/
QQuickItemLayer *QQuickItemPrivate::layer() const
{
+#if QT_CONFIG(quick_shadereffect)
if (!extra.isAllocated() || !extra->layer) {
extra.value().layer = new QQuickItemLayer(const_cast<QQuickItem *>(q_func()));
if (!componentComplete)
extra->layer->classBegin();
}
return extra->layer;
+#else
+ return 0;
+#endif
}
+#if QT_CONFIG(quick_shadereffect)
QQuickItemLayer::QQuickItemLayer(QQuickItem *item)
: m_item(item)
, m_enabled(false)
@@ -8184,12 +8268,16 @@ void QQuickItemLayer::updateMatrix()
ld->extra.value().origin = QQuickItemPrivate::get(m_item)->origin();
ld->dirty(QQuickItemPrivate::Transform);
}
+#endif // quick_shadereffect
QQuickItemPrivate::ExtraData::ExtraData()
: z(0), scale(1), rotation(0), opacity(1),
contents(0), screenAttached(0), layoutDirectionAttached(0),
enterKeyAttached(0),
- keyHandler(0), layer(0),
+ keyHandler(0),
+#if QT_CONFIG(quick_shadereffect)
+ layer(0),
+#endif
effectRefCount(0), hideRefCount(0),
opacityNode(0), clipNode(0), rootNode(0),
acceptedMouseButtons(0), origin(QQuickItem::Center),
@@ -8210,6 +8298,37 @@ QAccessible::Role QQuickItemPrivate::accessibleRole() const
}
#endif
+// helper code to let a visual parent mark its visual children for the garbage collector
+
+namespace QV4 {
+namespace Heap {
+struct QQuickItemWrapper : public QObjectWrapper {
+};
+}
+}
+
+struct QQuickItemWrapper : public QV4::QObjectWrapper {
+ V4_OBJECT2(QQuickItemWrapper, QV4::QObjectWrapper)
+ static void markObjects(QV4::Heap::Base *that, QV4::ExecutionEngine *e);
+};
+
+DEFINE_OBJECT_VTABLE(QQuickItemWrapper);
+
+void QQuickItemWrapper::markObjects(QV4::Heap::Base *that, QV4::ExecutionEngine *e)
+{
+ QObjectWrapper::Data *This = static_cast<QObjectWrapper::Data *>(that);
+ if (QQuickItem *item = static_cast<QQuickItem*>(This->object())) {
+ foreach (QQuickItem *child, QQuickItemPrivate::get(item)->childItems)
+ QV4::QObjectWrapper::markWrapper(child, e);
+ }
+ QV4::QObjectWrapper::markObjects(that, e);
+}
+
+quint64 QQuickItemPrivate::_q_createJSWrapper(QV4::ExecutionEngine *engine)
+{
+ return (engine->memoryManager->allocObject<QQuickItemWrapper>(q_func()))->asReturnedValue();
+}
+
QT_END_NAMESPACE
#include <moc_qquickitem.cpp>
diff --git a/src/quick/items/qquickitem.h b/src/quick/items/qquickitem.h
index 87ae83246c..b1b1d627b1 100644
--- a/src/quick/items/qquickitem.h
+++ b/src/quick/items/qquickitem.h
@@ -148,6 +148,7 @@ class Q_QUICK_EXPORT QQuickItem : public QObject, public QQmlParserStatus
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*)")
public:
enum Flag {
@@ -319,12 +320,12 @@ public:
QTransform itemTransform(QQuickItem *, bool *) const;
QPointF mapToItem(const QQuickItem *item, const QPointF &point) const;
QPointF mapToScene(const QPointF &point) const;
- Q_REVISION(7) Q_INVOKABLE QPointF mapToGlobal(const QPointF &point) const;
+ QPointF mapToGlobal(const QPointF &point) const;
QRectF mapRectToItem(const QQuickItem *item, const QRectF &rect) const;
QRectF mapRectToScene(const QRectF &rect) const;
QPointF mapFromItem(const QQuickItem *item, const QPointF &point) const;
QPointF mapFromScene(const QPointF &point) const;
- Q_REVISION(7) Q_INVOKABLE QPointF mapFromGlobal(const QPointF &point) const;
+ QPointF mapFromGlobal(const QPointF &point) const;
QRectF mapRectFromItem(const QQuickItem *item, const QRectF &rect) const;
QRectF mapRectFromScene(const QRectF &rect) const;
@@ -332,6 +333,8 @@ 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_INVOKABLE void forceActiveFocus();
Q_INVOKABLE void forceActiveFocus(Qt::FocusReason reason);
Q_REVISION(1) Q_INVOKABLE QQuickItem *nextItemInFocusChain(bool forward = true);
@@ -442,6 +445,7 @@ protected:
private:
Q_PRIVATE_SLOT(d_func(), void _q_resourceObjectDeleted(QObject *))
+ Q_PRIVATE_SLOT(d_func(), quint64 _q_createJSWrapper(QV4::ExecutionEngine *))
friend class QQuickWindow;
friend class QQuickWindowPrivate;
diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h
index 5fa6de546f..49d0949fb8 100644
--- a/src/quick/items/qquickitem_p.h
+++ b/src/quick/items/qquickitem_p.h
@@ -76,7 +76,9 @@
#include <QtCore/qdebug.h>
#include <QtCore/qelapsedtimer.h>
+#if QT_CONFIG(quick_shadereffect)
#include <QtQuick/private/qquickshadereffectsource_p.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -136,6 +138,7 @@ public:
QList<QQuickItem *> items;
};
+#if QT_CONFIG(quick_shadereffect)
class QQuickItemLayer : public QObject, public QQuickItemChangeListener
{
@@ -237,6 +240,8 @@ private:
QQuickShaderEffectSource::TextureMirroring m_textureMirroring;
};
+#endif
+
class Q_QUICK_PRIVATE_EXPORT QQuickItemPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QQuickItem)
@@ -301,6 +306,7 @@ public:
void _q_resourceObjectDeleted(QObject *);
void _q_windowChanged(QQuickWindow *w);
+ quint64 _q_createJSWrapper(QV4::ExecutionEngine *engine);
enum ChangeType {
Geometry = 0x01,
@@ -340,7 +346,9 @@ public:
QQuickEnterKeyAttached *enterKeyAttached;
QQuickItemKeyFilter *keyHandler;
QVector<QQuickPointerHandler *> pointerHandlers;
+#if QT_CONFIG(quick_shadereffect)
mutable QQuickItemLayer *layer;
+#endif
#ifndef QT_NO_CURSOR
QCursor cursor;
#endif
@@ -597,9 +605,6 @@ public:
void setHasCursorInChild(bool hasCursor);
void setHasHoverInChild(bool hasHover);
- // recursive helper to let a visual parent mark its visual children
- void markObjects(QV4::ExecutionEngine *e);
-
virtual void updatePolish() { }
};
@@ -860,9 +865,9 @@ private:
void inputMethodEvent(QInputMethodEvent *, bool post) Q_DECL_OVERRIDE;
QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE;
#endif
- const QByteArray keyToSignal(int key);
+ static QByteArray keyToSignal(int key);
- bool isConnected(const char *signalName);
+ bool isConnected(const char *signalName) const;
};
Qt::MouseButtons QQuickItemPrivate::acceptedMouseButtons() const
@@ -929,7 +934,9 @@ Q_DECLARE_TYPEINFO(QQuickItemPrivate::ChangeListener, Q_PRIMITIVE_TYPE);
QT_END_NAMESPACE
+#if QT_CONFIG(quick_shadereffect)
QML_DECLARE_TYPE(QQuickItemLayer)
+#endif
QML_DECLARE_TYPE(QQuickKeysAttached)
QML_DECLARE_TYPEINFO(QQuickKeysAttached, QML_HAS_ATTACHED_PROPERTIES)
QML_DECLARE_TYPE(QQuickKeyNavigationAttached)
diff --git a/src/quick/items/qquickitemanimation.cpp b/src/quick/items/qquickitemanimation.cpp
index 5c0caf5ca2..fd4a7d733f 100644
--- a/src/quick/items/qquickitemanimation.cpp
+++ b/src/quick/items/qquickitemanimation.cpp
@@ -42,7 +42,9 @@
#include "qquickstateoperations_p.h"
#include <private/qqmlproperty_p.h>
+#if QT_CONFIG(quick_path)
#include <private/qquickpath_p.h>
+#endif
#include "private/qparallelanimationgroupjob_p.h"
#include "private/qsequentialanimationgroupjob_p.h"
@@ -554,6 +556,8 @@ QAbstractAnimationJob* QQuickAnchorAnimation::transition(QQuickStateActions &act
return initInstance(animator);
}
+
+#if QT_CONFIG(quick_path)
/*!
\qmltype PathAnimation
\instantiates QQuickPathAnimation
@@ -1044,4 +1048,6 @@ QQuickPathAnimationAnimator::~QQuickPathAnimationAnimator()
}
}
+#endif // quick_path
+
QT_END_NAMESPACE
diff --git a/src/quick/items/qquickitemanimation_p.h b/src/quick/items/qquickitemanimation_p.h
index df80272eaa..a503cff223 100644
--- a/src/quick/items/qquickitemanimation_p.h
+++ b/src/quick/items/qquickitemanimation_p.h
@@ -124,6 +124,8 @@ protected:
QObject *defaultTarget = 0) Q_DECL_OVERRIDE;
};
+#if QT_CONFIG(quick_path)
+
class QQuickItem;
class QQuickPath;
class QQuickPathAnimationPrivate;
@@ -199,10 +201,14 @@ Q_SIGNALS:
void endRotationChanged(qreal);
};
+#endif
+
QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickParentAnimation)
QML_DECLARE_TYPE(QQuickAnchorAnimation)
+#if QT_CONFIG(quick_path)
QML_DECLARE_TYPE(QQuickPathAnimation)
+#endif
#endif // QQUICKITEMANIMATION_H
diff --git a/src/quick/items/qquickitemanimation_p_p.h b/src/quick/items/qquickitemanimation_p_p.h
index 5b18e4b0ae..2d075dfab3 100644
--- a/src/quick/items/qquickitemanimation_p_p.h
+++ b/src/quick/items/qquickitemanimation_p_p.h
@@ -53,7 +53,9 @@
#include "qquickitemanimation_p.h"
+#if QT_CONFIG(quick_path)
#include <private/qquickpath_p.h>
+#endif
#include <private/qquickanimation_p_p.h>
QT_BEGIN_NAMESPACE
@@ -84,6 +86,8 @@ public:
QList<QQuickItem*> targets;
};
+#if QT_CONFIG(quick_path)
+
class QQuickPathAnimationUpdater : public QQuickBulkValueUpdater
{
public:
@@ -93,7 +97,7 @@ public:
entryInterval(0), exitInterval(0) {}
~QQuickPathAnimationUpdater() {}
- void setValue(qreal v);
+ void setValue(qreal v) override;
QQuickPath *path;
@@ -129,7 +133,7 @@ public:
void clearTemplate() { animationTemplate = 0; }
- QQuickPathAnimationUpdater *pathUpdater() { return static_cast<QQuickPathAnimationUpdater*>(getAnimValue()); }
+ QQuickPathAnimationUpdater *pathUpdater() const { return static_cast<QQuickPathAnimationUpdater*>(getAnimValue()); }
private:
QQuickPathAnimationPrivate *animationTemplate;
};
@@ -153,6 +157,7 @@ public:
QHash<QQuickItem*, QQuickPathAnimationAnimator* > activeAnimations;
};
+#endif
QT_END_NAMESPACE
diff --git a/src/quick/items/qquickitemgrabresult.cpp b/src/quick/items/qquickitemgrabresult.cpp
index 0db5323863..c6355ceed2 100644
--- a/src/quick/items/qquickitemgrabresult.cpp
+++ b/src/quick/items/qquickitemgrabresult.cpp
@@ -37,17 +37,21 @@
**
****************************************************************************/
+#include <private/qtquickglobal_p.h>
#include "qquickitemgrabresult.h"
#include "qquickwindow.h"
#include "qquickitem.h"
+#if QT_CONFIG(quick_shadereffect)
#include "qquickshadereffectsource_p.h"
+#endif
#include <QtQml/QQmlEngine>
#include <private/qquickpixmapcache_p.h>
#include <private/qquickitem_p.h>
#include <private/qsgcontext_p.h>
+#include <private/qsgadaptationlayer_p.h>
QT_BEGIN_NAMESPACE
@@ -180,13 +184,26 @@ QQuickItemGrabResult::QQuickItemGrabResult(QObject *parent)
/*!
* Saves the grab result as an image to \a fileName. Returns true
* if successful; otherwise returns false.
+ *
+ * \note In Qt versions prior to 5.9, this function is marked as non-\c{const}.
*/
-bool QQuickItemGrabResult::saveToFile(const QString &fileName)
+bool QQuickItemGrabResult::saveToFile(const QString &fileName) const
{
- Q_D(QQuickItemGrabResult);
+ Q_D(const QQuickItemGrabResult);
return d->image.save(fileName);
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+/*!
+ * \overload
+ * \internal
+ */
+bool QQuickItemGrabResult::saveToFile(const QString &fileName)
+{
+ return qAsConst(*this).saveToFile(fileName);
+}
+#endif // < Qt 6
+
QUrl QQuickItemGrabResult::url() const
{
Q_D(const QQuickItemGrabResult);
diff --git a/src/quick/items/qquickitemgrabresult.h b/src/quick/items/qquickitemgrabresult.h
index 42d71862de..30f8f0c2ef 100644
--- a/src/quick/items/qquickitemgrabresult.h
+++ b/src/quick/items/qquickitemgrabresult.h
@@ -64,10 +64,13 @@ public:
QImage image() const;
QUrl url() const;
- Q_INVOKABLE bool saveToFile(const QString &fileName);
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ Q_INVOKABLE bool saveToFile(const QString &fileName); // ### Qt 6: remove
+#endif
+ Q_INVOKABLE bool saveToFile(const QString &fileName) const;
protected:
- bool event(QEvent *);
+ bool event(QEvent *) override;
Q_SIGNALS:
void ready();
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp
index 1bc1aebe4f..0705d9b504 100644
--- a/src/quick/items/qquickitemsmodule.cpp
+++ b/src/quick/items/qquickitemsmodule.cpp
@@ -55,34 +55,56 @@
#include "qquickpincharea_p.h"
#include "qquickflickable_p.h"
#include "qquickflickable_p_p.h"
+#if QT_CONFIG(quick_listview)
#include "qquicklistview_p.h"
+#endif
+#if QT_CONFIG(quick_gridview)
#include "qquickgridview_p.h"
+#endif
+#if QT_CONFIG(quick_pathview)
#include "qquickpathview_p.h"
+#endif
+#if QT_CONFIG(quick_viewtransitions)
#include "qquickitemviewtransition_p.h"
+#endif
+#if QT_CONFIG(quick_path)
#include <private/qquickpath_p.h>
#include <private/qquickpathinterpolator_p.h>
+#endif
+#if QT_CONFIG(quick_positioners)
#include "qquickpositioners_p.h"
+#endif
#include "qquickrepeater_p.h"
#include "qquickloader_p.h"
+#if QT_CONFIG(quick_animatedimage)
#include "qquickanimatedimage_p.h"
+#endif
+#if QT_CONFIG(quick_flipable)
#include "qquickflipable_p.h"
+#endif
#include "qquicktranslate_p.h"
#include "qquickstateoperations_p.h"
#include "qquickitemanimation_p.h"
-#include <QtQuick/private/qquickshadereffectsource_p.h>
//#include <private/qquickpincharea_p.h>
+#if QT_CONFIG(quick_canvas)
#include <QtQuick/private/qquickcanvasitem_p.h>
#include <QtQuick/private/qquickcontext2d_p.h>
+#endif
#include "qquickitemgrabresult.h"
+#if QT_CONFIG(quick_sprite)
#include "qquicksprite_p.h"
#include "qquickspritesequence_p.h"
#include "qquickanimatedsprite_p.h"
+#endif
#ifndef QT_NO_OPENGL
# include "qquickopenglinfo_p.h"
#endif
#include "qquickgraphicsinfo_p.h"
+#if QT_CONFIG(quick_shadereffect)
+#include <QtQuick/private/qquickshadereffectsource_p.h>
#include "qquickshadereffect_p.h"
#include "qquickshadereffectmesh_p.h"
+#endif
#include "qquickdrag_p.h"
#include "qquickdroparea_p.h"
#include "qquickmultipointtoucharea_p.h"
@@ -134,27 +156,40 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
QQmlPrivate::RegisterAutoParent autoparent = { 0, &qquickitem_autoParent };
QQmlPrivate::qmlregister(QQmlPrivate::AutoParentRegistration, &autoparent);
-#ifdef QT_NO_MOVIE
+#if !QT_CONFIG(quick_animatedimage)
qmlRegisterTypeNotAvailable(uri,major,minor,"AnimatedImage", QCoreApplication::translate("QQuickAnimatedImage","Qt was built without support for QMovie"));
#else
qmlRegisterType<QQuickAnimatedImage>(uri,major,minor,"AnimatedImage");
#endif
qmlRegisterType<QQuickBorderImage>(uri,major,minor,"BorderImage");
- qmlRegisterType<QQuickColumn>(uri,major,minor,"Column");
qmlRegisterType<QQuickFlickable>(uri,major,minor,"Flickable");
+#if QT_CONFIG(quick_flipable)
qmlRegisterType<QQuickFlipable>(uri,major,minor,"Flipable");
- qmlRegisterType<QQuickFlow>(uri,major,minor,"Flow");
+#endif
// qmlRegisterType<QQuickFocusPanel>(uri,major,minor,"FocusPanel");
qmlRegisterType<QQuickFocusScope>(uri,major,minor,"FocusScope");
qmlRegisterType<QQuickGradient>(uri,major,minor,"Gradient");
qmlRegisterType<QQuickGradientStop>(uri,major,minor,"GradientStop");
+#if QT_CONFIG(quick_positioners)
+ qmlRegisterType<QQuickColumn>(uri,major,minor,"Column");
+ qmlRegisterType<QQuickFlow>(uri,major,minor,"Flow");
qmlRegisterType<QQuickGrid>(uri,major,minor,"Grid");
+ qmlRegisterUncreatableType<QQuickBasePositioner>(uri,major,minor,"Positioner",
+ QStringLiteral("Positioner is an abstract type that is only available as an attached property."));
+ qmlRegisterType<QQuickRow>(uri,major,minor,"Row");
+#endif
+#if QT_CONFIG(quick_gridview)
qmlRegisterType<QQuickGridView>(uri,major,minor,"GridView");
+#endif
qmlRegisterType<QQuickImage>(uri,major,minor,"Image");
qmlRegisterType<QQuickItem>(uri,major,minor,"Item");
+#if QT_CONFIG(quick_listview)
qmlRegisterType<QQuickListView>(uri,major,minor,"ListView");
+ qmlRegisterType<QQuickViewSection>(uri,major,minor,"ViewSection");
+#endif
qmlRegisterType<QQuickLoader>(uri,major,minor,"Loader");
qmlRegisterType<QQuickMouseArea>(uri,major,minor,"MouseArea");
+#if QT_CONFIG(quick_path)
qmlRegisterType<QQuickPath>(uri,major,minor,"Path");
qmlRegisterType<QQuickPathAttribute>(uri,major,minor,"PathAttribute");
qmlRegisterType<QQuickPathCubic>(uri,major,minor,"PathCubic");
@@ -164,12 +199,12 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterType<QQuickPathCatmullRomCurve>("QtQuick",2,0,"PathCurve");
qmlRegisterType<QQuickPathArc>("QtQuick",2,0,"PathArc");
qmlRegisterType<QQuickPathSvg>("QtQuick",2,0,"PathSvg");
+#endif
+#if QT_CONFIG(quick_pathview)
qmlRegisterType<QQuickPathView>(uri,major,minor,"PathView");
- qmlRegisterUncreatableType<QQuickBasePositioner>(uri,major,minor,"Positioner",
- QStringLiteral("Positioner is an abstract type that is only available as an attached property."));
+#endif
qmlRegisterType<QQuickRectangle>(uri,major,minor,"Rectangle");
qmlRegisterType<QQuickRepeater>(uri,major,minor,"Repeater");
- qmlRegisterType<QQuickRow>(uri,major,minor,"Row");
qmlRegisterType<QQuickTranslate>(uri,major,minor,"Translate");
qmlRegisterType<QQuickRotation>(uri,major,minor,"Rotation");
qmlRegisterType<QQuickScale>(uri,major,minor,"Scale");
@@ -180,17 +215,20 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterType<QQuickTextInput>(uri,major,minor,"TextInput");
qmlRegisterType<QQuickTextInput,2>(uri,2,2,"TextInput");
qmlRegisterType<QQuickTextInput,3>(uri,2,4,"TextInput");
- qmlRegisterType<QQuickViewSection>(uri,major,minor,"ViewSection");
qmlRegisterType<QQuickItemGrabResult>();
+#if QT_CONFIG(quick_shadereffect)
qmlRegisterType<QQuickItemLayer>();
+#endif
qmlRegisterType<QQuickAnchors>();
qmlRegisterType<QQuickKeyEvent>();
qmlRegisterType<QQuickMouseEvent>();
qmlRegisterType<QQuickWheelEvent>();
qmlRegisterType<QQuickCloseEvent>();
qmlRegisterType<QQuickTransform>();
+#if QT_CONFIG(quick_path)
qmlRegisterType<QQuickPathElement>();
qmlRegisterType<QQuickCurve>();
+#endif
qmlRegisterType<QQuickScaleGrid>();
qmlRegisterType<QQuickTextLine>();
qmlRegisterType<QQuickPen>();
@@ -203,32 +241,42 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterUncreatableType<QQuickKeyNavigationAttached>(uri,major,minor,"KeyNavigation",QQuickKeyNavigationAttached::tr("KeyNavigation is only available via attached properties"));
qmlRegisterUncreatableType<QQuickKeysAttached>(uri,major,minor,"Keys",QQuickKeysAttached::tr("Keys is only available via attached properties"));
qmlRegisterUncreatableType<QQuickLayoutMirroringAttached>(uri,major,minor,"LayoutMirroring", QQuickLayoutMirroringAttached::tr("LayoutMirroring is only available via attached properties"));
+#if QT_CONFIG(quick_viewtransitions)
qmlRegisterUncreatableType<QQuickViewTransitionAttached>(uri,major,minor,"ViewTransition",QQuickViewTransitionAttached::tr("ViewTransition is only available via attached properties"));
+#endif
qmlRegisterType<QQuickPinchArea>(uri,major,minor,"PinchArea");
qmlRegisterType<QQuickPinch>(uri,major,minor,"Pinch");
qmlRegisterType<QQuickPinchEvent>();
+#if QT_CONFIG(quick_shadereffect)
qmlRegisterType<QQuickShaderEffectSource>("QtQuick", 2, 0, "ShaderEffectSource");
qmlRegisterUncreatableType<QQuickShaderEffectMesh>("QtQuick", 2, 0, "ShaderEffectMesh", QQuickShaderEffectMesh::tr("Cannot create instance of abstract class ShaderEffectMesh."));
qmlRegisterType<QQuickGridMesh>("QtQuick", 2, 0, "GridMesh");
qmlRegisterType<QQuickShaderEffect>("QtQuick", 2, 0, "ShaderEffect");
+#endif
qmlRegisterUncreatableType<QQuickPaintedItem>("QtQuick", 2, 0, "PaintedItem", QQuickPaintedItem::tr("Cannot create instance of abstract class PaintedItem"));
+#if QT_CONFIG(quick_canvas)
qmlRegisterType<QQuickCanvasItem>("QtQuick", 2, 0, "Canvas");
+#endif
+#if QT_CONFIG(quick_sprite)
qmlRegisterType<QQuickSprite>("QtQuick", 2, 0, "Sprite");
qmlRegisterType<QQuickAnimatedSprite>("QtQuick", 2, 0, "AnimatedSprite");
qmlRegisterType<QQuickSpriteSequence>("QtQuick", 2, 0, "SpriteSequence");
+#endif
qmlRegisterType<QQuickParentChange>(uri, major, minor,"ParentChange");
qmlRegisterType<QQuickAnchorChanges>(uri, major, minor,"AnchorChanges");
qmlRegisterType<QQuickAnchorSet>();
qmlRegisterType<QQuickAnchorAnimation>(uri, major, minor,"AnchorAnimation");
qmlRegisterType<QQuickParentAnimation>(uri, major, minor,"ParentAnimation");
+#if QT_CONFIG(quick_canvas)
qmlRegisterType<QQuickPathAnimation>("QtQuick",2,0,"PathAnimation");
qmlRegisterType<QQuickPathInterpolator>("QtQuick",2,0,"PathInterpolator");
+#endif
#ifndef QT_NO_DRAGANDDROP
qmlRegisterType<QQuickDropArea>("QtQuick", 2, 0, "DropArea");
@@ -246,11 +294,19 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
#endif
qmlRegisterType<QQuickItem, 1>(uri, 2, 1,"Item");
+#if QT_CONFIG(quick_positioners)
qmlRegisterType<QQuickGrid, 1>(uri, 2, 1, "Grid");
+#endif
+#if QT_CONFIG(quick_itemview)
qmlRegisterUncreatableType<QQuickItemView, 1>(uri, 2, 1, "ItemView", QQuickItemView::tr("ItemView is an abstract base class"));
qmlRegisterUncreatableType<QQuickItemView, 2>(uri, 2, 3, "ItemView", QQuickItemView::tr("ItemView is an abstract base class"));
+#endif
+#if QT_CONFIG(quick_listview)
qmlRegisterType<QQuickListView, 1>(uri, 2, 1, "ListView");
+#endif
+#if QT_CONFIG(quick_gridview)
qmlRegisterType<QQuickGridView, 1>(uri, 2, 1, "GridView");
+#endif
qmlRegisterType<QQuickTextEdit, 1>(uri, 2, 1, "TextEdit");
qmlRegisterType<QQuickText, 2>(uri, 2, 2, "Text");
@@ -261,9 +317,13 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterType<QQuickImage, 1>(uri, 2, 3,"Image");
qmlRegisterType<QQuickItem, 2>(uri, 2, 4, "Item");
+#if QT_CONFIG(quick_listview)
qmlRegisterType<QQuickListView, 2>(uri, 2, 4, "ListView");
+#endif
qmlRegisterType<QQuickMouseArea, 1>(uri, 2, 4, "MouseArea");
+#if QT_CONFIG(quick_shadereffect)
qmlRegisterType<QQuickShaderEffect, 1>(uri, 2, 4, "ShaderEffect");
+#endif
#ifndef QT_NO_OPENGL
qmlRegisterUncreatableType<QQuickOpenGLInfo>(uri, 2, 4,"OpenGLInfo", QQuickOpenGLInfo::tr("OpenGLInfo is only available via attached properties"));
@@ -275,26 +335,39 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterType<QQuickText, 6>(uri, 2, 6, "Text");
qmlRegisterType<QQuickTextEdit, 6>(uri, 2, 6, "TextEdit");
qmlRegisterType<QQuickTextInput, 6>(uri, 2, 6, "TextInput");
+#if QT_CONFIG(quick_positioners)
qmlRegisterUncreatableType<QQuickBasePositioner, 6>(uri, 2, 6, "Positioner",
QStringLiteral("Positioner is an abstract type that is only available as an attached property."));
qmlRegisterType<QQuickColumn, 6>(uri, 2, 6, "Column");
qmlRegisterType<QQuickRow, 6>(uri, 2, 6, "Row");
qmlRegisterType<QQuickGrid, 6>(uri, 2, 6, "Grid");
qmlRegisterType<QQuickFlow, 6>(uri, 2, 6, "Flow");
+#endif
qmlRegisterUncreatableType<QQuickEnterKeyAttached, 6>(uri, 2, 6, "EnterKey",
QQuickEnterKeyAttached::tr("EnterKey is only available via attached properties"));
+#if QT_CONFIG(quick_shadereffect)
qmlRegisterType<QQuickShaderEffectSource, 1>(uri, 2, 6, "ShaderEffectSource");
+#endif
+ qmlRegisterType<QQuickItem, 7>(uri, 2, 7, "Item");
+#if QT_CONFIG(quick_listview)
qmlRegisterType<QQuickListView, 7>(uri, 2, 7, "ListView");
+#endif
+#if QT_CONFIG(quick_gridview)
qmlRegisterType<QQuickGridView, 7>(uri, 2, 7, "GridView");
+#endif
qmlRegisterType<QQuickTextInput, 7>(uri, 2, 7, "TextInput");
qmlRegisterType<QQuickTextEdit, 7>(uri, 2, 7, "TextEdit");
+#if QT_CONFIG(quick_pathview)
qmlRegisterType<QQuickPathView, 7>(uri, 2, 7, "PathView");
+#endif
qmlRegisterUncreatableType<QQuickMouseEvent, 7>(uri, 2, 7, nullptr, QQuickMouseEvent::tr("MouseEvent is only available within handlers in MouseArea"));
qmlRegisterUncreatableType<QQuickGraphicsInfo>(uri, 2, 8,"GraphicsInfo", QQuickGraphicsInfo::tr("GraphicsInfo is only available via attached properties"));
+#if QT_CONFIG(quick_shadereffect)
qmlRegisterType<QQuickBorderImageMesh>("QtQuick", 2, 8, "BorderImageMesh");
+#endif
}
static void initResources()
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index e017d6564a..d02ed07de0 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -935,9 +935,11 @@ void QQuickItemViewPrivate::positionViewAtIndex(int index, int mode)
return;
applyPendingChanges();
- int idx = qMax(qMin(index, model->count()-1), 0);
+ const int modelCount = model->count();
+ int idx = qMax(qMin(index, modelCount - 1), 0);
- qreal pos = isContentFlowReversed() ? -position() - size() : position();
+ const auto viewSize = size();
+ qreal pos = isContentFlowReversed() ? -position() - viewSize : position();
FxViewItem *item = visibleItem(idx);
qreal maxExtent = calculatedMaxExtent();
if (!item) {
@@ -961,22 +963,22 @@ void QQuickItemViewPrivate::positionViewAtIndex(int index, int mode)
pos -= headerSize();
break;
case QQuickItemView::Center:
- pos = itemPos - (size() - item->size())/2;
+ pos = itemPos - (viewSize - item->size())/2;
break;
case QQuickItemView::End:
- pos = itemPos - size() + item->size();
- if (footer && (index >= model->count() || hasStickyFooter()))
+ pos = itemPos - viewSize + item->size();
+ if (footer && (index >= modelCount || hasStickyFooter()))
pos += footerSize();
break;
case QQuickItemView::Visible:
- if (itemPos > pos + size())
- pos = itemPos - size() + item->size();
+ if (itemPos > pos + viewSize)
+ pos = itemPos - viewSize + item->size();
else if (item->endPosition() <= pos)
pos = itemPos;
break;
case QQuickItemView::Contain:
- if (item->endPosition() >= pos + size())
- pos = itemPos - size() + item->size();
+ if (item->endPosition() >= pos + viewSize)
+ pos = itemPos - viewSize + item->size();
if (itemPos < pos)
pos = itemPos;
break;
@@ -1025,28 +1027,27 @@ void QQuickItemView::positionViewAtEnd()
d->positionViewAtIndex(d->model->count(), End);
}
-int QQuickItemView::indexAt(qreal x, qreal y) const
+static FxViewItem * fxViewItemAtPosition(const QList<FxViewItem *> &items, qreal x, qreal y)
{
- Q_D(const QQuickItemView);
- for (int i = 0; i < d->visibleItems.count(); ++i) {
- const FxViewItem *item = d->visibleItems.at(i);
+ for (FxViewItem *item : items) {
if (item->contains(x, y))
- return item->index;
+ return item;
}
+ return nullptr;
+}
- return -1;
+int QQuickItemView::indexAt(qreal x, qreal y) const
+{
+ Q_D(const QQuickItemView);
+ const FxViewItem *item = fxViewItemAtPosition(d->visibleItems, x, y);
+ return item ? item->index : -1;
}
QQuickItem *QQuickItemView::itemAt(qreal x, qreal y) const
{
Q_D(const QQuickItemView);
- for (int i = 0; i < d->visibleItems.count(); ++i) {
- const FxViewItem *item = d->visibleItems.at(i);
- if (item->contains(x, y))
- return item->item;
- }
-
- return 0;
+ const FxViewItem *item = fxViewItemAtPosition(d->visibleItems, x, y);
+ return item ? item->item : nullptr;
}
void QQuickItemView::forceLayout()
@@ -1787,10 +1788,11 @@ void QQuickItemViewPrivate::animationFinished(QAbstractAnimationJob *)
void QQuickItemViewPrivate::refill()
{
qreal s = qMax(size(), qreal(0.));
+ const auto pos = position();
if (isContentFlowReversed())
- refill(-position()-displayMarginBeginning-s, -position()+displayMarginEnd);
+ refill(-pos - displayMarginBeginning-s, -pos + displayMarginEnd);
else
- refill(position()-displayMarginBeginning, position()+displayMarginEnd+s);
+ refill(pos - displayMarginBeginning, pos + displayMarginEnd+s);
}
void QQuickItemViewPrivate::refill(qreal from, qreal to)
@@ -2428,14 +2430,14 @@ bool QQuickItemViewPrivate::releaseItem(FxViewItem *item)
return flags != QQmlInstanceModel::Referenced;
}
-QQuickItem *QQuickItemViewPrivate::createHighlightItem()
+QQuickItem *QQuickItemViewPrivate::createHighlightItem() const
{
return createComponentItem(highlightComponent, 0.0, true);
}
-QQuickItem *QQuickItemViewPrivate::createComponentItem(QQmlComponent *component, qreal zValue, bool createDefault)
+QQuickItem *QQuickItemViewPrivate::createComponentItem(QQmlComponent *component, qreal zValue, bool createDefault) const
{
- Q_Q(QQuickItemView);
+ Q_Q(const QQuickItemView);
QQuickItem *item = 0;
if (component) {
diff --git a/src/quick/items/qquickitemview_p.h b/src/quick/items/qquickitemview_p.h
index 1a28fc212b..3ac54ea3dc 100644
--- a/src/quick/items/qquickitemview_p.h
+++ b/src/quick/items/qquickitemview_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <QtQuick/private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_itemview);
+
#include "qquickflickable_p.h"
#include <qpointer.h>
#include <QtCore/QLoggingCategory>
@@ -312,7 +316,7 @@ public:
: QObject(parent), m_isCurrent(false), m_delayRemove(false) {}
~QQuickItemViewAttached() {}
- QQuickItemView *view() { return m_view; }
+ QQuickItemView *view() const { return m_view; }
void setView(QQuickItemView *view) {
if (view != m_view) {
m_view = view;
diff --git a/src/quick/items/qquickitemview_p_p.h b/src/quick/items/qquickitemview_p_p.h
index 0893d6e749..a8e66301c1 100644
--- a/src/quick/items/qquickitemview_p_p.h
+++ b/src/quick/items/qquickitemview_p_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <QtQuick/private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_itemview);
+
#include "qquickitemview_p.h"
#include "qquickitemviewtransition_p.h"
#include "qquickflickable_p_p.h"
@@ -205,8 +209,8 @@ public:
FxViewItem *createItem(int modelIndex, bool asynchronous = false);
virtual bool releaseItem(FxViewItem *item);
- QQuickItem *createHighlightItem();
- QQuickItem *createComponentItem(QQmlComponent *component, qreal zValue, bool createDefault = false);
+ QQuickItem *createHighlightItem() const;
+ QQuickItem *createComponentItem(QQmlComponent *component, qreal zValue, bool createDefault = false) const;
void updateCurrent(int modelIndex);
void updateTrackedItem();
diff --git a/src/quick/items/qquickitemviewtransition.cpp b/src/quick/items/qquickitemviewtransition.cpp
index 6d2421c3df..83c451613e 100644
--- a/src/quick/items/qquickitemviewtransition.cpp
+++ b/src/quick/items/qquickitemviewtransition.cpp
@@ -246,7 +246,7 @@ void QQuickItemViewTransitioner::resetTargetLists()
moveTransitionTargets.clear();
}
-QQuickTransition *QQuickItemViewTransitioner::transitionObject(QQuickItemViewTransitioner::TransitionType type, bool asTarget)
+QQuickTransition *QQuickItemViewTransitioner::transitionObject(QQuickItemViewTransitioner::TransitionType type, bool asTarget) const
{
if (type == QQuickItemViewTransitioner::NoTransition)
return 0;
diff --git a/src/quick/items/qquickitemviewtransition_p.h b/src/quick/items/qquickitemviewtransition_p.h
index 6641dada29..3d2f5361b1 100644
--- a/src/quick/items/qquickitemviewtransition_p.h
+++ b/src/quick/items/qquickitemviewtransition_p.h
@@ -52,6 +52,9 @@
//
#include <QtQuick/private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_viewtransitions);
+
#include <QtCore/qobject.h>
#include <QtCore/qpoint.h>
#include <QtQml/qqml.h>
@@ -94,7 +97,7 @@ public:
void addToTargetLists(QQuickItemViewTransitioner::TransitionType type, QQuickItemViewTransitionableItem *item, int index);
void resetTargetLists();
- QQuickTransition *transitionObject(QQuickItemViewTransitioner::TransitionType type, bool asTarget);
+ QQuickTransition *transitionObject(QQuickItemViewTransitioner::TransitionType type, bool asTarget) const;
const QList<int> &targetIndexes(QQuickItemViewTransitioner::TransitionType type) const;
const QList<QObject *> &targetItems(QQuickItemViewTransitioner::TransitionType type) const;
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index 47efecdb2d..30625c7ea8 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -1765,7 +1765,7 @@ bool QQuickListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
State should \e never be stored in a delegate.
ListView attaches a number of properties to the root item of the delegate, for example
- \c {ListView:isCurrentItem}. In the following example, the root delegate item can access
+ \c ListView.isCurrentItem. In the following example, the root delegate item can access
this attached property directly as \c ListView.isCurrentItem, while the child
\c contactInfo object must refer to this property as \c wrapper.ListView.isCurrentItem.
diff --git a/src/quick/items/qquicklistview_p.h b/src/quick/items/qquicklistview_p.h
index 5a5e8a55fe..3a871e88e9 100644
--- a/src/quick/items/qquicklistview_p.h
+++ b/src/quick/items/qquicklistview_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_listview);
+
#include "qquickitemview_p.h"
#include <private/qtquickglobal_p.h>
@@ -84,7 +88,7 @@ public:
enum LabelPositioning { InlineLabels = 0x01, CurrentLabelAtStart = 0x02, NextLabelAtEnd = 0x04 };
Q_ENUM(LabelPositioning)
- int labelPositioning() { return m_labelPositioning; }
+ int labelPositioning() const { return m_labelPositioning; }
void setLabelPositioning(int pos);
Q_SIGNALS:
diff --git a/src/quick/items/qquickloader_p_p.h b/src/quick/items/qquickloader_p_p.h
index fcccbfe4f5..a0a9ca0601 100644
--- a/src/quick/items/qquickloader_p_p.h
+++ b/src/quick/items/qquickloader_p_p.h
@@ -94,7 +94,7 @@ public:
void incubatorStateChanged(QQmlIncubator::Status status);
void setInitialState(QObject *o);
void disposeInitialPropertyValues();
- QUrl resolveSourceUrl(QQmlV4Function *args);
+ static QUrl resolveSourceUrl(QQmlV4Function *args);
QV4::ReturnedValue extractInitialPropertyValues(QQmlV4Function *args, QObject *loader, bool *error);
qreal getImplicitWidth() const Q_DECL_OVERRIDE;
diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp
index 0118d882af..6bd83dd808 100644
--- a/src/quick/items/qquickmousearea.cpp
+++ b/src/quick/items/qquickmousearea.cpp
@@ -43,6 +43,7 @@
#include "qquickdrag_p.h"
#include <private/qqmldata_p.h>
+#include <private/qsgadaptationlayer_p.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qevent.h>
@@ -672,6 +673,7 @@ void QQuickMouseArea::mousePressEvent(QMouseEvent *event)
Q_D(QQuickMouseArea);
d->moved = false;
d->stealMouse = d->preventStealing;
+ d->overThreshold = false;
if (!d->enabled || !(event->button() & acceptedMouseButtons())) {
QQuickItem::mousePressEvent(event);
} else {
@@ -957,6 +959,7 @@ bool QQuickMouseArea::sendMouseEvent(QMouseEvent *event)
if (!d->pressed) {
// no other buttons are pressed
d->stealMouse = false;
+ d->overThreshold = false;
if (c && c->mouseGrabberItem() == this)
ungrabMouse();
emit canceled();
diff --git a/src/quick/items/qquickopenglshadereffect.cpp b/src/quick/items/qquickopenglshadereffect.cpp
index b974641cca..42fcee3c0d 100644
--- a/src/quick/items/qquickopenglshadereffect.cpp
+++ b/src/quick/items/qquickopenglshadereffect.cpp
@@ -284,14 +284,14 @@ void QQuickOpenGLShaderEffectCommon::updateParseLog(bool ignoreAttributes)
parseLog.clear();
if (!ignoreAttributes) {
if (!attributes.contains(qtPositionAttributeName())) {
- parseLog += QLatin1String("Warning: Missing reference to \'");
- parseLog += QLatin1String(qtPositionAttributeName());
- parseLog += QLatin1String("\'.\n");
+ parseLog += QLatin1String("Warning: Missing reference to \'")
+ + QLatin1String(qtPositionAttributeName())
+ + QLatin1String("\'.\n");
}
if (!attributes.contains(qtTexCoordAttributeName())) {
- parseLog += QLatin1String("Warning: Missing reference to \'");
- parseLog += QLatin1String(qtTexCoordAttributeName());
- parseLog += QLatin1String("\'.\n");
+ parseLog += QLatin1String("Warning: Missing reference to \'")
+ + QLatin1String(qtTexCoordAttributeName())
+ + QLatin1String("\'.\n");
}
}
bool respectsMatrix = false;
@@ -918,9 +918,7 @@ QSGNode *QQuickOpenGLShaderEffect::handleUpdatePaintNode(QSGNode *oldNode, QQuic
if (!mesh->validateAttributes(m_common.attributes, &posIndex)) {
QString log = mesh->log();
if (!log.isNull()) {
- m_log = parseLog();
- m_log += QLatin1String("*** Mesh ***\n");
- m_log += log;
+ m_log = parseLog() + QLatin1String("*** Mesh ***\n") + log;
m_status = QQuickShaderEffect::Error;
emit m_item->logChanged();
emit m_item->statusChanged();
diff --git a/src/quick/items/qquickopenglshadereffect_p.h b/src/quick/items/qquickopenglshadereffect_p.h
index ed56a76409..64e79a9343 100644
--- a/src/quick/items/qquickopenglshadereffect_p.h
+++ b/src/quick/items/qquickopenglshadereffect_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_shadereffect);
+
#include <QtQuick/qquickitem.h>
#include <QtQuick/qsgmaterial.h>
diff --git a/src/quick/items/qquickopenglshadereffectnode.cpp b/src/quick/items/qquickopenglshadereffectnode.cpp
index 02b76b2dbc..e01ecc59e3 100644
--- a/src/quick/items/qquickopenglshadereffectnode.cpp
+++ b/src/quick/items/qquickopenglshadereffectnode.cpp
@@ -261,13 +261,11 @@ void QQuickCustomMaterialShader::compile()
m_log.clear();
m_compiled = true;
if (!program()->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShader())) {
- m_log += QLatin1String("*** Vertex shader ***\n");
- m_log += program()->log();
+ m_log += QLatin1String("*** Vertex shader ***\n") + program()->log();
m_compiled = false;
}
if (!program()->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShader())) {
- m_log += QLatin1String("*** Fragment shader ***\n");
- m_log += program()->log();
+ m_log += QLatin1String("*** Fragment shader ***\n") + program()->log();
m_compiled = false;
}
diff --git a/src/quick/items/qquickopenglshadereffectnode_p.h b/src/quick/items/qquickopenglshadereffectnode_p.h
index 5abe3ae3d0..aea28e6612 100644
--- a/src/quick/items/qquickopenglshadereffectnode_p.h
+++ b/src/quick/items/qquickopenglshadereffectnode_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_shadereffect);
+
#include <QtQuick/qsgnode.h>
#include <QtQuick/qsgmaterial.h>
#include <QtQuick/qsgtextureprovider.h>
diff --git a/src/quick/items/qquickpainteditem.cpp b/src/quick/items/qquickpainteditem.cpp
index d21eb93dbf..e565fceab8 100644
--- a/src/quick/items/qquickpainteditem.cpp
+++ b/src/quick/items/qquickpainteditem.cpp
@@ -43,6 +43,7 @@
#include <QtQuick/private/qsgdefaultpainternode_p.h>
#include <QtQuick/private/qsgcontext_p.h>
#include <private/qsgadaptationlayer_p.h>
+#include <qsgtextureprovider.h>
#include <qmath.h>
@@ -52,7 +53,7 @@ class QQuickPaintedItemTextureProvider : public QSGTextureProvider
{
public:
QSGPainterNode *node;
- QSGTexture *texture() const { return node ? node->texture() : 0; }
+ QSGTexture *texture() const override { return node ? node->texture() : 0; }
void fireTextureChanged() { emit textureChanged(); }
};
diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp
index e54ee66fe5..11881ae0ab 100644
--- a/src/quick/items/qquickpathview.cpp
+++ b/src/quick/items/qquickpathview.cpp
@@ -63,13 +63,7 @@ Q_DECLARE_LOGGING_CATEGORY(lcItemViewDelegateLifecycle)
const qreal MinimumFlickVelocity = 75.0;
-inline qreal qmlMod(qreal x, qreal y)
-{
- using std::fmod;
- return fmod(x, y);
-}
-
-static QQmlOpenMetaObjectType *qPathViewAttachedType = 0;
+static QQmlOpenMetaObjectType *qPathViewAttachedType = nullptr;
QQuickPathViewAttached::QQuickPathViewAttached(QObject *parent)
: QObject(parent), m_percent(-1), m_view(0), m_onPath(false), m_isCurrent(false)
@@ -96,7 +90,7 @@ void QQuickPathViewAttached::setValue(const QByteArray &name, const QVariant &va
}
QQuickPathViewPrivate::QQuickPathViewPrivate()
- : path(0), currentIndex(0), currentItemOffset(0.0), startPc(0)
+ : path(nullptr), currentIndex(0), currentItemOffset(0.0), startPc(0)
, offset(0.0), offsetAdj(0.0), mappedRange(1.0), mappedCache(0.0)
, stealMouse(false), ownModel(false), interactive(true), haveHighlightRange(true)
, autoHighlight(true), highlightUp(false), layoutScheduled(false)
@@ -106,7 +100,7 @@ QQuickPathViewPrivate::QQuickPathViewPrivate()
, moveOffset(this, &QQuickPathViewPrivate::setAdjustedOffset), flickDuration(0)
, pathItems(-1), requestedIndex(-1), cacheSize(0), requestedZ(0)
, moveReason(Other), movementDirection(QQuickPathView::Shortest), moveDirection(QQuickPathView::Shortest)
- , attType(0), highlightComponent(0), highlightItem(0)
+ , attType(nullptr), highlightComponent(nullptr), highlightItem(nullptr)
, moveHighlight(this, &QQuickPathViewPrivate::setHighlightPosition)
, highlightPosition(0)
, highlightRangeStart(0), highlightRangeEnd(0)
@@ -163,7 +157,7 @@ void QQuickPathView::createdItem(int index, QObject *object)
if (d->requestedIndex != index) {
qPathViewAttachedType = d->attachedType();
QQuickPathViewAttached *att = static_cast<QQuickPathViewAttached *>(qmlAttachedPropertiesObject<QQuickPathView>(item));
- qPathViewAttachedType = 0;
+ qPathViewAttachedType = nullptr;
if (att) {
att->m_view = this;
att->setOnPath(false);
@@ -186,7 +180,7 @@ void QQuickPathView::initItem(int index, QObject *object)
item->setParentItem(this);
qPathViewAttachedType = d->attachedType();
QQuickPathViewAttached *att = static_cast<QQuickPathViewAttached *>(qmlAttachedPropertiesObject<QQuickPathView>(item));
- qPathViewAttachedType = 0;
+ qPathViewAttachedType = nullptr;
if (att) {
att->m_view = this;
qreal percent = d->positionOfIndex(index);
@@ -215,7 +209,7 @@ void QQuickPathViewPrivate::releaseItem(QQuickItem *item)
att->setOnPath(false);
} else if (flags & QQmlInstanceModel::Destroyed) {
// but we still reference it
- item->setParentItem(0);
+ item->setParentItem(nullptr);
}
}
@@ -244,7 +238,7 @@ void QQuickPathViewPrivate::clear()
{
if (currentItem) {
releaseItem(currentItem);
- currentItem = 0;
+ currentItem = nullptr;
}
for (QQuickItem *p : qAsConst(items))
releaseItem(p);
@@ -280,13 +274,13 @@ qreal QQuickPathViewPrivate::positionOfIndex(qreal index) const
|| snapMode != QQuickPathView::NoSnap))
start = highlightRangeStart;
qreal globalPos = index + offset;
- globalPos = qmlMod(globalPos, qreal(modelCount)) / modelCount;
+ globalPos = std::fmod(globalPos, qreal(modelCount)) / modelCount;
if (pathItems != -1 && pathItems < modelCount) {
globalPos += start / mappedRange;
- globalPos = qmlMod(globalPos, 1.0);
+ globalPos = std::fmod(globalPos, qreal(1.0));
pos = globalPos * mappedRange;
} else {
- pos = qmlMod(globalPos + start, 1.0);
+ pos = std::fmod(globalPos + start, qreal(1.0));
}
}
@@ -315,13 +309,13 @@ void QQuickPathViewPrivate::createHighlight()
bool changed = false;
if (highlightItem) {
- highlightItem->setParentItem(0);
+ highlightItem->setParentItem(nullptr);
highlightItem->deleteLater();
- highlightItem = 0;
+ highlightItem = nullptr;
changed = true;
}
- QQuickItem *item = 0;
+ QQuickItem *item = nullptr;
if (highlightComponent) {
QQmlContext *creationContext = highlightComponent->creationContext();
QQmlContext *highlightContext = new QQmlContext(
@@ -397,7 +391,7 @@ void QQuickPathViewPrivate::setHighlightPosition(qreal pos)
qreal range = qreal(modelCount);
// calc normalized position of highlight relative to offset
- qreal relativeHighlight = qmlMod(pos + offset, range) / range;
+ qreal relativeHighlight = std::fmod(pos + offset, range) / range;
if (!highlightUp && relativeHighlight > end / mappedRange) {
qreal diff = 1.0 - relativeHighlight;
@@ -636,7 +630,7 @@ void QQuickPathView::setModel(const QVariant &m)
d->modelVariant = model;
QObject *object = qvariant_cast<QObject*>(model);
- QQmlInstanceModel *vim = 0;
+ QQmlInstanceModel *vim = nullptr;
if (object && (vim = qobject_cast<QQmlInstanceModel *>(object))) {
if (d->ownModel) {
delete d->model;
@@ -716,7 +710,7 @@ void QQuickPathView::setPath(QQuickPath *path)
d->clear();
if (d->attType) {
d->attType->release();
- d->attType = 0;
+ d->attType = nullptr;
}
d->regenerate();
}
@@ -755,7 +749,7 @@ void QQuickPathView::setCurrentIndex(int idx)
}
int oldCurrentIdx = d->currentIndex;
QQuickItem *oldCurrentItem = d->currentItem;
- d->currentItem = 0;
+ d->currentItem = nullptr;
d->moveReason = QQuickPathViewPrivate::SetIndex;
d->currentIndex = idx;
if (d->modelCount) {
@@ -836,7 +830,7 @@ void QQuickPathViewPrivate::setOffset(qreal o)
if (offset != o) {
if (isValid() && q->isComponentComplete()) {
qreal oldOffset = offset;
- offset = qmlMod(o, qreal(modelCount));
+ offset = std::fmod(o, qreal(modelCount));
if (offset < 0)
offset += qreal(modelCount);
qCDebug(lcItemViewDelegateLifecycle) << o << "was" << oldOffset << "now" << offset;
@@ -902,7 +896,7 @@ void QQuickPathView::setHighlight(QQmlComponent *highlight)
\sa highlight
*/
-QQuickItem *QQuickPathView::highlightItem()
+QQuickItem *QQuickPathView::highlightItem() const
{
Q_D(const QQuickPathView);
return d->highlightItem;
@@ -1237,7 +1231,7 @@ QQmlComponent *QQuickPathView::delegate() const
return dataModel->delegate();
}
- return 0;
+ return nullptr;
}
void QQuickPathView::setDelegate(QQmlComponent *delegate)
@@ -1468,7 +1462,7 @@ void QQuickPathView::positionViewAtIndex(int index, int mode)
// Small offset since the last point coincides with the first and
// this the only "end" position that gives the expected visual result.
qreal adj = sizeof(qreal) == sizeof(float) ? 0.00001f : 0.000000000001;
- endOffset = qmlMod(beginOffset + count, d->modelCount) - adj;
+ endOffset = std::fmod(beginOffset + count, qreal(d->modelCount)) - adj;
}
qreal offset = d->offset;
switch (mode) {
@@ -1489,8 +1483,8 @@ void QQuickPathView::positionViewAtIndex(int index, int mode)
case Contain:
if ((beginOffset < endOffset && (d->offset < beginOffset || d->offset > endOffset))
|| (d->offset < beginOffset && d->offset > endOffset)) {
- qreal diff1 = qmlMod(beginOffset - d->offset + d->modelCount, d->modelCount);
- qreal diff2 = qmlMod(d->offset - endOffset + d->modelCount, d->modelCount);
+ qreal diff1 = std::fmod(beginOffset - d->offset + d->modelCount, qreal(d->modelCount));
+ qreal diff2 = std::fmod(d->offset - endOffset + d->modelCount, qreal(d->modelCount));
if (diff1 < diff2)
offset = beginOffset;
else
@@ -1518,7 +1512,7 @@ int QQuickPathView::indexAt(qreal x, qreal y) const
{
Q_D(const QQuickPathView);
QQuickItem *item = itemAt(x, y);
- return item ? d->model->indexOf(item, 0) : -1;
+ return item ? d->model->indexOf(item, nullptr) : -1;
}
/*!
@@ -1533,7 +1527,7 @@ QQuickItem *QQuickPathView::itemAt(qreal x, qreal y) const
{
Q_D(const QQuickPathView);
if (!d->isValid())
- return 0;
+ return nullptr;
for (QQuickItem *item : d->items) {
QPointF p = item->mapFromItem(this, QPointF(x, y));
@@ -1541,7 +1535,7 @@ QQuickItem *QQuickPathView::itemAt(qreal x, qreal y) const
return item;
}
- return 0;
+ return nullptr;
}
QPointF QQuickPathViewPrivate::pointNear(const QPointF &point, qreal *nearPercent) const
@@ -1606,7 +1600,7 @@ qreal QQuickPathViewPrivate::calcVelocity() const
return velocity;
}
-qint64 QQuickPathViewPrivate::computeCurrentTime(QInputEvent *event)
+qint64 QQuickPathViewPrivate::computeCurrentTime(QInputEvent *event) const
{
if (0 != event->timestamp())
return event->timestamp();
@@ -1810,7 +1804,7 @@ bool QQuickPathView::sendMouseEvent(QMouseEvent *event)
QPointF localPos = mapFromScene(event->windowPos());
QQuickWindow *c = window();
- QQuickItem *grabber = c ? c->mouseGrabberItem() : 0;
+ QQuickItem *grabber = c ? c->mouseGrabberItem() : nullptr;
if (grabber == this && d->stealMouse) {
// we are already the grabber and we do want the mouse event to ourselves.
return true;
@@ -1836,7 +1830,7 @@ bool QQuickPathView::sendMouseEvent(QMouseEvent *event)
default:
break;
}
- grabber = c ? c->mouseGrabberItem() : 0;
+ grabber = c ? c->mouseGrabberItem() : nullptr;
if ((grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this) || grabberDisabled) {
grabMouse();
}
@@ -1915,7 +1909,7 @@ void QQuickPathView::componentComplete()
if (d->model) {
d->modelCount = d->model->count();
if (d->modelCount && d->currentIndex != 0) // an initial value has been provided for currentIndex
- d->offset = qmlMod(d->modelCount - currentIndexRemainder(d->currentIndex, d->modelCount), d->modelCount);
+ d->offset = std::fmod(qreal(d->modelCount - currentIndexRemainder(d->currentIndex, d->modelCount)), qreal(d->modelCount));
}
d->createHighlight();
@@ -1951,7 +1945,7 @@ void QQuickPathView::refill()
QList<QQuickItem*>::iterator it = d->items.begin();
while (it != d->items.end()) {
QQuickItem *item = *it;
- int idx = d->model->indexOf(item, 0);
+ int idx = d->model->indexOf(item, nullptr);
qreal pos = d->positionOfIndex(idx);
if (lcItemViewDelegateLifecycle().isDebugEnabled()) {
QQuickText *text = qmlobject_cast<QQuickText*>(item);
@@ -1996,7 +1990,7 @@ void QQuickPathView::refill()
startPos = 2.0;
for (QQuickItem * item : qAsConst(d->items)) {
- int idx = d->model->indexOf(item, 0);
+ int idx = d->model->indexOf(item, nullptr);
qreal curPos = d->positionOfIndex(idx);
if (curPos > endPos) {
endPos = curPos;
@@ -2198,7 +2192,7 @@ void QQuickPathView::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
if (QQuickPathViewAttached *att = d->attached(d->currentItem))
att->setIsCurrentItem(true);
d->releaseItem(d->currentItem);
- d->currentItem = 0;
+ d->currentItem = nullptr;
}
d->currentIndex = qMin(r.index, d->modelCount - r.count - 1);
currentChanged = true;
@@ -2231,7 +2225,7 @@ void QQuickPathView::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
d->modelCount += i.count;
}
- d->offset = qmlMod(d->offset, d->modelCount);
+ d->offset = std::fmod(d->offset, qreal(d->modelCount));
if (d->offset < 0)
d->offset += d->modelCount;
if (d->currentIndex == -1)
@@ -2249,7 +2243,7 @@ void QQuickPathView::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
d->tl.reset(d->moveOffset);
} else {
if (!d->flicking && !d->moving && d->haveHighlightRange && d->highlightRangeMode == QQuickPathView::StrictlyEnforceRange) {
- d->offset = qmlMod(d->modelCount - d->currentIndex, d->modelCount);
+ d->offset = std::fmod(qreal(d->modelCount - d->currentIndex), qreal(d->modelCount));
changedOffset = true;
}
d->updateMappedRange();
@@ -2295,10 +2289,10 @@ int QQuickPathViewPrivate::calcCurrentIndex()
{
int current = 0;
if (modelCount && model && items.count()) {
- offset = qmlMod(offset, modelCount);
+ offset = std::fmod(offset, qreal(modelCount));
if (offset < 0)
offset += modelCount;
- current = qRound(qAbs(qmlMod(modelCount - offset, modelCount)));
+ current = qRound(qAbs(std::fmod(modelCount - offset, qreal(modelCount))));
current = current % modelCount;
}
@@ -2312,7 +2306,7 @@ void QQuickPathViewPrivate::createCurrentItem()
bool inItems = false;
for (QQuickItem *item : qAsConst(items)) {
- if (model->indexOf(item, 0) == currentIndex) {
+ if (model->indexOf(item, nullptr) == currentIndex) {
inItems = true;
break;
}
@@ -2350,7 +2344,7 @@ void QQuickPathViewPrivate::updateCurrent()
}
int oldCurrentIndex = currentIndex;
currentIndex = idx;
- currentItem = 0;
+ currentItem = nullptr;
createCurrentItem();
if (oldCurrentIndex != currentIndex)
emit q->currentIndexChanged();
@@ -2383,7 +2377,7 @@ void QQuickPathViewPrivate::snapToIndex(int index, MovementReason reason)
if (!model || modelCount <= 0)
return;
- qreal targetOffset = qmlMod(modelCount - index, modelCount);
+ qreal targetOffset = std::fmod(qreal(modelCount - index), qreal(modelCount));
if (offset == targetOffset)
return;
diff --git a/src/quick/items/qquickpathview_p.h b/src/quick/items/qquickpathview_p.h
index bdd56b6311..669ef60ef7 100644
--- a/src/quick/items/qquickpathview_p.h
+++ b/src/quick/items/qquickpathview_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_pathview);
+
#include "qquickitem.h"
#include <private/qtquickglobal_p.h>
@@ -98,7 +102,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathView : public QQuickItem
Q_PROPERTY(int cacheItemCount READ cacheItemCount WRITE setCacheItemCount NOTIFY cacheItemCountChanged)
public:
- QQuickPathView(QQuickItem *parent=0);
+ QQuickPathView(QQuickItem *parent = nullptr);
virtual ~QQuickPathView();
QVariant model() const;
@@ -117,7 +121,7 @@ public:
QQmlComponent *highlight() const;
void setHighlight(QQmlComponent *highlight);
- QQuickItem *highlightItem();
+ QQuickItem *highlightItem() const;
enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange };
Q_ENUM(HighlightRangeMode)
@@ -255,7 +259,7 @@ public:
QQuickPathViewAttached(QObject *parent);
~QQuickPathViewAttached();
- QQuickPathView *view() { return m_view; }
+ QQuickPathView *view() const { return m_view; }
bool isCurrentItem() const { return m_isCurrent; }
void setIsCurrentItem(bool c) {
diff --git a/src/quick/items/qquickpathview_p_p.h b/src/quick/items/qquickpathview_p_p.h
index 0441603a4b..082f427f2c 100644
--- a/src/quick/items/qquickpathview_p_p.h
+++ b/src/quick/items/qquickpathview_p_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_pathview);
+
#include "qquickpathview_p.h"
#include "qquickitem_p.h"
@@ -125,7 +129,7 @@ public:
QPointF pointNear(const QPointF &point, qreal *nearPercent=0) const;
void addVelocitySample(qreal v);
qreal calcVelocity() const;
- qint64 computeCurrentTime(QInputEvent *event);
+ qint64 computeCurrentTime(QInputEvent *event) const;
void setDragging(bool d);
QQuickPath *path;
diff --git a/src/quick/items/qquickpositioners.cpp b/src/quick/items/qquickpositioners.cpp
index 38e89e78eb..e22427ca49 100644
--- a/src/quick/items/qquickpositioners.cpp
+++ b/src/quick/items/qquickpositioners.cpp
@@ -872,7 +872,7 @@ void QQuickPositionerAttached::setIsLastItem(bool isLastItem)
the item that is being added. See the \l ViewTransition documentation for more details
and examples on using these transitions.
- \note This transition is not applied to the items that already part of the positioner
+ \note This transition is not applied to the items that are already part of the positioner
at the time of its creation. In this case, the \l populate transition is applied instead.
\sa populate, ViewTransition, {Qt Quick Examples - Positioners}
@@ -1039,7 +1039,7 @@ void QQuickColumn::reportConflictingAnchors()
the item that is being added. See the \l ViewTransition documentation for more details
and examples on using these transitions.
- \note This transition is not applied to the items that already part of the positioner
+ \note This transition is not applied to the items that are already part of the positioner
at the time of its creation. In this case, the \l populate transition is applied instead.
\sa populate, ViewTransition, {Qt Quick Examples - Positioners}
@@ -1307,7 +1307,7 @@ void QQuickRow::reportConflictingAnchors()
the item that is being added. See the \l ViewTransition documentation for more details
and examples on using these transitions.
- \note This transition is not applied to the items that already part of the positioner
+ \note This transition is not applied to the items that are already part of the positioner
at the time of its creation. In this case, the \l populate transition is applied instead.
\sa populate, ViewTransition, {Qt Quick Examples - Positioners}
@@ -1882,7 +1882,7 @@ void QQuickGrid::reportConflictingAnchors()
the item that is being added. See the \l ViewTransition documentation for more details
and examples on using these transitions.
- \note This transition is not applied to the items that already part of the positioner
+ \note This transition is not applied to the items that are already part of the positioner
at the time of its creation. In this case, the \l populate transition is applied instead.
\sa populate, ViewTransition, {Qt Quick Examples - Positioners}
diff --git a/src/quick/items/qquickpositioners_p.h b/src/quick/items/qquickpositioners_p.h
index f6388f111d..c25ecd6dbc 100644
--- a/src/quick/items/qquickpositioners_p.h
+++ b/src/quick/items/qquickpositioners_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <QtQuick/private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_positioners);
+
#include "qquickimplicitsizeitem_p.h"
#include "qquickitemviewtransition_p.h"
diff --git a/src/quick/items/qquickpositioners_p_p.h b/src/quick/items/qquickpositioners_p_p.h
index d18f9b3724..6dd84e6098 100644
--- a/src/quick/items/qquickpositioners_p_p.h
+++ b/src/quick/items/qquickpositioners_p_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <QtQuick/private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_positioners);
+
#include "qquickpositioners_p.h"
#include "qquickimplicitsizeitem_p_p.h"
diff --git a/src/quick/items/qquickrectangle.cpp b/src/quick/items/qquickrectangle.cpp
index 9e747f2c47..7ba2421d62 100644
--- a/src/quick/items/qquickrectangle.cpp
+++ b/src/quick/items/qquickrectangle.cpp
@@ -365,7 +365,7 @@ QQuickPen *QQuickRectangle::border()
The gradient to use to fill the rectangle.
This property allows for the construction of simple vertical gradients.
- Other gradients may by formed by adding rotation to the rectangle.
+ Other gradients may be formed by adding rotation to the rectangle.
\div {class="float-left"}
\inlineimage declarative-rect_gradient.png
diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp
index 8b69447002..74aa2da9e0 100644
--- a/src/quick/items/qquickrendercontrol.cpp
+++ b/src/quick/items/qquickrendercontrol.cpp
@@ -47,8 +47,10 @@
#ifndef QT_NO_OPENGL
# include <QtGui/QOpenGLContext>
# include <QtQuick/private/qsgdefaultrendercontext_p.h>
+#if QT_CONFIG(quick_shadereffect)
# include <QtQuick/private/qquickopenglshadereffectnode_p.h>
#endif
+#endif
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
@@ -190,7 +192,7 @@ void QQuickRenderControlPrivate::windowDestroyed()
delete QQuickWindowPrivate::get(window)->animationController;
QQuickWindowPrivate::get(window)->animationController = 0;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
QQuickOpenGLShaderEffectMaterial::cleanupMaterialCache();
#endif
diff --git a/src/quick/items/qquickscreen.cpp b/src/quick/items/qquickscreen.cpp
index 5d01a2af9d..9347b55c70 100644
--- a/src/quick/items/qquickscreen.cpp
+++ b/src/quick/items/qquickscreen.cpp
@@ -207,100 +207,181 @@ QT_BEGIN_NAMESPACE
By default it is set to the value of the QScreen that the window uses.
*/
-QQuickScreenAttached::QQuickScreenAttached(QObject* attachee)
- : QObject(attachee)
- , m_screen(NULL)
- , m_window(NULL)
- , m_updateMask(0)
- , m_updateMaskSet(false)
+QQuickScreenInfo::QQuickScreenInfo(QObject *parent)
+ : QObject(parent),
+ m_screen(nullptr)
{
- m_attachee = qobject_cast<QQuickItem*>(attachee);
-
- if (m_attachee) {
- QQuickItemPrivate::get(m_attachee)->extra.value().screenAttached = this;
-
- if (m_attachee->window()) //It might not be assigned to a window yet
- windowChanged(m_attachee->window());
- } else {
- QQuickWindow *window = qobject_cast<QQuickWindow*>(attachee);
- if (window)
- windowChanged(window);
- }
-
- if (!m_screen)
- screenChanged(QGuiApplication::primaryScreen());
}
-QString QQuickScreenAttached::name() const
+QString QQuickScreenInfo::name() const
{
if (!m_screen)
return QString();
return m_screen->name();
}
-int QQuickScreenAttached::width() const
+int QQuickScreenInfo::width() const
{
if (!m_screen)
return 0;
return m_screen->size().width();
}
-int QQuickScreenAttached::height() const
+int QQuickScreenInfo::height() const
{
if (!m_screen)
return 0;
return m_screen->size().height();
}
-int QQuickScreenAttached::desktopAvailableWidth() const
+int QQuickScreenInfo::desktopAvailableWidth() const
{
if (!m_screen)
return 0;
return m_screen->availableVirtualSize().width();
}
-int QQuickScreenAttached::desktopAvailableHeight() const
+int QQuickScreenInfo::desktopAvailableHeight() const
{
if (!m_screen)
return 0;
return m_screen->availableVirtualSize().height();
}
-qreal QQuickScreenAttached::logicalPixelDensity() const
+qreal QQuickScreenInfo::logicalPixelDensity() const
{
if (!m_screen)
return 0.0;
return m_screen->logicalDotsPerInch() / 25.4;
}
-qreal QQuickScreenAttached::pixelDensity() const
+qreal QQuickScreenInfo::pixelDensity() const
{
if (!m_screen)
return 0.0;
return m_screen->physicalDotsPerInch() / 25.4;
}
-qreal QQuickScreenAttached::devicePixelRatio() const
+qreal QQuickScreenInfo::devicePixelRatio() const
{
if (!m_screen)
return 1.0;
return m_screen->devicePixelRatio();
}
-Qt::ScreenOrientation QQuickScreenAttached::primaryOrientation() const
+Qt::ScreenOrientation QQuickScreenInfo::primaryOrientation() const
{
if (!m_screen)
return Qt::PrimaryOrientation;
return m_screen->primaryOrientation();
}
-Qt::ScreenOrientation QQuickScreenAttached::orientation() const
+Qt::ScreenOrientation QQuickScreenInfo::orientation() const
{
if (!m_screen)
return Qt::PrimaryOrientation;
return m_screen->orientation();
}
+int QQuickScreenInfo::virtualX() const
+{
+ if (!m_screen)
+ return 0;
+ return m_screen->geometry().topLeft().x();
+}
+
+int QQuickScreenInfo::virtualY() const
+{
+ if (!m_screen)
+ return 0;
+ return m_screen->geometry().topLeft().y();
+}
+
+void QQuickScreenInfo::setWrappedScreen(QScreen *screen)
+{
+ if (screen == m_screen)
+ return;
+
+ QScreen *oldScreen = m_screen;
+ m_screen = screen;
+
+ if (oldScreen)
+ oldScreen->disconnect(this);
+
+ if (!screen) //Don't bother emitting signals, because the new values are garbage anyways
+ return;
+
+ if (!oldScreen || screen->geometry() != oldScreen->geometry()) {
+ emit virtualXChanged();
+ emit virtualYChanged();
+ }
+ if (!oldScreen || screen->size() != oldScreen->size()) {
+ emit widthChanged();
+ emit heightChanged();
+ }
+ if (!oldScreen || screen->name() != oldScreen->name())
+ emit nameChanged();
+ if (!oldScreen || screen->orientation() != oldScreen->orientation())
+ emit orientationChanged();
+ if (!oldScreen || screen->primaryOrientation() != oldScreen->primaryOrientation())
+ emit primaryOrientationChanged();
+ if (!oldScreen || screen->availableVirtualGeometry() != oldScreen->availableVirtualGeometry())
+ emit desktopGeometryChanged();
+ if (!oldScreen || screen->logicalDotsPerInch() != oldScreen->logicalDotsPerInch())
+ emit logicalPixelDensityChanged();
+ if (!oldScreen || screen->physicalDotsPerInch() != oldScreen->physicalDotsPerInch())
+ emit pixelDensityChanged();
+ if (!oldScreen || screen->devicePixelRatio() != oldScreen->devicePixelRatio())
+ emit devicePixelRatioChanged();
+
+ connect(screen, SIGNAL(geometryChanged(QRect)),
+ this, SIGNAL(widthChanged()));
+ connect(screen, SIGNAL(geometryChanged(QRect)),
+ this, SIGNAL(heightChanged()));
+ connect(screen, SIGNAL(geometryChanged(QRect)),
+ this, SIGNAL(virtualXChanged()));
+ connect(screen, SIGNAL(geometryChanged(QRect)),
+ this, SIGNAL(virtualYChanged()));
+ connect(screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)),
+ this, SIGNAL(orientationChanged()));
+ connect(screen, SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)),
+ this, SIGNAL(primaryOrientationChanged()));
+ connect(screen, SIGNAL(virtualGeometryChanged(QRect)),
+ this, SIGNAL(desktopGeometryChanged()));
+ connect(screen, SIGNAL(logicalDotsPerInchChanged(qreal)),
+ this, SIGNAL(logicalPixelDensityChanged()));
+ connect(screen, SIGNAL(physicalDotsPerInchChanged(qreal)),
+ this, SIGNAL(pixelDensityChanged()));
+}
+
+QScreen *QQuickScreenInfo::wrappedScreen() const
+{
+ return m_screen;
+}
+
+QQuickScreenAttached::QQuickScreenAttached(QObject* attachee)
+ : QQuickScreenInfo(attachee)
+ , m_window(NULL)
+ , m_updateMask(0)
+ , m_updateMaskSet(false)
+{
+ m_attachee = qobject_cast<QQuickItem*>(attachee);
+
+ if (m_attachee) {
+ QQuickItemPrivate::get(m_attachee)->extra.value().screenAttached = this;
+
+ if (m_attachee->window()) //It might not be assigned to a window yet
+ windowChanged(m_attachee->window());
+ } else {
+ QQuickWindow *window = qobject_cast<QQuickWindow*>(attachee);
+ if (window)
+ windowChanged(window);
+ }
+
+ if (!m_screen)
+ screenChanged(QGuiApplication::primaryScreen());
+}
+
Qt::ScreenOrientations QQuickScreenAttached::orientationUpdateMask() const
{
return m_updateMask;
@@ -341,55 +422,15 @@ void QQuickScreenAttached::screenChanged(QScreen *screen)
{
//qDebug() << "QQuickScreenAttached::screenChanged" << (screen ? screen->name() : QString::fromLatin1("null"));
if (screen != m_screen) {
- QScreen* oldScreen = m_screen;
- m_screen = screen;
-
- if (oldScreen)
- oldScreen->disconnect(this);
-
- if (!screen)
- return; //Don't bother emitting signals, because the new values are garbage anyways
-
+ setWrappedScreen(screen);
+ if (!m_screen)
+ return;
if (m_updateMaskSet) {
- screen->setOrientationUpdateMask(m_updateMask);
- } else if (m_updateMask != screen->orientationUpdateMask()) {
- m_updateMask = screen->orientationUpdateMask();
+ m_screen->setOrientationUpdateMask(m_updateMask);
+ } else if (m_updateMask != m_screen->orientationUpdateMask()) {
+ m_updateMask = m_screen->orientationUpdateMask();
emit orientationUpdateMaskChanged();
}
-
- if (!oldScreen || screen->size() != oldScreen->size()) {
- emit widthChanged();
- emit heightChanged();
- }
- if (!oldScreen || screen->name() != oldScreen->name())
- emit nameChanged();
- if (!oldScreen || screen->orientation() != oldScreen->orientation())
- emit orientationChanged();
- if (!oldScreen || screen->primaryOrientation() != oldScreen->primaryOrientation())
- emit primaryOrientationChanged();
- if (!oldScreen || screen->availableVirtualGeometry() != oldScreen->availableVirtualGeometry())
- emit desktopGeometryChanged();
- if (!oldScreen || screen->logicalDotsPerInch() != oldScreen->logicalDotsPerInch())
- emit logicalPixelDensityChanged();
- if (!oldScreen || screen->physicalDotsPerInch() != oldScreen->physicalDotsPerInch())
- emit pixelDensityChanged();
- if (!oldScreen || screen->devicePixelRatio() != oldScreen->devicePixelRatio())
- emit devicePixelRatioChanged();
-
- connect(screen, SIGNAL(geometryChanged(QRect)),
- this, SIGNAL(widthChanged()));
- connect(screen, SIGNAL(geometryChanged(QRect)),
- this, SIGNAL(heightChanged()));
- connect(screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)),
- this, SIGNAL(orientationChanged()));
- connect(screen, SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)),
- this, SIGNAL(primaryOrientationChanged()));
- connect(screen, SIGNAL(virtualGeometryChanged(QRect)),
- this, SIGNAL(desktopGeometryChanged()));
- connect(screen, SIGNAL(logicalDotsPerInchChanged(qreal)),
- this, SIGNAL(logicalPixelDensityChanged()));
- connect(screen, SIGNAL(physicalDotsPerInchChanged(qreal)),
- this, SIGNAL(pixelDensityChanged()));
}
}
diff --git a/src/quick/items/qquickscreen_p.h b/src/quick/items/qquickscreen_p.h
index 06d9a06070..06efb3ab45 100644
--- a/src/quick/items/qquickscreen_p.h
+++ b/src/quick/items/qquickscreen_p.h
@@ -63,10 +63,10 @@ class QQuickItem;
class QQuickWindow;
class QScreen;
-class Q_AUTOTEST_EXPORT QQuickScreenAttached : public QObject
+
+class Q_AUTOTEST_EXPORT QQuickScreenInfo : public QObject
{
Q_OBJECT
-
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(int width READ width NOTIFY widthChanged)
Q_PROPERTY(int height READ height NOTIFY heightChanged)
@@ -79,11 +79,12 @@ class Q_AUTOTEST_EXPORT QQuickScreenAttached : public QObject
Q_PROPERTY(Qt::ScreenOrientation primaryOrientation READ primaryOrientation NOTIFY primaryOrientationChanged)
// TODO Qt 6 Remove this orientation -> incomplete device orientation -> better use OrientationSensor
Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation NOTIFY orientationChanged)
- Q_PROPERTY(Qt::ScreenOrientations orientationUpdateMask READ orientationUpdateMask
- WRITE setOrientationUpdateMask NOTIFY orientationUpdateMaskChanged)
+
+ Q_PROPERTY(int virtualX READ virtualX NOTIFY virtualXChanged REVISION 1)
+ Q_PROPERTY(int virtualY READ virtualY NOTIFY virtualYChanged REVISION 1)
public:
- QQuickScreenAttached(QObject* attachee);
+ QQuickScreenInfo(QObject *parent = nullptr);
QString name() const;
int width() const;
@@ -95,13 +96,11 @@ public:
qreal devicePixelRatio() const;
Qt::ScreenOrientation primaryOrientation() const;
Qt::ScreenOrientation orientation() const;
- Qt::ScreenOrientations orientationUpdateMask() const;
- void setOrientationUpdateMask(Qt::ScreenOrientations mask);
+ int virtualX() const;
+ int virtualY() const;
- //Treats int as Qt::ScreenOrientation, due to QTBUG-20639
- Q_INVOKABLE int angleBetween(int a, int b);
-
- void windowChanged(QQuickWindow*);
+ void setWrappedScreen(QScreen *screen);
+ QScreen *wrappedScreen() const;
Q_SIGNALS:
void nameChanged();
@@ -113,13 +112,37 @@ Q_SIGNALS:
void devicePixelRatioChanged();
void primaryOrientationChanged();
void orientationChanged();
+ Q_REVISION(1) void virtualXChanged();
+ Q_REVISION(1) void virtualYChanged();
+
+protected:
+ QPointer<QScreen> m_screen;
+};
+
+class Q_AUTOTEST_EXPORT QQuickScreenAttached : public QQuickScreenInfo
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt::ScreenOrientations orientationUpdateMask READ orientationUpdateMask
+ WRITE setOrientationUpdateMask NOTIFY orientationUpdateMaskChanged)
+
+public:
+ QQuickScreenAttached(QObject* attachee);
+
+ Qt::ScreenOrientations orientationUpdateMask() const;
+ void setOrientationUpdateMask(Qt::ScreenOrientations mask);
+
+ //Treats int as Qt::ScreenOrientation, due to QTBUG-20639
+ Q_INVOKABLE int angleBetween(int a, int b);
+
+ void windowChanged(QQuickWindow*);
+
+Q_SIGNALS:
void orientationUpdateMaskChanged();
protected Q_SLOTS:
void screenChanged(QScreen*);
private:
- QPointer<QScreen> m_screen;
QQuickWindow* m_window;
QQuickItem* m_attachee;
Qt::ScreenOrientations m_updateMask;
@@ -136,5 +159,6 @@ public:
QT_END_NAMESPACE
QML_DECLARE_TYPEINFO(QQuickScreen, QML_HAS_ATTACHED_PROPERTIES)
+QML_DECLARE_TYPE(QQuickScreenInfo)
#endif
diff --git a/src/quick/items/qquickshadereffect_p.h b/src/quick/items/qquickshadereffect_p.h
index 17b009039a..2b7ff4cf6e 100644
--- a/src/quick/items/qquickshadereffect_p.h
+++ b/src/quick/items/qquickshadereffect_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_shadereffect);
+
#include <QtQuick/qquickitem.h>
#include <private/qtquickglobal_p.h>
diff --git a/src/quick/items/qquickshadereffectmesh.cpp b/src/quick/items/qquickshadereffectmesh.cpp
index 8616bf8022..d23b576d42 100644
--- a/src/quick/items/qquickshadereffectmesh.cpp
+++ b/src/quick/items/qquickshadereffectmesh.cpp
@@ -95,9 +95,8 @@ bool QQuickGridMesh::validateAttributes(const QVector<QByteArray> &attributes, i
return false;
case 1:
if (positionIndex != 0) {
- m_log = QLatin1String("Error: Missing \'");
- m_log += QLatin1String(qtPositionAttributeName());
- m_log += QLatin1String("\' attribute.\n");
+ m_log = QLatin1String("Error: Missing \'") + QLatin1String(qtPositionAttributeName())
+ + QLatin1String("\' attribute.\n");
return false;
}
break;
@@ -105,14 +104,12 @@ bool QQuickGridMesh::validateAttributes(const QVector<QByteArray> &attributes, i
if (positionIndex == -1 || texCoordIndex == -1) {
m_log.clear();
if (positionIndex == -1) {
- m_log = QLatin1String("Error: Missing \'");
- m_log += QLatin1String(qtPositionAttributeName());
- m_log += QLatin1String("\' attribute.\n");
+ m_log = QLatin1String("Error: Missing \'") + QLatin1String(qtPositionAttributeName())
+ + QLatin1String("\' attribute.\n");
}
if (texCoordIndex == -1) {
- m_log += QLatin1String("Error: Missing \'");
- m_log += QLatin1String(qtTexCoordAttributeName());
- m_log += QLatin1String("\' attribute.\n");
+ m_log += QLatin1String("Error: Missing \'") + QLatin1String(qtTexCoordAttributeName())
+ + QLatin1String("\' attribute.\n");
}
return false;
}
@@ -140,7 +137,7 @@ QSGGeometry *QQuickGridMesh::updateGeometry(QSGGeometry *geometry, int attrCount
? QSGGeometry::defaultAttributes_Point2D()
: QSGGeometry::defaultAttributes_TexturedPoint2D(),
(vmesh + 1) * (hmesh + 1), vmesh * 2 * (hmesh + 2),
- QSGGeometry::TypeUnsignedShort);
+ QSGGeometry::UnsignedShortType);
} else {
geometry->allocate((vmesh + 1) * (hmesh + 1), vmesh * 2 * (hmesh + 2));
@@ -367,7 +364,7 @@ QSGGeometry *QQuickBorderImageMesh::updateGeometry(QSGGeometry *geometry, int at
}
\endqml
*/
-QQuickScaleGrid *QQuickBorderImageMesh::border()
+QQuickScaleGrid *QQuickBorderImageMesh::border() const
{
return m_border;
}
diff --git a/src/quick/items/qquickshadereffectmesh_p.h b/src/quick/items/qquickshadereffectmesh_p.h
index c5f1d19866..aa3112b5a5 100644
--- a/src/quick/items/qquickshadereffectmesh_p.h
+++ b/src/quick/items/qquickshadereffectmesh_p.h
@@ -37,6 +37,10 @@
**
****************************************************************************/
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_shadereffect);
+
#include "qqmlparserstatus.h"
#include <QtQuick/qtquickglobal.h>
@@ -123,7 +127,7 @@ public:
QSGGeometry *updateGeometry(QSGGeometry *geometry, int attrCount, int posIndex,
const QRectF &srcRect, const QRectF &rect) override;
- QQuickScaleGrid *border();
+ QQuickScaleGrid *border() const;
enum TileMode { Stretch = Qt::StretchTile, Repeat = Qt::RepeatTile, Round = Qt::RoundTile };
Q_ENUM(TileMode)
diff --git a/src/quick/items/qquickshadereffectsource.cpp b/src/quick/items/qquickshadereffectsource.cpp
index a60a06f59a..1b37a746d3 100644
--- a/src/quick/items/qquickshadereffectsource.cpp
+++ b/src/quick/items/qquickshadereffectsource.cpp
@@ -64,7 +64,7 @@ public:
{
}
- QSGTexture *texture() const {
+ QSGTexture *texture() const override {
sourceTexture->setMipmapFiltering(mipmapFiltering);
sourceTexture->setFiltering(filtering);
sourceTexture->setHorizontalWrapMode(horizontalWrap);
diff --git a/src/quick/items/qquickshadereffectsource_p.h b/src/quick/items/qquickshadereffectsource_p.h
index ee18bf195a..5e7e354feb 100644
--- a/src/quick/items/qquickshadereffectsource_p.h
+++ b/src/quick/items/qquickshadereffectsource_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <QtQuick/private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_shadereffect);
+
#include "qquickitem.h"
#include <QtQuick/qsgtextureprovider.h>
#include <private/qsgadaptationlayer_p.h>
diff --git a/src/quick/items/qquicksprite_p.h b/src/quick/items/qquicksprite_p.h
index 684d432f39..d68a45ecc0 100644
--- a/src/quick/items/qquicksprite_p.h
+++ b/src/quick/items/qquicksprite_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_sprite);
+
#include <QObject>
#include <QUrl>
#include <QVariantMap>
@@ -325,4 +329,5 @@ private:
};
QT_END_NAMESPACE
+
#endif // QQUICKSPRITE_P_H
diff --git a/src/quick/items/qquickspriteengine.cpp b/src/quick/items/qquickspriteengine.cpp
index 10e0d51709..74b04a75ad 100644
--- a/src/quick/items/qquickspriteengine.cpp
+++ b/src/quick/items/qquickspriteengine.cpp
@@ -323,13 +323,13 @@ void QQuickStochasticEngine::setGoal(int state, int sprite, bool jump)
return;
}
-QQuickPixmap::Status QQuickSpriteEngine::status()//Composed status of all Sprites
+QQuickPixmap::Status QQuickSpriteEngine::status() const //Composed status of all Sprites
{
if (!m_startedImageAssembly)
return QQuickPixmap::Null;
int null, loading, ready;
null = loading = ready = 0;
- for (QQuickSprite* s : qAsConst(m_sprites)) {
+ for (QQuickSprite* s : m_sprites) {
switch (s->m_pix.status()) {
// ### Maybe add an error message here, because this null shouldn't be reached but when it does, the image fails without an error message.
case QQuickPixmap::Null : null++; break;
diff --git a/src/quick/items/qquickspriteengine_p.h b/src/quick/items/qquickspriteengine_p.h
index 485afc16e5..89de9ce4f2 100644
--- a/src/quick/items/qquickspriteengine_p.h
+++ b/src/quick/items/qquickspriteengine_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_sprite);
+
#include <QObject>
#include <QVector>
#include <QTimer>
@@ -289,11 +293,11 @@ public:
void advance(int index=0) Q_DECL_OVERRIDE;
//Similar API to QQuickPixmap for async loading convenience
- bool isNull() { return status() == QQuickPixmap::Null; }
- bool isReady() { return status() == QQuickPixmap::Ready; }
- bool isLoading() { return status() == QQuickPixmap::Loading; }
- bool isError() { return status() == QQuickPixmap::Error; }
- QQuickPixmap::Status status();//Composed status of all Sprites
+ bool isNull() const { return status() == QQuickPixmap::Null; }
+ bool isReady() const { return status() == QQuickPixmap::Ready; }
+ bool isLoading() const { return status() == QQuickPixmap::Loading; }
+ bool isError() const { return status() == QQuickPixmap::Error; }
+ QQuickPixmap::Status status() const; //Composed status of all Sprites
void startAssemblingImage();
QImage assembledImage(int maxSize = 2048);
diff --git a/src/quick/items/qquickspritesequence_p.h b/src/quick/items/qquickspritesequence_p.h
index 34af110a98..b80a8348aa 100644
--- a/src/quick/items/qquickspritesequence_p.h
+++ b/src/quick/items/qquickspritesequence_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_sprite);
+
#include <QtQuick/QQuickItem>
#include <QTime>
diff --git a/src/quick/items/qquickspritesequence_p_p.h b/src/quick/items/qquickspritesequence_p_p.h
index 4f352b5b69..3579833116 100644
--- a/src/quick/items/qquickspritesequence_p_p.h
+++ b/src/quick/items/qquickspritesequence_p_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_sprite);
+
#include "qquickitem_p.h"
#include "qquicksprite_p.h"
diff --git a/src/quick/items/qquickstateoperations.cpp b/src/quick/items/qquickstateoperations.cpp
index 7e485c675c..9cd3b6a5f5 100644
--- a/src/quick/items/qquickstateoperations.cpp
+++ b/src/quick/items/qquickstateoperations.cpp
@@ -899,9 +899,9 @@ QQuickAnchorChanges::ActionList QQuickAnchorChanges::actions()
return ActionList() << a;
}
-QQuickAnchorSet *QQuickAnchorChanges::anchors()
+QQuickAnchorSet *QQuickAnchorChanges::anchors() const
{
- Q_D(QQuickAnchorChanges);
+ Q_D(const QQuickAnchorChanges);
return d->anchorSet;
}
@@ -1134,9 +1134,9 @@ QQuickStateActionEvent::EventType QQuickAnchorChanges::type() const
return AnchorChanges;
}
-QList<QQuickStateAction> QQuickAnchorChanges::additionalActions()
+QList<QQuickStateAction> QQuickAnchorChanges::additionalActions() const
{
- Q_D(QQuickAnchorChanges);
+ Q_D(const QQuickAnchorChanges);
QList<QQuickStateAction> extra;
QQuickAnchors::Anchors combined = d->anchorSet->d_func()->usedAnchors | d->anchorSet->d_func()->resetAnchors;
diff --git a/src/quick/items/qquickstateoperations_p.h b/src/quick/items/qquickstateoperations_p.h
index 29dec218fa..48b4b23a76 100644
--- a/src/quick/items/qquickstateoperations_p.h
+++ b/src/quick/items/qquickstateoperations_p.h
@@ -192,7 +192,7 @@ public:
ActionList actions() Q_DECL_OVERRIDE;
- QQuickAnchorSet *anchors();
+ QQuickAnchorSet *anchors() const;
QQuickItem *object() const;
void setObject(QQuickItem *);
@@ -210,7 +210,7 @@ public:
void rewind() Q_DECL_OVERRIDE;
void saveCurrentValues() Q_DECL_OVERRIDE;
- QList<QQuickStateAction> additionalActions();
+ QList<QQuickStateAction> additionalActions() const;
void saveTargetValues() Q_DECL_OVERRIDE;
};
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index 14268b472e..2bfb4501fc 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -898,11 +898,11 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline)
// If the width of the item has changed and it's possible the result of wrapping,
// eliding, scaling has changed, or the text is not left aligned do another layout.
- if ((lineWidth < qMin(oldWidth, naturalWidth) || (widthExceeded && lineWidth > oldWidth))
+ if ((!qFuzzyCompare(lineWidth, oldWidth) || (widthExceeded && lineWidth > oldWidth))
&& (singlelineElide || multilineElide || canWrap || horizontalFit
|| q->effectiveHAlign() != QQuickText::AlignLeft)) {
widthChanged = true;
- widthExceeded = false;
+ widthExceeded = lineWidth >= qMin(oldWidth, naturalWidth);
heightExceeded = false;
continue;
}
@@ -937,7 +937,7 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline)
bool wasInLayout = internalWidthUpdate;
internalWidthUpdate = true;
- q->setImplicitHeight(naturalHeight);
+ q->setImplicitHeight(naturalHeight + q->topPadding() + q->bottomPadding());
internalWidthUpdate = wasInLayout;
multilineElide = elideMode == QQuickText::ElideRight
diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp
index ef7485a8e9..fe29249934 100644
--- a/src/quick/items/qquicktextcontrol.cpp
+++ b/src/quick/items/qquicktextcontrol.cpp
@@ -1664,8 +1664,8 @@ void QQuickTextControl::insertFromMimeData(const QMimeData *source)
#ifndef QT_NO_TEXTHTMLPARSER
if (source->hasFormat(QLatin1String("application/x-qrichtext")) && d->acceptRichText) {
// x-qrichtext is always UTF-8 (taken from Qt3 since we don't use it anymore).
- QString richtext = QString::fromUtf8(source->data(QLatin1String("application/x-qrichtext")));
- richtext.prepend(QLatin1String("<meta name=\"qrichtext\" content=\"1\" />"));
+ const QString richtext = QLatin1String("<meta name=\"qrichtext\" content=\"1\" />")
+ + QString::fromUtf8(source->data(QLatin1String("application/x-qrichtext")));
fragment = QTextDocumentFragment::fromHtml(richtext, d->doc);
hasData = true;
} else if (source->hasHtml() && d->acceptRichText) {
diff --git a/src/quick/items/qquicktextcontrol_p.h b/src/quick/items/qquicktextcontrol_p.h
index 602e457cb8..e06e3b8b29 100644
--- a/src/quick/items/qquicktextcontrol_p.h
+++ b/src/quick/items/qquicktextcontrol_p.h
@@ -193,9 +193,11 @@ class QQuickTextEditMimeData : public QMimeData
public:
inline QQuickTextEditMimeData(const QTextDocumentFragment &aFragment) : fragment(aFragment) {}
- virtual QStringList formats() const;
+ QStringList formats() const override;
+
protected:
- virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type) const;
+ QVariant retrieveData(const QString &mimeType, QVariant::Type type) const override;
+
private:
void setup() const;
diff --git a/src/quick/items/qquicktextdocument.cpp b/src/quick/items/qquicktextdocument.cpp
index 1dc54eb107..287e07e980 100644
--- a/src/quick/items/qquicktextdocument.cpp
+++ b/src/quick/items/qquicktextdocument.cpp
@@ -179,7 +179,7 @@ void QQuickTextDocumentWithImageResources::drawObject(
{
}
-QImage QQuickTextDocumentWithImageResources::image(const QTextImageFormat &format)
+QImage QQuickTextDocumentWithImageResources::image(const QTextImageFormat &format) const
{
QVariant res = resource(QTextDocument::ImageResource, QUrl(format.name()));
return res.value<QImage>();
diff --git a/src/quick/items/qquicktextdocument_p.h b/src/quick/items/qquicktextdocument_p.h
index 3ffedb5b96..1218b12b89 100644
--- a/src/quick/items/qquicktextdocument_p.h
+++ b/src/quick/items/qquicktextdocument_p.h
@@ -75,10 +75,10 @@ public:
void setText(const QString &);
int resourcesLoading() const { return outstanding; }
- QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format);
- void drawObject(QPainter *p, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format);
+ QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format) override;
+ void drawObject(QPainter *p, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format) override;
- QImage image(const QTextImageFormat &format);
+ QImage image(const QTextImageFormat &format) const;
public Q_SLOTS:
void clearResources();
@@ -87,7 +87,7 @@ Q_SIGNALS:
void imagesLoaded();
protected:
- QVariant loadResource(int type, const QUrl &name);
+ QVariant loadResource(int type, const QUrl &name) override;
QQuickPixmap *loadPixmap(QQmlContext *context, const QUrl &name);
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index c81544cbdb..4a5358faae 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -2566,7 +2566,7 @@ void QQuickTextEditPrivate::updateDefaultTextOption()
{
Q_Q(QQuickTextEdit);
QTextOption opt = document->defaultTextOption();
- int oldAlignment = opt.alignment();
+ const Qt::Alignment oldAlignment = opt.alignment();
Qt::LayoutDirection oldTextDirection = opt.textDirection();
QQuickTextEdit::HAlignment horizontalAlignment = q->effectiveHAlign();
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index 6543a64624..fbfaa0e199 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -766,7 +766,7 @@ void QQuickTextInput::setMaxLength(int ml)
(but without actually giving it active focus).
It should not be set directly on the item, like in the below QML,
- as the specified value will be overridden an lost on focus changes.
+ as the specified value will be overridden and lost on focus changes.
\code
TextInput {
@@ -1993,7 +1993,7 @@ bool QQuickTextInput::isRightToLeft(int start, int end)
qmlInfo(this) << "isRightToLeft(start, end) called with the end property being smaller than the start.";
return false;
} else {
- return text().mid(start, end - start).isRightToLeft();
+ return text().midRef(start, end - start).isRightToLeft();
}
}
@@ -2340,8 +2340,8 @@ QString QQuickTextInput::preeditText() const
If true, the user can use the mouse to select text in some
platform-specific way. Note that for some platforms this may
- not be an appropriate interaction (eg. may conflict with how
- the text needs to behave inside a Flickable.
+ not be an appropriate interaction (it may conflict with how
+ the text needs to behave inside a \l Flickable, for example).
*/
bool QQuickTextInput::selectByMouse() const
{
@@ -2843,7 +2843,7 @@ void QQuickTextInputPrivate::updateDisplayText(bool forceUpdate)
// drawing boxes when using fonts that don't have glyphs for such
// characters)
QChar* uc = str.data();
- for (int i = 0; i < (int)str.length(); ++i) {
+ for (int i = 0; i < str.length(); ++i) {
if ((uc[i].unicode() < 0x20 && uc[i] != QChar::Tabulation)
|| uc[i] == QChar::LineSeparator
|| uc[i] == QChar::ParagraphSeparator
@@ -3229,7 +3229,7 @@ void QQuickTextInputPrivate::setSelection(int start, int length)
commitPreedit();
#endif
- if (start < 0 || start > (int)m_text.length()){
+ if (start < 0 || start > m_text.length()) {
qWarning("QQuickTextInputPrivate::setSelection: Invalid start position");
return;
}
@@ -3238,7 +3238,7 @@ void QQuickTextInputPrivate::setSelection(int start, int length)
if (start == m_selstart && start + length == m_selend && m_cursor == m_selend)
return;
m_selstart = start;
- m_selend = qMin(start + length, (int)m_text.length());
+ m_selend = qMin(start + length, m_text.length());
m_cursor = m_selend;
} else if (length < 0){
if (start == m_selend && start + length == m_selstart && m_cursor == m_selstart)
@@ -3676,7 +3676,7 @@ void QQuickTextInputPrivate::internalInsert(const QString &s)
Q_ASSERT(!hasSelectedText()); // insert(), processInputMethodEvent() call removeSelectedText() first.
if (m_maskData) {
QString ms = maskString(m_cursor, s);
- for (int i = 0; i < (int) ms.length(); ++i) {
+ for (int i = 0; i < ms.length(); ++i) {
addCommand (Command(DeleteSelection, m_cursor + i, m_text.at(m_cursor + i), -1, -1));
addCommand(Command(Insert, m_cursor + i, ms.at(i), -1, -1));
}
@@ -3687,9 +3687,10 @@ void QQuickTextInputPrivate::internalInsert(const QString &s)
} else {
int remaining = m_maxLength - m_text.length();
if (remaining != 0) {
- m_text.insert(m_cursor, s.left(remaining));
- for (int i = 0; i < (int) s.leftRef(remaining).length(); ++i)
- addCommand(Command(Insert, m_cursor++, s.at(i), -1, -1));
+ const QStringRef remainingStr = s.leftRef(remaining);
+ m_text.insert(m_cursor, remainingStr);
+ for (auto e : remainingStr)
+ addCommand(Command(Insert, m_cursor++, e, -1, -1));
m_textDirty = true;
}
}
@@ -3708,7 +3709,7 @@ void QQuickTextInputPrivate::internalInsert(const QString &s)
*/
void QQuickTextInputPrivate::internalDelete(bool wasBackspace)
{
- if (m_cursor < (int) m_text.length()) {
+ if (m_cursor < m_text.length()) {
cancelPasswordEchoTimer();
Q_ASSERT(!hasSelectedText()); // del(), backspace() call removeSelectedText() first.
addCommand(Command((CommandType)((m_maskData ? 2 : 0) + (wasBackspace ? Remove : Delete)),
@@ -3734,7 +3735,7 @@ void QQuickTextInputPrivate::internalDelete(bool wasBackspace)
*/
void QQuickTextInputPrivate::removeSelectedText()
{
- if (m_selstart < m_selend && m_selend <= (int) m_text.length()) {
+ if (m_selstart < m_selend && m_selend <= m_text.length()) {
cancelPasswordEchoTimer();
int i ;
if (m_selstart <= m_cursor && m_cursor < m_selend) {
@@ -4020,44 +4021,44 @@ QString QQuickTextInputPrivate::maskString(uint pos, const QString &str, bool cl
if (strIndex < str.length()) {
if (m_maskData[i].separator) {
s += m_maskData[i].maskChar;
- if (str[(int)strIndex] == m_maskData[i].maskChar)
+ if (str[strIndex] == m_maskData[i].maskChar)
strIndex++;
++i;
} else {
- if (isValidInput(str[(int)strIndex], m_maskData[i].maskChar)) {
+ if (isValidInput(str[strIndex], m_maskData[i].maskChar)) {
switch (m_maskData[i].caseMode) {
case MaskInputData::Upper:
- s += str[(int)strIndex].toUpper();
+ s += str[strIndex].toUpper();
break;
case MaskInputData::Lower:
- s += str[(int)strIndex].toLower();
+ s += str[strIndex].toLower();
break;
default:
- s += str[(int)strIndex];
+ s += str[strIndex];
}
++i;
} else {
// search for separator first
- int n = findInMask(i, true, true, str[(int)strIndex]);
+ int n = findInMask(i, true, true, str[strIndex]);
if (n != -1) {
- if (str.length() != 1 || i == 0 || (i > 0 && (!m_maskData[i-1].separator || m_maskData[i-1].maskChar != str[(int)strIndex]))) {
+ if (str.length() != 1 || i == 0 || (i > 0 && (!m_maskData[i-1].separator || m_maskData[i-1].maskChar != str[strIndex]))) {
s += fill.midRef(i, n-i+1);
i = n + 1; // update i to find + 1
}
} else {
// search for valid m_blank if not
- n = findInMask(i, true, false, str[(int)strIndex]);
+ n = findInMask(i, true, false, str[strIndex]);
if (n != -1) {
s += fill.midRef(i, n-i);
switch (m_maskData[n].caseMode) {
case MaskInputData::Upper:
- s += str[(int)strIndex].toUpper();
+ s += str[strIndex].toUpper();
break;
case MaskInputData::Lower:
- s += str[(int)strIndex].toLower();
+ s += str[strIndex].toLower();
break;
default:
- s += str[(int)strIndex];
+ s += str[strIndex];
}
i = n + 1; // updates i to find + 1
}
@@ -4108,7 +4109,7 @@ QString QQuickTextInputPrivate::stripString(const QString &str) const
return str;
QString s;
- int end = qMin(m_maxLength, (int)str.length());
+ int end = qMin(m_maxLength, str.length());
for (int i = 0; i < end; ++i) {
if (m_maskData[i].separator)
s += m_maskData[i].maskChar;
@@ -4198,7 +4199,7 @@ void QQuickTextInputPrivate::internalRedo()
if (!isRedoAvailable())
return;
internalDeselect();
- while (m_undoState < (int)m_history.size()) {
+ while (m_undoState < m_history.size()) {
Command& cmd = m_history[m_undoState++];
switch (cmd.type) {
case Insert:
@@ -4225,7 +4226,7 @@ void QQuickTextInputPrivate::internalRedo()
m_cursor = cmd.pos;
break;
}
- if (m_undoState < (int)m_history.size()) {
+ if (m_undoState < m_history.size()) {
Command& next = m_history[m_undoState];
if (next.type != cmd.type
&& cmd.type < RemoveSelection
diff --git a/src/quick/items/qquickview.cpp b/src/quick/items/qquickview.cpp
index d79d8ba3cd..a167f01484 100644
--- a/src/quick/items/qquickview.cpp
+++ b/src/quick/items/qquickview.cpp
@@ -48,29 +48,11 @@
#include <QtQml/qqmlengine.h>
#include <private/qqmlengine_p.h>
+#include <private/qv4qobjectwrapper_p.h>
#include <QtCore/qbasictimer.h>
QT_BEGIN_NAMESPACE
-DEFINE_OBJECT_VTABLE(QV4::QQuickRootItemMarker);
-
-QV4::Heap::QQuickRootItemMarker *QV4::QQuickRootItemMarker::create(QQmlEngine *engine, QQuickWindow *window)
-{
- QV4::ExecutionEngine *e = QQmlEnginePrivate::getV4Engine(engine);
- return e->memoryManager->allocObject<QQuickRootItemMarker>(window);
-}
-
-void QV4::QQuickRootItemMarker::markObjects(QV4::Heap::Base *that, QV4::ExecutionEngine *e)
-{
- QQuickItem *root = static_cast<QQuickRootItemMarker::Data *>(that)->window->contentItem();
- if (root) {
- QQuickItemPrivate *rootPrivate = QQuickItemPrivate::get(root);
- rootPrivate->markObjects(e);
- }
-
- QV4::Object::markObjects(that, e);
-}
-
void QQuickViewPrivate::init(QQmlEngine* e)
{
Q_Q(QQuickView);
@@ -84,10 +66,10 @@ void QQuickViewPrivate::init(QQmlEngine* e)
engine.data()->setIncubationController(q->incubationController());
{
+ // The content item has CppOwnership policy (set in QQuickWindow). Ensure the presence of a JS
+ // wrapper so that the garbage collector can see the policy.
QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine.data());
- QV4::Scope scope(v4);
- QV4::Scoped<QV4::QQuickRootItemMarker> v(scope, QV4::QQuickRootItemMarker::create(engine.data(), q));
- rootItemMarker.set(v4, v);
+ QV4::QObjectWrapper::wrap(v4, contentItem);
}
}
diff --git a/src/quick/items/qquickview_p.h b/src/quick/items/qquickview_p.h
index 9c0d87984f..a090bdc9f7 100644
--- a/src/quick/items/qquickview_p.h
+++ b/src/quick/items/qquickview_p.h
@@ -108,38 +108,8 @@ public:
QQuickView::ResizeMode resizeMode;
QSize initialSize;
QElapsedTimer frameTimer;
- QV4::PersistentValue rootItemMarker;
};
-namespace QV4 {
-namespace Heap {
-
-struct QQuickRootItemMarker : Object {
- inline void init(QQuickWindow *window)
- {
- Object::init();
- this->window = window;
- }
-
- QQuickWindow *window;
-};
-
-}
-
-struct QQuickRootItemMarker : public Object
-{
- V4_OBJECT2(QQuickRootItemMarker, Object)
-
- static Heap::QQuickRootItemMarker *create(QQmlEngine *engine, QQuickWindow *window);
-
- static void markObjects(QV4::Heap::Base *that, QV4::ExecutionEngine *e);
-
-};
-
-
-
-}
-
QT_END_NAMESPACE
#endif // QQUICKVIEW_P_H
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 8cdc7955ff..8a90afe113 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -1808,6 +1808,7 @@ bool QQuickWindowPrivate::deliverWheelEvent(QQuickItem *item, QWheelEvent *event
if (item->contains(p)) {
QWheelEvent wheel(p, p, event->pixelDelta(), event->angleDelta(), event->delta(),
event->orientation(), event->buttons(), event->modifiers(), event->phase(), event->source(), event->inverted());
+ wheel.setTimestamp(event->timestamp());
wheel.accept();
QCoreApplication::sendEvent(item, &wheel);
if (wheel.isAccepted()) {
@@ -1908,8 +1909,6 @@ void QQuickWindowPrivate::deliverDelayedTouchEvent()
deliverPointerEvent(pointerEventInstance(e.data()));
}
-static bool qquickwindow_no_touch_compression = qEnvironmentVariableIsSet("QML_NO_TOUCH_COMPRESSION");
-
bool QQuickWindowPrivate::compressTouchEvent(QTouchEvent *event)
{
Q_Q(QQuickWindow);
@@ -1986,6 +1985,8 @@ void QQuickWindowPrivate::handleTouchEvent(QTouchEvent *event)
qCDebug(DBG_TOUCH) << event;
+ static bool qquickwindow_no_touch_compression = qEnvironmentVariableIsSet("QML_NO_TOUCH_COMPRESSION");
+
if (qquickwindow_no_touch_compression || pointerEventRecursionGuard) {
deliverPointerEvent(pointerEventInstance(event));
return;
@@ -2111,7 +2112,7 @@ void QQuickWindowPrivate::flushFrameSynchronousEvents()
There is a unique instance per QQuickPointerDevice, which is determined
from \a event's device.
*/
-QQuickPointerEvent *QQuickWindowPrivate::pointerEventInstance(QEvent *event)
+QQuickPointerEvent *QQuickWindowPrivate::pointerEventInstance(QEvent *event) const
{
QQuickPointerDevice *dev = nullptr;
switch (event->type()) {
@@ -4202,6 +4203,28 @@ void QQuickWindow::resetOpenGLState()
*/
/*!
+ \qmlproperty variant Window::targetScreen
+
+ Specifies the screen the window should be placed on. Equivalent to
+ QWindow::setScreen().
+
+ The value must be an element from the Qt.application.screens array.
+
+ By default the value is null which leads to using the primary screen.
+
+ \note To ensure that the window is associated with the desired screen right
+ upon the underlying native window's initial creation, make sure this
+ property is set as early as possible and that the setting of its value is
+ not deferred. This can be particularly important on embedded platforms
+ without a windowing system, where only one window per screen is allowed at a
+ time.
+
+ \since 5.9
+
+ \sa QWindow::setScreen(), QScreen, Qt.application
+ */
+
+/*!
\qmlproperty Item Window::activeFocusItem
\since 5.1
diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h
index cfadadec2d..7e1e45f345 100644
--- a/src/quick/items/qquickwindow.h
+++ b/src/quick/items/qquickwindow.h
@@ -56,6 +56,7 @@ class QSGTexture;
class QInputMethodEvent;
class QQuickWindowPrivate;
class QQuickWindowAttached;
+class QOpenGLContext;
class QOpenGLFramebufferObject;
class QQmlIncubationController;
class QInputMethodEvent;
diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h
index b13dda4ef8..cedfd765da 100644
--- a/src/quick/items/qquickwindow_p.h
+++ b/src/quick/items/qquickwindow_p.h
@@ -161,7 +161,7 @@ public:
void deliverDelayedTouchEvent();
// delivery of pointer events:
- QQuickPointerEvent *pointerEventInstance(QEvent *ev);
+ QQuickPointerEvent *pointerEventInstance(QEvent *ev) const;
void deliverPointerEvent(QQuickPointerEvent *);
void deliverTouchEvent(QQuickPointerTouchEvent *);
bool deliverTouchCancelEvent(QTouchEvent *);
@@ -198,7 +198,7 @@ public:
void setFocusInScope(QQuickItem *scope, QQuickItem *item, Qt::FocusReason reason, FocusOptions = 0);
void clearFocusInScope(QQuickItem *scope, QQuickItem *item, Qt::FocusReason reason, FocusOptions = 0);
static void notifyFocusChangesRecur(QQuickItem **item, int remaining);
- void clearFocusObject();
+ void clearFocusObject() override;
void updateFocusItemTransform();
diff --git a/src/quick/items/qquickwindowmodule.cpp b/src/quick/items/qquickwindowmodule.cpp
index c624d162a9..ea1fc2f106 100644
--- a/src/quick/items/qquickwindowmodule.cpp
+++ b/src/quick/items/qquickwindowmodule.cpp
@@ -47,6 +47,7 @@
#include <private/qguiapplication_p.h>
#include <private/qqmlengine_p.h>
+#include <private/qv4qobjectwrapper_p.h>
#include <qpa/qplatformintegration.h>
QT_BEGIN_NAMESPACE
@@ -58,6 +59,7 @@ public:
: complete(false)
, visible(false)
, visibility(QQuickWindow::AutomaticVisibility)
+ , targetScreen(nullptr)
{
}
@@ -65,6 +67,7 @@ public:
bool visible;
QQuickWindow::Visibility visibility;
QV4::PersistentValue rootItemMarker;
+ QObject *targetScreen;
};
QQuickWindowQmlImpl::QQuickWindowQmlImpl(QWindow *parent)
@@ -104,12 +107,11 @@ void QQuickWindowQmlImpl::classBegin()
if (e && !e->incubationController())
e->setIncubationController(incubationController());
}
- Q_ASSERT(e);
{
+ // The content item has CppOwnership policy (set in QQuickWindow). Ensure the presence of a JS
+ // wrapper so that the garbage collector can see the policy.
QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(e);
- QV4::Scope scope(v4);
- QV4::ScopedObject v(scope, QV4::QQuickRootItemMarker::create(e, this));
- d->rootItemMarker = v;
+ QV4::QObjectWrapper::wrap(v4, d->contentItem);
}
}
@@ -170,6 +172,26 @@ void QQuickWindowQmlImpl::setWindowVisibility()
}
}
+QObject *QQuickWindowQmlImpl::targetScreen() const
+{
+ Q_D(const QQuickWindowQmlImpl);
+ return d->targetScreen;
+}
+
+void QQuickWindowQmlImpl::setTargetScreen(QObject *screen)
+{
+ Q_D(QQuickWindowQmlImpl);
+ if (d->targetScreen != screen) {
+ d->targetScreen = screen;
+ emit targetScreenChanged();
+ QQuickScreenInfo *screenWrapper = qobject_cast<QQuickScreenInfo *>(screen);
+ if (screenWrapper)
+ setScreen(screenWrapper->wrappedScreen());
+ else
+ setScreen(nullptr);
+ }
+}
+
void QQuickWindowModule::defineModule()
{
const char uri[] = "QtQuick.Window";
@@ -181,7 +203,10 @@ void QQuickWindowModule::defineModule()
qmlRegisterRevision<QQuickWindow,2>(uri, 2, 2);
qmlRegisterType<QQuickWindowQmlImpl>(uri, 2, 1, "Window");
qmlRegisterType<QQuickWindowQmlImpl,1>(uri, 2, 2, "Window");
+ qmlRegisterType<QQuickWindowQmlImpl,2>(uri, 2, 3, "Window");
qmlRegisterUncreatableType<QQuickScreen>(uri, 2, 0, "Screen", QStringLiteral("Screen can only be used via the attached property."));
+ qmlRegisterUncreatableType<QQuickScreen,1>(uri, 2, 3, "Screen", QStringLiteral("Screen can only be used via the attached property."));
+ qmlRegisterUncreatableType<QQuickScreenInfo,2>(uri, 2, 3, "ScreenInfo", QStringLiteral("ScreenInfo can only be used via the attached property."));
}
QT_END_NAMESPACE
diff --git a/src/quick/items/qquickwindowmodule_p.h b/src/quick/items/qquickwindowmodule_p.h
index 8a6bbac412..7ca29880ea 100644
--- a/src/quick/items/qquickwindowmodule_p.h
+++ b/src/quick/items/qquickwindowmodule_p.h
@@ -67,6 +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 *targetScreen READ targetScreen WRITE setTargetScreen NOTIFY targetScreenChanged REVISION 2)
public:
QQuickWindowQmlImpl(QWindow *parent = Q_NULLPTR);
@@ -74,11 +75,15 @@ public:
void setVisible(bool visible);
void setVisibility(Visibility visibility);
+ QObject *targetScreen() const;
+ void setTargetScreen(QObject *screen);
+
static QQuickWindowAttached *qmlAttachedProperties(QObject *object);
Q_SIGNALS:
void visibleChanged(bool arg);
void visibilityChanged(QWindow::Visibility visibility);
+ Q_REVISION(2) void targetScreenChanged();
protected:
void classBegin() Q_DECL_OVERRIDE;
diff --git a/src/quick/qtquick2.cpp b/src/quick/qtquick2.cpp
index 9a50250ebb..4028c63da5 100644
--- a/src/quick/qtquick2.cpp
+++ b/src/quick/qtquick2.cpp
@@ -72,19 +72,19 @@ class QQmlQtQuick2DebugStatesDelegate : public QQmlDebugStatesDelegate
{
public:
QQmlQtQuick2DebugStatesDelegate();
- virtual ~QQmlQtQuick2DebugStatesDelegate();
- virtual void buildStatesList(bool cleanList, const QList<QPointer<QObject> > &instances);
- virtual void updateBinding(QQmlContext *context,
- const QQmlProperty &property,
- const QVariant &expression, bool isLiteralValue,
- const QString &fileName, int line, int column,
- bool *isBaseState);
- virtual bool setBindingForInvalidProperty(QObject *object,
- const QString &propertyName,
- const QVariant &expression,
- bool isLiteralValue);
- virtual void resetBindingForInvalidProperty(QObject *object,
- const QString &propertyName);
+ ~QQmlQtQuick2DebugStatesDelegate();
+ void buildStatesList(bool cleanList, const QList<QPointer<QObject> > &instances) override;
+ void updateBinding(QQmlContext *context,
+ const QQmlProperty &property,
+ const QVariant &expression, bool isLiteralValue,
+ const QString &fileName, int line, int column,
+ bool *isBaseState) override;
+ bool setBindingForInvalidProperty(QObject *object,
+ const QString &propertyName,
+ const QVariant &expression,
+ bool isLiteralValue) override;
+ void resetBindingForInvalidProperty(QObject *object,
+ const QString &propertyName) override;
private:
void buildStatesList(QObject *obj);
diff --git a/src/quick/qtquickglobal.h b/src/quick/qtquickglobal.h
index f6f8f42e7f..5e83c1db84 100644
--- a/src/quick/qtquickglobal.h
+++ b/src/quick/qtquickglobal.h
@@ -40,7 +40,9 @@
#ifndef QTQUICKGLOBAL_H
#define QTQUICKGLOBAL_H
-#include <QtCore/qglobal.h>
+#include <QtQml/qtqmlglobal.h>
+#include <QtGui/qtguiglobal.h>
+#include <QtQuick/qtquick-config.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/qtquickglobal_p.h b/src/quick/qtquickglobal_p.h
index 3c313de0a1..f6376a6d17 100644
--- a/src/quick/qtquickglobal_p.h
+++ b/src/quick/qtquickglobal_p.h
@@ -40,6 +40,10 @@
#ifndef QTQUICKGLOBAL_P_H
#define QTQUICKGLOBAL_P_H
+#include <QtQml/private/qtqmlglobal_p.h>
+#include <QtGui/private/qtguiglobal_p.h>
+#include <QtQuick/private/qtquick-config_p.h>
+
#include <QtCore/qloggingcategory.h>
//
diff --git a/src/quick/quick.pro b/src/quick/quick.pro
index 9f96ae2e33..2f49a53aa1 100644
--- a/src/quick/quick.pro
+++ b/src/quick/quick.pro
@@ -1,12 +1,8 @@
TARGET = QtQuick
QT = core-private gui-private qml-private
-!no_network {
- QT_PRIVATE = network
-}
-no_network {
- DEFINES += QT_NO_NETWORK
-}
+qtConfig(qml-network): \
+ QT_PRIVATE += network
DEFINES += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES
win32-msvc*:DEFINES *= _CRT_SECURE_NO_WARNINGS
@@ -33,7 +29,8 @@ include(util/util.pri)
include(scenegraph/scenegraph.pri)
include(items/items.pri)
include(handlers/handlers.pri)
-include(designer/designer.pri)
+qtConfig(quick-designer): \
+ include(designer/designer.pri)
qtConfig(accessibility) {
include(accessible/accessible.pri)
}
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareadaptation.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareadaptation.cpp
index 8ad9b50b09..92c02b4966 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareadaptation.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareadaptation.cpp
@@ -78,7 +78,7 @@ QSGRenderLoop *QSGSoftwareAdaptation::createWindowManager()
static bool envChecked = false;
if (!envChecked) {
envChecked = true;
- threaded = qgetenv("QSG_RENDER_LOOP") == QByteArrayLiteral("threaded");
+ threaded = qgetenv("QSG_RENDER_LOOP") == "threaded";
}
if (threaded)
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp
index 80112c1121..05d5daa686 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp
@@ -47,7 +47,9 @@
#include "qsgsoftwarepublicnodes_p.h"
#include "qsgsoftwarelayer_p.h"
#include "qsgsoftwarerenderer_p.h"
+#if QT_CONFIG(quick_sprite)
#include "qsgsoftwarespritenode_p.h"
+#endif
#include <QtCore/QCoreApplication>
#include <QtCore/QElapsedTimer>
@@ -184,10 +186,12 @@ QSGNinePatchNode *QSGSoftwareContext::createNinePatchNode()
return new QSGSoftwareNinePatchNode;
}
+#if QT_CONFIG(quick_sprite)
QSGSpriteNode *QSGSoftwareContext::createSpriteNode()
{
return new QSGSoftwareSpriteNode;
}
+#endif
QSGRendererInterface::GraphicsApi QSGSoftwareContext::graphicsApi() const
{
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext_p.h
index dcc137b4b4..1f14717416 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext_p.h
@@ -98,7 +98,9 @@ public:
QSGRectangleNode *createRectangleNode() override;
QSGImageNode *createImageNode() override;
QSGNinePatchNode *createNinePatchNode() override;
+#if QT_CONFIG(quick_sprite)
QSGSpriteNode *createSpriteNode() override;
+#endif
GraphicsApi graphicsApi() const override;
ShaderType shaderType() const override;
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp
index 7b9e749532..59c47db0c4 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp
@@ -45,7 +45,9 @@
#include "qsgsoftwarepublicnodes_p.h"
#include "qsgsoftwarepainternode_p.h"
#include "qsgsoftwarepixmaptexture_p.h"
+#if QT_CONFIG(quick_sprite)
#include "qsgsoftwarespritenode_p.h"
+#endif
#include <qsgsimplerectnode.h>
#include <qsgsimpletexturenode.h>
@@ -91,9 +93,11 @@ QSGSoftwareRenderableNode::QSGSoftwareRenderableNode(NodeType type, QSGNode *nod
case QSGSoftwareRenderableNode::SimpleImage:
m_handle.simpleImageNode = static_cast<QSGImageNode*>(node);
break;
+#if QT_CONFIG(quick_sprite)
case QSGSoftwareRenderableNode::SpriteNode:
m_handle.spriteNode = static_cast<QSGSoftwareSpriteNode*>(node);
break;
+#endif
case QSGSoftwareRenderableNode::RenderNode:
m_handle.renderNode = static_cast<QSGRenderNode*>(node);
break;
@@ -182,10 +186,12 @@ void QSGSoftwareRenderableNode::update()
boundingRect = m_handle.simpleImageNode->rect().toRect();
break;
+#if QT_CONFIG(quick_sprite)
case QSGSoftwareRenderableNode::SpriteNode:
m_isOpaque = m_handle.spriteNode->isOpaque();
boundingRect = m_handle.spriteNode->rect().toRect();
break;
+#endif
case QSGSoftwareRenderableNode::RenderNode:
if (m_handle.renderNode->flags().testFlag(QSGRenderNode::OpaqueRendering) && !m_transform.isRotating())
m_isOpaque = true;
@@ -317,9 +323,11 @@ QRegion QSGSoftwareRenderableNode::renderNode(QPainter *painter, bool forceOpaqu
case QSGSoftwareRenderableNode::SimpleImage:
static_cast<QSGSoftwareImageNode *>(m_handle.simpleImageNode)->paint(painter);
break;
+#if QT_CONFIG(quick_sprite)
case QSGSoftwareRenderableNode::SpriteNode:
static_cast<QSGSoftwareSpriteNode *>(m_handle.spriteNode)->paint(painter);
break;
+#endif
default:
break;
}
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h
index 0626b1e657..473578c185 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h
@@ -51,6 +51,8 @@
// We mean it.
//
+#include <QtQuick/private/qtquickglobal_p.h>
+
#include <QtGui/QRegion>
#include <QtCore/QRect>
#include <QtGui/QTransform>
@@ -84,7 +86,9 @@ public:
NinePatch,
SimpleRectangle,
SimpleImage,
+#if QT_CONFIG(quick_sprite)
SpriteNode,
+#endif
RenderNode
};
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater.cpp
index 12dbf63353..4937565aa9 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater.cpp
@@ -181,6 +181,7 @@ void QSGSoftwareRenderableNodeUpdater::endVisit(QSGRootNode *)
{
}
+#if QT_CONFIG(quick_sprite)
bool QSGSoftwareRenderableNodeUpdater::visit(QSGSpriteNode *node)
{
return updateRenderableNode(QSGSoftwareRenderableNode::SpriteNode, node);
@@ -190,6 +191,7 @@ void QSGSoftwareRenderableNodeUpdater::endVisit(QSGSpriteNode *)
{
}
+#endif
bool QSGSoftwareRenderableNodeUpdater::visit(QSGRenderNode *node)
{
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater_p.h
index f204867236..ca16f77c22 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater_p.h
@@ -86,8 +86,10 @@ public:
void endVisit(QSGGlyphNode *) override;
bool visit(QSGRootNode *) override;
void endVisit(QSGRootNode *) override;
+#if QT_CONFIG(quick_sprite)
bool visit(QSGSpriteNode *) override;
void endVisit(QSGSpriteNode *) override;
+#endif
bool visit(QSGRenderNode *) override;
void endVisit(QSGRenderNode *) override;
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder.cpp
index 4e34517dad..70dce71801 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder.cpp
@@ -141,6 +141,7 @@ void QSGSoftwareRenderListBuilder::endVisit(QSGRootNode *)
{
}
+#if QT_CONFIG(quick_sprite)
bool QSGSoftwareRenderListBuilder::visit(QSGSpriteNode *node)
{
return addRenderableNode(node);
@@ -150,6 +151,7 @@ void QSGSoftwareRenderListBuilder::endVisit(QSGSpriteNode *)
{
}
+#endif
bool QSGSoftwareRenderListBuilder::visit(QSGRenderNode *node)
{
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder_p.h
index 807cb7fdbe..f5db30269f 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder_p.h
@@ -80,8 +80,10 @@ public:
void endVisit(QSGGlyphNode *) override;
bool visit(QSGRootNode *) override;
void endVisit(QSGRootNode *) override;
+#if QT_CONFIG(quick_sprite)
bool visit(QSGSpriteNode *) override;
void endVisit(QSGSpriteNode *) override;
+#endif
bool visit(QSGRenderNode *) override;
void endVisit(QSGRenderNode *) override;
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarespritenode_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwarespritenode_p.h
index 284ed3dff5..577a30c051 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarespritenode_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarespritenode_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_sprite);
+
#include <private/qsgadaptationlayer_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/scenegraph/adaptations/software/software.pri b/src/quick/scenegraph/adaptations/software/software.pri
index 97644fc36a..de5f01cdee 100644
--- a/src/quick/scenegraph/adaptations/software/software.pri
+++ b/src/quick/scenegraph/adaptations/software/software.pri
@@ -19,7 +19,6 @@ SOURCES += \
$$PWD/qsgsoftwarerenderloop.cpp \
$$PWD/qsgsoftwarelayer.cpp \
$$PWD/qsgsoftwareadaptation.cpp \
- $$PWD/qsgsoftwarespritenode.cpp \
$$PWD/qsgsoftwarethreadedrenderloop.cpp
HEADERS += \
@@ -39,5 +38,11 @@ HEADERS += \
$$PWD/qsgsoftwarerenderloop_p.h \
$$PWD/qsgsoftwarelayer_p.h \
$$PWD/qsgsoftwareadaptation_p.h \
- $$PWD/qsgsoftwarespritenode_p.h \
$$PWD/qsgsoftwarethreadedrenderloop_p.h
+
+qtConfig(quick-sprite) {
+ SOURCES += \
+ $$PWD/qsgsoftwarespritenode.cpp
+ HEADERS += \
+ $$PWD/qsgsoftwarespritenode_p.h
+}
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
index 01e517e65b..d5e94cea3e 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
@@ -499,7 +499,7 @@ public:
void updateRootTransforms(Node *n);
void updateRootTransforms(Node *n, Node *root, const QMatrix4x4 &combined);
- void updateStates(QSGNode *n);
+ void updateStates(QSGNode *n) override;
void visitNode(Node *n);
void registerWithParentRoot(QSGNode *subRoot, QSGNode *parentRoot);
diff --git a/src/quick/scenegraph/coreapi/qsggeometry.cpp b/src/quick/scenegraph/coreapi/qsggeometry.cpp
index 239557d527..b43a2bc2ba 100644
--- a/src/quick/scenegraph/coreapi/qsggeometry.cpp
+++ b/src/quick/scenegraph/coreapi/qsggeometry.cpp
@@ -54,18 +54,18 @@ QT_BEGIN_NAMESPACE
QSGGeometry::Attribute QSGGeometry::Attribute::create(int attributeIndex, int tupleSize, int primitiveType, bool isPrimitive)
{
- Attribute a = { attributeIndex, tupleSize, primitiveType, isPrimitive, UNKNOWN, 0 };
+ Attribute a = { attributeIndex, tupleSize, primitiveType, isPrimitive, UnknownAttribute, 0 };
return a;
}
-QSGGeometry::Attribute QSGGeometry::Attribute::createWithSemantic(int pos, int tupleSize, int type, Semantic semantic)
+QSGGeometry::Attribute QSGGeometry::Attribute::createWithAttributeType(int pos, int tupleSize, int primitiveType, AttributeType attributeType)
{
Attribute a;
a.position = pos;
a.tupleSize = tupleSize;
- a.type = type;
- a.isVertexCoordinate = semantic == POSITION;
- a.semantic = semantic;
+ a.type = primitiveType;
+ a.isVertexCoordinate = attributeType == PositionAttribute;
+ a.attributeType = attributeType;
a.reserved = 0;
return a;
}
@@ -78,7 +78,7 @@ QSGGeometry::Attribute QSGGeometry::Attribute::createWithSemantic(int pos, int t
const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_Point2D()
{
static Attribute data[] = {
- Attribute::createWithSemantic(0, 2, TypeFloat, Attribute::POSITION)
+ Attribute::createWithAttributeType(0, 2, FloatType, PositionAttribute)
};
static AttributeSet attrs = { 1, sizeof(float) * 2, data };
return attrs;
@@ -91,8 +91,8 @@ const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_Point2D()
const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_TexturedPoint2D()
{
static Attribute data[] = {
- Attribute::createWithSemantic(0, 2, TypeFloat, Attribute::POSITION),
- Attribute::createWithSemantic(1, 2, TypeFloat, Attribute::TEXCOORD)
+ Attribute::createWithAttributeType(0, 2, FloatType, PositionAttribute),
+ Attribute::createWithAttributeType(1, 2, FloatType, TexCoordAttribute)
};
static AttributeSet attrs = { 2, sizeof(float) * 4, data };
return attrs;
@@ -105,8 +105,8 @@ const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_TexturedPoint2D(
const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_ColoredPoint2D()
{
static Attribute data[] = {
- Attribute::createWithSemantic(0, 2, TypeFloat, Attribute::POSITION),
- Attribute::createWithSemantic(1, 4, TypeUnsignedByte, Attribute::COLOR)
+ Attribute::createWithAttributeType(0, 2, FloatType, PositionAttribute),
+ Attribute::createWithAttributeType(1, 4, UnsignedByteType, ColorAttribute)
};
static AttributeSet attrs = { 2, 2 * sizeof(float) + 4 * sizeof(char), data };
return attrs;
@@ -134,12 +134,31 @@ const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_ColoredPoint2D()
\fn QSGGeometry::Attribute QSGGeometry::Attribute::create(int pos, int tupleSize, int primitiveType, bool isPosition)
Creates a new QSGGeometry::Attribute for attribute register \a pos with \a
- tupleSize. The \a primitiveType can be any of the supported OpenGL types,
- such as \c GL_FLOAT or \c GL_UNSIGNED_BYTE.
+ tupleSize. The \a primitiveType can be any of the supported types from
+ QSGGeometry::Type, such as QSGGeometry::FloatType or
+ QSGGeometry::UnsignedByteType.
- If the attribute describes the position for the vertex, the \a isPosition hint
- should be set to \c true. The scene graph renderer may use this information
- to perform optimizations.
+ If the attribute describes the position for the vertex, the \a isPosition
+ hint should be set to \c true. The scene graph renderer may use this
+ information to perform optimizations.
+
+ \note Scene graph backends for APIs other than OpenGL may require an
+ accurate description of attributes' usage, and therefore it is recommended
+ to use createWithAttributeType() instead.
+
+ Use the create function to construct the attribute, rather than an
+ initialization list, to ensure that all fields are initialized.
+ */
+
+/*!
+ \fn QSGGeometry::Attribute QSGGeometry::Attribute::createWithAttributeType(int pos, int tupleSize, int primitiveType, AttributeType attributeType)
+
+ Creates a new QSGGeometry::Attribute for attribute register \a pos with \a
+ tupleSize. The \a primitiveType can be any of the supported types from
+ QSGGeometry::Type, such as QSGGeometry::FloatType or
+ QSGGeometry::UnsignedByteType.
+
+ \a attributeType describes the intended use of the attribute.
Use the create function to construct the attribute, rather than an
initialization list, to ensure that all fields are initialized.
@@ -430,9 +449,9 @@ QSGGeometry::QSGGeometry(const QSGGeometry::AttributeSet &attributes,
"GL_UNSIGNED_INT is not supported, geometry will not render"
);
#endif
- if (indexType != TypeUnsignedByte
- && indexType != TypeUnsignedShort
- && indexType != TypeUnsignedInt) {
+ if (indexType != UnsignedByteType
+ && indexType != UnsignedShortType
+ && indexType != UnsignedIntType) {
qFatal("QSGGeometry: Unsupported index type, %x.\n", indexType);
}
@@ -549,13 +568,13 @@ const void *QSGGeometry::indexData() const
GL_UNSIGNED_BYTE, etc. QSGGeometry provies its own type in order to be able
to provide the same API with non-OpenGL backends as well.
- \value TypeByte
- \value TypeUnsignedByte
- \value TypeShort
- \value TypeUnsignedShort
- \value TypeInt
- \value TypeUnsignedInt
- \value TypeFloat
+ \value ByteType
+ \value UnsignedByteType
+ \value ShortType
+ \value UnsignedShortType
+ \value IntType
+ \value UnsignedIntType
+ \value FloatType
*/
/*!
@@ -653,8 +672,8 @@ void QSGGeometry::allocate(int vertexCount, int indexCount)
m_index_data_offset = -1;
m_owns_data = false;
} else {
- Q_ASSERT(m_index_type == TypeUnsignedInt || m_index_type == TypeUnsignedShort);
- int indexByteSize = indexCount * (m_index_type == TypeUnsignedShort ? sizeof(quint16) : sizeof(quint32));
+ Q_ASSERT(m_index_type == UnsignedIntType || m_index_type == UnsignedShortType);
+ int indexByteSize = indexCount * (m_index_type == UnsignedShortType ? sizeof(quint16) : sizeof(quint32));
m_data = (void *) malloc(vertexByteSize + indexByteSize);
m_index_data_offset = vertexByteSize;
m_owns_data = true;
diff --git a/src/quick/scenegraph/coreapi/qsggeometry.h b/src/quick/scenegraph/coreapi/qsggeometry.h
index ae7b2f494c..00acb51c8a 100644
--- a/src/quick/scenegraph/coreapi/qsggeometry.h
+++ b/src/quick/scenegraph/coreapi/qsggeometry.h
@@ -51,30 +51,68 @@ class QSGGeometryData;
class Q_QUICK_EXPORT QSGGeometry
{
public:
+ enum AttributeType {
+ UnknownAttribute,
+ PositionAttribute,
+ ColorAttribute,
+ TexCoordAttribute,
+ TexCoord1Attribute,
+ TexCoord2Attribute
+ };
+
+ enum DataPattern {
+ AlwaysUploadPattern = 0,
+ StreamPattern = 1,
+ DynamicPattern = 2,
+ StaticPattern = 3
+ };
+
+ // Equivalents to GL_* drawing modes.
+ // Keep in sync with GL headers.
+ enum DrawingMode {
+ DrawPoints = 0x0000,
+ DrawLines = 0x0001,
+ DrawLineLoop = 0x0002,
+ DrawLineStrip = 0x0003,
+ DrawTriangles = 0x0004,
+ DrawTriangleStrip = 0x0005,
+ DrawTriangleFan = 0x0006
+ };
+
+ // Equivalents to GL_BYTE and similar type constants.
+ // Keep in sync with GL headers.
+ enum Type {
+ ByteType = 0x1400,
+ UnsignedByteType = 0x1401,
+ ShortType = 0x1402,
+ UnsignedShortType = 0x1403,
+ IntType = 0x1404,
+ UnsignedIntType = 0x1405,
+ FloatType = 0x1406,
+
+ TypeByte = ByteType,
+ TypeUnsignedByte = UnsignedByteType,
+ TypeShort = ShortType,
+ TypeUnsignedShort = UnsignedShortType,
+ TypeInt = IntType,
+ TypeUnsignedInt = UnsignedIntType,
+ TypeFloat = FloatType
+ };
struct Q_QUICK_EXPORT Attribute
{
- enum Semantic {
- UNKNOWN,
- POSITION,
- COLOR,
- TEXCOORD,
- TEXCOORD1,
- TEXCOORD2
- };
-
int position;
int tupleSize;
int type;
uint isVertexCoordinate : 1;
- Semantic semantic : 4;
+ AttributeType attributeType : 4;
uint reserved : 27;
static Attribute create(int pos, int tupleSize, int primitiveType, bool isPosition = false);
- static Attribute createWithSemantic(int pos, int tupleSize, int type, Semantic semantic);
+ static Attribute createWithAttributeType(int pos, int tupleSize, int primitiveType, AttributeType attributeType);
};
struct AttributeSet {
@@ -109,39 +147,10 @@ public:
static const AttributeSet &defaultAttributes_TexturedPoint2D();
static const AttributeSet &defaultAttributes_ColoredPoint2D();
- enum DataPattern {
- AlwaysUploadPattern = 0,
- StreamPattern = 1,
- DynamicPattern = 2,
- StaticPattern = 3
- };
-
- // Equivalents to GL_* drawing modes.
- enum DrawingMode {
- DrawPoints = 0x0000,
- DrawLines = 0x0001,
- DrawLineLoop = 0x0002,
- DrawLineStrip = 0x0003,
- DrawTriangles = 0x0004,
- DrawTriangleStrip = 0x0005,
- DrawTriangleFan = 0x0006
- };
-
- // Equivalents to GL_BYTE and similar type constants.
- enum Type {
- TypeByte = 0x1400,
- TypeUnsignedByte = 0x1401,
- TypeShort = 0x1402,
- TypeUnsignedShort = 0x1403,
- TypeInt = 0x1404,
- TypeUnsignedInt = 0x1405,
- TypeFloat = 0x1406
- };
-
QSGGeometry(const QSGGeometry::AttributeSet &attribs,
int vertexCount,
int indexCount = 0,
- int indexType = TypeUnsignedShort);
+ int indexType = UnsignedShortType);
virtual ~QSGGeometry();
// must use unsigned int to be compatible with the old GLenum to keep BC
@@ -223,25 +232,25 @@ private:
inline uint *QSGGeometry::indexDataAsUInt()
{
- Q_ASSERT(m_index_type == TypeUnsignedInt);
+ Q_ASSERT(m_index_type == UnsignedIntType);
return static_cast<uint *>(indexData());
}
inline quint16 *QSGGeometry::indexDataAsUShort()
{
- Q_ASSERT(m_index_type == TypeUnsignedShort);
+ Q_ASSERT(m_index_type == UnsignedShortType);
return static_cast<quint16 *>(indexData());
}
inline const uint *QSGGeometry::indexDataAsUInt() const
{
- Q_ASSERT(m_index_type == TypeUnsignedInt);
+ Q_ASSERT(m_index_type == UnsignedIntType);
return static_cast<const uint *>(indexData());
}
inline const quint16 *QSGGeometry::indexDataAsUShort() const
{
- Q_ASSERT(m_index_type == TypeUnsignedShort);
+ Q_ASSERT(m_index_type == UnsignedShortType);
return static_cast<const quint16 *>(indexData());
}
@@ -250,7 +259,7 @@ inline QSGGeometry::Point2D *QSGGeometry::vertexDataAsPoint2D()
Q_ASSERT(m_attributes.count == 1);
Q_ASSERT(m_attributes.stride == 2 * sizeof(float));
Q_ASSERT(m_attributes.attributes[0].tupleSize == 2);
- Q_ASSERT(m_attributes.attributes[0].type == TypeFloat);
+ Q_ASSERT(m_attributes.attributes[0].type == FloatType);
Q_ASSERT(m_attributes.attributes[0].position == 0);
return static_cast<Point2D *>(m_data);
}
@@ -261,10 +270,10 @@ inline QSGGeometry::TexturedPoint2D *QSGGeometry::vertexDataAsTexturedPoint2D()
Q_ASSERT(m_attributes.stride == 4 * sizeof(float));
Q_ASSERT(m_attributes.attributes[0].position == 0);
Q_ASSERT(m_attributes.attributes[0].tupleSize == 2);
- Q_ASSERT(m_attributes.attributes[0].type == TypeFloat);
+ Q_ASSERT(m_attributes.attributes[0].type == FloatType);
Q_ASSERT(m_attributes.attributes[1].position == 1);
Q_ASSERT(m_attributes.attributes[1].tupleSize == 2);
- Q_ASSERT(m_attributes.attributes[1].type == TypeFloat);
+ Q_ASSERT(m_attributes.attributes[1].type == FloatType);
return static_cast<TexturedPoint2D *>(m_data);
}
@@ -274,10 +283,10 @@ inline QSGGeometry::ColoredPoint2D *QSGGeometry::vertexDataAsColoredPoint2D()
Q_ASSERT(m_attributes.stride == 2 * sizeof(float) + 4 * sizeof(char));
Q_ASSERT(m_attributes.attributes[0].position == 0);
Q_ASSERT(m_attributes.attributes[0].tupleSize == 2);
- Q_ASSERT(m_attributes.attributes[0].type == TypeFloat);
+ Q_ASSERT(m_attributes.attributes[0].type == FloatType);
Q_ASSERT(m_attributes.attributes[1].position == 1);
Q_ASSERT(m_attributes.attributes[1].tupleSize == 4);
- Q_ASSERT(m_attributes.attributes[1].type == TypeUnsignedByte);
+ Q_ASSERT(m_attributes.attributes[1].type == UnsignedByteType);
return static_cast<ColoredPoint2D *>(m_data);
}
@@ -286,7 +295,7 @@ inline const QSGGeometry::Point2D *QSGGeometry::vertexDataAsPoint2D() const
Q_ASSERT(m_attributes.count == 1);
Q_ASSERT(m_attributes.stride == 2 * sizeof(float));
Q_ASSERT(m_attributes.attributes[0].tupleSize == 2);
- Q_ASSERT(m_attributes.attributes[0].type == TypeFloat);
+ Q_ASSERT(m_attributes.attributes[0].type == FloatType);
Q_ASSERT(m_attributes.attributes[0].position == 0);
return static_cast<const Point2D *>(m_data);
}
@@ -297,10 +306,10 @@ inline const QSGGeometry::TexturedPoint2D *QSGGeometry::vertexDataAsTexturedPoin
Q_ASSERT(m_attributes.stride == 4 * sizeof(float));
Q_ASSERT(m_attributes.attributes[0].position == 0);
Q_ASSERT(m_attributes.attributes[0].tupleSize == 2);
- Q_ASSERT(m_attributes.attributes[0].type == TypeFloat);
+ Q_ASSERT(m_attributes.attributes[0].type == FloatType);
Q_ASSERT(m_attributes.attributes[1].position == 1);
Q_ASSERT(m_attributes.attributes[1].tupleSize == 2);
- Q_ASSERT(m_attributes.attributes[1].type == TypeFloat);
+ Q_ASSERT(m_attributes.attributes[1].type == FloatType);
return static_cast<const TexturedPoint2D *>(m_data);
}
@@ -310,18 +319,18 @@ inline const QSGGeometry::ColoredPoint2D *QSGGeometry::vertexDataAsColoredPoint2
Q_ASSERT(m_attributes.stride == 2 * sizeof(float) + 4 * sizeof(char));
Q_ASSERT(m_attributes.attributes[0].position == 0);
Q_ASSERT(m_attributes.attributes[0].tupleSize == 2);
- Q_ASSERT(m_attributes.attributes[0].type == TypeFloat);
+ Q_ASSERT(m_attributes.attributes[0].type == FloatType);
Q_ASSERT(m_attributes.attributes[1].position == 1);
Q_ASSERT(m_attributes.attributes[1].tupleSize == 4);
- Q_ASSERT(m_attributes.attributes[1].type == TypeUnsignedByte);
+ Q_ASSERT(m_attributes.attributes[1].type == UnsignedByteType);
return static_cast<const ColoredPoint2D *>(m_data);
}
int QSGGeometry::sizeOfIndex() const
{
- if (m_index_type == TypeUnsignedShort) return 2;
- else if (m_index_type == TypeUnsignedByte) return 1;
- else if (m_index_type == TypeUnsignedInt) return 4;
+ if (m_index_type == UnsignedShortType) return 2;
+ else if (m_index_type == UnsignedByteType) return 1;
+ else if (m_index_type == UnsignedIntType) return 4;
return 0;
}
diff --git a/src/quick/scenegraph/coreapi/qsgnode.cpp b/src/quick/scenegraph/coreapi/qsgnode.cpp
index 2211f88973..a1e1ef8c27 100644
--- a/src/quick/scenegraph/coreapi/qsgnode.cpp
+++ b/src/quick/scenegraph/coreapi/qsgnode.cpp
@@ -1490,7 +1490,7 @@ QDebug operator<<(QDebug d, const QSGGeometryNode *n)
d << "#V:" << g->vertexCount() << "#I:" << g->indexCount();
- if (g->attributeCount() > 0 && g->attributes()->type == QSGGeometry::TypeFloat) {
+ if (g->attributeCount() > 0 && g->attributes()->type == QSGGeometry::FloatType) {
float x1 = 1e10, x2 = -1e10, y1=1e10, y2=-1e10;
int stride = g->sizeOfVertex();
for (int i = 0; i < g->vertexCount(); ++i) {
diff --git a/src/quick/scenegraph/coreapi/qsgnode.h b/src/quick/scenegraph/coreapi/qsgnode.h
index f7ea6dbe23..1467f2233d 100644
--- a/src/quick/scenegraph/coreapi/qsgnode.h
+++ b/src/quick/scenegraph/coreapi/qsgnode.h
@@ -325,7 +325,7 @@ public:
void setCombinedOpacity(qreal opacity);
qreal combinedOpacity() const { return m_combined_opacity; }
- bool isSubtreeBlocked() const;
+ bool isSubtreeBlocked() const override;
private:
qreal m_opacity;
diff --git a/src/quick/scenegraph/coreapi/qsgrenderer_p.h b/src/quick/scenegraph/coreapi/qsgrenderer_p.h
index 94b78a85b4..3fb23fe3cd 100644
--- a/src/quick/scenegraph/coreapi/qsgrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgrenderer_p.h
@@ -138,7 +138,7 @@ class QSGBindableFboId : public QSGBindable
{
public:
QSGBindableFboId(GLuint);
- virtual void bind() const;
+ void bind() const override;
private:
GLuint m_id;
};
@@ -160,8 +160,8 @@ public:
static void dump(QSGNode *n);
QSGNodeDumper() : m_indent(0) {}
- void visitNode(QSGNode *n);
- void visitChildren(QSGNode *n);
+ void visitNode(QSGNode *n) override;
+ void visitChildren(QSGNode *n) override;
private:
int m_indent;
diff --git a/src/quick/scenegraph/coreapi/qsgshaderrewriter.cpp b/src/quick/scenegraph/coreapi/qsgshaderrewriter.cpp
index 3a35632d5c..48ab1aa52f 100644
--- a/src/quick/scenegraph/coreapi/qsgshaderrewriter.cpp
+++ b/src/quick/scenegraph/coreapi/qsgshaderrewriter.cpp
@@ -193,13 +193,13 @@ QByteArray qsgShaderRewriter_insertZAttributes(const char *input, QSurfaceFormat
switch (profile) {
case QSurfaceFormat::NoProfile:
case QSurfaceFormat::CompatibilityProfile:
- result += QByteArrayLiteral("attribute highp float _qt_order;\n");
- result += QByteArrayLiteral("uniform highp float _qt_zRange;\n");
+ result += "attribute highp float _qt_order;\n"
+ "uniform highp float _qt_zRange;\n";
break;
case QSurfaceFormat::CoreProfile:
- result += QByteArrayLiteral("in float _qt_order;\n");
- result += QByteArrayLiteral("uniform float _qt_zRange;\n");
+ result += "in float _qt_order;\n"
+ "uniform float _qt_zRange;\n";
break;
}
@@ -214,9 +214,9 @@ QByteArray qsgShaderRewriter_insertZAttributes(const char *input, QSurfaceFormat
case Tokenizer::Token_CloseBrace:
braceDepth--;
if (braceDepth == 0) {
- result += QByteArray::fromRawData(voidPos, tok.pos - 1 - voidPos);
- result += QByteArrayLiteral(" gl_Position.z = (gl_Position.z * _qt_zRange + _qt_order) * gl_Position.w;\n");
- result += QByteArray(tok.pos - 1);
+ result += QByteArray::fromRawData(voidPos, tok.pos - 1 - voidPos)
+ + " gl_Position.z = (gl_Position.z * _qt_zRange + _qt_order) * gl_Position.w;\n"
+ + QByteArray(tok.pos - 1);
return result;
}
break;
diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp
index e219ddd82e..9923fa6e24 100644
--- a/src/quick/scenegraph/qsgadaptationlayer.cpp
+++ b/src/quick/scenegraph/qsgadaptationlayer.cpp
@@ -122,7 +122,7 @@ void QSGDistanceFieldGlyphCache::populate(const QVector<glyph_t> &glyphs)
int count = glyphs.count();
for (int i = 0; i < count; ++i) {
glyph_t glyphIndex = glyphs.at(i);
- if ((int) glyphIndex >= glyphCount()) {
+ if ((int) glyphIndex >= glyphCount() && glyphCount() > 0) {
qWarning("Warning: distance-field glyph is not available with index %d", glyphIndex);
continue;
}
diff --git a/src/quick/scenegraph/qsgadaptationlayer_p.h b/src/quick/scenegraph/qsgadaptationlayer_p.h
index a74b38dba8..5880c67af0 100644
--- a/src/quick/scenegraph/qsgadaptationlayer_p.h
+++ b/src/quick/scenegraph/qsgadaptationlayer_p.h
@@ -108,8 +108,10 @@ public:
virtual void endVisit(QSGGlyphNode *) = 0;
virtual bool visit(QSGRootNode *) = 0;
virtual void endVisit(QSGRootNode *) = 0;
+#if QT_CONFIG(quick_sprite)
virtual bool visit(QSGSpriteNode *) = 0;
virtual void endVisit(QSGSpriteNode *) = 0;
+#endif
virtual bool visit(QSGRenderNode *) = 0;
virtual void endVisit(QSGRenderNode *) = 0;
@@ -213,6 +215,8 @@ Q_SIGNALS:
void scheduledUpdateCompleted();
};
+#if QT_CONFIG(quick_sprite)
+
class Q_QUICK_PRIVATE_EXPORT QSGSpriteNode : public QSGVisitableNode
{
public:
@@ -230,6 +234,8 @@ public:
virtual void accept(QSGNodeVisitorEx *visitor) { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); }
};
+#endif
+
class Q_QUICK_PRIVATE_EXPORT QSGGuiThreadShaderEffectManager : public QObject
{
Q_OBJECT
diff --git a/src/quick/scenegraph/qsgbasicinternalimagenode.cpp b/src/quick/scenegraph/qsgbasicinternalimagenode.cpp
index 685a51550d..c8699218ba 100644
--- a/src/quick/scenegraph/qsgbasicinternalimagenode.cpp
+++ b/src/quick/scenegraph/qsgbasicinternalimagenode.cpp
@@ -55,10 +55,10 @@ namespace
const QSGGeometry::AttributeSet &smoothAttributeSet()
{
static QSGGeometry::Attribute data[] = {
- QSGGeometry::Attribute::createWithSemantic(0, 2, QSGGeometry::TypeFloat, QSGGeometry::Attribute::POSITION),
- QSGGeometry::Attribute::createWithSemantic(1, 2, QSGGeometry::TypeFloat, QSGGeometry::Attribute::TEXCOORD),
- QSGGeometry::Attribute::createWithSemantic(2, 2, QSGGeometry::TypeFloat, QSGGeometry::Attribute::TEXCOORD1),
- QSGGeometry::Attribute::createWithSemantic(3, 2, QSGGeometry::TypeFloat, QSGGeometry::Attribute::TEXCOORD2)
+ QSGGeometry::Attribute::createWithAttributeType(0, 2, QSGGeometry::FloatType, QSGGeometry::PositionAttribute),
+ QSGGeometry::Attribute::createWithAttributeType(1, 2, QSGGeometry::FloatType, QSGGeometry::TexCoordAttribute),
+ QSGGeometry::Attribute::createWithAttributeType(2, 2, QSGGeometry::FloatType, QSGGeometry::TexCoord1Attribute),
+ QSGGeometry::Attribute::createWithAttributeType(3, 2, QSGGeometry::FloatType, QSGGeometry::TexCoord2Attribute)
};
static QSGGeometry::AttributeSet attrs = { 4, sizeof(SmoothVertex), data };
return attrs;
@@ -427,7 +427,7 @@ QSGGeometry *QSGBasicInternalImageNode::updateGeometry(const QRectF &targetRect,
if (!geometry) {
geometry = new QSGGeometry(QSGGeometry::defaultAttributes_TexturedPoint2D(),
hCells * vCells * 4, hCells * vCells * 6,
- QSGGeometry::TypeUnsignedShort);
+ QSGGeometry::UnsignedShortType);
} else {
geometry->allocate(hCells * vCells * 4, hCells * vCells * 6);
}
diff --git a/src/quick/scenegraph/qsgbasicinternalrectanglenode.cpp b/src/quick/scenegraph/qsgbasicinternalrectanglenode.cpp
index 8fc850b60c..df124cce35 100644
--- a/src/quick/scenegraph/qsgbasicinternalrectanglenode.cpp
+++ b/src/quick/scenegraph/qsgbasicinternalrectanglenode.cpp
@@ -87,9 +87,9 @@ namespace
const QSGGeometry::AttributeSet &smoothAttributeSet()
{
static QSGGeometry::Attribute data[] = {
- QSGGeometry::Attribute::createWithSemantic(0, 2, QSGGeometry::TypeFloat, QSGGeometry::Attribute::POSITION),
- QSGGeometry::Attribute::createWithSemantic(1, 4, QSGGeometry::TypeUnsignedByte, QSGGeometry::Attribute::COLOR),
- QSGGeometry::Attribute::createWithSemantic(2, 2, QSGGeometry::TypeFloat, QSGGeometry::Attribute::TEXCOORD)
+ QSGGeometry::Attribute::createWithAttributeType(0, 2, QSGGeometry::FloatType, QSGGeometry::PositionAttribute),
+ QSGGeometry::Attribute::createWithAttributeType(1, 4, QSGGeometry::UnsignedByteType, QSGGeometry::ColorAttribute),
+ QSGGeometry::Attribute::createWithAttributeType(2, 2, QSGGeometry::FloatType, QSGGeometry::TexCoordAttribute)
};
static QSGGeometry::AttributeSet attrs = { 3, sizeof(SmoothVertex), data };
return attrs;
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
index 688fc7db08..d52f69c7a3 100644
--- a/src/quick/scenegraph/qsgcontext.cpp
+++ b/src/quick/scenegraph/qsgcontext.cpp
@@ -307,10 +307,6 @@ QAnimationDriver *QSGContext::createAnimationDriver(QObject *parent)
QSize QSGContext::minimumFBOSize() const
{
-#ifdef Q_OS_MAC
- if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_8)
- return QSize(33, 33);
-#endif
return QSize(1, 1);
}
diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h
index 899278843e..6b9db105e7 100644
--- a/src/quick/scenegraph/qsgcontext_p.h
+++ b/src/quick/scenegraph/qsgcontext_p.h
@@ -178,7 +178,9 @@ public:
virtual QSGGuiThreadShaderEffectManager *createGuiThreadShaderEffectManager();
virtual QSGShaderEffectNode *createShaderEffectNode(QSGRenderContext *renderContext,
QSGGuiThreadShaderEffectManager *mgr);
+#if QT_CONFIG(quick_sprite)
virtual QSGSpriteNode *createSpriteNode() = 0;
+#endif
virtual QAnimationDriver *createAnimationDriver(QObject *parent);
virtual QSize minimumFBOSize() const;
diff --git a/src/quick/scenegraph/qsgcontextplugin.cpp b/src/quick/scenegraph/qsgcontextplugin.cpp
index 3751891455..7fab9aeae8 100644
--- a/src/quick/scenegraph/qsgcontextplugin.cpp
+++ b/src/quick/scenegraph/qsgcontextplugin.cpp
@@ -148,9 +148,9 @@ QSGAdaptationBackendData *contextFactory()
}
}
+#ifndef QT_NO_LIBRARY
// Then try the plugins.
if (!backendData->factory) {
-#ifndef QT_NO_LIBRARY
const int index = loader()->indexOf(requestedBackend);
if (index != -1)
backendData->factory = qobject_cast<QSGContextFactoryInterface*>(loader()->instance(index));
diff --git a/src/quick/scenegraph/qsgdefaultcontext.cpp b/src/quick/scenegraph/qsgdefaultcontext.cpp
index 6964b74dc8..405f1d86a4 100644
--- a/src/quick/scenegraph/qsgdefaultcontext.cpp
+++ b/src/quick/scenegraph/qsgdefaultcontext.cpp
@@ -52,7 +52,9 @@
#include <QtQuick/private/qsgdefaultrectanglenode_p.h>
#include <QtQuick/private/qsgdefaultimagenode_p.h>
#include <QtQuick/private/qsgdefaultninepatchnode_p.h>
+#if QT_CONFIG(quick_sprite)
#include <QtQuick/private/qsgdefaultspritenode_p.h>
+#endif
#include <QtGui/QOpenGLContext>
#include <QtGui/QOpenGLFramebufferObject>
@@ -258,10 +260,12 @@ QSGNinePatchNode *QSGDefaultContext::createNinePatchNode()
return new QSGDefaultNinePatchNode;
}
+#if QT_CONFIG(quick_sprite)
QSGSpriteNode *QSGDefaultContext::createSpriteNode()
{
return new QSGDefaultSpriteNode;
}
+#endif
QSGRendererInterface::GraphicsApi QSGDefaultContext::graphicsApi() const
{
diff --git a/src/quick/scenegraph/qsgdefaultcontext_p.h b/src/quick/scenegraph/qsgdefaultcontext_p.h
index 88db5e1e9a..ab319502ef 100644
--- a/src/quick/scenegraph/qsgdefaultcontext_p.h
+++ b/src/quick/scenegraph/qsgdefaultcontext_p.h
@@ -76,7 +76,9 @@ public:
QSGRectangleNode *createRectangleNode() override;
QSGImageNode *createImageNode() override;
QSGNinePatchNode *createNinePatchNode() override;
+#if QT_CONFIG(quick_sprite)
QSGSpriteNode *createSpriteNode() override;
+#endif
void setDistanceFieldEnabled(bool enabled);
bool isDistanceFieldEnabled() const;
diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h
index eeea104e91..9ad99e5c54 100644
--- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h
+++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h
@@ -116,9 +116,8 @@ private:
{
m_blitProgram = new QOpenGLShaderProgram;
{
- QString source;
- source.append(QLatin1String(qopenglslMainWithTexCoordsVertexShader));
- source.append(QLatin1String(qopenglslUntransformedPositionVertexShader));
+ const QString source = QLatin1String(qopenglslMainWithTexCoordsVertexShader)
+ + QLatin1String(qopenglslUntransformedPositionVertexShader);
QOpenGLShader *vertexShader = new QOpenGLShader(QOpenGLShader::Vertex, m_blitProgram);
vertexShader->compileSourceCode(source);
@@ -126,9 +125,8 @@ private:
m_blitProgram->addShader(vertexShader);
}
{
- QString source;
- source.append(QLatin1String(qopenglslMainFragmentShader));
- source.append(QLatin1String(qopenglslImageSrcFragmentShader));
+ const QString source = QLatin1String(qopenglslMainFragmentShader)
+ + QLatin1String(qopenglslImageSrcFragmentShader);
QOpenGLShader *fragmentShader = new QOpenGLShader(QOpenGLShader::Fragment, m_blitProgram);
fragmentShader->compileSourceCode(source);
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
index 3501f30487..b001899915 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -240,7 +240,8 @@ bool QSG24BitTextMaskShader::useSRGB() const
// m_useSRGB is true, but if some QOGLFBO was bound check it's texture format:
QOpenGLContext *ctx = QOpenGLContext::currentContext();
QOpenGLFramebufferObject *qfbo = QOpenGLContextPrivate::get(ctx)->qgl_current_fbo;
- return !qfbo || qfbo->format().internalTextureFormat() == GL_SRGB8_ALPHA8_EXT;
+ bool fboInvalid = QOpenGLContextPrivate::get(ctx)->qgl_current_fbo_invalid;
+ return !qfbo || fboInvalid || qfbo->format().internalTextureFormat() == GL_SRGB8_ALPHA8_EXT;
#else
return m_useSRGB;
#endif
diff --git a/src/quick/scenegraph/qsgdefaultrendercontext.cpp b/src/quick/scenegraph/qsgdefaultrendercontext.cpp
index 6f10611ba3..1a17453baf 100644
--- a/src/quick/scenegraph/qsgdefaultrendercontext.cpp
+++ b/src/quick/scenegraph/qsgdefaultrendercontext.cpp
@@ -99,12 +99,12 @@ void QSGDefaultRenderContext::initialize(void *context)
#ifdef Q_OS_LINUX
const char *vendor = (const char *) funcs->glGetString(GL_VENDOR);
- if (strstr(vendor, "nouveau"))
+ if (vendor && strstr(vendor, "nouveau"))
m_brokenIBOs = true;
const char *renderer = (const char *) funcs->glGetString(GL_RENDERER);
- if (strstr(renderer, "llvmpipe"))
+ if (renderer && strstr(renderer, "llvmpipe"))
m_serializedRender = true;
- if (strstr(vendor, "Hisilicon Technologies") && strstr(renderer, "Immersion.16"))
+ if (vendor && renderer && strstr(vendor, "Hisilicon Technologies") && strstr(renderer, "Immersion.16"))
m_brokenIBOs = true;
#endif
diff --git a/src/quick/scenegraph/qsgdefaultspritenode.cpp b/src/quick/scenegraph/qsgdefaultspritenode.cpp
index 89b26f8660..5eb8fb6e08 100644
--- a/src/quick/scenegraph/qsgdefaultspritenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultspritenode.cpp
@@ -150,8 +150,8 @@ QSGMaterialShader *QQuickSpriteMaterial::createShader() const
}
static QSGGeometry::Attribute Sprite_Attributes[] = {
- QSGGeometry::Attribute::create(0, 2, QSGGeometry::TypeFloat, true), // pos
- QSGGeometry::Attribute::create(1, 2, QSGGeometry::TypeFloat), // tex
+ QSGGeometry::Attribute::create(0, 2, QSGGeometry::FloatType, true), // pos
+ QSGGeometry::Attribute::create(1, 2, QSGGeometry::FloatType), // tex
};
static QSGGeometry::AttributeSet Sprite_AttributeSet =
diff --git a/src/quick/scenegraph/qsgdefaultspritenode_p.h b/src/quick/scenegraph/qsgdefaultspritenode_p.h
index cb76bf8d83..78aa8cc0cf 100644
--- a/src/quick/scenegraph/qsgdefaultspritenode_p.h
+++ b/src/quick/scenegraph/qsgdefaultspritenode_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_sprite);
+
#include <private/qsgadaptationlayer_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp
index e99e8dfe2e..9ddbe5aa1d 100644
--- a/src/quick/scenegraph/qsgrenderloop.cpp
+++ b/src/quick/scenegraph/qsgrenderloop.cpp
@@ -61,8 +61,10 @@
#ifndef QT_NO_OPENGL
# include <QtGui/QOpenGLContext>
# include <private/qsgdefaultrendercontext_p.h>
+#if QT_CONFIG(quick_shadereffect)
# include <private/qquickopenglshadereffectnode_p.h>
#endif
+#endif
#ifdef Q_OS_WIN
# include <QtCore/qt_windows.h>
@@ -209,11 +211,11 @@ QSGRenderLoop *QSGRenderLoop::instance()
if (Q_UNLIKELY(qEnvironmentVariableIsSet("QSG_RENDER_LOOP"))) {
const QByteArray loopName = qgetenv("QSG_RENDER_LOOP");
- if (loopName == QByteArrayLiteral("windows"))
+ if (loopName == "windows")
loopType = WindowsRenderLoop;
- else if (loopName == QByteArrayLiteral("basic"))
+ else if (loopName == "basic")
loopType = BasicRenderLoop;
- else if (loopName == QByteArrayLiteral("threaded"))
+ else if (loopName == "threaded")
loopType = ThreadedRenderLoop;
}
@@ -326,7 +328,7 @@ void QSGGuiThreadRenderLoop::windowDestroyed(QQuickWindow *window)
if (Q_UNLIKELY(!current))
qCDebug(QSG_LOG_RENDERLOOP) << "cleanup without an OpenGL context";
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
QQuickOpenGLShaderEffectMaterial::cleanupMaterialCache();
#endif
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
index 6b9c67b2bd..693012154e 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp
+++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
@@ -63,7 +63,9 @@
#include <private/qqmldebugserviceinterfaces_p.h>
#include <private/qqmldebugconnector_p.h>
+#if QT_CONFIG(quick_shadereffect)
#include <private/qquickopenglshadereffectnode_p.h>
+#endif
#include <private/qsgdefaultrendercontext_p.h>
/*
@@ -487,7 +489,9 @@ void QSGRenderThread::invalidateOpenGL(QQuickWindow *window, bool inDestructor,
QQuickWindowPrivate *dd = QQuickWindowPrivate::get(window);
+#if QT_CONFIG(quick_shadereffect)
QQuickOpenGLShaderEffectMaterial::cleanupMaterialCache();
+#endif
// The canvas nodes must be cleaned up regardless if we are in the destructor..
if (wipeSG) {
diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp
index 743e524a36..2a2d8be657 100644
--- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp
+++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp
@@ -55,7 +55,7 @@
#include <private/qquickprofiler_p.h>
#include <private/qquickanimatorcontroller_p.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
#include <private/qquickopenglshadereffectnode_p.h>
#endif
@@ -84,18 +84,17 @@ QSGWindowsRenderLoop::QSGWindowsRenderLoop()
{
m_rc = static_cast<QSGDefaultRenderContext *>(m_sg->createRenderContext());
- m_animationDriver = m_sg->createAnimationDriver(m_sg);
- m_animationDriver->install();
-
- connect(m_animationDriver, SIGNAL(started()), this, SLOT(started()));
- connect(m_animationDriver, SIGNAL(stopped()), this, SLOT(stopped()));
-
m_vsyncDelta = 1000 / QGuiApplication::primaryScreen()->refreshRate();
if (m_vsyncDelta <= 0)
m_vsyncDelta = 16;
RLDEBUG("Windows Render Loop created");
+ m_animationDriver = m_sg->createAnimationDriver(m_sg);
+ connect(m_animationDriver, SIGNAL(started()), this, SLOT(started()));
+ connect(m_animationDriver, SIGNAL(stopped()), this, SLOT(stopped()));
+ m_animationDriver->install();
+
qsg_render_timer.start();
}
@@ -245,7 +244,7 @@ void QSGWindowsRenderLoop::windowDestroyed(QQuickWindow *window)
if (Q_UNLIKELY(!current))
qCDebug(QSG_LOG_RENDERLOOP) << "cleanup without an OpenGL context";
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
QQuickOpenGLShaderEffectMaterial::cleanupMaterialCache();
#endif
diff --git a/src/quick/scenegraph/scenegraph.pri b/src/quick/scenegraph/scenegraph.pri
index a659ca5e10..edf4aa08c5 100644
--- a/src/quick/scenegraph/scenegraph.pri
+++ b/src/quick/scenegraph/scenegraph.pri
@@ -113,7 +113,6 @@ qtConfig(opengl(es1|es2)?) {
$$PWD/qsgdefaultinternalrectanglenode.cpp \
$$PWD/qsgdefaultrendercontext.cpp \
$$PWD/qsgdefaultcontext.cpp \
- $$PWD/qsgdefaultspritenode.cpp \
$$PWD/util/qsgdefaultpainternode.cpp \
$$PWD/util/qsgdefaultrectanglenode.cpp \
$$PWD/util/qsgdefaultimagenode.cpp \
@@ -129,7 +128,6 @@ qtConfig(opengl(es1|es2)?) {
$$PWD/qsgdefaultglyphnode_p_p.h \
$$PWD/qsgdefaultinternalimagenode_p.h \
$$PWD/qsgdefaultinternalrectanglenode_p.h \
- $$PWD/qsgdefaultspritenode_p.h \
$$PWD/qsgdefaultrendercontext_p.h \
$$PWD/qsgdefaultcontext_p.h \
$$PWD/util/qsgdefaultpainternode_p.h \
@@ -139,6 +137,13 @@ qtConfig(opengl(es1|es2)?) {
$$PWD/qsgdefaultlayer_p.h \
$$PWD/qsgthreadedrenderloop_p.h \
$$PWD/qsgwindowsrenderloop_p.h
+
+ qtConfig(quick-sprite) {
+ SOURCES += \
+ $$PWD/qsgdefaultspritenode.cpp
+ HEADERS += \
+ $$PWD/qsgdefaultspritenode_p.h
+ }
}
# Built-in, non-plugin-based adaptations
diff --git a/src/quick/scenegraph/util/qsgatlastexture_p.h b/src/quick/scenegraph/util/qsgatlastexture_p.h
index cd24645fcf..3dee539547 100644
--- a/src/quick/scenegraph/util/qsgatlastexture_p.h
+++ b/src/quick/scenegraph/util/qsgatlastexture_p.h
@@ -131,26 +131,26 @@ public:
Texture(Atlas *atlas, const QRect &textureRect, const QImage &image);
~Texture();
- int textureId() const { return m_atlas->textureId(); }
- QSize textureSize() const { return atlasSubRectWithoutPadding().size(); }
+ int textureId() const override { return m_atlas->textureId(); }
+ QSize textureSize() const override { return atlasSubRectWithoutPadding().size(); }
void setHasAlphaChannel(bool alpha) { m_has_alpha = alpha; }
- bool hasAlphaChannel() const { return m_has_alpha; }
- bool hasMipmaps() const { return false; }
- bool isAtlasTexture() const { return true; }
+ bool hasAlphaChannel() const override { return m_has_alpha; }
+ bool hasMipmaps() const override { return false; }
+ bool isAtlasTexture() const override { return true; }
- QRectF normalizedTextureSubRect() const { return m_texture_coords_rect; }
+ QRectF normalizedTextureSubRect() const override { return m_texture_coords_rect; }
QRect atlasSubRect() const { return m_allocated_rect; }
QRect atlasSubRectWithoutPadding() const { return m_allocated_rect.adjusted(1, 1, -1, -1); }
bool isTexture() const { return true; }
- QSGTexture *removedFromAtlas() const;
+ QSGTexture *removedFromAtlas() const override;
void releaseImage() { m_image = QImage(); }
const QImage &image() const { return m_image; }
- void bind();
+ void bind() override;
private:
QRect m_allocated_rect;
diff --git a/src/quick/scenegraph/util/qsgdefaultpainternode.cpp b/src/quick/scenegraph/util/qsgdefaultpainternode.cpp
index e1aea290a3..389b9e0b4e 100644
--- a/src/quick/scenegraph/util/qsgdefaultpainternode.cpp
+++ b/src/quick/scenegraph/util/qsgdefaultpainternode.cpp
@@ -443,9 +443,21 @@ void QSGDefaultPainterNode::setContentsScale(qreal s)
markDirty(DirtyMaterial);
}
-void QSGDefaultPainterNode::setFastFBOResizing(bool dynamic)
+void QSGDefaultPainterNode::setFastFBOResizing(bool fastResizing)
{
- m_fastFBOResizing = dynamic;
+ if (m_fastFBOResizing == fastResizing)
+ return;
+
+ m_fastFBOResizing = fastResizing;
+ updateFBOSize();
+
+ if ((m_preferredRenderTarget == QQuickPaintedItem::FramebufferObject
+ || m_preferredRenderTarget == QQuickPaintedItem::InvertedYFramebufferObject)
+ && (!m_fbo || (m_fbo && m_fbo->size() != m_fboSize))) {
+ m_dirtyRenderTarget = true;
+ m_dirtyGeometry = true;
+ m_dirtyTexture = true;
+ }
}
QImage QSGDefaultPainterNode::toImage() const
diff --git a/src/quick/scenegraph/util/qsgdefaultpainternode_p.h b/src/quick/scenegraph/util/qsgdefaultpainternode_p.h
index 069ef155b1..084fc1e004 100644
--- a/src/quick/scenegraph/util/qsgdefaultpainternode_p.h
+++ b/src/quick/scenegraph/util/qsgdefaultpainternode_p.h
@@ -72,7 +72,7 @@ public:
void setDirtyRect(const QRect &rect) { m_dirty_rect = rect; }
- void bind();
+ void bind() override;
private:
QRect m_dirty_rect;
@@ -84,43 +84,43 @@ public:
QSGDefaultPainterNode(QQuickPaintedItem *item);
virtual ~QSGDefaultPainterNode();
- void setPreferredRenderTarget(QQuickPaintedItem::RenderTarget target);
+ void setPreferredRenderTarget(QQuickPaintedItem::RenderTarget target) override;
- void setSize(const QSize &size);
+ void setSize(const QSize &size) override;
QSize size() const { return m_size; }
- void setDirty(const QRect &dirtyRect = QRect());
+ void setDirty(const QRect &dirtyRect = QRect()) override;
- void setOpaquePainting(bool opaque);
+ void setOpaquePainting(bool opaque) override;
bool opaquePainting() const { return m_opaquePainting; }
- void setLinearFiltering(bool linearFiltering);
+ void setLinearFiltering(bool linearFiltering) override;
bool linearFiltering() const { return m_linear_filtering; }
- void setMipmapping(bool mipmapping);
+ void setMipmapping(bool mipmapping) override;
bool mipmapping() const { return m_mipmapping; }
- void setSmoothPainting(bool s);
+ void setSmoothPainting(bool s) override;
bool smoothPainting() const { return m_smoothPainting; }
- void setFillColor(const QColor &c);
+ void setFillColor(const QColor &c) override;
QColor fillColor() const { return m_fillColor; }
- void setContentsScale(qreal s);
+ void setContentsScale(qreal s) override;
qreal contentsScale() const { return m_contentsScale; }
- void setFastFBOResizing(bool dynamic);
+ void setFastFBOResizing(bool fastResizing) override;
bool fastFBOResizing() const { return m_fastFBOResizing; }
- void setTextureSize(const QSize &textureSize);
+ void setTextureSize(const QSize &textureSize) override;
QSize textureSize() const { return m_textureSize; }
- QImage toImage() const;
- void update();
+ QImage toImage() const override;
+ void update() override;
void paint();
- QSGTexture *texture() const { return m_texture; }
+ QSGTexture *texture() const override { return m_texture; }
private:
void updateTexture();
diff --git a/src/quick/scenegraph/util/qsgdepthstencilbuffer_p.h b/src/quick/scenegraph/util/qsgdepthstencilbuffer_p.h
index c2d0590532..f7c6923021 100644
--- a/src/quick/scenegraph/util/qsgdepthstencilbuffer_p.h
+++ b/src/quick/scenegraph/util/qsgdepthstencilbuffer_p.h
@@ -119,7 +119,7 @@ public:
virtual ~QSGDefaultDepthStencilBuffer();
protected:
- virtual void free();
+ void free() override;
};
diff --git a/src/quick/scenegraph/util/qsgflatcolormaterial.h b/src/quick/scenegraph/util/qsgflatcolormaterial.h
index 7f292a2a9b..4829ac3279 100644
--- a/src/quick/scenegraph/util/qsgflatcolormaterial.h
+++ b/src/quick/scenegraph/util/qsgflatcolormaterial.h
@@ -49,13 +49,13 @@ class Q_QUICK_EXPORT QSGFlatColorMaterial : public QSGMaterial
{
public:
QSGFlatColorMaterial();
- virtual QSGMaterialType *type() const;
- virtual QSGMaterialShader *createShader() const;
+ QSGMaterialType *type() const override;
+ QSGMaterialShader *createShader() const override;
void setColor(const QColor &color);
const QColor &color() const { return m_color; }
- int compare(const QSGMaterial *other) const;
+ int compare(const QSGMaterial *other) const override;
private:
QColor m_color;
diff --git a/src/quick/scenegraph/util/qsgshadersourcebuilder.cpp b/src/quick/scenegraph/util/qsgshadersourcebuilder.cpp
index caa296451e..25af1997a8 100644
--- a/src/quick/scenegraph/util/qsgshadersourcebuilder.cpp
+++ b/src/quick/scenegraph/util/qsgshadersourcebuilder.cpp
@@ -310,13 +310,10 @@ void QSGShaderSourceBuilder::addDefinition(const QByteArray &definition)
const char *insertionPos = extensionPos ? extensionPos : (versionPos ? versionPos : input);
// Construct a new shader string, inserting the definition
- QByteArray newSource;
- newSource.reserve(m_source.size() + definition.size() + 9);
- newSource += QByteArray::fromRawData(input, insertionPos - input);
- newSource += QByteArrayLiteral("#define ") + definition + QByteArrayLiteral("\n");
- newSource += QByteArray::fromRawData(insertionPos, m_source.size() - (insertionPos - input));
-
- m_source = newSource;
+ QByteArray newSource = QByteArray::fromRawData(input, insertionPos - input)
+ + "#define " + definition + '\n'
+ + QByteArray::fromRawData(insertionPos, m_source.size() - (insertionPos - input));
+ m_source = std::move(newSource);
}
void QSGShaderSourceBuilder::removeVersion()
diff --git a/src/quick/scenegraph/util/qsgsimplematerial.h b/src/quick/scenegraph/util/qsgsimplematerial.h
index d07a68e850..01f98767fd 100644
--- a/src/quick/scenegraph/util/qsgsimplematerial.h
+++ b/src/quick/scenegraph/util/qsgsimplematerial.h
@@ -149,8 +149,8 @@ public:
{
}
- QSGMaterialShader *createShader() const { return m_func(); }
- QSGMaterialType *type() const { return &m_type; }
+ QSGMaterialShader *createShader() const override { return m_func(); }
+ QSGMaterialType *type() const override { return &m_type; }
State *state() { return &m_state; }
const State *state() const { return &m_state; }
diff --git a/src/quick/scenegraph/util/qsgtexture_p.h b/src/quick/scenegraph/util/qsgtexture_p.h
index a0d7eb41e3..e09cbdbef1 100644
--- a/src/quick/scenegraph/util/qsgtexture_p.h
+++ b/src/quick/scenegraph/util/qsgtexture_p.h
@@ -87,19 +87,19 @@ public:
bool ownsTexture() const { return m_owns_texture; }
void setTextureId(int id);
- int textureId() const;
+ int textureId() const override;
void setTextureSize(const QSize &size) { m_texture_size = size; }
- QSize textureSize() const { return m_texture_size; }
+ QSize textureSize() const override { return m_texture_size; }
void setHasAlphaChannel(bool alpha) { m_has_alpha = alpha; }
- bool hasAlphaChannel() const { return m_has_alpha; }
+ bool hasAlphaChannel() const override { return m_has_alpha; }
- bool hasMipmaps() const { return mipmapFiltering() != QSGTexture::None; }
+ bool hasMipmaps() const override { return mipmapFiltering() != QSGTexture::None; }
void setImage(const QImage &image);
const QImage &image() { return m_image; }
- virtual void bind();
+ void bind() override;
static QSGPlainTexture *fromImage(const QImage &image) {
QSGPlainTexture *t = new QSGPlainTexture();
diff --git a/src/quick/scenegraph/util/qsgtexturematerial.h b/src/quick/scenegraph/util/qsgtexturematerial.h
index 02b59108b3..dc87131773 100644
--- a/src/quick/scenegraph/util/qsgtexturematerial.h
+++ b/src/quick/scenegraph/util/qsgtexturematerial.h
@@ -50,9 +50,9 @@ class Q_QUICK_EXPORT QSGOpaqueTextureMaterial : public QSGMaterial
public:
QSGOpaqueTextureMaterial();
- virtual QSGMaterialType *type() const;
- virtual QSGMaterialShader *createShader() const;
- virtual int compare(const QSGMaterial *other) const;
+ QSGMaterialType *type() const override;
+ QSGMaterialShader *createShader() const override;
+ int compare(const QSGMaterial *other) const override;
void setTexture(QSGTexture *texture);
QSGTexture *texture() const { return m_texture; }
@@ -84,8 +84,8 @@ protected:
class Q_QUICK_EXPORT QSGTextureMaterial : public QSGOpaqueTextureMaterial
{
public:
- virtual QSGMaterialType *type() const;
- virtual QSGMaterialShader *createShader() const;
+ QSGMaterialType *type() const override;
+ QSGMaterialShader *createShader() const override;
};
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgtexturematerial_p.h b/src/quick/scenegraph/util/qsgtexturematerial_p.h
index 75e5877a72..093d820801 100644
--- a/src/quick/scenegraph/util/qsgtexturematerial_p.h
+++ b/src/quick/scenegraph/util/qsgtexturematerial_p.h
@@ -61,13 +61,13 @@ class Q_QUICK_PRIVATE_EXPORT QSGOpaqueTextureMaterialShader : public QSGMaterial
public:
QSGOpaqueTextureMaterialShader();
- virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect);
- virtual char const *const *attributeNames() const;
+ void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
+ char const *const *attributeNames() const override;
static QSGMaterialType type;
protected:
- virtual void initialize();
+ void initialize() override;
int m_matrix_id;
};
@@ -77,8 +77,8 @@ class QSGTextureMaterialShader : public QSGOpaqueTextureMaterialShader
public:
QSGTextureMaterialShader();
- virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect);
- virtual void initialize();
+ void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
+ void initialize() override;
static QSGMaterialType type;
diff --git a/src/quick/scenegraph/util/qsgvertexcolormaterial.h b/src/quick/scenegraph/util/qsgvertexcolormaterial.h
index 68f32d8af0..65cb642d92 100644
--- a/src/quick/scenegraph/util/qsgvertexcolormaterial.h
+++ b/src/quick/scenegraph/util/qsgvertexcolormaterial.h
@@ -49,11 +49,11 @@ class Q_QUICK_EXPORT QSGVertexColorMaterial : public QSGMaterial
public:
QSGVertexColorMaterial();
- int compare(const QSGMaterial *other) const;
+ int compare(const QSGMaterial *other) const override;
protected:
- virtual QSGMaterialType *type() const;
- virtual QSGMaterialShader *createShader() const;
+ QSGMaterialType *type() const override;
+ QSGMaterialShader *createShader() const override;
};
QT_END_NAMESPACE
diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp
index 206b92eb81..9de474ac36 100644
--- a/src/quick/util/qquickanimation.cpp
+++ b/src/quick/util/qquickanimation.cpp
@@ -1198,14 +1198,14 @@ QAbstractAnimationJob* QQuickPropertyAction::transition(QQuickStateActions &acti
struct QQuickSetPropertyAnimationAction : public QAbstractAnimationAction
{
QQuickStateActions actions;
- virtual void doAction()
+ void doAction() override
{
for (int ii = 0; ii < actions.count(); ++ii) {
const QQuickStateAction &action = actions.at(ii);
QQmlPropertyPrivate::write(action.property, action.toValue, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding);
}
}
- virtual void debugAction(QDebug d, int indentLevel) const {
+ void debugAction(QDebug d, int indentLevel) const override {
QByteArray ind(indentLevel, ' ');
for (int ii = 0; ii < actions.count(); ++ii) {
const QQuickStateAction &action = actions.at(ii);
diff --git a/src/quick/util/qquickanimation_p.h b/src/quick/util/qquickanimation_p.h
index 145f2656d2..e27871dcaa 100644
--- a/src/quick/util/qquickanimation_p.h
+++ b/src/quick/util/qquickanimation_p.h
@@ -114,8 +114,8 @@ public:
void setDisableUserControl();
void setEnableUserControl();
bool userControlDisabled() const;
- void classBegin();
- void componentComplete();
+ void classBegin() override;
+ void componentComplete() override;
virtual ThreadingModel threadingModel() const;
@@ -150,7 +150,7 @@ public:
private Q_SLOTS:
void componentFinalized();
private:
- virtual void setTarget(const QQmlProperty &);
+ void setTarget(const QQmlProperty &) override;
void notifyRunningChanged(bool running);
friend class QQuickBehavior;
friend class QQuickBehaviorPrivate;
@@ -179,7 +179,7 @@ protected:
QAbstractAnimationJob* transition(QQuickStateActions &actions,
QQmlProperties &modified,
TransitionDirection direction,
- QObject *defaultTarget = 0);
+ QObject *defaultTarget = 0) override;
};
class QQuickScriptActionPrivate;
@@ -202,10 +202,10 @@ public:
void setStateChangeScriptName(const QString &);
protected:
- virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
+ QAbstractAnimationJob* transition(QQuickStateActions &actions,
QQmlProperties &modified,
TransitionDirection direction,
- QObject *defaultTarget = 0);
+ QObject *defaultTarget = 0) override;
};
class QQuickPropertyActionPrivate;
@@ -247,10 +247,10 @@ Q_SIGNALS:
void propertyChanged();
protected:
- virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
+ QAbstractAnimationJob* transition(QQuickStateActions &actions,
QQmlProperties &modified,
TransitionDirection direction,
- QObject *defaultTarget = 0);
+ QObject *defaultTarget = 0) override;
};
class QQuickPropertyAnimationPrivate;
@@ -303,10 +303,10 @@ protected:
QObject *defaultTarget = 0);
QQuickPropertyAnimation(QQuickPropertyAnimationPrivate &dd, QObject *parent);
- virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
+ QAbstractAnimationJob* transition(QQuickStateActions &actions,
QQmlProperties &modified,
TransitionDirection direction,
- QObject *defaultTarget = 0);
+ QObject *defaultTarget = 0) override;
Q_SIGNALS:
void durationChanged(int);
void fromChanged(const QVariant &);
@@ -438,11 +438,11 @@ public:
virtual ~QQuickSequentialAnimation();
protected:
- virtual ThreadingModel threadingModel() const;
- virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
+ ThreadingModel threadingModel() const override;
+ QAbstractAnimationJob* transition(QQuickStateActions &actions,
QQmlProperties &modified,
TransitionDirection direction,
- QObject *defaultTarget = 0);
+ QObject *defaultTarget = 0) override;
};
class Q_QUICK_PRIVATE_EXPORT QQuickParallelAnimation : public QQuickAnimationGroup
@@ -455,11 +455,11 @@ public:
virtual ~QQuickParallelAnimation();
protected:
- virtual ThreadingModel threadingModel() const;
- virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
+ ThreadingModel threadingModel() const override;
+ QAbstractAnimationJob* transition(QQuickStateActions &actions,
QQmlProperties &modified,
TransitionDirection direction,
- QObject *defaultTarget = 0);
+ QObject *defaultTarget = 0) override;
};
diff --git a/src/quick/util/qquickanimation_p_p.h b/src/quick/util/qquickanimation_p_p.h
index ea7bf62171..a7abc5a004 100644
--- a/src/quick/util/qquickanimation_p_p.h
+++ b/src/quick/util/qquickanimation_p_p.h
@@ -88,8 +88,8 @@ class QAnimationActionProxy : public QAbstractAnimationAction
{
public:
QAnimationActionProxy(T *instance) : m_instance(instance) {}
- virtual void doAction() { (m_instance->*method)(); }
- virtual void debugAction(QDebug d, int indentLevel) const { (m_instance->*debugMethod)(d, indentLevel); }
+ void doAction() override { (m_instance->*method)(); }
+ void debugAction(QDebug d, int indentLevel) const override { (m_instance->*debugMethod)(d, indentLevel); }
private:
T *m_instance;
};
@@ -104,13 +104,13 @@ public:
QActionAnimation(QAbstractAnimationAction *action);
~QActionAnimation();
- virtual int duration() const;
+ int duration() const override;
void setAnimAction(QAbstractAnimationAction *action);
protected:
- virtual void updateCurrentTime(int);
- virtual void updateState(State newState, State oldState);
- void debugAnimation(QDebug d) const;
+ void updateCurrentTime(int) override;
+ void updateState(State newState, State oldState) override;
+ void debugAnimation(QDebug d) const override;
private:
QAbstractAnimationAction *animAction;
@@ -137,16 +137,16 @@ public:
void setFromSourcedValue(bool *value) { fromSourced = value; }
- int duration() const { return m_duration; }
+ int duration() const override { return m_duration; }
void setDuration(int msecs) { m_duration = msecs; }
QEasingCurve easingCurve() const { return easing; }
void setEasingCurve(const QEasingCurve &curve) { easing = curve; }
protected:
- void updateCurrentTime(int currentTime);
- void topLevelAnimationLoopChanged();
- void debugAnimation(QDebug d) const;
+ void updateCurrentTime(int currentTime) override;
+ void topLevelAnimationLoopChanged() override;
+ void debugAnimation(QDebug d) const override;
private:
QQuickBulkValueUpdater *animValue;
@@ -162,9 +162,9 @@ class QTickAnimationProxy : public QAbstractAnimationJob
Q_DISABLE_COPY(QTickAnimationProxy)
public:
QTickAnimationProxy(T *instance) : QAbstractAnimationJob(), m_instance(instance) {}
- virtual int duration() const { return -1; }
+ int duration() const override { return -1; }
protected:
- virtual void updateCurrentTime(int msec) { (m_instance->*method)(msec); }
+ void updateCurrentTime(int msec) override { (m_instance->*method)(msec); }
private:
T *m_instance;
@@ -192,7 +192,7 @@ public:
int loopCount;
void commence();
- virtual void animationFinished(QAbstractAnimationJob *);
+ void animationFinished(QAbstractAnimationJob *) override;
QQmlProperty defaultProperty;
@@ -309,9 +309,9 @@ public:
QQuickAnimationPropertyUpdater() : interpolatorType(0), interpolator(0), prevInterpolatorType(0), reverse(false), fromSourced(false), fromDefined(false), wasDeleted(0) {}
~QQuickAnimationPropertyUpdater();
- void setValue(qreal v);
+ void setValue(qreal v) override;
- void debugUpdater(QDebug d, int indentLevel) const;
+ void debugUpdater(QDebug d, int indentLevel) const override;
QQuickStateActions actions;
int interpolatorType; //for Number/ColorAnimation
diff --git a/src/quick/util/qquickanimationcontroller.cpp b/src/quick/util/qquickanimationcontroller.cpp
index 8b6968ad98..4bc2d6319e 100644
--- a/src/quick/util/qquickanimationcontroller.cpp
+++ b/src/quick/util/qquickanimationcontroller.cpp
@@ -50,8 +50,8 @@ class QQuickAnimationControllerPrivate : public QObjectPrivate, QAnimationJobCha
public:
QQuickAnimationControllerPrivate()
: progress(0.0), animation(0), animationInstance(0), finalized(false) {}
- virtual void animationFinished(QAbstractAnimationJob *job);
- virtual void animationCurrentTimeChanged(QAbstractAnimationJob *job, int currentTime);
+ void animationFinished(QAbstractAnimationJob *job) override;
+ void animationCurrentTimeChanged(QAbstractAnimationJob *job, int currentTime) override;
qreal progress;
diff --git a/src/quick/util/qquickanimationcontroller_p.h b/src/quick/util/qquickanimationcontroller_p.h
index e37bb90a0a..43555ac1c1 100644
--- a/src/quick/util/qquickanimationcontroller_p.h
+++ b/src/quick/util/qquickanimationcontroller_p.h
@@ -78,8 +78,8 @@ public:
QQuickAbstractAnimation *animation() const;
void setAnimation(QQuickAbstractAnimation *animation);
- void classBegin();
- void componentComplete() {}
+ void classBegin() override;
+ void componentComplete() override {}
Q_SIGNALS:
void progressChanged();
void animationChanged();
diff --git a/src/quick/util/qquickanimator.cpp b/src/quick/util/qquickanimator.cpp
index 100b7bd402..5d2af0f940 100644
--- a/src/quick/util/qquickanimator.cpp
+++ b/src/quick/util/qquickanimator.cpp
@@ -502,7 +502,8 @@ QQuickRotationAnimator::RotationDirection QQuickRotationAnimator::direction() co
Q_D(const QQuickRotationAnimator);
return d->direction;
}
-#ifndef QT_NO_OPENGL
+
+#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
/*!
\qmltype UniformAnimator
\instantiates QQuickUniformAnimator
diff --git a/src/quick/util/qquickanimator_p.h b/src/quick/util/qquickanimator_p.h
index f1e2d4e1d9..92c66299dc 100644
--- a/src/quick/util/qquickanimator_p.h
+++ b/src/quick/util/qquickanimator_p.h
@@ -86,13 +86,13 @@ public:
void setFrom(qreal from);
protected:
- ThreadingModel threadingModel() const { return RenderThread; }
+ ThreadingModel threadingModel() const override { return RenderThread; }
virtual QQuickAnimatorJob *createJob() const = 0;
virtual QString propertyName() const = 0;
QAbstractAnimationJob *transition(QQuickStateActions &actions,
QQmlProperties &modified,
TransitionDirection,
- QObject *);
+ QObject *) override;
QQuickAnimator(QQuickAnimatorPrivate &dd, QObject *parent = 0);
QQuickAnimator(QObject *parent = 0);
@@ -112,8 +112,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickScaleAnimator : public QQuickAnimator
public:
QQuickScaleAnimator(QObject *parent = 0);
protected:
- QQuickAnimatorJob *createJob() const;
- QString propertyName() const { return QStringLiteral("scale"); }
+ QQuickAnimatorJob *createJob() const override;
+ QString propertyName() const override { return QStringLiteral("scale"); }
};
class Q_QUICK_PRIVATE_EXPORT QQuickXAnimator : public QQuickAnimator
@@ -122,8 +122,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickXAnimator : public QQuickAnimator
public:
QQuickXAnimator(QObject *parent = 0);
protected:
- QQuickAnimatorJob *createJob() const;
- QString propertyName() const{ return QStringLiteral("x"); }
+ QQuickAnimatorJob *createJob() const override;
+ QString propertyName() const override { return QStringLiteral("x"); }
};
class Q_QUICK_PRIVATE_EXPORT QQuickYAnimator : public QQuickAnimator
@@ -132,8 +132,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickYAnimator : public QQuickAnimator
public:
QQuickYAnimator(QObject *parent = 0);
protected:
- QQuickAnimatorJob *createJob() const;
- QString propertyName() const { return QStringLiteral("y"); }
+ QQuickAnimatorJob *createJob() const override;
+ QString propertyName() const override { return QStringLiteral("y"); }
};
class Q_QUICK_PRIVATE_EXPORT QQuickOpacityAnimator : public QQuickAnimator
@@ -142,8 +142,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickOpacityAnimator : public QQuickAnimator
public:
QQuickOpacityAnimator(QObject *parent = 0);
protected:
- QQuickAnimatorJob *createJob() const;
- QString propertyName() const { return QStringLiteral("opacity"); }
+ QQuickAnimatorJob *createJob() const override;
+ QString propertyName() const override { return QStringLiteral("opacity"); }
};
class QQuickRotationAnimatorPrivate;
@@ -166,10 +166,11 @@ Q_SIGNALS:
void directionChanged(RotationDirection dir);
protected:
- QQuickAnimatorJob *createJob() const;
- QString propertyName() const { return QStringLiteral("rotation"); }
+ QQuickAnimatorJob *createJob() const override;
+ QString propertyName() const override { return QStringLiteral("rotation"); }
};
-#ifndef QT_NO_OPENGL
+
+#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
class QQuickUniformAnimatorPrivate;
class Q_QUICK_PRIVATE_EXPORT QQuickUniformAnimator : public QQuickAnimator
{
@@ -187,8 +188,8 @@ Q_SIGNALS:
void uniformChanged(const QString &);
protected:
- QQuickAnimatorJob *createJob() const;
- QString propertyName() const;
+ QQuickAnimatorJob *createJob() const override;
+ QString propertyName() const override;
};
#endif
@@ -200,7 +201,7 @@ QML_DECLARE_TYPE(QQuickYAnimator)
QML_DECLARE_TYPE(QQuickScaleAnimator)
QML_DECLARE_TYPE(QQuickRotationAnimator)
QML_DECLARE_TYPE(QQuickOpacityAnimator)
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
QML_DECLARE_TYPE(QQuickUniformAnimator)
#endif
#endif // QQUICKANIMATOR_P_H
diff --git a/src/quick/util/qquickanimatorcontroller.cpp b/src/quick/util/qquickanimatorcontroller.cpp
index 6d8167413e..2f96c511c0 100644
--- a/src/quick/util/qquickanimatorcontroller.cpp
+++ b/src/quick/util/qquickanimatorcontroller.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Gunnar Sletta <gunnar@sletta.org>
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -50,228 +51,116 @@
QT_BEGIN_NAMESPACE
-QQuickAnimatorController::QQuickAnimatorController(QQuickWindow *window)
- : m_window(window)
- , m_nodesAreInvalid(false)
-{
- m_guiEntity = new QQuickAnimatorControllerGuiThreadEntity();
- m_guiEntity->controller = this;
- connect(window, SIGNAL(frameSwapped()), m_guiEntity, SLOT(frameSwapped()));
-}
-
-void QQuickAnimatorControllerGuiThreadEntity::frameSwapped()
+QQuickAnimatorController::~QQuickAnimatorController()
{
- if (!controller.isNull())
- controller->stopProxyJobs();
}
-QQuickAnimatorController::~QQuickAnimatorController()
+QQuickAnimatorController::QQuickAnimatorController(QQuickWindow *window)
+ : m_window(window)
{
- // The proxy job might already have been deleted, in which case we
- // need to avoid calling functions on them. Then delete the job.
- for (QAbstractAnimationJob *job : qAsConst(m_deleting)) {
- m_starting.take(job);
- m_stopping.take(job);
- m_animatorRoots.take(job);
- delete job;
- }
-
- for (QQuickAnimatorProxyJob *proxy : qAsConst(m_animatorRoots))
- proxy->controllerWasDeleted();
- for (auto it = m_animatorRoots.keyBegin(), end = m_animatorRoots.keyEnd(); it != end; ++it)
- delete *it;
-
- // Delete those who have been started, stopped and are now still
- // pending for restart.
- for (auto it = m_starting.keyBegin(), end = m_starting.keyEnd(); it != end; ++it) {
- QAbstractAnimationJob *job = *it;
- if (!m_animatorRoots.contains(job))
- delete job;
- }
-
- delete m_guiEntity;
}
-static void qquickanimator_invalidate_node(QAbstractAnimationJob *job)
+static void qquickanimator_invalidate_jobs(QAbstractAnimationJob *job)
{
if (job->isRenderThreadJob()) {
- static_cast<QQuickAnimatorJob *>(job)->nodeWasDestroyed();
+ static_cast<QQuickAnimatorJob *>(job)->invalidate();
} else if (job->isGroup()) {
QAnimationGroupJob *g = static_cast<QAnimationGroupJob *>(job);
for (QAbstractAnimationJob *a = g->firstChild(); a; a = a->nextSibling())
- qquickanimator_invalidate_node(a);
+ qquickanimator_invalidate_jobs(a);
}
}
void QQuickAnimatorController::windowNodesDestroyed()
{
- m_nodesAreInvalid = true;
- for (QHash<QAbstractAnimationJob *, QQuickAnimatorProxyJob *>::const_iterator it = m_animatorRoots.constBegin();
- it != m_animatorRoots.constEnd(); ++it) {
- qquickanimator_invalidate_node(it.key());
+ for (const QSharedPointer<QAbstractAnimationJob> &toStop : qAsConst(m_rootsPendingStop)) {
+ qquickanimator_invalidate_jobs(toStop.data());
+ toStop->stop();
}
-}
+ m_rootsPendingStop.clear();
-void QQuickAnimatorController::itemDestroyed(QObject *o)
-{
- m_deletedSinceLastFrame << (QQuickItem *) o;
+ // Clear animation roots and iterate over a temporary to avoid that job->stop()
+ // modifies the m_animationRoots and messes with our iteration
+ const auto roots = m_animationRoots;
+ m_animationRoots.clear();
+ for (const QSharedPointer<QAbstractAnimationJob> &job : roots) {
+ qquickanimator_invalidate_jobs(job.data());
+
+ // Stop it and add it to the list of pending start so it might get
+ // started later on.
+ job->stop();
+ m_rootsPendingStart.insert(job);
+ }
}
void QQuickAnimatorController::advance()
{
bool running = false;
- for (QHash<QAbstractAnimationJob *, QQuickAnimatorProxyJob *>::const_iterator it = m_animatorRoots.constBegin();
- !running && it != m_animatorRoots.constEnd(); ++it) {
- if (it.key()->isRunning())
+ for (const QSharedPointer<QAbstractAnimationJob> &job : qAsConst(m_animationRoots)) {
+ if (job->isRunning()) {
running = true;
+ break;
+ }
}
- // It was tempting to only run over the active animations, but we need to push
- // the values for the transforms that finished in the last frame and those will
- // have been removed already...
- lock();
- for (QHash<QQuickItem *, QQuickTransformAnimatorJob::Helper *>::const_iterator it = m_transforms.constBegin();
- it != m_transforms.constEnd(); ++it) {
- QQuickTransformAnimatorJob::Helper *xform = *it;
- // Set to zero when the item was deleted in beforeNodeSync().
- if (!xform->item)
- continue;
- (*it)->apply();
- }
- unlock();
+ for (QQuickAnimatorJob *job : qAsConst(m_runningAnimators))
+ job->commit();
if (running)
m_window->update();
}
-static void qquick_initialize_helper(QAbstractAnimationJob *job, QQuickAnimatorController *c, bool attachListener)
+static void qquickanimator_sync_before_start(QAbstractAnimationJob *job)
{
if (job->isRenderThreadJob()) {
- QQuickAnimatorJob *j = static_cast<QQuickAnimatorJob *>(job);
- // Note: since a QQuickAnimatorJob::m_target is a QPointer,
- // if m_target is destroyed between the time it was set
- // as the target of the animator job and before this step,
- // (e.g a Loader being set inactive just after starting the animator)
- // we are sure it will be NULL and won't be dangling around
- if (!j->target()) {
- return;
- } else if (c->m_deletedSinceLastFrame.contains(j->target())) {
- j->targetWasDeleted();
- } else {
- if (attachListener)
- j->addAnimationChangeListener(c, QAbstractAnimationJob::StateChange);
- j->initialize(c);
- }
+ static_cast<QQuickAnimatorJob *>(job)->preSync();
} else if (job->isGroup()) {
QAnimationGroupJob *g = static_cast<QAnimationGroupJob *>(job);
for (QAbstractAnimationJob *a = g->firstChild(); a; a = a->nextSibling())
- qquick_initialize_helper(a, c, attachListener);
+ qquickanimator_sync_before_start(a);
}
}
void QQuickAnimatorController::beforeNodeSync()
{
- for (QAbstractAnimationJob *job : qAsConst(m_deleting)) {
- m_starting.take(job);
- m_stopping.take(job);
- m_animatorRoots.take(job);
- job->stop();
- delete job;
- }
- m_deleting.clear();
+ for (const QSharedPointer<QAbstractAnimationJob> &toStop : qAsConst(m_rootsPendingStop))
+ toStop->stop();
+ m_rootsPendingStop.clear();
- if (m_starting.size())
- m_window->update();
- for (QQuickAnimatorProxyJob *proxy : qAsConst(m_starting)) {
- QAbstractAnimationJob *job = proxy->job();
- job->addAnimationChangeListener(this, QAbstractAnimationJob::Completion);
- qquick_initialize_helper(job, this, true);
- m_animatorRoots[job] = proxy;
- job->start();
- proxy->startedByController();
- }
- m_starting.clear();
- for (QQuickAnimatorProxyJob *proxy : qAsConst(m_stopping)) {
- QAbstractAnimationJob *job = proxy->job();
- job->stop();
- }
- m_stopping.clear();
-
- // First sync after a window was hidden or otherwise invalidated.
- // call initialize again to pick up new nodes..
- if (m_nodesAreInvalid) {
- for (QHash<QAbstractAnimationJob *, QQuickAnimatorProxyJob *>::const_iterator it = m_animatorRoots.constBegin();
- it != m_animatorRoots.constEnd(); ++it) {
- qquick_initialize_helper(it.key(), this, false);
- }
- m_nodesAreInvalid = false;
- }
+ for (QQuickAnimatorJob *job : qAsConst(m_runningAnimators))
+ job->preSync();
- for (QQuickAnimatorJob *job : qAsConst(m_activeLeafAnimations)) {
- if (!job->target())
- continue;
- else if (m_deletedSinceLastFrame.contains(job->target()))
- job->targetWasDeleted();
- else if (job->isTransform()) {
- QQuickTransformAnimatorJob *xform = static_cast<QQuickTransformAnimatorJob *>(job);
- xform->transformHelper()->sync();
- }
- }
- for (QQuickItem *wiped : qAsConst(m_deletedSinceLastFrame)) {
- QQuickTransformAnimatorJob::Helper *helper = m_transforms.take(wiped);
- // Helper will now already have been reset in all animators referencing it.
- delete helper;
- }
+ // Start pending jobs
+ for (const QSharedPointer<QAbstractAnimationJob> &job : qAsConst(m_rootsPendingStart)) {
+ Q_ASSERT(!job->isRunning());
- m_deletedSinceLastFrame.clear();
-}
+ // We want to make sure that presync is called before
+ // updateAnimationTime is called the very first time, so before
+ // starting a tree of jobs, we go through it and call preSync on all
+ // its animators.
+ qquickanimator_sync_before_start(job.data());
-void QQuickAnimatorController::afterNodeSync()
-{
- for (QQuickAnimatorJob *job : qAsConst(m_activeLeafAnimations)) {
- if (job->target())
- job->afterNodeSync();
+ // The start the job..
+ job->start();
+ m_animationRoots.insert(job.data(), job);
}
-}
+ m_rootsPendingStart.clear();
-void QQuickAnimatorController::proxyWasDestroyed(QQuickAnimatorProxyJob *proxy)
-{
- lock();
- m_proxiesToStop.remove(proxy);
- unlock();
+ // Issue an update directly on the window to force another render pass.
+ if (m_animationRoots.size())
+ m_window->update();
}
-void QQuickAnimatorController::stopProxyJobs()
+void QQuickAnimatorController::afterNodeSync()
{
- // Need to make a copy under lock and then stop while unlocked.
- // Stopping triggers writeBack which in turn may lock, so it needs
- // to be outside the lock. It is also safe because deletion of
- // proxies happens on the GUI thread, where this code is also executing.
- lock();
- const QSet<QQuickAnimatorProxyJob *> jobs = m_proxiesToStop;
- m_proxiesToStop.clear();
- unlock();
- for (QQuickAnimatorProxyJob *p : jobs)
- p->stop();
+ for (QQuickAnimatorJob *job : qAsConst(m_runningAnimators))
+ job->postSync();
}
void QQuickAnimatorController::animationFinished(QAbstractAnimationJob *job)
{
- /* We are currently on the render thread and m_deleting is primarily
- * being written on the GUI Thread and read during sync. However, we don't
- * need to lock here as this is a direct result of animationDriver->advance()
- * which is already locked. For non-threaded render loops no locking is
- * needed in any case.
- */
- if (!m_deleting.contains(job)) {
- QQuickAnimatorProxyJob *proxy = m_animatorRoots.value(job);
- if (proxy) {
- m_window->update();
- m_proxiesToStop << proxy;
- }
- // else already gone...
- }
+ m_animationRoots.remove(job);
}
void QQuickAnimatorController::animationStateChanged(QAbstractAnimationJob *job,
@@ -281,43 +170,52 @@ void QQuickAnimatorController::animationStateChanged(QAbstractAnimationJob *job,
Q_ASSERT(job->isRenderThreadJob());
QQuickAnimatorJob *animator = static_cast<QQuickAnimatorJob *>(job);
if (newState == QAbstractAnimationJob::Running) {
- m_activeLeafAnimations << animator;
- animator->setHasBeenRunning(true);
+ m_runningAnimators.insert(animator);
} else if (oldState == QAbstractAnimationJob::Running) {
- m_activeLeafAnimations.remove(animator);
+ animator->commit();
+ m_runningAnimators.remove(animator);
}
}
-
void QQuickAnimatorController::requestSync()
{
// Force a "sync" pass as the newly started animation needs to sync properties from GUI.
m_window->maybeUpdate();
}
-// These functions are called on the GUI thread.
-void QQuickAnimatorController::startJob(QQuickAnimatorProxyJob *proxy, QAbstractAnimationJob *job)
+// All this is being executed on the GUI thread while the animator controller
+// is locked.
+void QQuickAnimatorController::start_helper(QAbstractAnimationJob *job)
{
- proxy->markJobManagedByController();
- m_starting[job] = proxy;
- m_stopping.remove(job);
- requestSync();
+ if (job->isRenderThreadJob()) {
+ QQuickAnimatorJob *j = static_cast<QQuickAnimatorJob *>(job);
+ j->addAnimationChangeListener(this, QAbstractAnimationJob::StateChange);
+ j->initialize(this);
+ } else if (job->isGroup()) {
+ QAnimationGroupJob *g = static_cast<QAnimationGroupJob *>(job);
+ for (QAbstractAnimationJob *a = g->firstChild(); a; a = a->nextSibling())
+ start_helper(a);
+ }
}
-void QQuickAnimatorController::stopJob(QQuickAnimatorProxyJob *proxy, QAbstractAnimationJob *job)
+// Called by the proxy when it is time to kick off an animation job
+void QQuickAnimatorController::start(const QSharedPointer<QAbstractAnimationJob> &job)
{
- m_stopping[job] = proxy;
- m_starting.remove(job);
+ m_rootsPendingStart.insert(job);
+ m_rootsPendingStop.remove(job);
+ job->addAnimationChangeListener(this, QAbstractAnimationJob::Completion);
+ start_helper(job.data());
requestSync();
}
-void QQuickAnimatorController::deleteJob(QAbstractAnimationJob *job)
+
+// Called by the proxy when it is time to stop an animation job.
+void QQuickAnimatorController::cancel(const QSharedPointer<QAbstractAnimationJob> &job)
{
- lock();
- m_deleting << job;
- requestSync();
- unlock();
+ m_rootsPendingStart.remove(job);
+ m_rootsPendingStop.insert(job);
}
+
QT_END_NAMESPACE
diff --git a/src/quick/util/qquickanimatorcontroller_p.h b/src/quick/util/qquickanimatorcontroller_p.h
index 0a9902cc30..428a6700d4 100644
--- a/src/quick/util/qquickanimatorcontroller_p.h
+++ b/src/quick/util/qquickanimatorcontroller_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Gunnar Sletta <gunnar@sletta.org>
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -60,8 +61,6 @@
QT_BEGIN_NAMESPACE
-class QQuickAnimatorControllerGuiThreadEntity;
-
class QQuickAnimatorController : public QObject, public QAnimationJobChangeListener
{
Q_OBJECT
@@ -74,54 +73,37 @@ public:
void beforeNodeSync();
void afterNodeSync();
- void animationFinished(QAbstractAnimationJob *job);
- void animationStateChanged(QAbstractAnimationJob *job, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState);
+ void animationFinished(QAbstractAnimationJob *job) override;
+ void animationStateChanged(QAbstractAnimationJob *job, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override;
void requestSync();
// These are called from the GUI thread (the proxy)
- void startJob(QQuickAnimatorProxyJob *proxy, QAbstractAnimationJob *job);
- void stopJob(QQuickAnimatorProxyJob *proxy, QAbstractAnimationJob *job);
- void deleteJob(QAbstractAnimationJob *job);
+ void start(const QSharedPointer<QAbstractAnimationJob> &job);
+ void cancel(const QSharedPointer<QAbstractAnimationJob> &job);
+ bool isPendingStart(const QSharedPointer<QAbstractAnimationJob> &job) const { return m_rootsPendingStart.contains(job); }
void lock() { m_mutex.lock(); }
void unlock() { m_mutex.unlock(); }
-
void proxyWasDestroyed(QQuickAnimatorProxyJob *proxy);
void stopProxyJobs();
void windowNodesDestroyed();
-public Q_SLOTS:
- void itemDestroyed(QObject *);
+ QQuickWindow *window() const { return m_window; }
-public:
- // These are manipulated from the GUI thread and should only
- // be updated during the sync() phase.
- QHash<QAbstractAnimationJob *, QQuickAnimatorProxyJob *> m_starting;
- QHash<QAbstractAnimationJob *, QQuickAnimatorProxyJob *> m_stopping;
- QSet<QAbstractAnimationJob *> m_deleting;
-
- QHash<QAbstractAnimationJob *, QQuickAnimatorProxyJob *> m_animatorRoots;
- QSet<QQuickAnimatorJob *> m_activeLeafAnimations;
- QHash<QQuickItem *, QQuickTransformAnimatorJob::Helper *> m_transforms;
- QSet<QQuickItem *> m_deletedSinceLastFrame;
- QQuickWindow *m_window;
- QQuickAnimatorControllerGuiThreadEntity *m_guiEntity;
- QSet<QQuickAnimatorProxyJob *> m_proxiesToStop;
- QMutex m_mutex;
+private:
+ void start_helper(QAbstractAnimationJob *job);
+ void cancel_helper(QAbstractAnimationJob *job);
- bool m_nodesAreInvalid;
-};
-
-class QQuickAnimatorControllerGuiThreadEntity : public QObject
-{
- Q_OBJECT
public:
- QPointer<QQuickAnimatorController> controller;
+ QSet<QQuickAnimatorJob * > m_runningAnimators;
+ QHash<QAbstractAnimationJob *, QSharedPointer<QAbstractAnimationJob> > m_animationRoots;
+ QSet<QSharedPointer<QAbstractAnimationJob> > m_rootsPendingStop;
+ QSet<QSharedPointer<QAbstractAnimationJob> > m_rootsPendingStart;
-public Q_SLOTS:
- void frameSwapped();
+ QQuickWindow *m_window;
+ QMutex m_mutex;
};
diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp
index a0c787dae5..5dd16407b8 100644
--- a/src/quick/util/qquickanimatorjob.cpp
+++ b/src/quick/util/qquickanimatorjob.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Gunnar Sletta <gunnar@sletta.org>
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -43,7 +44,7 @@
#include "qquickanimator_p_p.h"
#include <private/qquickwindow_p.h>
#include <private/qquickitem_p.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
# include <private/qquickopenglshadereffectnode_p.h>
# include <private/qquickopenglshadereffect_p.h>
#endif
@@ -54,12 +55,42 @@
QT_BEGIN_NAMESPACE
+struct QQuickTransformAnimatorHelperStore
+{
+ QHash<QQuickItem *, QQuickTransformAnimatorJob::Helper *> store;
+ QMutex mutex;
+
+ QQuickTransformAnimatorJob::Helper *acquire(QQuickItem *item) {
+ mutex.lock();
+ QQuickTransformAnimatorJob::Helper *helper = store.value(item);
+ if (!helper) {
+ helper = new QQuickTransformAnimatorJob::Helper();
+ helper->item = item;
+ store[item] = helper;
+ } else {
+ ++helper->ref;
+ }
+ mutex.unlock();
+ return helper;
+ }
+
+ void release(QQuickTransformAnimatorJob::Helper *helper) {
+ mutex.lock();
+ if (--helper->ref == 0) {
+ store.remove(helper->item);
+ delete helper;
+ }
+ mutex.unlock();
+ }
+};
+Q_GLOBAL_STATIC(QQuickTransformAnimatorHelperStore, qquick_transform_animatorjob_helper_store);
+
QQuickAnimatorProxyJob::QQuickAnimatorProxyJob(QAbstractAnimationJob *job, QObject *item)
- : m_controller(0)
- , m_job(job)
+ : m_controller(nullptr)
, m_internalState(State_Stopped)
- , m_jobManagedByController(false)
{
+ m_job.reset(job);
+
m_isRenderThreadProxy = true;
m_animation = qobject_cast<QQuickAbstractAnimation *>(item);
@@ -87,57 +118,58 @@ QQuickAnimatorProxyJob::QQuickAnimatorProxyJob(QAbstractAnimationJob *job, QObje
QQuickItem *item = qobject_cast<QQuickItem *>(ctx);
if (item->window())
setWindow(item->window());
-
- qmlobject_connect(item, QQuickItem, SIGNAL(windowChanged(QQuickWindow*)), this, QQuickAnimatorProxyJob, SLOT(windowChanged(QQuickWindow*)));
+ connect(item, &QQuickItem::windowChanged, this, &QQuickAnimatorProxyJob::windowChanged);
}
}
QQuickAnimatorProxyJob::~QQuickAnimatorProxyJob()
{
- deleteJob();
- if (m_controller)
- m_controller->proxyWasDestroyed(this);
-}
-
-void QQuickAnimatorProxyJob::deleteJob()
-{
- if (m_job) {
- // If we have a controller, we might have posted the job to be started
- // so delete it through the controller to clean up properly.
- if (m_controller)
- m_controller->deleteJob(m_job);
-
- // We explicitly delete the job if the animator controller has never touched
- // it. If it has, it will have ownership as well.
- else if (!m_jobManagedByController)
- delete m_job;
- m_job = 0;
- }
+ if (m_job && m_controller)
+ m_controller->cancel(m_job);
+ m_job.reset();
}
QObject *QQuickAnimatorProxyJob::findAnimationContext(QQuickAbstractAnimation *a)
{
QObject *p = a->parent();
- while (p != 0 && qobject_cast<QQuickWindow *>(p) == 0 && qobject_cast<QQuickItem *>(p) == 0)
+ while (p != nullptr && qobject_cast<QQuickWindow *>(p) == nullptr && qobject_cast<QQuickItem *>(p) == nullptr)
p = p->parent();
return p;
}
void QQuickAnimatorProxyJob::updateCurrentTime(int)
{
+ // We do a simple check here to see if the animator has run and stopped on
+ // the render thread. isPendingStart() will perform a check against jobs
+ // that have been scheduled for start, but that will not yet have entered
+ // the actual running state.
+ // Secondly, we make an unprotected read of the job's state to figure out
+ // if it is running, but this is ok, since we're only reading the state
+ // and if the render thread should happen to be writing it concurrently,
+ // we might get the wrong value for this update, but then we'll simply
+ // pick it up on the next iterationm when the job is stopped and render
+ // thread is no longer using it.
+ if (m_internalState == State_Running
+ && !m_controller->isPendingStart(m_job)
+ && !m_job->isRunning()) {
+ stop();
+ }
}
void QQuickAnimatorProxyJob::updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State)
{
if (m_state == Running) {
m_internalState = State_Starting;
- if (m_controller)
- m_controller->startJob(this, m_job);
+ if (m_controller) {
+ m_internalState = State_Running;
+ m_controller->start(m_job);
+ }
+
} else if (newState == Stopped) {
syncBackCurrentValues();
m_internalState = State_Stopped;
if (m_controller) {
- m_controller->stopJob(this, m_job);
+ m_controller->cancel(m_job);
}
}
}
@@ -154,69 +186,54 @@ void QQuickAnimatorProxyJob::windowChanged(QQuickWindow *window)
setWindow(window);
}
-void QQuickAnimatorProxyJob::controllerWasDeleted()
-{
- m_controller = 0;
- m_job = 0;
-}
-
void QQuickAnimatorProxyJob::setWindow(QQuickWindow *window)
{
if (!window) {
- stop();
- deleteJob();
-
- // Upon leaving a window, we reset the controller. This means that
- // animators will only enter the Starting phase and won't be making
- // calls to QQuickAnimatorController::startjob().
- if (m_controller)
- m_controller->proxyWasDestroyed(this);
- m_controller = 0;
+ if (m_job && m_controller)
+ m_controller->cancel(m_job);
+ m_controller = nullptr;
} else if (!m_controller && m_job) {
m_controller = QQuickWindowPrivate::get(window)->animationController;
if (window->isSceneGraphInitialized())
readyToAnimate();
else
- connect(window, SIGNAL(sceneGraphInitialized()), this, SLOT(sceneGraphInitialized()));
+ connect(window, &QQuickWindow::sceneGraphInitialized, this, &QQuickAnimatorProxyJob::sceneGraphInitialized);
}
}
void QQuickAnimatorProxyJob::sceneGraphInitialized()
{
+ disconnect(m_controller->window(), &QQuickWindow::sceneGraphInitialized, this, &QQuickAnimatorProxyJob::sceneGraphInitialized);
readyToAnimate();
- disconnect(this, SLOT(sceneGraphInitialized()));
}
void QQuickAnimatorProxyJob::readyToAnimate()
{
- if (m_internalState == State_Starting)
- m_controller->startJob(this, m_job);
-}
-
-void QQuickAnimatorProxyJob::startedByController()
-{
- m_internalState = State_Running;
+ Q_ASSERT(m_controller);
+ if (m_internalState == State_Starting) {
+ m_internalState = State_Running;
+ m_controller->start(m_job);
+ }
}
static void qquick_syncback_helper(QAbstractAnimationJob *job)
{
if (job->isRenderThreadJob()) {
- QQuickAnimatorJob *a = static_cast<QQuickAnimatorJob *>(job);
- // Sync back only those jobs that actually have been running
- if (a->controller() && a->hasBeenRunning())
- a->writeBack();
+ static_cast<QQuickAnimatorJob *>(job)->writeBack();
+
} else if (job->isGroup()) {
QAnimationGroupJob *g = static_cast<QAnimationGroupJob *>(job);
for (QAbstractAnimationJob *a = g->firstChild(); a; a = a->nextSibling())
qquick_syncback_helper(a);
}
+
}
void QQuickAnimatorProxyJob::syncBackCurrentValues()
{
if (m_job)
- qquick_syncback_helper(m_job);
+ qquick_syncback_helper(m_job.data());
}
QQuickAnimatorJob::QQuickAnimatorJob()
@@ -228,7 +245,6 @@ QQuickAnimatorJob::QQuickAnimatorJob()
, m_duration(0)
, m_isTransform(false)
, m_isUniform(false)
- , m_hasBeenRunning(false)
{
m_isRenderThreadJob = true;
}
@@ -244,13 +260,16 @@ qreal QQuickAnimatorJob::progress(int time) const
{
return m_easing.valueForProgress((m_duration == 0) ? qreal(1) : qreal(time) / qreal(m_duration));
}
+
qreal QQuickAnimatorJob::value() const
{
- qreal v;
- m_controller->lock();
- v = m_value;
- m_controller->unlock();
- return v;
+ qreal value = m_to;
+ if (m_controller) {
+ m_controller->lock();
+ value = m_value;
+ m_controller->unlock();
+ }
+ return value;
}
void QQuickAnimatorJob::setTarget(QQuickItem *target)
@@ -263,62 +282,81 @@ void QQuickAnimatorJob::initialize(QQuickAnimatorController *controller)
m_controller = controller;
}
-void QQuickAnimatorJob::targetWasDeleted()
-{
- m_target = 0;
- m_controller = 0;
-}
-
QQuickTransformAnimatorJob::QQuickTransformAnimatorJob()
- : m_helper(0)
+ : m_helper(nullptr)
{
m_isTransform = true;
}
QQuickTransformAnimatorJob::~QQuickTransformAnimatorJob()
{
- if (m_helper && --m_helper->ref == 0) {
- // The only condition for not having a controller is when target was
- // destroyed, in which case we have neither m_helper nor m_contorller.
- Q_ASSERT(m_controller);
- Q_ASSERT(m_helper->item);
- m_controller->m_transforms.remove(m_helper->item);
- delete m_helper;
- }
+ if (m_helper)
+ qquick_transform_animatorjob_helper_store()->release(m_helper);
}
-void QQuickTransformAnimatorJob::initialize(QQuickAnimatorController *controller)
+void QQuickTransformAnimatorJob::setTarget(QQuickItem *item)
{
- QQuickAnimatorJob::initialize(controller);
+ // In the extremely unlikely event that the target of an animator has been
+ // changed into a new item that sits in the exact same pointer address, we
+ // want to force syncing it again.
+ if (m_helper && m_target)
+ m_helper->wasSynced = false;
+ QQuickAnimatorJob::setTarget(item);
+}
- if (m_controller) {
- bool newHelper = m_helper == 0;
- m_helper = m_controller->m_transforms.value(m_target);
- if (!m_helper) {
- m_helper = new Helper();
- m_helper->item = m_target;
- m_controller->m_transforms.insert(m_target, m_helper);
- QObject::connect(m_target, SIGNAL(destroyed(QObject*)), m_controller, SLOT(itemDestroyed(QObject*)), Qt::DirectConnection);
- } else {
- if (newHelper) // only add reference the first time around..
- ++m_helper->ref;
- // Make sure leftovers from previous runs are being used...
- m_helper->wasSynced = false;
- }
- m_helper->sync();
+void QQuickTransformAnimatorJob::preSync()
+{
+ // If the target has changed or become null, release and reset the helper
+ if (m_helper && (m_helper->item != m_target || !m_target)) {
+ qquick_transform_animatorjob_helper_store()->release(m_helper);
+ m_helper = nullptr;
}
+
+ if (!m_target)
+ return;
+
+ if (!m_helper) {
+ m_helper = qquick_transform_animatorjob_helper_store()->acquire(m_target);
+
+ // This is a bit superfluous, but it ends up being simpler than the
+ // alternative. When an item happens to land on the same address as a
+ // previous item, that helper might not have been fully cleaned up by
+ // the time it gets taken back into use. As an alternative to storing
+ // connections to each and every item's QObject::destroyed() and
+ // having to clean those up afterwards, we simply sync all helpers on
+ // the first run. The sync is only done once for the run of an
+ // animation and it is a fairly light function (compared to storing
+ // potentially thousands of connections and managing their lifetime.
+ m_helper->wasSynced = false;
+ }
+
+ m_helper->sync();
}
-void QQuickTransformAnimatorJob::nodeWasDestroyed()
+void QQuickTransformAnimatorJob::postSync()
{
- if (m_helper)
- m_helper->node = 0;
+ Q_ASSERT((m_helper != nullptr) == (m_target != nullptr)); // If there is a target, there should also be a helper, ref: preSync
+ Q_ASSERT(!m_helper || m_helper->item == m_target); // If there is a helper, it should point to our target
+
+ if (!m_target || !m_helper) {
+ invalidate();
+ return;
+ }
+
+ QQuickItemPrivate *d = QQuickItemPrivate::get(m_target);
+ if (d->extra.isAllocated()
+ && d->extra->layer
+ && d->extra->layer->enabled()) {
+ d = QQuickItemPrivate::get(d->extra->layer->m_effectSource);
+ }
+
+ m_helper->node = d->itemNode();
}
-void QQuickTransformAnimatorJob::targetWasDeleted()
+void QQuickTransformAnimatorJob::invalidate()
{
- m_helper = 0;
- QQuickAnimatorJob::targetWasDeleted();
+ if (m_helper)
+ m_helper->node = nullptr;
}
void QQuickTransformAnimatorJob::Helper::sync()
@@ -329,11 +367,13 @@ void QQuickTransformAnimatorJob::Helper::sync()
| QQuickItemPrivate::Size;
QQuickItemPrivate *d = QQuickItemPrivate::get(item);
+#if QT_CONFIG(quick_shadereffect)
if (d->extra.isAllocated()
&& d->extra->layer
&& d->extra->layer->enabled()) {
d = QQuickItemPrivate::get(d->extra->layer->m_effectSource);
}
+#endif
quint32 dirty = mask & d->dirtyAttributes;
@@ -364,7 +404,7 @@ void QQuickTransformAnimatorJob::Helper::sync()
}
}
-void QQuickTransformAnimatorJob::Helper::apply()
+void QQuickTransformAnimatorJob::Helper::commit()
{
if (!wasChanged || !node)
return;
@@ -380,7 +420,11 @@ void QQuickTransformAnimatorJob::Helper::apply()
wasChanged = false;
}
-
+void QQuickTransformAnimatorJob::commit()
+{
+ if (m_helper)
+ m_helper->commit();
+}
void QQuickXAnimatorJob::writeBack()
{
@@ -390,7 +434,10 @@ void QQuickXAnimatorJob::writeBack()
void QQuickXAnimatorJob::updateCurrentTime(int time)
{
- if (!m_controller)
+#if QT_CONFIG(opengl)
+ Q_ASSERT(!m_controller || !m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread());
+#endif
+ if (!m_helper)
return;
m_value = m_from + (m_to - m_from) * progress(time);
@@ -406,7 +453,10 @@ void QQuickYAnimatorJob::writeBack()
void QQuickYAnimatorJob::updateCurrentTime(int time)
{
- if (!m_controller)
+#if QT_CONFIG(opengl)
+ Q_ASSERT(!m_controller || !m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread());
+#endif
+ if (!m_helper)
return;
m_value = m_from + (m_to - m_from) * progress(time);
@@ -414,22 +464,98 @@ void QQuickYAnimatorJob::updateCurrentTime(int time)
m_helper->wasChanged = true;
}
+void QQuickScaleAnimatorJob::writeBack()
+{
+ if (m_target)
+ m_target->setScale(value());
+}
+
+void QQuickScaleAnimatorJob::updateCurrentTime(int time)
+{
+#if QT_CONFIG(opengl)
+ Q_ASSERT(!m_controller || !m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread());
+#endif
+ if (!m_helper)
+ return;
+
+ m_value = m_from + (m_to - m_from) * progress(time);
+ m_helper->scale = m_value;
+ m_helper->wasChanged = true;
+}
+
+
+QQuickRotationAnimatorJob::QQuickRotationAnimatorJob()
+ : m_direction(QQuickRotationAnimator::Numerical)
+{
+}
+
+extern QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress);
+extern QVariant _q_interpolateClockwiseRotation(qreal &f, qreal &t, qreal progress);
+extern QVariant _q_interpolateCounterclockwiseRotation(qreal &f, qreal &t, qreal progress);
+
+void QQuickRotationAnimatorJob::updateCurrentTime(int time)
+{
+#if QT_CONFIG(opengl)
+ Q_ASSERT(!m_controller || !m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread());
+#endif
+ if (!m_helper)
+ return;
+
+ float t = progress(time);
+
+ switch (m_direction) {
+ case QQuickRotationAnimator::Clockwise:
+ m_value = _q_interpolateClockwiseRotation(m_from, m_to, t).toFloat();
+ // The logic in _q_interpolateClockwise comes out a bit wrong
+ // for the case of X->0 where 0<X<360. It ends on 360 which it
+ // shouldn't.
+ if (t == 1)
+ m_value = m_to;
+ break;
+ case QQuickRotationAnimator::Counterclockwise:
+ m_value = _q_interpolateCounterclockwiseRotation(m_from, m_to, t).toFloat();
+ break;
+ case QQuickRotationAnimator::Shortest:
+ m_value = _q_interpolateShortestRotation(m_from, m_to, t).toFloat();
+ break;
+ case QQuickRotationAnimator::Numerical:
+ m_value = m_from + (m_to - m_from) * t;
+ break;
+ }
+ m_helper->rotation = m_value;
+ m_helper->wasChanged = true;
+}
+
+void QQuickRotationAnimatorJob::writeBack()
+{
+ if (m_target)
+ m_target->setRotation(value());
+}
+
+
QQuickOpacityAnimatorJob::QQuickOpacityAnimatorJob()
- : m_opacityNode(0)
+ : m_opacityNode(nullptr)
{
}
-void QQuickOpacityAnimatorJob::initialize(QQuickAnimatorController *controller)
+void QQuickOpacityAnimatorJob::postSync()
{
- QQuickAnimatorJob::initialize(controller);
+ if (!m_target) {
+ invalidate();
+ return;
+ }
+
QQuickItemPrivate *d = QQuickItemPrivate::get(m_target);
+#if QT_CONFIG(quick_shadereffect)
if (d->extra.isAllocated()
&& d->extra->layer
&& d->extra->layer->enabled()) {
d = QQuickItemPrivate::get(d->extra->layer->m_effectSource);
}
+#endif
m_opacityNode = d->opacityNode();
+
if (!m_opacityNode) {
m_opacityNode = new QSGOpacityNode();
@@ -460,11 +586,12 @@ void QQuickOpacityAnimatorJob::initialize(QQuickAnimatorController *controller)
d->extra.value().opacityNode = m_opacityNode;
}
+ Q_ASSERT(m_opacityNode);
}
-void QQuickOpacityAnimatorJob::nodeWasDestroyed()
+void QQuickOpacityAnimatorJob::invalidate()
{
- m_opacityNode = 0;
+ m_opacityNode = nullptr;
}
void QQuickOpacityAnimatorJob::writeBack()
@@ -475,77 +602,21 @@ void QQuickOpacityAnimatorJob::writeBack()
void QQuickOpacityAnimatorJob::updateCurrentTime(int time)
{
- if (!m_controller || !m_opacityNode)
- return;
-
- m_value = m_from + (m_to - m_from) * progress(time);
- m_opacityNode->setOpacity(m_value);
-}
-
-void QQuickScaleAnimatorJob::writeBack()
-{
- if (m_target)
- m_target->setScale(value());
-}
+#if QT_CONFIG(opengl)
+ Q_ASSERT(!m_controller || !m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread());
+#endif
-void QQuickScaleAnimatorJob::updateCurrentTime(int time)
-{
- if (!m_controller)
+ if (!m_opacityNode)
return;
m_value = m_from + (m_to - m_from) * progress(time);
- m_helper->scale = m_value;
- m_helper->wasChanged = true;
-}
-
-QQuickRotationAnimatorJob::QQuickRotationAnimatorJob()
- : m_direction(QQuickRotationAnimator::Numerical)
-{
-}
-
-extern QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress);
-extern QVariant _q_interpolateClockwiseRotation(qreal &f, qreal &t, qreal progress);
-extern QVariant _q_interpolateCounterclockwiseRotation(qreal &f, qreal &t, qreal progress);
-
-void QQuickRotationAnimatorJob::updateCurrentTime(int time)
-{
- if (!m_controller)
- return;
-
- float t = progress(time);
-
- switch (m_direction) {
- case QQuickRotationAnimator::Clockwise:
- m_value = _q_interpolateClockwiseRotation(m_from, m_to, t).toFloat();
- // The logic in _q_interpolateClockwise comes out a bit wrong
- // for the case of X->0 where 0<X<360. It ends on 360 which it
- // shouldn't.
- if (t == 1)
- m_value = m_to;
- break;
- case QQuickRotationAnimator::Counterclockwise:
- m_value = _q_interpolateCounterclockwiseRotation(m_from, m_to, t).toFloat();
- break;
- case QQuickRotationAnimator::Shortest:
- m_value = _q_interpolateShortestRotation(m_from, m_to, t).toFloat();
- break;
- case QQuickRotationAnimator::Numerical:
- m_value = m_from + (m_to - m_from) * t;
- break;
- }
- m_helper->rotation = m_value;
- m_helper->wasChanged = true;
+ m_opacityNode->setOpacity(m_value);
}
-void QQuickRotationAnimatorJob::writeBack()
-{
- if (m_target)
- m_target->setRotation(value());
-}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
QQuickUniformAnimatorJob::QQuickUniformAnimatorJob()
- : m_node(0)
+ : m_node(nullptr)
, m_uniformIndex(-1)
, m_uniformType(-1)
{
@@ -554,19 +625,24 @@ QQuickUniformAnimatorJob::QQuickUniformAnimatorJob()
void QQuickUniformAnimatorJob::setTarget(QQuickItem *target)
{
- if (qobject_cast<QQuickOpenGLShaderEffect *>(target) != 0)
+ if (qobject_cast<QQuickOpenGLShaderEffect *>(target) != nullptr)
m_target = target;
}
-void QQuickUniformAnimatorJob::nodeWasDestroyed()
+void QQuickUniformAnimatorJob::invalidate()
{
- m_node = 0;
+ m_node = nullptr;
m_uniformIndex = -1;
m_uniformType = -1;
}
-void QQuickUniformAnimatorJob::afterNodeSync()
+void QQuickUniformAnimatorJob::postSync()
{
+ if (!m_target) {
+ invalidate();
+ return;
+ }
+
m_node = static_cast<QQuickOpenGLShaderEffectNode *>(QQuickItemPrivate::get(m_target)->paintNode);
if (m_node && m_uniformIndex == -1 && m_uniformType == -1) {
diff --git a/src/quick/util/qquickanimatorjob_p.h b/src/quick/util/qquickanimatorjob_p.h
index 64e849d322..d7aaa988a9 100644
--- a/src/quick/util/qquickanimatorjob_p.h
+++ b/src/quick/util/qquickanimatorjob_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Gunnar Sletta <gunnar@sletta.org>
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -80,25 +81,20 @@ public:
QQuickAnimatorProxyJob(QAbstractAnimationJob *job, QObject *item);
~QQuickAnimatorProxyJob();
- int duration() const Q_DECL_OVERRIDE { return m_duration; }
+ int duration() const override { return m_duration; }
- QAbstractAnimationJob *job() const { return m_job; }
-
- void startedByController();
- void controllerWasDeleted();
- void markJobManagedByController() { m_jobManagedByController = true; }
+ const QSharedPointer<QAbstractAnimationJob> &job() const { return m_job; }
protected:
- void updateCurrentTime(int) Q_DECL_OVERRIDE;
- void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) Q_DECL_OVERRIDE;
- void debugAnimation(QDebug d) const Q_DECL_OVERRIDE;
+ void updateCurrentTime(int) override;
+ void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override;
+ void debugAnimation(QDebug d) const override;
public Q_SLOTS:
void windowChanged(QQuickWindow *window);
void sceneGraphInitialized();
private:
- void deleteJob();
void syncBackCurrentValues();
void readyToAnimate();
void setWindow(QQuickWindow *window);
@@ -106,7 +102,7 @@ private:
QPointer<QQuickAnimatorController> m_controller;
QQuickAbstractAnimation *m_animation;
- QAbstractAnimationJob *m_job;
+ QSharedPointer<QAbstractAnimationJob> m_job;
int m_duration;
enum InternalState {
@@ -117,7 +113,6 @@ private:
};
InternalState m_internalState;
- bool m_jobManagedByController;
};
class Q_QUICK_PRIVATE_EXPORT QQuickAnimatorJob : public QAbstractAnimationJob
@@ -126,37 +121,53 @@ public:
virtual void setTarget(QQuickItem *target);
QQuickItem *target() const { return m_target; }
- void setFrom(qreal scale) { m_from = scale; }
+ void setFrom(qreal from) { m_from = from; }
qreal from() const { return m_from; }
void setTo(qreal to) { m_to = to; }
qreal to() const { return m_to; }
void setDuration(int duration) { m_duration = duration; }
- int duration() const Q_DECL_OVERRIDE { return m_duration; }
+ int duration() const override { return m_duration; }
QEasingCurve easingCurve() const { return m_easing; }
void setEasingCurve(const QEasingCurve &curve) { m_easing = curve; }
- virtual void targetWasDeleted();
+ // Initialize is called on the GUI thread just before it is started
+ // and taken over on the render thread.
virtual void initialize(QQuickAnimatorController *controller);
+
+ // Called on the render thread during SG shutdown.
+ virtual void invalidate() = 0;
+
+ // Called on the GUI thread after a complete render thread animation job
+ // has been completed to write back a given animator's result to the
+ // source item.
virtual void writeBack() = 0;
- virtual void nodeWasDestroyed() = 0;
- virtual void afterNodeSync() { }
+
+ // Called before the SG sync on the render thread. The GUI thread is
+ // locked during this call.
+ virtual void preSync() { }
+
+ // Called after the SG sync on the render thread. The GUI thread is
+ // locked during this call.
+ virtual void postSync() { }
+
+ // Called after animations have ticked on the render thread. No locks are
+ // held at this time, so synchronization needs to be taken into account
+ // if applicable.
+ virtual void commit() { }
bool isTransform() const { return m_isTransform; }
bool isUniform() const { return m_isUniform; }
- bool hasBeenRunning() const { return m_hasBeenRunning; }
- void setHasBeenRunning(bool has) { m_hasBeenRunning = has; }
-
qreal value() const;
QQuickAnimatorController *controller() const { return m_controller; }
protected:
QQuickAnimatorJob();
- void debugAnimation(QDebug d) const Q_DECL_OVERRIDE;
+ void debugAnimation(QDebug d) const override;
qreal progress(int time) const;
@@ -173,7 +184,6 @@ protected:
uint m_isTransform : 1;
uint m_isUniform : 1;
- uint m_hasBeenRunning : 1;
};
class QQuickTransformAnimatorJob : public QQuickAnimatorJob
@@ -197,7 +207,7 @@ public:
}
void sync();
- void apply();
+ void commit();
int ref;
QQuickItem *item;
@@ -217,13 +227,16 @@ public:
};
~QQuickTransformAnimatorJob();
- Helper *transformHelper() const { return m_helper; }
+
+ void commit() override;
+ void preSync() override;
+
+ void setTarget(QQuickItem *item) override;
protected:
QQuickTransformAnimatorJob();
- void initialize(QQuickAnimatorController *controller) Q_DECL_OVERRIDE;
- void nodeWasDestroyed() Q_DECL_OVERRIDE;
- void targetWasDeleted() Q_DECL_OVERRIDE;
+ void postSync() override;
+ void invalidate() override;
Helper *m_helper;
};
@@ -231,22 +244,22 @@ protected:
class Q_QUICK_PRIVATE_EXPORT QQuickScaleAnimatorJob : public QQuickTransformAnimatorJob
{
public:
- void updateCurrentTime(int time) Q_DECL_OVERRIDE;
- void writeBack() Q_DECL_OVERRIDE;
+ void updateCurrentTime(int time) override;
+ void writeBack() override;
};
class Q_QUICK_PRIVATE_EXPORT QQuickXAnimatorJob : public QQuickTransformAnimatorJob
{
public:
- void updateCurrentTime(int time) Q_DECL_OVERRIDE;
- void writeBack() Q_DECL_OVERRIDE;
+ void updateCurrentTime(int time) override;
+ void writeBack() override;
};
class Q_QUICK_PRIVATE_EXPORT QQuickYAnimatorJob : public QQuickTransformAnimatorJob
{
public:
- void updateCurrentTime(int time) Q_DECL_OVERRIDE;
- void writeBack() Q_DECL_OVERRIDE;
+ void updateCurrentTime(int time) override;
+ void writeBack() override;
};
class Q_QUICK_PRIVATE_EXPORT QQuickRotationAnimatorJob : public QQuickTransformAnimatorJob
@@ -254,8 +267,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickRotationAnimatorJob : public QQuickTransformA
public:
QQuickRotationAnimatorJob();
- void updateCurrentTime(int time) Q_DECL_OVERRIDE;
- void writeBack() Q_DECL_OVERRIDE;
+ void updateCurrentTime(int time) override;
+ void writeBack() override;
void setDirection(QQuickRotationAnimator::RotationDirection direction) { m_direction = direction; }
QQuickRotationAnimator::RotationDirection direction() const { return m_direction; }
@@ -269,10 +282,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickOpacityAnimatorJob : public QQuickAnimatorJob
public:
QQuickOpacityAnimatorJob();
- void initialize(QQuickAnimatorController *controller) Q_DECL_OVERRIDE;
- void updateCurrentTime(int time) Q_DECL_OVERRIDE;
- void writeBack() Q_DECL_OVERRIDE;
- void nodeWasDestroyed() Q_DECL_OVERRIDE;
+ void invalidate() override;
+ void updateCurrentTime(int time) override;
+ void writeBack() override;
+ void postSync() override;
private:
QSGOpacityNode *m_opacityNode;
@@ -283,16 +296,17 @@ class Q_QUICK_PRIVATE_EXPORT QQuickUniformAnimatorJob : public QQuickAnimatorJob
public:
QQuickUniformAnimatorJob();
- void setTarget(QQuickItem *target) Q_DECL_OVERRIDE;
+ void setTarget(QQuickItem *target) override;
void setUniform(const QByteArray &uniform) { m_uniform = uniform; }
QByteArray uniform() const { return m_uniform; }
- void afterNodeSync() Q_DECL_OVERRIDE;
+ void postSync() override;
+
+ void updateCurrentTime(int time) override;
+ void writeBack() override;
- void updateCurrentTime(int time) Q_DECL_OVERRIDE;
- void writeBack() Q_DECL_OVERRIDE;
- void nodeWasDestroyed() Q_DECL_OVERRIDE;
+ void invalidate() override;
private:
QByteArray m_uniform;
diff --git a/src/quick/util/qquickapplication.cpp b/src/quick/util/qquickapplication.cpp
index 5c26b23ff7..5c89275c5a 100644
--- a/src/quick/util/qquickapplication.cpp
+++ b/src/quick/util/qquickapplication.cpp
@@ -38,7 +38,7 @@
****************************************************************************/
#include "qquickapplication_p.h"
-
+#include <private/qquickscreen_p.h>
#include <private/qobject_p.h>
#include <private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
@@ -63,6 +63,12 @@ QQuickApplication::QQuickApplication(QObject *parent)
this, SIGNAL(stateChanged(Qt::ApplicationState)));
connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
this, SIGNAL(activeChanged()));
+ connect(qApp, SIGNAL(applicationDisplayNameChanged()),
+ this, SIGNAL(displayNameChanged()));
+
+ connect(qApp, &QGuiApplication::screenAdded, this, &QQuickApplication::updateScreens);
+ connect(qApp, &QGuiApplication::screenRemoved, this, &QQuickApplication::updateScreens);
+ updateScreens();
}
}
@@ -95,4 +101,42 @@ QFont QQuickApplication::font() const
return QGuiApplication::font();
}
+QString QQuickApplication::displayName() const
+{
+ return QGuiApplication::applicationDisplayName();
+}
+
+void QQuickApplication::setDisplayName(const QString &displayName)
+{
+ return QGuiApplication::setApplicationDisplayName(displayName);
+}
+
+int screens_count(QQmlListProperty<QQuickScreenInfo> *prop)
+{
+ return static_cast<QVector<QQuickScreenInfo *> *>(prop->data)->count();
+}
+
+QQuickScreenInfo *screens_at(QQmlListProperty<QQuickScreenInfo> *prop, int idx)
+{
+ return static_cast<QVector<QQuickScreenInfo *> *>(prop->data)->at(idx);
+}
+
+QQmlListProperty<QQuickScreenInfo> QQuickApplication::screens()
+{
+ return QQmlListProperty<QQuickScreenInfo>(this,
+ const_cast<QVector<QQuickScreenInfo *> *>(&m_screens), &screens_count, &screens_at);
+}
+
+void QQuickApplication::updateScreens()
+{
+ const QList<QScreen *> screenList = QGuiApplication::screens();
+ m_screens.resize(screenList.count());
+ for (int i = 0; i < screenList.count(); ++i) {
+ if (!m_screens[i])
+ m_screens[i] = new QQuickScreenInfo(this);
+ m_screens[i]->setWrappedScreen(screenList[i]);
+ }
+ emit screensChanged();
+}
+
QT_END_NAMESPACE
diff --git a/src/quick/util/qquickapplication_p.h b/src/quick/util/qquickapplication_p.h
index 091cb094ed..8ee203f0da 100644
--- a/src/quick/util/qquickapplication_p.h
+++ b/src/quick/util/qquickapplication_p.h
@@ -56,10 +56,10 @@
#include <qqml.h>
#include <QtQml/private/qqmlglobal_p.h>
#include <private/qtquickglobal_p.h>
+#include "../items/qquickscreen_p.h"
QT_BEGIN_NAMESPACE
-
class Q_AUTOTEST_EXPORT QQuickApplication : public QQmlApplication
{
Q_OBJECT
@@ -68,6 +68,8 @@ class Q_AUTOTEST_EXPORT QQuickApplication : public QQmlApplication
Q_PROPERTY(bool supportsMultipleWindows READ supportsMultipleWindows CONSTANT)
Q_PROPERTY(Qt::ApplicationState state READ state NOTIFY stateChanged)
Q_PROPERTY(QFont font READ font CONSTANT)
+ Q_PROPERTY(QString displayName READ displayName WRITE setDisplayName NOTIFY displayNameChanged)
+ Q_PROPERTY(QQmlListProperty<QQuickScreenInfo> screens READ screens NOTIFY screensChanged)
public:
explicit QQuickApplication(QObject *parent = 0);
@@ -77,14 +79,23 @@ public:
bool supportsMultipleWindows() const;
Qt::ApplicationState state() const;
QFont font() const;
+ QQmlListProperty<QQuickScreenInfo> screens();
+ QString displayName() const;
+ void setDisplayName(const QString &displayName);
Q_SIGNALS:
void activeChanged();
+ void displayNameChanged();
void layoutDirectionChanged();
void stateChanged(Qt::ApplicationState state);
+ void screensChanged();
+
+private Q_SLOTS:
+ void updateScreens();
private:
Q_DISABLE_COPY(QQuickApplication)
+ QVector<QQuickScreenInfo *> m_screens;
};
QT_END_NAMESPACE
diff --git a/src/quick/util/qquickbehavior.cpp b/src/quick/util/qquickbehavior.cpp
index 1d3ee2c4be..9af1d41b29 100644
--- a/src/quick/util/qquickbehavior.cpp
+++ b/src/quick/util/qquickbehavior.cpp
@@ -60,7 +60,7 @@ public:
QQuickBehaviorPrivate() : animation(0), animationInstance(0), enabled(true), finalized(false)
, blockRunningChanged(false) {}
- virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState);
+ void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override;
QQmlProperty property;
QVariant targetValue;
diff --git a/src/quick/util/qquickbehavior_p.h b/src/quick/util/qquickbehavior_p.h
index c3438d8c6d..b3fd2af400 100644
--- a/src/quick/util/qquickbehavior_p.h
+++ b/src/quick/util/qquickbehavior_p.h
@@ -75,8 +75,8 @@ public:
QQuickBehavior(QObject *parent=0);
~QQuickBehavior();
- virtual void setTarget(const QQmlProperty &);
- virtual void write(const QVariant &value);
+ void setTarget(const QQmlProperty &) override;
+ void write(const QVariant &value) override;
QQuickAbstractAnimation *animation();
void setAnimation(QQuickAbstractAnimation *);
diff --git a/src/quick/util/qquickfontloader.cpp b/src/quick/util/qquickfontloader.cpp
index 6e23d99f7e..d13291c30a 100644
--- a/src/quick/util/qquickfontloader.cpp
+++ b/src/quick/util/qquickfontloader.cpp
@@ -52,7 +52,7 @@
#include <qqmlinfo.h>
#include <qqmlfile.h>
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
#include <QNetworkRequest>
#include <QNetworkReply>
#endif
@@ -70,7 +70,7 @@ Q_OBJECT
public:
explicit QQuickFontObject(int _id = -1);
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
void download(const QUrl &url, QNetworkAccessManager *manager);
Q_SIGNALS:
@@ -82,7 +82,7 @@ private:
private Q_SLOTS:
void replyFinished();
-#endif // QT_NO_NETWORK
+#endif // qml_network
public:
int id;
@@ -92,7 +92,7 @@ public:
QQuickFontObject::QQuickFontObject(int _id)
: QObject(0)
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
,redirectCount(0), reply(0)
#endif
,id(_id)
@@ -100,7 +100,7 @@ QQuickFontObject::QQuickFontObject(int _id)
}
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
void QQuickFontObject::download(const QUrl &url, QNetworkAccessManager *manager)
{
QNetworkRequest req(url);
@@ -141,7 +141,7 @@ void QQuickFontObject::replyFinished()
reply = 0;
}
}
-#endif // QT_NO_NETWORK
+#endif // qml_network
class QQuickFontLoaderPrivate : public QObjectPrivate
{
@@ -268,7 +268,7 @@ void QQuickFontLoader::setSource(const QUrl &url)
}
} else {
if (!fontLoaderFonts()->map.contains(d->url)) {
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QQuickFontObject *fo = new QQuickFontObject;
fontLoaderFonts()->map[d->url] = fo;
fo->download(d->url, qmlEngine(this)->networkAccessManager());
@@ -282,7 +282,7 @@ void QQuickFontLoader::setSource(const QUrl &url)
} else {
QQuickFontObject *fo = fontLoaderFonts()->map.value(d->url);
if (fo->id == -1) {
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
d->status = Loading;
emit statusChanged();
QObject::connect(fo, SIGNAL(fontDownloaded(QString,QQuickFontLoader::Status)),
diff --git a/src/quick/util/qquickimageprovider.cpp b/src/quick/util/qquickimageprovider.cpp
index 6cecf6f6f6..c4182d9f93 100644
--- a/src/quick/util/qquickimageprovider.cpp
+++ b/src/quick/util/qquickimageprovider.cpp
@@ -44,13 +44,6 @@
QT_BEGIN_NAMESPACE
-class QQuickImageProviderPrivate
-{
-public:
- QQuickImageProvider::ImageType type;
- QQuickImageProvider::Flags flags;
-};
-
/*!
\class QQuickTextureFactory
\since 5.0
@@ -105,7 +98,7 @@ QImage QQuickTextureFactory::image() const
}
/*!
- Returns a QQuickTextureFactory holding the given image.
+ Returns a QQuickTextureFactory holding the given \a image.
This is typically used as a helper in QQuickImageResponse::textureFactory.
@@ -187,6 +180,8 @@ QString QQuickImageResponse::errorString() const
This method is used to communicate that the response is no longer required by the engine.
It may be reimplemented to cancel a request in the provider side, however, it is not mandatory.
+
+ A cancelled QQuickImageResponse still needs to emit finished().
*/
void QQuickImageResponse::cancel()
{
@@ -347,6 +342,7 @@ QQuickImageProvider::QQuickImageProvider(ImageType type, Flags flags)
{
d->type = type;
d->flags = flags;
+ d->isProviderWithOptions = false;
}
/*!
@@ -500,26 +496,165 @@ QQuickAsyncImageProvider::~QQuickAsyncImageProvider()
implementation of this method is reentrant.
*/
+
+class QQuickImageProviderOptionsPrivate : public QSharedData
+{
+public:
+ QQuickImageProviderOptionsPrivate()
+ : autoTransform(QQuickImageProviderOptions::UsePluginDefaultTransform)
+ , preserveAspectRatioCrop(false)
+ , preserveAspectRatioFit(false)
+ {
+ }
+
+ QQuickImageProviderOptions::AutoTransform autoTransform;
+ bool preserveAspectRatioCrop;
+ bool preserveAspectRatioFit;
+};
+
/*!
- \fn QImage QQuickImageProvider::requestImage(const QString &id, QSize *size, const QSize& requestedSize, bool requestedAutoTransform);
+ \class QQuickImageProviderOptions
+ \since 5.9
+ \brief The QQuickImageProviderOptions class provides options for QQuickImageProviderWithOptions image requests.
+ \inmodule QtQuick
- \internal
- For future reference.
+ \sa QQuickImageProviderWithOptions
*/
/*!
- \fn QPixmap QQuickImageProvider::requestPixmap(const QString &id, QSize *size, const QSize& requestedSize, bool requestedAutoTransform);
+ \enum QQuickImageProviderOptions::AutoTransform
+
+ Whether the image provider should apply transformation metadata on read().
+
+ \value UsePluginDefaultTransform Image provider should do its default behavior on whether applying transformation metadata on read or not
+ \value ApplyTransform Image provider should apply transformation metadata on read
+ \value DoNotApplyTransform Image provider should not apply transformation metadata on read
+*/
+
+QQuickImageProviderOptions::QQuickImageProviderOptions()
+ : d(new QQuickImageProviderOptionsPrivate())
+{
+}
- \internal
- For future reference.
+QQuickImageProviderOptions::~QQuickImageProviderOptions()
+{
+}
+
+QQuickImageProviderOptions::QQuickImageProviderOptions(const QQuickImageProviderOptions &other)
+ : d(other.d)
+{
+}
+
+QQuickImageProviderOptions& QQuickImageProviderOptions::operator=(const QQuickImageProviderOptions &other)
+{
+ d = other.d;
+ return *this;
+}
+
+bool QQuickImageProviderOptions::operator==(const QQuickImageProviderOptions &other) const
+{
+ return d->autoTransform == other.d->autoTransform &&
+ d->preserveAspectRatioCrop == other.d->preserveAspectRatioCrop &&
+ d->preserveAspectRatioFit == other.d->preserveAspectRatioFit;
+}
+
+/*!
+ Returns whether the image provider should apply transformation metadata on read().
*/
+QQuickImageProviderOptions::AutoTransform QQuickImageProviderOptions::autoTransform() const
+{
+ return d->autoTransform;
+}
+
+void QQuickImageProviderOptions::setAutoTransform(QQuickImageProviderOptions::AutoTransform autoTransform)
+{
+ d->autoTransform = autoTransform;
+}
/*!
- \fn QQuickTextureFactory *QQuickImageProvider::requestTexture(const QString &id, QSize *size, const QSize &requestedSize, bool requestedAutoTransform);
+ Returns whether the image request is for a PreserveAspectCrop Image.
+ This allows the provider to better optimize the size of the returned image.
+*/
+bool QQuickImageProviderOptions::preserveAspectRatioCrop() const
+{
+ return d->preserveAspectRatioCrop;
+}
- \internal
- For future reference.
+void QQuickImageProviderOptions::setPreserveAspectRatioCrop(bool preserveAspectRatioCrop)
+{
+ d->preserveAspectRatioCrop = preserveAspectRatioCrop;
+}
+
+/*!
+ Returns whether the image request is for a PreserveAspectFit Image.
+ This allows the provider to better optimize the size of the returned image.
*/
+bool QQuickImageProviderOptions::preserveAspectRatioFit() const
+{
+ return d->preserveAspectRatioFit;
+}
+
+void QQuickImageProviderOptions::setPreserveAspectRatioFit(bool preserveAspectRatioFit)
+{
+ d->preserveAspectRatioFit = preserveAspectRatioFit;
+}
+
+
+QQuickImageProviderWithOptions::QQuickImageProviderWithOptions(ImageType type, Flags flags)
+ : QQuickAsyncImageProvider()
+{
+ QQuickImageProvider::d->type = type;
+ QQuickImageProvider::d->flags = flags;
+ QQuickImageProvider::d->isProviderWithOptions = true;
+}
+
+QImage QQuickImageProviderWithOptions::requestImage(const QString &id, QSize *size, const QSize& requestedSize)
+{
+ return requestImage(id, size, requestedSize, QQuickImageProviderOptions());
+}
+
+QPixmap QQuickImageProviderWithOptions::requestPixmap(const QString &id, QSize *size, const QSize& requestedSize)
+{
+ return requestPixmap(id, size, requestedSize, QQuickImageProviderOptions());
+}
+
+QQuickTextureFactory *QQuickImageProviderWithOptions::requestTexture(const QString &id, QSize *size, const QSize &requestedSize)
+{
+ return requestTexture(id, size, requestedSize, QQuickImageProviderOptions());
+}
+
+QImage QQuickImageProviderWithOptions::requestImage(const QString &id, QSize *size, const QSize& requestedSize, const QQuickImageProviderOptions &options)
+{
+ Q_UNUSED(options);
+ return QQuickAsyncImageProvider::requestImage(id, size, requestedSize);
+}
+
+QPixmap QQuickImageProviderWithOptions::requestPixmap(const QString &id, QSize *size, const QSize& requestedSize, const QQuickImageProviderOptions &options)
+{
+ Q_UNUSED(options);
+ return QQuickAsyncImageProvider::requestPixmap(id, size, requestedSize);
+}
+
+QQuickTextureFactory *QQuickImageProviderWithOptions::requestTexture(const QString &id, QSize *size, const QSize &requestedSize, const QQuickImageProviderOptions &options)
+{
+ Q_UNUSED(options);
+ return QQuickAsyncImageProvider::requestTexture(id, size, requestedSize);
+}
+
+QQuickImageResponse *QQuickImageProviderWithOptions::requestImageResponse(const QString &id, const QSize &requestedSize)
+{
+ Q_UNUSED(id);
+ Q_UNUSED(requestedSize);
+ if (imageType() == ImageResponse)
+ qWarning("ImageProvider is of ImageResponse type but has not implemented requestImageResponse()");
+ return nullptr;
+}
+
+QQuickImageResponse *QQuickImageProviderWithOptions::requestImageResponse(const QString &id, const QSize &requestedSize, const QQuickImageProviderOptions &options)
+{
+ Q_UNUSED(options);
+ return requestImageResponse(id, requestedSize);
+}
QT_END_NAMESPACE
diff --git a/src/quick/util/qquickimageprovider.h b/src/quick/util/qquickimageprovider.h
index d4719a7f5b..c77ff95f32 100644
--- a/src/quick/util/qquickimageprovider.h
+++ b/src/quick/util/qquickimageprovider.h
@@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE
class QQuickImageProviderPrivate;
class QQuickAsyncImageProviderPrivate;
+class QQuickImageProviderOptionsPrivate;
class QSGTexture;
class QQuickWindow;
@@ -86,17 +87,19 @@ Q_SIGNALS:
class Q_QUICK_EXPORT QQuickImageProvider : public QQmlImageProviderBase
{
+ friend class QQuickImageProviderWithOptions; // ### Qt 6 Remove
+ friend class QQuickPixmapReader; // ### Qt 6 Remove
public:
QQuickImageProvider(ImageType type, Flags flags = Flags());
virtual ~QQuickImageProvider();
- ImageType imageType() const;
- Flags flags() const;
+ ImageType imageType() const override;
+ Flags flags() const override;
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
- virtual QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize, bool requestedAutoTransform);
- virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize, bool requestedAutoTransform);
- virtual QQuickTextureFactory *requestTexture(const QString &id, QSize *size, const QSize &requestedSize, bool requestedAutoTransform);
+ virtual QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize, const QQuickImageProviderOptions &options);
+ virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize, const QQuickImageProviderOptions &options);
+ virtual QQuickTextureFactory *requestTexture(const QString &id, QSize *size, const QSize &requestedSize, const QQuickImageProviderOptions &options);
#else
virtual QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize);
virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize);
@@ -113,7 +116,11 @@ public:
QQuickAsyncImageProvider();
virtual ~QQuickAsyncImageProvider();
+#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
+ virtual QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize, const QQuickImageProviderOptions &options) = 0;
+#else
virtual QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize) = 0;
+#endif
private:
QQuickAsyncImageProviderPrivate *d;
diff --git a/src/quick/util/qquickpath_p.h b/src/quick/util/qquickpath_p.h
index fa6cbc668a..06ad389b49 100644
--- a/src/quick/util/qquickpath_p.h
+++ b/src/quick/util/qquickpath_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_path);
+
#include <qqml.h>
#include <private/qqmlnullablevalue_p.h>
@@ -152,7 +156,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathLine : public QQuickCurve
public:
QQuickPathLine(QObject *parent=0) : QQuickCurve(parent) {}
- void addToPath(QPainterPath &path, const QQuickPathData &);
+ void addToPath(QPainterPath &path, const QQuickPathData &) override;
};
class Q_QUICK_PRIVATE_EXPORT QQuickPathQuad : public QQuickCurve
@@ -180,7 +184,7 @@ public:
void setRelativeControlY(qreal y);
bool hasRelativeControlY();
- void addToPath(QPainterPath &path, const QQuickPathData &);
+ void addToPath(QPainterPath &path, const QQuickPathData &) override;
Q_SIGNALS:
void controlXChanged();
@@ -238,7 +242,7 @@ public:
void setRelativeControl2Y(qreal y);
bool hasRelativeControl2Y();
- void addToPath(QPainterPath &path, const QQuickPathData &);
+ void addToPath(QPainterPath &path, const QQuickPathData &) override;
Q_SIGNALS:
void control1XChanged();
@@ -267,7 +271,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathCatmullRomCurve : public QQuickCurve
public:
QQuickPathCatmullRomCurve(QObject *parent=0) : QQuickCurve(parent) {}
- void addToPath(QPainterPath &path, const QQuickPathData &);
+ void addToPath(QPainterPath &path, const QQuickPathData &) override;
};
class Q_QUICK_PRIVATE_EXPORT QQuickPathArc : public QQuickCurve
@@ -297,7 +301,7 @@ public:
ArcDirection direction() const;
void setDirection(ArcDirection direction);
- void addToPath(QPainterPath &path, const QQuickPathData &);
+ void addToPath(QPainterPath &path, const QQuickPathData &) override;
Q_SIGNALS:
void radiusXChanged();
@@ -322,7 +326,7 @@ public:
QString path() const;
void setPath(const QString &path);
- void addToPath(QPainterPath &path, const QQuickPathData &);
+ void addToPath(QPainterPath &path, const QQuickPathData &) override;
Q_SIGNALS:
void pathChanged();
@@ -401,8 +405,8 @@ Q_SIGNALS:
void startYChanged();
protected:
- virtual void componentComplete();
- virtual void classBegin();
+ void componentComplete() override;
+ void classBegin() override;
void disconnectPathElements();
void connectPathElements();
void gatherAttributes();
diff --git a/src/quick/util/qquickpath_p_p.h b/src/quick/util/qquickpath_p_p.h
index 3e4ccc7eb6..1dc3c1c47a 100644
--- a/src/quick/util/qquickpath_p_p.h
+++ b/src/quick/util/qquickpath_p_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_path);
+
#include "qquickpath_p.h"
#include <qqml.h>
diff --git a/src/quick/util/qquickpathinterpolator_p.h b/src/quick/util/qquickpathinterpolator_p.h
index ce18190977..0fdb1a444f 100644
--- a/src/quick/util/qquickpathinterpolator_p.h
+++ b/src/quick/util/qquickpathinterpolator_p.h
@@ -51,6 +51,10 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+
+QT_REQUIRE_CONFIG(quick_path);
+
#include <qqml.h>
#include <QObject>
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
index 9722bf544b..7b369a2d0f 100644
--- a/src/quick/util/qquickpixmapcache.cpp
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -67,7 +67,7 @@
#include <QQmlFile>
#include <QMetaMethod>
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
#include <qqmlnetworkaccessmanagerfactory.h>
#include <QNetworkReply>
#include <QSslError>
@@ -140,18 +140,16 @@ public:
QUrl url;
bool loading;
- AutoTransform autoTransform;
int redirectCount;
class Event : public QEvent {
public:
- Event(ReadError, const QString &, const QSize &, AutoTransform, QQuickTextureFactory *factory);
+ Event(ReadError, const QString &, const QSize &, QQuickTextureFactory *factory);
~Event();
ReadError error;
QString errorString;
QSize implicitSize;
- AutoTransform autoTransform;
QQuickTextureFactory *textureFactory;
};
void postReply(ReadError, const QString &, const QSize &, QQuickTextureFactory *factory);
@@ -177,7 +175,7 @@ class QQuickPixmapReaderThreadObject : public QObject {
public:
QQuickPixmapReaderThreadObject(QQuickPixmapReader *);
void processJobs();
- virtual bool event(QEvent *e);
+ bool event(QEvent *e) override;
private slots:
void networkRequestDone();
void asyncResponseFinished();
@@ -205,8 +203,8 @@ protected:
private:
friend class QQuickPixmapReaderThreadObject;
void processJobs();
- void processJob(QQuickPixmapReply *, const QUrl &, const QString &, AutoTransform, QQuickImageProvider::ImageType, QQuickImageProvider *);
-#ifndef QT_NO_NETWORK
+ void processJob(QQuickPixmapReply *, const QUrl &, const QString &, const QQuickImageProviderOptions &, QQuickImageProvider::ImageType, QQuickImageProvider *);
+#if QT_CONFIG(qml_network)
void networkRequestDone(QNetworkReply *);
#endif
void asyncResponseFinished(QQuickImageResponse *);
@@ -220,7 +218,7 @@ private:
QQuickPixmapReaderThreadObject *threadObject;
QWaitCondition waitCondition;
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QNetworkAccessManager *networkAccessManager();
QNetworkAccessManager *accessManager;
QHash<QNetworkReply*,QQuickPixmapReply*> networkJobs;
@@ -239,20 +237,20 @@ public:
class QQuickPixmapData
{
public:
- QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QSize &s, AutoTransform transform, const QString &e)
+ QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QSize &s, const QQuickImageProviderOptions &po, const QString &e)
: refCount(1), inCache(false), pixmapStatus(QQuickPixmap::Error),
url(u), errorString(e), requestSize(s),
- requestedTransform(transform), appliedTransform(UsePluginDefault),
+ providerOptions(po), appliedTransform(QQuickImageProviderOptions::UsePluginDefaultTransform),
textureFactory(0), reply(0), prevUnreferenced(0),
prevUnreferencedPtr(0), nextUnreferenced(0)
{
declarativePixmaps.insert(pixmap);
}
- QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QSize &r, AutoTransform rTransform, AutoTransform aTransform)
+ QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QSize &r, const QQuickImageProviderOptions &po, QQuickImageProviderOptions::AutoTransform aTransform)
: refCount(1), inCache(false), pixmapStatus(QQuickPixmap::Loading),
url(u), requestSize(r),
- requestedTransform(rTransform), appliedTransform(aTransform),
+ providerOptions(po), appliedTransform(aTransform),
textureFactory(0), reply(0), prevUnreferenced(0), prevUnreferencedPtr(0),
nextUnreferenced(0)
{
@@ -260,10 +258,10 @@ public:
}
QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, QQuickTextureFactory *texture,
- const QSize &s, const QSize &r, AutoTransform rTransform, AutoTransform aTransform)
+ const QSize &s, const QSize &r, const QQuickImageProviderOptions &po, QQuickImageProviderOptions::AutoTransform aTransform)
: refCount(1), inCache(false), pixmapStatus(QQuickPixmap::Ready),
url(u), implicitSize(s), requestSize(r),
- requestedTransform(rTransform), appliedTransform(aTransform),
+ providerOptions(po), appliedTransform(aTransform),
textureFactory(texture), reply(0), prevUnreferenced(0),
prevUnreferencedPtr(0), nextUnreferenced(0)
{
@@ -272,7 +270,7 @@ public:
QQuickPixmapData(QQuickPixmap *pixmap, QQuickTextureFactory *texture)
: refCount(1), inCache(false), pixmapStatus(QQuickPixmap::Ready),
- requestedTransform(UsePluginDefault), appliedTransform(UsePluginDefault),
+ appliedTransform(QQuickImageProviderOptions::UsePluginDefaultTransform),
textureFactory(texture), reply(0), prevUnreferenced(0),
prevUnreferencedPtr(0), nextUnreferenced(0)
{
@@ -306,8 +304,8 @@ public:
QString errorString;
QSize implicitSize;
QSize requestSize;
- AutoTransform requestedTransform;
- AutoTransform appliedTransform;
+ QQuickImageProviderOptions providerOptions;
+ QQuickImageProviderOptions::AutoTransform appliedTransform;
QQuickTextureFactory *textureFactory;
@@ -336,11 +334,11 @@ void QQuickPixmapReply::postReply(ReadError error, const QString &errorString,
const QSize &implicitSize, QQuickTextureFactory *factory)
{
loading = false;
- QCoreApplication::postEvent(this, new Event(error, errorString, implicitSize, autoTransform, factory));
+ QCoreApplication::postEvent(this, new Event(error, errorString, implicitSize, factory));
}
-QQuickPixmapReply::Event::Event(ReadError e, const QString &s, const QSize &iSize, AutoTransform iTransformed, QQuickTextureFactory *factory)
- : QEvent(QEvent::User), error(e), errorString(s), implicitSize(iSize), autoTransform(iTransformed), textureFactory(factory)
+QQuickPixmapReply::Event::Event(ReadError e, const QString &s, const QSize &iSize, QQuickTextureFactory *factory)
+ : QEvent(QEvent::User), error(e), errorString(s), implicitSize(iSize), textureFactory(factory)
{
}
@@ -349,7 +347,7 @@ QQuickPixmapReply::Event::~Event()
delete textureFactory;
}
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QNetworkAccessManager *QQuickPixmapReader::networkAccessManager()
{
if (!accessManager) {
@@ -384,25 +382,32 @@ static void maybeRemoveAlpha(QImage *image)
}
static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *errorString, QSize *impsize,
- const QSize &requestSize, AutoTransform &autoTransform)
+ const QSize &requestSize, const QQuickImageProviderOptions &providerOptions,
+ QQuickImageProviderOptions::AutoTransform *appliedTransform = nullptr)
{
+ const bool preserveAspectCropOrFit = providerOptions.preserveAspectRatioCrop() || providerOptions.preserveAspectRatioFit();
+
QImageReader imgio(dev);
- if (autoTransform != UsePluginDefault)
- imgio.setAutoTransform(autoTransform == ApplyTransform);
- else
- autoTransform = imgio.autoTransform() ? ApplyTransform : DoNotApplyTransform;
+ if (providerOptions.autoTransform() != QQuickImageProviderOptions::UsePluginDefaultTransform)
+ imgio.setAutoTransform(providerOptions.autoTransform() == QQuickImageProviderOptions::ApplyTransform);
+ else if (appliedTransform)
+ *appliedTransform = imgio.autoTransform() ? QQuickImageProviderOptions::ApplyTransform : QQuickImageProviderOptions::DoNotApplyTransform;
const bool force_scale = imgio.format() == "svg" || imgio.format() == "svgz";
if (requestSize.width() > 0 || requestSize.height() > 0) {
QSize s = imgio.size();
qreal ratio = 0.0;
- if (requestSize.width() && (force_scale || requestSize.width() < s.width())) {
+ if (requestSize.width() && (preserveAspectCropOrFit || force_scale || requestSize.width() < s.width())) {
ratio = qreal(requestSize.width())/s.width();
}
- if (requestSize.height() && (force_scale || requestSize.height() < s.height())) {
+ if (requestSize.height() && (preserveAspectCropOrFit || force_scale || requestSize.height() < s.height())) {
qreal hr = qreal(requestSize.height())/s.height();
- if (ratio == 0.0 || hr < ratio)
+ if (ratio == 0.0)
+ ratio = hr;
+ else if (!preserveAspectCropOrFit && (hr < ratio))
+ ratio = hr;
+ else if (preserveAspectCropOrFit && (hr > ratio))
ratio = hr;
}
if (ratio > 0.0) {
@@ -430,7 +435,7 @@ static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *e
QQuickPixmapReader::QQuickPixmapReader(QQmlEngine *eng)
: QThread(eng), engine(eng), threadObject(0)
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
, accessManager(0)
#endif
{
@@ -454,7 +459,7 @@ QQuickPixmapReader::~QQuickPixmapReader()
delete reply;
}
jobs.clear();
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
const auto cancelJob = [this](QQuickPixmapReply *reply) {
if (reply->loading) {
@@ -476,7 +481,7 @@ QQuickPixmapReader::~QQuickPixmapReader()
wait();
}
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
void QQuickPixmapReader::networkRequestDone(QNetworkReply *reply)
{
QQuickPixmapReply *job = networkJobs.take(reply);
@@ -512,7 +517,7 @@ void QQuickPixmapReader::networkRequestDone(QNetworkReply *reply)
QByteArray all = reply->readAll();
QBuffer buff(&all);
buff.open(QIODevice::ReadOnly);
- if (!readImage(reply->url(), &buff, &image, &errorString, &readSize, job->requestSize, job->autoTransform))
+ if (!readImage(reply->url(), &buff, &image, &errorString, &readSize, job->requestSize, job->data->providerOptions))
error = QQuickPixmapReply::Decoding;
}
// send completion event to the QQuickPixmapReply
@@ -526,7 +531,7 @@ void QQuickPixmapReader::networkRequestDone(QNetworkReply *reply)
// kick off event loop again incase we have dropped below max request count
threadObject->processJobs();
}
-#endif // QT_NO_NETWORK
+#endif // qml_network
void QQuickPixmapReader::asyncResponseFinished(QQuickImageResponse *response)
{
@@ -577,7 +582,7 @@ bool QQuickPixmapReaderThreadObject::event(QEvent *e)
void QQuickPixmapReaderThreadObject::networkRequestDone()
{
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reader->networkRequestDone(reply);
#endif
@@ -599,7 +604,7 @@ void QQuickPixmapReader::processJobs()
// Clean cancelled jobs
if (!cancelled.isEmpty()) {
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
for (int i = 0; i < cancelled.count(); ++i) {
QQuickPixmapReply *job = cancelled.at(i);
QNetworkReply *reply = networkJobs.key(job, 0);
@@ -614,7 +619,6 @@ void QQuickPixmapReader::processJobs()
if (asyncResponse) {
asyncResponses.remove(asyncResponse);
asyncResponse->cancel();
- asyncResponse->deleteLater();
}
}
PIXMAP_PROFILE(pixmapStateChanged<QQuickProfiler::PixmapLoadingError>(job->url));
@@ -644,7 +648,7 @@ void QQuickPixmapReader::processJobs()
} else {
localFile = QQmlFile::urlToLocalFileOrQrc(url);
usableJob = !localFile.isEmpty()
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
|| networkJobs.count() < IMAGEREQUEST_MAX_NETWORK_REQUEST_COUNT
#endif
;
@@ -658,9 +662,8 @@ void QQuickPixmapReader::processJobs()
PIXMAP_PROFILE(pixmapStateChanged<QQuickProfiler::PixmapLoadingStarted>(url));
- AutoTransform autoTransform = job->autoTransform;
locker.unlock();
- processJob(job, url, localFile, autoTransform, imageType, provider);
+ processJob(job, url, localFile, job->data->providerOptions, imageType, provider);
locker.relock();
}
}
@@ -672,27 +675,50 @@ void QQuickPixmapReader::processJobs()
}
void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &url, const QString &localFile,
- AutoTransform autoTransform, QQuickImageProvider::ImageType imageType, QQuickImageProvider *provider)
+ const QQuickImageProviderOptions &providerOptions,
+ QQuickImageProvider::ImageType imageType, QQuickImageProvider *provider)
{
// fetch
if (url.scheme() == QLatin1String("image")) {
// Use QQuickImageProvider
QSize readSize;
+ if (imageType == QQuickImageProvider::Invalid) {
+ QString errorStr = QQuickPixmap::tr("Invalid image provider: %1").arg(url.toString());
+ mutex.lock();
+ if (!cancelled.contains(runningJob))
+ runningJob->postReply(QQuickPixmapReply::Loading, errorStr, readSize, 0);
+ mutex.unlock();
+ return;
+ }
+
+ QQuickImageProviderWithOptions *providerV2 = provider->d->isProviderWithOptions ? static_cast<QQuickImageProviderWithOptions *>(provider)
+ : nullptr;
+
+ if (!provider->d->isProviderWithOptions &&
+ (providerOptions.autoTransform() != QQuickImageProviderOptions::UsePluginDefaultTransform
+ || providerOptions.preserveAspectRatioCrop()
+ || providerOptions.preserveAspectRatioFit())
+ )
+ {
+ qWarning() << "Trying to pass extra request flags to provider but it is not a QQuickImageProviderWithOptions";
+ }
+
switch (imageType) {
case QQuickImageProvider::Invalid:
{
- QString errorStr = QQuickPixmap::tr("Invalid image provider: %1").arg(url.toString());
- mutex.lock();
- if (!cancelled.contains(runningJob))
- runningJob->postReply(QQuickPixmapReply::Loading, errorStr, readSize, 0);
- mutex.unlock();
+ // Already handled
break;
}
case QQuickImageProvider::Image:
{
- QImage image = provider->requestImage(imageId(url), &readSize, runningJob->requestSize);
+ QImage image;
+ if (providerV2) {
+ image = providerV2->requestImage(imageId(url), &readSize, runningJob->requestSize, providerOptions);
+ } else {
+ image = provider->requestImage(imageId(url), &readSize, runningJob->requestSize);
+ }
QQuickPixmapReply::ReadError errorCode = QQuickPixmapReply::NoError;
QString errorStr;
if (image.isNull()) {
@@ -708,7 +734,12 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u
case QQuickImageProvider::Pixmap:
{
- const QPixmap pixmap = provider->requestPixmap(imageId(url), &readSize, runningJob->requestSize);
+ QPixmap pixmap;
+ if (providerV2) {
+ pixmap = providerV2->requestPixmap(imageId(url), &readSize, runningJob->requestSize, providerOptions);
+ } else {
+ pixmap = provider->requestPixmap(imageId(url), &readSize, runningJob->requestSize);
+ }
QQuickPixmapReply::ReadError errorCode = QQuickPixmapReply::NoError;
QString errorStr;
if (pixmap.isNull()) {
@@ -724,7 +755,12 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u
case QQuickImageProvider::Texture:
{
- QQuickTextureFactory *t = provider->requestTexture(imageId(url), &readSize, runningJob->requestSize);
+ QQuickTextureFactory *t;
+ if (providerV2) {
+ t = providerV2->requestTexture(imageId(url), &readSize, runningJob->requestSize, providerOptions);
+ } else {
+ t = provider->requestTexture(imageId(url), &readSize, runningJob->requestSize);
+ }
QQuickPixmapReply::ReadError errorCode = QQuickPixmapReply::NoError;
QString errorStr;
if (!t) {
@@ -742,8 +778,13 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u
case QQuickImageProvider::ImageResponse:
{
- QQuickAsyncImageProvider *asyncProvider = static_cast<QQuickAsyncImageProvider*>(provider);
- QQuickImageResponse *response = asyncProvider->requestImageResponse(imageId(url), runningJob->requestSize);
+ QQuickImageResponse *response;
+ if (providerV2) {
+ response = providerV2->requestImageResponse(imageId(url), runningJob->requestSize, providerOptions);
+ } else {
+ QQuickAsyncImageProvider *asyncProvider = static_cast<QQuickAsyncImageProvider*>(provider);
+ response = asyncProvider->requestImageResponse(imageId(url), runningJob->requestSize);
+ }
QObject::connect(response, SIGNAL(finished()), threadObject, SLOT(asyncResponseFinished()));
@@ -761,7 +802,7 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u
QFile f(localFile);
QSize readSize;
if (f.open(QIODevice::ReadOnly)) {
- if (!readImage(url, &f, &image, &errorStr, &readSize, runningJob->requestSize, autoTransform))
+ if (!readImage(url, &f, &image, &errorStr, &readSize, runningJob->requestSize, providerOptions))
errorCode = QQuickPixmapReply::Loading;
} else {
errorStr = QQuickPixmap::tr("Cannot open: %1").arg(url.toString());
@@ -772,7 +813,7 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u
runningJob->postReply(errorCode, errorStr, readSize, QQuickTextureFactory::textureFactoryForImage(image));
mutex.unlock();
} else {
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
// Network resource
QNetworkRequest req(url);
req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
@@ -841,7 +882,7 @@ void QQuickPixmapReader::cancel(QQuickPixmapReply *reply)
void QQuickPixmapReader::run()
{
if (replyDownloadProgress == -1) {
-#ifndef QT_NO_NETWORK
+#if QT_CONFIG(qml_network)
replyDownloadProgress = QMetaMethod::fromSignal(&QNetworkReply::downloadProgress).methodIndex();
replyFinished = QMetaMethod::fromSignal(&QNetworkReply::finished).methodIndex();
const QMetaObject *ir = &QQuickPixmapReaderThreadObject::staticMetaObject;
@@ -866,17 +907,17 @@ class QQuickPixmapKey
public:
const QUrl *url;
const QSize *size;
- AutoTransform autoTransform;
+ QQuickImageProviderOptions options;
};
inline bool operator==(const QQuickPixmapKey &lhs, const QQuickPixmapKey &rhs)
{
- return *lhs.size == *rhs.size && *lhs.url == *rhs.url && lhs.autoTransform == rhs.autoTransform;
+ return *lhs.size == *rhs.size && *lhs.url == *rhs.url && lhs.options == rhs.options;
}
inline uint qHash(const QQuickPixmapKey &key)
{
- return qHash(*key.url) ^ (key.size->width()*7) ^ (key.size->height()*17) ^ (key.autoTransform * 0x5c5c5c5c);
+ return qHash(*key.url) ^ (key.size->width()*7) ^ (key.size->height()*17) ^ (key.options.autoTransform() * 0x5c5c5c5c);
}
class QQuickPixmapStore : public QObject
@@ -892,7 +933,7 @@ public:
void purgeCache();
protected:
- virtual void timerEvent(QTimerEvent *);
+ void timerEvent(QTimerEvent *) override;
public:
QHash<QQuickPixmapKey, QQuickPixmapData *> m_cache;
@@ -1042,7 +1083,7 @@ void QQuickPixmap::purgeCache()
}
QQuickPixmapReply::QQuickPixmapReply(QQuickPixmapData *d)
-: data(d), engineForReader(0), requestSize(d->requestSize), url(d->url), loading(false), autoTransform(d->appliedTransform), redirectCount(0)
+: data(d), engineForReader(0), requestSize(d->requestSize), url(d->url), loading(false), redirectCount(0)
{
if (finishedIndex == -1) {
finishedIndex = QMetaMethod::fromSignal(&QQuickPixmapReply::finished).methodIndex();
@@ -1067,7 +1108,6 @@ bool QQuickPixmapReply::event(QEvent *event)
data->textureFactory = de->textureFactory;
de->textureFactory = 0;
data->implicitSize = de->implicitSize;
- data->appliedTransform = de->autoTransform;
PIXMAP_PROFILE(pixmapLoadingFinished(data->url,
data->textureFactory != 0 && data->textureFactory->textureSize().isValid() ?
data->textureFactory->textureSize() :
@@ -1138,7 +1178,7 @@ void QQuickPixmapData::release()
void QQuickPixmapData::addToCache()
{
if (!inCache) {
- QQuickPixmapKey key = { &url, &requestSize, requestedTransform };
+ QQuickPixmapKey key = { &url, &requestSize, providerOptions };
pixmapStore()->m_cache.insert(key, this);
inCache = true;
PIXMAP_PROFILE(pixmapCountChanged<QQuickProfiler::PixmapCacheCountChanged>(
@@ -1149,7 +1189,7 @@ void QQuickPixmapData::addToCache()
void QQuickPixmapData::removeFromCache()
{
if (inCache) {
- QQuickPixmapKey key = { &url, &requestSize, requestedTransform };
+ QQuickPixmapKey key = { &url, &requestSize, providerOptions };
pixmapStore()->m_cache.remove(key);
inCache = false;
PIXMAP_PROFILE(pixmapCountChanged<QQuickProfiler::PixmapCacheCountChanged>(
@@ -1157,7 +1197,7 @@ void QQuickPixmapData::removeFromCache()
}
}
-static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, QQmlEngine *engine, const QUrl &url, const QSize &requestSize, AutoTransform autoTransform, bool *ok)
+static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, QQmlEngine *engine, const QUrl &url, const QSize &requestSize, const QQuickImageProviderOptions &providerOptions, bool *ok)
{
if (url.scheme() == QLatin1String("image")) {
QSize readSize;
@@ -1169,14 +1209,14 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q
switch (imageType) {
case QQuickImageProvider::Invalid:
- return new QQuickPixmapData(declarativePixmap, url, requestSize, autoTransform,
+ return new QQuickPixmapData(declarativePixmap, url, requestSize, providerOptions,
QQuickPixmap::tr("Invalid image provider: %1").arg(url.toString()));
case QQuickImageProvider::Texture:
{
QQuickTextureFactory *texture = provider->requestTexture(imageId(url), &readSize, requestSize);
if (texture) {
*ok = true;
- return new QQuickPixmapData(declarativePixmap, url, texture, readSize, requestSize, autoTransform, UsePluginDefault);
+ return new QQuickPixmapData(declarativePixmap, url, texture, readSize, requestSize, providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform);
}
break;
}
@@ -1186,7 +1226,7 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q
QImage image = provider->requestImage(imageId(url), &readSize, requestSize);
if (!image.isNull()) {
*ok = true;
- return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(image), readSize, requestSize, autoTransform, UsePluginDefault);
+ return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(image), readSize, requestSize, providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform);
}
break;
}
@@ -1195,7 +1235,7 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q
QPixmap pixmap = provider->requestPixmap(imageId(url), &readSize, requestSize);
if (!pixmap.isNull()) {
*ok = true;
- return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(pixmap.toImage()), readSize, requestSize, autoTransform, UsePluginDefault);
+ return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(pixmap.toImage()), readSize, requestSize, providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform);
}
break;
}
@@ -1207,7 +1247,7 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q
}
// provider has bad image type, or provider returned null image
- return new QQuickPixmapData(declarativePixmap, url, requestSize, autoTransform,
+ return new QQuickPixmapData(declarativePixmap, url, requestSize, providerOptions,
QQuickPixmap::tr("Failed to get image from provider: %1").arg(url.toString()));
}
@@ -1221,15 +1261,15 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q
if (f.open(QIODevice::ReadOnly)) {
QImage image;
- AutoTransform appliedTransform = autoTransform;
- if (readImage(url, &f, &image, &errorString, &readSize, requestSize, appliedTransform)) {
+ QQuickImageProviderOptions::AutoTransform appliedTransform = providerOptions.autoTransform();
+ if (readImage(url, &f, &image, &errorString, &readSize, requestSize, providerOptions, &appliedTransform)) {
*ok = true;
- return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(image), readSize, requestSize, autoTransform, appliedTransform);
+ return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(image), readSize, requestSize, providerOptions, appliedTransform);
}
} else {
errorString = QQuickPixmap::tr("Cannot open: %1").arg(url.toString());
}
- return new QQuickPixmapData(declarativePixmap, url, requestSize, autoTransform, errorString);
+ return new QQuickPixmapData(declarativePixmap, url, requestSize, providerOptions, errorString);
}
@@ -1258,7 +1298,7 @@ QQuickPixmap::QQuickPixmap(QQmlEngine *engine, const QUrl &url, const QSize &siz
QQuickPixmap::QQuickPixmap(const QUrl &url, const QImage &image)
{
- d = new QQuickPixmapData(this, url, new QQuickDefaultTextureFactory(image), image.size(), QSize(), UsePluginDefault, UsePluginDefault);
+ d = new QQuickPixmapData(this, url, new QQuickDefaultTextureFactory(image), image.size(), QSize(), QQuickImageProviderOptions(), QQuickImageProviderOptions::UsePluginDefaultTransform);
d->addToCache();
}
@@ -1331,12 +1371,12 @@ const QSize &QQuickPixmap::requestSize() const
return nullPixmap()->size;
}
-AutoTransform QQuickPixmap::autoTransform() const
+QQuickImageProviderOptions::AutoTransform QQuickPixmap::autoTransform() const
{
if (d)
return d->appliedTransform;
else
- return UsePluginDefault;
+ return QQuickImageProviderOptions::UsePluginDefaultTransform;
}
QQuickTextureFactory *QQuickPixmap::textureFactory() const
@@ -1414,10 +1454,10 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &size)
void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &requestSize, QQuickPixmap::Options options)
{
- load(engine, url, requestSize, options, UsePluginDefault);
+ load(engine, url, requestSize, options, QQuickImageProviderOptions());
}
-void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &requestSize, QQuickPixmap::Options options, AutoTransform requestAutoTransform)
+void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &requestSize, QQuickPixmap::Options options, const QQuickImageProviderOptions &providerOptions)
{
if (d) {
d->declarativePixmaps.remove(this);
@@ -1425,7 +1465,7 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &reques
d = 0;
}
- QQuickPixmapKey key = { &url, &requestSize, requestAutoTransform };
+ QQuickPixmapKey key = { &url, &requestSize, providerOptions };
QQuickPixmapStore *store = pixmapStore();
QHash<QQuickPixmapKey, QQuickPixmapData *>::Iterator iter = store->m_cache.end();
@@ -1451,7 +1491,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, requestAutoTransform, &ok);
+ d = createPixmapDataSync(this, engine, url, requestSize, providerOptions, &ok);
if (ok) {
PIXMAP_PROFILE(pixmapLoadingFinished(url, QSize(width(), height())));
if (options & QQuickPixmap::Cache)
@@ -1467,7 +1507,8 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &reques
if (!engine)
return;
- d = new QQuickPixmapData(this, url, requestSize, requestAutoTransform, requestAutoTransform);
+
+ d = new QQuickPixmapData(this, url, requestSize, providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform);
if (options & QQuickPixmap::Cache)
d->addToCache();
@@ -1503,7 +1544,7 @@ void QQuickPixmap::clear(QObject *obj)
bool QQuickPixmap::isCached(const QUrl &url, const QSize &requestSize)
{
- QQuickPixmapKey key = { &url, &requestSize, UsePluginDefault };
+ QQuickPixmapKey key = { &url, &requestSize, QQuickImageProviderOptions() };
QQuickPixmapStore *store = pixmapStore();
return store->m_cache.contains(key);
diff --git a/src/quick/util/qquickpixmapcache_p.h b/src/quick/util/qquickpixmapcache_p.h
index f53e847e00..eea6a7a454 100644
--- a/src/quick/util/qquickpixmapcache_p.h
+++ b/src/quick/util/qquickpixmapcache_p.h
@@ -65,28 +65,62 @@ QT_BEGIN_NAMESPACE
class QQmlEngine;
class QQuickPixmapData;
class QQuickTextureFactory;
-
-enum AutoTransform {
- UsePluginDefault = -1,
- ApplyTransform = 0,
- DoNotApplyTransform = 1
-};
+class QQuickImageProviderOptionsPrivate;
class QQuickDefaultTextureFactory : public QQuickTextureFactory
{
Q_OBJECT
public:
QQuickDefaultTextureFactory(const QImage &i);
- QSGTexture *createTexture(QQuickWindow *window) const;
- QSize textureSize() const { return size; }
- int textureByteCount() const { return size.width() * size.height() * 4; }
- QImage image() const { return im; }
+ QSGTexture *createTexture(QQuickWindow *window) const override;
+ QSize textureSize() const override { return size; }
+ int textureByteCount() const override { return size.width() * size.height() * 4; }
+ QImage image() const override { return im; }
private:
QImage im;
QSize size;
};
+class QQuickImageProviderPrivate
+{
+public:
+ QQuickImageProvider::ImageType type;
+ QQuickImageProvider::Flags flags;
+ bool isProviderWithOptions;
+};
+
+// ### Qt 6: Make public moving to qquickimageprovider.h
+class Q_QUICK_EXPORT QQuickImageProviderOptions
+{
+public:
+ enum AutoTransform {
+ UsePluginDefaultTransform = -1,
+ ApplyTransform = 0,
+ DoNotApplyTransform = 1
+ };
+
+ QQuickImageProviderOptions();
+ ~QQuickImageProviderOptions();
+
+ QQuickImageProviderOptions(const QQuickImageProviderOptions&);
+ QQuickImageProviderOptions& operator=(const QQuickImageProviderOptions&);
+
+ bool operator==(const QQuickImageProviderOptions&) const;
+
+ AutoTransform autoTransform() const;
+ void setAutoTransform(AutoTransform autoTransform);
+
+ bool preserveAspectRatioCrop() const;
+ void setPreserveAspectRatioCrop(bool preserveAspectRatioCrop);
+
+ bool preserveAspectRatioFit() const;
+ void setPreserveAspectRatioFit(bool preserveAspectRatioFit);
+
+private:
+ QSharedDataPointer<QQuickImageProviderOptionsPrivate> d;
+};
+
class Q_QUICK_PRIVATE_EXPORT QQuickPixmap
{
Q_DECLARE_TR_FUNCTIONS(QQuickPixmap)
@@ -115,7 +149,7 @@ public:
const QUrl &url() const;
const QSize &implicitSize() const;
const QSize &requestSize() const;
- AutoTransform autoTransform() const;
+ QQuickImageProviderOptions::AutoTransform autoTransform() const;
QImage image() const;
void setImage(const QImage &);
void setPixmap(const QQuickPixmap &other);
@@ -130,7 +164,7 @@ public:
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, AutoTransform autoTransform);
+ void load(QQmlEngine *, const QUrl &, const QSize &, QQuickPixmap::Options options, const QQuickImageProviderOptions &providerOptions);
void clear();
void clear(QObject *);
@@ -152,6 +186,24 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickPixmap::Options)
+// This class will disappear with Qt6 and will just be the regular QQuickImageProvider
+// ### Qt 6: Remove this class and fold it with QQuickImageProvider
+class Q_QUICK_EXPORT QQuickImageProviderWithOptions : public QQuickAsyncImageProvider
+{
+public:
+ QQuickImageProviderWithOptions(ImageType type, Flags flags = Flags());
+
+ QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize) override;
+ QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize) override;
+ QQuickTextureFactory *requestTexture(const QString &id, QSize *size, const QSize &requestedSize) override;
+ QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize) override;
+
+ virtual QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize, const QQuickImageProviderOptions &options);
+ virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize, const QQuickImageProviderOptions &options);
+ virtual QQuickTextureFactory *requestTexture(const QString &id, QSize *size, const QSize &requestedSize, const QQuickImageProviderOptions &options);
+ virtual QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize, const QQuickImageProviderOptions &options);
+};
+
QT_END_NAMESPACE
#endif // QQUICKPIXMAPCACHE_H
diff --git a/src/quick/util/qquickpropertychanges.cpp b/src/quick/util/qquickpropertychanges.cpp
index 37a910876e..4dfeb7cc4a 100644
--- a/src/quick/util/qquickpropertychanges.cpp
+++ b/src/quick/util/qquickpropertychanges.cpp
@@ -142,29 +142,29 @@ public:
QQuickReplaceSignalHandler() {}
~QQuickReplaceSignalHandler() {}
- virtual EventType type() const { return SignalHandler; }
+ EventType type() const override { return SignalHandler; }
QQmlProperty property;
QQmlBoundSignalExpressionPointer expression;
QQmlBoundSignalExpressionPointer reverseExpression;
QQmlBoundSignalExpressionPointer rewindExpression;
- virtual void execute() {
+ void execute() override {
QQmlPropertyPrivate::setSignalExpression(property, expression);
}
- virtual bool isReversable() { return true; }
- virtual void reverse() {
+ bool isReversable() override { return true; }
+ void reverse() override {
QQmlPropertyPrivate::setSignalExpression(property, reverseExpression);
}
- virtual void saveOriginals() {
+ void saveOriginals() override {
saveCurrentValues();
reverseExpression = rewindExpression;
}
- virtual bool needsCopy() { return true; }
- virtual void copyOriginals(QQuickStateActionEvent *other)
+ bool needsCopy() override { return true; }
+ void copyOriginals(QQuickStateActionEvent *other) override
{
QQuickReplaceSignalHandler *rsh = static_cast<QQuickReplaceSignalHandler*>(other);
saveCurrentValues();
@@ -173,14 +173,14 @@ public:
reverseExpression = rsh->reverseExpression;
}
- virtual void rewind() {
+ void rewind() override {
QQmlPropertyPrivate::setSignalExpression(property, rewindExpression);
}
- virtual void saveCurrentValues() {
+ void saveCurrentValues() override {
rewindExpression = QQmlPropertyPrivate::signalExpression(property);
}
- virtual bool override(QQuickStateActionEvent*other) {
+ bool override(QQuickStateActionEvent *other) override {
if (other == this)
return true;
if (other->type() != type())
diff --git a/src/quick/util/qquickpropertychanges_p.h b/src/quick/util/qquickpropertychanges_p.h
index 0537750338..35b37e84cb 100644
--- a/src/quick/util/qquickpropertychanges_p.h
+++ b/src/quick/util/qquickpropertychanges_p.h
@@ -78,7 +78,7 @@ public:
bool isExplicit() const;
void setIsExplicit(bool);
- virtual ActionList actions();
+ ActionList actions() override;
bool containsProperty(const QString &name) const;
bool containsValue(const QString &name) const;
@@ -103,8 +103,8 @@ public:
void verifyList(const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding);
- virtual void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props);
- virtual void applyBindings(QObject *obj, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings);
+ void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props) override;
+ void applyBindings(QObject *obj, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
};
diff --git a/src/quick/util/qquickshortcut.cpp b/src/quick/util/qquickshortcut.cpp
index 9725ddd671..a0a58f2e02 100644
--- a/src/quick/util/qquickshortcut.cpp
+++ b/src/quick/util/qquickshortcut.cpp
@@ -41,10 +41,9 @@
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickwindow.h>
+#include <QtQuick/private/qtquickglobal_p.h>
#include <QtGui/private/qguiapplication_p.h>
-QT_BEGIN_NAMESPACE
-
/*!
\qmltype Shortcut
\instantiates QQuickShortcut
@@ -71,6 +70,9 @@ QT_BEGIN_NAMESPACE
}
\endqml
+ It is also possible to set multiple shortcut \l sequences, so that the shortcut
+ can be \l activated via several different sequences of key presses.
+
\sa Keys
*/
@@ -89,14 +91,56 @@ QT_BEGIN_NAMESPACE
The corresponding handler is \c onActivatedAmbiguously.
*/
-QQuickShortcut::QQuickShortcut(QObject *parent) : QObject(parent), m_id(0),
+static bool qQuickShortcutContextMatcher(QObject *obj, Qt::ShortcutContext context)
+{
+ switch (context) {
+ case Qt::ApplicationShortcut:
+ return true;
+ case Qt::WindowShortcut:
+ while (obj && !obj->isWindowType()) {
+ obj = obj->parent();
+ if (QQuickItem *item = qobject_cast<QQuickItem *>(obj))
+ obj = item->window();
+ }
+ return obj && obj == QGuiApplication::focusWindow();
+ default:
+ return false;
+ }
+}
+
+typedef bool (*ContextMatcher)(QObject *, Qt::ShortcutContext);
+
+Q_GLOBAL_STATIC_WITH_ARGS(ContextMatcher, ctxMatcher, (qQuickShortcutContextMatcher))
+
+Q_QUICK_PRIVATE_EXPORT ContextMatcher qt_quick_shortcut_context_matcher()
+{
+ return *ctxMatcher();
+}
+
+Q_QUICK_PRIVATE_EXPORT void qt_quick_set_shortcut_context_matcher(ContextMatcher matcher)
+{
+ *ctxMatcher() = matcher;
+}
+
+QT_BEGIN_NAMESPACE
+
+static QKeySequence valueToKeySequence(const QVariant &value)
+{
+ if (value.type() == QVariant::Int)
+ return QKeySequence(static_cast<QKeySequence::StandardKey>(value.toInt()));
+ return QKeySequence::fromString(value.toString());
+}
+
+QQuickShortcut::QQuickShortcut(QObject *parent) : QObject(parent),
m_enabled(true), m_completed(false), m_autorepeat(true), m_context(Qt::WindowShortcut)
{
}
QQuickShortcut::~QQuickShortcut()
{
- ungrabShortcut();
+ ungrabShortcut(m_shortcut);
+ for (Shortcut &shortcut : m_shortcuts)
+ ungrabShortcut(shortcut);
}
/*!
@@ -115,31 +159,79 @@ QQuickShortcut::~QQuickShortcut()
onActivated: edit.wrapMode = TextEdit.Wrap
}
\endqml
+
+ \sa sequences
*/
QVariant QQuickShortcut::sequence() const
{
- return m_sequence;
+ return m_shortcut.userValue;
}
-void QQuickShortcut::setSequence(const QVariant &sequence)
+void QQuickShortcut::setSequence(const QVariant &value)
{
- if (sequence == m_sequence)
+ if (value == m_shortcut.userValue)
return;
- QKeySequence shortcut;
- if (sequence.type() == QVariant::Int)
- shortcut = QKeySequence(static_cast<QKeySequence::StandardKey>(sequence.toInt()));
- else
- shortcut = QKeySequence::fromString(sequence.toString());
-
- grabShortcut(shortcut, m_context);
+ QKeySequence keySequence = valueToKeySequence(value);
- m_sequence = sequence;
- m_shortcut = shortcut;
+ ungrabShortcut(m_shortcut);
+ m_shortcut.userValue = value;
+ m_shortcut.keySequence = keySequence;
+ grabShortcut(m_shortcut, m_context);
emit sequenceChanged();
}
/*!
+ \qmlproperty list<keysequence> QtQuick::Shortcut::sequences
+ \since 5.9
+
+ This property holds multiple key sequences for the shortcut. The key sequences
+ can be set to one of the \l{QKeySequence::StandardKey}{standard keyboard shortcuts},
+ or they can be described with strings containing sequences of up to four key
+ presses that are needed to \l{Shortcut::activated}{activate} the shortcut.
+
+ \qml
+ Shortcut {
+ sequences: [StandardKey.Cut, "Ctrl+X", "Shift+Del"]
+ onActivated: edit.cut()
+ }
+ \endqml
+*/
+QVariantList QQuickShortcut::sequences() const
+{
+ QVariantList values;
+ for (const Shortcut &shortcut : m_shortcuts)
+ values += shortcut.userValue;
+ return values;
+}
+
+void QQuickShortcut::setSequences(const QVariantList &values)
+{
+ QVector<Shortcut> remainder = m_shortcuts.mid(values.count());
+ m_shortcuts.resize(values.count());
+
+ bool changed = !remainder.isEmpty();
+ for (int i = 0; i < values.count(); ++i) {
+ QVariant value = values.at(i);
+ Shortcut& shortcut = m_shortcuts[i];
+ if (value == shortcut.userValue)
+ continue;
+
+ QKeySequence keySequence = valueToKeySequence(value);
+
+ ungrabShortcut(shortcut);
+ shortcut.userValue = value;
+ shortcut.keySequence = keySequence;
+ grabShortcut(shortcut, m_context);
+
+ changed = true;
+ }
+
+ if (changed)
+ emit sequencesChanged();
+}
+
+/*!
\qmlproperty string QtQuick::Shortcut::nativeText
\since 5.6
@@ -152,7 +244,7 @@ void QQuickShortcut::setSequence(const QVariant &sequence)
*/
QString QQuickShortcut::nativeText() const
{
- return m_shortcut.toString(QKeySequence::NativeText);
+ return m_shortcut.keySequence.toString(QKeySequence::NativeText);
}
/*!
@@ -167,7 +259,7 @@ QString QQuickShortcut::nativeText() const
*/
QString QQuickShortcut::portableText() const
{
- return m_shortcut.toString(QKeySequence::PortableText);
+ return m_shortcut.keySequence.toString(QKeySequence::PortableText);
}
/*!
@@ -187,8 +279,9 @@ void QQuickShortcut::setEnabled(bool enabled)
if (enabled == m_enabled)
return;
- if (m_id)
- QGuiApplicationPrivate::instance()->shortcutMap.setShortcutEnabled(enabled, m_id, this);
+ setEnabled(m_shortcut, enabled);
+ for (Shortcut &shortcut : m_shortcuts)
+ setEnabled(shortcut, enabled);
m_enabled = enabled;
emit enabledChanged();
@@ -211,8 +304,9 @@ void QQuickShortcut::setAutoRepeat(bool repeat)
if (repeat == m_autorepeat)
return;
- if (m_id)
- QGuiApplicationPrivate::instance()->shortcutMap.setShortcutAutoRepeat(repeat, m_id, this);
+ setAutoRepeat(m_shortcut, repeat);
+ for (Shortcut &shortcut : m_shortcuts)
+ setAutoRepeat(shortcut, repeat);
m_autorepeat = repeat;
emit autoRepeatChanged();
@@ -247,9 +341,9 @@ void QQuickShortcut::setContext(Qt::ShortcutContext context)
if (context == m_context)
return;
- grabShortcut(m_shortcut, context);
-
+ ungrabShortcut(m_shortcut);
m_context = context;
+ grabShortcut(m_shortcut, context);
emit contextChanged();
}
@@ -261,13 +355,19 @@ void QQuickShortcut::componentComplete()
{
m_completed = true;
grabShortcut(m_shortcut, m_context);
+ for (Shortcut &shortcut : m_shortcuts)
+ grabShortcut(shortcut, m_context);
}
bool QQuickShortcut::event(QEvent *event)
{
if (m_enabled && event->type() == QEvent::Shortcut) {
QShortcutEvent *se = static_cast<QShortcutEvent *>(event);
- if (se->shortcutId() == m_id && se->key() == m_shortcut){
+ bool match = m_shortcut.matches(se);
+ int i = 0;
+ while (!match && i < m_shortcuts.count())
+ match |= m_shortcuts.at(i++).matches(se);
+ if (match) {
if (se->isAmbiguous())
emit activatedAmbiguously();
else
@@ -278,42 +378,40 @@ bool QQuickShortcut::event(QEvent *event)
return false;
}
-static bool qQuickShortcutContextMatcher(QObject *obj, Qt::ShortcutContext context)
+bool QQuickShortcut::Shortcut::matches(QShortcutEvent *event) const
{
- switch (context) {
- case Qt::ApplicationShortcut:
- return true;
- case Qt::WindowShortcut:
- while (obj && !obj->isWindowType()) {
- obj = obj->parent();
- if (QQuickItem *item = qobject_cast<QQuickItem *>(obj))
- obj = item->window();
- }
- return obj && obj == QGuiApplication::focusWindow();
- default:
- return false;
- }
+ return event->shortcutId() == id && event->key() == keySequence;
}
-void QQuickShortcut::grabShortcut(const QKeySequence &sequence, Qt::ShortcutContext context)
+void QQuickShortcut::setEnabled(QQuickShortcut::Shortcut &shortcut, bool enabled)
{
- ungrabShortcut();
+ if (shortcut.id)
+ QGuiApplicationPrivate::instance()->shortcutMap.setShortcutEnabled(enabled, shortcut.id, this);
+}
- if (m_completed && !sequence.isEmpty()) {
+void QQuickShortcut::setAutoRepeat(QQuickShortcut::Shortcut &shortcut, bool repeat)
+{
+ if (shortcut.id)
+ QGuiApplicationPrivate::instance()->shortcutMap.setShortcutAutoRepeat(repeat, shortcut.id, this);
+}
+
+void QQuickShortcut::grabShortcut(Shortcut &shortcut, Qt::ShortcutContext context)
+{
+ if (m_completed && !shortcut.keySequence.isEmpty()) {
QGuiApplicationPrivate *pApp = QGuiApplicationPrivate::instance();
- m_id = pApp->shortcutMap.addShortcut(this, sequence, context, qQuickShortcutContextMatcher);
+ shortcut.id = pApp->shortcutMap.addShortcut(this, shortcut.keySequence, context, *ctxMatcher());
if (!m_enabled)
- pApp->shortcutMap.setShortcutEnabled(false, m_id, this);
+ pApp->shortcutMap.setShortcutEnabled(false, shortcut.id, this);
if (!m_autorepeat)
- pApp->shortcutMap.setShortcutAutoRepeat(false, m_id, this);
+ pApp->shortcutMap.setShortcutAutoRepeat(false, shortcut.id, this);
}
}
-void QQuickShortcut::ungrabShortcut()
+void QQuickShortcut::ungrabShortcut(Shortcut &shortcut)
{
- if (m_id) {
- QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(m_id, this);
- m_id = 0;
+ if (shortcut.id) {
+ QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(shortcut.id, this);
+ shortcut.id = 0;
}
}
diff --git a/src/quick/util/qquickshortcut_p.h b/src/quick/util/qquickshortcut_p.h
index b3f33a33c1..93430ad893 100644
--- a/src/quick/util/qquickshortcut_p.h
+++ b/src/quick/util/qquickshortcut_p.h
@@ -52,17 +52,21 @@
//
#include <QtCore/qobject.h>
+#include <QtCore/qvector.h>
#include <QtCore/qvariant.h>
#include <QtGui/qkeysequence.h>
#include <QtQml/qqmlparserstatus.h>
QT_BEGIN_NAMESPACE
+class QShortcutEvent;
+
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 1)
Q_PROPERTY(QString portableText READ portableText NOTIFY sequenceChanged FINAL REVISION 1)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged FINAL)
@@ -76,6 +80,9 @@ public:
QVariant sequence() const;
void setSequence(const QVariant &sequence);
+ QVariantList sequences() const;
+ void setSequences(const QVariantList &sequences);
+
QString nativeText() const;
QString portableText() const;
@@ -90,6 +97,7 @@ public:
Q_SIGNALS:
void sequenceChanged();
+ Q_REVISION(9) void sequencesChanged();
void enabledChanged();
void autoRepeatChanged();
void contextChanged();
@@ -102,17 +110,26 @@ protected:
void componentComplete() Q_DECL_OVERRIDE;
bool event(QEvent *event) Q_DECL_OVERRIDE;
- void grabShortcut(const QKeySequence &sequence, Qt::ShortcutContext context);
- void ungrabShortcut();
+ struct Shortcut {
+ bool matches(QShortcutEvent *event) const;
+ int id;
+ QVariant userValue;
+ QKeySequence keySequence;
+ };
+
+ void setEnabled(Shortcut &shortcut, bool enabled);
+ void setAutoRepeat(Shortcut &shortcut, bool repeat);
+
+ void grabShortcut(Shortcut &shortcut, Qt::ShortcutContext context);
+ void ungrabShortcut(Shortcut &shortcut);
private:
- int m_id;
bool m_enabled;
bool m_completed;
bool m_autorepeat;
- QKeySequence m_shortcut;
Qt::ShortcutContext m_context;
- QVariant m_sequence;
+ Shortcut m_shortcut;
+ QVector<Shortcut> m_shortcuts;
};
QT_END_NAMESPACE
diff --git a/src/quick/util/qquicksmoothedanimation_p.h b/src/quick/util/qquicksmoothedanimation_p.h
index d640985b39..2f0e3bc0d8 100644
--- a/src/quick/util/qquicksmoothedanimation_p.h
+++ b/src/quick/util/qquicksmoothedanimation_p.h
@@ -79,8 +79,8 @@ public:
ReversingMode reversingMode() const;
void setReversingMode(ReversingMode);
- virtual int duration() const;
- virtual void setDuration(int);
+ int duration() const override;
+ void setDuration(int) override;
qreal velocity() const;
void setVelocity(qreal);
@@ -88,10 +88,10 @@ public:
int maximumEasingTime() const;
void setMaximumEasingTime(int);
- virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
+ QAbstractAnimationJob* transition(QQuickStateActions &actions,
QQmlProperties &modified,
TransitionDirection direction,
- QObject *defaultTarget = 0);
+ QObject *defaultTarget = 0) override;
Q_SIGNALS:
void velocityChanged();
void reversingModeChanged();
diff --git a/src/quick/util/qquicksmoothedanimation_p_p.h b/src/quick/util/qquicksmoothedanimation_p_p.h
index 4a61599592..a415fdb55f 100644
--- a/src/quick/util/qquicksmoothedanimation_p_p.h
+++ b/src/quick/util/qquicksmoothedanimation_p_p.h
@@ -93,7 +93,7 @@ public:
QQmlProperty target;
- int duration() const;
+ int duration() const override;
void restart();
void init();
@@ -101,9 +101,9 @@ public:
void clearTemplate() { animationTemplate = 0; }
protected:
- virtual void updateCurrentTime(int);
- virtual void updateState(QAbstractAnimationJob::State, QAbstractAnimationJob::State);
- void debugAnimation(QDebug d) const;
+ void updateCurrentTime(int) override;
+ void updateState(QAbstractAnimationJob::State, QAbstractAnimationJob::State) override;
+ void debugAnimation(QDebug d) const override;
private:
qreal easeFollow(qreal);
diff --git a/src/quick/util/qquickspringanimation.cpp b/src/quick/util/qquickspringanimation.cpp
index 294122150a..a9940959a0 100644
--- a/src/quick/util/qquickspringanimation.cpp
+++ b/src/quick/util/qquickspringanimation.cpp
@@ -61,7 +61,7 @@ public:
QSpringAnimation(QQuickSpringAnimationPrivate * = 0);
~QSpringAnimation();
- int duration() const;
+ int duration() const override;
void restart();
void init();
@@ -97,9 +97,9 @@ public:
void clearTemplate() { animationTemplate = 0; }
protected:
- virtual void updateCurrentTime(int time);
- virtual void updateState(QAbstractAnimationJob::State, QAbstractAnimationJob::State);
- void debugAnimation(QDebug d) const;
+ void updateCurrentTime(int time) override;
+ void updateState(QAbstractAnimationJob::State, QAbstractAnimationJob::State) override;
+ void debugAnimation(QDebug d) const override;
private:
QQuickSpringAnimationPrivate *animationTemplate;
diff --git a/src/quick/util/qquickspringanimation_p.h b/src/quick/util/qquickspringanimation_p.h
index 141a2469d7..ffb2c41e6b 100644
--- a/src/quick/util/qquickspringanimation_p.h
+++ b/src/quick/util/qquickspringanimation_p.h
@@ -94,10 +94,10 @@ public:
qreal modulus() const;
void setModulus(qreal modulus);
- virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
+ QAbstractAnimationJob* transition(QQuickStateActions &actions,
QQmlProperties &modified,
TransitionDirection direction,
- QObject *defaultTarget = 0);
+ QObject *defaultTarget = 0) override;
Q_SIGNALS:
void modulusChanged();
diff --git a/src/quick/util/qquickstatechangescript_p.h b/src/quick/util/qquickstatechangescript_p.h
index 0c17b7c68c..a1315ae2ef 100644
--- a/src/quick/util/qquickstatechangescript_p.h
+++ b/src/quick/util/qquickstatechangescript_p.h
@@ -69,9 +69,9 @@ public:
QQuickStateChangeScript(QObject *parent=0);
~QQuickStateChangeScript();
- virtual ActionList actions();
+ ActionList actions() override;
- virtual EventType type() const;
+ EventType type() const override;
QQmlScriptString script() const;
void setScript(const QQmlScriptString &);
@@ -79,7 +79,7 @@ public:
QString name() const;
void setName(const QString &);
- virtual void execute();
+ void execute() override;
};
diff --git a/src/quick/util/qquickstategroup_p.h b/src/quick/util/qquickstategroup_p.h
index 78508ac166..eebe3a9e56 100644
--- a/src/quick/util/qquickstategroup_p.h
+++ b/src/quick/util/qquickstategroup_p.h
@@ -81,8 +81,8 @@ public:
QQuickState *findState(const QString &name) const;
void removeState(QQuickState *state);
- virtual void classBegin();
- virtual void componentComplete();
+ void classBegin() override;
+ void componentComplete() override;
Q_SIGNALS:
void stateChanged(const QString &);
diff --git a/src/quick/util/qquickstyledtext.cpp b/src/quick/util/qquickstyledtext.cpp
index 4139c87eda..ae8719341d 100644
--- a/src/quick/util/qquickstyledtext.cpp
+++ b/src/quick/util/qquickstyledtext.cpp
@@ -721,8 +721,7 @@ void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QStri
QString padding(qFloor(imgWidth / spaceWidth), QChar::Nbsp);
if (!trailingSpace)
textOut += QLatin1Char(' ');
- textOut += padding;
- textOut += QLatin1Char(' ');
+ textOut += padding + QLatin1Char(' ');
}
QPair<QStringRef,QStringRef> QQuickStyledTextPrivate::parseAttribute(const QChar *&ch, const QString &textIn)
diff --git a/src/quick/util/qquicktimeline_p_p.h b/src/quick/util/qquicktimeline_p_p.h
index 552f194b79..ae1087487b 100644
--- a/src/quick/util/qquicktimeline_p_p.h
+++ b/src/quick/util/qquicktimeline_p_p.h
@@ -100,14 +100,14 @@ public:
int time() const;
- virtual int duration() const;
+ int duration() const override;
Q_SIGNALS:
void updated();
void completed();
protected:
- virtual void updateCurrentTime(int);
- void debugAnimation(QDebug d) const;
+ void updateCurrentTime(int) override;
+ void debugAnimation(QDebug d) const override;
private:
void remove(QQuickTimeLineObject *);
@@ -181,7 +181,7 @@ public:
Q_ASSERT(_class);
}
- virtual void setValue(qreal v)
+ void setValue(qreal v) override
{
QQuickTimeLineValue::setValue(v);
if (_setFunctionReal) (_class->*_setFunctionReal)(v);
diff --git a/src/quick/util/qquicktransition.cpp b/src/quick/util/qquicktransition.cpp
index c8b5482c87..1d258d84bf 100644
--- a/src/quick/util/qquicktransition.cpp
+++ b/src/quick/util/qquicktransition.cpp
@@ -106,7 +106,7 @@ public:
QQuickTransitionManager *manager;
protected:
- virtual void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState);
+ void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override;
};
class QQuickTransitionPrivate : public QObjectPrivate, QAnimationJobChangeListener
@@ -134,7 +134,7 @@ public:
bool reversible;
bool enabled;
protected:
- virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State, QAbstractAnimationJob::State);
+ void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State, QAbstractAnimationJob::State) override;
static void append_animation(QQmlListProperty<QQuickAbstractAnimation> *list, QQuickAbstractAnimation *a);
static int animation_count(QQmlListProperty<QQuickAbstractAnimation> *list);
diff --git a/src/quick/util/qquickutilmodule.cpp b/src/quick/util/qquickutilmodule.cpp
index 66994e22ba..cb586d1565 100644
--- a/src/quick/util/qquickutilmodule.cpp
+++ b/src/quick/util/qquickutilmodule.cpp
@@ -107,7 +107,7 @@ void QQuickUtilModule::defineModule()
qmlRegisterType<QQuickScaleAnimator>("QtQuick", 2, 2, "ScaleAnimator");
qmlRegisterType<QQuickRotationAnimator>("QtQuick", 2, 2, "RotationAnimator");
qmlRegisterType<QQuickOpacityAnimator>("QtQuick", 2, 2, "OpacityAnimator");
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
qmlRegisterType<QQuickUniformAnimator>("QtQuick", 2, 2, "UniformAnimator");
#endif
qmlRegisterType<QQuickStateOperation>();
@@ -123,4 +123,6 @@ void QQuickUtilModule::defineModule()
qmlRegisterType<QQuickShortcut>("QtQuick", 2, 5, "Shortcut");
qmlRegisterType<QQuickShortcut,1>("QtQuick", 2, 6, "Shortcut");
+
+ qmlRegisterType<QQuickShortcut,9>("QtQuick", 2, 9, "Shortcut");
}
diff --git a/src/quick/util/util.pri b/src/quick/util/util.pri
index 66792536d7..1ef1018a31 100644
--- a/src/quick/util/util.pri
+++ b/src/quick/util/util.pri
@@ -17,8 +17,6 @@ SOURCES += \
$$PWD/qquickbehavior.cpp \
$$PWD/qquickfontloader.cpp \
$$PWD/qquickstyledtext.cpp \
- $$PWD/qquickpath.cpp \
- $$PWD/qquickpathinterpolator.cpp \
$$PWD/qquickimageprovider.cpp \
$$PWD/qquicksvgparser.cpp \
$$PWD/qquickvaluetypes.cpp \
@@ -55,9 +53,6 @@ HEADERS += \
$$PWD/qquickbehavior_p.h \
$$PWD/qquickfontloader_p.h \
$$PWD/qquickstyledtext_p.h \
- $$PWD/qquickpath_p.h \
- $$PWD/qquickpath_p_p.h \
- $$PWD/qquickpathinterpolator_p.h \
$$PWD/qquickimageprovider.h \
$$PWD/qquicksvgparser_p.h \
$$PWD/qquickvaluetypes_p.h \
@@ -70,3 +65,13 @@ HEADERS += \
$$PWD/qquicktextmetrics_p.h \
$$PWD/qquickshortcut_p.h \
$$PWD/qquickvalidator_p.h
+
+qtConfig(quick-path) {
+ SOURCES += \
+ $$PWD/qquickpath.cpp \
+ $$PWD/qquickpathinterpolator.cpp
+ HEADERS += \
+ $$PWD/qquickpath_p.h \
+ $$PWD/qquickpath_p_p.h \
+ $$PWD/qquickpathinterpolator_p.h
+}
diff --git a/src/src.pro b/src/src.pro
index 11bc4de8e3..f585ef15ca 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -1,5 +1,7 @@
TEMPLATE = subdirs
CONFIG += ordered
+include($$OUT_PWD/quick/qtquick-config.pri)
+QT_FOR_CONFIG += quick-private
SUBDIRS += \
qml
@@ -8,7 +10,8 @@ qtHaveModule(gui) {
quick \
qmltest
- qtConfig(opengl(es1|es2)?): SUBDIRS += particles
+ qtConfig(quick-sprite):qtConfig(opengl(es1|es2)?): \
+ SUBDIRS += particles
qtHaveModule(widgets): SUBDIRS += quickwidgets
}