aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2016-12-20 09:37:14 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2016-12-20 09:37:14 +0100
commitc07610b208268e6b6b952d634a6540ff66a0a8a8 (patch)
treedf8f0a71db8e1d3a6144e35468125c2b263dc372
parent6f94828e8f1865259ff1b1cd7fda5064ffd9576c (diff)
parentc4eefa4a8d6d3e95062deb78229940460a7ef605 (diff)
Merge branch remote-tracking branch 'origin/dev' into wip/pointerhandler
-rw-r--r--dist/changes-5.7.164
-rw-r--r--examples/qml/networkaccessmanagerfactory/main.cpp16
-rw-r--r--examples/quick/demos/stocqt/content/Banner.qml (renamed from examples/quick/localstorage/localstorage/hello.qml)70
-rw-r--r--examples/quick/demos/stocqt/content/CheckBox.qml1
-rw-r--r--examples/quick/demos/stocqt/content/StockChart.qml535
-rw-r--r--examples/quick/demos/stocqt/content/StockInfo.qml99
-rw-r--r--examples/quick/demos/stocqt/content/StockListDelegate.qml153
-rw-r--r--examples/quick/demos/stocqt/content/StockListModel.qml66
-rw-r--r--examples/quick/demos/stocqt/content/StockListView.qml184
-rw-r--r--examples/quick/demos/stocqt/content/StockSettingsPanel.qml204
-rw-r--r--examples/quick/demos/stocqt/content/StockView.qml67
-rw-r--r--examples/quick/demos/stocqt/content/qmldir2
-rw-r--r--examples/quick/demos/stocqt/stocqt.qml115
-rw-r--r--examples/quick/demos/stocqt/stocqt.qrc2
-rw-r--r--examples/quick/localstorage/doc/src/localstorage.qdoc11
-rw-r--r--examples/quick/localstorage/localstorage/Database.js97
-rw-r--r--examples/quick/localstorage/localstorage/Header.qml173
-rw-r--r--examples/quick/localstorage/localstorage/MyButton.qml76
-rw-r--r--examples/quick/localstorage/localstorage/MyDelegate.qml74
-rw-r--r--examples/quick/localstorage/localstorage/MyModel.qml35
-rw-r--r--examples/quick/localstorage/localstorage/localstorage.qml209
-rw-r--r--examples/quick/localstorage/localstorage/localstorage.qmlproject16
-rw-r--r--examples/quick/localstorage/localstorage/localstorage.qrc8
-rw-r--r--examples/quick/localstorage/localstorage/main.cpp65
-rw-r--r--examples/quick/localstorage/localstorage/qml-localstorage-example.pngbin0 -> 46168 bytes
-rw-r--r--examples/quick/positioners/positioners-attachedproperties.qml18
-rw-r--r--examples/quick/positioners/positioners-transitions.qml94
-rw-r--r--examples/quick/quickwidgets/qquickviewcomparison/fbitem.cpp4
-rw-r--r--examples/quick/quickwidgets/quickwidget/fbitem.cpp4
-rw-r--r--examples/quick/rendercontrol/cuberenderer.cpp4
-rw-r--r--examples/quick/scenegraph/openglunderqml/squircle.cpp32
-rw-r--r--examples/quick/scenegraph/rendernode/customrenderitem.cpp2
-rw-r--r--examples/quick/scenegraph/rendernode/d3d12renderer.cpp30
-rw-r--r--examples/quick/scenegraph/rendernode/openglrenderer.cpp8
-rw-r--r--examples/quick/scenegraph/rendernode/openglrenderer.h4
-rw-r--r--examples/quick/scenegraph/rendernode/rendernode.pro16
-rw-r--r--examples/quick/scenegraph/rendernode/rendernode.qrc2
-rw-r--r--examples/quick/scenegraph/rendernode/shader_frag.csobin0 -> 908 bytes
-rw-r--r--examples/quick/scenegraph/rendernode/shader_vert.csobin0 -> 1720 bytes
-rw-r--r--examples/quick/scenegraph/rendernode/softwarerenderer.cpp2
-rw-r--r--examples/quick/scenegraph/scenegraph.pro1
-rw-r--r--examples/quick/scenegraph/shared/logorenderer.cpp8
-rw-r--r--examples/quick/shared/shared.h1
-rw-r--r--src/3rdparty/masm/wtf/OSAllocatorPosix.cpp10
-rw-r--r--src/imports/folderlistmodel/fileinfothread.cpp16
-rw-r--r--src/imports/folderlistmodel/fileinfothread_p.h4
-rw-r--r--src/imports/folderlistmodel/plugin.cpp2
-rw-r--r--src/imports/folderlistmodel/qquickfolderlistmodel.cpp6
-rw-r--r--src/imports/layouts/qquicklayout.cpp32
-rw-r--r--src/imports/layouts/qquicklayout_p.h4
-rw-r--r--src/imports/layouts/qquicklinearlayout.cpp54
-rw-r--r--src/imports/layouts/qquicklinearlayout_p.h9
-rw-r--r--src/imports/localstorage/plugin.cpp6
-rw-r--r--src/imports/testlib/SignalSpy.qml10
-rw-r--r--src/imports/testlib/TestCase.qml269
-rw-r--r--src/imports/testlib/main.cpp1
-rw-r--r--src/imports/testlib/qmldir1
-rw-r--r--src/imports/testlib/toucheventsequence.qdoc110
-rw-r--r--src/imports/window/plugins.qmltypes8
-rw-r--r--src/particles/qquickimageparticle.cpp6
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qmldbg_debugger.pro4
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservice.json2
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservicefactory.cpp8
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservicefactory.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp5
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp45
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h9
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp5
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp4
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/globalinspector.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/highlight.h4
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservicefactory.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp12
-rw-r--r--src/plugins/qmltooling/qmldbg_local/qlocalclientconnectionfactory.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.cpp (renamed from src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.cpp)0
-rw-r--r--src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.h (renamed from src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.h)4
-rw-r--r--src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.json3
-rw-r--r--src/plugins/qmltooling/qmldbg_messages/qdebugmessageservicefactory.cpp (renamed from src/qml/jsruntime/qv4context_p_p.h)43
-rw-r--r--src/plugins/qmltooling/qmldbg_messages/qdebugmessageservicefactory.h57
-rw-r--r--src/plugins/qmltooling/qmldbg_messages/qmldbg_messages.pro21
-rw-r--r--src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp4
-rw-r--r--src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_nativedebugger/qmldbg_nativedebugger.pro21
-rw-r--r--src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp (renamed from src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp)24
-rw-r--r--src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.h (renamed from src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.h)2
-rw-r--r--src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.json3
-rw-r--r--src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservicefactory.cpp54
-rw-r--r--src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservicefactory.h57
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp5
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.h1
-rw-r--r--src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapterfactory.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp4
-rw-r--r--src/plugins/qmltooling/qmldbg_server/qqmldebugserverfactory.h2
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnectionfactory.h2
-rw-r--r--src/plugins/qmltooling/qmltooling.pro6
-rw-r--r--src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp83
-rw-r--r--src/plugins/scenegraph/d3d12/qsgd3d12publicnodes.cpp14
-rw-r--r--src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp12
-rw-r--r--src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp24
-rw-r--r--src/plugins/scenegraph/openvg/openvg.json3
-rw-r--r--src/plugins/scenegraph/openvg/openvg.pro56
-rw-r--r--src/plugins/scenegraph/openvg/qopenvgcontext.cpp218
-rw-r--r--src/plugins/scenegraph/openvg/qopenvgcontext_p.h88
-rw-r--r--src/plugins/scenegraph/openvg/qopenvgmatrix.cpp378
-rw-r--r--src/plugins/scenegraph/openvg/qopenvgmatrix.h108
-rw-r--r--src/plugins/scenegraph/openvg/qopenvgoffscreensurface.cpp123
-rw-r--r--src/plugins/scenegraph/openvg/qopenvgoffscreensurface.h75
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgadaptation.cpp78
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgadaptation_p.h68
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgcontext.cpp219
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgcontext_p.h104
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.cpp162
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.h97
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgglyphnode.cpp214
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgglyphnode_p.h95
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvghelpers.cpp433
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvghelpers.h64
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.cpp239
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.h92
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp732
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h100
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvglayer.cpp315
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvglayer.h113
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.cpp275
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.h92
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgpainternode.cpp253
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgpainternode.h97
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.cpp325
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.h145
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgrenderable.cpp87
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgrenderable.h75
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgrenderer.cpp90
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgrenderer_p.h61
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgrenderloop.cpp257
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgrenderloop_p.h94
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgspritenode.cpp157
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgspritenode.h78
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgtexture.cpp123
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvgtexture.h67
-rw-r--r--src/plugins/scenegraph/scenegraph.pro2
-rw-r--r--src/qml/animations/qabstractanimationjob_p.h6
-rw-r--r--src/qml/animations/qcontinuinganimationgroupjob_p.h12
-rw-r--r--src/qml/animations/qpauseanimationjob_p.h6
-rw-r--r--src/qml/animations/qsequentialanimationgroupjob_p.h16
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp10
-rw-r--r--src/qml/compiler/qqmlpropertycachecreator_p.h56
-rw-r--r--src/qml/compiler/qqmlpropertyvalidator.cpp4
-rw-r--r--src/qml/compiler/qqmltypecompiler.cpp12
-rw-r--r--src/qml/compiler/qv4compileddata.cpp4
-rw-r--r--src/qml/compiler/qv4compileddata_p.h16
-rw-r--r--src/qml/compiler/qv4ssa.cpp16
-rw-r--r--src/qml/debugger/qqmldebug.cpp14
-rw-r--r--src/qml/debugger/qqmldebug.h1
-rw-r--r--src/qml/debugger/qqmldebugconnector.cpp15
-rw-r--r--src/qml/debugger/qqmldebugserviceinterfaces_p.h4
-rw-r--r--src/qml/debugger/qqmlmemoryprofiler.cpp4
-rw-r--r--src/qml/debugger/qqmlprofiler_p.h9
-rw-r--r--src/qml/doc/src/javascript/resources.qdoc8
-rw-r--r--src/qml/doc/src/qmlfunctions.qdoc12
-rw-r--r--src/qml/jit/qv4isel_masm.cpp49
-rw-r--r--src/qml/jit/qv4isel_masm_p.h118
-rw-r--r--src/qml/jsapi/qjsvalue.cpp16
-rw-r--r--src/qml/jsruntime/jsruntime.pri3
-rw-r--r--src/qml/jsruntime/qv4argumentsobject.cpp19
-rw-r--r--src/qml/jsruntime/qv4argumentsobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4context.cpp169
-rw-r--r--src/qml/jsruntime/qv4context_p.h47
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp11
-rw-r--r--src/qml/jsruntime/qv4dateobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4engine.cpp63
-rw-r--r--src/qml/jsruntime/qv4engine_p.h34
-rw-r--r--src/qml/jsruntime/qv4errorobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4function.cpp4
-rw-r--r--src/qml/jsruntime/qv4function_p.h18
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp262
-rw-r--r--src/qml/jsruntime/qv4functionobject_p.h38
-rw-r--r--src/qml/jsruntime/qv4global_p.h6
-rw-r--r--src/qml/jsruntime/qv4globalobject.cpp5
-rw-r--r--src/qml/jsruntime/qv4include.cpp1
-rw-r--r--src/qml/jsruntime/qv4jsonobject.cpp14
-rw-r--r--src/qml/jsruntime/qv4lookup.cpp178
-rw-r--r--src/qml/jsruntime/qv4managed_p.h27
-rw-r--r--src/qml/jsruntime/qv4memberdata.cpp30
-rw-r--r--src/qml/jsruntime/qv4memberdata_p.h3
-rw-r--r--src/qml/jsruntime/qv4numberobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4object.cpp11
-rw-r--r--src/qml/jsruntime/qv4object_p.h8
-rw-r--r--src/qml/jsruntime/qv4objectiterator.cpp19
-rw-r--r--src/qml/jsruntime/qv4objectproto.cpp16
-rw-r--r--src/qml/jsruntime/qv4profiling_p.h2
-rw-r--r--src/qml/jsruntime/qv4property_p.h4
-rw-r--r--src/qml/jsruntime/qv4qmlcontext.cpp (renamed from src/qml/qml/qqmlcontextwrapper.cpp)71
-rw-r--r--src/qml/jsruntime/qv4qmlcontext_p.h (renamed from src/qml/qml/qqmlcontextwrapper_p.h)37
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp9
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper_p.h17
-rw-r--r--src/qml/jsruntime/qv4regexpobject.cpp12
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp221
-rw-r--r--src/qml/jsruntime/qv4runtime_p.h3
-rw-r--r--src/qml/jsruntime/qv4runtimeapi_p.h6
-rw-r--r--src/qml/jsruntime/qv4scopedvalue_p.h48
-rw-r--r--src/qml/jsruntime/qv4script.cpp76
-rw-r--r--src/qml/jsruntime/qv4script_p.h3
-rw-r--r--src/qml/jsruntime/qv4string.cpp1
-rw-r--r--src/qml/jsruntime/qv4string_p.h2
-rw-r--r--src/qml/jsruntime/qv4stringobject.cpp12
-rw-r--r--src/qml/jsruntime/qv4value.cpp52
-rw-r--r--src/qml/jsruntime/qv4value_p.h83
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp10
-rw-r--r--src/qml/memory/qv4mm.cpp16
-rw-r--r--src/qml/parser/qqmljs.g160
-rw-r--r--src/qml/parser/qqmljsast_p.h16
-rw-r--r--src/qml/parser/qqmljsgrammar.cpp1045
-rw-r--r--src/qml/parser/qqmljsgrammar_p.h12
-rw-r--r--src/qml/parser/qqmljsmemorypool_p.h5
-rw-r--r--src/qml/parser/qqmljsparser.cpp455
-rw-r--r--src/qml/parser/qqmljsparser_p.h4
-rw-r--r--src/qml/qml/qml.pri3
-rw-r--r--src/qml/qml/qqml.h1
-rw-r--r--src/qml/qml/qqmlapplicationengine.cpp6
-rw-r--r--src/qml/qml/qqmlapplicationengine_p.h2
-rw-r--r--src/qml/qml/qqmlbinding.cpp73
-rw-r--r--src/qml/qml/qqmlbinding_p.h10
-rw-r--r--src/qml/qml/qqmlboundsignal.cpp68
-rw-r--r--src/qml/qml/qqmlboundsignal_p.h6
-rw-r--r--src/qml/qml/qqmlcontext_p.h2
-rw-r--r--src/qml/qml/qqmldelayedcallqueue.cpp1
-rw-r--r--src/qml/qml/qqmlengine.cpp2
-rw-r--r--src/qml/qml/qqmlerror.cpp2
-rw-r--r--src/qml/qml/qqmlexpression.cpp4
-rw-r--r--src/qml/qml/qqmlglobal.cpp2
-rw-r--r--src/qml/qml/qqmlglobal_p.h2
-rw-r--r--src/qml/qml/qqmlimport.cpp14
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp59
-rw-r--r--src/qml/qml/qqmljavascriptexpression_p.h13
-rw-r--r--src/qml/qml/qqmllocale.cpp64
-rw-r--r--src/qml/qml/qqmlloggingcategory.cpp4
-rw-r--r--src/qml/qml/qqmlmetatype.cpp38
-rw-r--r--src/qml/qml/qqmlmetatype_p.h1
-rw-r--r--src/qml/qml/qqmlnotifier.cpp6
-rw-r--r--src/qml/qml/qqmlnotifier_p.h2
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp25
-rw-r--r--src/qml/qml/qqmlopenmetaobject_p.h2
-rw-r--r--src/qml/qml/qqmlproperty_p.h16
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp24
-rw-r--r--src/qml/qml/qqmlpropertycache_p.h2
-rw-r--r--src/qml/qml/qqmlstringconverters.cpp12
-rw-r--r--src/qml/qml/qqmlstringconverters_p.h2
-rw-r--r--src/qml/qml/qqmltypeloader.cpp3
-rw-r--r--src/qml/qml/qqmltypeloader_p.h4
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp1
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp7
-rw-r--r--src/qml/qml/qqmlvme.cpp1
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp6
-rw-r--r--src/qml/qml/qqmlvmemetaobject_p.h2
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp11
-rw-r--r--src/qml/qml/qqmlxmlhttprequest_p.h4
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp37
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions_p.h20
-rw-r--r--src/qml/qml/v8/qv8engine.cpp5
-rw-r--r--src/qml/types/qqmlconnections.cpp4
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp23
-rw-r--r--src/qml/types/qqmldelegatemodel_p_p.h5
-rw-r--r--src/qml/types/qqmllistmodel.cpp48
-rw-r--r--src/qml/types/qqmllistmodel_p_p.h2
-rw-r--r--src/qml/types/qquickworkerscript.cpp16
-rw-r--r--src/qml/util/qqmladaptormodel_p.h2
-rw-r--r--src/qmldebug/qqmlenginecontrolclient_p.h2
-rw-r--r--src/qmldebug/qqmlprofilerclient_p.h2
-rw-r--r--src/qmltest/qmltest.pro2
-rw-r--r--src/qmltest/quicktest.cpp2
-rw-r--r--src/qmltest/quicktestevent.cpp98
-rw-r--r--src/qmltest/quicktestevent_p.h26
-rw-r--r--src/quick/accessible/qaccessiblequickitem.cpp4
-rw-r--r--src/quick/accessible/qaccessiblequickitem_p.h4
-rw-r--r--src/quick/accessible/qaccessiblequickview.cpp4
-rw-r--r--src/quick/accessible/qaccessiblequickview_p.h4
-rw-r--r--src/quick/accessible/qquickaccessiblefactory.cpp2
-rw-r--r--src/quick/accessible/qquickaccessiblefactory_p.h2
-rw-r--r--src/quick/designer/qquickdesignercustomobjectdata.cpp2
-rw-r--r--src/quick/designer/qquickdesignersupport.cpp2
-rw-r--r--src/quick/designer/qquickdesignerwindowmanager.cpp4
-rw-r--r--src/quick/designer/qquickdesignerwindowmanager_p.h4
-rw-r--r--src/quick/doc/src/concepts/visualcanvas/adaptations.qdoc80
-rw-r--r--src/quick/items/context2d/qquickcanvasitem.cpp2
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp14
-rw-r--r--src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp2
-rw-r--r--src/quick/items/context2d/qquickcontext2dtexture.cpp10
-rw-r--r--src/quick/items/context2d/qquickcontext2dtexture_p.h8
-rw-r--r--src/quick/items/context2d/qquickcontext2dtile.cpp4
-rw-r--r--src/quick/items/context2d/qquickcontext2dtile_p.h4
-rw-r--r--src/quick/items/qquickaccessibleattached.cpp2
-rw-r--r--src/quick/items/qquickaccessibleattached_p.h4
-rw-r--r--src/quick/items/qquickanchors.cpp127
-rw-r--r--src/quick/items/qquickanchors_p_p.h19
-rw-r--r--src/quick/items/qquickdrag.cpp4
-rw-r--r--src/quick/items/qquickdrag_p.h6
-rw-r--r--src/quick/items/qquickdroparea.cpp4
-rw-r--r--src/quick/items/qquickdroparea_p.h4
-rw-r--r--src/quick/items/qquickevents.cpp2
-rw-r--r--src/quick/items/qquickevents_p_p.h9
-rw-r--r--src/quick/items/qquickflickable.cpp2
-rw-r--r--src/quick/items/qquickflickable_p.h2
-rw-r--r--src/quick/items/qquickgraphicsinfo.cpp2
-rw-r--r--src/quick/items/qquickitem.cpp302
-rw-r--r--src/quick/items/qquickitem.h14
-rw-r--r--src/quick/items/qquickitem_p.h14
-rw-r--r--src/quick/items/qquickitemchangelistener_p.h4
-rw-r--r--src/quick/items/qquickitemsmodule.cpp10
-rw-r--r--src/quick/items/qquickitemview.cpp4
-rw-r--r--src/quick/items/qquicklistview.cpp20
-rw-r--r--src/quick/items/qquickloader.cpp6
-rw-r--r--src/quick/items/qquickloader_p_p.h2
-rw-r--r--src/quick/items/qquickmousearea.cpp77
-rw-r--r--src/quick/items/qquickmousearea_p.h18
-rw-r--r--src/quick/items/qquickmousearea_p_p.h5
-rw-r--r--src/quick/items/qquickopenglshadereffectnode.cpp4
-rw-r--r--src/quick/items/qquickpainteditem.cpp2
-rw-r--r--src/quick/items/qquickpincharea.cpp4
-rw-r--r--src/quick/items/qquickrendercontrol.cpp8
-rw-r--r--src/quick/items/qquickshadereffect.cpp48
-rw-r--r--src/quick/items/qquickshadereffect_p.h2
-rw-r--r--src/quick/items/qquickspriteengine.cpp11
-rw-r--r--src/quick/items/qquickspriteengine_p.h2
-rw-r--r--src/quick/items/qquicktext.cpp6
-rw-r--r--src/quick/items/qquicktextcontrol.cpp96
-rw-r--r--src/quick/items/qquicktextcontrol_p.h9
-rw-r--r--src/quick/items/qquicktextcontrol_p_p.h8
-rw-r--r--src/quick/items/qquicktextdocument.cpp2
-rw-r--r--src/quick/items/qquicktextedit.cpp75
-rw-r--r--src/quick/items/qquicktextedit_p.h6
-rw-r--r--src/quick/items/qquicktextedit_p_p.h6
-rw-r--r--src/quick/items/qquicktextinput.cpp160
-rw-r--r--src/quick/items/qquicktextinput_p.h8
-rw-r--r--src/quick/items/qquicktextinput_p_p.h28
-rw-r--r--src/quick/items/qquicktextnode.cpp20
-rw-r--r--src/quick/items/qquicktextnodeengine.cpp13
-rw-r--r--src/quick/items/qquicktextnodeengine_p.h12
-rw-r--r--src/quick/items/qquickview.cpp4
-rw-r--r--src/quick/items/qquickwindow.cpp89
-rw-r--r--src/quick/items/qquickwindow.h8
-rw-r--r--src/quick/items/qquickwindow_p.h29
-rw-r--r--src/quick/qtquick2.cpp5
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp2
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp12
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp24
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp63
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h70
-rw-r--r--src/quick/scenegraph/coreapi/qsggeometry.cpp4
-rw-r--r--src/quick/scenegraph/coreapi/qsggeometry.h10
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterial.cpp14
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterial.h12
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterialshader_p.h2
-rw-r--r--src/quick/scenegraph/coreapi/qsgrenderer.cpp24
-rw-r--r--src/quick/scenegraph/coreapi/qsgrenderer_p.h2
-rw-r--r--src/quick/scenegraph/coreapi/qsgrendererinterface.cpp9
-rw-r--r--src/quick/scenegraph/coreapi/qsgrendererinterface.h11
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer.cpp6
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer_p.h10
-rw-r--r--src/quick/scenegraph/qsgbasicglyphnode_p.h14
-rw-r--r--src/quick/scenegraph/qsgcontextplugin.cpp12
-rw-r--r--src/quick/scenegraph/qsgcontextplugin_p.h6
-rw-r--r--src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h18
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p_p.h16
-rw-r--r--src/quick/scenegraph/qsgdefaultrendercontext.cpp4
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p.h18
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h34
-rw-r--r--src/quick/scenegraph/qsgrenderloop.cpp24
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop.cpp24
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop_p.h30
-rw-r--r--src/quick/scenegraph/qsgwindowsrenderloop.cpp21
-rw-r--r--src/quick/scenegraph/qsgwindowsrenderloop_p.h26
-rw-r--r--src/quick/scenegraph/util/qsgatlastexture.cpp20
-rw-r--r--src/quick/scenegraph/util/qsgdefaultimagenode.cpp29
-rw-r--r--src/quick/scenegraph/util/qsgdefaultimagenode_p.h6
-rw-r--r--src/quick/scenegraph/util/qsgdefaultninepatchnode.cpp52
-rw-r--r--src/quick/scenegraph/util/qsgdefaultninepatchnode_p.h3
-rw-r--r--src/quick/scenegraph/util/qsgdistancefieldutil.cpp26
-rw-r--r--src/quick/scenegraph/util/qsgdistancefieldutil_p.h4
-rw-r--r--src/quick/scenegraph/util/qsgengine.cpp6
-rw-r--r--src/quick/scenegraph/util/qsgflatcolormaterial.cpp10
-rw-r--r--src/quick/scenegraph/util/qsgimagenode.cpp29
-rw-r--r--src/quick/scenegraph/util/qsgimagenode.h6
-rw-r--r--src/quick/scenegraph/util/qsgninepatchnode.cpp52
-rw-r--r--src/quick/scenegraph/util/qsgninepatchnode.h4
-rw-r--r--src/quick/scenegraph/util/qsgshadersourcebuilder.cpp4
-rw-r--r--src/quick/scenegraph/util/qsgsimplematerial.h10
-rw-r--r--src/quick/scenegraph/util/qsgtexture.cpp36
-rw-r--r--src/quick/scenegraph/util/qsgtexture_p.h2
-rw-r--r--src/quick/scenegraph/util/qsgtexturematerial.cpp18
-rw-r--r--src/quick/scenegraph/util/qsgvertexcolormaterial.cpp10
-rw-r--r--src/quick/util/qquickanimatorjob_p.h2
-rw-r--r--src/quick/util/qquickglobal.cpp2
-rw-r--r--src/quick/util/qquickprofiler_p.h141
-rw-r--r--src/quick/util/qquickpropertychanges.cpp12
-rw-r--r--src/quick/util/qquickshortcut.cpp2
-rw-r--r--src/quick/util/qquickstate_p_p.h2
-rw-r--r--src/quick/util/qquickutilmodule.cpp4
-rw-r--r--src/quick/util/qquickvalidator.cpp4
-rw-r--r--src/quick/util/qquickvalidator_p.h4
-rw-r--r--src/quickwidgets/qquickwidget.cpp51
-rw-r--r--src/quickwidgets/qquickwidget.h4
-rw-r--r--src/quickwidgets/qquickwidget_p.h6
-rw-r--r--sync.profile11
-rw-r--r--tests/auto/auto.pro1
-rw-r--r--tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/data/test.qml1
-rw-r--r--tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp96
-rw-r--r--tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp23
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro1
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp68
-rw-r--r--tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp11
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp2
-rw-r--r--tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp26
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp8
-rw-r--r--tests/auto/qml/qjsvalue/tst_qjsvalue.cpp27
-rw-r--r--tests/auto/qml/qjsvalue/tst_qjsvalue.h2
-rw-r--r--tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp27
-rw-r--r--tests/auto/qml/qmlmin/tst_qmlmin.cpp1
-rw-r--r--tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp6
-rw-r--r--tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp2
-rw-r--r--tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml9
-rw-r--r--tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp27
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp4
-rw-r--r--tests/auto/qml/qqmllanguage/data/QtObjectWithChildren.qml5
-rw-r--r--tests/auto/qml/qqmllanguage/data/defaultListProperty.qml6
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml2
-rw-r--r--tests/auto/qml/qqmllanguage/data/namespacedPropertyTypes.qml8
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.cpp7
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp19
-rw-r--r--tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml27
-rw-r--r--tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp13
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/works22.qml3
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.2.2.pro12
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.cpp72
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin.2.2/qmldir1
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro3
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp76
-rw-r--r--tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp26
-rw-r--r--tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp38
-rw-r--r--tests/auto/qmltest-blacklist/animators/tst_stopped.qml2
-rw-r--r--tests/auto/qmltest/events/tst_touch.qml182
-rw-r--r--tests/auto/qmltest/selftests/tst_createTemporaryObject.qml113
-rw-r--r--tests/auto/quick/examples/tst_examples.cpp2
-rw-r--r--tests/auto/quick/nokeywords/tst_nokeywords.cpp2
-rw-r--r--tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp4
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp2
-rw-r--r--tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp4
-rw-r--r--tests/auto/quick/qquickitem/data/shortcutOverride.qml65
-rw-r--r--tests/auto/quick/qquickitem/tst_qquickitem.cpp35
-rw-r--r--tests/auto/quick/qquickitem2/tst_qquickitem.cpp16
-rw-r--r--tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp6
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp218
-rw-r--r--tests/auto/quick/qquickmousearea/data/pressAndHold.qml12
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp51
-rw-r--r--tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp4
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp13
-rw-r--r--tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp10
-rw-r--r--tests/auto/quick/qquicktextedit/data/cursorHeight.qml20
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp53
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp14
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp22
-rw-r--r--tests/auto/quick/scenegraph/tst_scenegraph.cpp14
-rw-r--r--tests/auto/quick/shared/viewtestutil.cpp2
-rw-r--r--tests/auto/quicktest/quicktest.pro3
-rw-r--r--tests/auto/quicktest/signalspy/data/signalspy.qml60
-rw-r--r--tests/auto/quicktest/signalspy/mypropertymap.cpp38
-rw-r--r--tests/auto/quicktest/signalspy/mypropertymap.h41
-rw-r--r--tests/auto/quicktest/signalspy/signalspy.pro9
-rw-r--r--tests/auto/quicktest/signalspy/tst_signalspy.cpp95
-rw-r--r--tests/auto/shared/platformquirks.h2
-rw-r--r--tests/benchmarks/qml/compilation/tst_compilation.cpp2
-rw-r--r--tests/benchmarks/qml/creation/tst_creation.cpp8
-rw-r--r--tests/benchmarks/qml/qml.pro2
-rw-r--r--tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_ltr.qml14
-rw-r--r--tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_rtl.qml14
-rw-r--r--tests/tests.pro3
-rw-r--r--tools/qml/main.cpp11
-rw-r--r--tools/qmleasing/main.cpp1
-rw-r--r--tools/qmleasing/mainwindow.h6
-rw-r--r--tools/qmleasing/splineeditor.cpp4
-rw-r--r--tools/qmleasing/splineeditor.h14
-rw-r--r--tools/qmlimportscanner/main.cpp12
-rw-r--r--tools/qmljs/qmljs.cpp58
-rw-r--r--tools/qmlmin/main.cpp1
-rw-r--r--tools/qmlplugindump/main.cpp12
-rw-r--r--tools/qmlprofiler/qmlprofilerclient.h26
-rw-r--r--tools/qmlscene/main.cpp17
-rw-r--r--tools/qmltime/qmltime.cpp1
492 files changed, 14408 insertions, 4873 deletions
diff --git a/dist/changes-5.7.1 b/dist/changes-5.7.1
new file mode 100644
index 0000000000..b9bdaedca3
--- /dev/null
+++ b/dist/changes-5.7.1
@@ -0,0 +1,64 @@
+Qt 5.7.1 is a bug-fix release. It maintains both forward and backward
+compatibility (source and binary) with Qt 5.7.0.
+
+For more details, refer to the online documentation included in this
+distribution. The documentation is also available online:
+
+http://doc.qt.io/qt-5/index.html
+
+The Qt version 5.7 series is binary compatible with the 5.6.x series.
+Applications compiled for 5.6 will continue to run with 5.7.
+
+Some of the changes listed in this file include issue tracking numbers
+corresponding to tasks in the Qt Bug Tracker:
+
+https://bugreports.qt.io/
+
+Each of these identifiers can be entered in the bug tracker to obtain more
+information about a particular change.
+
+****************************************************************************
+* Important Behavior Changes *
+****************************************************************************
+
+ - [QTBUG-55935] AnimatedSprite will no longer cause scenegraph updates when not
+ visible
+ - [QTBUG-46263] Fix QObjects becoming undefined when used in multiple QML
+ engines
+ - [QTBUG-54238] qt.scenegraph.info logging category got renamed to
+ qt.scenegraph.general.
+ - [QTBUG-50592] QVariants (e.g. QUrl) will now be better handled by
+ JSON.stringify
+ - [QTBUG-37095] Canvas now properly supports high-DPI screens
+ - QQuickWidget now properly repaints text on high-DPI screen changes.
+
+****************************************************************************
+* Library *
+****************************************************************************
+
+QtQml
+-----
+
+ - [QTBUG-53412] Fix mapping of null JS values to null SQL values instead
+ of empty strings.
+ - [QTBUG-53794] Fix crash when using the "with" statement with an
+ expression that throws an exception.
+ - [QTBUG-54589] Fix assertion when deleting properties of JS objects
+ - [QTBUG-56658] Fix a crash in the QML compiler
+ - [QTBUG-53672] Fix crash caused by passing 0 to Array.join
+
+QtQuick
+-------
+
+ - The relevant child item is now sent a hover event when the window
+ receives a QEnterEvent, making sure hovering is recognized without
+ waiting for mouse movement.
+ - The threaded scene graph renderer does not sleep up to one vsync
+ interval before the first frame anymore.
+ - [QTBUG-56056] Fix crash when cancelling a QQuickImageResponse
+ - [QTBUG-39888] Fix crash with QQuickItems created via JavaScript being
+ garbage collected sometimes when they're not assigned to a window.
+ - [QTBUG-31861] Item: Fixed issue with mouse button events being sent even
+ when they were disabled by setAcceptedMouseButtons.
+ - [QTBUG-52389] Text: Fixed clipping of glyphs that extend beyond font's em
+ square.
diff --git a/examples/qml/networkaccessmanagerfactory/main.cpp b/examples/qml/networkaccessmanagerfactory/main.cpp
index 55e00d6917..5b6b7681a9 100644
--- a/examples/qml/networkaccessmanagerfactory/main.cpp
+++ b/examples/qml/networkaccessmanagerfactory/main.cpp
@@ -56,10 +56,10 @@
networkaccessmanagerfactory [-host <proxy> -port <port>] [file]
*/
-#ifndef QT_NO_NETWORKPROXY
+#if QT_CONFIG(networkproxy)
static QString proxyHost;
static int proxyPort = 0;
-#endif // !QT_NO_NETWORKPROXY
+#endif // networkproxy
class MyNetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory
{
@@ -70,13 +70,13 @@ public:
QNetworkAccessManager *MyNetworkAccessManagerFactory::create(QObject *parent)
{
QNetworkAccessManager *nam = new QNetworkAccessManager(parent);
-#ifndef QT_NO_NETWORKPROXY
+#if QT_CONFIG(networkproxy)
if (!proxyHost.isEmpty()) {
qDebug() << "Created QNetworkAccessManager using proxy" << (proxyHost + ":" + QString::number(proxyPort));
QNetworkProxy proxy(QNetworkProxy::HttpCachingProxy, proxyHost, proxyPort);
nam->setProxy(proxy);
}
-#endif // !QT_NO_NETWORKPROXY
+#endif // networkproxy
return nam;
}
@@ -88,12 +88,12 @@ int main(int argc, char ** argv)
QGuiApplication app(argc, argv);
QCommandLineParser parser;
-#ifndef QT_NO_NETWORKPROXY
+#if QT_CONFIG(networkproxy)
QCommandLineOption proxyHostOption("host", "The proxy host to use.", "host");
parser.addOption(proxyHostOption);
QCommandLineOption proxyPortOption("port", "The proxy port to use.", "port", "0");
parser.addOption(proxyPortOption);
-#endif // !QT_NO_NETWORKPROXY
+#endif // networkproxy
parser.addPositionalArgument("file", "The file to use.");
QCommandLineOption helpOption = parser.addHelpOption();
parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
@@ -106,7 +106,7 @@ int main(int argc, char ** argv)
qWarning() << parser.helpText();
exit(0);
}
-#ifndef QT_NO_NETWORKPROXY
+#if QT_CONFIG(networkproxy)
if (parser.isSet(proxyHostOption))
proxyHost = parser.value(proxyHostOption);
if (parser.isSet(proxyPortOption)) {
@@ -118,7 +118,7 @@ int main(int argc, char ** argv)
exit(1);
}
}
-#endif // !QT_NO_NETWORKPROXY
+#endif // networkproxy
if (parser.positionalArguments().count() == 1)
source = QUrl::fromLocalFile(parser.positionalArguments().first());
diff --git a/examples/quick/localstorage/localstorage/hello.qml b/examples/quick/demos/stocqt/content/Banner.qml
index d4f82ba2fe..8d64e88410 100644
--- a/examples/quick/localstorage/localstorage/hello.qml
+++ b/examples/quick/demos/stocqt/content/Banner.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2016 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -37,42 +37,50 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-//![0]
+
import QtQuick 2.0
-import QtQuick.LocalStorage 2.0
+import QtQuick.Layouts 1.1
Rectangle {
- width: 200
- height: 100
-
- Text {
- text: "?"
- anchors.horizontalCenter: parent.horizontalCenter
-
- function findGreetings() {
- var db = LocalStorage.openDatabaseSync("QQmlExampleDB", "1.0", "The Example QML SQL!", 1000000);
-
- db.transaction(
- function(tx) {
- // Create the database if it doesn't already exist
- tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)');
+ id: banner
+ height: 80
+ color: "#000000"
- // Add (another) greeting row
- tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
+ GridLayout {
+ anchors.fill: parent
+ rows: 1
+ columns: 3
+ Rectangle {
+ Layout.leftMargin: 10
+ Layout.topMargin: 20
+ Layout.alignment: Qt.AlignLeft | Qt.AlignTop
+ Image {
+ id: arrow
+ source: "./images/icon-left-arrow.png"
+ visible: root.currentIndex == 1 ? true : false
- // Show all added greetings
- var rs = tx.executeSql('SELECT * FROM Greeting');
-
- var r = ""
- for(var i = 0; i < rs.rows.length; i++) {
- r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n"
- }
- text = r
+ MouseArea {
+ anchors.fill: parent
+ onClicked: root.currentIndex = 0;
}
- )
+ }
+ }
+ Text {
+ id: stocText
+ color: "#ffffff"
+ font.family: "Abel"
+ font.pointSize: 40
+ text: "Stoc"
+ Layout.alignment: Qt.AlignRight
+ Layout.leftMargin: parent.width / 2.5
+ }
+ Text {
+ id: qtText
+ color: "#5caa15"
+ font.family: "Abel"
+ font.pointSize: 40
+ text: "Qt"
+ Layout.fillWidth: true
}
-
- Component.onCompleted: findGreetings()
}
}
-//![0]
diff --git a/examples/quick/demos/stocqt/content/CheckBox.qml b/examples/quick/demos/stocqt/content/CheckBox.qml
index 5702b17709..f62eb538fb 100644
--- a/examples/quick/demos/stocqt/content/CheckBox.qml
+++ b/examples/quick/demos/stocqt/content/CheckBox.qml
@@ -60,7 +60,6 @@ Item {
id: checkbox
width: 30
height: 30
- anchors.left: parent.left
border.color: "#999999"
border.width: 1
antialiasing: true
diff --git a/examples/quick/demos/stocqt/content/StockChart.qml b/examples/quick/demos/stocqt/content/StockChart.qml
index cd8b9f3db9..e90aba3aef 100644
--- a/examples/quick/demos/stocqt/content/StockChart.qml
+++ b/examples/quick/demos/stocqt/content/StockChart.qml
@@ -39,20 +39,19 @@
****************************************************************************/
import QtQuick 2.0
+import QtQuick.Layouts 1.1
import "."
Rectangle {
id: chart
- width: 320
- height: 200
property var stockModel: null
property var startDate: new Date()
property var endDate: new Date()
- property string activeChart: "year"
+ property string activeChart: "week"
property var settings
property int gridSize: 4
- property real gridStep: gridSize ? (width - canvas.tickMargin) / gridSize : canvas.xGridStep
+ property real gridStep: gridSize ? (canvas.width - canvas.tickMargin) / gridSize : canvas.xGridStep
function update() {
endDate = new Date();
@@ -66,7 +65,7 @@ Rectangle {
chart.startDate = new Date(chart.endDate.getFullYear(),
chart.endDate.getMonth() - 1,
chart.endDate.getDate());
- gridSize = 0;
+ gridSize = 4;
}
else if (chart.activeChart === "week") {
chart.startDate = new Date(chart.endDate.getFullYear(),
@@ -74,6 +73,18 @@ Rectangle {
chart.endDate.getDate() - 7);
gridSize = 0;
}
+ else if (chart.activeChart === "halfyear") {
+ chart.startDate = new Date(chart.endDate.getFullYear(),
+ chart.endDate.getMonth() - 6,
+ chart.endDate.getDate());
+ gridSize = 6;
+ }
+ else if (chart.activeChart === "quarter") {
+ chart.startDate = new Date(chart.endDate.getFullYear(),
+ chart.endDate.getMonth() - 3,
+ chart.endDate.getDate());
+ gridSize = 3;
+ }
else {
chart.startDate = new Date(2005, 3, 25);
gridSize = 4;
@@ -82,315 +93,327 @@ Rectangle {
canvas.requestPaint();
}
- Row {
- id: activeChartRow
- anchors.left: chart.left
- anchors.right: chart.right
- anchors.top: chart.top
- anchors.topMargin: 4
- spacing: 52
- onWidthChanged: {
- var buttonsLen = maxButton.width + yearButton.width + monthButton.width + weekButton.width;
- var space = (width - buttonsLen) / 3;
- spacing = Math.max(space, 10);
+ GridLayout {
+ anchors.fill: parent
+ columns: 6
+ rows: 3
+ columnSpacing: 4
+ Button {
+ id: weekButton
+ text: "Week"
+ buttonEnabled: chart.activeChart === "week"
+ onClicked: {
+ chart.activeChart = "week";
+ chart.update();
+ }
}
Button {
- id: maxButton
- text: "Max"
- buttonEnabled: chart.activeChart === "max"
+ id: monthButton
+ text: "Month"
+ buttonEnabled: chart.activeChart === "month"
onClicked: {
- chart.activeChart = "max";
+ chart.activeChart = "month";
chart.update();
}
}
+
Button {
- id: yearButton
- text: "Year"
- buttonEnabled: chart.activeChart === "year"
+ id: quarterlyButton
+ text: "3M"
+ buttonEnabled: chart.activeChart === "quarter"
onClicked: {
- chart.activeChart = "year";
+ chart.activeChart = "quarter";
chart.update();
}
}
+
Button {
- id: monthButton
- text: "Month"
- buttonEnabled: chart.activeChart === "month"
+ id: halfYearlyButton
+ text: "6M"
+ buttonEnabled: chart.activeChart === "halfyear"
onClicked: {
- chart.activeChart = "month";
+ chart.activeChart = "halfyear";
chart.update();
}
}
Button {
- id: weekButton
- text: "Week"
- buttonEnabled: chart.activeChart === "week"
+ id: yearButton
+ text: "Year"
+ buttonEnabled: chart.activeChart === "year"
onClicked: {
- chart.activeChart = "week";
+ chart.activeChart = "year";
+ chart.update();
+ }
+ }
+ Button {
+ id: maxButton
+ text: "Max"
+ buttonEnabled: chart.activeChart === "max"
+ onClicked: {
+ chart.activeChart = "max";
chart.update();
}
}
- }
- Text {
- id: fromDate
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 8
- anchors.left: parent.left
- anchors.bottom: parent.bottom
- text: "| " + startDate.toDateString()
- }
+ Canvas {
+ id: canvas
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.columnSpan: 6
+ // Uncomment below lines to use OpenGL hardware accelerated rendering.
+ // See Canvas documentation for available options.
+ // renderTarget: Canvas.FramebufferObject
+ // renderStrategy: Canvas.Threaded
+
+ property int pixelSkip: 1
+ property int numPoints: 1
+ property int tickMargin: 34
+
+ property real xGridStep: (canvas.width - tickMargin) / numPoints
+ property real yGridOffset: canvas.height / 26
+ property real yGridStep: canvas.height / 12
+
+ function drawBackground(ctx) {
+ ctx.save();
+ ctx.fillStyle = "#ffffff";
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+ ctx.strokeStyle = "#d7d7d7";
+ ctx.beginPath();
+ // Horizontal grid lines
+ for (var i = 0; i < 12; i++) {
+ ctx.moveTo(0, canvas.yGridOffset + i * canvas.yGridStep);
+ ctx.lineTo(canvas.width, canvas.yGridOffset + i * canvas.yGridStep);
+ }
- Text {
- id: toDate
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 8
- anchors.right: parent.right
- anchors.rightMargin: canvas.tickMargin
- anchors.bottom: parent.bottom
- text: endDate.toDateString() + " |"
- }
+ // Vertical grid lines
+ var height = 35 * canvas.height / 36;
+ var yOffset = canvas.height - height;
+ var xOffset = 0;
+ for (i = 0; i < chart.gridSize; i++) {
+ ctx.moveTo(xOffset + i * chart.gridStep, yOffset);
+ ctx.lineTo(xOffset + i * chart.gridStep, height);
+ }
+ ctx.stroke();
+
+ // Right ticks
+ ctx.strokeStyle = "#666666";
+ ctx.beginPath();
+ var xStart = canvas.width - tickMargin;
+ ctx.moveTo(xStart, 0);
+ ctx.lineTo(xStart, canvas.height);
+ for (i = 0; i < 12; i++) {
+ ctx.moveTo(xStart, canvas.yGridOffset + i * canvas.yGridStep);
+ ctx.lineTo(canvas.width, canvas.yGridOffset + i * canvas.yGridStep);
+ }
+ ctx.moveTo(0, canvas.yGridOffset + 9 * canvas.yGridStep);
+ ctx.lineTo(canvas.width, canvas.yGridOffset + 9 * canvas.yGridStep);
+ ctx.closePath();
+ ctx.stroke();
- Canvas {
- id: canvas
-
- // Uncomment below lines to use OpenGL hardware accelerated rendering.
- // See Canvas documentation for available options.
- // renderTarget: Canvas.FramebufferObject
- // renderStrategy: Canvas.Threaded
-
- anchors.top: activeChartRow.bottom
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.bottom: fromDate.top
-
- property int pixelSkip: 1
- property int numPoints: 1
- property int tickMargin: 34
-
- property real xGridStep: (width - tickMargin) / numPoints
- property real yGridOffset: height / 26
- property real yGridStep: height / 12
-
- function drawBackground(ctx) {
- ctx.save();
- ctx.fillStyle = "#ffffff";
- ctx.fillRect(0, 0, canvas.width, canvas.height);
- ctx.strokeStyle = "#d7d7d7";
- ctx.beginPath();
- // Horizontal grid lines
- for (var i = 0; i < 12; i++) {
- ctx.moveTo(0, canvas.yGridOffset + i * canvas.yGridStep);
- ctx.lineTo(canvas.width, canvas.yGridOffset + i * canvas.yGridStep);
+ ctx.restore();
}
- // Vertical grid lines
- var height = 35 * canvas.height / 36;
- var yOffset = canvas.height - height;
- var xOffset = 0;
- for (i = 0; i < chart.gridSize; i++) {
- ctx.moveTo(xOffset + i * chart.gridStep, yOffset);
- ctx.lineTo(xOffset + i * chart.gridStep, height);
- }
- ctx.stroke();
-
- // Right ticks
- ctx.strokeStyle = "#666666";
- ctx.beginPath();
- var xStart = canvas.width - tickMargin;
- ctx.moveTo(xStart, 0);
- ctx.lineTo(xStart, canvas.height);
- for (i = 0; i < 12; i++) {
- ctx.moveTo(xStart, canvas.yGridOffset + i * canvas.yGridStep);
- ctx.lineTo(canvas.width, canvas.yGridOffset + i * canvas.yGridStep);
+ // Returns a shortened, readable version of the potentially
+ // large volume number.
+ function volumeToString(value) {
+ if (value < 1000)
+ return value;
+ var exponent = parseInt(Math.log(value) / Math.log(1000));
+ var shortVal = parseFloat(parseFloat(value) / Math.pow(1000, exponent)).toFixed(1);
+
+ // Drop the decimal point on 3-digit values to make it fit
+ if (shortVal >= 100.0) {
+ shortVal = parseFloat(shortVal).toFixed(0);
+ }
+ return shortVal + "KMBTG".charAt(exponent - 1);
}
- ctx.moveTo(0, canvas.yGridOffset + 9 * canvas.yGridStep);
- ctx.lineTo(canvas.width, canvas.yGridOffset + 9 * canvas.yGridStep);
- ctx.closePath();
- ctx.stroke();
- ctx.restore();
- }
+ function drawScales(ctx, high, low, vol)
+ {
+ ctx.save();
+ ctx.strokeStyle = "#888888";
+ ctx.font = "10px Open Sans"
- // Returns a shortened, readable version of the potentially
- // large volume number.
- function volumeToString(value) {
- if (value < 1000)
- return value;
- var exponent = parseInt(Math.log(value) / Math.log(1000));
- var shortVal = parseFloat(parseFloat(value) / Math.pow(1000, exponent)).toFixed(1);
-
- // Drop the decimal point on 3-digit values to make it fit
- if (shortVal >= 100.0) {
- shortVal = parseFloat(shortVal).toFixed(0);
- }
- return shortVal + "KMBTG".charAt(exponent - 1);
- }
+ ctx.beginPath();
- function drawScales(ctx, high, low, vol)
- {
- ctx.save();
- ctx.strokeStyle = "#888888";
- ctx.font = "10px Open Sans"
- ctx.beginPath();
-
- // prices on y-axis
- var x = canvas.width - tickMargin + 3;
- var priceStep = (high - low) / 9.0;
- for (var i = 0; i < 10; i += 2) {
- var price = parseFloat(high - i * priceStep).toFixed(1);
- ctx.text(price, x, canvas.yGridOffset + i * yGridStep - 2);
- }
+ // prices on y-axis
+ var x = canvas.width - tickMargin + 3;
+ var priceStep = (high - low) / 9.0;
+ for (var i = 0; i < 10; i += 2) {
+ var price = parseFloat(high - i * priceStep).toFixed(1);
+ ctx.text(price, x, canvas.yGridOffset + i * yGridStep - 2);
+ }
+
+ // volume scale
+ for (i = 0; i < 3; i++) {
+ var volume = volumeToString(vol - (i * (vol/3)));
+ ctx.text(volume, x, canvas.yGridOffset + (i + 9) * yGridStep + 10);
+ }
- // volume scale
- for (i = 0; i < 3; i++) {
- var volume = volumeToString(vol - (i * (vol/3)));
- ctx.text(volume, x, canvas.yGridOffset + (i + 9) * yGridStep + 10);
+ ctx.closePath();
+ ctx.stroke();
+ ctx.restore();
}
- ctx.closePath();
- ctx.stroke();
- ctx.restore();
- }
+ function drawPrice(ctx, from, to, color, price, points, highest, lowest)
+ {
+ ctx.save();
+ ctx.globalAlpha = 0.7;
+ ctx.strokeStyle = color;
- function drawPrice(ctx, from, to, color, price, points, highest, lowest)
- {
- ctx.save();
- ctx.globalAlpha = 0.7;
- ctx.strokeStyle = color;
- ctx.lineWidth = 3;
- ctx.beginPath();
+ ctx.lineWidth = numPoints > 200 ? 1 : 3
- var end = points.length;
+ ctx.beginPath();
- var range = highest - lowest;
- if (range == 0) {
- range = 1;
- }
+ var end = points.length;
- for (var i = 0; i < end; i += pixelSkip) {
- var x = points[i].x;
- var y = points[i][price];
- var h = 9 * yGridStep;
+ var range = highest - lowest;
+ if (range == 0) {
+ range = 1;
+ }
- y = h * (lowest - y)/range + h + yGridOffset;
+ for (var i = 0; i < end; i += pixelSkip) {
+ var x = points[i].x;
+ var y = points[i][price];
+ var h = 9 * yGridStep;
- if (i == 0) {
- ctx.moveTo(x, y);
- } else {
- ctx.lineTo(x, y);
+ y = h * (lowest - y)/range + h + yGridOffset;
+
+ if (i == 0) {
+ ctx.moveTo(x, y);
+ } else {
+ ctx.lineTo(x, y);
+ }
}
+ ctx.stroke();
+ ctx.restore();
}
- ctx.stroke();
- ctx.restore();
- }
- function drawVolume(ctx, from, to, color, price, points, highest)
- {
- ctx.save();
- ctx.fillStyle = color;
- ctx.globalAlpha = 0.8;
- ctx.lineWidth = 0;
- ctx.beginPath();
+ function drawVolume(ctx, from, to, color, price, points, highest)
+ {
+ ctx.save();
+ ctx.fillStyle = color;
+ ctx.globalAlpha = 0.8;
+ ctx.lineWidth = 0;
+ ctx.beginPath();
+
+ var end = points.length;
+ var margin = 0;
+
+ if (chart.activeChart === "month" || chart.activeChart === "week") {
+ margin = 8;
+ ctx.shadowOffsetX = 4;
+ ctx.shadowBlur = 3.5;
+ ctx.shadowColor = Qt.darker(color);
+ }
- var end = points.length;
- var margin = 0;
+ // To match the volume graph with price grid, skip drawing the initial
+ // volume of the first day on chart.
+ for (var i = 1; i < end; i += pixelSkip) {
+ var x = points[i - 1].x;
+ var y = points[i][price];
+ y = canvas.height * (y / highest);
+ y = 3 * y / 12;
+ ctx.fillRect(x, canvas.height - y + yGridOffset,
+ canvas.xGridStep - margin, y);
+ }
- if (chart.activeChart === "month" || chart.activeChart === "week") {
- margin = 8;
- ctx.shadowOffsetX = 4;
- ctx.shadowBlur = 3.5;
- ctx.shadowColor = Qt.darker(color);
+ ctx.stroke();
+ ctx.restore();
}
- // To match the volume graph with price grid, skip drawing the initial
- // volume of the first day on chart.
- for (var i = 1; i < end; i += pixelSkip) {
- var x = points[i - 1].x;
- var y = points[i][price];
- y = canvas.height * (y / highest);
- y = 3 * y / 12;
- ctx.fillRect(x, canvas.height - y + yGridOffset,
- canvas.xGridStep - margin, y);
+ function drawError(ctx, msg)
+ {
+ ctx.save();
+ ctx.strokeStyle = "#888888";
+ ctx.font = "24px Open Sans"
+ ctx.textAlign = "center"
+ ctx.shadowOffsetX = 4;
+ ctx.shadowOffsetY = 4;
+ ctx.shadowBlur = 1.5;
+ ctx.shadowColor = "#aaaaaa";
+ ctx.beginPath();
+
+ ctx.fillText(msg, (canvas.width - tickMargin) / 2,
+ (canvas.height - yGridOffset - yGridStep) / 2);
+
+ ctx.closePath();
+ ctx.stroke();
+ ctx.restore();
}
- ctx.stroke();
- ctx.restore();
- }
+ onPaint: {
+ numPoints = stockModel.indexOf(chart.startDate);
- function drawError(ctx, msg)
- {
- ctx.save();
- ctx.strokeStyle = "#888888";
- ctx.font = "24px Open Sans"
- ctx.textAlign = "center"
- ctx.shadowOffsetX = 4;
- ctx.shadowOffsetY = 4;
- ctx.shadowBlur = 1.5;
- ctx.shadowColor = "#aaaaaa";
- ctx.beginPath();
-
- ctx.fillText(msg, (canvas.width - tickMargin) / 2,
- (canvas.height - yGridOffset - yGridStep) / 2);
-
- ctx.closePath();
- ctx.stroke();
- ctx.restore();
- }
+ if (chart.gridSize == 0)
+ chart.gridSize = numPoints
- onPaint: {
- numPoints = stockModel.indexOf(chart.startDate);
+ var ctx = canvas.getContext("2d");
+ ctx.globalCompositeOperation = "source-over";
+ ctx.lineWidth = 1;
- if (chart.gridSize == 0)
- chart.gridSize = numPoints
+ drawBackground(ctx);
- var ctx = canvas.getContext("2d");
- ctx.globalCompositeOperation = "source-over";
- ctx.lineWidth = 1;
+ if (!stockModel.ready) {
+ drawError(ctx, "No data available.");
+ return;
+ }
- drawBackground(ctx);
+ var highestPrice = 0;
+ var highestVolume = 0;
+ var lowestPrice = -1;
+ var points = [];
+ for (var i = numPoints, j = 0; i >= 0 ; i -= pixelSkip, j += pixelSkip) {
+ var price = stockModel.get(i);
+ if (parseFloat(highestPrice) < parseFloat(price.high))
+ highestPrice = price.high;
+ if (parseInt(highestVolume, 10) < parseInt(price.volume, 10))
+ highestVolume = price.volume;
+ if (lowestPrice < 0 || parseFloat(lowestPrice) > parseFloat(price.low))
+ lowestPrice = price.low;
+ points.push({
+ x: j * xGridStep,
+ open: price.open,
+ close: price.close,
+ high: price.high,
+ low: price.low,
+ volume: price.volume
+ });
+ }
- if (!stockModel.ready) {
- drawError(ctx, "No data available.");
- return;
+ if (settings.drawHighPrice)
+ drawPrice(ctx, 0, numPoints, settings.highColor, "high", points, highestPrice, lowestPrice);
+ if (settings.drawLowPrice)
+ drawPrice(ctx, 0, numPoints, settings.lowColor, "low", points, highestPrice, lowestPrice);
+ if (settings.drawOpenPrice)
+ drawPrice(ctx, 0, numPoints,settings.openColor, "open", points, highestPrice, lowestPrice);
+ if (settings.drawClosePrice)
+ drawPrice(ctx, 0, numPoints, settings.closeColor, "close", points, highestPrice, lowestPrice);
+
+ drawVolume(ctx, 0, numPoints, settings.volumeColor, "volume", points, highestVolume);
+ drawScales(ctx, highestPrice, lowestPrice, highestVolume);
}
+ }
- var highestPrice = 0;
- var highestVolume = 0;
- var lowestPrice = -1;
- var points = [];
- for (var i = numPoints, j = 0; i >= 0 ; i -= pixelSkip, j += pixelSkip) {
- var price = stockModel.get(i);
- if (parseFloat(highestPrice) < parseFloat(price.high))
- highestPrice = price.high;
- if (parseInt(highestVolume, 10) < parseInt(price.volume, 10))
- highestVolume = price.volume;
- if (lowestPrice < 0 || parseFloat(lowestPrice) > parseFloat(price.low))
- lowestPrice = price.low;
- points.push({
- x: j * xGridStep,
- open: price.open,
- close: price.close,
- high: price.high,
- low: price.low,
- volume: price.volume
- });
- }
- if (settings.drawHighPrice)
- drawPrice(ctx, 0, numPoints, settings.highColor, "high", points, highestPrice, lowestPrice);
- if (settings.drawLowPrice)
- drawPrice(ctx, 0, numPoints, settings.lowColor, "low", points, highestPrice, lowestPrice);
- if (settings.drawOpenPrice)
- drawPrice(ctx, 0, numPoints,settings.openColor, "open", points, highestPrice, lowestPrice);
- if (settings.drawClosePrice)
- drawPrice(ctx, 0, numPoints, settings.closeColor, "close", points, highestPrice, lowestPrice);
-
- drawVolume(ctx, 0, numPoints, settings.volumeColor, "volume", points, highestVolume);
- drawScales(ctx, highestPrice, lowestPrice, highestVolume);
+ Text {
+ id: fromDate
+ color: "#000000"
+ font.family: Settings.fontFamily
+ font.pointSize: 8
+ Layout.alignment: Qt.AlignLeft
+ text: "| " + startDate.toDateString()
+ }
+ Text {
+ id: toDate
+ color: "#000000"
+ font.family: Settings.fontFamily
+ font.pointSize: 8
+ Layout.alignment: Qt.AlignRight
+ Layout.rightMargin: canvas.tickMargin
+ Layout.columnSpan: 5
+ text: endDate.toDateString() + " |"
}
}
}
diff --git a/examples/quick/demos/stocqt/content/StockInfo.qml b/examples/quick/demos/stocqt/content/StockInfo.qml
index 88f540fa09..2935e74db9 100644
--- a/examples/quick/demos/stocqt/content/StockInfo.qml
+++ b/examples/quick/demos/stocqt/content/StockInfo.qml
@@ -39,42 +39,43 @@
****************************************************************************/
import QtQuick 2.0
+import QtQuick.Layouts 1.1
import "."
Rectangle {
id: root
- width: 440
- height: 160
color: "transparent"
property var stock: null
- Column {
- id: stockColumn
+ GridLayout {
+ id: stockInfoLayout
anchors.fill: parent
- spacing: 4
+ columns: 2
+ rows: 3
+ rowSpacing: 4
- Flow {
- anchors { left: parent.left; right: parent.right }
- spacing: 12
-
- Text {
- id: stockIdText
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 28
- font.weight: Font.DemiBold
- text: root.stock.stockId
- }
+ Text {
+ id: stockIdText
+ color: "#000000"
+ font.family: Settings.fontFamily
+ font.pointSize: 28
+ font.weight: Font.DemiBold
+ text: root.stock.stockId
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
+ Layout.leftMargin: 10
+ }
- Text {
- id: price
- color: "#6d6d6d"
- font.family: Settings.fontFamily
- font.pointSize: 28
- font.weight: Font.DemiBold
- text: parseFloat(root.stock.stockPrice).toFixed(2);
- }
+ Text {
+ id: price
+ color: "#6d6d6d"
+ font.family: Settings.fontFamily
+ font.pointSize: 28
+ font.weight: Font.DemiBold
+ text: parseFloat(root.stock.stockPrice).toFixed(2);
+ Layout.fillWidth: true
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
+ Layout.leftMargin: 5
}
Text {
@@ -82,38 +83,38 @@ Rectangle {
color: "#0c0c0c"
font.family: Settings.fontFamily
font.pointSize: 16
- width: stockColumn.width
elide: Text.ElideRight
maximumLineCount: 3
wrapMode: Text.WordWrap
text: root.stock.stockName
+ Layout.leftMargin: 10
+ Layout.columnSpan: 2
+ Layout.alignment: Qt.AlignLeft
}
- Flow {
- anchors { left: parent.left; right: parent.right }
- spacing: 12
- Text {
- id: priceChange
- horizontalAlignment: Text.AlignRight
- color: root.stock.stockPriceChanged < 0 ? "#d40000" : "#328930"
- font.family: Settings.fontFamily
- font.pointSize: 18
- text: parseFloat(root.stock.stockPriceChanged).toFixed(2);
- }
+ Text {
+ id: priceChange
+ Layout.alignment: Qt.AlignLeft | Qt.AlignTop
+ Layout.leftMargin: 10
+ color: root.stock.stockPriceChanged < 0 ? "#d40000" : "#328930"
+ font.family: Settings.fontFamily
+ font.pointSize: 18
+ text: parseFloat(root.stock.stockPriceChanged).toFixed(2);
+ }
- Text {
- id: priceChangePercentage
- horizontalAlignment: Text.AlignRight
- color: root.stock.stockPriceChanged < 0 ? "#d40000" : "#328930"
- font.family: Settings.fontFamily
- font.pointSize: 18
- font.weight: Font.DemiBold
- text: "(" +
- parseFloat(root.stock.stockPriceChanged /
- (root.stock.stockPrice - root.stock.stockPriceChanged) * 100.0).toFixed(2) +
- "%)"
- }
+ Text {
+ id: priceChangePercentage
+ Layout.alignment: Qt.AlignLeft | Qt.AlignTop
+ color: root.stock.stockPriceChanged < 0 ? "#d40000" : "#328930"
+ font.family: Settings.fontFamily
+ font.pointSize: 18
+ font.weight: Font.DemiBold
+ Layout.fillWidth: true
+ text: "(" +
+ parseFloat(root.stock.stockPriceChanged /
+ (root.stock.stockPrice - root.stock.stockPriceChanged) * 100.0).toFixed(2) +
+ "%)"
}
}
}
diff --git a/examples/quick/demos/stocqt/content/StockListDelegate.qml b/examples/quick/demos/stocqt/content/StockListDelegate.qml
new file mode 100644
index 0000000000..f3a3ab6976
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/StockListDelegate.qml
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.5
+import QtQuick.Layouts 1.1
+import "."
+
+Rectangle {
+ height: 102
+ width: parent.width
+ color: "transparent"
+ MouseArea {
+ anchors.fill: parent;
+ onClicked: {
+ if (view.currentIndex == index)
+ mainRect.currentIndex = 1;
+ else
+ view.currentIndex = index;
+ }
+ }
+ GridLayout {
+ id: stockGrid
+ columns: 3
+ rows: 2
+ anchors.fill: parent
+
+ Text {
+ id: stockIdText
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
+ Layout.leftMargin: 10
+ color: "#000000"
+ font.family: Settings.fontFamily
+ font.pointSize: 20
+ font.weight: Font.Bold
+ verticalAlignment: Text.AlignVCenter
+ text: stockId
+ }
+
+ Text {
+ id: stockValueText
+ Layout.preferredWidth: 100
+ Layout.alignment: Qt.AlignRight | Qt.AlignBottom
+ color: "#000000"
+ font.family: Settings.fontFamily
+ font.pointSize: 20
+ font.bold: true
+ horizontalAlignment: Text.AlignRight
+ verticalAlignment: Text.AlignVCenter
+ text: value
+ }
+ Text {
+ id: stockValueChangeText
+ Layout.preferredWidth: 135
+ Layout.rightMargin: 10
+ Layout.alignment: Qt.AlignRight | Qt.AlignBottom
+ color: "#328930"
+ font.family: Settings.fontFamily
+ font.pointSize: 20
+ font.bold: true
+ horizontalAlignment: Text.AlignRight
+ verticalAlignment: Text.AlignVCenter
+ text: change
+ onTextChanged: {
+ if (parseFloat(text) >= 0.0)
+ color = "#328930";
+ else
+ color = "#d40000";
+ }
+ }
+ Text {
+ id: stockNameText
+ Layout.preferredWidth: 300
+ Layout.leftMargin: 10
+ Layout.alignment: Qt.AlignLeft | Qt.AlignTop
+ color: "#000000"
+ font.family: Settings.fontFamily
+ font.pointSize: 16
+ font.bold: false
+ elide: Text.ElideRight
+ maximumLineCount: 1
+ verticalAlignment: Text.AlignVCenter
+ text: name
+ }
+
+ Item {Layout.fillWidth: true }
+
+ Text {
+ id: stockValueChangePercentageText
+ Layout.fillWidth: true
+ Layout.alignment: Qt.AlignRight | Qt.AlignTop
+ Layout.rightMargin: 10
+ color: "#328930"
+ font.family: Settings.fontFamily
+ font.pointSize: 18
+ font.bold: false
+ horizontalAlignment: Text.AlignRight
+ verticalAlignment: Text.AlignVCenter
+ text: changePercentage
+ onTextChanged: {
+ if (parseFloat(text) >= 0.0)
+ color = "#328930";
+ else
+ color = "#d40000";
+ }
+ }
+ }
+
+ Rectangle {
+ id: endingLine
+ anchors.top: stockGrid.bottom
+ height: 1
+ width: parent.width
+ color: "#d7d7d7"
+ }
+}
+
diff --git a/examples/quick/demos/stocqt/content/StockListModel.qml b/examples/quick/demos/stocqt/content/StockListModel.qml
index be00e7bb1c..9b48124bda 100644
--- a/examples/quick/demos/stocqt/content/StockListModel.qml
+++ b/examples/quick/demos/stocqt/content/StockListModel.qml
@@ -42,6 +42,72 @@ import QtQuick 2.0
ListModel {
id: stocks
+
+ // pre-fetch data for all entries
+ Component.onCompleted: {
+ for (var idx = 0; idx < count; ++idx) {
+ getCloseValue(idx)
+ }
+ }
+
+ function requestUrl(stockId) {
+ var endDate = new Date(""); // today
+ var startDate = new Date()
+ startDate.setDate(startDate.getDate() - 5);
+
+ var request = "http://ichart.finance.yahoo.com/table.csv?";
+ request += "s=" + stockId;
+ request += "&g=d";
+ request += "&a=" + startDate.getMonth();
+ request += "&b=" + startDate.getDate();
+ request += "&c=" + startDate.getFullYear();
+ request += "&d=" + endDate.getMonth();
+ request += "&e=" + endDate.getDate();
+ request += "&f=" + endDate.getFullYear();
+ request += "&g=d";
+ request += "&ignore=.csv";
+ return request;
+ }
+
+ function getCloseValue(index) {
+ var req = requestUrl(get(index).stockId);
+
+ if (!req)
+ return;
+
+ var xhr = new XMLHttpRequest;
+
+ xhr.open("GET", req, true);
+
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState === XMLHttpRequest.LOADING || xhr.readyState === XMLHttpRequest.DONE) {
+ var records = xhr.responseText.split('\n');
+ if (records.length > 0 && xhr.status == 200) {
+ var r = records[1].split(',');
+ var today = parseFloat(r[4]);
+ setProperty(index, "value", today.toFixed(2));
+
+ r = records[2].split(',');
+ var yesterday = parseFloat(r[4]);
+ var change = today - yesterday;
+ if (change >= 0.0)
+ setProperty(index, "change", "+" + change.toFixed(2));
+ else
+ setProperty(index, "change", change.toFixed(2));
+
+ var changePercentage = (change / yesterday) * 100.0;
+ if (changePercentage >= 0.0)
+ setProperty(index, "changePercentage", "+" + changePercentage.toFixed(2) + "%");
+ else
+ setProperty(index, "changePercentage", changePercentage.toFixed(2) + "%");
+ } else {
+ var unknown = "n/a";
+ set(index, {"value": unknown, "change": unknown, "changePercentage": unknown});
+ }
+ }
+ }
+ xhr.send()
+ }
// Uncomment to test invalid entries
// ListElement {name: "The Qt Company"; stockId: "TQTC"; value: "999.0"; change: "0.0"; changePercentage: "0.0"}
diff --git a/examples/quick/demos/stocqt/content/StockListView.qml b/examples/quick/demos/stocqt/content/StockListView.qml
index 59f36b42cc..177580cf6b 100644
--- a/examples/quick/demos/stocqt/content/StockListView.qml
+++ b/examples/quick/demos/stocqt/content/StockListView.qml
@@ -43,8 +43,6 @@ import "."
Rectangle {
id: root
- width: 320
- height: 410
anchors.top: parent.top
anchors.bottom: parent.bottom
color: "white"
@@ -55,74 +53,14 @@ Rectangle {
ListView {
id: view
anchors.fill: parent
- width: parent.width
clip: true
keyNavigationWraps: true
highlightMoveDuration: 0
focus: true
snapMode: ListView.SnapToItem
- model: StockListModel{}
+ model: StockListModel {}
currentIndex: -1 // Don't pre-select any item
- function requestUrl(stockId) {
- var endDate = new Date(""); //today
- var startDate = new Date()
- startDate.setDate(startDate.getDate() - 5);
-
- var request = "http://ichart.finance.yahoo.com/table.csv?";
- request += "s=" + stockId;
- request += "&g=d";
- request += "&a=" + startDate.getMonth();
- request += "&b=" + startDate.getDate();
- request += "&c=" + startDate.getFullYear();
- request += "&d=" + endDate.getMonth();
- request += "&e=" + endDate.getDate();
- request += "&f=" + endDate.getFullYear();
- request += "&g=d";
- request += "&ignore=.csv";
- return request;
- }
-
- function getCloseValue(index) {
- var req = requestUrl(model.get(index).stockId);
-
- if (!req)
- return;
-
- var xhr = new XMLHttpRequest;
-
- xhr.open("GET", req, true);
-
- xhr.onreadystatechange = function() {
- if (xhr.readyState === XMLHttpRequest.LOADING || xhr.readyState === XMLHttpRequest.DONE) {
- var records = xhr.responseText.split('\n');
- if (records.length > 0 && xhr.status == 200) {
- var r = records[1].split(',');
- var today = parseFloat(r[4]);
- model.setProperty(index, "value", today.toFixed(2));
-
- r = records[2].split(',');
- var yesterday = parseFloat(r[4]);
- var change = today - yesterday;
- if (change >= 0.0)
- model.setProperty(index, "change", "+" + change.toFixed(2));
- else
- model.setProperty(index, "change", change.toFixed(2));
-
- var changePercentage = (change / yesterday) * 100.0;
- if (changePercentage >= 0.0)
- model.setProperty(index, "changePercentage", "+" + changePercentage.toFixed(2) + "%");
- else
- model.setProperty(index, "changePercentage", changePercentage.toFixed(2) + "%");
- } else {
- var unknown = "n/a";
- model.set(index, {"value": unknown, "change": unknown, "changePercentage": unknown});
- }
- }
- }
- xhr.send()
- }
-
onCurrentIndexChanged: {
if (currentItem) {
root.currentStockId = model.get(currentIndex).stockId;
@@ -130,125 +68,7 @@ Rectangle {
}
}
- delegate: Rectangle {
- height: 102
- width: parent.width
- color: "transparent"
- MouseArea {
- anchors.fill: parent;
- onClicked: {
- if (view.currentIndex == index)
- mainRect.currentIndex = 1;
- else
- view.currentIndex = index;
- }
- }
-
- Text {
- id: stockIdText
- anchors.top: parent.top
- anchors.topMargin: 15
- anchors.left: parent.left
- anchors.leftMargin: 15
- width: 125
- height: 40
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 20
- font.weight: Font.Bold
- verticalAlignment: Text.AlignVCenter
- text: stockId
- }
-
- Text {
- id: stockValueText
- anchors.top: parent.top
- anchors.topMargin: 15
- anchors.right: parent.right
- anchors.rightMargin: 0.31 * parent.width
- width: 190
- height: 40
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 20
- font.bold: true
- horizontalAlignment: Text.AlignRight
- verticalAlignment: Text.AlignVCenter
- text: value
- Component.onCompleted: view.getCloseValue(index);
- }
-
- Text {
- id: stockValueChangeText
- anchors.top: parent.top
- anchors.topMargin: 15
- anchors.right: parent.right
- anchors.rightMargin: 20
- width: 135
- height: 40
- color: "#328930"
- font.family: Settings.fontFamily
- font.pointSize: 20
- font.bold: true
- horizontalAlignment: Text.AlignRight
- verticalAlignment: Text.AlignVCenter
- text: change
- onTextChanged: {
- if (parseFloat(text) >= 0.0)
- color = "#328930";
- else
- color = "#d40000";
- }
- }
-
- Text {
- id: stockNameText
- anchors.top: stockIdText.bottom
- anchors.left: parent.left
- anchors.leftMargin: 15
- width: 330
- height: 30
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 16
- font.bold: false
- elide: Text.ElideRight
- maximumLineCount: 1
- verticalAlignment: Text.AlignVCenter
- text: name
- }
-
- Text {
- id: stockValueChangePercentageText
- anchors.top: stockIdText.bottom
- anchors.right: parent.right
- anchors.rightMargin: 20
- width: 120
- height: 30
- color: "#328930"
- font.family: Settings.fontFamily
- font.pointSize: 18
- font.bold: false
- horizontalAlignment: Text.AlignRight
- verticalAlignment: Text.AlignVCenter
- text: changePercentage
- onTextChanged: {
- if (parseFloat(text) >= 0.0)
- color = "#328930";
- else
- color = "#d40000";
- }
- }
-
- Rectangle {
- id: endingLine
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- height: 1
- width: parent.width
- color: "#d7d7d7"
- }
- }
+ delegate: StockListDelegate {}
highlight: Rectangle {
width: view.width
diff --git a/examples/quick/demos/stocqt/content/StockSettingsPanel.qml b/examples/quick/demos/stocqt/content/StockSettingsPanel.qml
index 0c34e453de..1ac1035789 100644
--- a/examples/quick/demos/stocqt/content/StockSettingsPanel.qml
+++ b/examples/quick/demos/stocqt/content/StockSettingsPanel.qml
@@ -39,12 +39,11 @@
****************************************************************************/
import QtQuick 2.0
+import QtQuick.Layouts 1.1
import "."
Rectangle {
id: root
- width: 440
- height: 160
color: "transparent"
property bool drawOpenPrice: openButton.buttonEnabled
@@ -58,118 +57,93 @@ Rectangle {
property string lowColor: "#f30000"
property string volumeColor: "#14aaff"
- Text {
- id: openText
- anchors.left: root.left
- anchors.top: root.top
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 19
- text: "Open"
- }
-
- Text {
- id: closeText
- anchors.left: root.left
- anchors.top: openText.bottom
- anchors.topMargin: 10
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 19
- text: "Close"
- }
-
- Text {
- id: highText
- anchors.left: root.left
- anchors.top: closeText.bottom
- anchors.topMargin: 10
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 19
- text: "High"
- }
-
- Text {
- id: lowText
- anchors.left: root.left
- anchors.top: highText.bottom
- anchors.topMargin: 10
- color: "#000000"
- font.family: Settings.fontFamily
- font.pointSize: 19
- text: "Low"
- }
-
- Rectangle {
- height: 4
- anchors.left: root.left
- anchors.leftMargin: 114
- anchors.right: openButton.left
- anchors.rightMargin: 65
- anchors.verticalCenter: openText.verticalCenter
- color: openColor
- }
-
- Rectangle {
- height: 4
- anchors.left: root.left
- anchors.leftMargin: 114
- anchors.right: closeButton.left
- anchors.rightMargin: 65
- anchors.verticalCenter: closeText.verticalCenter
- color: closeColor
- }
-
- Rectangle {
- height: 4
- anchors.left: root.left
- anchors.leftMargin: 114
- anchors.right: highButton.left
- anchors.rightMargin: 65
- anchors.verticalCenter: highText.verticalCenter
- color: highColor
- }
-
- Rectangle {
- height: 4
- anchors.left: root.left
- anchors.leftMargin: 114
- anchors.right: lowButton.left
- anchors.rightMargin: 65
- anchors.verticalCenter: lowText.verticalCenter
- color: lowColor
- }
-
- CheckBox {
- id: openButton
- buttonEnabled: false
- anchors.verticalCenter: openText.verticalCenter
- anchors.right: root.right
- anchors.rightMargin: 40
- }
-
- CheckBox {
- id: closeButton
- buttonEnabled: false
- anchors.verticalCenter: closeText.verticalCenter
- anchors.right: root.right
- anchors.rightMargin: 40
- }
-
- CheckBox {
- id: highButton
- buttonEnabled: true
- anchors.verticalCenter: highText.verticalCenter
- anchors.right: root.right
- anchors.rightMargin: 40
- }
-
- CheckBox {
- id: lowButton
- buttonEnabled: true
- anchors.verticalCenter: lowText.verticalCenter
- anchors.right: root.right
- anchors.rightMargin: 40
+ GridLayout {
+ id: settingsGrid
+ rows: 5
+ columns: 3
+ rowSpacing: 4
+ anchors.fill: parent
+
+ Item {
+ Layout.fillHeight: true
+ Layout.columnSpan: 3
+ }
+
+ Text {
+ id: openText
+ color: "#000000"
+ font.family: Settings.fontFamily
+ font.pointSize: 19
+ text: "Open"
+ Layout.leftMargin: 10
+ }
+ Rectangle {
+ Layout.preferredHeight: 4
+ Layout.preferredWidth: 114
+ color: openColor
+ }
+ CheckBox {
+ id: openButton
+ buttonEnabled: false
+ Layout.rightMargin: 10
+ }
+
+ Text {
+ id: closeText
+ Layout.leftMargin: 10
+ color: "#000000"
+ font.family: Settings.fontFamily
+ font.pointSize: 19
+ text: "Close"
+ }
+ Rectangle {
+ Layout.preferredHeight: 4
+ Layout.preferredWidth: 114
+ color: closeColor
+ }
+ CheckBox {
+ id: closeButton
+ buttonEnabled: false
+ Layout.rightMargin: 10
+ }
+
+ Text {
+ id: highText
+ Layout.leftMargin: 10
+ color: "#000000"
+ font.family: Settings.fontFamily
+ font.pointSize: 19
+ text: "High"
+ }
+ Rectangle {
+ Layout.preferredHeight: 4
+ Layout.preferredWidth: 114
+ color: highColor
+ }
+ CheckBox {
+ id: highButton
+ buttonEnabled: true
+ Layout.rightMargin: 10
+ }
+
+ Text {
+ id: lowText
+ Layout.leftMargin: 10
+ color: "#000000"
+ font.family: Settings.fontFamily
+ font.pointSize: 19
+ text: "Low"
+ }
+ Rectangle {
+ Layout.preferredHeight: 4
+ Layout.preferredWidth: 114
+ color: lowColor
+ }
+
+ CheckBox {
+ id: lowButton
+ buttonEnabled: true
+ Layout.rightMargin: 10
+ }
}
}
diff --git a/examples/quick/demos/stocqt/content/StockView.qml b/examples/quick/demos/stocqt/content/StockView.qml
index ec89c52510..d598ddd201 100644
--- a/examples/quick/demos/stocqt/content/StockView.qml
+++ b/examples/quick/demos/stocqt/content/StockView.qml
@@ -40,6 +40,7 @@
import QtQuick 2.0
import QtQuick.Window 2.1
+import QtQuick.Layouts 1.1
Rectangle {
id: root
@@ -60,42 +61,40 @@ Rectangle {
color: "transparent"
anchors.fill: parent
- StockInfo {
- id: stockInfo
- anchors.left: parent.left
- anchors.leftMargin: 10
- anchors.top: parent.top
- anchors.topMargin: 15
- height: 160
- anchors.right: Screen.primaryOrientation === Qt.PortraitOrientation ? parent.right : chart.left
- anchors.rightMargin: 20
- stock: root.stock
- }
+ GridLayout {
+ anchors.fill: parent
+ rows: 2
+ columns: Screen.primaryOrientation === Qt.PortraitOrientation ? 1 : 2
- StockChart {
- id: chart
- anchors.bottom: Screen.primaryOrientation === Qt.PortraitOrientation ? settingsPanel.top : parent.bottom
- anchors.bottomMargin: 20
- anchors.top : Screen.primaryOrientation === Qt.PortraitOrientation ? stockInfo.bottom : parent.top
- anchors.topMargin: 20
- anchors.right: parent.right
- anchors.rightMargin: 20
- width: Screen.primaryOrientation === Qt.PortraitOrientation ? parent.width - 40 : 0.6 * parent.width
- stockModel: root.stock
- settings: settingsPanel
- }
+ StockInfo {
+ id: stockInfo
+ Layout.alignment: Qt.AlignTop
+ Layout.preferredWidth: 400
+ Layout.preferredHeight: 160
+ stock: root.stock
+ }
- StockSettingsPanel {
- id: settingsPanel
- anchors.left: parent.left
- anchors.leftMargin: 20
- anchors.right: Screen.primaryOrientation === Qt.PortraitOrientation ? parent.right : chart.left
- anchors.rightMargin: 20
- anchors.bottom: parent.bottom
- onDrawOpenPriceChanged: root.update()
- onDrawClosePriceChanged: root.update();
- onDrawHighPriceChanged: root.update();
- onDrawLowPriceChanged: root.update();
+ StockChart {
+ id: chart
+ Layout.alignment: Qt.AlignRight
+ Layout.margins: 5
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.rowSpan: 2
+ stockModel: root.stock
+ settings: settingsPanel
+ }
+ StockSettingsPanel {
+ id: settingsPanel
+ Layout.alignment: Qt.AlignBottom
+ Layout.fillHeight: true
+ Layout.preferredWidth: 400
+ Layout.bottomMargin: 5
+ onDrawOpenPriceChanged: root.update()
+ onDrawClosePriceChanged: root.update();
+ onDrawHighPriceChanged: root.update();
+ onDrawLowPriceChanged: root.update();
+ }
}
}
}
diff --git a/examples/quick/demos/stocqt/content/qmldir b/examples/quick/demos/stocqt/content/qmldir
index bcfa27b484..77f5ed3c56 100644
--- a/examples/quick/demos/stocqt/content/qmldir
+++ b/examples/quick/demos/stocqt/content/qmldir
@@ -8,3 +8,5 @@ StockListView 1.0 StockListView.qml
StockModel 1.0 StockModel.qml
StockSettingsPanel 1.0 StockSettingsPanel.qml
StockView 1.0 StockView.qml
+StockListDelegate 1.0 StockListDelegate.qml
+Banner 1.0 Banner.qml
diff --git a/examples/quick/demos/stocqt/stocqt.qml b/examples/quick/demos/stocqt/stocqt.qml
index 6b1da1713a..a13e63fd50 100644
--- a/examples/quick/demos/stocqt/stocqt.qml
+++ b/examples/quick/demos/stocqt/stocqt.qml
@@ -40,6 +40,7 @@
import QtQuick 2.0
import QtQml.Models 2.1
+import QtQuick.Layouts 1.1
import "./content"
Rectangle {
@@ -49,90 +50,50 @@ Rectangle {
property alias currentIndex: root.currentIndex
- Rectangle {
- id: banner
- height: 80
- anchors.top: parent.top
- width: parent.width
- color: "#000000"
+ ColumnLayout {
+ anchors.fill: parent
- Image {
- id: arrow
- source: "./content/images/icon-left-arrow.png"
- anchors.left: banner.left
- anchors.leftMargin: 20
- anchors.verticalCenter: banner.verticalCenter
- visible: root.currentIndex == 1 ? true : false
-
- MouseArea {
- anchors.fill: parent
- onClicked: root.currentIndex = 0;
- }
- }
-
- Item {
- id: textItem
- width: stocText.width + qtText.width
- height: stocText.height + qtText.height
- anchors.horizontalCenter: banner.horizontalCenter
- anchors.verticalCenter: banner.verticalCenter
-
- Text {
- id: stocText
- anchors.verticalCenter: textItem.verticalCenter
- color: "#ffffff"
- font.family: "Abel"
- font.pointSize: 40
- text: "Stoc"
- }
- Text {
- id: qtText
- anchors.verticalCenter: textItem.verticalCenter
- anchors.left: stocText.right
- color: "#5caa15"
- font.family: "Abel"
- font.pointSize: 40
- text: "Qt"
- }
+ Banner {
+ id: banner
+ Layout.fillWidth: true
}
- }
- ListView {
- id: root
- width: parent.width
- anchors.top: banner.bottom
- anchors.bottom: parent.bottom
- snapMode: ListView.SnapOneItem
- highlightRangeMode: ListView.StrictlyEnforceRange
- highlightMoveDuration: 250
- focus: false
- orientation: ListView.Horizontal
- boundsBehavior: Flickable.StopAtBounds
+ ListView {
+ id: root
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ snapMode: ListView.SnapOneItem
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ highlightMoveDuration: 250
+ focus: false
+ orientation: ListView.Horizontal
+ boundsBehavior: Flickable.StopAtBounds
- StockModel {
- id: stock
- stockId: listView.currentStockId
- stockName: listView.currentStockName
- onStockIdChanged: stock.updateStock();
- onDataReady: {
- root.currentIndex = 1
- stockView.update()
+ StockModel {
+ id: stock
+ stockId: listView.currentStockId
+ stockName: listView.currentStockName
+ onStockIdChanged: stock.updateStock();
+ onDataReady: {
+ root.currentIndex = 1
+ stockView.update()
+ }
}
- }
- model: ObjectModel {
- StockListView {
- id: listView
- width: root.width
- height: root.height
- }
+ model: ObjectModel {
+ StockListView {
+ id: listView
+ width: root.width
+ height: root.height
+ }
- StockView {
- id: stockView
- width: root.width
- height: root.height
- stocklist: listView
- stock: stock
+ StockView {
+ id: stockView
+ width: root.width
+ height: root.height
+ stocklist: listView
+ stock: stock
+ }
}
}
}
diff --git a/examples/quick/demos/stocqt/stocqt.qrc b/examples/quick/demos/stocqt/stocqt.qrc
index 920e56d4d0..ab7772a62a 100644
--- a/examples/quick/demos/stocqt/stocqt.qrc
+++ b/examples/quick/demos/stocqt/stocqt.qrc
@@ -16,5 +16,7 @@
<file>content/StockInfo.qml</file>
<file>content/Settings.qml</file>
<file>content/+windows/Settings.qml</file>
+ <file>content/StockListDelegate.qml</file>
+ <file>content/Banner.qml</file>
</qresource>
</RCC>
diff --git a/examples/quick/localstorage/doc/src/localstorage.qdoc b/examples/quick/localstorage/doc/src/localstorage.qdoc
index b52e0afd80..1bfba147e1 100644
--- a/examples/quick/localstorage/doc/src/localstorage.qdoc
+++ b/examples/quick/localstorage/doc/src/localstorage.qdoc
@@ -35,8 +35,13 @@
\include examples-run.qdocinc
- \section1 Hello World
+ \section1 Activity Tracker
- \e {Hello World} demonstrates creating a simple SQL table and doing
- insert and select operations.
+ \e {Activity tracker} allows you to keep track of walks, hikes, or bike trips.
+
+ All database transactions are handled in Database.js. The database is
+ checked at startup, and created if it does not exist. LocalStorage uses
+ SQLite, which is a self-contained, serverless, public-domain database.
+ Opening a connection to the database is handled at the beginning of each
+ function that manipulates or retrieves data.
*/
diff --git a/examples/quick/localstorage/localstorage/Database.js b/examples/quick/localstorage/localstorage/Database.js
new file mode 100644
index 0000000000..387033795f
--- /dev/null
+++ b/examples/quick/localstorage/localstorage/Database.js
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+function dbInit()
+{
+ var db = LocalStorage.openDatabaseSync("Activity_Tracker_DB", "", "Track exercise", 1000000)
+ try {
+ db.transaction(function (tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS trip_log (date text,trip_desc text,distance numeric)')
+ })
+ } catch (err) {
+ console.log("Error creating table in database: " + err)
+ };
+}
+
+function dbGetHandle()
+{
+ try {
+ var db = LocalStorage.openDatabaseSync("Activity_Tracker_DB", "",
+ "Track exercise", 1000000)
+ } catch (err) {
+ console.log("Error opening database: " + err)
+ }
+ return db
+}
+
+function dbInsert(Pdate, Pdesc, Pdistance)
+{
+ var db = dbGetHandle()
+ var rowid = 0;
+ db.transaction(function (tx) {
+ tx.executeSql('INSERT INTO trip_log VALUES(?, ?, ?)',
+ [Pdate, Pdesc, Pdistance])
+ var result = tx.executeSql('SELECT last_insert_rowid()')
+ rowid = result.insertId
+ })
+ return rowid;
+}
+
+function dbReadAll()
+{
+ var db = dbGetHandle()
+ db.transaction(function (tx) {
+ var results = tx.executeSql(
+ 'SELECT rowid,date,trip_desc,distance FROM trip_log order by rowid desc')
+ for (var i = 0; i < results.rows.length; i++) {
+ listModel.append({
+ id: results.rows.item(i).rowid,
+ checked: " ",
+ date: results.rows.item(i).date,
+ trip_desc: results.rows.item(i).trip_desc,
+ distance: results.rows.item(i).distance
+ })
+ }
+ })
+}
+
+function dbUpdate(Pdate, Pdesc, Pdistance, Prowid)
+{
+ var db = dbGetHandle()
+ db.transaction(function (tx) {
+ tx.executeSql(
+ 'update trip_log set date=?, trip_desc=?, distance=? where rowid = ?', [Pdate, Pdesc, Pdistance, Prowid])
+ })
+}
+
+function dbDeleteRow(Prowid)
+{
+ var db = dbGetHandle()
+ db.transaction(function (tx) {
+ tx.executeSql('delete from trip_log where rowid = ?', [Prowid])
+ })
+}
diff --git a/examples/quick/localstorage/localstorage/Header.qml b/examples/quick/localstorage/localstorage/Header.qml
new file mode 100644
index 0000000000..a08645a170
--- /dev/null
+++ b/examples/quick/localstorage/localstorage/Header.qml
@@ -0,0 +1,173 @@
+
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.7
+import QtQuick.Window 2.0
+import QtQuick.LocalStorage 2.0
+import "Database.js" as JS
+import QtQuick.Layouts 1.1
+
+Item {
+ id: root
+ width: Screen.width / 2
+ height: Screen.height / 7
+
+ function insertrec() {
+ var rowid = parseInt(JS.dbInsert(dateInput.text, descInput.text, distInput.text), 10)
+ if (rowid) {
+ listView.model.setProperty(listView.currentIndex, "id", rowid)
+ listView.forceLayout()
+ }
+ return rowid;
+ }
+
+ function editrec(Pdate, Pdesc, Pdistance, Prowid) {
+ dateInput.text = Pdate
+ descInput.text = Pdesc
+ distInput.text = Pdistance
+ }
+
+ function initrec_new() {
+ dateInput.clear()
+ descInput.clear()
+ distInput.clear()
+ listView.model.insert(0, {
+ date: "",
+ trip_desc: "",
+ distance: 0
+ })
+ listView.currentIndex = 0
+ dateInput.forceActiveFocus()
+ }
+
+ function initrec() {
+ dateInput.clear()
+ descInput.clear()
+ distInput.clear()
+ }
+
+ function setlistview() {
+ listView.model.setProperty(listView.currentIndex, "date",
+ dateInput.text)
+ listView.model.setProperty(listView.currentIndex, "trip_desc",
+ descInput.text)
+ listView.model.setProperty(listView.currentIndex, "distance",
+ parseInt(distInput.text,10))
+ }
+
+ Rectangle {
+ id: rootrect
+ border.width: 10
+ color: "#161616"
+
+ ColumnLayout {
+ id: mainLayout
+ anchors.fill: parent
+
+ Rectangle {
+ id: gridBox
+ Layout.fillWidth: true
+
+ GridLayout {
+ id: gridLayout
+ rows: 3
+ flow: GridLayout.TopToBottom
+ anchors.fill: parent
+
+ Text {
+ text: "Date"
+ font.pixelSize: 22
+ rightPadding: 10
+ }
+
+ Text {
+ text: "Description"
+ font.pixelSize: 22
+ rightPadding: 10
+ }
+
+ Text {
+ text: "Distance"
+ font.pixelSize: 22
+ }
+
+ TextInput {
+ id: dateInput
+ font.pixelSize: 22
+ activeFocusOnPress: true
+ activeFocusOnTab: true
+ validator: RegExpValidator {
+ regExp: /[0-9/,:.]+/
+ }
+ onEditingFinished: {
+ if (dateInput.text == "") {
+ statustext.text = "Please fill in the date"
+ dateInput.forceActiveFocus()
+ }
+ }
+ }
+
+ TextInput {
+ id: descInput
+ font.pixelSize: 22
+ activeFocusOnPress: true
+ activeFocusOnTab: true
+ onEditingFinished: {
+ if (descInput.text.length < 8) {
+ statustext.text = "Enter a description of minimum 8 characters"
+ descInput.forceActiveFocus()
+ } else {
+ statustext.text = ""
+ }
+ }
+ }
+
+ TextInput {
+ id: distInput
+ font.pixelSize: 22
+ activeFocusOnPress: true
+ activeFocusOnTab: true
+ validator: RegExpValidator {
+ regExp: /\d{1,3}/
+ }
+ onEditingFinished: {
+ if (distInput.text == "") {
+ statustext.text = "Please fill in the distance"
+ distInput.forceActiveFocus()
+ }
+ }
+ }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: dateInput.forceActiveFocus()
+ }
+ }
+ }
+}
diff --git a/examples/quick/localstorage/localstorage/MyButton.qml b/examples/quick/localstorage/localstorage/MyButton.qml
new file mode 100644
index 0000000000..4659b45f64
--- /dev/null
+++ b/examples/quick/localstorage/localstorage/MyButton.qml
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: button
+
+ property bool checked: false
+ property alias text: buttonText.text
+
+ Accessible.name: text
+ Accessible.description: "This button does " + text
+ Accessible.role: Accessible.Button
+ Accessible.onPressAction: button.clicked()
+
+ signal clicked
+
+ implicitWidth: buttonText.implicitWidth + 20
+ implicitHeight: 30
+ gradient: Gradient {
+ GradientStop {
+ position: 0.0
+ color: "grey"
+ }
+ GradientStop {
+ position: 1.0
+ color: button.focus ? "red" : "grey"
+ }
+ }
+
+ radius: 5
+ antialiasing: true
+
+ Text {
+ id: buttonText
+ text: parent.description
+ anchors.centerIn: parent
+ font.pixelSize: parent.height * .5
+ style: enabled ? Text.Sunken : Text.Normal
+ color: enabled ? "white" : "#555"
+ styleColor: "black"
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: parent.clicked()
+ }
+
+ Keys.onSpacePressed: clicked()
+}
diff --git a/examples/quick/localstorage/localstorage/MyDelegate.qml b/examples/quick/localstorage/localstorage/MyDelegate.qml
new file mode 100644
index 0000000000..9a4ac1cc46
--- /dev/null
+++ b/examples/quick/localstorage/localstorage/MyDelegate.qml
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.LocalStorage 2.0
+import QtQuick.Layouts 1.1
+import "Database.js" as JS
+
+Item {
+ width: parent.width
+ height: rDate.implicitHeight
+
+ Rectangle {
+ id: baseRec
+ anchors.fill: parent
+ opacity: 0.8
+ color: index % 2 ? "lightgrey" : "grey"
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: listView.currentIndex = index
+ }
+ GridLayout {
+ anchors.fill:parent
+ columns: 3
+
+ Text {
+ id: rDate
+ text: date
+ font.pixelSize: 22
+ Layout.preferredWidth: parent.width / 4
+ color: "black"
+ }
+ Text {
+ id: rDesc
+ text: trip_desc
+ Layout.fillWidth: true
+ font.pixelSize: 22
+ color: "black"
+ }
+ Text {
+ id: rDistance
+ text: distance
+ font.pixelSize: 22
+ Layout.alignment: Qt.AlignRight
+ color: "black"
+ }
+ }
+ }
+}
diff --git a/examples/quick/localstorage/localstorage/MyModel.qml b/examples/quick/localstorage/localstorage/MyModel.qml
new file mode 100644
index 0000000000..0677ec74d6
--- /dev/null
+++ b/examples/quick/localstorage/localstorage/MyModel.qml
@@ -0,0 +1,35 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.LocalStorage 2.0
+import "Database.js" as JS
+
+ListModel {
+ id: listModel
+ Component.onCompleted: JS.dbReadAll()
+}
diff --git a/examples/quick/localstorage/localstorage/localstorage.qml b/examples/quick/localstorage/localstorage/localstorage.qml
index 61e9eff8b6..b85fad4764 100644
--- a/examples/quick/localstorage/localstorage/localstorage.qml
+++ b/examples/quick/localstorage/localstorage/localstorage.qml
@@ -1,54 +1,183 @@
- /****************************************************************************
+/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2016 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the documentation of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import "../../shared" as Examples
+import QtQuick 2.5
+import QtQuick.Window 2.2
+import QtQuick.Layouts 1.1
+import QtQuick.LocalStorage 2.0
+import "Database.js" as JS
+
+Window {
+ visible: true
+ width: Screen.width / 2
+ height: Screen.height / 1.8
+ color: "#161616"
-Item {
- height: 480
- width: 320
- Examples.LauncherList {
- id: ll
+ property bool creatingNewEntry: false
+ property bool editingEntry: false
+
+ Rectangle {
anchors.fill: parent
- Component.onCompleted: {
- addExample("Hello World", "Simple SQL operations with local storage API", Qt.resolvedUrl("hello.qml"));
+
+ ColumnLayout {
+ anchors.fill: parent
+
+ Header {
+ id: input
+ Layout.fillWidth: true
+ }
+ RowLayout {
+ MyButton {
+ text: "New"
+ onClicked: {
+ input.initrec_new()
+ creatingNewEntry = true
+ listView.model.setProperty(listView.currentIndex, "id", 0)
+ }
+ }
+ MyButton {
+ id: saveButton
+ enabled: (creatingNewEntry || editingEntry) && listView.currentIndex != -1
+ text: "Save"
+ onClicked: {
+ var insertedRow = false;
+ if (listView.model.get(listView.currentIndex).id < 1) {
+ //insert mode
+ if (input.insertrec()) {
+ // Successfully inserted a row.
+ input.setlistview()
+ insertedRow = true
+ } else {
+ // Failed to insert a row; display an error message.
+ statustext.text = "Failed to insert row"
+ }
+ } else {
+ // edit mode
+ input.setlistview()
+ JS.dbUpdate(listView.model.get(listView.currentIndex).date,
+ listView.model.get(listView.currentIndex).trip_desc,
+ listView.model.get(listView.currentIndex).distance,
+ listView.model.get(listView.currentIndex).id)
+ }
+
+ if (insertedRow) {
+ input.initrec()
+ creatingNewEntry = false
+ editingEntry = false
+ listView.forceLayout()
+ }
+ }
+ }
+ MyButton {
+ id: editButton
+ text: "Edit"
+ enabled: !creatingNewEntry && !editingEntry && listView.currentIndex != -1
+ onClicked: {
+ input.editrec(listView.model.get(listView.currentIndex).date,
+ listView.model.get(listView.currentIndex).trip_desc,
+ listView.model.get(listView.currentIndex).distance,
+ listView.model.get(listView.currentIndex).id)
+
+ editingEntry = true
+ }
+ }
+ MyButton {
+ id: deleteButton
+ text: "Delete"
+ enabled: !creatingNewEntry && listView.currentIndex != -1
+ onClicked: {
+ JS.dbDeleteRow(listView.model.get(listView.currentIndex).id)
+ listView.model.remove(listView.currentIndex, 1)
+ if (listView.count == 0) {
+ // ListView doesn't automatically set its currentIndex to -1
+ // when the count becomes 0.
+ listView.currentIndex = -1
+ }
+ }
+ }
+ MyButton {
+ id: cancelButton
+ text: "Cancel"
+ enabled: (creatingNewEntry || editingEntry) && listView.currentIndex != -1
+ onClicked: {
+ if (listView.model.get(listView.currentIndex).id === 0) {
+ // This entry had an id of 0, which means it was being created and hadn't
+ // been saved to the database yet, so we can safely remove it from the model.
+ listView.model.remove(listView.currentIndex, 1)
+ }
+ listView.forceLayout()
+ creatingNewEntry = false
+ editingEntry = false
+ input.initrec()
+ }
+ }
+ MyButton {
+ text: "Exit"
+ onClicked: Qt.quit()
+ }
+ }
+ Component {
+ id: highlightBar
+ Rectangle {
+ width: listView.currentItem.width
+ height: listView.currentItem.height
+ color: "lightgreen"
+ }
+ }
+ ListView {
+ id: listView
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ model: MyModel {}
+ delegate: MyDelegate {}
+ // Don't allow changing the currentIndex while the user is creating/editing values.
+ enabled: !creatingNewEntry && !editingEntry
+
+ highlight: highlightBar
+ highlightFollowsCurrentItem: true
+ focus: true
+
+ header: Component {
+ Text {
+ text: "Saved activities"
+ }
+ }
+ }
+ Text {
+ id: statustext
+ color: "red"
+ Layout.fillWidth: true
+ font.bold: true
+ font.pointSize: 20
+
+ }
}
}
+ Component.onCompleted: {
+ JS.dbInit()
+ }
}
diff --git a/examples/quick/localstorage/localstorage/localstorage.qmlproject b/examples/quick/localstorage/localstorage/localstorage.qmlproject
deleted file mode 100644
index 6835d23503..0000000000
--- a/examples/quick/localstorage/localstorage/localstorage.qmlproject
+++ /dev/null
@@ -1,16 +0,0 @@
-import QmlProject 1.0
-
-Project {
- mainFile: "localstorage.qml"
- /* Include .qml, .js, and image files from current directory and subdirectories */
-
- QmlFiles {
- directory: "."
- }
- JavaScriptFiles {
- directory: "."
- }
- ImageFiles {
- directory: "."
- }
-} \ No newline at end of file
diff --git a/examples/quick/localstorage/localstorage/localstorage.qrc b/examples/quick/localstorage/localstorage/localstorage.qrc
index 09ac2de033..079438be2b 100644
--- a/examples/quick/localstorage/localstorage/localstorage.qrc
+++ b/examples/quick/localstorage/localstorage/localstorage.qrc
@@ -1,6 +1,10 @@
<RCC>
- <qresource prefix="/localstorage/localstorage">
- <file>hello.qml</file>
+ <qresource prefix="/">
+ <file>Header.qml</file>
+ <file>Database.js</file>
+ <file>MyModel.qml</file>
+ <file>MyButton.qml</file>
+ <file>MyDelegate.qml</file>
<file>localstorage.qml</file>
</qresource>
</RCC>
diff --git a/examples/quick/localstorage/localstorage/main.cpp b/examples/quick/localstorage/localstorage/main.cpp
index 6e522753e9..9f8adbb7a5 100644
--- a/examples/quick/localstorage/localstorage/main.cpp
+++ b/examples/quick/localstorage/localstorage/main.cpp
@@ -1,41 +1,38 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2016 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "../../shared/shared.h"
-DECLARATIVE_EXAMPLE_MAIN(localstorage/localstorage/localstorage)
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/localstorage.qml")));
+
+ return app.exec();
+}
diff --git a/examples/quick/localstorage/localstorage/qml-localstorage-example.png b/examples/quick/localstorage/localstorage/qml-localstorage-example.png
new file mode 100644
index 0000000000..7d7edafe63
--- /dev/null
+++ b/examples/quick/localstorage/localstorage/qml-localstorage-example.png
Binary files differ
diff --git a/examples/quick/positioners/positioners-attachedproperties.qml b/examples/quick/positioners/positioners-attachedproperties.qml
index ac2c76db47..e7fa59bb9a 100644
--- a/examples/quick/positioners/positioners-attachedproperties.qml
+++ b/examples/quick/positioners/positioners-attachedproperties.qml
@@ -66,14 +66,14 @@ Rectangle {
anchors.left: parent.left
anchors.leftMargin: page.width / 32
anchors.topMargin: page.height / 48
- spacing: elementSpacing
+ spacing: page.elementSpacing
//! [0]
Rectangle {
id: green
color: "#80c342"
- width: 100 * ratio
- height: 100 * ratio
+ width: 100 * page.ratio
+ height: 100 * page.ratio
Text {
anchors.left: parent.right
@@ -95,8 +95,8 @@ Rectangle {
Rectangle {
id: blue
color: "#14aaff"
- width: 100 * ratio
- height: 100 * ratio
+ width: 100 * page.ratio
+ height: 100 * page.ratio
Text {
anchors.left: parent.right
@@ -117,8 +117,8 @@ Rectangle {
Rectangle {
id: purple
color: "#6400aa"
- width: 100 * ratio
- height: 100 * ratio
+ width: 100 * page.ratio
+ height: 100 * page.ratio
Text {
anchors.left: parent.right
@@ -140,8 +140,8 @@ Rectangle {
Rectangle {
id: hidingRect
color: "#006325"
- width: 100 * ratio
- height: 100 * ratio
+ width: 100 * page.ratio
+ height: 100 * page.ratio
visible: false
Text {
diff --git a/examples/quick/positioners/positioners-transitions.qml b/examples/quick/positioners/positioners-transitions.qml
index 0d283f7301..17fe41a7e2 100644
--- a/examples/quick/positioners/positioners-transitions.qml
+++ b/examples/quick/positioners/positioners-transitions.qml
@@ -55,7 +55,7 @@ Item {
interval: 2000
running: true
repeat: true
- onTriggered: effectiveOpacity = (effectiveOpacity == 1.0 ? 0.0 : 1.0);
+ onTriggered: page.effectiveOpacity = (page.effectiveOpacity == 1.0 ? 0.0 : 1.0);
}
Column {
@@ -65,7 +65,7 @@ Item {
top: parent.top
topMargin: page.height / 48
}
- spacing: elementSpacing
+ spacing: page.elementSpacing
populate: Transition {
NumberAnimation { properties: "x,y"; from: 200; duration: 100; easing.type: Easing.OutBounce }
@@ -77,32 +77,32 @@ Item {
NumberAnimation { properties: "y"; easing.type: Easing.OutBounce }
}
- Rectangle { color: "#80c342"; width: bigSize; height: smallSize }
+ Rectangle { color: "#80c342"; width: page.bigSize; height: page.smallSize }
Rectangle {
id: greenV1
visible: opacity != 0
- width: bigSize; height: smallSize
+ width: page.bigSize; height: page.smallSize
color: "#006325"
border.color: "transparent"
Behavior on opacity { NumberAnimation {} }
- opacity: effectiveOpacity
+ opacity: page.effectiveOpacity
}
- Rectangle { color: "#14aaff"; width: bigSize; height: smallSize }
+ Rectangle { color: "#14aaff"; width: page.bigSize; height: page.smallSize }
Rectangle {
id: greenV2
visible: opacity != 0
- width: bigSize; height: smallSize
+ width: page.bigSize; height: page.smallSize
color: "#006325"
border.color: "transparent"
Behavior on opacity { NumberAnimation {} }
- opacity: effectiveOpacity
+ opacity: page.effectiveOpacity
}
- Rectangle { color: "#6400aa"; width: bigSize; height: smallSize }
- Rectangle { color: "#80c342"; width: bigSize; height: smallSize }
+ Rectangle { color: "#6400aa"; width: page.bigSize; height: page.smallSize }
+ Rectangle { color: "#80c342"; width: page.bigSize; height: page.smallSize }
}
Row {
@@ -112,7 +112,7 @@ Item {
bottom: page.bottom
bottomMargin: page.height / 48
}
- spacing: elementSpacing
+ spacing: page.elementSpacing
populate: Transition {
NumberAnimation { properties: "x,y"; from: 200; duration: 100; easing.type: Easing.OutBounce }
@@ -124,40 +124,40 @@ Item {
NumberAnimation { properties: "x"; easing.type: Easing.OutBounce }
}
- Rectangle { color: "#80c342"; width: smallSize; height: bigSize }
+ Rectangle { color: "#80c342"; width: page.smallSize; height: page.bigSize }
Rectangle {
id: blueH1
visible: opacity != 0
- width: smallSize; height: bigSize
+ width: page.smallSize; height: page.bigSize
color: "#006325"
border.color: "transparent"
Behavior on opacity { NumberAnimation {} }
- opacity: effectiveOpacity
+ opacity: page.effectiveOpacity
}
- Rectangle { color: "#14aaff"; width: smallSize; height: bigSize }
+ Rectangle { color: "#14aaff"; width: page.smallSize; height: page.bigSize }
Rectangle {
id: greenH2
visible: opacity != 0
- width: smallSize; height: bigSize
+ width: page.smallSize; height: page.bigSize
color: "#006325"
border.color: "transparent"
Behavior on opacity { NumberAnimation {} }
- opacity: effectiveOpacity
+ opacity: page.effectiveOpacity
}
- Rectangle { color: "#6400aa"; width: smallSize; height: bigSize }
- Rectangle { color: "#80c342"; width: smallSize; height: bigSize }
+ Rectangle { color: "#6400aa"; width: page.smallSize; height: page.bigSize }
+ Rectangle { color: "#80c342"; width: page.smallSize; height: page.bigSize }
}
Grid {
anchors.top: parent.top
anchors.topMargin: page.height / 48
- anchors.left: flow.left
+ anchors.left: flowItem.left
columns: 3
- spacing: elementSpacing
+ spacing: page.elementSpacing
populate: Transition {
NumberAnimation { properties: "x,y"; from: 200; duration: 100; easing.type: Easing.OutBounce }
@@ -169,55 +169,55 @@ Item {
NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce }
}
- Rectangle { color: "#80c342"; width: smallSize; height: smallSize }
+ Rectangle { color: "#80c342"; width: page.smallSize; height: page.smallSize }
Rectangle {
id: greenG1
visible: opacity != 0
- width: smallSize; height: smallSize
+ width: page.smallSize; height: page.smallSize
color: "#006325"
border.color: "transparent"
Behavior on opacity { NumberAnimation {} }
- opacity: effectiveOpacity
+ opacity: page.effectiveOpacity
}
- Rectangle { color: "#14aaff"; width: smallSize; height: smallSize }
+ Rectangle { color: "#14aaff"; width: page.smallSize; height: page.smallSize }
Rectangle {
id: greenG2
visible: opacity != 0
- width: smallSize; height: smallSize
+ width: page.smallSize; height:page. smallSize
color: "#006325"
border.color: "transparent"
Behavior on opacity { NumberAnimation {} }
- opacity: effectiveOpacity
+ opacity: page.effectiveOpacity
}
- Rectangle { color: "#6400aa"; width: smallSize; height: smallSize }
+ Rectangle { color: "#6400aa"; width: page.smallSize; height: page.smallSize }
Rectangle {
id: greenG3
visible: opacity != 0
- width: smallSize; height: smallSize
+ width: page.smallSize; height: page.smallSize
color: "#006325"
border.color: "transparent"
Behavior on opacity { NumberAnimation {} }
- opacity: effectiveOpacity
+ opacity: page.effectiveOpacity
}
- Rectangle { color: "#80c342"; width: smallSize; height: smallSize }
- Rectangle { color: "#14aaff"; width: smallSize; height: smallSize }
- Rectangle { color: "#6400aa"; width: smallSize; height: smallSize }
+ Rectangle { color: "#80c342"; width:page. smallSize; height: page.smallSize }
+ Rectangle { color: "#14aaff"; width: smallSize; height: page.smallSize }
+ Rectangle { color: "#6400aa"; width: page.page.smallSize; height: page.smallSize }
}
Flow {
- id: flow
+ id: flowItem
anchors.right: page.right
anchors.rightMargin: page.width / 32
- y: 2 * bigSize
- width: 1.8 * bigSize
- spacing: elementSpacing
+ y: 2 * page.bigSize
+ width: 1.8 * page.bigSize
+ spacing: page.elementSpacing
//! [move]
move: Transition {
@@ -237,42 +237,42 @@ Item {
}
//! [populate]
- Rectangle { color: "#80c342"; width: smallSize; height: smallSize }
+ Rectangle { color: "#80c342"; width: page.smallSize; height: page.smallSize }
Rectangle {
id: greenF1
visible: opacity != 0
- width: 0.6 * bigSize; height: smallSize
+ width: 0.6 * page.bigSize; height: page.smallSize
color: "#006325"
border.color: "transparent"
Behavior on opacity { NumberAnimation {} }
- opacity: effectiveOpacity
+ opacity: page.effectiveOpacity
}
- Rectangle { color: "#14aaff"; width: 0.3 * bigSize; height: smallSize }
+ Rectangle { color: "#14aaff"; width: 0.3 * page.bigSize; height: page.smallSize }
Rectangle {
id: greenF2
visible: opacity != 0
- width: 0.6 * bigSize; height: smallSize
+ width: 0.6 * page.bigSize; height: page.smallSize
color: "#006325"
border.color: "transparent"
Behavior on opacity { NumberAnimation {} }
- opacity: effectiveOpacity
+ opacity: page.effectiveOpacity
}
- Rectangle { color: "#6400aa"; width: smallSize; height: smallSize }
+ Rectangle { color: "#6400aa"; width: page.smallSize; height: page.smallSize }
Rectangle {
id: greenF3
visible: opacity != 0
- width: 0.4 * bigSize; height: smallSize
+ width: 0.4 * page.bigSize; height: page.smallSize
color: "#006325"
border.color: "transparent"
Behavior on opacity { NumberAnimation {} }
- opacity: effectiveOpacity
+ opacity: page.effectiveOpacity
}
- Rectangle { color: "#80c342"; width: 0.8 * bigSize; height: smallSize }
+ Rectangle { color: "#80c342"; width: 0.8 * page.bigSize; height: page.smallSize }
}
}
diff --git a/examples/quick/quickwidgets/qquickviewcomparison/fbitem.cpp b/examples/quick/quickwidgets/qquickviewcomparison/fbitem.cpp
index c5924bf159..49c4450b89 100644
--- a/examples/quick/quickwidgets/qquickviewcomparison/fbitem.cpp
+++ b/examples/quick/quickwidgets/qquickviewcomparison/fbitem.cpp
@@ -263,8 +263,8 @@ static const char *fragmentShaderSource =
void FbItemRenderer::initProgram()
{
m_program.reset(new QOpenGLShaderProgram);
- m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource);
- m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource);
+ m_program->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource);
+ m_program->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource);
m_program->bindAttributeLocation("vertex", 0);
m_program->bindAttributeLocation("normal", 1);
m_program->link();
diff --git a/examples/quick/quickwidgets/quickwidget/fbitem.cpp b/examples/quick/quickwidgets/quickwidget/fbitem.cpp
index fc2a4ea7ad..cb3cc976fb 100644
--- a/examples/quick/quickwidgets/quickwidget/fbitem.cpp
+++ b/examples/quick/quickwidgets/quickwidget/fbitem.cpp
@@ -44,7 +44,7 @@
#include <QtGui/QOpenGLFunctions>
#include <QtCore/QDebug>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
class FbRenderer : public QQuickFramebufferObject::Renderer
{
public:
@@ -82,7 +82,7 @@ private:
QQuickFramebufferObject::Renderer *FbItem::createRenderer() const
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
return new FbRenderer;
#else
return nullptr;
diff --git a/examples/quick/rendercontrol/cuberenderer.cpp b/examples/quick/rendercontrol/cuberenderer.cpp
index 1b2d7dec8f..4651882542 100644
--- a/examples/quick/rendercontrol/cuberenderer.cpp
+++ b/examples/quick/rendercontrol/cuberenderer.cpp
@@ -101,8 +101,8 @@ void CubeRenderer::init(QWindow *w, QOpenGLContext *share)
" gl_FragColor = vec4(texture2D(sampler, v_coord).rgb, 1.0);\n"
"}\n";
m_program = new QOpenGLShaderProgram;
- m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource);
- m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource);
+ m_program->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource);
+ m_program->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource);
m_program->bindAttributeLocation("vertex", 0);
m_program->bindAttributeLocation("coord", 1);
m_program->link();
diff --git a/examples/quick/scenegraph/openglunderqml/squircle.cpp b/examples/quick/scenegraph/openglunderqml/squircle.cpp
index 6b25756e61..b7082892b8 100644
--- a/examples/quick/scenegraph/openglunderqml/squircle.cpp
+++ b/examples/quick/scenegraph/openglunderqml/squircle.cpp
@@ -125,22 +125,22 @@ void SquircleRenderer::paint()
initializeOpenGLFunctions();
m_program = new QOpenGLShaderProgram();
- m_program->addShaderFromSourceCode(QOpenGLShader::Vertex,
- "attribute highp vec4 vertices;"
- "varying highp vec2 coords;"
- "void main() {"
- " gl_Position = vertices;"
- " coords = vertices.xy;"
- "}");
- m_program->addShaderFromSourceCode(QOpenGLShader::Fragment,
- "uniform lowp float t;"
- "varying highp vec2 coords;"
- "void main() {"
- " lowp float i = 1. - (pow(abs(coords.x), 4.) + pow(abs(coords.y), 4.));"
- " i = smoothstep(t - 0.8, t + 0.8, i);"
- " i = floor(i * 20.) / 20.;"
- " gl_FragColor = vec4(coords * .5 + .5, i, i);"
- "}");
+ m_program->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex,
+ "attribute highp vec4 vertices;"
+ "varying highp vec2 coords;"
+ "void main() {"
+ " gl_Position = vertices;"
+ " coords = vertices.xy;"
+ "}");
+ m_program->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment,
+ "uniform lowp float t;"
+ "varying highp vec2 coords;"
+ "void main() {"
+ " lowp float i = 1. - (pow(abs(coords.x), 4.) + pow(abs(coords.y), 4.));"
+ " i = smoothstep(t - 0.8, t + 0.8, i);"
+ " i = floor(i * 20.) / 20.;"
+ " gl_FragColor = vec4(coords * .5 + .5, i, i);"
+ "}");
m_program->bindAttributeLocation("vertices", 0);
m_program->link();
diff --git a/examples/quick/scenegraph/rendernode/customrenderitem.cpp b/examples/quick/scenegraph/rendernode/customrenderitem.cpp
index a92a400922..27c55bf86d 100644
--- a/examples/quick/scenegraph/rendernode/customrenderitem.cpp
+++ b/examples/quick/scenegraph/rendernode/customrenderitem.cpp
@@ -62,7 +62,7 @@ QSGNode *CustomRenderItem::updatePaintNode(QSGNode *node, UpdatePaintNodeData *)
return nullptr;
switch (ri->graphicsApi()) {
case QSGRendererInterface::OpenGL:
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
n = new OpenGLRenderNode(this);
break;
#endif
diff --git a/examples/quick/scenegraph/rendernode/d3d12renderer.cpp b/examples/quick/scenegraph/rendernode/d3d12renderer.cpp
index 3b377f1cb1..9916769241 100644
--- a/examples/quick/scenegraph/rendernode/d3d12renderer.cpp
+++ b/examples/quick/scenegraph/rendernode/d3d12renderer.cpp
@@ -42,12 +42,10 @@
#include <QQuickItem>
#include <QQuickWindow>
#include <QSGRendererInterface>
+#include <QFile>
#if QT_CONFIG(d3d12)
-#include "vs_shader.hlslh"
-#include "ps_shader.hlslh"
-
D3D12RenderNode::D3D12RenderNode(QQuickItem *item)
: m_item(item)
{
@@ -78,7 +76,7 @@ void D3D12RenderNode::releaseResources()
void D3D12RenderNode::init()
{
QSGRendererInterface *rif = m_item->window()->rendererInterface();
- m_device = static_cast<ID3D12Device *>(rif->getResource(m_item->window(), QSGRendererInterface::Device));
+ m_device = static_cast<ID3D12Device *>(rif->getResource(m_item->window(), QSGRendererInterface::DeviceResource));
Q_ASSERT(m_device);
D3D12_ROOT_PARAMETER rootParameter;
@@ -111,12 +109,25 @@ void D3D12RenderNode::init()
{ "COLOR", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 8, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }
};
+ QFile f(QStringLiteral(":/scenegraph/rendernode/shader_vert.cso"));
+ if (!f.open(QIODevice::ReadOnly)) {
+ qWarning("Failed to open file with vertex shader bytecode");
+ return;
+ }
+ QByteArray vshader_cso = f.readAll();
+ f.close();
+ f.setFileName(QStringLiteral(":/scenegraph/rendernode/shader_frag.cso"));
+ if (!f.open(QIODevice::ReadOnly)) {
+ qWarning("Failed to open file with fragment shader bytecode");
+ return;
+ }
+ QByteArray fshader_cso = f.readAll();
D3D12_SHADER_BYTECODE vshader;
- vshader.pShaderBytecode = g_VS_Simple;
- vshader.BytecodeLength = sizeof(g_VS_Simple);
+ vshader.pShaderBytecode = vshader_cso.constData();
+ vshader.BytecodeLength = vshader_cso.size();
D3D12_SHADER_BYTECODE pshader;
- pshader.pShaderBytecode = g_PS_Simple;
- pshader.BytecodeLength = sizeof(g_PS_Simple);
+ pshader.pShaderBytecode = fshader_cso.constData();
+ pshader.BytecodeLength = fshader_cso.size();
D3D12_RASTERIZER_DESC rastDesc = {};
rastDesc.FillMode = D3D12_FILL_MODE_SOLID;
@@ -235,7 +246,8 @@ void D3D12RenderNode::render(const RenderState *state)
init();
QSGRendererInterface *rif = m_item->window()->rendererInterface();
- ID3D12GraphicsCommandList *commandList = static_cast<ID3D12GraphicsCommandList *>(rif->getResource(m_item->window(), QSGRendererInterface::CommandList));
+ ID3D12GraphicsCommandList *commandList = static_cast<ID3D12GraphicsCommandList *>(
+ rif->getResource(m_item->window(), QSGRendererInterface::CommandListResource));
Q_ASSERT(commandList);
const int msize = 16 * sizeof(float);
diff --git a/examples/quick/scenegraph/rendernode/openglrenderer.cpp b/examples/quick/scenegraph/rendernode/openglrenderer.cpp
index 3de864b7b9..c84867797d 100644
--- a/examples/quick/scenegraph/rendernode/openglrenderer.cpp
+++ b/examples/quick/scenegraph/rendernode/openglrenderer.cpp
@@ -41,7 +41,7 @@
#include "openglrenderer.h"
#include <QQuickItem>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
#include <QOpenGLShaderProgram>
#include <QOpenGLBuffer>
@@ -86,8 +86,8 @@ void OpenGLRenderNode::init()
" gl_FragColor = col * opacity;\n"
"}\n";
- m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource);
- m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource);
+ m_program->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource);
+ m_program->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource);
m_program->bindAttributeLocation("posAttr", 0);
m_program->bindAttributeLocation("colAttr", 1);
m_program->link();
@@ -161,4 +161,4 @@ QRectF OpenGLRenderNode::rect() const
return QRect(0, 0, m_item->width(), m_item->height());
}
-#endif // QT_NO_OPENGL
+#endif // opengl
diff --git a/examples/quick/scenegraph/rendernode/openglrenderer.h b/examples/quick/scenegraph/rendernode/openglrenderer.h
index 92cc2bc72b..ea2bbcbc38 100644
--- a/examples/quick/scenegraph/rendernode/openglrenderer.h
+++ b/examples/quick/scenegraph/rendernode/openglrenderer.h
@@ -43,7 +43,7 @@
#include <qsgrendernode.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QT_BEGIN_NAMESPACE
@@ -75,6 +75,6 @@ private:
QT_END_NAMESPACE
-#endif // QT_NO_OPENGL
+#endif // opengl
#endif
diff --git a/examples/quick/scenegraph/rendernode/rendernode.pro b/examples/quick/scenegraph/rendernode/rendernode.pro
index 968902a5be..76e498042b 100644
--- a/examples/quick/scenegraph/rendernode/rendernode.pro
+++ b/examples/quick/scenegraph/rendernode/rendernode.pro
@@ -15,24 +15,10 @@ target.path = $$[QT_INSTALL_EXAMPLES]/quick/scenegraph/rendernode
INSTALLS += target
OTHER_FILES += \
- main.qml \
- shader.hlsl
+ main.qml
qtConfig(d3d12) {
HEADERS += d3d12renderer.h
SOURCES += d3d12renderer.cpp
LIBS += -ld3d12
-
- VSPS = shader.hlsl
- vshader.input = VSPS
- vshader.header = vs_shader.hlslh
- vshader.entry = VS_Simple
- vshader.type = vs_5_0
- pshader.input = VSPS
- pshader.header = ps_shader.hlslh
- pshader.entry = PS_Simple
- pshader.type = ps_5_0
-
- HLSL_SHADERS = vshader pshader
- load(hlsl_bytecode_header)
}
diff --git a/examples/quick/scenegraph/rendernode/rendernode.qrc b/examples/quick/scenegraph/rendernode/rendernode.qrc
index 3674baccd8..049adcf8a6 100644
--- a/examples/quick/scenegraph/rendernode/rendernode.qrc
+++ b/examples/quick/scenegraph/rendernode/rendernode.qrc
@@ -1,5 +1,7 @@
<RCC>
<qresource prefix="/scenegraph/rendernode">
<file>main.qml</file>
+ <file>shader_vert.cso</file>
+ <file>shader_frag.cso</file>
</qresource>
</RCC>
diff --git a/examples/quick/scenegraph/rendernode/shader_frag.cso b/examples/quick/scenegraph/rendernode/shader_frag.cso
new file mode 100644
index 0000000000..686c6af3fc
--- /dev/null
+++ b/examples/quick/scenegraph/rendernode/shader_frag.cso
Binary files differ
diff --git a/examples/quick/scenegraph/rendernode/shader_vert.cso b/examples/quick/scenegraph/rendernode/shader_vert.cso
new file mode 100644
index 0000000000..fa13be5160
--- /dev/null
+++ b/examples/quick/scenegraph/rendernode/shader_vert.cso
Binary files differ
diff --git a/examples/quick/scenegraph/rendernode/softwarerenderer.cpp b/examples/quick/scenegraph/rendernode/softwarerenderer.cpp
index 06e406874a..d303b9ef13 100644
--- a/examples/quick/scenegraph/rendernode/softwarerenderer.cpp
+++ b/examples/quick/scenegraph/rendernode/softwarerenderer.cpp
@@ -61,7 +61,7 @@ void SoftwareRenderNode::releaseResources()
void SoftwareRenderNode::render(const RenderState *renderState)
{
QSGRendererInterface *rif = m_item->window()->rendererInterface();
- QPainter *p = static_cast<QPainter *>(rif->getResource(m_item->window(), QSGRendererInterface::Painter));
+ QPainter *p = static_cast<QPainter *>(rif->getResource(m_item->window(), QSGRendererInterface::PainterResource));
Q_ASSERT(p);
p->setTransform(matrix()->toTransform());
diff --git a/examples/quick/scenegraph/scenegraph.pro b/examples/quick/scenegraph/scenegraph.pro
index e13e8198b0..2efeb5ed83 100644
--- a/examples/quick/scenegraph/scenegraph.pro
+++ b/examples/quick/scenegraph/scenegraph.pro
@@ -7,7 +7,6 @@ qtConfig(opengl(es1|es2)?) {
sgengine \
textureinsgnode \
openglunderqml \
- textureinsgnode \
textureinthread \
twotextureproviders
}
diff --git a/examples/quick/scenegraph/shared/logorenderer.cpp b/examples/quick/scenegraph/shared/logorenderer.cpp
index 06f4892a49..8eb2d44c1e 100644
--- a/examples/quick/scenegraph/shared/logorenderer.cpp
+++ b/examples/quick/scenegraph/shared/logorenderer.cpp
@@ -70,7 +70,6 @@ void LogoRenderer::initialize()
glClearColor(0.1f, 0.1f, 0.2f, 1.0f);
- QOpenGLShader *vshader1 = new QOpenGLShader(QOpenGLShader::Vertex, &program1);
const char *vsrc1 =
"attribute highp vec4 vertex;\n"
"attribute mediump vec3 normal;\n"
@@ -85,19 +84,16 @@ void LogoRenderer::initialize()
" color = clamp(color, 0.0, 1.0);\n"
" gl_Position = matrix * vertex;\n"
"}\n";
- vshader1->compileSourceCode(vsrc1);
- QOpenGLShader *fshader1 = new QOpenGLShader(QOpenGLShader::Fragment, &program1);
const char *fsrc1 =
"varying mediump vec4 color;\n"
"void main(void)\n"
"{\n"
" gl_FragColor = color;\n"
"}\n";
- fshader1->compileSourceCode(fsrc1);
- program1.addShader(vshader1);
- program1.addShader(fshader1);
+ program1.addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, vsrc1);
+ program1.addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, fsrc1);
program1.link();
vertexAttr1 = program1.attributeLocation("vertex");
diff --git a/examples/quick/shared/shared.h b/examples/quick/shared/shared.h
index d8fb80b97e..0eed618d9d 100644
--- a/examples/quick/shared/shared.h
+++ b/examples/quick/shared/shared.h
@@ -44,6 +44,7 @@
#include <QQuickView> //Not using QQmlApplicationEngine because many examples don't have a Window{}
#define DECLARATIVE_EXAMPLE_MAIN(NAME) int main(int argc, char* argv[]) \
{\
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);\
QGuiApplication app(argc,argv);\
app.setOrganizationName("QtProject");\
app.setOrganizationDomain("qt-project.org");\
diff --git a/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp b/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp
index bbf11e4488..0c902c7172 100644
--- a/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp
+++ b/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp
@@ -191,6 +191,16 @@ void OSAllocator::releaseDecommitted(void* address, size_t bytes)
bool OSAllocator::canAllocateExecutableMemory()
{
+ int flags = MAP_PRIVATE | MAP_ANON;
+#if PLATFORM(IOS)
+ if (executable)
+ flags |= MAP_JIT;
+#endif
+ const auto size = pageSize();
+ void *testPage = mmap(nullptr, size, PROT_READ | PROT_WRITE | PROT_EXEC, flags, /*fd*/-1, /*offset*/0);
+ if (testPage == MAP_FAILED)
+ return false;
+ munmap(testPage, size);
return true;
}
diff --git a/src/imports/folderlistmodel/fileinfothread.cpp b/src/imports/folderlistmodel/fileinfothread.cpp
index 0b62935f87..d3e256bb7e 100644
--- a/src/imports/folderlistmodel/fileinfothread.cpp
+++ b/src/imports/folderlistmodel/fileinfothread.cpp
@@ -46,7 +46,7 @@
FileInfoThread::FileInfoThread(QObject *parent)
: QThread(parent),
abort(false),
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
watcher(0),
#endif
sortFlags(QDir::Name),
@@ -61,11 +61,11 @@ FileInfoThread::FileInfoThread(QObject *parent)
showOnlyReadable(false),
caseSensitive(true)
{
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
watcher = new QFileSystemWatcher(this);
connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(dirChanged(QString)));
connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString)));
-#endif // !QT_NO_FILESYSTEMWATCHER
+#endif // filesystemwatcher
}
FileInfoThread::~FileInfoThread()
@@ -80,7 +80,7 @@ FileInfoThread::~FileInfoThread()
void FileInfoThread::clear()
{
QMutexLocker locker(&mutex);
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
watcher->removePaths(watcher->files());
watcher->removePaths(watcher->directories());
#endif
@@ -89,7 +89,7 @@ void FileInfoThread::clear()
void FileInfoThread::removePath(const QString &path)
{
QMutexLocker locker(&mutex);
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
if (!path.startsWith(QLatin1Char(':')))
watcher->removePath(path);
#else
@@ -103,7 +103,7 @@ void FileInfoThread::setPath(const QString &path)
Q_ASSERT(!path.isEmpty());
QMutexLocker locker(&mutex);
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
if (!path.startsWith(QLatin1Char(':')))
watcher->addPath(path);
#endif
@@ -120,7 +120,7 @@ void FileInfoThread::setRootPath(const QString &path)
rootPath = path;
}
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
void FileInfoThread::dirChanged(const QString &directoryPath)
{
Q_UNUSED(directoryPath);
@@ -204,7 +204,7 @@ void FileInfoThread::setCaseSensitive(bool on)
condition.wakeAll();
}
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
void FileInfoThread::updateFile(const QString &path)
{
Q_UNUSED(path);
diff --git a/src/imports/folderlistmodel/fileinfothread_p.h b/src/imports/folderlistmodel/fileinfothread_p.h
index 56058fd6be..b505ece750 100644
--- a/src/imports/folderlistmodel/fileinfothread_p.h
+++ b/src/imports/folderlistmodel/fileinfothread_p.h
@@ -88,7 +88,7 @@ public:
void setCaseSensitive(bool on);
public Q_SLOTS:
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
void dirChanged(const QString &directoryPath);
void updateFile(const QString &path);
#endif
@@ -103,7 +103,7 @@ private:
QWaitCondition condition;
volatile bool abort;
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
QFileSystemWatcher *watcher;
#endif
QList<FileProperty> currentFileList;
diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp
index affde1c3aa..ef719109bd 100644
--- a/src/imports/folderlistmodel/plugin.cpp
+++ b/src/imports/folderlistmodel/plugin.cpp
@@ -62,12 +62,10 @@ public:
void registerTypes(const char *uri) Q_DECL_OVERRIDE
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.folderlistmodel"));
-#ifndef QT_NO_DIRMODEL
qmlRegisterType<QQuickFolderListModel>(uri,1,0,"FolderListModel");
qmlRegisterType<QQuickFolderListModel>(uri,2,0,"FolderListModel");
qmlRegisterType<QQuickFolderListModel,1>(uri,2,1,"FolderListModel");
qmlRegisterType<QQuickFolderListModel,2>(uri,2,2,"FolderListModel");
-#endif
}
};
//![class decl]
diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
index 1c94fddecf..fdcce9c685 100644
--- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
+++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
@@ -447,9 +447,9 @@ void QQuickFolderListModel::setFolder(const QUrl &folder)
/*!
\qmlproperty url FolderListModel::rootFolder
- When the rootFolder is set, then this folder will
- be threated as the root in the file system, so that
- you can only travers sub folders from this rootFolder.
+ When this property is set, the given folder will
+ be treated as the root in the file system, so that
+ you can only traverse subfolders within it.
*/
QUrl QQuickFolderListModel::rootFolder() const
{
diff --git a/src/imports/layouts/qquicklayout.cpp b/src/imports/layouts/qquicklayout.cpp
index 07ada75a5f..3786d21727 100644
--- a/src/imports/layouts/qquicklayout.cpp
+++ b/src/imports/layouts/qquicklayout.cpp
@@ -763,18 +763,14 @@ void QQuickLayout::itemChange(ItemChange change, const ItemChangeData &value)
{
if (change == ItemChildAddedChange) {
QQuickItem *item = value.item;
- qmlobject_connect(item, QQuickItem, SIGNAL(implicitWidthChanged()), this, QQuickLayout, SLOT(invalidateSenderItem()));
- qmlobject_connect(item, QQuickItem, SIGNAL(implicitHeightChanged()), this, QQuickLayout, SLOT(invalidateSenderItem()));
qmlobject_connect(item, QQuickItem, SIGNAL(baselineOffsetChanged(qreal)), this, QQuickLayout, SLOT(invalidateSenderItem()));
- QQuickItemPrivate::get(item)->addItemChangeListener(this, QQuickItemPrivate::SiblingOrder);
+ QQuickItemPrivate::get(item)->addItemChangeListener(this, QQuickItemPrivate::SiblingOrder | QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight | QQuickItemPrivate::Destroyed | QQuickItemPrivate::Visibility);
if (isReady())
updateLayoutItems();
} else if (change == ItemChildRemovedChange) {
QQuickItem *item = value.item;
- qmlobject_disconnect(item, QQuickItem, SIGNAL(implicitWidthChanged()), this, QQuickLayout, SLOT(invalidateSenderItem()));
- qmlobject_disconnect(item, QQuickItem, SIGNAL(implicitHeightChanged()), this, QQuickLayout, SLOT(invalidateSenderItem()));
qmlobject_disconnect(item, QQuickItem, SIGNAL(baselineOffsetChanged(qreal)), this, QQuickLayout, SLOT(invalidateSenderItem()));
- QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::SiblingOrder);
+ QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::SiblingOrder | QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight | QQuickItemPrivate::Destroyed | QQuickItemPrivate::Visibility);
if (isReady())
updateLayoutItems();
}
@@ -812,6 +808,30 @@ void QQuickLayout::itemSiblingOrderChanged(QQuickItem *item)
updateLayoutItems();
}
+void QQuickLayout::itemImplicitWidthChanged(QQuickItem *item)
+{
+ if (!isReady() || item->signalsBlocked())
+ return;
+ invalidate(item);
+}
+
+void QQuickLayout::itemImplicitHeightChanged(QQuickItem *item)
+{
+ if (!isReady() || item->signalsBlocked())
+ return;
+ invalidate(item);
+}
+
+void QQuickLayout::itemDestroyed(QQuickItem *item)
+{
+ Q_UNUSED(item);
+}
+
+void QQuickLayout::itemVisibilityChanged(QQuickItem *item)
+{
+ Q_UNUSED(item);
+}
+
void QQuickLayout::rearrange(const QSizeF &/*size*/)
{
m_dirty = false;
diff --git a/src/imports/layouts/qquicklayout_p.h b/src/imports/layouts/qquicklayout_p.h
index c7f04c1fed..eece6f8658 100644
--- a/src/imports/layouts/qquicklayout_p.h
+++ b/src/imports/layouts/qquicklayout_p.h
@@ -99,6 +99,10 @@ public:
/* QQuickItemChangeListener */
void itemSiblingOrderChanged(QQuickItem *item) Q_DECL_OVERRIDE;
+ void itemImplicitWidthChanged(QQuickItem *item) Q_DECL_OVERRIDE;
+ void itemImplicitHeightChanged(QQuickItem *item) Q_DECL_OVERRIDE;
+ void itemDestroyed(QQuickItem *item) Q_DECL_OVERRIDE;
+ void itemVisibilityChanged(QQuickItem *item) Q_DECL_OVERRIDE;
protected:
void updatePolish() Q_DECL_OVERRIDE;
diff --git a/src/imports/layouts/qquicklinearlayout.cpp b/src/imports/layouts/qquicklinearlayout.cpp
index 7fad395a29..13fdd496c2 100644
--- a/src/imports/layouts/qquicklinearlayout.cpp
+++ b/src/imports/layouts/qquicklinearlayout.cpp
@@ -303,17 +303,13 @@ QQuickGridLayoutBase::~QQuickGridLayoutBase()
{
Q_D(QQuickGridLayoutBase);
- /* Avoid messy deconstruction, should give:
- * Faster deconstruction
- * Less risk of signals reaching already deleted objects
- */
+ // Remove item listeners so we do not act on signalling unnecessarily
+ // (there is no point, as the layout will be torn down anyway).
for (int i = 0; i < itemCount(); ++i) {
QQuickItem *item = itemAt(i);
- qmlobject_disconnect(item, QQuickItem, SIGNAL(destroyed()), this, QQuickGridLayoutBase, SLOT(onItemDestroyed()));
- qmlobject_disconnect(item, QQuickItem, SIGNAL(visibleChanged()), this, QQuickGridLayoutBase, SLOT(onItemVisibleChanged()));
- qmlobject_disconnect(item, QQuickItem, SIGNAL(implicitWidthChanged()), this, QQuickGridLayoutBase, SLOT(invalidateSenderItem()));
- qmlobject_disconnect(item, QQuickItem, SIGNAL(implicitHeightChanged()), this, QQuickGridLayoutBase, SLOT(invalidateSenderItem()));
+ QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::SiblingOrder | QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight | QQuickItemPrivate::Destroyed | QQuickItemPrivate::Visibility);
}
+
delete d->styleInfo;
}
@@ -436,23 +432,6 @@ int QQuickGridLayoutBase::itemCount() const
return d->engine.itemCount();
}
-void QQuickGridLayoutBase::itemChange(ItemChange change, const ItemChangeData &value)
-{
- if (change == ItemChildAddedChange) {
- quickLayoutDebug() << "ItemChildAddedChange";
- QQuickItem *item = value.item;
- qmlobject_connect(item, QQuickItem, SIGNAL(destroyed()), this, QQuickGridLayoutBase, SLOT(onItemDestroyed()));
- qmlobject_connect(item, QQuickItem, SIGNAL(visibleChanged()), this, QQuickGridLayoutBase, SLOT(onItemVisibleChanged()));
- } else if (change == ItemChildRemovedChange) {
- quickLayoutDebug() << "ItemChildRemovedChange";
- QQuickItem *item = value.item;
- qmlobject_disconnect(item, QQuickItem, SIGNAL(destroyed()), this, QQuickGridLayoutBase, SLOT(onItemDestroyed()));
- qmlobject_disconnect(item, QQuickItem, SIGNAL(visibleChanged()), this, QQuickGridLayoutBase, SLOT(onItemVisibleChanged()));
- }
-
- QQuickLayout::itemChange(change, value);
-}
-
void QQuickGridLayoutBase::removeGridItem(QGridLayoutItem *gridItem)
{
Q_D(QQuickGridLayoutBase);
@@ -461,28 +440,29 @@ void QQuickGridLayoutBase::removeGridItem(QGridLayoutItem *gridItem)
d->engine.removeRows(index, 1, d->orientation);
}
-void QQuickGridLayoutBase::onItemVisibleChanged()
-{
- if (!isReady())
- return;
- quickLayoutDebug() << "QQuickGridLayoutBase::onItemVisibleChanged";
- updateLayoutItems();
-}
-
-void QQuickGridLayoutBase::onItemDestroyed()
+void QQuickGridLayoutBase::itemDestroyed(QQuickItem *item)
{
if (!isReady())
return;
Q_D(QQuickGridLayoutBase);
- quickLayoutDebug() << "QQuickGridLayoutBase::onItemDestroyed";
- QQuickItem *inDestruction = static_cast<QQuickItem *>(sender());
- if (QQuickGridLayoutItem *gridItem = d->engine.findLayoutItem(inDestruction)) {
+ quickLayoutDebug() << "QQuickGridLayoutBase::itemDestroyed";
+ if (QQuickGridLayoutItem *gridItem = d->engine.findLayoutItem(item)) {
removeGridItem(gridItem);
delete gridItem;
invalidate();
}
}
+void QQuickGridLayoutBase::itemVisibilityChanged(QQuickItem *item)
+{
+ Q_UNUSED(item);
+
+ if (!isReady())
+ return;
+ quickLayoutDebug() << "QQuickGridLayoutBase::itemVisibilityChanged";
+ updateLayoutItems();
+}
+
void QQuickGridLayoutBase::rearrange(const QSizeF &size)
{
Q_D(QQuickGridLayoutBase);
diff --git a/src/imports/layouts/qquicklinearlayout_p.h b/src/imports/layouts/qquicklinearlayout_p.h
index ca8b867824..b425df0fa4 100644
--- a/src/imports/layouts/qquicklinearlayout_p.h
+++ b/src/imports/layouts/qquicklinearlayout_p.h
@@ -77,6 +77,10 @@ public:
Qt::LayoutDirection effectiveLayoutDirection() const;
void setAlignment(QQuickItem *item, Qt::Alignment align) Q_DECL_OVERRIDE;
+ /* QQuickItemChangeListener */
+ void itemDestroyed(QQuickItem *item) Q_DECL_OVERRIDE;
+ void itemVisibilityChanged(QQuickItem *item) Q_DECL_OVERRIDE;
+
protected:
void updateLayoutItems() Q_DECL_OVERRIDE;
QQuickItem *itemAt(int index) const Q_DECL_OVERRIDE;
@@ -84,15 +88,10 @@ protected:
void rearrange(const QSizeF &size) Q_DECL_OVERRIDE;
virtual void insertLayoutItems() {}
- void itemChange(ItemChange change, const ItemChangeData &data) Q_DECL_OVERRIDE;
signals:
Q_REVISION(1) void layoutDirectionChanged();
-protected slots:
- void onItemVisibleChanged();
- void onItemDestroyed();
-
private:
void removeGridItem(QGridLayoutItem *gridItem);
Q_DECLARE_PRIVATE(QQuickGridLayoutBase)
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
index b8fd307215..ebffb07346 100644
--- a/src/imports/localstorage/plugin.cpp
+++ b/src/imports/localstorage/plugin.cpp
@@ -449,7 +449,7 @@ static ReturnedValue qmlsqldatabase_changeVersion(CallContext *ctx)
if (ok) {
*w->d()->version = to_version;
-#ifndef QT_NO_SETTINGS
+#if QT_CONFIG(settings)
QSettings ini(qmlsqldatabase_databaseFile(db.connectionName(), scope.engine) + QLatin1String(".ini"), QSettings::IniFormat);
ini.setValue(QLatin1String("Version"), to_version);
#endif
@@ -700,7 +700,7 @@ public:
void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args)
{
-#ifndef QT_NO_SETTINGS
+#if QT_CONFIG(settings)
QV4::Scope scope(args->v4engine());
if (scope.engine->qmlEngine()->offlineStoragePath().isEmpty())
V4THROW_SQL2(SQLEXCEPTION_DATABASE_ERR, QQmlEngine::tr("SQL: can't create database, offline storage is disabled."));
@@ -770,7 +770,7 @@ void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args)
}
args->setReturnValue(db.asReturnedValue());
-#endif // QT_NO_SETTINGS
+#endif // settings
}
static QObject *module_api_factory(QQmlEngine *engine, QJSEngine *scriptEngine)
diff --git a/src/imports/testlib/SignalSpy.qml b/src/imports/testlib/SignalSpy.qml
index 200fc725f7..8a8e844a21 100644
--- a/src/imports/testlib/SignalSpy.qml
+++ b/src/imports/testlib/SignalSpy.qml
@@ -230,8 +230,14 @@ Item {
qtest_prevSignalName = ""
}
if (target != null && signalName != "") {
- var handlerName = qtest_signalHandlerName(signalName)
- var func = target[handlerName]
+ // Look for the signal name in the object
+ var func = target[signalName]
+ if (typeof func !== "function") {
+ // If it is not a function, try looking for signal handler
+ // i.e. (onSignal) this is needed for cases where there is a property
+ // and a signal with the same name, e.g. Mousearea.pressed
+ func = target[qtest_signalHandlerName(signalName)]
+ }
if (func === undefined) {
spy.qtest_valid = false
console.log("Signal '" + signalName + "' not found")
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml
index 683200a259..ad7533c550 100644
--- a/src/imports/testlib/TestCase.qml
+++ b/src/imports/testlib/TestCase.qml
@@ -206,6 +206,59 @@ import Qt.test.qtestroot 1.0
will fail. Use the \l when and windowShown properties to track
when the main window has been shown.
+ \section1 Managing Dynamically Created Test Objects
+
+ A typical pattern with QML tests is to
+ \l {Dynamic QML Object Creation from JavaScript}{dynamically create}
+ an item and then destroy it at the end of the test function:
+
+ \code
+ TestCase {
+ id: testCase
+ name: "MyTest"
+ when: windowShown
+
+ function test_click() {
+ var item = Qt.createQmlObject("import QtQuick 2.0; Item {}", testCase);
+ verify(item);
+
+ // Test item...
+
+ item.destroy();
+ }
+ }
+ \endcode
+
+ The problem with this pattern is that any failures in the test function
+ will cause the call to \c item.destroy() to be skipped, leaving the item
+ hanging around in the scene until the test case has finished. This can
+ result in interference with future tests; for example, by blocking input
+ events or producing unrelated debug output that makes it difficult to
+ follow the code's execution.
+
+ By calling \l createTemporaryQmlObject() instead, the object is guaranteed
+ to be destroyed at the end of the test function:
+
+ \code
+ TestCase {
+ id: testCase
+ name: "MyTest"
+ when: windowShown
+
+ function test_click() {
+ var item = createTemporaryQmlObject("import QtQuick 2.0; Item {}", testCase);
+ verify(item);
+
+ // Test item...
+
+ // Don't need to worry about destroying "item" here.
+ }
+ }
+ \endcode
+
+ For objects that are created via the \l {Component::}{createObject()} function
+ of \l Component, the \l createTemporaryObject() function can be used.
+
\sa {QtTest::SignalSpy}{SignalSpy}, {Qt Quick Test Reference Documentation}
*/
@@ -221,7 +274,7 @@ Item {
\qmlproperty string TestCase::name
This property defines the name of the test case for result reporting.
- The default is the empty string.
+ The default value is an empty string.
\code
TestCase {
@@ -358,6 +411,8 @@ Item {
/*! \internal */
property var qtest_events: qtest_events_normal
TestEvent { id: qtest_events_normal }
+ /*! \internal */
+ property var qtest_temporaryObjects: []
/*!
\qmlmethod TestCase::fail(message = "")
@@ -461,6 +516,110 @@ Item {
throw new Error("QtQuickTest::fail")
}
+ /*!
+ \since 5.9
+ \qmlmethod object TestCase::createTemporaryQmlObject(string qml, object parent, string filePath)
+
+ This function dynamically creates a QML object from the given \a qml
+ string with the specified \a parent. The returned object will be
+ destroyed (if it was not already) after \l cleanup() has finished
+ executing, meaning that objects created with this function are
+ guaranteed to be destroyed after each test, regardless of whether or
+ not the tests fail.
+
+ If there was an error while creating the object, \c null will be
+ returned.
+
+ If \a filePath is specified, it will be used for error reporting for
+ the created object.
+
+ This function calls
+ \l {QtQml::Qt::createQmlObject()}{Qt.createQmlObject()} internally.
+
+ \sa {Managing Dynamically Created Test Objects}
+ */
+ function createTemporaryQmlObject(qml, parent, filePath) {
+ if (typeof qml !== "string") {
+ qtest_results.fail("First argument must be a string of QML; actual type is " + typeof qml,
+ util.callerFile(), util.callerLine());
+ throw new Error("QtQuickTest::fail");
+ }
+
+ if (!parent || typeof parent !== "object") {
+ qtest_results.fail("Second argument must be a valid parent object; actual type is " + typeof parent,
+ util.callerFile(), util.callerLine());
+ throw new Error("QtQuickTest::fail");
+ }
+
+ if (filePath !== undefined && typeof filePath !== "string") {
+ qtest_results.fail("Third argument must be a file path string; actual type is " + typeof filePath,
+ util.callerFile(), util.callerLine());
+ throw new Error("QtQuickTest::fail");
+ }
+
+ var object = Qt.createQmlObject(qml, parent, filePath);
+ qtest_temporaryObjects.push(object);
+ return object;
+ }
+
+ /*!
+ \since 5.9
+ \qmlmethod object TestCase::createTemporaryObject(Component component, object parent, object properties)
+
+ This function dynamically creates a QML object from the given
+ \a component with the specified \a parent and \a properties.
+ The returned object will be destroyed (if it was not already) after
+ \l cleanup() has finished executing, meaning that objects created with
+ this function are guaranteed to be destroyed after each test,
+ regardless of whether or not the tests fail.
+
+ If there was an error while creating the object, \c null will be
+ returned.
+
+ This function calls
+ \l {QtQml::Component::createObject()}{component.createObject()}
+ internally.
+
+ \sa {Managing Dynamically Created Test Objects}
+ */
+ function createTemporaryObject(component, parent, properties) {
+ if (typeof component !== "object") {
+ qtest_results.fail("First argument must be a Component; actual type is " + typeof component,
+ util.callerFile(), util.callerLine());
+ throw new Error("QtQuickTest::fail");
+ }
+
+ if (!parent && parent !== null) {
+ qtest_results.fail("Second argument must be a parent object or null; actual type is " + typeof parent,
+ util.callerFile(), util.callerLine());
+ throw new Error("QtQuickTest::fail");
+ }
+
+ if (properties && typeof properties !== "object") {
+ qtest_results.fail("Third argument must be an object; actual type is " + typeof properties,
+ util.callerFile(), util.callerLine());
+ throw new Error("QtQuickTest::fail");
+ }
+
+ var object = component.createObject(parent, properties ? properties : ({}));
+ qtest_temporaryObjects.push(object);
+ return object;
+ }
+
+ /*!
+ \internal
+
+ Destroys all temporary objects that still exist.
+ */
+ function qtest_destroyTemporaryObjects() {
+ for (var i = 0; i < qtest_temporaryObjects.length; ++i) {
+ var temporaryObject = qtest_temporaryObjects[i];
+ if (temporaryObject)
+ temporaryObject.destroy();
+ }
+ qtest_temporaryObjects = [];
+ }
+
/*! \internal */
// Determine what is o.
// Discussions and reference: http://philrathe.com/articles/equiv
@@ -835,7 +994,7 @@ Item {
\c{QEXPECT_FAIL(tag, message, Abort)} in C++.
If the test is not data-driven, then \a tag must be set to
- the empty string.
+ an empty string.
\sa expectFailContinue()
*/
@@ -861,7 +1020,7 @@ Item {
\c{QEXPECT_FAIL(tag, message, Continue)} in C++.
If the test is not data-driven, then \a tag must be set to
- the empty string.
+ an empty string.
\sa expectFail()
*/
@@ -1317,6 +1476,109 @@ Item {
qtest_fail("window not shown", 2)
}
+ /*!
+ \qmlmethod TouchEventSequence TestCase::touchEvent(object item)
+
+ \since 5.9
+
+ Begins a sequence of touch events through a simulated QTouchDevice::TouchScreen.
+ Events are delivered to the window containing \a item.
+
+ The returned object is used to enumerate events to be delivered through a single
+ QTouchEvent. Touches are delivered to the window containing the TestCase unless
+ otherwise specified.
+
+ \code
+ Rectangle {
+ width: 640; height: 480
+
+ MultiPointTouchArea {
+ id: area
+ anchors.fill: parent
+
+ property bool touched: false
+
+ onPressed: touched = true
+ }
+
+ TestCase {
+ name: "ItemTests"
+ when: area.pressed
+ id: test1
+
+ function test_touch() {
+ var touch = touchEvent(area);
+ touch.press(0, area, 10, 10);
+ touch.commit();
+ verify(area.touched);
+ }
+ }
+ }
+ \endcode
+
+ \sa TouchEventSequence::press(), TouchEventSequence::move(), TouchEventSequence::release(), TouchEventSequence::stationary(), TouchEventSequence::commit(), QTouchDevice::TouchScreen
+ */
+
+ function touchEvent(item) {
+ if (!item)
+ qtest_fail("No item given to touchEvent", 1)
+
+ return {
+ _defaultItem: item,
+ _sequence: qtest_events.touchEvent(item),
+
+ press: function (id, target, x, y) {
+ if (!target)
+ target = this._defaultItem;
+ if (id === undefined)
+ qtest_fail("No id given to TouchEventSequence::press", 1);
+ if (x === undefined)
+ x = target.width / 2;
+ if (y === undefined)
+ y = target.height / 2;
+ this._sequence.press(id, target, x, y);
+ return this;
+ },
+
+ move: function (id, target, x, y) {
+ if (!target)
+ target = this._defaultItem;
+ if (id === undefined)
+ qtest_fail("No id given to TouchEventSequence::move", 1);
+ if (x === undefined)
+ x = target.width / 2;
+ if (y === undefined)
+ y = target.height / 2;
+ this._sequence.move(id, target, x, y);
+ return this;
+ },
+
+ stationary: function (id) {
+ if (id === undefined)
+ qtest_fail("No id given to TouchEventSequence::stationary", 1);
+ this._sequence.stationary(id);
+ return this;
+ },
+
+ release: function (id, target, x, y) {
+ if (!target)
+ target = this._defaultItem;
+ if (id === undefined)
+ qtest_fail("No id given to TouchEventSequence::release", 1);
+ if (x === undefined)
+ x = target.width / 2;
+ if (y === undefined)
+ y = target.height / 2;
+ this._sequence.release(id, target, x, y);
+ return this;
+ },
+
+ commit: function () {
+ this._sequence.commit();
+ return this;
+ }
+ };
+ }
// Functions that can be overridden in subclasses for init/cleanup duties.
/*!
@@ -1389,6 +1651,7 @@ Item {
qtest_runInternal(prop, arg)
qtest_results.finishTestData()
qtest_runInternal("cleanup")
+ qtest_destroyTemporaryObjects()
qtest_results.finishTestDataCleanup()
// wait(0) will call processEvents() so objects marked for deletion
// in the test function will be deleted.
diff --git a/src/imports/testlib/main.cpp b/src/imports/testlib/main.cpp
index 4e2bd919e9..3c28000e35 100644
--- a/src/imports/testlib/main.cpp
+++ b/src/imports/testlib/main.cpp
@@ -158,6 +158,7 @@ public:
qmlRegisterType<QuickTestResult, 1>(uri,1,1,"TestResult");
qmlRegisterType<QuickTestEvent>(uri,1,0,"TestEvent");
qmlRegisterType<QuickTestUtil>(uri,1,0,"TestUtil");
+ qmlRegisterType<QQuickTouchEventSequence>();
}
};
diff --git a/src/imports/testlib/qmldir b/src/imports/testlib/qmldir
index 9da8ebb4be..e5757f6a88 100644
--- a/src/imports/testlib/qmldir
+++ b/src/imports/testlib/qmldir
@@ -3,4 +3,5 @@ plugin qmltestplugin
classname QTestQmlModule
typeinfo plugins.qmltypes
TestCase 1.0 TestCase.qml
+TestCase 1.2 TestCase.qml
SignalSpy 1.0 SignalSpy.qml
diff --git a/src/imports/testlib/toucheventsequence.qdoc b/src/imports/testlib/toucheventsequence.qdoc
new file mode 100644
index 0000000000..f85a1cd4f9
--- /dev/null
+++ b/src/imports/testlib/toucheventsequence.qdoc
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Jeremy Katz
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \qmltype TouchEventSequence
+ \inqmlmodule QtTest
+ \ingroup qtquicktest
+ \brief TouchEventSequence is used to build and dispatch touch events
+ for testing.
+
+ \since 5.9
+
+ A TouchEventSequence is created by calling \l [QML] {TestCase::touchEvent()}{TestCase.touchEvent()}.
+ The type can not be directly instantiated. Each method provided by the type returns
+ the same object, allowing chained calls.
+
+ For example:
+ \code
+ touchEvent(item).press(0).commit();
+ \endcode
+ is equivalent to:
+ \code
+ var sequence = touchEvent(item);
+ sequence.press(0);
+ sequence.commit();
+ \endcode
+
+ Events are delivered to the window which contains the item specified in touchEvent.
+
+ \sa TestCase::touchEvent(), QTest::QTouchEventSequence
+*/
+
+/*!
+ \qmlmethod TouchEventSequence TouchEventSequence::press(int touchId, object item, real x = item.width / 2, real y = item.height / 2)
+
+ Creates a new point identified as \a touchId, at the point indicated by \a x and \a y relative to \a item.
+ Further use of the same touch point should maintain the same touchId.
+
+ Item defaults to the value provided via touchEvent().
+ X and y default to the midpoint of the item.
+*/
+
+/*!
+ \qmlmethod TouchEventSequence TouchEventSequence::move(int touchId, object item, real x = item.width / 2, real y = item.height / 2)
+
+ Moves \a touchId to the point indicated by \a x and \a y relative to \a item.
+
+ Item defaults to the value provided via touchEvent().
+ X and y default to the midpoint of the item.
+*/
+
+/*!
+ \qmlmethod TouchEventSequence TouchEventSequence::release(int touchId, object item, real x = item.width / 2, real y = item.height / 2)
+
+ Removes \a touchId at the point indicated by \a x and \a y relative to \a item.
+
+ Item defaults to the value provided via touchEvent().
+ X and y default to the midpoint of the item.
+*/
+
+/*!
+ \qmlmethod TouchEventSequence TouchEventSequence::stationary(int touchId)
+
+ Indicates that \a touchId is present but otherwise unchanged from prior events.
+*/
+
+/*!
+ \qmlmethod TouchEventSequence TouchEventSequence::commit()
+
+ Sends the touch event composed by prior use of press(), move(), release(), and stationary().
+ Following commit's return, the TouchEventSequence can be used to compose a new event.
+
+ \code
+ var sequence = touchEvent(target);
+ // Touch the middle of target with 1 point
+ sequence.press(1);
+ sequence.commit();
+
+ // Begin a new event
+ // Move the point to target's upper left corner
+ sequence.move(1, target, 0, 0);
+ sequence.commit();
+ \endcode
+
+ Commit is automatically invoked when the TouchEventSequence object is destroyed.
+*/
diff --git a/src/imports/window/plugins.qmltypes b/src/imports/window/plugins.qmltypes
index 6a8dbfa024..a79bd8c332 100644
--- a/src/imports/window/plugins.qmltypes
+++ b/src/imports/window/plugins.qmltypes
@@ -55,8 +55,12 @@ Module {
name: "QQuickWindow"
defaultProperty: "data"
prototype: "QWindow"
- exports: ["QtQuick.Window/Window 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Window/Window 2.0",
+ "QtQuick.Window/Window 2.1",
+ "QtQuick.Window/Window 2.2"
+ ]
+ exportMetaObjectRevisions: [0, 1, 2]
Enum {
name: "SceneGraphError"
values: {
diff --git a/src/particles/qquickimageparticle.cpp b/src/particles/qquickimageparticle.cpp
index c68153aca8..e6b921792f 100644
--- a/src/particles/qquickimageparticle.cpp
+++ b/src/particles/qquickimageparticle.cpp
@@ -1292,14 +1292,16 @@ void QQuickImageParticle::finishBuildParticleNodes(QSGNode** node)
// OS X 10.8.3 introduced a bug in the AMD drivers, for at least the 2011 macbook pros,
// causing point sprites who read gl_PointCoord in the frag shader to come out as
// green-red blobs.
- if (perfLevel < Deformable && strstr((char *) glGetString(GL_VENDOR), "ATI")) {
+ const GLubyte *glVendor = QOpenGLContext::currentContext()->functions()->glGetString(GL_VENDOR);
+ if (perfLevel < Deformable && glVendor && strstr((char *) glVendor, "ATI")) {
perfLevel = Deformable;
}
#endif
#ifdef Q_OS_LINUX
// Nouveau drivers can potentially freeze a machine entirely when taking the point-sprite path.
- if (perfLevel < Deformable && strstr((const char *) glGetString(GL_VENDOR), "nouveau"))
+ const GLubyte *glVendor = QOpenGLContext::currentContext()->functions()->glGetString(GL_VENDOR);
+ if (perfLevel < Deformable && glVendor && strstr((const char *) glVendor, "nouveau"))
perfLevel = Deformable;
#endif
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qmldbg_debugger.pro b/src/plugins/qmltooling/qmldbg_debugger/qmldbg_debugger.pro
index 27b3a5b513..f3f8a21ff8 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qmldbg_debugger.pro
+++ b/src/plugins/qmltooling/qmldbg_debugger/qmldbg_debugger.pro
@@ -2,10 +2,8 @@ TARGET = qmldbg_debugger
QT = qml-private core-private packetprotocol-private
SOURCES += \
- $$PWD/qdebugmessageservice.cpp \
$$PWD/qqmldebuggerservicefactory.cpp \
$$PWD/qqmlenginedebugservice.cpp \
- $$PWD/qqmlnativedebugservice.cpp \
$$PWD/qqmlwatcher.cpp \
$$PWD/qv4debugservice.cpp \
$$PWD/qv4debugger.cpp \
@@ -16,10 +14,8 @@ SOURCES += \
HEADERS += \
$$PWD/../shared/qqmlconfigurabledebugservice.h \
$$PWD/../shared/qqmldebugpacket.h \
- $$PWD/qdebugmessageservice.h \
$$PWD/qqmldebuggerservicefactory.h \
$$PWD/qqmlenginedebugservice.h \
- $$PWD/qqmlnativedebugservice.h \
$$PWD/qqmlwatcher.h \
$$PWD/qv4debugservice.h \
$$PWD/qv4debugger.h \
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservice.json b/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservice.json
index 967a725903..442d7781a1 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservice.json
+++ b/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservice.json
@@ -1,3 +1,3 @@
{
- "Keys": [ "DebugMessages", "QmlDebugger", "V8Debugger", "NativeQmlDebugger" ]
+ "Keys": [ "QmlDebugger", "V8Debugger" ]
}
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservicefactory.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservicefactory.cpp
index ca3f07323d..9315adf4ce 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservicefactory.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservicefactory.cpp
@@ -39,27 +39,19 @@
#include "qqmldebuggerservicefactory.h"
#include "qqmlenginedebugservice.h"
-#include "qdebugmessageservice.h"
#include "qv4debugservice.h"
-#include "qqmlnativedebugservice.h"
#include <private/qqmldebugserviceinterfaces_p.h>
QT_BEGIN_NAMESPACE
QQmlDebugService *QQmlDebuggerServiceFactory::create(const QString &key)
{
- if (key == QDebugMessageServiceImpl::s_key)
- return new QDebugMessageServiceImpl(this);
-
if (key == QQmlEngineDebugServiceImpl::s_key)
return new QQmlEngineDebugServiceImpl(this);
if (key == QV4DebugServiceImpl::s_key)
return new QV4DebugServiceImpl(this);
- if (key == QQmlNativeDebugServiceImpl::s_key)
- return new QQmlNativeDebugServiceImpl(this);
-
return 0;
}
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservicefactory.h b/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservicefactory.h
index 99d6679833..50eed2369c 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservicefactory.h
+++ b/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservicefactory.h
@@ -49,7 +49,7 @@ class QQmlDebuggerServiceFactory : public QQmlDebugServiceFactory
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlDebugServiceFactory_iid FILE "qqmldebuggerservice.json")
public:
- QQmlDebugService *create(const QString &key);
+ QQmlDebugService *create(const QString &key) override;
};
QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp
index fe88d686fc..151e44c4d4 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp
@@ -662,7 +662,7 @@ bool QQmlEngineDebugServiceImpl::setBinding(int objectId,
filename, line, column);
QQmlPropertyPrivate::takeSignalExpression(property, qmlExpression);
} else if (property.isProperty()) {
- QQmlBinding *binding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core, expression.toString(), object, QQmlContextData::get(context), filename, line, column);
+ QQmlBinding *binding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core, expression.toString(), object, QQmlContextData::get(context), filename, line);
binding->setTarget(property);
QQmlPropertyPrivate::setBinding(binding);
binding->update();
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp
index b2db23d78c..aed2759383 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp
@@ -60,7 +60,7 @@ QV4::CallContext *QV4DataCollector::findContext(int frame)
QV4::ExecutionContext *ctx = engine()->currentContext;
while (ctx) {
QV4::CallContext *cCtxt = ctx->asCallContext();
- if (cCtxt && cCtxt->d()->function) {
+ if (cCtxt && cCtxt->d()->v4Function) {
if (frame < 1)
return cCtxt;
--frame;
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp
index 44810dd4cb..5cc2043cb1 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp
@@ -252,9 +252,8 @@ QV4::Function *QV4Debugger::getFunction() const
{
QV4::Scope scope(m_engine);
QV4::ExecutionContext *context = m_engine->currentContext;
- QV4::ScopedFunctionObject function(scope, context->getFunctionObject());
- if (function)
- return function->function();
+ if (QV4::Function *function = context->getFunction())
+ return function;
else
return context->d()->engine->globalCode;
}
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp
index 4e4048f6ad..df316c1ae6 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp
@@ -41,7 +41,9 @@
#include <private/qv4script_p.h>
#include <private/qqmlcontext_p.h>
+#include <private/qv4qmlcontext_p.h>
#include <private/qv4qobjectwrapper_p.h>
+#include <private/qqmldebugservice_p.h>
#include <QtQml/qqmlengine.h>
@@ -51,9 +53,10 @@ QV4DebugJob::~QV4DebugJob()
{
}
-JavaScriptJob::JavaScriptJob(QV4::ExecutionEngine *engine, int frameNr,
- const QString &script) :
- engine(engine), frameNr(frameNr), script(script), resultIsException(false)
+JavaScriptJob::JavaScriptJob(QV4::ExecutionEngine *engine, int frameNr, int context,
+ const QString &script) :
+ engine(engine), frameNr(frameNr), context(context), script(script),
+ resultIsException(false)
{}
void JavaScriptJob::run()
@@ -64,7 +67,23 @@ void JavaScriptJob::run()
QV4::ExecutionContext *ctx = engine->currentContext;
QObject scopeObject;
- if (frameNr < 0) { // Use QML context if available
+
+ if (frameNr > 0) {
+ for (int i = 0; i < frameNr; ++i) {
+ ctx = engine->parentContext(ctx);
+ }
+ engine->pushContext(ctx);
+ ctx = engine->currentContext;
+ }
+
+ if (context >= 0) {
+ QQmlContext *extraContext = qmlContext(QQmlDebugService::objectForId(context));
+ if (extraContext) {
+ engine->pushContext(QV4::QmlContext::create(ctx, QQmlContextData::get(extraContext),
+ &scopeObject));
+ ctx = engine->currentContext;
+ }
+ } else if (frameNr < 0) { // Use QML context if available
QQmlEngine *qmlEngine = engine->qmlEngine();
if (qmlEngine) {
QQmlContext *qmlRootContext = qmlEngine->rootContext();
@@ -81,20 +100,13 @@ void JavaScriptJob::run()
}
}
if (!engine->qmlContext()) {
- engine->pushContext(ctx->newQmlContext(QQmlContextData::get(qmlRootContext),
+ engine->pushContext(QV4::QmlContext::create(ctx, QQmlContextData::get(qmlRootContext),
&scopeObject));
ctx = engine->currentContext;
}
engine->pushContext(ctx->newWithContext(withContext->toObject(engine)));
ctx = engine->currentContext;
}
- } else {
- if (frameNr > 0) {
- for (int i = 0; i < frameNr; ++i) {
- ctx = engine->parentContext(ctx);
- }
- engine->pushContext(ctx);
- }
}
QV4::Script script(ctx, this->script);
@@ -201,7 +213,7 @@ void ValueLookupJob::run()
QV4::ExecutionEngine *engine = collector->engine();
if (engine->qmlEngine() && !engine->qmlContext()) {
scopeObject.reset(new QObject);
- engine->pushContext(engine->currentContext->newQmlContext(
+ engine->pushContext(QV4::QmlContext::create(engine->currentContext,
QQmlContextData::get(engine->qmlEngine()->rootContext()),
scopeObject.data()));
}
@@ -224,8 +236,9 @@ const QString &ValueLookupJob::exceptionMessage() const
}
ExpressionEvalJob::ExpressionEvalJob(QV4::ExecutionEngine *engine, int frameNr,
- const QString &expression, QV4DataCollector *collector) :
- JavaScriptJob(engine, frameNr, expression), collector(collector)
+ int context, const QString &expression,
+ QV4DataCollector *collector) :
+ JavaScriptJob(engine, frameNr, context, expression), collector(collector)
{
}
@@ -271,7 +284,7 @@ const QStringList &GatherSourcesJob::result() const
}
EvalJob::EvalJob(QV4::ExecutionEngine *engine, const QString &script) :
- JavaScriptJob(engine, /*frameNr*/-1, script), result(false)
+ JavaScriptJob(engine, /*frameNr*/-1, /*context*/ -1, script), result(false)
{}
void EvalJob::handleResult(QV4::ScopedValue &result)
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h
index aff2ea1b6c..00d3e6206a 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h
@@ -60,11 +60,12 @@ class JavaScriptJob : public QV4DebugJob
{
QV4::ExecutionEngine *engine;
int frameNr;
+ int context;
const QString &script;
bool resultIsException;
public:
- JavaScriptJob(QV4::ExecutionEngine *engine, int frameNr, const QString &script);
+ JavaScriptJob(QV4::ExecutionEngine *engine, int frameNr, int context, const QString &script);
void run() override;
bool hasExeption() const;
@@ -112,7 +113,7 @@ class ScopeJob: public CollectJob
public:
ScopeJob(QV4DataCollector *collector, int frameNr, int scopeNr);
- void run();
+ void run() override;
bool wasSuccessful() const;
};
@@ -135,8 +136,8 @@ class ExpressionEvalJob: public JavaScriptJob
QJsonArray collectedRefs;
public:
- ExpressionEvalJob(QV4::ExecutionEngine *engine, int frameNr, const QString &expression,
- QV4DataCollector *collector);
+ ExpressionEvalJob(QV4::ExecutionEngine *engine, int frameNr, int context,
+ const QString &expression, QV4DataCollector *collector);
void handleResult(QV4::ScopedValue &value) override;
const QString &exceptionMessage() const;
const QJsonObject &returnValue() const;
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp
index de97b5437b..1d2cc092dc 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp
@@ -177,6 +177,7 @@ public:
body.insert(QStringLiteral("V8Version"),
QLatin1String("this is not V8, this is V4 in Qt " QT_VERSION_STR));
body.insert(QStringLiteral("UnpausedEvaluate"), true);
+ body.insert(QStringLiteral("ContextEvaluate"), true);
addBody(body);
}
};
@@ -610,6 +611,7 @@ public:
{
QJsonObject arguments = req.value(QLatin1String("arguments")).toObject();
QString expression = arguments.value(QLatin1String("expression")).toString();
+ int context = arguments.value(QLatin1String("context")).toInt(-1);
int frame = -1;
QV4Debugger *debugger = debugService->debuggerAgent.pausedDebugger();
@@ -627,7 +629,8 @@ public:
frame = arguments.value(QLatin1String("frame")).toInt(0);
}
- ExpressionEvalJob job(debugger->engine(), frame, expression, debugger->collector());
+ ExpressionEvalJob job(debugger->engine(), frame, context, expression,
+ debugger->collector());
debugger->runInEngine(&job);
if (job.hasExeption()) {
createErrorResponse(job.exceptionMessage());
diff --git a/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp
index eb254ca1e0..7145645609 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp
@@ -235,9 +235,7 @@ bool GlobalInspector::syncSelectedItems(const QList<QQuickItem *> &items)
// Disconnect and remove items that are no longer selected
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;
+ for (QQuickItem *item : selectedItemsCopy) {
if (items.contains(item))
continue;
diff --git a/src/plugins/qmltooling/qmldbg_inspector/globalinspector.h b/src/plugins/qmltooling/qmldbg_inspector/globalinspector.h
index 338eee14c3..f7b325c454 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/globalinspector.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/globalinspector.h
@@ -84,7 +84,7 @@ private:
bool syncSelectedItems(const QList<QQuickItem *> &items);
// Hash< object to be destroyed, QPair<destroy eventId, object debugId> >
- QList<QPointer<QQuickItem> > m_selectedItems;
+ QList<QQuickItem *> m_selectedItems;
QHash<QQuickItem *, SelectionHighlight *> m_highlightItems;
QList<QQuickWindowInspector *> m_windowInspectors;
int m_eventId;
diff --git a/src/plugins/qmltooling/qmldbg_inspector/highlight.h b/src/plugins/qmltooling/qmldbg_inspector/highlight.h
index 2bf4fc1ad5..3f910e833b 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/highlight.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/highlight.h
@@ -81,7 +81,7 @@ class SelectionHighlight : public Highlight
public:
SelectionHighlight(const QString &name, QQuickItem *item, QQuickItem *parent);
- void paint(QPainter *painter);
+ void paint(QPainter *painter) override;
void showName(const QPointF &displayPoint);
private:
@@ -104,7 +104,7 @@ public:
setZ(1); // hover highlight on top of selection highlight
}
- void paint(QPainter *painter);
+ void paint(QPainter *painter) override;
};
} // namespace QmlJSDebugger
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservicefactory.h b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservicefactory.h
index 09e6a01f96..3214532c8d 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservicefactory.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservicefactory.h
@@ -64,7 +64,7 @@ class QQmlInspectorServiceFactory : public QQmlDebugServiceFactory
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlDebugServiceFactory_iid FILE "qqmlinspectorservice.json")
public:
- QQmlDebugService *create(const QString &key);
+ QQmlDebugService *create(const QString &key) override;
};
QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.cpp
index 2525500e65..7d260a4d2a 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.cpp
@@ -153,7 +153,7 @@ bool QQuickWindowInspector::eventFilter(QObject *obj, QEvent *event)
case QEvent::MouseButtonDblClick:
m_tool->mouseDoubleClickEvent(static_cast<QMouseEvent*>(event));
return true;
-#ifndef QT_NO_WHEELEVENT
+#if QT_CONFIG(wheelevent)
case QEvent::Wheel:
return true;
#endif
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.h b/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.h
index b37a9face1..fc18f33ad3 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.h
+++ b/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.h
@@ -78,7 +78,7 @@ public:
void setEnabled(bool enabled);
protected:
- bool eventFilter(QObject *, QEvent *);
+ bool eventFilter(QObject *, QEvent *) override;
private:
QQuickItem *m_overlay;
diff --git a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp
index 64b26bdd0d..6152853917 100644
--- a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp
+++ b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp
@@ -43,6 +43,8 @@
#include <QtCore/qplugin.h>
#include <QtNetwork/qlocalsocket.h>
+Q_DECLARE_METATYPE(QLocalSocket::LocalSocketError)
+
QT_BEGIN_NAMESPACE
@@ -133,8 +135,14 @@ bool QLocalClientConnection::connectToServer()
{
m_socket = new QLocalSocket;
m_socket->setParent(this);
- QObject::connect(m_socket, &QLocalSocket::connected,
- this, &QLocalClientConnection::connectionEstablished);
+ connect(m_socket, &QLocalSocket::connected,
+ this, &QLocalClientConnection::connectionEstablished);
+ connect(m_socket, static_cast<void(QLocalSocket::*)(QLocalSocket::LocalSocketError)>(
+ &QLocalSocket::error), m_socket, [this](QLocalSocket::LocalSocketError) {
+ m_socket->disconnectFromServer();
+ m_socket->connectToServer(m_filename);
+ }, Qt::QueuedConnection);
+
m_socket->connectToServer(m_filename);
qDebug("QML Debugger: Connecting to socket %s...", m_filename.toLatin1().constData());
return true;
diff --git a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnectionfactory.h b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnectionfactory.h
index b884a1ec23..b64a1fff95 100644
--- a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnectionfactory.h
+++ b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnectionfactory.h
@@ -50,7 +50,7 @@ class QLocalClientConnectionFactory : public QQmlDebugServerConnectionFactory
Q_PLUGIN_METADATA(IID QQmlDebugServerConnectionFactory_iid FILE "qlocalclientconnection.json")
Q_INTERFACES(QQmlDebugServerConnectionFactory)
public:
- QQmlDebugServerConnection *create(const QString &key);
+ QQmlDebugServerConnection *create(const QString &key) override;
};
QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.cpp b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.cpp
index b0f59717ac..b0f59717ac 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.cpp
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.h b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.h
index c25e756c2d..24fd27514b 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qdebugmessageservice.h
+++ b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.h
@@ -68,10 +68,10 @@ public:
QDebugMessageServiceImpl(QObject *parent = 0);
void sendDebugMessage(QtMsgType type, const QMessageLogContext &ctxt, const QString &buf);
- void synchronizeTime(const QElapsedTimer &otherTimer);
+ void synchronizeTime(const QElapsedTimer &otherTimer) override;
protected:
- void stateChanged(State);
+ void stateChanged(State) override;
private:
friend class QQmlDebuggerServiceFactory;
diff --git a/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.json b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.json
new file mode 100644
index 0000000000..2e8dc65cf5
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "DebugMessages" ]
+}
diff --git a/src/qml/jsruntime/qv4context_p_p.h b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservicefactory.cpp
index ca8dc0b518..a066237e77 100644
--- a/src/qml/jsruntime/qv4context_p_p.h
+++ b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservicefactory.cpp
@@ -36,48 +36,19 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#ifndef QV4CONTEXT_P_P_H
-#define QV4CONTEXT_P_P_H
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-// This header defines a couple of inlinable methods.
-// These implementation cannot be put in qv4context_p.h, because they rely on the
-// QQmlContextWrapper, which in turn is a QV4::Object subclass (so it includes qv4object_p.h),
-// which includes qv4engine_p.h, that needs to include qv4context_p.h
-
-#include "qv4context_p.h"
-#include "private/qqmlcontextwrapper_p.h"
+#include "qdebugmessageservicefactory.h"
+#include "qdebugmessageservice.h"
+#include <private/qqmldebugserviceinterfaces_p.h>
QT_BEGIN_NAMESPACE
-namespace QV4 {
-
-QObject *QmlContext::qmlScope() const
+QQmlDebugService *QDebugMessageServiceFactory::create(const QString &key)
{
- return d()->qml->scopeObject;
-}
+ if (key == QDebugMessageServiceImpl::s_key)
+ return new QDebugMessageServiceImpl(this);
-QQmlContextData *QmlContext::qmlContext() const
-{
- return *d()->qml->context;
+ return 0;
}
-void QmlContext::takeContextOwnership() {
- d()->qml->ownsContext = true;
-}
-
-} // QV4 namespace
-
QT_END_NAMESPACE
-
-#endif // QV4CONTEXT_P_P_H
diff --git a/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservicefactory.h b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservicefactory.h
new file mode 100644
index 0000000000..0c5f0f5d0a
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservicefactory.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDEBUGMESSAGESERVICEFACTORY_H
+#define QDEBUGMESSAGESERVICEFACTORY_H
+
+#include <private/qqmldebugservicefactory_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDebugMessageServiceFactory : public QQmlDebugServiceFactory
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QQmlDebugServiceFactory_iid FILE "qdebugmessageservice.json")
+public:
+ QQmlDebugService *create(const QString &key) override;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDEBUGMESSAGESERVICEFACTORY_H
diff --git a/src/plugins/qmltooling/qmldbg_messages/qmldbg_messages.pro b/src/plugins/qmltooling/qmldbg_messages/qmldbg_messages.pro
new file mode 100644
index 0000000000..5ddf7c615d
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_messages/qmldbg_messages.pro
@@ -0,0 +1,21 @@
+TARGET = qmldbg_messages
+QT = qml-private core packetprotocol-private
+
+SOURCES += \
+ $$PWD/qdebugmessageservice.cpp \
+ $$PWD/qdebugmessageservicefactory.cpp
+
+HEADERS += \
+ $$PWD/../shared/qqmldebugpacket.h \
+ $$PWD/qdebugmessageservice.h \
+ $$PWD/qdebugmessageservicefactory.h
+
+INCLUDEPATH += $$PWD \
+ $$PWD/../shared
+
+OTHER_FILES += \
+ $$PWD/qdebugmessageservice.json
+
+PLUGIN_TYPE = qmltooling
+PLUGIN_CLASS_NAME = QDebugMessageServiceFactory
+load(qt_plugin)
diff --git a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
index 9eeb285951..1a318b3ca2 100644
--- a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
+++ b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
@@ -183,7 +183,7 @@ QQmlNativeDebugConnector::QQmlNativeDebugConnector()
: m_blockingMode(false)
{
const QString args = commandLineArguments();
- const auto lstjsDebugArguments = args.splitRef(QLatin1Char(','));
+ const auto lstjsDebugArguments = args.splitRef(QLatin1Char(','), QString::SkipEmptyParts);
QStringList services;
for (const QStringRef &strArgument : lstjsDebugArguments) {
if (strArgument == QLatin1String("block")) {
@@ -195,7 +195,7 @@ QQmlNativeDebugConnector::QQmlNativeDebugConnector()
services.append(strArgument.mid(9).toString());
} else if (!services.isEmpty()) {
services.append(strArgument.toString());
- } else {
+ } else if (!strArgument.startsWith(QLatin1String("connector:"))) {
qWarning("QML Debugger: Invalid argument \"%s\" detected. Ignoring the same.",
strArgument.toUtf8().constData());
}
diff --git a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h
index 1184925e53..f8b7e1d527 100644
--- a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h
+++ b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h
@@ -78,7 +78,7 @@ class QQmlNativeDebugConnectorFactory : public QQmlDebugConnectorFactory
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlDebugConnectorFactory_iid FILE "qqmlnativedebugconnector.json")
public:
- QQmlDebugConnector *create(const QString &key);
+ QQmlDebugConnector *create(const QString &key) override;
};
QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qmldbg_nativedebugger.pro b/src/plugins/qmltooling/qmldbg_nativedebugger/qmldbg_nativedebugger.pro
new file mode 100644
index 0000000000..1873a6a77c
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qmldbg_nativedebugger.pro
@@ -0,0 +1,21 @@
+TARGET = qmldbg_nativedebugger
+QT = qml-private core packetprotocol-private
+
+SOURCES += \
+ $$PWD/qqmlnativedebugservicefactory.cpp \
+ $$PWD/qqmlnativedebugservice.cpp
+
+HEADERS += \
+ $$PWD/../shared/qqmldebugpacket.h \
+ $$PWD/qqmlnativedebugservicefactory.h \
+ $$PWD/qqmlnativedebugservice.h \
+
+INCLUDEPATH += $$PWD \
+ $$PWD/../shared
+
+OTHER_FILES += \
+ $$PWD/qqmlnativedebugservice.json
+
+PLUGIN_TYPE = qmltooling
+PLUGIN_CLASS_NAME = QQmlNativeDebugServiceFactory
+load(qt_plugin)
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp
index 9c198a8afc..7f842419e7 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp
@@ -336,18 +336,16 @@ void NativeDebugger::handleBacktrace(QJsonObject *response, const QJsonObject &a
QJsonArray frameArray;
QV4::ExecutionContext *executionContext = m_engine->currentContext;
for (int i = 0; i < limit && executionContext; ++i) {
- QV4::Heap::FunctionObject *heapFunctionObject = executionContext->getFunctionObject();
- if (heapFunctionObject) {
+ if (QV4::Function *function = executionContext->getFunction()) {
QJsonObject frame;
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.insert(QStringLiteral("function"), functionName->toQString());
- frame.insert(QStringLiteral("file"), function->sourceFile());
- }
+ if (QV4::Heap::String *functionName = function->name())
+ frame.insert(QStringLiteral("function"), functionName->toQString());
+ frame.insert(QStringLiteral("file"), function->sourceFile());
+
int line = executionContext->d()->lineNumber;
frame.insert(QStringLiteral("line"), (line < 0 ? -line : line));
@@ -667,11 +665,9 @@ void NativeDebugger::aboutToThrow()
QV4::Function *NativeDebugger::getFunction() const
{
- QV4::Scope scope(m_engine);
QV4::ExecutionContext *context = m_engine->currentContext;
- QV4::ScopedFunctionObject function(scope, context->getFunctionObject());
- if (function)
- return function->function();
+ if (QV4::Function *function = context->getFunction())
+ return function;
else
return context->d()->engine->globalCode;
}
@@ -683,10 +679,8 @@ void NativeDebugger::pauseAndWait()
event.insert(QStringLiteral("event"), QStringLiteral("break"));
event.insert(QStringLiteral("language"), QStringLiteral("js"));
if (QV4::ExecutionContext *executionContext = m_engine->currentContext) {
- QV4::Heap::FunctionObject *heapFunctionObject = executionContext->getFunctionObject();
- if (heapFunctionObject) {
- if (QV4::Function *function = heapFunctionObject->function)
- event.insert(QStringLiteral("file"), function->sourceFile());
+ if (QV4::Function *function = executionContext->getFunction()) {
+ event.insert(QStringLiteral("file"), function->sourceFile());
int line = executionContext->d()->lineNumber;
event.insert(QStringLiteral("line"), (line < 0 ? -line : line));
}
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.h b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.h
index 8015513f9e..58bf1bc94a 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.h
+++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.h
@@ -67,7 +67,6 @@ QT_BEGIN_NAMESPACE
class NativeDebugger;
class BreakPointHandler;
-class QQmlDebuggerServiceFactory;
class QQmlNativeDebugServiceImpl : public QQmlNativeDebugService
{
@@ -86,7 +85,6 @@ public:
void emitAsynchronousMessageToClient(const QJsonObject &message);
private:
- friend class QQmlDebuggerServiceFactory;
friend class NativeDebugger;
QList<QPointer<NativeDebugger> > m_debuggers;
diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.json b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.json
new file mode 100644
index 0000000000..2951166298
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "NativeQmlDebugger" ]
+}
diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservicefactory.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservicefactory.cpp
new file mode 100644
index 0000000000..1841c82d5d
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservicefactory.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlnativedebugservice.h"
+#include "qqmlnativedebugservicefactory.h"
+#include <private/qqmldebugserviceinterfaces_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QQmlDebugService *QQmlNativeDebugServiceFactory::create(const QString &key)
+{
+ if (key == QQmlNativeDebugServiceImpl::s_key)
+ return new QQmlNativeDebugServiceImpl(this);
+
+ return 0;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservicefactory.h b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservicefactory.h
new file mode 100644
index 0000000000..f2b2e4792e
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservicefactory.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLNATIVEDEBUGSERVICEFACTORY_H
+#define QQMLNATIVEDEBUGSERVICEFACTORY_H
+
+#include <private/qqmldebugservicefactory_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlNativeDebugServiceFactory : public QQmlDebugServiceFactory
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QQmlDebugServiceFactory_iid FILE "qqmlnativedebugservice.json")
+public:
+ QQmlDebugService *create(const QString &key) override;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLNATIVEDEBUGSERVICEFACTORY_H
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp
index 0ed13d5105..9918a95116 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp
@@ -46,6 +46,7 @@ QT_BEGIN_NAMESPACE
QQmlEngineControlServiceImpl::QQmlEngineControlServiceImpl(QObject *parent) :
QQmlEngineControlService(1, parent)
{
+ blockingMode = QQmlDebugConnector::instance()->blockingMode();
}
void QQmlEngineControlServiceImpl::messageReceived(const QByteArray &message)
@@ -68,7 +69,7 @@ void QQmlEngineControlServiceImpl::messageReceived(const QByteArray &message)
void QQmlEngineControlServiceImpl::engineAboutToBeAdded(QJSEngine *engine)
{
QMutexLocker lock(&dataMutex);
- if (state() == Enabled) {
+ if (blockingMode && state() == Enabled) {
Q_ASSERT(!stoppingEngines.contains(engine));
Q_ASSERT(!startingEngines.contains(engine));
startingEngines.append(engine);
@@ -81,7 +82,7 @@ void QQmlEngineControlServiceImpl::engineAboutToBeAdded(QJSEngine *engine)
void QQmlEngineControlServiceImpl::engineAboutToBeRemoved(QJSEngine *engine)
{
QMutexLocker lock(&dataMutex);
- if (state() == Enabled) {
+ if (blockingMode && state() == Enabled) {
Q_ASSERT(!stoppingEngines.contains(engine));
Q_ASSERT(!startingEngines.contains(engine));
stoppingEngines.append(engine);
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.h b/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.h
index 1138310820..6392944519 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.h
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.h
@@ -79,6 +79,7 @@ protected:
QMutex dataMutex;
QList<QJSEngine *> startingEngines;
QList<QJSEngine *> stoppingEngines;
+ bool blockingMode;
void messageReceived(const QByteArray &) Q_DECL_OVERRIDE;
void engineAboutToBeAdded(QJSEngine *) Q_DECL_OVERRIDE;
diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.h b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.h
index 772e53bde7..cdce4cd240 100644
--- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.h
+++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.h
@@ -60,7 +60,7 @@ class QQmlProfilerServiceFactory : public QQmlDebugServiceFactory
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlDebugServiceFactory_iid FILE "qqmlprofilerservice.json")
public:
- QQmlDebugService *create(const QString &key);
+ QQmlDebugService *create(const QString &key) override;
};
QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapterfactory.h b/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapterfactory.h
index 489545b504..41b9875c03 100644
--- a/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapterfactory.h
+++ b/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapterfactory.h
@@ -61,7 +61,7 @@ class QQuickProfilerAdapterFactory : public QQmlAbstractProfilerAdapterFactory
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlAbstractProfilerAdapterFactory_iid FILE "qquickprofileradapter.json")
public:
- QQmlAbstractProfilerAdapter *create(const QString &key);
+ QQmlAbstractProfilerAdapter *create(const QString &key) override;
};
QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
index f449989598..f6f48e43a4 100644
--- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
+++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
@@ -346,7 +346,7 @@ void QQmlDebugServerImpl::parseArguments()
QString fileName;
QStringList services;
- const auto lstjsDebugArguments = args.splitRef(QLatin1Char(','));
+ const auto lstjsDebugArguments = args.splitRef(QLatin1Char(','), QString::SkipEmptyParts);
for (auto argsIt = lstjsDebugArguments.begin(), argsItEnd = lstjsDebugArguments.end(); argsIt != argsItEnd; ++argsIt) {
const QStringRef &strArgument = *argsIt;
if (strArgument.startsWith(QLatin1String("port:"))) {
@@ -377,7 +377,7 @@ void QQmlDebugServerImpl::parseArguments()
services.append(strArgument.mid(9).toString());
} else if (!services.isEmpty()) {
services.append(strArgument.toString());
- } else {
+ } else if (!strArgument.startsWith(QLatin1String("connector:"))) {
const QString message = tr("QML Debugger: Invalid argument \"%1\" detected."
" Ignoring the same.").arg(strArgument.toString());
qWarning("%s", qPrintable(message));
diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserverfactory.h b/src/plugins/qmltooling/qmldbg_server/qqmldebugserverfactory.h
index fd71b03019..2debabaeb2 100644
--- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserverfactory.h
+++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserverfactory.h
@@ -63,7 +63,7 @@ class QQmlDebugServerFactory : public QQmlDebugConnectorFactory
// QQmlDebugServer is for connection plugins.
Q_PLUGIN_METADATA(IID QQmlDebugConnectorFactory_iid FILE "qqmldebugserver.json")
public:
- QQmlDebugConnector *create(const QString &key);
+ QQmlDebugConnector *create(const QString &key) override;
};
QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnectionfactory.h b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnectionfactory.h
index 52d9f4b709..d3b0e00584 100644
--- a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnectionfactory.h
+++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnectionfactory.h
@@ -50,7 +50,7 @@ class QTcpServerConnectionFactory : public QQmlDebugServerConnectionFactory
Q_PLUGIN_METADATA(IID QQmlDebugServerConnectionFactory_iid FILE "qtcpserverconnection.json")
Q_INTERFACES(QQmlDebugServerConnectionFactory)
public:
- QQmlDebugServerConnection *create(const QString &key);
+ QQmlDebugServerConnection *create(const QString &key) override;
};
QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmltooling.pro b/src/plugins/qmltooling/qmltooling.pro
index 907fbe9273..8123e2999e 100644
--- a/src/plugins/qmltooling/qmltooling.pro
+++ b/src/plugins/qmltooling/qmltooling.pro
@@ -19,12 +19,16 @@ qtConfig(qml-network) {
# Services
SUBDIRS += \
qmldbg_debugger \
- qmldbg_profiler
+ qmldbg_profiler \
+ qmldbg_messages \
+ qmldbg_nativedebugger
qmldbg_server.depends = packetprotocol
qmldbg_native.depends = packetprotocol
qmldbg_debugger.depends = packetprotocol
qmldbg_profiler.depends = packetprotocol
+qmldbg_messages.depends = packetprotocol
+qmldbg_nativedebugger.depends = packetprotocol
qtHaveModule(quick) {
SUBDIRS += \
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp
index a318ce23f7..908f1221ab 100644
--- a/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp
+++ b/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp
@@ -61,6 +61,8 @@
#include <windows.ui.xaml.media.dxinterop.h>
#endif
+#include <comdef.h>
+
QT_BEGIN_NAMESPACE
// NOTE: Avoid categorized logging. It is slow.
@@ -98,6 +100,19 @@ static const int BUCKETS_PER_HEAP = 8; // must match freeMap
static const int DESCRIPTORS_PER_BUCKET = 32; // the bit map (freeMap) is quint32
static const int MAX_DESCRIPTORS_PER_HEAP = BUCKETS_PER_HEAP * DESCRIPTORS_PER_BUCKET;
+static QString comErrorMessage(HRESULT hr)
+{
+#ifndef Q_OS_WINRT
+ const _com_error comError(hr);
+#else
+ const _com_error comError(hr, nullptr);
+#endif
+ QString result = QLatin1String("Error 0x") + QString::number(ulong(hr), 16);
+ if (const wchar_t *msg = comError.ErrorMessage())
+ result += QLatin1String(": ") + QString::fromWCharArray(msg);
+ return result;
+}
+
D3D12_CPU_DESCRIPTOR_HANDLE QSGD3D12CPUDescriptorHeapManager::allocate(D3D12_DESCRIPTOR_HEAP_TYPE type)
{
D3D12_CPU_DESCRIPTOR_HANDLE h = {};
@@ -128,7 +143,8 @@ D3D12_CPU_DESCRIPTOR_HANDLE QSGD3D12CPUDescriptorHeapManager::allocate(D3D12_DES
HRESULT hr = m_device->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&heap.heap));
if (FAILED(hr)) {
- qWarning("Failed to create heap with type 0x%x: %x", type, hr);
+ qWarning("Failed to create heap with type 0x%x: %s",
+ type, qPrintable(comErrorMessage(hr)));
return h;
}
@@ -211,7 +227,8 @@ static void getHardwareAdapter(IDXGIFactory1 *factory, IDXGIAdapter1 **outAdapte
*outAdapter = adapter.Detach();
return;
} else {
- qWarning("Failed to create device for requested adapter '%s': 0x%x", qPrintable(name), hr);
+ qWarning("Failed to create device for requested adapter '%s': %s",
+ qPrintable(name), qPrintable(comErrorMessage(hr)));
}
}
}
@@ -270,7 +287,7 @@ void QSGD3D12DeviceManager::ensureCreated()
HRESULT hr = CreateDXGIFactory2(0, IID_PPV_ARGS(&m_factory));
if (FAILED(hr)) {
- qWarning("Failed to create DXGI: 0x%x", hr);
+ qWarning("Failed to create DXGI: %s", qPrintable(comErrorMessage(hr)));
return;
}
@@ -283,7 +300,7 @@ void QSGD3D12DeviceManager::ensureCreated()
if (SUCCEEDED(hr))
warp = false;
else
- qWarning("Failed to create device: 0x%x", hr);
+ qWarning("Failed to create device: %s", qPrintable(comErrorMessage(hr)));
}
if (warp) {
@@ -291,7 +308,7 @@ void QSGD3D12DeviceManager::ensureCreated()
m_factory->EnumWarpAdapter(IID_PPV_ARGS(&adapter));
HRESULT hr = D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_device));
if (FAILED(hr)) {
- qWarning("Failed to create WARP device: 0x%x", hr);
+ qWarning("Failed to create WARP device: %s", qPrintable(comErrorMessage(hr)));
return;
}
}
@@ -798,15 +815,18 @@ void QSGD3D12EnginePrivate::initialize(WId w, const QSize &size, float dpr, int
if (SUCCEEDED(hr)) {
hr = dcompDevice->CreateVisual(&dcompVisual);
if (FAILED(hr)) {
- qWarning("Failed to create DirectComposition visual: 0x%x", hr);
+ qWarning("Failed to create DirectComposition visual: %s",
+ qPrintable(comErrorMessage(hr)));
windowAlpha = false;
}
} else {
- qWarning("Failed to create DirectComposition target: 0x%x", hr);
+ qWarning("Failed to create DirectComposition target: %s",
+ qPrintable(comErrorMessage(hr)));
windowAlpha = false;
}
} else {
- qWarning("Failed to create DirectComposition device: 0x%x", hr);
+ qWarning("Failed to create DirectComposition device: %s",
+ qPrintable(comErrorMessage(hr)));
windowAlpha = false;
}
}
@@ -833,11 +853,13 @@ void QSGD3D12EnginePrivate::initialize(WId w, const QSize &size, float dpr, int
if (SUCCEEDED(hr)) {
hr = dcompTarget->SetRoot(dcompVisual.Get());
if (FAILED(hr)) {
- qWarning("SetRoot failed for DirectComposition target: 0x%x", hr);
+ qWarning("SetRoot failed for DirectComposition target: %s",
+ qPrintable(comErrorMessage(hr)));
windowAlpha = false;
}
} else {
- qWarning("SetContent failed for DirectComposition visual: 0x%x", hr);
+ qWarning("SetContent failed for DirectComposition visual: %s",
+ qPrintable(comErrorMessage(hr)));
windowAlpha = false;
}
} else {
@@ -867,11 +889,12 @@ void QSGD3D12EnginePrivate::initialize(WId w, const QSize &size, float dpr, int
ComPtr<IDXGISwapChain> baseSwapChain;
HRESULT hr = dev->dxgi()->CreateSwapChain(commandQueue.Get(), &swapChainDesc, &baseSwapChain);
if (FAILED(hr)) {
- qWarning("Failed to create swap chain: 0x%x", hr);
+ qWarning("Failed to create swap chain: %s", qPrintable(comErrorMessage(hr)));
return;
}
- if (FAILED(baseSwapChain.As(&swapChain))) {
- qWarning("Failed to cast swap chain");
+ hr = baseSwapChain.As(&swapChain);
+ if (FAILED(hr)) {
+ qWarning("Failed to cast swap chain: %s", qPrintable(comErrorMessage(hr)));
return;
}
}
@@ -1052,8 +1075,11 @@ ID3D12Resource *QSGD3D12EnginePrivate::createColorBuffer(D3D12_CPU_DESCRIPTOR_HA
rtDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
ID3D12Resource *resource = nullptr;
+ const D3D12_RESOURCE_STATES initialState = samples <= 1
+ ? D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE
+ : D3D12_RESOURCE_STATE_RENDER_TARGET;
if (FAILED(device->CreateCommittedResource(&heapProp, D3D12_HEAP_FLAG_NONE, &rtDesc,
- D3D12_RESOURCE_STATE_RENDER_TARGET, &clearValue, IID_PPV_ARGS(&resource)))) {
+ initialState, &clearValue, IID_PPV_ARGS(&resource)))) {
qWarning("Failed to create offscreen render target of size %dx%d", size.width(), size.height());
return nullptr;
}
@@ -1162,7 +1188,7 @@ void QSGD3D12EnginePrivate::setWindowSize(const QSize &size, float dpr)
deviceManager()->deviceLossDetected();
return;
} else if (FAILED(hr)) {
- qWarning("Failed to resize buffers: 0x%x", hr);
+ qWarning("Failed to resize buffers: %s", qPrintable(comErrorMessage(hr)));
return;
}
@@ -1185,7 +1211,7 @@ QSGD3D12CPUWaitableFence *QSGD3D12EnginePrivate::createCPUWaitableFence() const
QSGD3D12CPUWaitableFence *f = new QSGD3D12CPUWaitableFence;
HRESULT hr = device->CreateFence(f->value, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&f->fence));
if (FAILED(hr)) {
- qWarning("Failed to create fence: 0x%x", hr);
+ qWarning("Failed to create fence: %s", qPrintable(comErrorMessage(hr)));
return f;
}
f->event = CreateEvent(nullptr, FALSE, FALSE, nullptr);
@@ -1199,7 +1225,7 @@ void QSGD3D12EnginePrivate::waitForGPU(QSGD3D12CPUWaitableFence *f) const
if (f->fence->GetCompletedValue() < newValue) {
HRESULT hr = f->fence->SetEventOnCompletion(newValue, f->event);
if (FAILED(hr)) {
- qWarning("SetEventOnCompletion failed: 0x%x", hr);
+ qWarning("SetEventOnCompletion failed: %s", qPrintable(comErrorMessage(hr)));
return;
}
WaitForSingleObject(f->event, INFINITE);
@@ -1280,7 +1306,7 @@ ID3D12Resource *QSGD3D12EnginePrivate::createBuffer(int size)
HRESULT hr = device->CreateCommittedResource(&uploadHeapProp, D3D12_HEAP_FLAG_NONE, &bufDesc,
D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS(&buf));
if (FAILED(hr))
- qWarning("Failed to create buffer resource: 0x%x", hr);
+ qWarning("Failed to create buffer resource: %s", qPrintable(comErrorMessage(hr)));
return buf;
}
@@ -1637,7 +1663,7 @@ void QSGD3D12EnginePrivate::endDrawCalls(bool lastInFrame)
// Go!
HRESULT hr = frameCommandList->Close();
if (FAILED(hr)) {
- qWarning("Failed to close command list: 0x%x", hr);
+ qWarning("Failed to close command list: %s", qPrintable(comErrorMessage(hr)));
if (hr == E_INVALIDARG)
qWarning("Invalid arguments. Some of the commands in the list is invalid in some way.");
}
@@ -1871,7 +1897,8 @@ void QSGD3D12EnginePrivate::finalizePipeline(const QSGD3D12PipelineState &pipeli
HRESULT hr = device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&cachedPso->pso));
if (FAILED(hr)) {
- qWarning("Failed to create graphics pipeline state");
+ qWarning("Failed to create graphics pipeline state: %s",
+ qPrintable(comErrorMessage(hr)));
return;
}
@@ -2176,7 +2203,7 @@ void QSGD3D12EnginePrivate::present()
deviceManager()->deviceLossDetected();
return;
} else if (FAILED(hr)) {
- qWarning("Present failed: 0x%x", hr);
+ qWarning("Present failed: %s", qPrintable(comErrorMessage(hr)));
return;
}
@@ -2430,7 +2457,7 @@ void QSGD3D12EnginePrivate::createTexture(uint id, const QSize &size, QImage::Fo
HRESULT hr = device->CreateCommittedResource(&defaultHeapProp, D3D12_HEAP_FLAG_NONE, &textureDesc,
D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&t.texture));
if (FAILED(hr)) {
- qWarning("Failed to create texture resource: 0x%x", hr);
+ qWarning("Failed to create texture resource: %s", qPrintable(comErrorMessage(hr)));
return;
}
@@ -2495,7 +2522,8 @@ void QSGD3D12EnginePrivate::queueTextureResize(uint id, const QSize &size)
HRESULT hr = device->CreateCommittedResource(&defaultHeapProp, D3D12_HEAP_FLAG_NONE, &textureDesc,
D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&t.texture));
if (FAILED(hr)) {
- qWarning("Failed to create resized texture resource: 0x%x", hr);
+ qWarning("Failed to create resized texture resource: %s",
+ qPrintable(comErrorMessage(hr)));
return;
}
@@ -2951,7 +2979,8 @@ void QSGD3D12EnginePrivate::createRenderTarget(uint id, const QSize &size, const
HRESULT hr = device->CreateCommittedResource(&defaultHeapProp, D3D12_HEAP_FLAG_NONE, &textureDesc,
D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&rt.colorResolve));
if (FAILED(hr)) {
- qWarning("Failed to create resolve buffer: 0x%x", hr);
+ qWarning("Failed to create resolve buffer: %s",
+ qPrintable(comErrorMessage(hr)));
return;
}
@@ -3236,11 +3265,11 @@ void QSGD3D12EnginePrivate::DeviceLossTester::killDevice()
void *QSGD3D12EnginePrivate::getResource(QSGRendererInterface::Resource resource) const
{
switch (resource) {
- case QSGRendererInterface::Device:
+ case QSGRendererInterface::DeviceResource:
return device;
- case QSGRendererInterface::CommandQueue:
+ case QSGRendererInterface::CommandQueueResource:
return commandQueue.Get();
- case QSGRendererInterface::CommandList:
+ case QSGRendererInterface::CommandListResource:
return commandList;
default:
break;
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12publicnodes.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12publicnodes.cpp
index 783caa280f..1f01c440e5 100644
--- a/src/plugins/scenegraph/d3d12/qsgd3d12publicnodes.cpp
+++ b/src/plugins/scenegraph/d3d12/qsgd3d12publicnodes.cpp
@@ -39,10 +39,6 @@
#include "qsgd3d12publicnodes_p.h"
-// for rebuildGeometry
-#include <private/qsgdefaultninepatchnode_p.h>
-#include <private/qsgdefaultimagenode_p.h>
-
QT_BEGIN_NAMESPACE
QSGD3D12RectangleNode::QSGD3D12RectangleNode()
@@ -138,7 +134,7 @@ void QSGD3D12ImageNode::setRect(const QRectF &r)
return;
m_rect = r;
- QSGDefaultImageNode::rebuildGeometry(&m_geometry, texture(), m_rect, m_sourceRect, m_texCoordMode);
+ QSGImageNode::rebuildGeometry(&m_geometry, texture(), m_rect, m_sourceRect, m_texCoordMode);
markDirty(DirtyGeometry);
}
@@ -153,7 +149,7 @@ void QSGD3D12ImageNode::setSourceRect(const QRectF &r)
return;
m_sourceRect = r;
- QSGDefaultImageNode::rebuildGeometry(&m_geometry, texture(), m_rect, m_sourceRect, m_texCoordMode);
+ QSGImageNode::rebuildGeometry(&m_geometry, texture(), m_rect, m_sourceRect, m_texCoordMode);
markDirty(DirtyGeometry);
}
@@ -170,7 +166,7 @@ void QSGD3D12ImageNode::setTexture(QSGTexture *texture)
delete m_material.texture();
m_material.setTexture(texture);
- QSGDefaultImageNode::rebuildGeometry(&m_geometry, texture, m_rect, m_sourceRect, m_texCoordMode);
+ QSGImageNode::rebuildGeometry(&m_geometry, texture, m_rect, m_sourceRect, m_texCoordMode);
DirtyState dirty = DirtyMaterial;
const bool wasAtlas = m_isAtlasTexture;
@@ -192,7 +188,7 @@ void QSGD3D12ImageNode::setTextureCoordinatesTransform(TextureCoordinatesTransfo
return;
m_texCoordMode = mode;
- QSGDefaultImageNode::rebuildGeometry(&m_geometry, texture(), m_rect, m_sourceRect, m_texCoordMode);
+ QSGImageNode::rebuildGeometry(&m_geometry, texture(), m_rect, m_sourceRect, m_texCoordMode);
markDirty(DirtyMaterial);
}
@@ -247,7 +243,7 @@ void QSGD3D12NinePatchNode::setPadding(qreal left, qreal top, qreal right, qreal
void QSGD3D12NinePatchNode::update()
{
- QSGDefaultNinePatchNode::rebuildGeometry(m_material.texture(), &m_geometry, m_padding, m_bounds, m_devicePixelRatio);
+ QSGNinePatchNode::rebuildGeometry(m_material.texture(), &m_geometry, m_padding, m_bounds, m_devicePixelRatio);
markDirty(QSGNode::DirtyGeometry | QSGNode::DirtyMaterial);
}
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp
index c53a1fa6c1..60b76deb2e 100644
--- a/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp
+++ b/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp
@@ -421,7 +421,8 @@ void QSGD3D12RenderLoop::renderWindow(QQuickWindow *window)
if (profileFrames)
polishTime = renderTimer.nsecsElapsed();
Q_QUICK_SG_PROFILE_SWITCH(QQuickProfiler::SceneGraphPolishFrame,
- QQuickProfiler::SceneGraphRenderLoopFrame);
+ QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphPolishPolish);
emit window->afterAnimating();
@@ -463,13 +464,15 @@ void QSGD3D12RenderLoop::renderWindow(QQuickWindow *window)
if (profileFrames)
syncTime = renderTimer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopSync);
wd->renderSceneGraph(window->size());
if (profileFrames)
renderTime = renderTimer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopRender);
if (!data.grabOnly) {
// The engine is able to have multiple frames in flight. This in effect is
@@ -496,7 +499,8 @@ void QSGD3D12RenderLoop::renderWindow(QQuickWindow *window)
qint64 swapTime = 0;
if (profileFrames)
swapTime = renderTimer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame);
+ Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopSwap);
if (Q_UNLIKELY(debug_time())) {
static QTime lastFrameTime = QTime::currentTime();
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp
index a803f67380..317471eeec 100644
--- a/src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp
+++ b/src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp
@@ -597,7 +597,8 @@ void QSGD3D12RenderThread::syncAndRender()
if (Q_UNLIKELY(debug_time()))
syncTime = threadTimer.nsecsElapsed();
#endif
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopSync);
if (!syncResultedInChanges && !repaintRequested) {
if (Q_UNLIKELY(debug_loop()))
@@ -632,7 +633,8 @@ void QSGD3D12RenderThread::syncAndRender()
wd->renderSceneGraph(engine->windowSize());
if (Q_UNLIKELY(debug_time()))
renderTime = threadTimer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopRender);
// The engine is able to have multiple frames in flight. This in effect is
// similar to BufferQueueingOpenGL. Provide an env var to force the
@@ -649,7 +651,8 @@ void QSGD3D12RenderThread::syncAndRender()
// blockOnEachFrame is not used, but emit it for compatibility.
wd->fireFrameSwapped();
} else {
- Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphRenderLoopFrame, 1);
+ Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopSync, 1);
if (Q_UNLIKELY(debug_loop()))
qDebug("RT - window not ready, skipping render");
}
@@ -671,7 +674,8 @@ void QSGD3D12RenderThread::syncAndRender()
int((renderTime - syncTime) / 1000000),
int(threadTimer.elapsed() - renderTime / 1000000));
- Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame);
+ Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopSwap);
static int devLossTest = qEnvironmentVariableIntValue("QT_D3D_TEST_DEVICE_LOSS");
if (devLossTest > 0) {
@@ -1127,7 +1131,8 @@ void QSGD3D12ThreadedRenderLoop::polishAndSync(WindowData *w, bool inExpose)
if (Q_UNLIKELY(debug_time()))
polishTime = timer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync,
+ QQuickProfiler::SceneGraphPolishAndSyncPolish);
w->updateDuringSync = false;
@@ -1144,7 +1149,8 @@ void QSGD3D12ThreadedRenderLoop::polishAndSync(WindowData *w, bool inExpose)
qDebug("polishAndSync - wait for sync");
if (Q_UNLIKELY(debug_time()))
waitTime = timer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync,
+ QQuickProfiler::SceneGraphPolishAndSyncWait);
w->thread->waitCondition.wait(&w->thread->mutex);
lockedForSync = false;
w->thread->mutex.unlock();
@@ -1153,7 +1159,8 @@ void QSGD3D12ThreadedRenderLoop::polishAndSync(WindowData *w, bool inExpose)
if (Q_UNLIKELY(debug_time()))
syncTime = timer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync,
+ QQuickProfiler::SceneGraphPolishAndSyncSync);
if (!animationTimer && anim->isRunning()) {
if (Q_UNLIKELY(debug_loop()))
@@ -1175,7 +1182,8 @@ void QSGD3D12ThreadedRenderLoop::polishAndSync(WindowData *w, bool inExpose)
<< ", animations=" << (timer.nsecsElapsed() - syncTime) / 1000000
<< " - (on gui thread) " << window;
- Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphPolishAndSync);
+ Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphPolishAndSync,
+ QQuickProfiler::SceneGraphPolishAndSyncAnimations);
}
#include "qsgd3d12threadedrenderloop.moc"
diff --git a/src/plugins/scenegraph/openvg/openvg.json b/src/plugins/scenegraph/openvg/openvg.json
new file mode 100644
index 0000000000..224afbf784
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/openvg.json
@@ -0,0 +1,3 @@
+{
+ "Keys": ["openvg"]
+}
diff --git a/src/plugins/scenegraph/openvg/openvg.pro b/src/plugins/scenegraph/openvg/openvg.pro
new file mode 100644
index 0000000000..8a58796a05
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/openvg.pro
@@ -0,0 +1,56 @@
+TARGET = qsgopenvgbackend
+
+QT += gui-private core-private qml-private quick-private
+
+PLUGIN_TYPE = scenegraph
+PLUGIN_CLASS_NAME = QSGOpenVGAdaptation
+load(qt_plugin)
+
+QMAKE_TARGET_PRODUCT = "Qt Quick OpenVG Renderer (Qt $$QT_VERSION)"
+QMAKE_TARGET_DESCRIPTION = "Quick OpenVG Renderer for Qt."
+
+QMAKE_USE += openvg
+
+OTHER_FILES += $$PWD/openvg.json
+
+HEADERS += \
+ qsgopenvgadaptation_p.h \
+ qsgopenvgcontext_p.h \
+ qsgopenvgrenderloop_p.h \
+ qsgopenvgglyphnode_p.h \
+ qopenvgcontext_p.h \
+ qsgopenvgrenderer_p.h \
+ qsgopenvginternalrectanglenode.h \
+ qsgopenvgnodevisitor.h \
+ qopenvgmatrix.h \
+ qsgopenvgpublicnodes.h \
+ qsgopenvginternalimagenode.h \
+ qsgopenvgtexture.h \
+ qsgopenvglayer.h \
+ qsgopenvghelpers.h \
+ qsgopenvgfontglyphcache.h \
+ qsgopenvgpainternode.h \
+ qsgopenvgspritenode.h \
+ qsgopenvgrenderable.h \
+ qopenvgoffscreensurface.h
+
+SOURCES += \
+ qsgopenvgadaptation.cpp \
+ qsgopenvgcontext.cpp \
+ qsgopenvgrenderloop.cpp \
+ qsgopenvgglyphnode.cpp \
+ qopenvgcontext.cpp \
+ qsgopenvgrenderer.cpp \
+ qsgopenvginternalrectanglenode.cpp \
+ qsgopenvgnodevisitor.cpp \
+ qopenvgmatrix.cpp \
+ qsgopenvgpublicnodes.cpp \
+ qsgopenvginternalimagenode.cpp \
+ qsgopenvgtexture.cpp \
+ qsgopenvglayer.cpp \
+ qsgopenvghelpers.cpp \
+ qsgopenvgfontglyphcache.cpp \
+ qsgopenvgpainternode.cpp \
+ qsgopenvgspritenode.cpp \
+ qsgopenvgrenderable.cpp \
+ qopenvgoffscreensurface.cpp
diff --git a/src/plugins/scenegraph/openvg/qopenvgcontext.cpp b/src/plugins/scenegraph/openvg/qopenvgcontext.cpp
new file mode 100644
index 0000000000..ea2c24afdb
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qopenvgcontext.cpp
@@ -0,0 +1,218 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qpa/qplatformnativeinterface.h>
+#include <QtGui/QGuiApplication>
+#include <QtCore/QVector>
+#include <QtCore/QDebug>
+
+#include "qopenvgcontext_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QOpenVGContext::QOpenVGContext(QWindow *window)
+ : m_window(window)
+{
+ QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
+ m_display = reinterpret_cast<EGLDisplay>(nativeInterface->nativeResourceForWindow("EglDisplay", window));
+ m_surface = reinterpret_cast<EGLSurface>(nativeInterface->nativeResourceForWindow("EglSurface", window));
+
+ if (m_display == 0)
+ qFatal("QOpenVGContext: failed to get EGLDisplay");
+ if (m_surface == 0)
+ qFatal("QOpenVGContext: failed to get EGLSurface");
+
+ EGLint configID = 0;
+ if (eglQuerySurface(m_display, m_surface, EGL_CONFIG_ID, &configID)) {
+ EGLint numConfigs;
+ const EGLint configAttribs[] = {
+ EGL_CONFIG_ID, configID,
+ EGL_NONE
+ };
+ eglChooseConfig(m_display, configAttribs, &m_config, 1, &numConfigs);
+ } else {
+ qFatal("QOpenVGContext: failed to get surface config");
+ }
+
+ // Create an EGL Context
+ eglBindAPI(EGL_OPENVG_API);
+ m_context = eglCreateContext(m_display, m_config, EGL_NO_CONTEXT, 0);
+ if (!m_context)
+ qFatal("QOpenVGContext: eglCreateContext failed");
+}
+
+QOpenVGContext::~QOpenVGContext()
+{
+ doneCurrent();
+ eglDestroyContext(m_display, m_context);
+}
+
+void QOpenVGContext::makeCurrent()
+{
+ makeCurrent(m_surface);
+}
+
+void QOpenVGContext::makeCurrent(EGLSurface surface)
+{
+ eglMakeCurrent(m_display, surface, surface, m_context);
+}
+
+void QOpenVGContext::doneCurrent()
+{
+ eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+}
+
+void QOpenVGContext::swapBuffers()
+{
+ swapBuffers(m_surface);
+}
+
+void QOpenVGContext::swapBuffers(EGLSurface surface)
+{
+ eglSwapBuffers(m_display, surface);
+}
+
+QWindow *QOpenVGContext::window() const
+{
+ return m_window;
+}
+
+QImage QOpenVGContext::readFramebuffer(const QSize &size)
+{
+ QImage framebufferImage(size, QImage::Format_RGB32);
+ vgReadPixels(framebufferImage.bits(), framebufferImage.bytesPerLine(), VG_sXRGB_8888, 0, 0, size.width(), size.height());
+ return framebufferImage.mirrored(false, true);
+}
+
+void QOpenVGContext::getConfigs()
+{
+ EGLint configsAvailable = 0;
+ eglGetConfigs(m_display, 0, 0, &configsAvailable);
+
+ QVector<EGLConfig> configs(configsAvailable);
+ eglGetConfigs(m_display, configs.data(), configs.size(), &configsAvailable);
+
+ for (EGLConfig config : configs) {
+ EGLint value;
+ eglGetConfigAttrib(m_display, config, EGL_CONFIG_ID, &value);
+ qDebug() << "#################\n" << "EGL_CONFIG_ID:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_BUFFER_SIZE, &value);
+ qDebug() << "EGL_BUFFER_SIZE:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_ALPHA_SIZE, &value);
+ qDebug() << "EGL_ALPHA_SIZE:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_RED_SIZE, &value);
+ qDebug() << "EGL_RED_SIZE:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_GREEN_SIZE, &value);
+ qDebug() << "EGL_GREEN_SIZE:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_BLUE_SIZE, &value);
+ qDebug() << "EGL_BLUE_SIZE:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_DEPTH_SIZE, &value);
+ qDebug() << "EGL_DEPTH_SIZE:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_STENCIL_SIZE, &value);
+ qDebug() << "EGL_STENCIL_SIZE:" << value;
+
+ eglGetConfigAttrib(m_display, config, EGL_ALPHA_MASK_SIZE, &value);
+ qDebug() << "EGL_ALPHA_MASK_SIZE:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_BIND_TO_TEXTURE_RGB, &value);
+ qDebug() << "EGL_BIND_TO_TEXTURE_RGB:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_BIND_TO_TEXTURE_RGBA, &value);
+ qDebug() << "EGL_BIND_TO_TEXTURE_RGBA:" << value;
+
+
+ eglGetConfigAttrib(m_display, config, EGL_COLOR_BUFFER_TYPE, &value);
+ qDebug() << "EGL_COLOR_BUFFER_TYPE:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_CONFIG_CAVEAT, &value);
+ qDebug() << "EGL_CONFIG_CAVEAT:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_CONFORMANT, &value);
+ qDebug() << "EGL_CONFORMANT:" << value;
+
+
+ eglGetConfigAttrib(m_display, config, EGL_LEVEL, &value);
+ qDebug() << "EGL_LEVEL:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_LUMINANCE_SIZE, &value);
+ qDebug() << "EGL_LUMINANCE_SIZE:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_MAX_PBUFFER_WIDTH, &value);
+ qDebug() << "EGL_MAX_PBUFFER_WIDTH:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_MAX_PBUFFER_HEIGHT, &value);
+ qDebug() << "EGL_MAX_PBUFFER_HEIGHT:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_MAX_PBUFFER_PIXELS, &value);
+ qDebug() << "EGL_MAX_PBUFFER_PIXELS:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_MAX_SWAP_INTERVAL, &value);
+ qDebug() << "EGL_MAX_SWAP_INTERVAL:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_MIN_SWAP_INTERVAL, &value);
+ qDebug() << "EGL_MIN_SWAP_INTERVAL:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_NATIVE_RENDERABLE, &value);
+ qDebug() << "EGL_NATIVE_RENDERABLE:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_NATIVE_VISUAL_ID, &value);
+ qDebug() << "EGL_NATIVE_VISUAL_ID:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_NATIVE_VISUAL_TYPE, &value);
+ qDebug() << "EGL_NATIVE_VISUAL_TYPE:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_RENDERABLE_TYPE, &value);
+ qDebug() << "EGL_RENDERABLE_TYPE:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_SAMPLE_BUFFERS, &value);
+ qDebug() << "EGL_SAMPLE_BUFFERS:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_SAMPLES, &value);
+ qDebug() << "EGL_SAMPLES:" << value;
+
+ eglGetConfigAttrib(m_display, config, EGL_SURFACE_TYPE, &value);
+ qDebug() << "EGL_SURFACE_TYPE:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_TRANSPARENT_TYPE, &value);
+ qDebug() << "EGL_TRANSPARENT_TYPE:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_TRANSPARENT_RED_VALUE, &value);
+ qDebug() << "EGL_TRANSPARENT_RED_VALUE:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_TRANSPARENT_GREEN_VALUE, &value);
+ qDebug() << "EGL_TRANSPARENT_GREEN_VALUE:" << value;
+ eglGetConfigAttrib(m_display, config, EGL_TRANSPARENT_BLUE_VALUE, &value);
+ qDebug() << "EGL_TRANSPARENT_BLUE_VALUE:" << value;
+ }
+}
+
+void QOpenVGContext::checkErrors()
+{
+ VGErrorCode error;
+ EGLint eglError;
+ do {
+ error = vgGetError();
+ eglError = eglGetError();
+ qDebug() << "error: " << QString::number(error, 16);
+ qDebug() << "eglError: " << QString::number(eglError, 16);
+ } while (error != VG_NO_ERROR && eglError != EGL_SUCCESS);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/scenegraph/openvg/qopenvgcontext_p.h b/src/plugins/scenegraph/openvg/qopenvgcontext_p.h
new file mode 100644
index 0000000000..a1ba73957f
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qopenvgcontext_p.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QOPENVGCONTEXT_H
+#define QOPENVGCONTEXT_H
+
+#include <QtGui/QWindow>
+#include <QtGui/QImage>
+
+#include <EGL/egl.h>
+#include <VG/openvg.h>
+
+QT_BEGIN_NAMESPACE
+
+class QOpenVGContext
+{
+public:
+ QOpenVGContext(QWindow *window);
+ ~QOpenVGContext();
+
+ void makeCurrent();
+ void makeCurrent(EGLSurface surface);
+ void doneCurrent();
+ void swapBuffers();
+ void swapBuffers(EGLSurface surface);
+
+
+ QWindow *window() const;
+
+ EGLDisplay eglDisplay() { return m_display; }
+ EGLConfig eglConfig() { return m_config; }
+ EGLContext eglContext() { return m_context; }
+
+ QImage readFramebuffer(const QSize &size);
+
+ void getConfigs();
+
+ static void checkErrors();
+
+private:
+ EGLSurface m_surface;
+ EGLDisplay m_display;
+ EGLConfig m_config;
+ EGLContext m_context;
+
+ QWindow *m_window;
+
+};
+
+QT_END_NAMESPACE
+
+#endif // QOPENVGCONTEXT_H
diff --git a/src/plugins/scenegraph/openvg/qopenvgmatrix.cpp b/src/plugins/scenegraph/openvg/qopenvgmatrix.cpp
new file mode 100644
index 0000000000..83ce96578e
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qopenvgmatrix.cpp
@@ -0,0 +1,378 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qopenvgmatrix.h"
+
+QT_BEGIN_NAMESPACE
+
+// QOpenVGMatrix: Because Qt will never have enough matrix classes
+// Internally the data is stored as column-major format
+// So this is a 3x3 version of QMatrix4x4 for optimal
+// OpenVG usage.
+
+QOpenVGMatrix::QOpenVGMatrix()
+{
+ setToIdentity();
+}
+
+QOpenVGMatrix::QOpenVGMatrix(const float *values)
+{
+ for (int col = 0; col < 3; ++col)
+ for (int row = 0; row < 3; ++row)
+ m[col][row] = values[col * 3 + row];
+}
+
+const float &QOpenVGMatrix::operator()(int row, int column) const
+{
+ Q_ASSERT(row >= 0 && row < 4 && column >= 0 && column < 4);
+ return m[column][row];
+}
+
+float &QOpenVGMatrix::operator()(int row, int column)
+{
+ Q_ASSERT(row >= 0 && row < 4 && column >= 0 && column < 4);
+ return m[column][row];
+}
+
+bool QOpenVGMatrix::isIdentity() const
+{
+ if (m[0][0] != 1.0f || m[0][1] != 0.0f || m[0][2] != 0.0f)
+ return false;
+ if ( m[1][0] != 0.0f || m[1][1] != 1.0f)
+ return false;
+ if (m[1][2] != 0.0f || m[2][0] != 0.0f)
+ return false;
+ if (m[2][1] != 0.0f || m[2][2] != 1.0f)
+ return false;
+
+ return true;
+}
+
+void QOpenVGMatrix::setToIdentity()
+{
+ m[0][0] = 1.0f;
+ m[0][1] = 0.0f;
+ m[0][2] = 0.0f;
+ m[1][0] = 0.0f;
+ m[1][1] = 1.0f;
+ m[1][2] = 0.0f;
+ m[2][0] = 0.0f;
+ m[2][1] = 0.0f;
+ m[2][2] = 1.0f;
+}
+
+bool QOpenVGMatrix::isAffine() const
+{
+ if (m[0][2] == 0.0f && m[1][2] == 0.0f && m[2][2] == 1.0f)
+ return true;
+
+ return false;
+}
+
+QPointF QOpenVGMatrix::map(const QPointF &point) const
+{
+ return *this * point;
+}
+
+void QOpenVGMatrix::fill(float value)
+{
+ m[0][0] = value;
+ m[0][1] = value;
+ m[0][2] = value;
+ m[1][0] = value;
+ m[1][1] = value;
+ m[1][2] = value;
+ m[2][0] = value;
+ m[2][1] = value;
+ m[2][2] = value;
+}
+
+QOpenVGMatrix QOpenVGMatrix::transposed() const
+{
+ QOpenVGMatrix result;
+ for (int row = 0; row < 3; ++row) {
+ for (int col = 0; col < 3; ++col)
+ result.m[col][row] = m[row][col];
+ }
+ return result;
+}
+
+QOpenVGMatrix &QOpenVGMatrix::operator+=(const QOpenVGMatrix &other)
+{
+ m[0][0] += other.m[0][0];
+ m[0][1] += other.m[0][1];
+ m[0][2] += other.m[0][2];
+ m[1][0] += other.m[1][0];
+ m[1][1] += other.m[1][1];
+ m[1][2] += other.m[1][2];
+ m[2][0] += other.m[2][0];
+ m[2][1] += other.m[2][1];
+ m[2][2] += other.m[2][2];
+ return *this;
+}
+
+QOpenVGMatrix &QOpenVGMatrix::operator-=(const QOpenVGMatrix &other)
+{
+ m[0][0] -= other.m[0][0];
+ m[0][1] -= other.m[0][1];
+ m[0][2] -= other.m[0][2];
+ m[1][0] -= other.m[1][0];
+ m[1][1] -= other.m[1][1];
+ m[1][2] -= other.m[1][2];
+ m[2][0] -= other.m[2][0];
+ m[2][1] -= other.m[2][1];
+ m[2][2] -= other.m[2][2];
+ return *this;
+}
+
+QOpenVGMatrix &QOpenVGMatrix::operator*=(const QOpenVGMatrix &other)
+{
+ float m0, m1;
+ m0 = m[0][0] * other.m[0][0]
+ + m[1][0] * other.m[0][1]
+ + m[2][0] * other.m[0][2];
+ m1 = m[0][0] * other.m[1][0]
+ + m[1][0] * other.m[1][1]
+ + m[2][0] * other.m[1][2];
+ m[2][0] = m[0][0] * other.m[2][0]
+ + m[1][0] * other.m[2][1]
+ + m[2][0] * other.m[2][2];
+ m[0][0] = m0;
+ m[1][0] = m1;
+
+ m0 = m[0][1] * other.m[0][0]
+ + m[1][1] * other.m[0][1]
+ + m[2][1] * other.m[0][2];
+ m1 = m[0][1] * other.m[1][0]
+ + m[1][1] * other.m[1][1]
+ + m[2][1] * other.m[1][2];
+ m[2][1] = m[0][1] * other.m[2][0]
+ + m[1][1] * other.m[2][1]
+ + m[2][1] * other.m[2][2];
+ m[0][1] = m0;
+ m[1][1] = m1;
+
+ m0 = m[0][2] * other.m[0][0]
+ + m[1][2] * other.m[0][1]
+ + m[2][2] * other.m[0][2];
+ m1 = m[0][2] * other.m[1][0]
+ + m[1][2] * other.m[1][1]
+ + m[2][2] * other.m[1][2];
+ m[2][2] = m[0][2] * other.m[2][0]
+ + m[1][2] * other.m[2][1]
+ + m[2][2] * other.m[2][2];
+ m[0][2] = m0;
+ m[1][2] = m1;
+ return *this;
+}
+
+QOpenVGMatrix &QOpenVGMatrix::operator*=(float factor)
+{
+ m[0][0] *= factor;
+ m[0][1] *= factor;
+ m[0][2] *= factor;
+ m[1][0] *= factor;
+ m[1][1] *= factor;
+ m[1][2] *= factor;
+ m[2][0] *= factor;
+ m[2][1] *= factor;
+ m[2][2] *= factor;
+ return *this;
+}
+
+QOpenVGMatrix &QOpenVGMatrix::operator/=(float divisor)
+{
+ m[0][0] /= divisor;
+ m[0][1] /= divisor;
+ m[0][2] /= divisor;
+ m[1][0] /= divisor;
+ m[1][1] /= divisor;
+ m[1][2] /= divisor;
+ m[2][0] /= divisor;
+ m[2][1] /= divisor;
+ m[2][2] /= divisor;
+ return *this;
+}
+
+bool QOpenVGMatrix::operator==(const QOpenVGMatrix &other) const
+{
+ return m[0][0] == other.m[0][0] &&
+ m[0][1] == other.m[0][1] &&
+ m[0][2] == other.m[0][2] &&
+ m[1][0] == other.m[1][0] &&
+ m[1][1] == other.m[1][1] &&
+ m[1][2] == other.m[1][2] &&
+ m[2][0] == other.m[2][0] &&
+ m[2][1] == other.m[2][1] &&
+ m[2][2] == other.m[2][2];
+}
+
+bool QOpenVGMatrix::operator!=(const QOpenVGMatrix &other) const
+{
+ return m[0][0] != other.m[0][0] ||
+ m[0][1] != other.m[0][1] ||
+ m[0][2] != other.m[0][2] ||
+ m[1][0] != other.m[1][0] ||
+ m[1][1] != other.m[1][1] ||
+ m[1][2] != other.m[1][2] ||
+ m[2][0] != other.m[2][0] ||
+ m[2][1] != other.m[2][1] ||
+ m[2][2] != other.m[2][2];
+}
+
+void QOpenVGMatrix::copyDataTo(float *values) const
+{
+ // Row-Major?
+ for (int row = 0; row < 3; ++row) {
+ for (int col = 0; col < 3; ++col)
+ values[row * 3 + col] = float(m[col][row]);
+ }
+}
+
+QOpenVGMatrix operator*(const QOpenVGMatrix &m1, const QOpenVGMatrix &m2)
+{
+ QOpenVGMatrix matrix;
+ matrix.m[0][0] = m1.m[0][0] * m2.m[0][0]
+ + m1.m[1][0] * m2.m[0][1]
+ + m1.m[2][0] * m2.m[0][2];
+ matrix.m[0][1] = m1.m[0][1] * m2.m[0][0]
+ + m1.m[1][1] * m2.m[0][1]
+ + m1.m[2][1] * m2.m[0][2];
+ matrix.m[0][2] = m1.m[0][2] * m2.m[0][0]
+ + m1.m[1][2] * m2.m[0][1]
+ + m1.m[2][2] * m2.m[0][2];
+
+ matrix.m[1][0] = m1.m[0][0] * m2.m[1][0]
+ + m1.m[1][0] * m2.m[1][1]
+ + m1.m[2][0] * m2.m[1][2];
+ matrix.m[1][1] = m1.m[0][1] * m2.m[1][0]
+ + m1.m[1][1] * m2.m[1][1]
+ + m1.m[2][1] * m2.m[1][2];
+ matrix.m[1][2] = m1.m[0][2] * m2.m[1][0]
+ + m1.m[1][2] * m2.m[1][1]
+ + m1.m[2][2] * m2.m[1][2];
+
+ matrix.m[2][0] = m1.m[0][0] * m2.m[2][0]
+ + m1.m[1][0] * m2.m[2][1]
+ + m1.m[2][0] * m2.m[2][2];
+ matrix.m[2][1] = m1.m[0][1] * m2.m[2][0]
+ + m1.m[1][1] * m2.m[2][1]
+ + m1.m[2][1] * m2.m[2][2];
+ matrix.m[2][2] = m1.m[0][2] * m2.m[2][0]
+ + m1.m[1][2] * m2.m[2][1]
+ + m1.m[2][2] * m2.m[2][2];
+ return matrix;
+}
+
+QPointF operator*(const QPointF& point, const QOpenVGMatrix& matrix)
+{
+ float xin = point.x();
+ float yin = point.y();
+ float x = xin * matrix.m[0][0] +
+ yin * matrix.m[0][1] +
+ matrix.m[0][2];
+ float y = xin * matrix.m[1][0] +
+ yin * matrix.m[1][1] +
+ matrix.m[1][2];
+ float w = xin * matrix.m[2][0] +
+ yin * matrix.m[2][1] +
+ matrix.m[2][2];
+ if (w == 1.0f) {
+ return QPointF(float(x), float(y));
+ } else {
+ return QPointF(float(x / w), float(y / w));
+ }
+}
+
+QPointF operator*(const QOpenVGMatrix& matrix, const QPointF& point)
+{
+ float xin = point.x();
+ float yin = point.y();
+ float x = xin * matrix.m[0][0] +
+ yin * matrix.m[1][0] +
+ matrix.m[2][0];
+ float y = xin * matrix.m[0][1] +
+ yin * matrix.m[1][1] +
+ matrix.m[2][1];
+ float w = xin * matrix.m[0][2] +
+ yin * matrix.m[1][2] +
+ matrix.m[2][2];
+ if (w == 1.0f) {
+ return QPointF(float(x), float(y));
+ } else {
+ return QPointF(float(x / w), float(y / w));
+ }
+}
+
+QDebug operator<<(QDebug dbg, const QOpenVGMatrix &m)
+{
+ QDebugStateSaver saver(dbg);
+ // Output in row-major order because it is more human-readable.
+ dbg.nospace() << "QOpenVGMatrix:(" << endl
+ << qSetFieldWidth(10)
+ << m(0, 0) << m(0, 1) << m(0, 2) << endl
+ << m(1, 0) << m(1, 1) << m(1, 2) << endl
+ << m(2, 0) << m(2, 1) << m(2, 2) << endl
+ << qSetFieldWidth(0) << ')';
+ return dbg;
+}
+
+QDataStream &operator<<(QDataStream &stream, const QOpenVGMatrix &matrix)
+{
+ for (int row = 0; row < 3; ++row)
+ for (int col = 0; col < 3; ++col)
+ stream << matrix(row, col);
+ return stream;
+}
+
+
+QDataStream &operator>>(QDataStream &stream, QOpenVGMatrix &matrix)
+{
+ float x;
+ for (int row = 0; row < 4; ++row) {
+ for (int col = 0; col < 4; ++col) {
+ stream >> x;
+ matrix(row, col) = x;
+ }
+ }
+ return stream;
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/plugins/scenegraph/openvg/qopenvgmatrix.h b/src/plugins/scenegraph/openvg/qopenvgmatrix.h
new file mode 100644
index 0000000000..f51bf8147d
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qopenvgmatrix.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QOPENVGMATRIX_H
+#define QOPENVGMATRIX_H
+
+#include <QtCore/qdebug.h>
+#include <QtCore/QDataStream>
+#include <QtCore/QPointF>
+
+QT_BEGIN_NAMESPACE
+
+class QOpenVGMatrix
+{
+public:
+ QOpenVGMatrix();
+ explicit QOpenVGMatrix(const float *values);
+
+ const float& operator()(int row, int column) const;
+ float& operator()(int row, int column);
+
+ bool isIdentity() const;
+ void setToIdentity();
+
+ bool isAffine() const;
+
+ QPointF map(const QPointF& point) const;
+
+ void fill(float value);
+
+ QOpenVGMatrix transposed() const;
+
+ QOpenVGMatrix& operator+=(const QOpenVGMatrix& other);
+ QOpenVGMatrix& operator-=(const QOpenVGMatrix& other);
+ QOpenVGMatrix& operator*=(const QOpenVGMatrix& other);
+ QOpenVGMatrix& operator*=(float factor);
+ QOpenVGMatrix& operator/=(float divisor);
+ friend QOpenVGMatrix operator*(const QOpenVGMatrix& m1, const QOpenVGMatrix& m2);
+ friend QPointF operator*(const QPointF& point, const QOpenVGMatrix& matrix);
+ friend QPointF operator*(const QOpenVGMatrix& matrix, const QPointF& point);
+#ifndef QT_NO_DEBUG_STREAM
+ friend QDebug operator<<(QDebug dbg, const QOpenVGMatrix &m);
+#endif
+ bool operator==(const QOpenVGMatrix& other) const;
+ bool operator!=(const QOpenVGMatrix& other) const;
+
+ void copyDataTo(float *values) const;
+
+ float *data() { return *m; }
+ const float *data() const { return *m; }
+ const float *constData() const { return *m; }
+
+private:
+ float m[3][3];
+};
+
+QOpenVGMatrix operator*(const QOpenVGMatrix& m1, const QOpenVGMatrix& m2);
+QPointF operator*(const QPointF& point, const QOpenVGMatrix& matrix);
+QPointF operator*(const QOpenVGMatrix& matrix, const QPointF& point);
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QOpenVGMatrix &m);
+#endif
+
+#ifndef QT_NO_DATASTREAM
+QDataStream &operator<<(QDataStream &, const QOpenVGMatrix &);
+QDataStream &operator>>(QDataStream &, QOpenVGMatrix &);
+#endif
+
+QT_END_NAMESPACE
+
+#endif // QOPENVGMATRIX_H
diff --git a/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.cpp b/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.cpp
new file mode 100644
index 0000000000..80af227fb4
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qopenvgoffscreensurface.h"
+
+#include <QtGui/QImage>
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+QOpenVGOffscreenSurface::QOpenVGOffscreenSurface(const QSize &size)
+ : m_size(size)
+{
+ m_display = eglGetCurrentDisplay();
+ m_image = vgCreateImage(VG_sARGB_8888_PRE, m_size.width(), m_size.height(), VG_IMAGE_QUALITY_BETTER);
+
+ const EGLint configAttribs[] = {
+ EGL_CONFORMANT, EGL_OPENVG_BIT,
+ EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
+ EGL_RED_SIZE, 8,
+ EGL_GREEN_SIZE, 8,
+ EGL_BLUE_SIZE, 8,
+ EGL_ALPHA_SIZE, 8,
+ EGL_ALPHA_MASK_SIZE, 8,
+ EGL_NONE
+ };
+
+ EGLConfig pbufferConfig;
+ EGLint numConfig;
+ eglChooseConfig(m_display, configAttribs, &pbufferConfig, 1, &numConfig);
+
+ m_context = eglCreateContext(m_display, pbufferConfig, eglGetCurrentContext(), 0);
+ if (m_context == EGL_NO_CONTEXT)
+ qWarning("QOpenVGOffscreenSurface: failed to create EGLContext");
+
+ m_renderTarget = eglCreatePbufferFromClientBuffer(m_display,
+ EGL_OPENVG_IMAGE,
+ (EGLClientBuffer)m_image,
+ pbufferConfig,
+ 0);
+ if (m_renderTarget == EGL_NO_SURFACE)
+ qWarning("QOpenVGOffscreenSurface: failed to create EGLSurface from VGImage");
+}
+
+QOpenVGOffscreenSurface::~QOpenVGOffscreenSurface()
+{
+ vgDestroyImage(m_image);
+ eglDestroySurface(m_display, m_renderTarget);
+ eglDestroyContext(m_display, m_context);
+}
+
+void QOpenVGOffscreenSurface::makeCurrent()
+{
+ EGLContext currentContext = eglGetCurrentContext();
+ if (m_context != currentContext) {
+ m_previousContext = eglGetCurrentContext();
+ m_previousReadSurface = eglGetCurrentSurface(EGL_READ);
+ m_previousDrawSurface = eglGetCurrentSurface(EGL_DRAW);
+
+ eglMakeCurrent(m_display, m_renderTarget, m_renderTarget, m_context);
+ }
+}
+
+void QOpenVGOffscreenSurface::doneCurrent()
+{
+ EGLContext currentContext = eglGetCurrentContext();
+ if (m_context == currentContext) {
+ eglMakeCurrent(m_display, m_previousDrawSurface, m_previousReadSurface, m_previousContext);
+ m_previousContext = EGL_NO_CONTEXT;
+ m_previousReadSurface = EGL_NO_SURFACE;
+ m_previousDrawSurface = EGL_NO_SURFACE;
+ }
+}
+
+void QOpenVGOffscreenSurface::swapBuffers()
+{
+ eglSwapBuffers(m_display, m_renderTarget);
+}
+
+QImage QOpenVGOffscreenSurface::readbackQImage()
+{
+ QImage readbackImage(m_size, QImage::Format_ARGB32_Premultiplied);
+ vgGetImageSubData(m_image, readbackImage.bits(), readbackImage.bytesPerLine(), VG_sARGB_8888_PRE, 0, 0, m_size.width(), m_size.height());
+ return readbackImage;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.h b/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.h
new file mode 100644
index 0000000000..746e4de1cd
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QOPENVGOFFSCREENSURFACE_H
+#define QOPENVGOFFSCREENSURFACE_H
+
+#include "qopenvgcontext_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QOpenVGOffscreenSurface
+{
+public:
+ QOpenVGOffscreenSurface(const QSize &size);
+ ~QOpenVGOffscreenSurface();
+
+ void makeCurrent();
+ void doneCurrent();
+ void swapBuffers();
+
+ VGImage image() { return m_image; }
+ QSize size() const { return m_size; }
+
+ QImage readbackQImage();
+
+private:
+ VGImage m_image;
+ QSize m_size;
+ EGLContext m_context;
+ EGLSurface m_renderTarget;
+ EGLContext m_previousContext = EGL_NO_CONTEXT;
+ EGLSurface m_previousReadSurface = EGL_NO_SURFACE;
+ EGLSurface m_previousDrawSurface = EGL_NO_SURFACE;
+ EGLDisplay m_display;
+};
+
+QT_END_NAMESPACE
+
+#endif // QOPENVGOFFSCREENSURFACE_H
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgadaptation.cpp b/src/plugins/scenegraph/openvg/qsgopenvgadaptation.cpp
new file mode 100644
index 0000000000..1a26522459
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgadaptation.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgopenvgadaptation_p.h"
+
+#include "qsgopenvgcontext_p.h"
+#include "qsgopenvgrenderloop_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QSGOpenVGAdaptation::QSGOpenVGAdaptation(QObject *parent)
+ : QSGContextPlugin(parent)
+{
+}
+
+QStringList QSGOpenVGAdaptation::keys() const
+{
+ return QStringList() << QLatin1String("openvg");
+}
+
+QSGContext *QSGOpenVGAdaptation::create(const QString &key) const
+{
+ Q_UNUSED(key)
+ if (!instance)
+ instance = new QSGOpenVGContext();
+ return instance;
+}
+
+QSGRenderLoop *QSGOpenVGAdaptation::createWindowManager()
+{
+ return new QSGOpenVGRenderLoop();
+}
+
+QSGContextFactoryInterface::Flags QSGOpenVGAdaptation::flags(const QString &key) const
+{
+ Q_UNUSED(key)
+ return 0;
+}
+
+QSGOpenVGContext *QSGOpenVGAdaptation::instance = nullptr;
+
+QT_END_NAMESPACE
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgadaptation_p.h b/src/plugins/scenegraph/openvg/qsgopenvgadaptation_p.h
new file mode 100644
index 0000000000..77f79af9ac
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgadaptation_p.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGOPENVGADAPTATION_H
+#define QSGOPENVGADAPTATION_H
+
+#include <private/qsgcontextplugin_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QSGContext;
+class QSGRenderLoop;
+class QSGOpenVGContext;
+
+class QSGOpenVGAdaptation : public QSGContextPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QSGContextFactoryInterface" FILE "openvg.json")
+public:
+ QSGOpenVGAdaptation(QObject *parent = nullptr);
+
+ QStringList keys() const override;
+ QSGContext *create(const QString &key) const override;
+ QSGRenderLoop *createWindowManager() override;
+ Flags flags(const QString &key) const override;
+private:
+ static QSGOpenVGContext *instance;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGOPENVGADAPTATION_H
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgcontext.cpp b/src/plugins/scenegraph/openvg/qsgopenvgcontext.cpp
new file mode 100644
index 0000000000..22a80c62e8
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgcontext.cpp
@@ -0,0 +1,219 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgopenvgcontext_p.h"
+#include "qsgopenvgrenderer_p.h"
+#include "qsgopenvginternalrectanglenode.h"
+#include "qsgopenvginternalimagenode.h"
+#include "qsgopenvgpublicnodes.h"
+#include "qsgopenvgtexture.h"
+#include "qsgopenvglayer.h"
+#include "qsgopenvgglyphnode_p.h"
+#include "qsgopenvgfontglyphcache.h"
+#include "qsgopenvgpainternode.h"
+#include "qsgopenvgspritenode.h"
+
+#include "qopenvgcontext_p.h"
+
+#include <private/qsgrenderer_p.h>
+
+// polish, animations, sync, render and swap in the render loop
+Q_LOGGING_CATEGORY(QSG_OPENVG_LOG_TIME_RENDERLOOP, "qt.scenegraph.time.renderloop")
+
+QT_BEGIN_NAMESPACE
+
+QSGOpenVGRenderContext::QSGOpenVGRenderContext(QSGContext *context)
+ : QSGRenderContext(context)
+ , m_vgContext(nullptr)
+ , m_glyphCacheManager(nullptr)
+{
+
+}
+
+void QSGOpenVGRenderContext::initialize(void *context)
+{
+ m_vgContext = static_cast<QOpenVGContext*>(context);
+ QSGRenderContext::initialize(context);
+}
+
+void QSGOpenVGRenderContext::invalidate()
+{
+ m_vgContext = nullptr;
+ delete m_glyphCacheManager;
+ m_glyphCacheManager = nullptr;
+ QSGRenderContext::invalidate();
+}
+
+void QSGOpenVGRenderContext::renderNextFrame(QSGRenderer *renderer, uint fboId)
+{
+ renderer->renderScene(fboId);
+}
+
+QSGTexture *QSGOpenVGRenderContext::createTexture(const QImage &image, uint flags) const
+{
+ QImage tmp = image;
+
+ // Make sure image is not larger than maxTextureSize
+ int maxSize = maxTextureSize();
+ if (tmp.width() > maxSize || tmp.height() > maxSize) {
+ tmp = tmp.scaled(qMin(maxSize, tmp.width()), qMin(maxSize, tmp.height()), Qt::IgnoreAspectRatio, Qt::FastTransformation);
+ }
+
+ return new QSGOpenVGTexture(tmp, flags);
+}
+
+QSGRenderer *QSGOpenVGRenderContext::createRenderer()
+{
+ return new QSGOpenVGRenderer(this);
+}
+
+QSGOpenVGContext::QSGOpenVGContext(QObject *parent)
+{
+ Q_UNUSED(parent)
+}
+
+QSGRenderContext *QSGOpenVGContext::createRenderContext()
+{
+ return new QSGOpenVGRenderContext(this);
+}
+
+QSGRectangleNode *QSGOpenVGContext::createRectangleNode()
+{
+ return new QSGOpenVGRectangleNode;
+}
+
+QSGImageNode *QSGOpenVGContext::createImageNode()
+{
+ return new QSGOpenVGImageNode;
+}
+
+QSGPainterNode *QSGOpenVGContext::createPainterNode(QQuickPaintedItem *item)
+{
+ Q_UNUSED(item)
+ return new QSGOpenVGPainterNode(item);
+}
+
+QSGGlyphNode *QSGOpenVGContext::createGlyphNode(QSGRenderContext *rc, bool preferNativeGlyphNode)
+{
+ Q_UNUSED(preferNativeGlyphNode)
+ return new QSGOpenVGGlyphNode(rc);
+}
+
+QSGNinePatchNode *QSGOpenVGContext::createNinePatchNode()
+{
+ return new QSGOpenVGNinePatchNode;
+}
+
+QSGLayer *QSGOpenVGContext::createLayer(QSGRenderContext *renderContext)
+{
+ return new QSGOpenVGLayer(renderContext);
+}
+
+QSurfaceFormat QSGOpenVGContext::defaultSurfaceFormat() const
+{
+ QSurfaceFormat format = QSurfaceFormat::defaultFormat();
+ format.setRenderableType(QSurfaceFormat::OpenVG);
+ format.setMajorVersion(1);
+ return format;
+}
+
+QSGInternalRectangleNode *QSGOpenVGContext::createInternalRectangleNode()
+{
+ return new QSGOpenVGInternalRectangleNode();
+}
+
+QSGInternalImageNode *QSGOpenVGContext::createInternalImageNode()
+{
+ return new QSGOpenVGInternalImageNode();
+}
+
+int QSGOpenVGRenderContext::maxTextureSize() const
+{
+ VGint width = vgGeti(VG_MAX_IMAGE_WIDTH);
+ VGint height = vgGeti(VG_MAX_IMAGE_HEIGHT);
+
+ return qMin(width, height);
+}
+
+
+QSGSpriteNode *QSGOpenVGContext::createSpriteNode()
+{
+ return new QSGOpenVGSpriteNode();
+}
+
+QSGRendererInterface *QSGOpenVGContext::rendererInterface(QSGRenderContext *renderContext)
+{
+ return static_cast<QSGOpenVGRenderContext *>(renderContext);
+}
+
+QSGRendererInterface::GraphicsApi QSGOpenVGRenderContext::graphicsApi() const
+{
+ return OpenVG;
+}
+
+QSGRendererInterface::ShaderType QSGOpenVGRenderContext::shaderType() const
+{
+ return UnknownShadingLanguage;
+}
+
+QSGRendererInterface::ShaderCompilationTypes QSGOpenVGRenderContext::shaderCompilationType() const
+{
+ return 0;
+}
+
+QSGRendererInterface::ShaderSourceTypes QSGOpenVGRenderContext::shaderSourceType() const
+{
+ return 0;
+}
+
+QSGOpenVGFontGlyphCache *QSGOpenVGRenderContext::glyphCache(const QRawFont &rawFont)
+{
+ if (!m_glyphCacheManager)
+ m_glyphCacheManager = new QSGOpenVGFontGlyphCacheManager;
+
+ QSGOpenVGFontGlyphCache *cache = m_glyphCacheManager->cache(rawFont);
+ if (!cache) {
+ cache = new QSGOpenVGFontGlyphCache(m_glyphCacheManager, rawFont);
+ m_glyphCacheManager->insertCache(rawFont, cache);
+ }
+
+ return cache;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgcontext_p.h b/src/plugins/scenegraph/openvg/qsgopenvgcontext_p.h
new file mode 100644
index 0000000000..fa9939a253
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgcontext_p.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGOPENVGCONTEXT_H
+#define QSGOPENVGCONTEXT_H
+
+#include <private/qsgcontext_p.h>
+#include <qsgrendererinterface.h>
+
+Q_DECLARE_LOGGING_CATEGORY(QSG_OPENVG_LOG_TIME_RENDERLOOP)
+
+QT_BEGIN_NAMESPACE
+
+class QOpenVGContext;
+class QSGOpenVGFontGlyphCache;
+class QSGOpenVGFontGlyphCacheManager;
+
+class QSGOpenVGRenderContext : public QSGRenderContext, public QSGRendererInterface
+{
+ Q_OBJECT
+public:
+ QSGOpenVGRenderContext(QSGContext *context);
+
+ void initialize(void *context) override;
+ void invalidate() override;
+ void renderNextFrame(QSGRenderer *renderer, uint fboId) override;
+ QSGTexture *createTexture(const QImage &image, uint flags) const override;
+ QSGRenderer *createRenderer() override;
+ int maxTextureSize() const override;
+
+ // QSGRendererInterface interface
+ GraphicsApi graphicsApi() const override;
+ ShaderType shaderType() const override;
+ ShaderCompilationTypes shaderCompilationType() const override;
+ ShaderSourceTypes shaderSourceType() const override;
+
+ QOpenVGContext* vgContext() { return m_vgContext; }
+ QSGOpenVGFontGlyphCache* glyphCache(const QRawFont &rawFont);
+
+private:
+ QOpenVGContext *m_vgContext;
+ QSGOpenVGFontGlyphCacheManager *m_glyphCacheManager;
+
+};
+
+class QSGOpenVGContext : public QSGContext
+{
+ Q_OBJECT
+public:
+ QSGOpenVGContext(QObject *parent = nullptr);
+
+ QSGRenderContext *createRenderContext() override;
+ QSGRectangleNode *createRectangleNode() override;
+ QSGImageNode *createImageNode() override;
+ QSGPainterNode *createPainterNode(QQuickPaintedItem *item) override;
+ QSGGlyphNode *createGlyphNode(QSGRenderContext *rc, bool preferNativeGlyphNode) override;
+ QSGNinePatchNode *createNinePatchNode() override;
+ QSGLayer *createLayer(QSGRenderContext *renderContext) override;
+ QSurfaceFormat defaultSurfaceFormat() const override;
+ QSGInternalRectangleNode *createInternalRectangleNode() override;
+ QSGInternalImageNode *createInternalImageNode() override;
+ QSGSpriteNode *createSpriteNode() override;
+ QSGRendererInterface *rendererInterface(QSGRenderContext *renderContext) override;
+};
+
+#endif // QSGOPENVGCONTEXT_H
+
+QT_END_NAMESPACE
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.cpp b/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.cpp
new file mode 100644
index 0000000000..dd630c776f
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.cpp
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgopenvgfontglyphcache.h"
+#include "qsgopenvghelpers.h"
+#include <private/qfontengine_p.h>
+#include <private/qrawfont_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QSGOpenVGFontGlyphCacheManager::QSGOpenVGFontGlyphCacheManager()
+{
+
+}
+
+QSGOpenVGFontGlyphCacheManager::~QSGOpenVGFontGlyphCacheManager()
+{
+ qDeleteAll(m_caches);
+}
+
+QSGOpenVGFontGlyphCache *QSGOpenVGFontGlyphCacheManager::cache(const QRawFont &font)
+{
+ return m_caches.value(font, nullptr);
+}
+
+void QSGOpenVGFontGlyphCacheManager::insertCache(const QRawFont &font, QSGOpenVGFontGlyphCache *cache)
+{
+ m_caches.insert(font, cache);
+}
+
+QSGOpenVGFontGlyphCache::QSGOpenVGFontGlyphCache(QSGOpenVGFontGlyphCacheManager *manager, const QRawFont &font)
+ : m_manager(manager)
+{
+ m_referenceFont = font;
+ QRawFontPrivate *fontD = QRawFontPrivate::get(font);
+ m_glyphCount = fontD->fontEngine->glyphCount();
+ m_font = vgCreateFont(0);
+}
+
+QSGOpenVGFontGlyphCache::~QSGOpenVGFontGlyphCache()
+{
+ if (m_font != VG_INVALID_HANDLE)
+ vgDestroyFont(m_font);
+}
+
+void QSGOpenVGFontGlyphCache::populate(const QVector<quint32> &glyphs)
+{
+ QSet<quint32> referencedGlyphs;
+ QSet<quint32> newGlyphs;
+ int count = glyphs.count();
+ for (int i = 0; i < count; ++i) {
+ quint32 glyphIndex = glyphs.at(i);
+ if ((int) glyphIndex >= glyphCount()) {
+ qWarning("Warning: glyph is not available with index %d", glyphIndex);
+ continue;
+ }
+
+ referencedGlyphs.insert(glyphIndex);
+
+
+ if (!m_cachedGlyphs.contains(glyphIndex)) {
+ newGlyphs.insert(glyphIndex);
+ }
+ }
+
+ referenceGlyphs(referencedGlyphs);
+ if (!newGlyphs.isEmpty())
+ requestGlyphs(newGlyphs);
+}
+
+void QSGOpenVGFontGlyphCache::release(const QVector<quint32> &glyphs)
+{
+ QSet<quint32> unusedGlyphs;
+ int count = glyphs.count();
+ for (int i = 0; i < count; ++i) {
+ quint32 glyphIndex = glyphs.at(i);
+ unusedGlyphs.insert(glyphIndex);
+ }
+ releaseGlyphs(unusedGlyphs);
+}
+
+void QSGOpenVGFontGlyphCache::requestGlyphs(const QSet<quint32> &glyphs)
+{
+ VGfloat origin[2];
+ VGfloat escapement[2];
+ QRectF metrics;
+ QRawFont rawFont = m_referenceFont;
+
+ // Before adding any new glyphs, remove any unused glyphs
+ for (auto glyph : qAsConst(m_unusedGlyphs)) {
+ vgClearGlyph(m_font, glyph);
+ }
+
+ for (auto glyph : glyphs) {
+ m_cachedGlyphs.insert(glyph);
+
+ // Calculate the path for the glyph and cache it.
+ QPainterPath path = rawFont.pathForGlyph(glyph);
+ VGPath vgPath;
+ if (!path.isEmpty()) {
+ vgPath = QSGOpenVGHelpers::qPainterPathToVGPath(path);
+ } else {
+ // Probably a "space" character with no visible outline.
+ vgPath = VG_INVALID_HANDLE;
+ }
+ origin[0] = 0;
+ origin[1] = 0;
+ escapement[0] = 0;
+ escapement[1] = 0;
+ vgSetGlyphToPath(m_font, glyph, vgPath, VG_FALSE, origin, escapement);
+ vgDestroyPath(vgPath); // Reduce reference count.
+ }
+
+}
+
+void QSGOpenVGFontGlyphCache::referenceGlyphs(const QSet<quint32> &glyphs)
+{
+ m_unusedGlyphs -= glyphs;
+}
+
+void QSGOpenVGFontGlyphCache::releaseGlyphs(const QSet<quint32> &glyphs)
+{
+ m_unusedGlyphs += glyphs;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.h b/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.h
new file mode 100644
index 0000000000..a88d28b0fe
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.h
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGOPENVGFONTGLYPHCACHE_H
+#define QSGOPENVGFONTGLYPHCACHE_H
+
+#include <QtGui/QGlyphRun>
+#include <QtCore/QSet>
+#include <QtCore/QLinkedList>
+#include <VG/openvg.h>
+
+QT_BEGIN_NAMESPACE
+
+class QSGOpenVGFontGlyphCache;
+
+class QSGOpenVGFontGlyphCacheManager
+{
+public:
+ QSGOpenVGFontGlyphCacheManager();
+ ~QSGOpenVGFontGlyphCacheManager();
+
+ QSGOpenVGFontGlyphCache *cache(const QRawFont &font);
+ void insertCache(const QRawFont &font, QSGOpenVGFontGlyphCache *cache);
+
+private:
+ QHash<QRawFont, QSGOpenVGFontGlyphCache *> m_caches;
+};
+
+class QSGOpenVGFontGlyphCache
+{
+public:
+ QSGOpenVGFontGlyphCache(QSGOpenVGFontGlyphCacheManager *manager, const QRawFont &font);
+ ~QSGOpenVGFontGlyphCache();
+
+ const QSGOpenVGFontGlyphCacheManager *manager() const { return m_manager; }
+ const QRawFont &referenceFont() const { return m_referenceFont; }
+ int glyphCount() const { return m_glyphCount; }
+
+ void populate(const QVector<quint32> &glyphs);
+ void release(const QVector<quint32> &glyphs);
+
+ VGFont font() { return m_font; }
+
+private:
+ void requestGlyphs(const QSet<quint32> &glyphs);
+ void referenceGlyphs(const QSet<quint32> &glyphs);
+ void releaseGlyphs(const QSet<quint32> &glyphs);
+
+ QSGOpenVGFontGlyphCacheManager *m_manager;
+ QRawFont m_referenceFont;
+ int m_glyphCount;
+
+ VGFont m_font;
+ QSet<quint32> m_cachedGlyphs;
+ QSet<quint32> m_unusedGlyphs;
+};
+
+
+QT_END_NAMESPACE
+
+#endif // QSGOPENVGFONTGLYPHCACHE_H
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgglyphnode.cpp b/src/plugins/scenegraph/openvg/qsgopenvgglyphnode.cpp
new file mode 100644
index 0000000000..8be2a97034
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgglyphnode.cpp
@@ -0,0 +1,214 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgopenvgglyphnode_p.h"
+#include "qopenvgcontext_p.h"
+#include "qsgopenvgcontext_p.h"
+#include "qsgopenvghelpers.h"
+#include "qsgopenvgfontglyphcache.h"
+#include "qopenvgoffscreensurface.h"
+
+QT_BEGIN_NAMESPACE
+
+QSGOpenVGGlyphNode::QSGOpenVGGlyphNode(QSGRenderContext *rc)
+ : m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 0)
+ , m_style(QQuickText::Normal)
+ , m_glyphCache(nullptr)
+{
+ // Set Dummy material to avoid asserts
+ setMaterial((QSGMaterial*)1);
+ setGeometry(&m_geometry);
+ m_fontColorPaint = vgCreatePaint();
+ m_styleColorPaint = vgCreatePaint();
+
+ // Get handle to Glyph Cache
+ m_renderContext = static_cast<QSGOpenVGRenderContext*>(rc);
+}
+
+QSGOpenVGGlyphNode::~QSGOpenVGGlyphNode()
+{
+ if (m_glyphCache)
+ m_glyphCache->release(m_glyphRun.glyphIndexes());
+
+ vgDestroyPaint(m_fontColorPaint);
+ vgDestroyPaint(m_styleColorPaint);
+}
+
+void QSGOpenVGGlyphNode::setGlyphs(const QPointF &position, const QGlyphRun &glyphs)
+{
+ // Obtain glyph cache for font
+ auto oldGlyphCache = m_glyphCache;
+ m_glyphCache = m_renderContext->glyphCache(glyphs.rawFont());
+ if (m_glyphCache != oldGlyphCache) {
+ if (oldGlyphCache)
+ oldGlyphCache->release(m_glyphRun.glyphIndexes());
+ }
+ m_glyphCache->populate(glyphs.glyphIndexes());
+
+ m_position = position;
+ m_glyphRun = glyphs;
+ m_bounding_rect = glyphs.boundingRect().translated(m_position - QPointF(0.0, glyphs.rawFont().ascent()));
+
+ // Recreate ajustments
+ m_xAdjustments.clear();
+ m_yAdjustments.clear();
+
+ for (int i = 1; i < glyphs.positions().count(); ++i) {
+ m_xAdjustments.append(glyphs.positions().at(i).x() - glyphs.positions().at(i-1).x());
+ m_yAdjustments.append(glyphs.positions().at(i).y() - glyphs.positions().at(i-1).y());
+ }
+}
+
+void QSGOpenVGGlyphNode::setColor(const QColor &color)
+{
+ m_color = color;
+ vgSetParameteri(m_fontColorPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
+ vgSetParameterfv(m_fontColorPaint, VG_PAINT_COLOR, 4, QSGOpenVGHelpers::qColorToVGColor(m_color, opacity()).constData());
+}
+
+void QSGOpenVGGlyphNode::setStyle(QQuickText::TextStyle style)
+{
+ m_style = style;
+}
+
+void QSGOpenVGGlyphNode::setStyleColor(const QColor &color)
+{
+ m_styleColor = color;
+ vgSetParameteri(m_styleColorPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
+ vgSetParameterfv(m_styleColorPaint, VG_PAINT_COLOR, 4, QSGOpenVGHelpers::qColorToVGColor(m_styleColor, opacity()).constData());
+}
+
+QPointF QSGOpenVGGlyphNode::baseLine() const
+{
+ return QPointF();
+}
+
+void QSGOpenVGGlyphNode::setPreferredAntialiasingMode(QSGGlyphNode::AntialiasingMode)
+{
+}
+
+void QSGOpenVGGlyphNode::update()
+{
+}
+
+void QSGOpenVGGlyphNode::render()
+{
+ if (m_glyphRun.positions().count() == 0)
+ return;
+
+ // Rendering Style
+ qreal offset = 1.0;
+
+ QOpenVGOffscreenSurface *offscreenSurface = nullptr;
+
+ // Set Transform
+ vgSeti(VG_MATRIX_MODE, VG_MATRIX_GLYPH_USER_TO_SURFACE);
+ if (transform().isAffine()) {
+ vgLoadMatrix(transform().constData());
+ } else {
+ vgLoadIdentity();
+ offscreenSurface = new QOpenVGOffscreenSurface(QSize(ceil(m_bounding_rect.width()), ceil(m_bounding_rect.height())));
+ offscreenSurface->makeCurrent();
+ }
+
+ // Set Quality
+ vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_BETTER);
+
+
+ switch (m_style) {
+ case QQuickText::Normal: break;
+ case QQuickText::Outline:
+ // Set the correct fill state
+ vgSetPaint(m_styleColorPaint, VG_FILL_PATH);
+ drawGlyphsAtOffset(QPointF(0, offset));
+ drawGlyphsAtOffset(QPointF(0, -offset));
+ drawGlyphsAtOffset(QPointF(offset, 0));
+ drawGlyphsAtOffset(QPointF(-offset, 0));
+ break;
+ case QQuickText::Raised:
+ vgSetPaint(m_styleColorPaint, VG_FILL_PATH);
+ drawGlyphsAtOffset(QPointF(0, offset));
+ break;
+ case QQuickText::Sunken:
+ vgSetPaint(m_styleColorPaint, VG_FILL_PATH);
+ drawGlyphsAtOffset(QPointF(0, -offset));
+ break;
+ }
+
+ // Set the correct fill state
+ vgSetPaint(m_fontColorPaint, VG_FILL_PATH);
+ drawGlyphsAtOffset(QPointF(0.0, 0.0));
+
+ if (!transform().isAffine()) {
+ vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
+ vgLoadMatrix(transform().constData());
+ offscreenSurface->doneCurrent();
+ vgDrawImage(offscreenSurface->image());
+ delete offscreenSurface;
+ }
+}
+
+void QSGOpenVGGlyphNode::setOpacity(float opacity)
+{
+ if (QSGOpenVGRenderable::opacity() != opacity) {
+ QSGOpenVGRenderable::setOpacity(opacity);
+ // Update Colors
+ setColor(m_color);
+ setStyleColor(m_styleColor);
+ }
+}
+
+void QSGOpenVGGlyphNode::drawGlyphsAtOffset(const QPointF &offset)
+{
+ QPointF firstPosition = m_glyphRun.positions()[0] + (m_position - QPointF(0, m_glyphRun.rawFont().ascent()));
+ VGfloat origin[2];
+ origin[0] = firstPosition.x() + offset.x();
+ origin[1] = firstPosition.y() + offset.y();
+ vgSetfv(VG_GLYPH_ORIGIN, 2, origin);
+
+ vgDrawGlyphs(m_glyphCache->font(),
+ m_glyphRun.glyphIndexes().count(),
+ (VGuint*)m_glyphRun.glyphIndexes().constData(),
+ m_xAdjustments.constData(),
+ m_yAdjustments.constData(),
+ VG_FILL_PATH,
+ VG_TRUE);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgglyphnode_p.h b/src/plugins/scenegraph/openvg/qsgopenvgglyphnode_p.h
new file mode 100644
index 0000000000..205e3dcbc8
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgglyphnode_p.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGOPENVGGLYPHNODE_H
+#define QSGOPENVGGLYPHNODE_H
+
+#include <private/qsgadaptationlayer_p.h>
+#include <QtCore/QVector>
+
+#include <VG/openvg.h>
+
+#include "qsgopenvgrenderable.h"
+#include "qsgopenvgfontglyphcache.h"
+
+QT_BEGIN_NAMESPACE
+
+class QSGOpenVGFontGlyphCache;
+class QSGOpenVGRenderContext;
+class QSGRenderContext;
+
+class QSGOpenVGGlyphNode : public QSGGlyphNode, public QSGOpenVGRenderable
+{
+public:
+ QSGOpenVGGlyphNode(QSGRenderContext *rc);
+ ~QSGOpenVGGlyphNode();
+
+ void setGlyphs(const QPointF &position, const QGlyphRun &glyphs) override;
+ void setColor(const QColor &color) override;
+ void setStyle(QQuickText::TextStyle style) override;
+ void setStyleColor(const QColor &color) override;
+ QPointF baseLine() const override;
+ void setPreferredAntialiasingMode(AntialiasingMode) override;
+ void update() override;
+
+ void render() override;
+ void setOpacity(float opacity) override;
+
+private:
+ void drawGlyphsAtOffset(const QPointF &offset);
+
+ QPointF m_position;
+ QGlyphRun m_glyphRun;
+ QColor m_color;
+ QSGGeometry m_geometry;
+ QQuickText::TextStyle m_style;
+ QColor m_styleColor;
+
+ QSGOpenVGFontGlyphCache *m_glyphCache;
+ QVector<VGfloat> m_xAdjustments;
+ QVector<VGfloat> m_yAdjustments;
+ VGPaint m_fontColorPaint;
+ VGPaint m_styleColorPaint;
+
+ QSGOpenVGRenderContext *m_renderContext;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGOPENVGGLYPHNODE_H
diff --git a/src/plugins/scenegraph/openvg/qsgopenvghelpers.cpp b/src/plugins/scenegraph/openvg/qsgopenvghelpers.cpp
new file mode 100644
index 0000000000..6bc99d32a1
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvghelpers.cpp
@@ -0,0 +1,433 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgopenvghelpers.h"
+#include <cmath>
+
+QT_BEGIN_NAMESPACE
+
+namespace QSGOpenVGHelpers {
+
+VGPath qPainterPathToVGPath(const QPainterPath &path)
+{
+ int count = path.elementCount();
+
+ VGPath vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
+ VG_PATH_DATATYPE_F,
+ 1.0f, // scale
+ 0.0f, // bias
+ count + 1, // segmentCapacityHint
+ count * 2, // coordCapacityHint
+ VG_PATH_CAPABILITY_ALL);
+
+ if (count == 0)
+ return vgpath;
+
+ QVector<VGfloat> coords;
+ QVector<VGubyte> segments;
+
+ int curvePos = 0;
+ QPointF temp;
+
+ // Keep track of the start and end of each sub-path. QPainterPath
+ // does not have an "implicit close" flag like QVectorPath does.
+ // We therefore have to detect closed paths by looking for a LineTo
+ // element that connects back to the initial MoveTo element.
+ qreal startx = 0.0;
+ qreal starty = 0.0;
+ qreal endx = 0.0;
+ qreal endy = 0.0;
+ bool haveStart = false;
+ bool haveEnd = false;
+
+ for (int i = 0; i < count; ++i) {
+ const QPainterPath::Element element = path.elementAt(i);
+ switch (element.type) {
+
+ case QPainterPath::MoveToElement:
+ {
+ if (haveStart && haveEnd && startx == endx && starty == endy) {
+ // Implicitly close the previous sub-path.
+ segments.append(VG_CLOSE_PATH);
+ }
+ temp = QPointF(element.x, element.y);
+ startx = temp.x();
+ starty = temp.y();
+ coords.append(startx);
+ coords.append(starty);
+ haveStart = true;
+ haveEnd = false;
+ segments.append(VG_MOVE_TO_ABS);
+ }
+ break;
+
+ case QPainterPath::LineToElement:
+ {
+ temp = QPointF(element.x, element.y);
+ endx = temp.x();
+ endy = temp.y();
+ coords.append(endx);
+ coords.append(endy);
+ haveEnd = true;
+ segments.append(VG_LINE_TO_ABS);
+ }
+ break;
+
+ case QPainterPath::CurveToElement:
+ {
+ temp = QPointF(element.x, element.y);
+ coords.append(temp.x());
+ coords.append(temp.y());
+ haveEnd = false;
+ curvePos = 2;
+ }
+ break;
+
+ case QPainterPath::CurveToDataElement:
+ {
+ temp = QPointF(element.x, element.y);
+ coords.append(temp.x());
+ coords.append(temp.y());
+ haveEnd = false;
+ curvePos += 2;
+ if (curvePos == 6) {
+ curvePos = 0;
+ segments.append(VG_CUBIC_TO_ABS);
+ }
+ }
+ break;
+
+ }
+ }
+
+ if (haveStart && haveEnd && startx == endx && starty == endy) {
+ // Implicitly close the last sub-path.
+ segments.append(VG_CLOSE_PATH);
+ }
+
+ vgAppendPathData(vgpath, segments.count(),
+ segments.constData(), coords.constData());
+
+ return vgpath;
+}
+
+
+void qDrawTiled(VGImage image, const QSize imageSize, const QRectF &targetRect, const QPointF offset, float scaleX, float scaleY) {
+
+ //Check for valid image size and targetRect
+ if (imageSize.width() <= 0 || imageSize.height() <= 0)
+ return;
+ if (targetRect.width() <= 0 || targetRect.height() <= 0)
+ return;
+
+ // This logic is mostly from the Qt Raster PaintEngine's qt_draw_tile
+ qreal drawH;
+ qreal drawW;
+ qreal xPos;
+ qreal xOff;
+ qreal yPos = targetRect.y();
+ qreal yOff;
+
+ if (offset.y() < 0)
+ yOff = imageSize.height() - qRound(-offset.y()) % imageSize.height();
+ else
+ yOff = qRound(offset.y()) % imageSize.height();
+
+
+ // Save the current image transform matrix
+ vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
+ QVector<float> originalMatrix(9);
+ vgGetMatrix(originalMatrix.data());
+
+ while (!qFuzzyCompare(yPos, targetRect.y() + targetRect.height()) &&
+ yPos < targetRect.y() + targetRect.height()) {
+ drawH = imageSize.height() - yOff; // Cropping first row
+ if (yPos + drawH * scaleY > targetRect.y() + targetRect.height()) { // Cropping last row
+ // Check that values aren't equal
+ if (!qFuzzyCompare((float)(yPos + drawH * scaleY), (float)(targetRect.y() + targetRect.height())))
+ drawH = targetRect.y() + targetRect.height() - yPos;
+ }
+ xPos = targetRect.x();
+ if (offset.x() < 0)
+ xOff = imageSize.width() - qRound(-offset.x()) % imageSize.width();
+ else
+ xOff = qRound(offset.x()) % imageSize.width();
+
+ while (!qFuzzyCompare(xPos, targetRect.x() + targetRect.width()) &&
+ xPos < targetRect.x() + targetRect.width()) {
+ drawW = imageSize.width() - xOff; // Cropping first column
+ if (xPos + drawW * scaleX > targetRect.x() + targetRect.width()) {
+ // Check that values aren't equal
+ if (!qFuzzyCompare((float)(xPos + drawW * scaleX), (float)(targetRect.x() + targetRect.width())))
+ drawW = targetRect.x() + targetRect.width() - xPos;
+ }
+ if (round(drawW) > 0 && round(drawH) > 0) { // Can't source image less than 1 width or height
+ //Draw here
+ VGImage childRectImage = vgChildImage(image, xOff, yOff, round(drawW), round(drawH));
+ vgTranslate(xPos, yPos);
+ vgScale(scaleX, scaleY);
+ vgDrawImage(childRectImage);
+ vgDestroyImage(childRectImage);
+ vgLoadMatrix(originalMatrix.constData());
+ }
+ if ( drawW > 0)
+ xPos += drawW * scaleX;
+ xOff = 0;
+ }
+ if ( drawH > 0)
+ yPos += drawH * scaleY;
+ yOff = 0;
+
+ }
+}
+
+void qDrawBorderImage(VGImage image, const QSizeF &textureSize, const QRectF &targetRect, const QRectF &innerTargetRect, const QRectF &subSourceRect)
+{
+ // Create normalized margins
+ QMarginsF margins(qMax(innerTargetRect.left() - targetRect.left(), 0.0),
+ qMax(innerTargetRect.top() - targetRect.top(), 0.0),
+ qMax(targetRect.right() - innerTargetRect.right(), 0.0),
+ qMax(targetRect.bottom() - innerTargetRect.bottom(), 0.0));
+
+ QRectF sourceRect(0, 0, textureSize.width(), textureSize.height());
+
+ // Create all the subRects
+ QRectF topLeftSourceRect(sourceRect.topLeft(), QSizeF(margins.left(), margins.top()));
+ QRectF topRightSourceRect(sourceRect.width() - margins.right(), sourceRect.top(), margins.right(), margins.top());
+ QRectF bottomLeftSourceRect(sourceRect.left(), sourceRect.height() - margins.bottom(), margins.left(), margins.bottom());
+ QRectF bottomRightSourceRect(sourceRect.width() - margins.right(), sourceRect.height() - margins.bottom(), margins.right(), margins.bottom());
+
+ QRectF topSourceRect(margins.left(), 0.0, sourceRect.width() - (margins.right() + margins.left()), margins.top());
+ QRectF topTargetRect(margins.left(), 0.0, innerTargetRect.width(), margins.top());
+ QRectF bottomSourceRect(margins.left(), sourceRect.height() - margins.bottom(), sourceRect.width() - (margins.right() + margins.left()), margins.bottom());
+ QRectF bottomTargetRect(margins.left(), targetRect.height() - margins.bottom(), innerTargetRect.width(), margins.bottom());
+ QRectF leftSourceRect(0.0, margins.top(), margins.left(), sourceRect.height() - (margins.bottom() + margins.top()));
+ QRectF leftTargetRect(0.0, margins.top(), margins.left(), innerTargetRect.height());
+ QRectF rightSourceRect(sourceRect.width() - margins.right(), margins.top(), margins.right(), sourceRect.height() - (margins.bottom() + margins.top()));
+ QRectF rightTargetRect(targetRect.width() - margins.right(), margins.top(), margins.right(), innerTargetRect.height());
+
+ QRectF centerSourceRect(margins.left(), margins.top(), sourceRect.width() - (margins.right() + margins.left()), sourceRect.height() - (margins.top() + margins.bottom()));
+
+ // Draw the 9 different sections
+ // (1) Top Left (unscaled)
+ qDrawSubImage(image,
+ topLeftSourceRect,
+ targetRect.topLeft());
+
+ // (3) Top Right (unscaled)
+ qDrawSubImage(image,
+ topRightSourceRect,
+ QPointF(targetRect.width() - margins.right(), 0.0));
+
+ // (7) Bottom Left (unscaled)
+ qDrawSubImage(image,
+ bottomLeftSourceRect,
+ QPointF(targetRect.left(), targetRect.height() - margins.bottom()));
+
+ // (9) Bottom Right (unscaled)
+ qDrawSubImage(image,
+ bottomRightSourceRect,
+ QPointF(targetRect.width() - margins.right(), targetRect.height() - margins.bottom()));
+
+ double scaledWidth = 1.0;
+ double scaledHeight = 1.0;
+
+ // (2) Top (scaled via horizontalTileRule)
+ VGImage topImage = vgChildImage(image, topSourceRect.x(), topSourceRect.y(), topSourceRect.width(), topSourceRect.height());
+ scaledWidth = (topTargetRect.width() / subSourceRect.width()) / topSourceRect.width();
+
+ QSGOpenVGHelpers::qDrawTiled(topImage, topSourceRect.size().toSize(), topTargetRect, QPoint(0.0, 0.0), scaledWidth, 1);
+
+ vgDestroyImage(topImage);
+
+ // (8) Bottom (scaled via horizontalTileRule)
+ VGImage bottomImage = vgChildImage(image, bottomSourceRect.x(), bottomSourceRect.y(), bottomSourceRect.width(), bottomSourceRect.height());
+ scaledWidth = (bottomTargetRect.width() / subSourceRect.width()) / bottomSourceRect.width();
+
+ QSGOpenVGHelpers::qDrawTiled(bottomImage, bottomSourceRect.size().toSize(), bottomTargetRect, QPoint(0.0, 0.0), scaledWidth, 1);
+
+ vgDestroyImage(bottomImage);
+
+ // (4) Left (scaled via verticalTileRule)
+ VGImage leftImage = vgChildImage(image, leftSourceRect.x(), leftSourceRect.y(), leftSourceRect.width(), leftSourceRect.height());
+ scaledHeight = (leftTargetRect.height() / subSourceRect.height()) / leftSourceRect.height();
+ QSGOpenVGHelpers::qDrawTiled(leftImage, leftSourceRect.size().toSize(), leftTargetRect, QPointF(0.0, 0.0), 1, scaledHeight);
+
+ vgDestroyImage(leftImage);
+
+ // (6) Right (scaled via verticalTileRule)
+ VGImage rightImage = vgChildImage(image, rightSourceRect.x(), rightSourceRect.y(), rightSourceRect.width(), rightSourceRect.height());
+ scaledHeight = (rightTargetRect.height() / subSourceRect.height()) / rightSourceRect.height();
+
+ QSGOpenVGHelpers::qDrawTiled(rightImage, rightSourceRect.size().toSize(), rightTargetRect, QPointF(0, 0), 1, scaledHeight);
+
+ vgDestroyImage(rightImage);
+
+ // (5) Center (saled via verticalTileRule and horizontalTileRule)
+ VGImage centerImage = vgChildImage(image, centerSourceRect.x(), centerSourceRect.y(), centerSourceRect.width(), centerSourceRect.height());
+
+ scaledWidth = (innerTargetRect.width() / subSourceRect.width()) / centerSourceRect.width();
+ scaledHeight = (innerTargetRect.height() / subSourceRect.height()) / centerSourceRect.height();
+
+ QSGOpenVGHelpers::qDrawTiled(centerImage, centerSourceRect.size().toSize(), innerTargetRect, QPointF(0, 0), scaledWidth, scaledHeight);
+
+ vgDestroyImage(centerImage);
+}
+
+void qDrawSubImage(VGImage image, const QRectF &sourceRect, const QPointF &destOffset)
+{
+ // Check for valid source size
+ if (sourceRect.width() <= 0 || sourceRect.height() <= 0)
+ return;
+
+ // Save the current image transform matrix
+ vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
+ QVector<float> originalMatrix(9);
+ vgGetMatrix(originalMatrix.data());
+
+ // Get the child Image
+ VGImage childRectImage = vgChildImage(image, sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height());
+ vgTranslate(destOffset.x(), destOffset.y());
+ vgDrawImage(childRectImage);
+ vgDestroyImage(childRectImage);
+
+ // Pop Matrix
+ vgLoadMatrix(originalMatrix.constData());
+}
+
+const QVector<VGfloat> qColorToVGColor(const QColor &color, float opacity)
+{
+ QVector<VGfloat> vgColor(4);
+ vgColor[0] = color.redF();
+ vgColor[1] = color.greenF();
+ vgColor[2] = color.blueF();
+ vgColor[3] = color.alphaF() * opacity;
+ return vgColor;
+}
+
+VGImageFormat qImageFormatToVGImageFormat(QImage::Format format)
+{
+ VGImageFormat vgFormat;
+
+ switch (format) {
+ case QImage::Format_Mono:
+ case QImage::Format_MonoLSB:
+ vgFormat = VG_BW_1;
+ break;
+ case QImage::Format_RGB32:
+ vgFormat = VG_sXRGB_8888;
+ break;
+ case QImage::Format_ARGB32:
+ vgFormat = VG_sARGB_8888;
+ break;
+ case QImage::Format_ARGB32_Premultiplied:
+ vgFormat = VG_sARGB_8888_PRE;
+ break;
+ case QImage::Format_RGB16:
+ vgFormat = VG_sRGB_565;
+ break;
+ case QImage::Format_RGBX8888:
+ vgFormat = VG_sRGBX_8888;
+ break;
+ case QImage::Format_RGBA8888:
+ vgFormat = VG_sRGBA_8888;
+ break;
+ case QImage::Format_RGBA8888_Premultiplied:
+ vgFormat = VG_sRGBA_8888_PRE;
+ break;
+ case QImage::Format_Alpha8:
+ vgFormat = VG_A_8;
+ break;
+ case QImage::Format_Grayscale8:
+ vgFormat = VG_sL_8;
+ break;
+ default:
+ //Invalid
+ vgFormat = (VGImageFormat)-1;
+ break;
+ }
+
+ return vgFormat;
+}
+
+QImage::Format qVGImageFormatToQImageFormat(VGImageFormat format)
+{
+ QImage::Format qImageFormat;
+
+ switch (format) {
+ case VG_BW_1:
+ qImageFormat = QImage::Format_Mono;
+ break;
+ case VG_sXRGB_8888:
+ qImageFormat = QImage::Format_RGB32;
+ break;
+ case VG_sARGB_8888:
+ qImageFormat = QImage::Format_ARGB32;
+ break;
+ case VG_sARGB_8888_PRE:
+ qImageFormat = QImage::Format_ARGB32_Premultiplied;
+ break;
+ case VG_sRGB_565:
+ qImageFormat = QImage::Format_RGB16;
+ break;
+ case VG_sRGBX_8888:
+ qImageFormat = QImage::Format_RGBX8888;
+ break;
+ case VG_sRGBA_8888:
+ qImageFormat = QImage::Format_RGBA8888;
+ break;
+ case VG_sRGBA_8888_PRE:
+ qImageFormat = QImage::Format_RGBA8888_Premultiplied;
+ break;
+ case VG_A_8:
+ qImageFormat = QImage::Format_Alpha8;
+ break;
+ case VG_sL_8:
+ qImageFormat = QImage::Format_Grayscale8;
+ default:
+ qImageFormat = QImage::Format_ARGB32;
+ break;
+ }
+
+ return qImageFormat;
+}
+
+} // end namespace QSGOpenVGHelpers
+
+QT_END_NAMESPACE
diff --git a/src/plugins/scenegraph/openvg/qsgopenvghelpers.h b/src/plugins/scenegraph/openvg/qsgopenvghelpers.h
new file mode 100644
index 0000000000..ee8ff73ca8
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvghelpers.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGOPENVGHELPERS_H
+#define QSGOPENVGHELPERS_H
+
+#include <QtGui/QPainterPath>
+#include <QtGui/QColor>
+#include <QtGui/QImage>
+#include <VG/openvg.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QSGOpenVGHelpers {
+
+VGPath qPainterPathToVGPath(const QPainterPath &path);
+void qDrawTiled(VGImage image, const QSize imageSize, const QRectF &targetRect, const QPointF offset, float scaleX, float scaleY);
+void qDrawBorderImage(VGImage image, const QSizeF &textureSize, const QRectF &targetRect, const QRectF &innerTargetRect, const QRectF &subSourceRect);
+void qDrawSubImage(VGImage image, const QRectF &sourceRect, const QPointF &destOffset);
+const QVector<VGfloat> qColorToVGColor(const QColor &color, float opacity = 1.0f);
+VGImageFormat qImageFormatToVGImageFormat(QImage::Format format);
+QImage::Format qVGImageFormatToQImageFormat(VGImageFormat format);
+
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGOPENVGHELPERS_H
diff --git a/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.cpp b/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.cpp
new file mode 100644
index 0000000000..3dd1f9133c
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.cpp
@@ -0,0 +1,239 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgopenvginternalimagenode.h"
+#include "qsgopenvghelpers.h"
+
+#include <VG/openvg.h>
+
+QT_BEGIN_NAMESPACE
+
+QSGOpenVGInternalImageNode::QSGOpenVGInternalImageNode()
+{
+ // Set Dummy material and geometry to avoid asserts
+ setMaterial((QSGMaterial*)1);
+ setGeometry((QSGGeometry*)1);
+}
+
+QSGOpenVGInternalImageNode::~QSGOpenVGInternalImageNode()
+{
+ if (m_subSourceRectImage != 0)
+ vgDestroyImage(m_subSourceRectImage);
+}
+
+void QSGOpenVGInternalImageNode::render()
+{
+ if (!m_texture) {
+ return;
+ }
+
+ // Set Draw Mode
+ if (opacity() < 1.0) {
+ //Transparent
+ vgSetPaint(opacityPaint(), VG_FILL_PATH);
+ vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY);
+ } else {
+ vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL);
+ }
+
+ // Set Transform
+ vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
+ vgLoadMatrix(transform().constData());
+
+ VGImage image = static_cast<VGImage>(m_texture->textureId());
+ QSize textureSize = m_texture->textureSize();
+
+ if (image == VG_INVALID_HANDLE || !textureSize.isValid())
+ return;
+
+
+ // If Mirrored
+ if (m_mirror) {
+ vgTranslate(m_targetRect.width(), 0.0f);
+ vgScale(-1.0, 1.0);
+ }
+
+ if (m_smooth)
+ vgSeti(VG_IMAGE_QUALITY, VG_IMAGE_QUALITY_BETTER);
+ else
+ vgSeti(VG_IMAGE_QUALITY, VG_IMAGE_QUALITY_NONANTIALIASED);
+
+
+ if (m_innerTargetRect != m_targetRect) {
+ // border image
+ QSGOpenVGHelpers::qDrawBorderImage(image, textureSize, m_targetRect, m_innerTargetRect, m_subSourceRect);
+ } else if (m_tileHorizontal || m_tileVertical) {
+ // Tilled Image
+
+ float sx = m_targetRect.width() / (m_subSourceRect.width() * textureSize.width());
+ float sy = m_targetRect.height() / (m_subSourceRect.height() * textureSize.height());
+ QPointF offset(m_subSourceRect.left() * textureSize.width(), m_subSourceRect.top() * textureSize.height());
+
+ QSGOpenVGHelpers::qDrawTiled(image, textureSize, m_targetRect, offset, sx, sy);
+
+ } else {
+ // Regular BLIT
+
+ QRectF sr(m_subSourceRect.left() * textureSize.width(), m_subSourceRect.top() * textureSize.height(),
+ m_subSourceRect.width() * textureSize.width(), m_subSourceRect.height() * textureSize.height());
+
+ if (m_subSourceRectImageDirty) {
+ if (m_subSourceRectImage != 0)
+ vgDestroyImage(m_subSourceRectImage);
+ m_subSourceRectImage = vgChildImage(image, sr.x(), sr.y(), sr.width(), sr.height());
+ m_subSourceRectImageDirty = false;
+ }
+
+ // If the the source rect is the same as the target rect
+ if (sr == m_targetRect) {
+ vgDrawImage(image);
+ } else {
+ // Scale
+ float scaleX = m_targetRect.width() / sr.width();
+ float scaleY = m_targetRect.height() / sr.height();
+ vgTranslate(m_targetRect.x(), m_targetRect.y());
+ vgScale(scaleX, scaleY);
+ vgDrawImage(m_subSourceRectImage);
+ }
+ }
+}
+
+void QSGOpenVGInternalImageNode::setTargetRect(const QRectF &rect)
+{
+ if (rect == m_targetRect)
+ return;
+ m_targetRect = rect;
+ markDirty(DirtyGeometry);
+}
+
+void QSGOpenVGInternalImageNode::setInnerTargetRect(const QRectF &rect)
+{
+ if (rect == m_innerTargetRect)
+ return;
+ m_innerTargetRect = rect;
+ markDirty(DirtyGeometry);
+}
+
+void QSGOpenVGInternalImageNode::setInnerSourceRect(const QRectF &rect)
+{
+ if (rect == m_innerSourceRect)
+ return;
+ m_innerSourceRect = rect;
+ markDirty(DirtyGeometry);
+}
+
+void QSGOpenVGInternalImageNode::setSubSourceRect(const QRectF &rect)
+{
+ if (rect == m_subSourceRect)
+ return;
+ m_subSourceRect = rect;
+ m_subSourceRectImageDirty = true;
+ markDirty(DirtyGeometry);
+}
+
+void QSGOpenVGInternalImageNode::setTexture(QSGTexture *texture)
+{
+ m_texture = texture;
+ m_subSourceRectImageDirty = true;
+ markDirty(DirtyMaterial);
+}
+
+void QSGOpenVGInternalImageNode::setMirror(bool mirror)
+{
+ if (m_mirror != mirror) {
+ m_mirror = mirror;
+ markDirty(DirtyMaterial);
+ }
+}
+
+void QSGOpenVGInternalImageNode::setMipmapFiltering(QSGTexture::Filtering)
+{
+}
+
+void QSGOpenVGInternalImageNode::setFiltering(QSGTexture::Filtering filtering)
+{
+ bool smooth = (filtering == QSGTexture::Linear);
+ if (smooth == m_smooth)
+ return;
+
+ m_smooth = smooth;
+ markDirty(DirtyMaterial);
+}
+
+void QSGOpenVGInternalImageNode::setHorizontalWrapMode(QSGTexture::WrapMode wrapMode)
+{
+ bool tileHorizontal = (wrapMode == QSGTexture::Repeat);
+ if (tileHorizontal == m_tileHorizontal)
+ return;
+
+ m_tileHorizontal = tileHorizontal;
+ markDirty(DirtyMaterial);
+}
+
+void QSGOpenVGInternalImageNode::setVerticalWrapMode(QSGTexture::WrapMode wrapMode)
+{
+ bool tileVertical = (wrapMode == QSGTexture::Repeat);
+ if (tileVertical == m_tileVertical)
+ return;
+
+ m_tileVertical = (wrapMode == QSGTexture::Repeat);
+ markDirty(DirtyMaterial);
+}
+
+void QSGOpenVGInternalImageNode::update()
+{
+}
+
+void QSGOpenVGInternalImageNode::preprocess()
+{
+ bool doDirty = false;
+ QSGLayer *t = qobject_cast<QSGLayer *>(m_texture);
+ if (t) {
+ doDirty = t->updateTexture();
+ markDirty(DirtyGeometry);
+ }
+ if (doDirty)
+ markDirty(DirtyMaterial);
+}
+
+QT_END_NAMESPACE
+
+
+
+
diff --git a/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.h b/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.h
new file mode 100644
index 0000000000..2361aa4892
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGOPENVGINTERNALIMAGENODE_H
+#define QSGOPENVGINTERNALIMAGENODE_H
+
+#include <private/qsgadaptationlayer_p.h>
+#include "qsgopenvgrenderable.h"
+
+#include <VG/openvg.h>
+
+QT_BEGIN_NAMESPACE
+
+class QSGOpenVGInternalImageNode : public QSGInternalImageNode, public QSGOpenVGRenderable
+{
+public:
+ QSGOpenVGInternalImageNode();
+ ~QSGOpenVGInternalImageNode();
+
+ void render() override;
+
+ void setTargetRect(const QRectF &rect) override;
+ void setInnerTargetRect(const QRectF &rect) override;
+ void setInnerSourceRect(const QRectF &rect) override;
+ void setSubSourceRect(const QRectF &rect) override;
+ void setTexture(QSGTexture *texture) override;
+ void setMirror(bool mirror) override;
+ void setMipmapFiltering(QSGTexture::Filtering filtering) override;
+ void setFiltering(QSGTexture::Filtering filtering) override;
+ void setHorizontalWrapMode(QSGTexture::WrapMode wrapMode) override;
+ void setVerticalWrapMode(QSGTexture::WrapMode wrapMode) override;
+ void update() override;
+
+ void preprocess() override;
+
+private:
+
+ QRectF m_targetRect;
+ QRectF m_innerTargetRect;
+ QRectF m_innerSourceRect = QRectF(0, 0, 1, 1);
+ QRectF m_subSourceRect = QRectF(0, 0, 1, 1);
+
+ bool m_mirror = false;
+ bool m_smooth = true;
+ bool m_tileHorizontal = false;
+ bool m_tileVertical = false;
+
+ QSGTexture *m_texture = nullptr;
+
+ VGImage m_subSourceRectImage = 0;
+ bool m_subSourceRectImageDirty = true;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGOPENVGINTERNALIMAGENODE_H
diff --git a/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp
new file mode 100644
index 0000000000..be437303bc
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp
@@ -0,0 +1,732 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgopenvginternalrectanglenode.h"
+#include "qsgopenvghelpers.h"
+
+#include <VG/vgu.h>
+
+QSGOpenVGInternalRectangleNode::QSGOpenVGInternalRectangleNode()
+{
+ // Set Dummy material and geometry to avoid asserts
+ setMaterial((QSGMaterial*)1);
+ setGeometry((QSGGeometry*)1);
+ createVGResources();
+}
+
+QSGOpenVGInternalRectangleNode::~QSGOpenVGInternalRectangleNode()
+{
+ destroyVGResources();
+}
+
+
+void QSGOpenVGInternalRectangleNode::setRect(const QRectF &rect)
+{
+ m_rect = rect;
+ m_pathDirty = true;
+}
+
+void QSGOpenVGInternalRectangleNode::setColor(const QColor &color)
+{
+ m_fillColor = color;
+ m_fillDirty = true;
+}
+
+void QSGOpenVGInternalRectangleNode::setPenColor(const QColor &color)
+{
+ m_strokeColor = color;
+ m_strokeDirty = true;
+}
+
+void QSGOpenVGInternalRectangleNode::setPenWidth(qreal width)
+{
+ m_penWidth = width;
+ m_strokeDirty = true;
+ m_pathDirty = true;
+}
+
+//Move first stop by pos relative to seconds
+static QGradientStop interpolateStop(const QGradientStop &firstStop, const QGradientStop &secondStop, double newPos)
+{
+ double distance = secondStop.first - firstStop.first;
+ double distanceDelta = newPos - firstStop.first;
+ double modifierValue = distanceDelta / distance;
+ int redDelta = (secondStop.second.red() - firstStop.second.red()) * modifierValue;
+ int greenDelta = (secondStop.second.green() - firstStop.second.green()) * modifierValue;
+ int blueDelta = (secondStop.second.blue() - firstStop.second.blue()) * modifierValue;
+ int alphaDelta = (secondStop.second.alpha() - firstStop.second.alpha()) * modifierValue;
+
+ QGradientStop newStop;
+ newStop.first = newPos;
+ newStop.second = QColor(firstStop.second.red() + redDelta,
+ firstStop.second.green() + greenDelta,
+ firstStop.second.blue() + blueDelta,
+ firstStop.second.alpha() + alphaDelta);
+
+ return newStop;
+}
+
+void QSGOpenVGInternalRectangleNode::setGradientStops(const QGradientStops &stops)
+{
+
+ //normalize stops
+ bool needsNormalization = false;
+ for (const QGradientStop &stop : qAsConst(stops)) {
+ if (stop.first < 0.0 || stop.first > 1.0) {
+ needsNormalization = true;
+ continue;
+ }
+ }
+
+ if (needsNormalization) {
+ QGradientStops normalizedStops;
+ if (stops.count() == 1) {
+ //If there is only one stop, then the position does not matter
+ //It is just treated as a color
+ QGradientStop stop = stops.at(0);
+ stop.first = 0.0;
+ normalizedStops.append(stop);
+ } else {
+ //Clip stops to only the first below 0.0 and above 1.0
+ int below = -1;
+ int above = -1;
+ QVector<int> between;
+ for (int i = 0; i < stops.count(); ++i) {
+ if (stops.at(i).first < 0.0) {
+ below = i;
+ } else if (stops.at(i).first > 1.0) {
+ above = i;
+ break;
+ } else {
+ between.append(i);
+ }
+ }
+
+ //Interpoloate new color values for above and below
+ if (below != -1 ) {
+ //If there are more than one stops left, interpolate
+ if (below + 1 < stops.count()) {
+ normalizedStops.append(interpolateStop(stops.at(below), stops.at(below + 1), 0.0));
+ } else {
+ QGradientStop singleStop;
+ singleStop.first = 0.0;
+ singleStop.second = stops.at(below).second;
+ normalizedStops.append(singleStop);
+ }
+ }
+
+ for (int i = 0; i < between.count(); ++i)
+ normalizedStops.append(stops.at(between.at(i)));
+
+ if (above != -1) {
+ //If there stops before above, interpolate
+ if (above >= 1) {
+ normalizedStops.append(interpolateStop(stops.at(above), stops.at(above - 1), 1.0));
+ } else {
+ QGradientStop singleStop;
+ singleStop.first = 1.0;
+ singleStop.second = stops.at(above).second;
+ normalizedStops.append(singleStop);
+ }
+ }
+ }
+
+ m_gradientStops = normalizedStops;
+
+ } else {
+ m_gradientStops = stops;
+ }
+
+ m_fillDirty = true;
+}
+
+void QSGOpenVGInternalRectangleNode::setRadius(qreal radius)
+{
+ m_radius = radius;
+ m_pathDirty = true;
+}
+
+void QSGOpenVGInternalRectangleNode::setAligned(bool aligned)
+{
+ m_aligned = aligned;
+}
+
+void QSGOpenVGInternalRectangleNode::update()
+{
+}
+
+void QSGOpenVGInternalRectangleNode::render()
+{
+ // Set Transform
+ if (transform().isAffine()) {
+ // Use current transform matrix
+ vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
+ vgLoadMatrix(transform().constData());
+ if (m_offscreenSurface) {
+ delete m_offscreenSurface;
+ m_offscreenSurface = nullptr;
+ }
+ } else {
+ vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
+ vgLoadIdentity();
+ if (m_radius > 0) {
+ // Fallback to rendering to an image for rounded rects with perspective transforms
+ if (m_offscreenSurface == nullptr || m_offscreenSurface->size() != QSize(ceil(m_rect.width()), ceil(m_rect.height()))) {
+ delete m_offscreenSurface;
+ m_offscreenSurface = new QOpenVGOffscreenSurface(QSize(ceil(m_rect.width()), ceil(m_rect.height())));
+ }
+
+ m_offscreenSurface->makeCurrent();
+ } else if (m_offscreenSurface) {
+ delete m_offscreenSurface;
+ m_offscreenSurface = nullptr;
+ }
+ }
+
+
+ // If path is dirty
+ if (m_pathDirty) {
+ vgClearPath(m_rectanglePath, VG_PATH_CAPABILITY_APPEND_TO);
+ vgClearPath(m_borderPath, VG_PATH_CAPABILITY_APPEND_TO);
+
+ if (m_penWidth == 0) {
+ generateRectanglePath(m_rect, m_radius, m_rectanglePath);
+ } else {
+ generateRectangleAndBorderPaths(m_rect, m_penWidth, m_radius, m_rectanglePath, m_borderPath);
+ }
+
+ m_pathDirty = false;
+ }
+
+ //If fill is drity
+ if (m_fillDirty) {
+ if (m_gradientStops.isEmpty()) {
+ vgSetParameteri(m_rectanglePaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
+ vgSetParameterfv(m_rectanglePaint, VG_PAINT_COLOR, 4, QSGOpenVGHelpers::qColorToVGColor(m_fillColor, opacity()).constData());
+ } else {
+ // Linear Gradient
+ vgSetParameteri(m_rectanglePaint, VG_PAINT_TYPE, VG_PAINT_TYPE_LINEAR_GRADIENT);
+ const VGfloat verticalLinearGradient[] = {
+ 0.0f,
+ 0.0f,
+ 0.0f,
+ static_cast<VGfloat>(m_rect.height())
+ };
+ vgSetParameterfv(m_rectanglePaint, VG_PAINT_LINEAR_GRADIENT, 4, verticalLinearGradient);
+ vgSetParameteri(m_rectanglePaint, VG_PAINT_COLOR_RAMP_SPREAD_MODE, VG_COLOR_RAMP_SPREAD_PAD);
+ vgSetParameteri(m_rectanglePaint, VG_PAINT_COLOR_RAMP_PREMULTIPLIED, false);
+
+ QVector<VGfloat> stops;
+ for (const QGradientStop &stop : qAsConst(m_gradientStops)) {
+ // offset
+ stops.append(stop.first);
+ // color
+ stops.append(QSGOpenVGHelpers::qColorToVGColor(stop.second, opacity()));
+ }
+
+ vgSetParameterfv(m_rectanglePaint, VG_PAINT_COLOR_RAMP_STOPS, stops.length(), stops.constData());
+ }
+
+ m_fillDirty = false;
+ }
+
+ //If stroke is dirty
+ if (m_strokeDirty) {
+ vgSetParameteri(m_borderPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
+ vgSetParameterfv(m_borderPaint, VG_PAINT_COLOR, 4, QSGOpenVGHelpers::qColorToVGColor(m_strokeColor, opacity()).constData());
+
+ m_strokeDirty = false;
+ }
+
+ //Draw
+ if (m_penWidth > 0) {
+ vgSetPaint(m_borderPaint, VG_FILL_PATH);
+ vgDrawPath(m_borderPath, VG_FILL_PATH);
+ vgSetPaint(m_rectanglePaint, VG_FILL_PATH);
+ vgDrawPath(m_rectanglePath, VG_FILL_PATH);
+ } else {
+ vgSetPaint(m_rectanglePaint, VG_FILL_PATH);
+ vgDrawPath(m_rectanglePath, VG_FILL_PATH);
+ }
+
+ if (!transform().isAffine() && m_radius > 0) {
+ m_offscreenSurface->doneCurrent();
+ // Render offscreen surface
+ vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
+ vgLoadMatrix(transform().constData());
+ vgDrawImage(m_offscreenSurface->image());
+ }
+}
+
+void QSGOpenVGInternalRectangleNode::setOpacity(float opacity)
+{
+ if (opacity != QSGOpenVGRenderable::opacity()) {
+ QSGOpenVGRenderable::setOpacity(opacity);
+ m_strokeDirty = true;
+ m_fillDirty = true;
+ }
+}
+
+void QSGOpenVGInternalRectangleNode::setTransform(const QOpenVGMatrix &transform)
+{
+ // if there transform matrix is not affine, regenerate the path
+ if (transform.isAffine())
+ m_pathDirty = true;
+
+ QSGOpenVGRenderable::setTransform(transform);
+}
+
+void QSGOpenVGInternalRectangleNode::createVGResources()
+{
+ m_rectanglePaint = vgCreatePaint();
+ m_borderPaint = vgCreatePaint();
+ m_rectanglePath = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
+ VG_PATH_CAPABILITY_APPEND_TO);
+ m_borderPath = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
+ VG_PATH_CAPABILITY_APPEND_TO);
+}
+
+void QSGOpenVGInternalRectangleNode::destroyVGResources()
+{
+ if (m_offscreenSurface)
+ delete m_offscreenSurface;
+
+ vgDestroyPaint(m_rectanglePaint);
+ vgDestroyPaint(m_borderPaint);
+ vgDestroyPath(m_rectanglePath);
+ vgDestroyPath(m_borderPath);
+}
+
+void QSGOpenVGInternalRectangleNode::generateRectanglePath(const QRectF &rect, float radius, VGPath path) const
+{
+ if (radius == 0) {
+ // Generate a rectangle
+ if (transform().isAffine()) {
+ // Create command list
+ static const VGubyte rectCommands[] = {
+ VG_MOVE_TO_ABS,
+ VG_HLINE_TO_REL,
+ VG_VLINE_TO_REL,
+ VG_HLINE_TO_REL,
+ VG_CLOSE_PATH
+ };
+
+ // Create command data
+ QVector<VGfloat> coordinates(5);
+ coordinates[0] = rect.x();
+ coordinates[1] = rect.y();
+ coordinates[2] = rect.width();
+ coordinates[3] = rect.height();
+ coordinates[4] = -rect.width();
+ vgAppendPathData(path, 5, rectCommands, coordinates.constData());
+ } else {
+ // Pre-transform path
+ static const VGubyte rectCommands[] = {
+ VG_MOVE_TO_ABS,
+ VG_LINE_TO_ABS,
+ VG_LINE_TO_ABS,
+ VG_LINE_TO_ABS,
+ VG_CLOSE_PATH
+ };
+
+ QVector<VGfloat> coordinates(8);
+ const QPointF topLeft = transform().map(rect.topLeft());
+ const QPointF topRight = transform().map(rect.topRight());
+ const QPointF bottomLeft = transform().map(rect.bottomLeft());
+ const QPointF bottomRight = transform().map(rect.bottomRight());
+ coordinates[0] = bottomLeft.x();
+ coordinates[1] = bottomLeft.y();
+ coordinates[2] = bottomRight.x();
+ coordinates[3] = bottomRight.y();
+ coordinates[4] = topRight.x();
+ coordinates[5] = topRight.y();
+ coordinates[6] = topLeft.x();
+ coordinates[7] = topLeft.y();
+
+ vgAppendPathData(path, 5, rectCommands, coordinates.constData());
+ }
+ } else {
+ // Generate a rounded rectangle
+ //Radius should never exceeds half of the width or half of the height
+ float adjustedRadius = qMin((float)qMin(rect.width(), rect.height()) * 0.5f, radius);
+
+ // OpenVG expectes radius to be 2x what we expect
+ adjustedRadius *= 2;
+
+ // Create command list
+ static const VGubyte roundedRectCommands[] = {
+ VG_MOVE_TO_ABS,
+ VG_HLINE_TO_REL,
+ VG_SCCWARC_TO_REL,
+ VG_VLINE_TO_REL,
+ VG_SCCWARC_TO_REL,
+ VG_HLINE_TO_REL,
+ VG_SCCWARC_TO_REL,
+ VG_VLINE_TO_REL,
+ VG_SCCWARC_TO_REL,
+ VG_CLOSE_PATH
+ };
+
+ // Create command data
+ QVector<VGfloat> coordinates(26);
+
+ coordinates[0] = rect.x() + adjustedRadius / 2;
+ coordinates[1] = rect.y();
+
+ coordinates[2] = rect.width() - adjustedRadius;
+
+ coordinates[3] = adjustedRadius / 2;
+ coordinates[4] = adjustedRadius / 2;
+ coordinates[5] = 0;
+ coordinates[6] = adjustedRadius / 2;
+ coordinates[7] = adjustedRadius / 2;
+
+ coordinates[8] = rect.height() - adjustedRadius;
+
+ coordinates[9] = adjustedRadius / 2;
+ coordinates[10] = adjustedRadius / 2;
+ coordinates[11] = 0;
+ coordinates[12] = -adjustedRadius / 2;
+ coordinates[13] = adjustedRadius / 2;
+
+ coordinates[14] = -(rect.width() - adjustedRadius);
+
+ coordinates[15] = adjustedRadius / 2;
+ coordinates[16] = adjustedRadius / 2;
+ coordinates[17] = 0;
+ coordinates[18] = -adjustedRadius / 2;
+ coordinates[19] = -adjustedRadius / 2;
+
+ coordinates[20] = -(rect.height() - adjustedRadius);
+
+ coordinates[21] = adjustedRadius / 2;
+ coordinates[22] = adjustedRadius / 2;
+ coordinates[23] = 0;
+ coordinates[24] = adjustedRadius / 2;
+ coordinates[25] = -adjustedRadius / 2;
+
+ vgAppendPathData(path, 10, roundedRectCommands, coordinates.constData());
+ }
+}
+
+void QSGOpenVGInternalRectangleNode::generateBorderPath(const QRectF &rect, float borderWidth, float borderHeight, float radius, VGPath path) const
+{
+ if (radius == 0) {
+ // squared frame
+ if (transform().isAffine()) {
+ // Create command list
+ static const VGubyte squaredBorderCommands[] = {
+ VG_MOVE_TO_ABS,
+ VG_HLINE_TO_REL,
+ VG_VLINE_TO_REL,
+ VG_HLINE_TO_REL,
+ VG_MOVE_TO_ABS,
+ VG_VLINE_TO_REL,
+ VG_HLINE_TO_REL,
+ VG_VLINE_TO_REL,
+ VG_CLOSE_PATH
+ };
+
+ // Create command data
+ QVector<VGfloat> coordinates(10);
+ // Outside Square
+ coordinates[0] = rect.x();
+ coordinates[1] = rect.y();
+ coordinates[2] = rect.width();
+ coordinates[3] = rect.height();
+ coordinates[4] = -rect.width();
+ // Inside Square (opposite direction)
+ coordinates[5] = rect.x() + borderWidth;
+ coordinates[6] = rect.y() + borderHeight;
+ coordinates[7] = rect.height() - (borderHeight * 2);
+ coordinates[8] = rect.width() - (borderWidth * 2);
+ coordinates[9] = -(rect.height() - (borderHeight * 2));
+
+ vgAppendPathData(path, 9, squaredBorderCommands, coordinates.constData());
+ } else {
+ // persepective transform
+ static const VGubyte squaredBorderCommands[] = {
+ VG_MOVE_TO_ABS,
+ VG_LINE_TO_ABS,
+ VG_LINE_TO_ABS,
+ VG_LINE_TO_ABS,
+ VG_MOVE_TO_ABS,
+ VG_LINE_TO_ABS,
+ VG_LINE_TO_ABS,
+ VG_LINE_TO_ABS,
+ VG_CLOSE_PATH
+ };
+
+ QVector<VGfloat> coordinates(16);
+ QRectF insideRect = rect.marginsRemoved(QMarginsF(borderWidth, borderHeight, borderWidth, borderHeight));
+ QPointF outsideBottomLeft = transform().map(rect.bottomLeft());
+ QPointF outsideBottomRight = transform().map(rect.bottomRight());
+ QPointF outsideTopRight = transform().map(rect.topRight());
+ QPointF outsideTopLeft = transform().map(rect.topLeft());
+ QPointF insideBottomLeft = transform().map(insideRect.bottomLeft());
+ QPointF insideTopLeft = transform().map(insideRect.topLeft());
+ QPointF insideTopRight = transform().map(insideRect.topRight());
+ QPointF insideBottomRight = transform().map(insideRect.bottomRight());
+
+ // Outside
+ coordinates[0] = outsideBottomLeft.x();
+ coordinates[1] = outsideBottomLeft.y();
+ coordinates[2] = outsideBottomRight.x();
+ coordinates[3] = outsideBottomRight.y();
+ coordinates[4] = outsideTopRight.x();
+ coordinates[5] = outsideTopRight.y();
+ coordinates[6] = outsideTopLeft.x();
+ coordinates[7] = outsideTopLeft.y();
+ // Inside
+ coordinates[8] = insideBottomLeft.x();
+ coordinates[9] = insideBottomLeft.y();
+ coordinates[10] = insideTopLeft.x();
+ coordinates[11] = insideTopLeft.y();
+ coordinates[12] = insideTopRight.x();
+ coordinates[13] = insideTopRight.y();
+ coordinates[14] = insideBottomRight.x();
+ coordinates[15] = insideBottomRight.y();
+
+ vgAppendPathData(path, 9, squaredBorderCommands, coordinates.constData());
+ }
+ } else if (radius < qMax(borderWidth, borderHeight)){
+ // rounded outside, squared inside
+ // Create command list
+ static const VGubyte roundedRectCommands[] = {
+ VG_MOVE_TO_ABS,
+ VG_HLINE_TO_REL,
+ VG_SCCWARC_TO_REL,
+ VG_VLINE_TO_REL,
+ VG_SCCWARC_TO_REL,
+ VG_HLINE_TO_REL,
+ VG_SCCWARC_TO_REL,
+ VG_VLINE_TO_REL,
+ VG_SCCWARC_TO_REL,
+ VG_MOVE_TO_ABS,
+ VG_VLINE_TO_REL,
+ VG_HLINE_TO_REL,
+ VG_VLINE_TO_REL,
+ VG_CLOSE_PATH
+ };
+
+ // Ajust for OpenVG's usage or radius
+ float adjustedRadius = radius * 2;
+
+ // Create command data
+ QVector<VGfloat> coordinates(31);
+ // Outside Rounded Rect
+ coordinates[0] = rect.x() + adjustedRadius / 2;
+ coordinates[1] = rect.y();
+
+ coordinates[2] = rect.width() - adjustedRadius;
+
+ coordinates[3] = adjustedRadius / 2;
+ coordinates[4] = adjustedRadius / 2;
+ coordinates[5] = 0;
+ coordinates[6] = adjustedRadius / 2;
+ coordinates[7] = adjustedRadius / 2;
+
+ coordinates[8] = rect.height() - adjustedRadius;
+
+ coordinates[9] = adjustedRadius / 2;
+ coordinates[10] = adjustedRadius / 2;
+ coordinates[11] = 0;
+ coordinates[12] = -adjustedRadius / 2;
+ coordinates[13] = adjustedRadius / 2;
+
+ coordinates[14] = -(rect.width() - adjustedRadius);
+
+ coordinates[15] = adjustedRadius / 2;
+ coordinates[16] = adjustedRadius / 2;
+ coordinates[17] = 0;
+ coordinates[18] = -adjustedRadius / 2;
+ coordinates[19] = -adjustedRadius / 2;
+
+ coordinates[20] = -(rect.height() - adjustedRadius);
+
+ coordinates[21] = adjustedRadius / 2;
+ coordinates[22] = adjustedRadius / 2;
+ coordinates[23] = 0;
+ coordinates[24] = adjustedRadius / 2;
+ coordinates[25] = -adjustedRadius / 2;
+
+ // Inside Square (opposite direction)
+ coordinates[26] = rect.x() + borderWidth;
+ coordinates[27] = rect.y() + borderHeight;
+ coordinates[28] = rect.height() - (borderHeight * 2);
+ coordinates[29] = rect.width() - (borderWidth * 2);
+ coordinates[30] = -(rect.height() - (borderHeight * 2));
+
+ vgAppendPathData(path, 14, roundedRectCommands, coordinates.constData());
+ } else {
+ // rounded outside, rounded inside
+
+ static const VGubyte roundedBorderCommands[] = {
+ // Outer
+ VG_MOVE_TO_ABS,
+ VG_HLINE_TO_REL,
+ VG_SCCWARC_TO_REL,
+ VG_VLINE_TO_REL,
+ VG_SCCWARC_TO_REL,
+ VG_HLINE_TO_REL,
+ VG_SCCWARC_TO_REL,
+ VG_VLINE_TO_REL,
+ VG_SCCWARC_TO_REL,
+ // Inner
+ VG_MOVE_TO_ABS,
+ VG_SCWARC_TO_REL,
+ VG_VLINE_TO_REL,
+ VG_SCWARC_TO_REL,
+ VG_HLINE_TO_REL,
+ VG_SCWARC_TO_REL,
+ VG_VLINE_TO_REL,
+ VG_SCWARC_TO_REL,
+ VG_HLINE_TO_REL,
+ VG_CLOSE_PATH
+ };
+
+ // Adjust for OpenVG's usage or radius
+ float adjustedRadius = radius * 2;
+ float adjustedInnerRadius = (radius - qMax(borderWidth, borderHeight)) * 2;
+
+ // Create command data
+ QVector<VGfloat> coordinates(52);
+
+ // Outer
+ coordinates[0] = rect.x() + adjustedRadius / 2;
+ coordinates[1] = rect.y();
+
+ coordinates[2] = rect.width() - adjustedRadius;
+
+ coordinates[3] = adjustedRadius / 2;
+ coordinates[4] = adjustedRadius / 2;
+ coordinates[5] = 0;
+ coordinates[6] = adjustedRadius / 2;
+ coordinates[7] = adjustedRadius / 2;
+
+ coordinates[8] = rect.height() - adjustedRadius;
+
+ coordinates[9] = adjustedRadius / 2;
+ coordinates[10] = adjustedRadius / 2;
+ coordinates[11] = 0;
+ coordinates[12] = -adjustedRadius / 2;
+ coordinates[13] = adjustedRadius / 2;
+
+ coordinates[14] = -(rect.width() - adjustedRadius);
+
+ coordinates[15] = adjustedRadius / 2;
+ coordinates[16] = adjustedRadius / 2;
+ coordinates[17] = 0;
+ coordinates[18] = -adjustedRadius / 2;
+ coordinates[19] = -adjustedRadius / 2;
+
+ coordinates[20] = -(rect.height() - adjustedRadius);
+
+ coordinates[21] = adjustedRadius / 2;
+ coordinates[22] = adjustedRadius / 2;
+ coordinates[23] = 0;
+ coordinates[24] = adjustedRadius / 2;
+ coordinates[25] = -adjustedRadius / 2;
+
+ // Inner
+ coordinates[26] = rect.width() - (adjustedInnerRadius / 2 + borderWidth);
+ coordinates[27] = rect.height() - borderHeight;
+
+ coordinates[28] = adjustedInnerRadius / 2;
+ coordinates[29] = adjustedInnerRadius / 2;
+ coordinates[30] = 0;
+ coordinates[31] = adjustedInnerRadius / 2;
+ coordinates[32] = -adjustedInnerRadius / 2;
+
+ coordinates[33] = -((rect.height() - borderHeight * 2) - adjustedInnerRadius);
+
+ coordinates[34] = adjustedInnerRadius / 2;
+ coordinates[35] = adjustedInnerRadius / 2;
+ coordinates[36] = 0;
+ coordinates[37] = -adjustedInnerRadius / 2;
+ coordinates[38] = -adjustedInnerRadius / 2;
+
+ coordinates[39] = -((rect.width() - borderWidth * 2) - adjustedInnerRadius);
+
+ coordinates[40] = adjustedInnerRadius / 2;
+ coordinates[41] = adjustedInnerRadius / 2;
+ coordinates[42] = 0;
+ coordinates[43] = -adjustedInnerRadius / 2;
+ coordinates[44] = adjustedInnerRadius / 2;
+
+ coordinates[45] = (rect.height() - borderHeight * 2) - adjustedInnerRadius;
+
+ coordinates[46] = adjustedInnerRadius / 2;
+ coordinates[47] = adjustedInnerRadius / 2;
+ coordinates[48] = 0;
+ coordinates[49] = adjustedInnerRadius / 2;
+ coordinates[50] = adjustedInnerRadius / 2;
+
+ coordinates[51] = (rect.width() - borderWidth * 2) - adjustedInnerRadius;
+
+ vgAppendPathData(path, 19, roundedBorderCommands, coordinates.constData());
+ }
+}
+
+void QSGOpenVGInternalRectangleNode::generateRectangleAndBorderPaths(const QRectF &rect, float penWidth, float radius, VGPath inside, VGPath outside) const
+{
+ //Borders can not be more than half the height/width of a rect
+ float borderWidth = qMin(penWidth, (float)rect.width() * 0.5f);
+ float borderHeight = qMin(penWidth, (float)rect.height() * 0.5f);
+
+ //Radius should never exceeds half of the width or half of the height
+ float adjustedRadius = qMin((float)qMin(rect.width(), rect.height()) * 0.5f, radius);
+
+ QRectF innerRect = rect;
+ innerRect.adjust(borderWidth, borderHeight, -borderWidth, -borderHeight);
+
+ if (radius == 0) {
+ // Regular rect with border
+ generateRectanglePath(innerRect, 0, inside);
+ generateBorderPath(rect, borderWidth, borderHeight, 0, outside);
+ } else {
+ // Rounded Rect with border
+ float innerRadius = radius - qMax(borderWidth, borderHeight);
+ if (innerRadius < 0)
+ innerRadius = 0.0f;
+
+ generateRectanglePath(innerRect, innerRadius, inside);
+ generateBorderPath(rect, borderWidth, borderHeight, adjustedRadius, outside);
+ }
+}
diff --git a/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h
new file mode 100644
index 0000000000..e8d25c94f8
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGOPENVGINTERNALRECTANGLENODE_H
+#define QSGOPENVGINTERNALRECTANGLENODE_H
+
+#include <private/qsgadaptationlayer_p.h>
+#include "qsgopenvgrenderable.h"
+#include "qopenvgoffscreensurface.h"
+
+#include <VG/openvg.h>
+
+QT_BEGIN_NAMESPACE
+
+class QSGOpenVGInternalRectangleNode : public QSGInternalRectangleNode, public QSGOpenVGRenderable
+{
+public:
+ QSGOpenVGInternalRectangleNode();
+ ~QSGOpenVGInternalRectangleNode();
+
+ void setRect(const QRectF &rect) override;
+ void setColor(const QColor &color) override;
+ void setPenColor(const QColor &color) override;
+ void setPenWidth(qreal width) override;
+ void setGradientStops(const QGradientStops &stops) override;
+ void setRadius(qreal radius) override;
+ void setAligned(bool aligned) override;
+ void update() override;
+
+ void render() override;
+ void setOpacity(float opacity) override;
+ void setTransform(const QOpenVGMatrix &transform) override;
+
+private:
+ void createVGResources();
+ void destroyVGResources();
+
+ void generateRectanglePath(const QRectF &rect, float radius, VGPath path) const;
+ void generateRectangleAndBorderPaths(const QRectF &rect, float penWidth, float radius, VGPath inside, VGPath outside) const;
+ void generateBorderPath(const QRectF &rect, float borderWidth, float borderHeight, float radius, VGPath path) const;
+
+ bool m_pathDirty = true;
+ bool m_fillDirty = true;
+ bool m_strokeDirty = true;
+
+ QRectF m_rect;
+ QColor m_fillColor;
+ QColor m_strokeColor;
+ qreal m_penWidth = 0.0;
+ qreal m_radius = 0.0;
+ bool m_aligned = false;
+ QGradientStops m_gradientStops;
+
+ VGPath m_rectanglePath;
+ VGPath m_borderPath;
+ VGPaint m_rectanglePaint;
+ VGPaint m_borderPaint;
+
+ QOpenVGOffscreenSurface *m_offscreenSurface = nullptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGOPENVGINTERNALRECTANGLENODE_H
diff --git a/src/plugins/scenegraph/openvg/qsgopenvglayer.cpp b/src/plugins/scenegraph/openvg/qsgopenvglayer.cpp
new file mode 100644
index 0000000000..047539d431
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvglayer.cpp
@@ -0,0 +1,315 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgopenvglayer.h"
+#include "qsgopenvgrenderer_p.h"
+#include "qsgopenvgcontext_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QSGOpenVGLayer::QSGOpenVGLayer(QSGRenderContext *renderContext)
+ : m_item(nullptr)
+ , m_renderer(nullptr)
+ , m_device_pixel_ratio(1)
+ , m_mirrorHorizontal(false)
+ , m_mirrorVertical(false)
+ , m_live(true)
+ , m_grab(true)
+ , m_recursive(false)
+ , m_dirtyTexture(true)
+ , m_offscreenSurface(nullptr)
+ , m_secondaryOffscreenSurface(nullptr)
+{
+ m_context = static_cast<QSGOpenVGRenderContext*>(renderContext);
+}
+
+QSGOpenVGLayer::~QSGOpenVGLayer()
+{
+ invalidated();
+}
+
+int QSGOpenVGLayer::textureId() const
+{
+ if (m_offscreenSurface)
+ return static_cast<int>(m_offscreenSurface->image());
+ else
+ return 0;
+}
+
+QSize QSGOpenVGLayer::textureSize() const
+{
+ if (m_offscreenSurface) {
+ return m_offscreenSurface->size();
+ }
+
+ return QSize();
+}
+
+bool QSGOpenVGLayer::hasAlphaChannel() const
+{
+ return true;
+}
+
+bool QSGOpenVGLayer::hasMipmaps() const
+{
+ return false;
+}
+
+void QSGOpenVGLayer::bind()
+{
+}
+
+bool QSGOpenVGLayer::updateTexture()
+{
+ bool doGrab = (m_live || m_grab) && m_dirtyTexture;
+ if (doGrab)
+ grab();
+ if (m_grab)
+ emit scheduledUpdateCompleted();
+ m_grab = false;
+ return doGrab;
+}
+
+void QSGOpenVGLayer::setItem(QSGNode *item)
+{
+ if (item == m_item)
+ return;
+ m_item = item;
+
+ if (m_live && !m_item) {
+ delete m_offscreenSurface;
+ delete m_secondaryOffscreenSurface;
+ m_offscreenSurface = nullptr;
+ m_secondaryOffscreenSurface = nullptr;
+ }
+
+ markDirtyTexture();
+}
+
+void QSGOpenVGLayer::setRect(const QRectF &rect)
+{
+ if (rect == m_rect)
+ return;
+ m_rect = rect;
+ markDirtyTexture();
+}
+
+void QSGOpenVGLayer::setSize(const QSize &size)
+{
+ if (size == m_size)
+ return;
+ m_size = size;
+
+ if (m_live && m_size.isNull()) {
+ delete m_offscreenSurface;
+ delete m_secondaryOffscreenSurface;
+ m_offscreenSurface = nullptr;
+ m_secondaryOffscreenSurface = nullptr;
+ }
+
+ markDirtyTexture();
+}
+
+void QSGOpenVGLayer::scheduleUpdate()
+{
+ if (m_grab)
+ return;
+ m_grab = true;
+ if (m_dirtyTexture) {
+ emit updateRequested();
+ }
+}
+
+QImage QSGOpenVGLayer::toImage() const
+{
+ return m_offscreenSurface->readbackQImage();
+}
+
+void QSGOpenVGLayer::setLive(bool live)
+{
+ if (live == m_live)
+ return;
+ m_live = live;
+
+ if (m_live && (!m_item || m_size.isNull())) {
+ delete m_offscreenSurface;
+ delete m_secondaryOffscreenSurface;
+ m_offscreenSurface = nullptr;
+ m_secondaryOffscreenSurface = nullptr;
+ }
+
+ markDirtyTexture();
+}
+
+void QSGOpenVGLayer::setRecursive(bool recursive)
+{
+ m_recursive = recursive;
+}
+
+void QSGOpenVGLayer::setFormat(uint format)
+{
+ Q_UNUSED(format)
+}
+
+void QSGOpenVGLayer::setHasMipmaps(bool mipmap)
+{
+ Q_UNUSED(mipmap)
+}
+
+void QSGOpenVGLayer::setDevicePixelRatio(qreal ratio)
+{
+ m_device_pixel_ratio = ratio;
+}
+
+void QSGOpenVGLayer::setMirrorHorizontal(bool mirror)
+{
+ if (m_mirrorHorizontal == mirror)
+ return;
+ m_mirrorHorizontal = mirror;
+ markDirtyTexture();
+}
+
+void QSGOpenVGLayer::setMirrorVertical(bool mirror)
+{
+ if (m_mirrorVertical == mirror)
+ return;
+ m_mirrorVertical = mirror;
+ markDirtyTexture();
+}
+
+void QSGOpenVGLayer::markDirtyTexture()
+{
+ m_dirtyTexture = true;
+ if (m_live || m_grab) {
+ emit updateRequested();
+ }
+}
+
+void QSGOpenVGLayer::invalidated()
+{
+ delete m_offscreenSurface;
+ delete m_secondaryOffscreenSurface;
+ delete m_renderer;
+ m_renderer = nullptr;
+ m_offscreenSurface = nullptr;
+ m_secondaryOffscreenSurface = nullptr;
+}
+
+void QSGOpenVGLayer::grab()
+{
+ if (!m_item || m_size.isNull()) {
+ delete m_offscreenSurface;
+ delete m_secondaryOffscreenSurface;
+ m_offscreenSurface = nullptr;
+ m_secondaryOffscreenSurface = nullptr;
+ m_dirtyTexture = false;
+ return;
+ }
+ QSGNode *root = m_item;
+ while (root->firstChild() && root->type() != QSGNode::RootNodeType)
+ root = root->firstChild();
+ if (root->type() != QSGNode::RootNodeType)
+ return;
+
+ if (!m_renderer) {
+ m_renderer = new QSGOpenVGRenderer(m_context);
+ connect(m_renderer, SIGNAL(sceneGraphChanged()), this, SLOT(markDirtyTexture()));
+ }
+ m_renderer->setDevicePixelRatio(m_device_pixel_ratio);
+ m_renderer->setRootNode(static_cast<QSGRootNode *>(root));
+
+ bool deleteOffscreenSurfaceLater = false;
+ if (m_offscreenSurface == nullptr || m_offscreenSurface->size() != m_size ) {
+ if (m_recursive) {
+ deleteOffscreenSurfaceLater = true;
+ delete m_secondaryOffscreenSurface;
+ m_secondaryOffscreenSurface = new QOpenVGOffscreenSurface(m_size);
+ } else {
+ delete m_offscreenSurface;
+ delete m_secondaryOffscreenSurface;
+ m_offscreenSurface = new QOpenVGOffscreenSurface(m_size);
+ m_secondaryOffscreenSurface = nullptr;
+ }
+ }
+
+ if (m_recursive && !m_secondaryOffscreenSurface)
+ m_secondaryOffscreenSurface = new QOpenVGOffscreenSurface(m_size);
+
+ // Render texture.
+ root->markDirty(QSGNode::DirtyForceUpdate); // Force matrix, clip and opacity update.
+ m_renderer->nodeChanged(root, QSGNode::DirtyForceUpdate); // Force render list update.
+
+ m_dirtyTexture = false;
+
+ m_renderer->setDeviceRect(m_size);
+ m_renderer->setViewportRect(m_size);
+ QRect mirrored(m_mirrorHorizontal ? m_rect.right() * m_device_pixel_ratio : m_rect.left() * m_device_pixel_ratio,
+ m_mirrorVertical ? m_rect.top() * m_device_pixel_ratio : m_rect.bottom() * m_device_pixel_ratio,
+ m_mirrorHorizontal ? -m_rect.width() * m_device_pixel_ratio : m_rect.width() * m_device_pixel_ratio,
+ m_mirrorVertical ? m_rect.height() * m_device_pixel_ratio : -m_rect.height() * m_device_pixel_ratio);
+ m_renderer->setProjectionMatrixToRect(mirrored);
+ m_renderer->setClearColor(Qt::transparent);
+
+
+ if (m_recursive)
+ m_secondaryOffscreenSurface->makeCurrent();
+ else
+ m_offscreenSurface->makeCurrent();
+
+ m_renderer->renderScene();
+
+ // Make the previous surface and context active again
+ if (m_recursive) {
+ if (deleteOffscreenSurfaceLater) {
+ delete m_offscreenSurface;
+ m_offscreenSurface = new QOpenVGOffscreenSurface(m_size);
+ }
+ m_secondaryOffscreenSurface->doneCurrent();
+ qSwap(m_offscreenSurface, m_secondaryOffscreenSurface);
+ } else {
+ m_offscreenSurface->doneCurrent();
+ }
+
+ root->markDirty(QSGNode::DirtyForceUpdate); // Force matrix, clip, opacity and render list update.
+
+ if (m_recursive)
+ markDirtyTexture(); // Continuously update if 'live' and 'recursive'.
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/scenegraph/openvg/qsgopenvglayer.h b/src/plugins/scenegraph/openvg/qsgopenvglayer.h
new file mode 100644
index 0000000000..2af0bfb40f
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvglayer.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGOPENVGLAYER_H
+#define QSGOPENVGLAYER_H
+
+#include <private/qsgadaptationlayer_p.h>
+#include <private/qsgcontext_p.h>
+
+#include "qopenvgcontext_p.h"
+#include "qopenvgoffscreensurface.h"
+
+QT_BEGIN_NAMESPACE
+
+class QSGOpenVGRenderer;
+class QSGOpenVGRenderContext;
+
+class QSGOpenVGLayer : public QSGLayer
+{
+public:
+ QSGOpenVGLayer(QSGRenderContext *renderContext);
+ ~QSGOpenVGLayer();
+
+ // QSGTexture interface
+public:
+ int textureId() const override;
+ QSize textureSize() const override;
+ bool hasAlphaChannel() const override;
+ bool hasMipmaps() const override;
+ void bind() override;
+
+ // QSGDynamicTexture interface
+public:
+ bool updateTexture() override;
+
+ // QSGLayer interface
+public:
+ void setItem(QSGNode *item) override;
+ void setRect(const QRectF &rect) override;
+ void setSize(const QSize &size) override;
+ void scheduleUpdate() override;
+ QImage toImage() const override;
+ void setLive(bool live) override;
+ void setRecursive(bool recursive) override;
+ void setFormat(uint format) override;
+ void setHasMipmaps(bool mipmap) override;
+ void setDevicePixelRatio(qreal ratio) override;
+ void setMirrorHorizontal(bool mirror) override;
+ void setMirrorVertical(bool mirror) override;
+
+public slots:
+ void markDirtyTexture() override;
+ void invalidated() override;
+
+private:
+ void grab();
+
+ QSGNode *m_item;
+ QSGOpenVGRenderContext *m_context;
+ QSGOpenVGRenderer *m_renderer;
+ QRectF m_rect;
+ QSize m_size;
+ qreal m_device_pixel_ratio;
+ bool m_mirrorHorizontal;
+ bool m_mirrorVertical;
+ bool m_live;
+ bool m_grab;
+ bool m_recursive;
+ bool m_dirtyTexture;
+
+ QOpenVGOffscreenSurface *m_offscreenSurface;
+ QOpenVGOffscreenSurface *m_secondaryOffscreenSurface;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGOPENVGLAYER_H
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.cpp b/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.cpp
new file mode 100644
index 0000000000..8aa179f705
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.cpp
@@ -0,0 +1,275 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgopenvgnodevisitor.h"
+#include "qsgopenvginternalrectanglenode.h"
+#include "qsgopenvginternalimagenode.h"
+#include "qsgopenvgpublicnodes.h"
+#include "qsgopenvgglyphnode_p.h"
+#include "qsgopenvgpainternode.h"
+#include "qsgopenvgspritenode.h"
+#include "qsgopenvgrenderable.h"
+
+#include "qopenvgcontext_p.h"
+
+#include <QtQuick/qsgsimplerectnode.h>
+#include <QtQuick/qsgsimpletexturenode.h>
+#include <QtQuick/qsgrendernode.h>
+
+QT_BEGIN_NAMESPACE
+
+QSGOpenVGNodeVisitor::QSGOpenVGNodeVisitor()
+{
+ //Store the current matrix state
+ QVector<VGfloat> matrix(9);
+ vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
+ vgGetMatrix(matrix.data());
+
+ m_transformStack.push(QOpenVGMatrix(matrix.constData()));
+
+ // Opacity
+ m_opacityState.push(1.0f);
+}
+
+bool QSGOpenVGNodeVisitor::visit(QSGTransformNode *node)
+{
+ const QVector<float> matrixData = { node->matrix().constData()[0], node->matrix().constData()[1], node->matrix().constData()[3],
+ node->matrix().constData()[4], node->matrix().constData()[5], node->matrix().constData()[7],
+ node->matrix().constData()[12], node->matrix().constData()[13], node->matrix().constData()[15] };
+ const QOpenVGMatrix matrix2d(matrixData.constData());
+
+ m_transformStack.push(m_transformStack.top() * matrix2d);
+ return true;
+}
+
+void QSGOpenVGNodeVisitor::endVisit(QSGTransformNode *)
+{
+ m_transformStack.pop();
+}
+
+bool QSGOpenVGNodeVisitor::visit(QSGClipNode *node)
+{
+ VGMaskOperation maskOperation = VG_INTERSECT_MASK;
+ if (m_clipStack.count() == 0) {
+ vgSeti(VG_MASKING, VG_TRUE);
+ vgMask(0,VG_FILL_MASK, 0, 0, VG_MAXINT, VG_MAXINT);
+ }
+
+ // Render clip node geometry to mask
+ vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
+ vgLoadIdentity();
+ VGPath clipPath = generateClipPath(node->clipRect());
+ vgRenderToMask(clipPath, VG_FILL_PATH, maskOperation);
+
+ m_clipStack.push(clipPath);
+
+ return true;
+}
+
+void QSGOpenVGNodeVisitor::endVisit(QSGClipNode *)
+{
+ // Remove clip node geometry from mask
+ auto clipState = m_clipStack.pop();
+ vgDestroyPath(clipState);
+
+ if (m_clipStack.count() == 0) {
+ vgSeti(VG_MASKING, VG_FALSE);
+ } else {
+ // Recreate the mask
+ vgMask(0,VG_FILL_MASK, 0, 0, VG_MAXINT, VG_MAXINT);
+ vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
+ vgLoadIdentity();
+ for (auto path : qAsConst(m_clipStack)) {
+ vgRenderToMask(path, VG_FILL_PATH, VG_INTERSECT_MASK);
+ }
+ }
+}
+
+bool QSGOpenVGNodeVisitor::visit(QSGGeometryNode *node)
+{
+ if (QSGSimpleRectNode *rectNode = dynamic_cast<QSGSimpleRectNode *>(node)) {
+ // TODO: Try and render the QSGSimpleRectNode
+ Q_UNUSED(rectNode)
+ return false;
+ } else if (QSGSimpleTextureNode *tn = dynamic_cast<QSGSimpleTextureNode *>(node)) {
+ // TODO: Try and render the QSGSimpleTextureNode
+ Q_UNUSED(tn)
+ return false;
+ } else if (QSGOpenVGNinePatchNode *nn = dynamic_cast<QSGOpenVGNinePatchNode *>(node)) {
+ renderRenderableNode(nn);
+ } else if (QSGOpenVGRectangleNode *rn = dynamic_cast<QSGOpenVGRectangleNode *>(node)) {
+ renderRenderableNode(rn);
+ } else if (QSGOpenVGImageNode *n = dynamic_cast<QSGOpenVGImageNode *>(node)) {
+ renderRenderableNode(n);
+ } else {
+ // We dont know, so skip
+ return false;
+ }
+
+ return true;
+}
+
+void QSGOpenVGNodeVisitor::endVisit(QSGGeometryNode *)
+{
+}
+
+bool QSGOpenVGNodeVisitor::visit(QSGOpacityNode *node)
+{
+ m_opacityState.push(m_opacityState.top() * node->opacity());
+ return true;
+}
+
+void QSGOpenVGNodeVisitor::endVisit(QSGOpacityNode *)
+{
+ m_opacityState.pop();
+}
+
+bool QSGOpenVGNodeVisitor::visit(QSGInternalImageNode *node)
+{
+ renderRenderableNode(static_cast<QSGOpenVGInternalImageNode*>(node));
+ return true;
+}
+
+void QSGOpenVGNodeVisitor::endVisit(QSGInternalImageNode *)
+{
+}
+
+bool QSGOpenVGNodeVisitor::visit(QSGPainterNode *node)
+{
+ renderRenderableNode(static_cast<QSGOpenVGPainterNode*>(node));
+ return true;
+}
+
+void QSGOpenVGNodeVisitor::endVisit(QSGPainterNode *)
+{
+}
+
+bool QSGOpenVGNodeVisitor::visit(QSGInternalRectangleNode *node)
+{
+ renderRenderableNode(static_cast<QSGOpenVGInternalRectangleNode*>(node));
+ return true;
+}
+
+void QSGOpenVGNodeVisitor::endVisit(QSGInternalRectangleNode *)
+{
+}
+
+bool QSGOpenVGNodeVisitor::visit(QSGGlyphNode *node)
+{
+ renderRenderableNode(static_cast<QSGOpenVGGlyphNode*>(node));
+ return true;
+}
+
+void QSGOpenVGNodeVisitor::endVisit(QSGGlyphNode *)
+{
+}
+
+bool QSGOpenVGNodeVisitor::visit(QSGRootNode *)
+{
+ return true;
+}
+
+void QSGOpenVGNodeVisitor::endVisit(QSGRootNode *)
+{
+}
+
+bool QSGOpenVGNodeVisitor::visit(QSGSpriteNode *node)
+{
+ renderRenderableNode(static_cast<QSGOpenVGSpriteNode*>(node));
+ return true;
+}
+
+void QSGOpenVGNodeVisitor::endVisit(QSGSpriteNode *)
+{
+}
+
+bool QSGOpenVGNodeVisitor::visit(QSGRenderNode *)
+{
+ return true;
+}
+
+void QSGOpenVGNodeVisitor::endVisit(QSGRenderNode *)
+{
+}
+
+VGPath QSGOpenVGNodeVisitor::generateClipPath(const QRectF &rect) const
+{
+ VGPath clipPath = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
+ VG_PATH_CAPABILITY_APPEND_TO);
+
+ // Create command list
+ static const VGubyte rectCommands[] = {
+ VG_MOVE_TO_ABS,
+ VG_LINE_TO_ABS,
+ VG_LINE_TO_ABS,
+ VG_LINE_TO_ABS,
+ VG_CLOSE_PATH
+ };
+
+ const QOpenVGMatrix &transform = m_transformStack.top();
+
+ // Create command data
+ QVector<VGfloat> coordinates(8);
+ const QPointF topLeft = transform.map(rect.topLeft());
+ const QPointF topRight = transform.map(rect.topRight());
+ const QPointF bottomLeft = transform.map(rect.bottomLeft());
+ const QPointF bottomRight = transform.map(rect.bottomRight());
+ coordinates[0] = bottomLeft.x();
+ coordinates[1] = bottomLeft.y();
+ coordinates[2] = bottomRight.x();
+ coordinates[3] = bottomRight.y();
+ coordinates[4] = topRight.x();
+ coordinates[5] = topRight.y();
+ coordinates[6] = topLeft.x();
+ coordinates[7] = topLeft.y();
+
+ vgAppendPathData(clipPath, 5, rectCommands, coordinates.constData());
+ return clipPath;
+}
+
+void QSGOpenVGNodeVisitor::renderRenderableNode(QSGOpenVGRenderable *node)
+{
+ if (!node)
+ return;
+ node->setTransform(m_transformStack.top());
+ node->setOpacity(m_opacityState.top());
+ node->render();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.h b/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.h
new file mode 100644
index 0000000000..4805d63024
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGOPENVGNODEVISITOR_H
+#define QSGOPENVGNODEVISITOR_H
+
+#include <private/qsgadaptationlayer_p.h>
+#include <QtCore/QStack>
+
+#include "qopenvgmatrix.h"
+
+#include <VG/openvg.h>
+
+QT_BEGIN_NAMESPACE
+
+class QSGOpenVGRenderable;
+class QSGOpenVGNodeVisitor : public QSGNodeVisitorEx
+{
+public:
+ QSGOpenVGNodeVisitor();
+
+ bool visit(QSGTransformNode *) override;
+ void endVisit(QSGTransformNode *) override;
+ bool visit(QSGClipNode *) override;
+ void endVisit(QSGClipNode *) override;
+ bool visit(QSGGeometryNode *) override;
+ void endVisit(QSGGeometryNode *) override;
+ bool visit(QSGOpacityNode *) override;
+ void endVisit(QSGOpacityNode *) override;
+ bool visit(QSGInternalImageNode *) override;
+ void endVisit(QSGInternalImageNode *) override;
+ bool visit(QSGPainterNode *) override;
+ void endVisit(QSGPainterNode *) override;
+ bool visit(QSGInternalRectangleNode *) override;
+ void endVisit(QSGInternalRectangleNode *) override;
+ bool visit(QSGGlyphNode *) override;
+ void endVisit(QSGGlyphNode *) override;
+ bool visit(QSGRootNode *) override;
+ void endVisit(QSGRootNode *) override;
+ bool visit(QSGSpriteNode *) override;
+ void endVisit(QSGSpriteNode *) override;
+ bool visit(QSGRenderNode *) override;
+ void endVisit(QSGRenderNode *) override;
+
+private:
+ VGPath generateClipPath(const QRectF &rect) const;
+ void renderRenderableNode(QSGOpenVGRenderable *node);
+
+ QStack<QOpenVGMatrix> m_transformStack;
+ QStack<float> m_opacityState;
+ QStack<VGPath> m_clipStack;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGOPENVGNODEVISITOR_H
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgpainternode.cpp b/src/plugins/scenegraph/openvg/qsgopenvgpainternode.cpp
new file mode 100644
index 0000000000..fb68ebf2bc
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgpainternode.cpp
@@ -0,0 +1,253 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgopenvgpainternode.h"
+#include "qsgopenvgtexture.h"
+#include <qmath.h>
+
+#include <QtGui/QPainter>
+
+QT_BEGIN_NAMESPACE
+
+QSGOpenVGPainterNode::QSGOpenVGPainterNode(QQuickPaintedItem *item)
+ : m_preferredRenderTarget(QQuickPaintedItem::Image)
+ , m_item(item)
+ , m_texture(nullptr)
+ , m_dirtyContents(false)
+ , m_opaquePainting(false)
+ , m_linear_filtering(false)
+ , m_smoothPainting(false)
+ , m_fillColor(Qt::transparent)
+ , m_contentsScale(1.0)
+ , m_dirtyGeometry(false)
+{
+ // Set Dummy material and geometry to avoid asserts
+ setMaterial((QSGMaterial*)1);
+ setGeometry((QSGGeometry*)1);
+}
+
+QSGOpenVGPainterNode::~QSGOpenVGPainterNode()
+{
+ delete m_texture;
+}
+
+void QSGOpenVGPainterNode::setPreferredRenderTarget(QQuickPaintedItem::RenderTarget)
+{
+}
+
+void QSGOpenVGPainterNode::setSize(const QSize &size)
+{
+ if (size == m_size)
+ return;
+
+ m_size = size;
+
+ m_dirtyGeometry = true;
+}
+
+void QSGOpenVGPainterNode::setDirty(const QRect &dirtyRect)
+{
+ m_dirtyContents = true;
+ m_dirtyRect = dirtyRect;
+ markDirty(DirtyMaterial);
+}
+
+void QSGOpenVGPainterNode::setOpaquePainting(bool opaque)
+{
+ if (opaque == m_opaquePainting)
+ return;
+
+ m_opaquePainting = opaque;
+}
+
+void QSGOpenVGPainterNode::setLinearFiltering(bool linearFiltering)
+{
+ if (linearFiltering == m_linear_filtering)
+ return;
+
+ m_linear_filtering = linearFiltering;
+}
+
+void QSGOpenVGPainterNode::setMipmapping(bool)
+{
+
+}
+
+void QSGOpenVGPainterNode::setSmoothPainting(bool s)
+{
+ if (s == m_smoothPainting)
+ return;
+
+ m_smoothPainting = s;
+}
+
+void QSGOpenVGPainterNode::setFillColor(const QColor &c)
+{
+ if (c == m_fillColor)
+ return;
+
+ m_fillColor = c;
+ markDirty(DirtyMaterial);
+}
+
+void QSGOpenVGPainterNode::setContentsScale(qreal s)
+{
+ if (s == m_contentsScale)
+ return;
+
+ m_contentsScale = s;
+ markDirty(DirtyMaterial);
+}
+
+void QSGOpenVGPainterNode::setFastFBOResizing(bool)
+{
+}
+
+void QSGOpenVGPainterNode::setTextureSize(const QSize &size)
+{
+ if (size == m_textureSize)
+ return;
+
+ m_textureSize = size;
+ m_dirtyGeometry = true;
+}
+
+QImage QSGOpenVGPainterNode::toImage() const
+{
+ return m_image;
+}
+
+void QSGOpenVGPainterNode::update()
+{
+ if (m_dirtyGeometry) {
+ if (!m_opaquePainting)
+ m_image = QImage(m_size, QImage::Format_ARGB32_Premultiplied);
+ else
+ m_image = QImage(m_size, QImage::Format_RGB32);
+ }
+
+ if (m_dirtyContents)
+ paint();
+
+ m_dirtyGeometry = false;
+ m_dirtyContents = false;
+}
+
+QSGTexture *QSGOpenVGPainterNode::texture() const
+{
+ return m_texture;
+}
+
+void QSGOpenVGPainterNode::render()
+{
+ if (!m_texture)
+ return;
+
+ // Set Draw Mode
+ if (opacity() < 1.0) {
+ //Transparent
+ vgSetPaint(opacityPaint(), VG_FILL_PATH);
+ vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY);
+ } else {
+ vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL);
+ }
+
+ if (m_linear_filtering)
+ vgSeti(VG_IMAGE_QUALITY, VG_IMAGE_QUALITY_BETTER);
+ else
+ vgSeti(VG_IMAGE_QUALITY, VG_IMAGE_QUALITY_NONANTIALIASED);
+
+ // Set Transform
+ vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
+ vgLoadMatrix(transform().constData());
+
+ vgDrawImage(static_cast<VGImage>(m_texture->textureId()));
+}
+
+void QSGOpenVGPainterNode::paint()
+{
+ QRect dirtyRect = m_dirtyRect.isNull() ? QRect(0, 0, m_size.width(), m_size.height()) : m_dirtyRect;
+
+ QPainter painter;
+
+ painter.begin(&m_image);
+ if (m_smoothPainting) {
+ painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
+ }
+
+ QRect clipRect;
+
+ if (m_contentsScale == 1) {
+ qreal scaleX = m_textureSize.width() / (qreal) m_size.width();
+ qreal scaleY = m_textureSize.height() / (qreal) m_size.height();
+ painter.scale(scaleX, scaleY);
+ clipRect = dirtyRect;
+ } else {
+ painter.scale(m_contentsScale, m_contentsScale);
+
+ QRect sclip(qFloor(dirtyRect.x()/m_contentsScale),
+ qFloor(dirtyRect.y()/m_contentsScale),
+ qCeil(dirtyRect.width()/m_contentsScale+dirtyRect.x()/m_contentsScale-qFloor(dirtyRect.x()/m_contentsScale)),
+ qCeil(dirtyRect.height()/m_contentsScale+dirtyRect.y()/m_contentsScale-qFloor(dirtyRect.y()/m_contentsScale)));
+
+ clipRect = sclip;
+ }
+
+ if (!m_dirtyRect.isNull())
+ painter.setClipRect(clipRect);
+
+ painter.setCompositionMode(QPainter::CompositionMode_Source);
+ painter.fillRect(clipRect, m_fillColor);
+ painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
+
+ m_item->paint(&painter);
+ painter.end();
+
+ m_dirtyRect = QRect();
+
+ if (m_texture)
+ delete m_texture;
+
+ uint textureFlags = m_opaquePainting ? 0 : QSGRenderContext::CreateTexture_Alpha;
+ m_texture = new QSGOpenVGTexture(m_image, textureFlags);
+}
+
+QT_END_NAMESPACE
+
+
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgpainternode.h b/src/plugins/scenegraph/openvg/qsgopenvgpainternode.h
new file mode 100644
index 0000000000..1fe992115f
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgpainternode.h
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGOPENVGPAINTERNODE_H
+#define QSGOPENVGPAINTERNODE_H
+
+#include <private/qsgadaptationlayer_p.h>
+#include <QtQuick/QQuickPaintedItem>
+#include "qsgopenvgrenderable.h"
+
+QT_BEGIN_NAMESPACE
+
+class QSGOpenVGTexture;
+
+class QSGOpenVGPainterNode : public QSGPainterNode, public QSGOpenVGRenderable
+{
+public:
+ QSGOpenVGPainterNode(QQuickPaintedItem *item);
+ ~QSGOpenVGPainterNode();
+
+ void setPreferredRenderTarget(QQuickPaintedItem::RenderTarget target) override;
+ void setSize(const QSize &size) override;
+ void setDirty(const QRect &dirtyRect) override;
+ void setOpaquePainting(bool opaque) override;
+ void setLinearFiltering(bool linearFiltering) override;
+ void setMipmapping(bool mipmapping) override;
+ void setSmoothPainting(bool s) override;
+ void setFillColor(const QColor &c) override;
+ void setContentsScale(qreal s) override;
+ void setFastFBOResizing(bool dynamic) override;
+ void setTextureSize(const QSize &size) override;
+ QImage toImage() const override;
+ void update() override;
+ QSGTexture *texture() const override;
+
+ void render() override;
+ void paint();
+
+private:
+ QQuickPaintedItem::RenderTarget m_preferredRenderTarget;
+
+ QQuickPaintedItem *m_item;
+ QSGOpenVGTexture *m_texture;
+ QImage m_image;
+
+ QSize m_size;
+ bool m_dirtyContents;
+ QRect m_dirtyRect;
+ bool m_opaquePainting;
+ bool m_linear_filtering;
+ bool m_smoothPainting;
+ QColor m_fillColor;
+ qreal m_contentsScale;
+ QSize m_textureSize;
+
+ bool m_dirtyGeometry;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGOPENVGPAINTERNODE_H
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.cpp b/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.cpp
new file mode 100644
index 0000000000..1afc5ea7ca
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.cpp
@@ -0,0 +1,325 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgopenvgpublicnodes.h"
+#include "qsgopenvghelpers.h"
+
+QT_BEGIN_NAMESPACE
+
+QSGOpenVGRectangleNode::QSGOpenVGRectangleNode()
+{
+ // Set Dummy material and geometry to avoid asserts
+ setMaterial((QSGMaterial*)1);
+ setGeometry((QSGGeometry*)1);
+
+ m_rectPath = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
+ VG_PATH_CAPABILITY_APPEND_TO);
+ m_rectPaint = vgCreatePaint();
+}
+
+QSGOpenVGRectangleNode::~QSGOpenVGRectangleNode()
+{
+ vgDestroyPaint(m_rectPaint);
+ vgDestroyPath(m_rectPath);
+}
+
+void QSGOpenVGRectangleNode::setRect(const QRectF &rect)
+{
+ m_rect = rect;
+ m_pathDirty = true;
+ markDirty(DirtyMaterial);
+}
+
+void QSGOpenVGRectangleNode::setColor(const QColor &color)
+{
+ m_color = color;
+ m_paintDirty = true;
+ markDirty(DirtyMaterial);
+}
+
+void QSGOpenVGRectangleNode::setTransform(const QOpenVGMatrix &transform)
+{
+ // if there transform matrix is not affine, regenerate the path
+ if (transform.isAffine())
+ m_pathDirty = true;
+ markDirty(DirtyGeometry);
+
+ QSGOpenVGRenderable::setTransform(transform);
+}
+
+void QSGOpenVGRectangleNode::render()
+{
+ // Set Transform
+ if (transform().isAffine()) {
+ // Use current transform matrix
+ vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
+ vgLoadMatrix(transform().constData());
+ } else {
+ // map the path's to handle the perspective matrix
+ vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
+ vgLoadIdentity();
+ }
+
+ if (m_pathDirty) {
+ vgClearPath(m_rectPath, VG_PATH_CAPABILITY_APPEND_TO);
+
+ if (transform().isAffine()) {
+ // Create command list
+ static const VGubyte rectCommands[] = {
+ VG_MOVE_TO_ABS,
+ VG_HLINE_TO_REL,
+ VG_VLINE_TO_REL,
+ VG_HLINE_TO_REL,
+ VG_CLOSE_PATH
+ };
+
+ // Create command data
+ QVector<VGfloat> coordinates(5);
+ coordinates[0] = m_rect.x();
+ coordinates[1] = m_rect.y();
+ coordinates[2] = m_rect.width();
+ coordinates[3] = m_rect.height();
+ coordinates[4] = -m_rect.width();
+
+ vgAppendPathData(m_rectPath, 5, rectCommands, coordinates.constData());
+
+ } else {
+ // Pre-transform path
+ static const VGubyte rectCommands[] = {
+ VG_MOVE_TO_ABS,
+ VG_LINE_TO_ABS,
+ VG_LINE_TO_ABS,
+ VG_LINE_TO_ABS,
+ VG_CLOSE_PATH
+ };
+
+ QVector<VGfloat> coordinates(8);
+ const QPointF topLeft = transform().map(m_rect.topLeft());
+ const QPointF topRight = transform().map(m_rect.topRight());
+ const QPointF bottomLeft = transform().map(m_rect.bottomLeft());
+ const QPointF bottomRight = transform().map(m_rect.bottomRight());
+ coordinates[0] = bottomLeft.x();
+ coordinates[1] = bottomLeft.y();
+ coordinates[2] = bottomRight.x();
+ coordinates[3] = bottomRight.y();
+ coordinates[4] = topRight.x();
+ coordinates[5] = topRight.y();
+ coordinates[6] = topLeft.x();
+ coordinates[7] = topLeft.y();
+
+ vgAppendPathData(m_rectPath, 5, rectCommands, coordinates.constData());
+ }
+
+ m_pathDirty = false;
+ }
+
+ if (m_paintDirty) {
+ vgSetPaint(m_rectPaint, VG_FILL_PATH);
+ vgSetParameteri(m_rectPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
+ vgSetParameterfv(m_rectPaint, VG_PAINT_COLOR, 4, QSGOpenVGHelpers::qColorToVGColor(m_color).constData());
+
+ m_paintDirty = false;
+ }
+
+ vgSetPaint(m_rectPaint, VG_FILL_PATH);
+ vgDrawPath(m_rectPath, VG_FILL_PATH);
+
+}
+
+QSGOpenVGImageNode::QSGOpenVGImageNode()
+{
+ // Set Dummy material and geometry to avoid asserts
+ setMaterial((QSGMaterial*)1);
+ setGeometry((QSGGeometry*)1);
+
+}
+
+QSGOpenVGImageNode::~QSGOpenVGImageNode()
+{
+ if (m_owns) {
+ m_texture->deleteLater();
+ }
+}
+
+void QSGOpenVGImageNode::setTexture(QSGTexture *texture)
+{
+ m_texture = texture;
+ markDirty(DirtyMaterial);
+}
+
+void QSGOpenVGImageNode::setTextureCoordinatesTransform(QSGImageNode::TextureCoordinatesTransformMode transformNode)
+{
+ if (m_transformMode == transformNode)
+ return;
+ m_transformMode = transformNode;
+ markDirty(DirtyGeometry);
+}
+
+void QSGOpenVGImageNode::render()
+{
+ if (!m_texture) {
+ return;
+ }
+
+ // Set Draw Mode
+ if (opacity() < 1.0) {
+ //Transparent
+ vgSetPaint(opacityPaint(), VG_FILL_PATH);
+ vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY);
+ } else {
+ vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL);
+ }
+
+ // Set Transform
+ vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
+ vgLoadMatrix(transform().constData());
+
+ VGImage image = static_cast<VGImage>(m_texture->textureId());
+
+ //Apply the TextureCoordinateTransform Flag
+ if (m_transformMode != QSGImageNode::NoTransform) {
+ float translateX = 0.0f;
+ float translateY = 0.0f;
+ float scaleX = 1.0f;
+ float scaleY = 1.0f;
+
+ if (m_transformMode & QSGImageNode::MirrorHorizontally) {
+ translateX = m_rect.width();
+ scaleX = -1.0;
+ }
+
+ if (m_transformMode & QSGImageNode::MirrorVertically) {
+ translateY = m_rect.height();
+ scaleY = -1.0;
+ }
+
+ vgTranslate(translateX, translateY);
+ vgScale(scaleX, scaleY);
+ }
+
+ // If the the source rect is the same as the target rect
+ if (m_sourceRect == m_rect) {
+ vgDrawImage(image);
+ } else {
+ // Scale
+ float scaleX = m_rect.width() / m_sourceRect.width();
+ float scaleY = m_rect.height() / m_sourceRect.height();
+ vgScale(scaleX, scaleY);
+ VGImage subImage = vgChildImage(image, m_sourceRect.x(), m_sourceRect.y(), m_sourceRect.width(), m_sourceRect.height());
+ vgDrawImage(subImage);
+ vgDestroyImage(subImage);
+ }
+
+}
+
+QSGOpenVGNinePatchNode::QSGOpenVGNinePatchNode()
+{
+ // Set Dummy material and geometry to avoid asserts
+ setMaterial((QSGMaterial*)1);
+ setGeometry((QSGGeometry*)1);
+
+}
+
+void QSGOpenVGNinePatchNode::setTexture(QSGTexture *texture)
+{
+ m_texture = texture;
+ markDirty(DirtyMaterial);
+}
+
+void QSGOpenVGNinePatchNode::setBounds(const QRectF &bounds)
+{
+ if (m_bounds == bounds)
+ return;
+ m_bounds = bounds;
+ markDirty(DirtyGeometry);
+}
+
+void QSGOpenVGNinePatchNode::setDevicePixelRatio(qreal ratio)
+{
+ if (m_pixelRatio == ratio)
+ return;
+ m_pixelRatio = ratio;
+ markDirty(DirtyGeometry);
+}
+
+void QSGOpenVGNinePatchNode::setPadding(qreal left, qreal top, qreal right, qreal bottom)
+{
+ QMarginsF margins(left, top, right, bottom);
+ if (m_margins == margins)
+ return;
+ m_margins = margins;
+ markDirty(DirtyGeometry);
+}
+
+void QSGOpenVGNinePatchNode::update()
+{
+
+}
+
+void QSGOpenVGNinePatchNode::render()
+{
+ if (!m_texture)
+ return;
+
+ // Set Draw Mode
+ if (opacity() < 1.0) {
+ //Transparent
+ vgSetPaint(opacityPaint(), VG_FILL_PATH);
+ vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY);
+ } else {
+ vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL);
+ }
+
+ // Set Transform
+ vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
+ vgLoadMatrix(transform().constData());
+
+ VGImage image = static_cast<VGImage>(m_texture->textureId());
+
+ //Draw borderImage
+ QSGOpenVGHelpers::qDrawBorderImage(image, m_texture->textureSize(), m_bounds, m_bounds.marginsRemoved(m_margins), QRectF(0, 0, 1, 1));
+}
+
+QRectF QSGOpenVGNinePatchNode::bounds() const
+{
+ return m_bounds;
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.h b/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.h
new file mode 100644
index 0000000000..34c8e50615
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.h
@@ -0,0 +1,145 @@
+#ifndef QSGOPENVGPUBLICNODES_H
+#define QSGOPENVGPUBLICNODES_H
+
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQuick/qsgrectanglenode.h>
+#include <QtQuick/qsgimagenode.h>
+#include <QtQuick/qsgninepatchnode.h>
+
+#include <QtGui/QPixmap>
+
+#include <VG/openvg.h>
+
+#include "qsgopenvgrenderable.h"
+
+QT_BEGIN_NAMESPACE
+
+class QSGOpenVGRectangleNode : public QSGRectangleNode, public QSGOpenVGRenderable
+{
+public:
+ QSGOpenVGRectangleNode();
+ ~QSGOpenVGRectangleNode();
+
+ void setRect(const QRectF &rect) override;
+ QRectF rect() const override { return m_rect; }
+
+ void setColor(const QColor &color) override;
+ QColor color() const override { return m_color; }
+
+ void setTransform(const QOpenVGMatrix &transform) override;
+
+ void render() override;
+
+private:
+ QRectF m_rect;
+ QColor m_color;
+
+
+ bool m_pathDirty = true;
+ bool m_paintDirty = true;
+
+ VGPath m_rectPath;
+ VGPaint m_rectPaint;
+};
+
+class QSGOpenVGImageNode : public QSGImageNode, public QSGOpenVGRenderable
+{
+public:
+ QSGOpenVGImageNode();
+ ~QSGOpenVGImageNode();
+
+ void setRect(const QRectF &rect) override { m_rect = rect; markDirty(DirtyMaterial); }
+ QRectF rect() const override { return m_rect; }
+
+ void setSourceRect(const QRectF &r) override { m_sourceRect = r; }
+ QRectF sourceRect() const override { return m_sourceRect; }
+
+ void setTexture(QSGTexture *texture) override;
+ QSGTexture *texture() const override { return m_texture; }
+
+ void setFiltering(QSGTexture::Filtering filtering) override { m_filtering = filtering; markDirty(DirtyMaterial); }
+ QSGTexture::Filtering filtering() const override { return m_filtering; }
+
+ void setMipmapFiltering(QSGTexture::Filtering) override { }
+ QSGTexture::Filtering mipmapFiltering() const override { return QSGTexture::None; }
+
+ void setTextureCoordinatesTransform(TextureCoordinatesTransformMode transformNode) override;
+ TextureCoordinatesTransformMode textureCoordinatesTransform() const override { return m_transformMode; }
+
+ void setOwnsTexture(bool owns) override { m_owns = owns; }
+ bool ownsTexture() const override { return m_owns; }
+
+ void render() override;
+
+private:
+ QSGTexture *m_texture;
+ QRectF m_rect;
+ QRectF m_sourceRect;
+ bool m_owns;
+ QSGTexture::Filtering m_filtering;
+ TextureCoordinatesTransformMode m_transformMode;
+};
+
+class QSGOpenVGNinePatchNode : public QSGNinePatchNode, public QSGOpenVGRenderable
+{
+public:
+ QSGOpenVGNinePatchNode();
+
+ void setTexture(QSGTexture *texture) override;
+ void setBounds(const QRectF &bounds) override;
+ void setDevicePixelRatio(qreal ratio) override;
+ void setPadding(qreal left, qreal top, qreal right, qreal bottom) override;
+ void update() override;
+
+ void render() override;
+
+ QRectF bounds() const;
+
+private:
+ QSGTexture *m_texture;
+ QRectF m_bounds;
+ qreal m_pixelRatio;
+ QMarginsF m_margins;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGOPENVGPUBLICNODES_H
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgrenderable.cpp b/src/plugins/scenegraph/openvg/qsgopenvgrenderable.cpp
new file mode 100644
index 0000000000..97d0be99c8
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgrenderable.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgopenvgrenderable.h"
+
+QT_BEGIN_NAMESPACE
+
+QSGOpenVGRenderable::QSGOpenVGRenderable()
+ : m_opacity(1.0f)
+{
+ m_opacityPaint = vgCreatePaint();
+}
+
+QSGOpenVGRenderable::~QSGOpenVGRenderable()
+{
+ vgDestroyPaint(m_opacityPaint);
+}
+
+void QSGOpenVGRenderable::setOpacity(float opacity)
+{
+ if (m_opacity == opacity)
+ return;
+
+ m_opacity = opacity;
+ VGfloat values[] = {
+ 1.0f, 1.0f, 1.0f, m_opacity
+ };
+ vgSetParameterfv(m_opacityPaint, VG_PAINT_COLOR, 4, values);
+}
+
+float QSGOpenVGRenderable::opacity() const
+{
+ return m_opacity;
+}
+
+VGPaint QSGOpenVGRenderable::opacityPaint() const
+{
+ return m_opacityPaint;
+}
+
+void QSGOpenVGRenderable::setTransform(const QOpenVGMatrix &transform)
+{
+ m_transform = transform;
+}
+
+const QOpenVGMatrix &QSGOpenVGRenderable::transform() const
+{
+ return m_transform;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgrenderable.h b/src/plugins/scenegraph/openvg/qsgopenvgrenderable.h
new file mode 100644
index 0000000000..a544ae743e
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgrenderable.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGOPENVGRENDERABLE_H
+#define QSGOPENVGRENDERABLE_H
+
+#include <QtGlobal>
+
+#include <VG/openvg.h>
+
+#include "qopenvgmatrix.h"
+
+QT_BEGIN_NAMESPACE
+
+class QSGOpenVGRenderable
+{
+public:
+ QSGOpenVGRenderable();
+ virtual ~QSGOpenVGRenderable();
+
+ virtual void render() = 0;
+
+ virtual void setOpacity(float opacity);
+ float opacity() const;
+ VGPaint opacityPaint() const;
+
+ virtual void setTransform(const QOpenVGMatrix &transform);
+ const QOpenVGMatrix &transform() const;
+
+private:
+ float m_opacity;
+ VGPaint m_opacityPaint;
+ QOpenVGMatrix m_transform;
+
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGOPENVGRENDERABLE_H
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgrenderer.cpp b/src/plugins/scenegraph/openvg/qsgopenvgrenderer.cpp
new file mode 100644
index 0000000000..acd4cf88dc
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgrenderer.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgopenvgrenderer_p.h"
+#include "qsgopenvgcontext_p.h"
+#include "qsgopenvgnodevisitor.h"
+#include "qopenvgcontext_p.h"
+#include "qsgopenvghelpers.h"
+
+#include <QtGui/QWindow>
+
+#include <VG/openvg.h>
+
+QT_BEGIN_NAMESPACE
+
+QSGOpenVGRenderer::QSGOpenVGRenderer(QSGRenderContext *context)
+ : QSGRenderer(context)
+{
+
+}
+
+QSGOpenVGRenderer::~QSGOpenVGRenderer()
+{
+
+}
+
+void QSGOpenVGRenderer::renderScene(uint fboId)
+{
+ Q_UNUSED(fboId)
+ class B : public QSGBindable
+ {
+ public:
+ void bind() const { }
+ } bindable;
+ QSGRenderer::renderScene(bindable);
+}
+
+void QSGOpenVGRenderer::render()
+{
+ //Clear the window geometry with the clear color
+ vgSetfv(VG_CLEAR_COLOR, 4, QSGOpenVGHelpers::qColorToVGColor(clearColor()).constData());
+ vgClear(0, 0, VG_MAXINT, VG_MAXINT);
+
+ // Visit each node to render scene
+ QSGOpenVGNodeVisitor rendererVisitor;
+ rendererVisitor.visitChildren(rootNode());
+}
+
+void QSGOpenVGRenderer::nodeChanged(QSGNode *node, QSGNode::DirtyState state)
+{
+ QSGRenderer::nodeChanged(node, state);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgrenderer_p.h b/src/plugins/scenegraph/openvg/qsgopenvgrenderer_p.h
new file mode 100644
index 0000000000..24cabd1b89
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgrenderer_p.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGOPENVGRENDERER_H
+#define QSGOPENVGRENDERER_H
+
+#include <private/qsgrenderer_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QSGOpenVGRenderer : public QSGRenderer
+{
+public:
+ QSGOpenVGRenderer(QSGRenderContext *context);
+ virtual ~QSGOpenVGRenderer();
+
+ void nodeChanged(QSGNode *node, QSGNode::DirtyState state) override;
+
+ void renderScene(uint fboId = 0) final;
+ void render() final;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGOPENVGRENDERER_H
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgrenderloop.cpp b/src/plugins/scenegraph/openvg/qsgopenvgrenderloop.cpp
new file mode 100644
index 0000000000..290ee8028c
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgrenderloop.cpp
@@ -0,0 +1,257 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgopenvgrenderloop_p.h"
+#include "qsgopenvgcontext_p.h"
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QElapsedTimer>
+
+#include <private/qquickwindow_p.h>
+#include <private/qquickprofiler_p.h>
+
+#include "qopenvgcontext_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QSGOpenVGRenderLoop::QSGOpenVGRenderLoop()
+ : vg(nullptr)
+{
+ sg = QSGContext::createDefaultContext();
+ rc = sg->createRenderContext();
+}
+
+QSGOpenVGRenderLoop::~QSGOpenVGRenderLoop()
+{
+ delete rc;
+ delete sg;
+}
+
+void QSGOpenVGRenderLoop::show(QQuickWindow *window)
+{
+ WindowData data;
+ data.updatePending = false;
+ data.grabOnly = false;
+ m_windows[window] = data;
+
+ maybeUpdate(window);
+}
+
+void QSGOpenVGRenderLoop::hide(QQuickWindow *window)
+{
+ QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window);
+ cd->fireAboutToStop();
+}
+
+void QSGOpenVGRenderLoop::windowDestroyed(QQuickWindow *window)
+{
+ m_windows.remove(window);
+ hide(window);
+
+ QQuickWindowPrivate *d = QQuickWindowPrivate::get(window);
+ d->cleanupNodesOnShutdown();
+
+ if (m_windows.size() == 0) {
+ rc->invalidate();
+ delete vg;
+ vg = nullptr;
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ } else if (vg && window == vg->window()) {
+ vg->doneCurrent();
+ }
+}
+
+void QSGOpenVGRenderLoop::exposureChanged(QQuickWindow *window)
+{
+ if (window->isExposed()) {
+ m_windows[window].updatePending = true;
+ renderWindow(window);
+ }
+}
+
+QImage QSGOpenVGRenderLoop::grab(QQuickWindow *window)
+{
+ if (!m_windows.contains(window))
+ return QImage();
+
+ m_windows[window].grabOnly = true;
+
+ renderWindow(window);
+
+ QImage grabbed = grabContent;
+ grabContent = QImage();
+ return grabbed;
+}
+
+void QSGOpenVGRenderLoop::update(QQuickWindow *window)
+{
+ maybeUpdate(window);
+}
+
+void QSGOpenVGRenderLoop::handleUpdateRequest(QQuickWindow *window)
+{
+ renderWindow(window);
+}
+
+void QSGOpenVGRenderLoop::maybeUpdate(QQuickWindow *window)
+{
+ if (!m_windows.contains(window))
+ return;
+
+ m_windows[window].updatePending = true;
+ window->requestUpdate();
+}
+
+QAnimationDriver *QSGOpenVGRenderLoop::animationDriver() const
+{
+ return nullptr;
+}
+
+QSGContext *QSGOpenVGRenderLoop::sceneGraphContext() const
+{
+ return sg;
+}
+
+QSGRenderContext *QSGOpenVGRenderLoop::createRenderContext(QSGContext *) const
+{
+ return rc;
+}
+
+void QSGOpenVGRenderLoop::releaseResources(QQuickWindow *window)
+{
+ Q_UNUSED(window)
+}
+
+QSurface::SurfaceType QSGOpenVGRenderLoop::windowSurfaceType() const
+{
+ return QSurface::OpenVGSurface;
+}
+
+void QSGOpenVGRenderLoop::renderWindow(QQuickWindow *window)
+{
+ QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window);
+ if (!cd->isRenderable() || !m_windows.contains(window))
+ return;
+
+ WindowData &data = const_cast<WindowData &>(m_windows[window]);
+
+ if (vg == nullptr) {
+ vg = new QOpenVGContext(window);
+ vg->makeCurrent();
+ cd->context->initialize(vg);
+ } else {
+ vg->makeCurrent();
+ }
+
+ bool alsoSwap = data.updatePending;
+ data.updatePending = false;
+
+ if (!data.grabOnly) {
+ // Event delivery/processing triggered the window to be deleted or stop rendering.
+ if (!m_windows.contains(window))
+ return;
+ }
+ QElapsedTimer renderTimer;
+ qint64 renderTime = 0, syncTime = 0, polishTime = 0;
+ bool profileFrames = QSG_OPENVG_LOG_TIME_RENDERLOOP().isDebugEnabled();
+ if (profileFrames)
+ renderTimer.start();
+ Q_QUICK_SG_PROFILE_START(QQuickProfiler::SceneGraphPolishFrame);
+
+ cd->polishItems();
+
+ if (profileFrames)
+ polishTime = renderTimer.nsecsElapsed();
+ Q_QUICK_SG_PROFILE_SWITCH(QQuickProfiler::SceneGraphPolishFrame,
+ QQuickProfiler::SceneGraphRenderLoopFrame);
+
+ emit window->afterAnimating();
+
+ cd->syncSceneGraph();
+
+ if (profileFrames)
+ syncTime = renderTimer.nsecsElapsed();
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame);
+
+ // setup coordinate system for window
+ vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
+ vgLoadIdentity();
+ vgTranslate(0.0f, window->size().height());
+ vgScale(1.0, -1.0);
+
+ cd->renderSceneGraph(window->size());
+
+ if (profileFrames)
+ renderTime = renderTimer.nsecsElapsed();
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame);
+
+ if (data.grabOnly) {
+ grabContent = vg->readFramebuffer(window->size() * window->effectiveDevicePixelRatio());
+ data.grabOnly = false;
+ }
+
+ if (alsoSwap && window->isVisible()) {
+ vg->swapBuffers();
+ cd->fireFrameSwapped();
+ }
+
+ qint64 swapTime = 0;
+ if (profileFrames)
+ swapTime = renderTimer.nsecsElapsed();
+ Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame);
+
+ if (QSG_OPENVG_LOG_TIME_RENDERLOOP().isDebugEnabled()) {
+ static QTime lastFrameTime = QTime::currentTime();
+ qCDebug(QSG_OPENVG_LOG_TIME_RENDERLOOP,
+ "Frame rendered with 'basic' renderloop in %dms, polish=%d, sync=%d, render=%d, swap=%d, frameDelta=%d",
+ int(swapTime / 1000000),
+ int(polishTime / 1000000),
+ int((syncTime - polishTime) / 1000000),
+ int((renderTime - syncTime) / 1000000),
+ int((swapTime - renderTime) / 10000000),
+ int(lastFrameTime.msecsTo(QTime::currentTime())));
+ lastFrameTime = QTime::currentTime();
+ }
+
+ // Might have been set during syncSceneGraph()
+ if (data.updatePending)
+ maybeUpdate(window);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgrenderloop_p.h b/src/plugins/scenegraph/openvg/qsgopenvgrenderloop_p.h
new file mode 100644
index 0000000000..f35b689e00
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgrenderloop_p.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGOPENVGRENDERLOOP_H
+#define QSGOPENVGRENDERLOOP_H
+
+#include <private/qsgrenderloop_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QOpenVGContext;
+
+class QSGOpenVGRenderLoop : public QSGRenderLoop
+{
+public:
+ QSGOpenVGRenderLoop();
+ ~QSGOpenVGRenderLoop();
+
+
+ void show(QQuickWindow *window) override;
+ void hide(QQuickWindow *window) override;
+
+ void windowDestroyed(QQuickWindow *window) override;
+
+ void renderWindow(QQuickWindow *window);
+ void exposureChanged(QQuickWindow *window) override;
+ QImage grab(QQuickWindow *window) override;
+
+ void maybeUpdate(QQuickWindow *window) override;
+ void update(QQuickWindow *window) override;
+ void handleUpdateRequest(QQuickWindow *window) override;
+
+ void releaseResources(QQuickWindow *) override;
+
+ QSurface::SurfaceType windowSurfaceType() const override;
+
+ QAnimationDriver *animationDriver() const override;
+
+ QSGContext *sceneGraphContext() const override;
+ QSGRenderContext *createRenderContext(QSGContext *) const override;
+
+ struct WindowData {
+ bool updatePending : 1;
+ bool grabOnly : 1;
+ };
+
+ QHash<QQuickWindow *, WindowData> m_windows;
+
+ QSGContext *sg;
+ QSGRenderContext *rc;
+ QOpenVGContext *vg;
+
+ QImage grabContent;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGOPENVGRENDERLOOP_H
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgspritenode.cpp b/src/plugins/scenegraph/openvg/qsgopenvgspritenode.cpp
new file mode 100644
index 0000000000..fb24df7471
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgspritenode.cpp
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgopenvgspritenode.h"
+#include "qsgopenvgtexture.h"
+
+QT_BEGIN_NAMESPACE
+
+QSGOpenVGSpriteNode::QSGOpenVGSpriteNode()
+ : m_time(0.0f)
+{
+ // Set Dummy material and geometry to avoid asserts
+ setMaterial((QSGMaterial*)1);
+ setGeometry((QSGGeometry*)1);
+}
+
+QSGOpenVGSpriteNode::~QSGOpenVGSpriteNode()
+{
+
+}
+
+void QSGOpenVGSpriteNode::setTexture(QSGTexture *texture)
+{
+ m_texture = static_cast<QSGOpenVGTexture*>(texture);
+ markDirty(DirtyMaterial);
+}
+
+void QSGOpenVGSpriteNode::setTime(float time)
+{
+ if (m_time != time) {
+ m_time = time;
+ markDirty(DirtyMaterial);
+ }
+}
+
+void QSGOpenVGSpriteNode::setSourceA(const QPoint &source)
+{
+ if (m_sourceA != source) {
+ m_sourceA = source;
+ markDirty(DirtyMaterial);
+ }
+}
+
+void QSGOpenVGSpriteNode::setSourceB(const QPoint &source)
+{
+ if (m_sourceB != source) {
+ m_sourceB = source;
+ markDirty(DirtyMaterial);
+ }
+}
+
+void QSGOpenVGSpriteNode::setSpriteSize(const QSize &size)
+{
+ if (m_spriteSize != size) {
+ m_spriteSize = size;
+ markDirty(DirtyMaterial);
+ }
+}
+
+void QSGOpenVGSpriteNode::setSheetSize(const QSize &size)
+{
+ if (m_sheetSize != size) {
+ m_sheetSize = size;
+ markDirty(DirtyMaterial);
+ }
+}
+
+void QSGOpenVGSpriteNode::setSize(const QSizeF &size)
+{
+ if (m_size != size) {
+ m_size = size;
+ markDirty(DirtyGeometry);
+ }
+}
+
+void QSGOpenVGSpriteNode::setFiltering(QSGTexture::Filtering)
+{
+}
+
+void QSGOpenVGSpriteNode::update()
+{
+}
+
+void QSGOpenVGSpriteNode::render()
+{
+ if (!m_texture)
+ return;
+
+ VGImage image = static_cast<VGImage>(m_texture->textureId());
+
+ QRectF sourceRect(m_sourceA, m_spriteSize);
+ QRectF targetRect(0, 0, m_size.width(), m_size.height());
+
+ VGImage sourceImage = vgChildImage(image, sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height());
+
+ // Set Draw Mode
+ if (opacity() < 1.0) {
+ //Transparent
+ vgSetPaint(opacityPaint(), VG_FILL_PATH);
+ vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY);
+ } else {
+ vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL);
+ }
+
+ // Set Image Matrix
+ vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
+ vgLoadMatrix(transform().constData());
+
+ if (sourceRect != targetRect) {
+ // Scale
+ float scaleX = targetRect.width() / sourceRect.width();
+ float scaleY = targetRect.height() / sourceRect.height();
+ vgScale(scaleX, scaleY);
+ }
+
+ vgDrawImage(sourceImage);
+
+ vgDestroyImage(sourceImage);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgspritenode.h b/src/plugins/scenegraph/openvg/qsgopenvgspritenode.h
new file mode 100644
index 0000000000..3ade2ef8ad
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgspritenode.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGOPENVGSPRITENODE_H
+#define QSGOPENVGSPRITENODE_H
+
+#include <private/qsgadaptationlayer_p.h>
+#include "qsgopenvgrenderable.h"
+
+QT_BEGIN_NAMESPACE
+class QSGOpenVGTexture;
+class QSGOpenVGSpriteNode : public QSGSpriteNode, public QSGOpenVGRenderable
+{
+public:
+ QSGOpenVGSpriteNode();
+ ~QSGOpenVGSpriteNode();
+
+ void setTexture(QSGTexture *texture) override;
+ void setTime(float time) override;
+ void setSourceA(const QPoint &source) override;
+ void setSourceB(const QPoint &source) override;
+ void setSpriteSize(const QSize &size) override;
+ void setSheetSize(const QSize &size) override;
+ void setSize(const QSizeF &size) override;
+ void setFiltering(QSGTexture::Filtering filtering) override;
+ void update() override;
+
+ void render() override;
+
+private:
+ QSGOpenVGTexture *m_texture;
+ float m_time;
+ QPoint m_sourceA;
+ QPoint m_sourceB;
+ QSize m_spriteSize;
+ QSize m_sheetSize;
+ QSizeF m_size;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGOPENVGSPRITENODE_H
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgtexture.cpp b/src/plugins/scenegraph/openvg/qsgopenvgtexture.cpp
new file mode 100644
index 0000000000..dd2fdc7020
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgtexture.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgopenvgtexture.h"
+#include "qsgopenvghelpers.h"
+
+QT_BEGIN_NAMESPACE
+
+QSGOpenVGTexture::QSGOpenVGTexture(const QImage &image, uint flags)
+{
+ Q_UNUSED(flags)
+
+ VGImageFormat format = QSGOpenVGHelpers::qImageFormatToVGImageFormat(image.format());
+ m_image = vgCreateImage(format, image.width(), image.height(), VG_IMAGE_QUALITY_BETTER);
+
+ // Do Texture Upload
+ vgImageSubData(m_image, image.constBits(), image.bytesPerLine(), format, 0, 0, image.width(), image.height());
+}
+
+QSGOpenVGTexture::~QSGOpenVGTexture()
+{
+ vgDestroyImage(m_image);
+}
+
+int QSGOpenVGTexture::textureId() const
+{
+ return static_cast<int>(m_image);
+}
+
+QSize QSGOpenVGTexture::textureSize() const
+{
+ VGint imageWidth = vgGetParameteri(m_image, VG_IMAGE_WIDTH);
+ VGint imageHeight = vgGetParameteri(m_image, VG_IMAGE_HEIGHT);
+ return QSize(imageWidth, imageHeight);
+}
+
+bool QSGOpenVGTexture::hasAlphaChannel() const
+{
+ VGImageFormat format = static_cast<VGImageFormat>(vgGetParameteri(m_image, VG_IMAGE_FORMAT));
+
+ switch (format) {
+ case VG_sRGBA_8888:
+ case VG_sRGBA_8888_PRE:
+ case VG_sRGBA_5551:
+ case VG_sRGBA_4444:
+ case VG_lRGBA_8888:
+ case VG_lRGBA_8888_PRE:
+ case VG_A_8:
+ case VG_A_1:
+ case VG_A_4:
+ case VG_sARGB_8888:
+ case VG_sARGB_8888_PRE:
+ case VG_sARGB_1555:
+ case VG_sARGB_4444:
+ case VG_lARGB_8888:
+ case VG_lARGB_8888_PRE:
+ case VG_sBGRA_8888:
+ case VG_sBGRA_8888_PRE:
+ case VG_sBGRA_5551:
+ case VG_sBGRA_4444:
+ case VG_lBGRA_8888:
+ case VG_lBGRA_8888_PRE:
+ case VG_sABGR_8888:
+ case VG_sABGR_8888_PRE:
+ case VG_sABGR_1555:
+ case VG_sABGR_4444:
+ case VG_lABGR_8888:
+ case VG_lABGR_8888_PRE:
+ return true;
+ break;
+ default:
+ break;
+ }
+ return false;
+}
+
+bool QSGOpenVGTexture::hasMipmaps() const
+{
+ return false;
+}
+
+void QSGOpenVGTexture::bind()
+{
+ // No need to bind
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/scenegraph/openvg/qsgopenvgtexture.h b/src/plugins/scenegraph/openvg/qsgopenvgtexture.h
new file mode 100644
index 0000000000..523c9e690d
--- /dev/null
+++ b/src/plugins/scenegraph/openvg/qsgopenvgtexture.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGOPENVGTEXTURE_H
+#define QSGOPENVGTEXTURE_H
+
+#include <private/qsgtexture_p.h>
+
+#include <VG/openvg.h>
+
+QT_BEGIN_NAMESPACE
+
+class QSGOpenVGTexture : public QSGTexture
+{
+public:
+ QSGOpenVGTexture(const QImage &image, uint flags);
+ ~QSGOpenVGTexture();
+
+ int textureId() const override;
+ QSize textureSize() const override;
+ bool hasAlphaChannel() const override;
+ bool hasMipmaps() const override;
+ void bind() override;
+
+private:
+ VGImage m_image;;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGOPENVGTEXTURE_H
diff --git a/src/plugins/scenegraph/scenegraph.pro b/src/plugins/scenegraph/scenegraph.pro
index a90e8d4814..39c0c0815c 100644
--- a/src/plugins/scenegraph/scenegraph.pro
+++ b/src/plugins/scenegraph/scenegraph.pro
@@ -1,3 +1,5 @@
TEMPLATE = subdirs
QT_FOR_CONFIG += quick
qtConfig(d3d12): SUBDIRS += d3d12
+qtConfig(openvg): SUBDIRS += openvg
+
diff --git a/src/qml/animations/qabstractanimationjob_p.h b/src/qml/animations/qabstractanimationjob_p.h
index efc86a5823..95a39b1301 100644
--- a/src/qml/animations/qabstractanimationjob_p.h
+++ b/src/qml/animations/qabstractanimationjob_p.h
@@ -218,11 +218,11 @@ public:
*/
static void updateAnimationTimer();
- void restartAnimationTimer();
- void updateAnimationsTime(qint64 timeStep);
+ void restartAnimationTimer() override;
+ void updateAnimationsTime(qint64 timeStep) override;
//useful for profiling/debugging
- int runningAnimationCount() { return animations.count(); }
+ int runningAnimationCount() override { return animations.count(); }
bool hasStartAnimationPending() const { return startAnimationPending; }
diff --git a/src/qml/animations/qcontinuinganimationgroupjob_p.h b/src/qml/animations/qcontinuinganimationgroupjob_p.h
index f34a118cad..baf4ff1ae5 100644
--- a/src/qml/animations/qcontinuinganimationgroupjob_p.h
+++ b/src/qml/animations/qcontinuinganimationgroupjob_p.h
@@ -62,14 +62,14 @@ public:
QContinuingAnimationGroupJob();
~QContinuingAnimationGroupJob();
- int duration() const { return -1; }
+ int duration() const override { return -1; }
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;
};
QT_END_NAMESPACE
diff --git a/src/qml/animations/qpauseanimationjob_p.h b/src/qml/animations/qpauseanimationjob_p.h
index 2967e1cf60..e228f46daa 100644
--- a/src/qml/animations/qpauseanimationjob_p.h
+++ b/src/qml/animations/qpauseanimationjob_p.h
@@ -62,12 +62,12 @@ public:
explicit QPauseAnimationJob(int duration = 250);
~QPauseAnimationJob();
- int duration() const;
+ int duration() const override;
void setDuration(int msecs);
protected:
- void updateCurrentTime(int);
- void debugAnimation(QDebug d) const;
+ void updateCurrentTime(int) override;
+ void debugAnimation(QDebug d) const override;
private:
//definition
diff --git a/src/qml/animations/qsequentialanimationgroupjob_p.h b/src/qml/animations/qsequentialanimationgroupjob_p.h
index bb481d1322..5fbafcb9ac 100644
--- a/src/qml/animations/qsequentialanimationgroupjob_p.h
+++ b/src/qml/animations/qsequentialanimationgroupjob_p.h
@@ -63,16 +63,16 @@ public:
QSequentialAnimationGroupJob();
~QSequentialAnimationGroupJob();
- int duration() const;
+ int duration() const override;
QAbstractAnimationJob *currentAnimation() const { return m_currentAnimation; }
protected:
- void updateCurrentTime(int);
- 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) 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:
struct AnimationIndex
@@ -91,8 +91,8 @@ private:
void setCurrentAnimation(QAbstractAnimationJob *anim, bool intermediate = false);
void activateCurrentAnimation(bool intermediate = false);
- void animationInserted(QAbstractAnimationJob *anim);
- void animationRemoved(QAbstractAnimationJob *anim,QAbstractAnimationJob*,QAbstractAnimationJob*);
+ void animationInserted(QAbstractAnimationJob *anim) override;
+ void animationRemoved(QAbstractAnimationJob *anim, QAbstractAnimationJob *, QAbstractAnimationJob *) override;
bool atEnd() const;
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index e66e8ccbff..54d0cb4f46 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -758,7 +758,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node)
QQmlJS::AST::UiParameterList *p = node->parameters;
while (p) {
- const QStringRef &memberType = p->type;
+ const QString memberType = asString(p->type);
if (memberType.isEmpty()) {
recordError(node->typeToken, QCoreApplication::translate("QQmlParser","Expected parameter type"));
@@ -781,10 +781,10 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node)
// Must be a QML object type.
// Lazily determine type during compilation.
param->type = QV4::CompiledData::Property::Custom;
- param->customTypeNameIndex = registerString(p->type.toString());
+ param->customTypeNameIndex = registerString(memberType);
} else {
QString errStr = QCoreApplication::translate("QQmlParser","Invalid signal parameter type: ");
- errStr.append(memberType.toString());
+ errStr.append(memberType);
recordError(node->typeToken, errStr);
return false;
}
@@ -813,7 +813,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node)
return false;
}
} else {
- const QStringRef &memberType = node->memberType;
+ QString memberType = asString(node->memberType);
if (memberType == QLatin1String("alias")) {
return appendAlias(node);
} else {
@@ -858,7 +858,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node)
property->flags |= QV4::CompiledData::Property::IsReadOnly;
property->type = type;
if (type >= QV4::CompiledData::Property::Custom)
- property->customTypeNameIndex = registerString(memberType.toString());
+ property->customTypeNameIndex = registerString(memberType);
else
property->customTypeNameIndex = emptyStringIndex;
diff --git a/src/qml/compiler/qqmlpropertycachecreator_p.h b/src/qml/compiler/qqmlpropertycachecreator_p.h
index 10bcd1dbc1..3c14abc019 100644
--- a/src/qml/compiler/qqmlpropertycachecreator_p.h
+++ b/src/qml/compiler/qqmlpropertycachecreator_p.h
@@ -118,7 +118,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObje
bool needVMEMetaObject = obj->propertyCount() != 0 || obj->aliasCount() != 0 || obj->signalCount() != 0 || obj->functionCount() != 0;
if (!needVMEMetaObject) {
- for (auto binding = obj->bindingsBegin(), end = obj->bindingsEnd(); binding != end; ++binding) {
+ auto binding = obj->bindingsBegin();
+ auto end = obj->bindingsEnd();
+ for ( ; binding != end; ++binding) {
if (binding->type == QV4::CompiledData::Binding::Type_Object && (binding->flags & QV4::CompiledData::Binding::IsOnAssignment)) {
// If the on assignment is inside a group property, we need to distinguish between QObject based
// group properties and value type group properties. For the former the base type is derived from
@@ -162,7 +164,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::buildMetaObje
}
if (QQmlPropertyCache *thisCache = propertyCaches->at(objectIndex)) {
- for (auto binding = obj->bindingsBegin(), end = obj->bindingsEnd(); binding != end; ++binding)
+ auto binding = obj->bindingsBegin();
+ auto end = obj->bindingsEnd();
+ for ( ; binding != end; ++binding)
if (binding->type >= QV4::CompiledData::Binding::Type_Object) {
QQmlBindingInstantiationContext context(objectIndex, &(*binding), stringAt(binding->propertyNameIndex), thisCache);
QQmlCompileError error = buildMetaObjectRecursively(binding->value.objectIndex, context);
@@ -296,7 +300,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj
QmlIR::PropertyResolver resolver(baseTypeCache);
- for (auto p = obj->propertiesBegin(), end = obj->propertiesEnd(); p != end; ++p) {
+ auto p = obj->propertiesBegin();
+ auto pend = obj->propertiesEnd();
+ for ( ; p != pend; ++p) {
if (p->type == QV4::CompiledData::Property::Var)
varPropCount++;
@@ -306,7 +312,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj
return QQmlCompileError(p->location, QQmlPropertyCacheCreatorBase::tr("Cannot override FINAL property"));
}
- for (auto a = obj->aliasesBegin(), end = obj->aliasesEnd(); a != end; ++a) {
+ auto a = obj->aliasesBegin();
+ auto aend = obj->aliasesEnd();
+ for ( ; a != aend; ++a) {
bool notInRevision = false;
QQmlPropertyData *d = resolver.property(stringAt(a->nameIndex), &notInRevision);
if (d && d->isFinal())
@@ -340,7 +348,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj
}
// Set up notify signals for properties - first normal, then alias
- for (auto p = obj->propertiesBegin(), end = obj->propertiesEnd(); p != end; ++p) {
+ p = obj->propertiesBegin();
+ pend = obj->propertiesEnd();
+ for ( ; p != pend; ++p) {
auto flags = QQmlPropertyData::defaultSignalFlags();
QString changedSigName = stringAt(p->nameIndex) + QLatin1String("Changed");
@@ -349,7 +359,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj
cache->appendSignal(changedSigName, flags, effectiveMethodIndex++);
}
- for (auto a = obj->aliasesBegin(), end = obj->aliasesEnd(); a != end; ++a) {
+ a = obj->aliasesBegin();
+ aend = obj->aliasesEnd();
+ for ( ; a != aend; ++a) {
auto flags = QQmlPropertyData::defaultSignalFlags();
QString changedSigName = stringAt(a->nameIndex) + QLatin1String("Changed");
@@ -359,7 +371,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj
}
// Dynamic signals
- for (auto s = obj->signalsBegin(), end = obj->signalsEnd(); s != end; ++s) {
+ auto s = obj->signalsBegin();
+ auto send = obj->signalsEnd();
+ for ( ; s != send; ++s) {
const int paramCount = s->parameterCount();
QList<QByteArray> names;
@@ -370,7 +384,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj
paramTypes[0] = paramCount;
int i = 0;
- for (auto param = s->parametersBegin(), end = s->parametersEnd(); param != end; ++param, ++i) {
+ auto param = s->parametersBegin();
+ auto end = s->parametersEnd();
+ for ( ; param != end; ++param, ++i) {
names.append(stringAt(param->nameIndex).toUtf8());
if (param->type < builtinTypeCount) {
// built-in type
@@ -415,7 +431,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj
// Dynamic slots
- for (auto function = objectContainer->objectFunctionsBegin(obj), end = objectContainer->objectFunctionsEnd(obj); function != end; ++function) {
+ auto function = objectContainer->objectFunctionsBegin(obj);
+ auto fend = objectContainer->objectFunctionsEnd(obj);
+ for ( ; function != fend; ++function) {
auto flags = QQmlPropertyData::defaultSlotFlags();
const QString slotName = stringAt(function->nameIndex);
@@ -425,7 +443,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj
// protect against overriding change signals or methods with properties.
QList<QByteArray> parameterNames;
- for (auto formal = function->formalsBegin(), end = function->formalsEnd(); formal != end; ++formal) {
+ auto formal = function->formalsBegin();
+ auto end = function->formalsEnd();
+ for ( ; formal != end; ++formal) {
flags.hasArguments = true;
parameterNames << stringAt(*formal).toUtf8();
}
@@ -437,7 +457,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObj
// Dynamic properties
int effectiveSignalIndex = cache->signalHandlerIndexCacheStart;
int propertyIdx = 0;
- for (auto p = obj->propertiesBegin(), end = obj->propertiesEnd(); p != end; ++p, ++propertyIdx) {
+ p = obj->propertiesBegin();
+ pend = obj->propertiesEnd();
+ for ( ; p != pend; ++p, ++propertyIdx) {
int propertyType = 0;
QQmlPropertyData::Flags propertyFlags;
@@ -561,7 +583,9 @@ inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::appendAliasPropertie
return;
const auto allAliasTargetsExist = [this, &component](const CompiledObject &object) {
- for (auto alias = object.aliasesBegin(), end = object.aliasesEnd(); alias != end; ++alias) {
+ auto alias = object.aliasesBegin();
+ auto end = object.aliasesEnd();
+ for ( ; alias != end; ++alias) {
Q_ASSERT(alias->flags & QV4::CompiledData::Alias::Resolved);
const int targetObjectIndex = objectForId(component, alias->targetObjectId);
@@ -612,7 +636,9 @@ inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::collectObjectsWithAl
if (object.flags & QV4::CompiledData::Object::IsComponent && objectIndex != objectContainer->rootObjectIndex())
return;
- for (auto binding = object.bindingsBegin(), end = object.bindingsEnd(); binding != end; ++binding) {
+ auto binding = object.bindingsBegin();
+ auto end = object.bindingsEnd();
+ for (; binding != end; ++binding) {
if (binding->type != QV4::CompiledData::Binding::Type_Object
&& binding->type != QV4::CompiledData::Binding::Type_AttachedProperty
&& binding->type != QV4::CompiledData::Binding::Type_GroupProperty)
@@ -707,7 +733,9 @@ inline void QQmlPropertyCacheAliasCreator<ObjectContainer>::appendAliasesToPrope
int effectivePropertyIndex = propertyCache->propertyIndexCacheStart + propertyCache->propertyIndexCache.count();
int aliasIndex = 0;
- for (auto alias = object.aliasesBegin(), end = object.aliasesEnd(); alias != end; ++alias, ++aliasIndex) {
+ auto alias = object.aliasesBegin();
+ auto end = object.aliasesEnd();
+ for ( ; alias != end; ++alias, ++aliasIndex) {
Q_ASSERT(alias->flags & QV4::CompiledData::Alias::Resolved);
int type = 0;
diff --git a/src/qml/compiler/qqmlpropertyvalidator.cpp b/src/qml/compiler/qqmlpropertyvalidator.cpp
index 45379d5155..383c20239f 100644
--- a/src/qml/compiler/qqmlpropertyvalidator.cpp
+++ b/src/qml/compiler/qqmlpropertyvalidator.cpp
@@ -412,7 +412,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
}
}
break;
-#ifndef QT_NO_DATESTRING
+#if QT_CONFIG(datestring)
case QVariant::Date: {
bool ok = false;
QQmlStringConverters::dateFromString(binding->valueAsString(qmlUnit), &ok);
@@ -437,7 +437,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
}
}
break;
-#endif // QT_NO_DATESTRING
+#endif // datestring
case QVariant::Point: {
bool ok = false;
QQmlStringConverters::pointFFromString(binding->valueAsString(qmlUnit), &ok);
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp
index 5e05485b93..ab2b0553a9 100644
--- a/src/qml/compiler/qqmltypecompiler.cpp
+++ b/src/qml/compiler/qqmltypecompiler.cpp
@@ -1570,19 +1570,15 @@ bool QQmlJavaScriptBindingExpressionSimplificationPass::simplifyBinding(QV4::IR:
if (!_canSimplify)
return false;
}
- if (!_canSimplify)
- return false;
}
if (_returnValueOfBindingExpression == -1)
return false;
- if (_canSimplify) {
- if (_nameOfFunctionCalled) {
- if (_functionCallReturnValue != _returnValueOfBindingExpression)
- return false;
- return detectTranslationCallAndConvertBinding(binding);
- }
+ if (_nameOfFunctionCalled) {
+ if (_functionCallReturnValue != _returnValueOfBindingExpression)
+ return false;
+ return detectTranslationCallAndConvertBinding(binding);
}
return false;
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp
index e815c41a86..8586c84c3d 100644
--- a/src/qml/compiler/qv4compileddata.cpp
+++ b/src/qml/compiler/qv4compileddata.cpp
@@ -397,7 +397,7 @@ bool CompilationUnit::loadFromDisk(const QUrl &url, EvalISelFactory *iselFactory
return false;
}
- const QString sourcePath = url.toLocalFile();
+ const QString sourcePath = QQmlFile::urlToLocalFileOrQrc(url);
QScopedPointer<CompilationUnitMapper> cacheFile(new CompilationUnitMapper());
CompiledData::Unit *mappedUnit = cacheFile->open(cacheFilePath(url), sourcePath, errorString);
@@ -471,7 +471,7 @@ QString Binding::valueAsString(const Unit *unit) const
return QString::number(valueAsNumber());
case Type_Invalid:
return QString();
-#ifdef QT_NO_TRANSLATION
+#if !QT_CONFIG(translation)
case Type_TranslationById:
case Type_Translation:
return unit->stringAt(stringIndex);
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h
index 90cbe04505..2682365182 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 0x07
+#define QV4_DATA_STRUCTURE_VERSION 0x08
class QIODevice;
class QQmlPropertyCache;
@@ -207,9 +207,9 @@ struct String
struct Function
{
enum Flags : unsigned int {
- HasDirectEval = 0x1,
- UsesArgumentsObject = 0x2,
- IsStrict = 0x4,
+ IsStrict = 0x1,
+ HasDirectEval = 0x2,
+ UsesArgumentsObject = 0x4,
IsNamedExpression = 0x8,
HasCatchOrWith = 0x10
};
@@ -749,7 +749,9 @@ struct TypeReferenceMap : QHash<int, TypeReference>
r.errorWhenNotFound = true;
}
- for (auto prop = obj->propertiesBegin(), propEnd = obj->propertiesEnd(); prop != propEnd; ++prop) {
+ auto prop = obj->propertiesBegin();
+ auto propEnd = obj->propertiesEnd();
+ for ( ; prop != propEnd; ++prop) {
if (prop->type >= QV4::CompiledData::Property::Custom) {
// ### FIXME: We could report the more accurate location here by using prop->location, but the old
// compiler can't and the tests expect it to be the object location right now.
@@ -758,7 +760,9 @@ struct TypeReferenceMap : QHash<int, TypeReference>
}
}
- for (auto binding = obj->bindingsBegin(), bindingEnd = obj->bindingsEnd(); binding != bindingEnd; ++binding) {
+ auto binding = obj->bindingsBegin();
+ auto bindingEnd = obj->bindingsEnd();
+ for ( ; binding != bindingEnd; ++binding) {
if (binding->type == QV4::CompiledData::Binding::Type_AttachedProperty)
this->add(binding->propertyNameIndex, binding->location);
}
diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp
index 4fa0cf421b..943700de44 100644
--- a/src/qml/compiler/qv4ssa.cpp
+++ b/src/qml/compiler/qv4ssa.cpp
@@ -1838,11 +1838,6 @@ public:
return *this;
}
- bool isEmpty() const
- {
- return worklistSize == 0;
- }
-
unsigned size() const
{
return worklistSize;
@@ -1850,7 +1845,7 @@ public:
Stmt *takeNext(Stmt *last)
{
- if (isEmpty())
+ if (worklistSize == 0)
return 0;
const int startAt = last ? last->id() + 1 : 0;
@@ -1866,6 +1861,10 @@ public:
--worklistSize;
Stmt *s = stmts.at(pos);
Q_ASSERT(s);
+
+ if (removed.at(s->id()))
+ return takeNext(s);
+
return s;
}
@@ -2692,6 +2691,7 @@ void convertConst(Const *c, Type targetType)
case UndefinedType:
c->value = qt_qnan();
c->type = targetType;
+ break;
default:
Q_UNIMPLEMENTED();
Q_ASSERT(!"Unimplemented!");
@@ -3991,9 +3991,7 @@ void optimizeSSA(StatementWorklist &W, DefUses &defUses, DominatorTree &df)
ExprReplacer replaceUses(defUses, function);
Stmt *s = 0;
- while (!W.isEmpty()) {
- s = W.takeNext(s);
- Q_ASSERT(s);
+ while ((s = W.takeNext(s))) {
if (Phi *phi = s->asPhi()) {
// dead code elimination:
diff --git a/src/qml/debugger/qqmldebug.cpp b/src/qml/debugger/qqmldebug.cpp
index b2c4b139ee..15230d75a5 100644
--- a/src/qml/debugger/qqmldebug.cpp
+++ b/src/qml/debugger/qqmldebug.cpp
@@ -84,7 +84,19 @@ QStringList QQmlDebuggingEnabler::inspectorServices()
*/
QStringList QQmlDebuggingEnabler::profilerServices()
{
- return QStringList() << QQmlProfilerService::s_key << QQmlEngineControlService::s_key;
+ return QStringList() << QQmlProfilerService::s_key << QQmlEngineControlService::s_key
+ << QDebugMessageService::s_key;
+}
+
+/*!
+ * Retrieves the plugin keys of the debug services designed to be used with a native debugger. The
+ * native debugger will communicate with these services by directly reading and writing the
+ * application's memory.
+ * \return List of plugin keys of debug services designed to be used with a native debugger.
+ */
+QStringList QQmlDebuggingEnabler::nativeDebuggerServices()
+{
+ return QStringList() << QQmlNativeDebugService::s_key;
}
/*!
diff --git a/src/qml/debugger/qqmldebug.h b/src/qml/debugger/qqmldebug.h
index fb41039867..6a0cfdc709 100644
--- a/src/qml/debugger/qqmldebug.h
+++ b/src/qml/debugger/qqmldebug.h
@@ -60,6 +60,7 @@ struct Q_QML_EXPORT QQmlDebuggingEnabler
static QStringList debuggerServices();
static QStringList inspectorServices();
static QStringList profilerServices();
+ static QStringList nativeDebuggerServices();
static void setServices(const QStringList &services);
diff --git a/src/qml/debugger/qqmldebugconnector.cpp b/src/qml/debugger/qqmldebugconnector.cpp
index 029df1e748..8a16d56c45 100644
--- a/src/qml/debugger/qqmldebugconnector.cpp
+++ b/src/qml/debugger/qqmldebugconnector.cpp
@@ -126,6 +126,16 @@ QQmlDebugConnector *QQmlDebugConnector::instance()
params->instance = loadQQmlDebugConnector(params->pluginKey);
} else if (params->arguments.isEmpty()) {
return 0; // no explicit class name given and no command line arguments
+ } else if (params->arguments.startsWith(QLatin1String("connector:"))) {
+ static const int connectorBegin = int(strlen("connector:"));
+
+ int connectorEnd = params->arguments.indexOf(QLatin1Char(','), connectorBegin);
+ if (connectorEnd == -1)
+ connectorEnd = params->arguments.length();
+
+ params->instance = loadQQmlDebugConnector(params->arguments.mid(
+ connectorBegin,
+ connectorEnd - connectorBegin));
} else {
params->instance = loadQQmlDebugConnector(
params->arguments.startsWith(QLatin1String("native")) ?
@@ -154,7 +164,10 @@ QQmlDebugConnectorFactory::~QQmlDebugConnectorFactory()
{
// This is triggered when the plugin is unloaded.
QQmlDebugConnectorParams *params = qmlDebugConnectorParams();
- if (params && params->instance) {
+ if (params) {
+ params->pluginKey.clear();
+ params->arguments.clear();
+ params->services.clear();
delete params->instance;
params->instance = 0;
}
diff --git a/src/qml/debugger/qqmldebugserviceinterfaces_p.h b/src/qml/debugger/qqmldebugserviceinterfaces_p.h
index ca6293c3ec..2fe3a588c3 100644
--- a/src/qml/debugger/qqmldebugserviceinterfaces_p.h
+++ b/src/qml/debugger/qqmldebugserviceinterfaces_p.h
@@ -205,14 +205,14 @@ protected:
class Q_QML_PRIVATE_EXPORT QQmlNativeDebugService : public QQmlDebugService
{
Q_OBJECT
+public:
+ static const QString s_key;
protected:
friend class QQmlDebugConnector;
QQmlNativeDebugService(float version, QObject *parent = 0)
: QQmlDebugService(s_key, version, parent) {}
-
- static const QString s_key;
};
#endif
diff --git a/src/qml/debugger/qqmlmemoryprofiler.cpp b/src/qml/debugger/qqmlmemoryprofiler.cpp
index 53d4e7ab21..b89dbfd02d 100644
--- a/src/qml/debugger/qqmlmemoryprofiler.cpp
+++ b/src/qml/debugger/qqmlmemoryprofiler.cpp
@@ -62,13 +62,13 @@ static qmlmemprofile_pop_location *memprofile_pop_location;
static qmlmemprofile_save *memprofile_save;
static qmlmemprofile_is_enabled *memprofile_is_enabled;
-#ifndef QT_NO_LIBRARY
+#if QT_CONFIG(library)
extern QFunctionPointer qt_linux_find_symbol_sys(const char *symbol);
#endif
bool QQmlMemoryScope::doOpenLibrary()
{
-#if defined(Q_OS_LINUX) && !defined(QT_NO_LIBRARY)
+#if defined(Q_OS_LINUX) && QT_CONFIG(library)
if (state == Unloaded) {
memprofile_stats = (qmlmemprofile_stats *) qt_linux_find_symbol_sys("qmlmemprofile_stats");
memprofile_clear = (qmlmemprofile_clear *) qt_linux_find_symbol_sys("qmlmemprofile_clear");
diff --git a/src/qml/debugger/qqmlprofiler_p.h b/src/qml/debugger/qqmlprofiler_p.h
index 6643695d11..242f26ee0d 100644
--- a/src/qml/debugger/qqmlprofiler_p.h
+++ b/src/qml/debugger/qqmlprofiler_p.h
@@ -204,6 +204,11 @@ public:
ref(new BindingRefCount(binding), QQmlRefPointer<QQmlRefCount>::Adopt), sent(false)
{}
+ RefLocation(QQmlBinding *binding, QV4::Function *function) :
+ Location(function->sourceLocation()), locationType(Binding),
+ ref(new BindingRefCount(binding), QQmlRefPointer<QQmlRefCount>::Adopt), sent(false)
+ {}
+
RefLocation(QV4::CompiledData::CompilationUnit *ref, const QUrl &url, const QV4::CompiledData::Object *obj,
const QString &type) :
Location(QQmlSourceLocation(type, obj->location.line, obj->location.column), url),
@@ -231,7 +236,7 @@ public:
typedef QHash<quintptr, Location> LocationHash;
- void startBinding(QQmlBinding *binding, QV4::FunctionObject *function)
+ void startBinding(QQmlBinding *binding, QV4::Function *function)
{
quintptr locationId(id(binding));
m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(),
@@ -326,7 +331,7 @@ struct QQmlProfilerHelper : public QQmlProfilerDefinitions {
struct QQmlBindingProfiler : public QQmlProfilerHelper {
QQmlBindingProfiler(QQmlProfiler *profiler, QQmlBinding *binding,
- QV4::FunctionObject *function) :
+ QV4::Function *function) :
QQmlProfilerHelper(profiler)
{
Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileBinding, profiler,
diff --git a/src/qml/doc/src/javascript/resources.qdoc b/src/qml/doc/src/javascript/resources.qdoc
index b831e2ba70..4f9b40f1d7 100644
--- a/src/qml/doc/src/javascript/resources.qdoc
+++ b/src/qml/doc/src/javascript/resources.qdoc
@@ -78,13 +78,13 @@ Rectangle {
\code
// my_button_impl.js
-property var clickCount = 0; // this state is separate for each instance of MyButton
-function onClicked(btn) {
+var clickCount = 0; // this state is separate for each instance of MyButton
+function onClicked(button) {
clickCount += 1;
if ((clickCount % 5) == 0) {
- obj.color = Qt.rgba(1,0,0,1);
+ button.color = Qt.rgba(1,0,0,1);
} else {
- obj.color = Qt.rgba(0,1,0,1);
+ button.color = Qt.rgba(0,1,0,1);
}
}
\endcode
diff --git a/src/qml/doc/src/qmlfunctions.qdoc b/src/qml/doc/src/qmlfunctions.qdoc
index 8b24d19891..a03c382ed5 100644
--- a/src/qml/doc/src/qmlfunctions.qdoc
+++ b/src/qml/doc/src/qmlfunctions.qdoc
@@ -544,3 +544,15 @@
in order to be found.
*/
+/*!
+ \since 5.9
+ \fn void qmlRegisterModule(const char* uri, int versionMajor, int versionMinor);
+ \relates QQmlEngine
+
+ This function registers a module in a particular \a uri with a version specified
+ in \a versionMajor and \a versionMinor.
+
+ This can be used to make a certain module version available, even if no types
+ are registered for that version. This is particularly useful for keeping the
+ versions of related modules in sync.
+*/
diff --git a/src/qml/jit/qv4isel_masm.cpp b/src/qml/jit/qv4isel_masm.cpp
index 515b8aea4d..c5d612ae65 100644
--- a/src/qml/jit/qv4isel_masm.cpp
+++ b/src/qml/jit/qv4isel_masm.cpp
@@ -69,13 +69,6 @@ using namespace QV4::JIT;
namespace {
-inline bool isPregOrConst(IR::Expr *e)
-{
- if (IR::Temp *t = e->asTemp())
- return t->kind == IR::Temp::PhysicalRegister;
- return e->asConst() != 0;
-}
-
class QIODevicePrintStream: public FilePrintStream
{
Q_DISABLE_COPY(QIODevicePrintStream)
@@ -1164,11 +1157,41 @@ void InstructionSelection::convertTypeToBool(IR::Expr *source, IR::Expr *target)
_as->storeBool(false, target);
break;
case IR::StringType:
+ generateRuntimeCall(Assembler::ReturnValueRegister, toBoolean,
+ Assembler::PointerToValue(source));
+ _as->storeBool(Assembler::ReturnValueRegister, target);
case IR::VarType:
default:
+ Assembler::Pointer addr = _as->loadAddress(Assembler::ScratchRegister, source);
+ Assembler::Pointer tagAddr = addr;
+ tagAddr.offset += 4;
+ _as->load32(tagAddr, Assembler::ReturnValueRegister);
+
+ // checkif it's a bool:
+ Assembler::Jump notBool = _as->branch32(Assembler::NotEqual, Assembler::ReturnValueRegister,
+ Assembler::TrustedImm32(Value::Boolean_Type_Internal));
+ _as->load32(addr, Assembler::ReturnValueRegister);
+ Assembler::Jump boolDone = _as->jump();
+ // check if it's an int32:
+ notBool.link(_as);
+ Assembler::Jump fallback = _as->branch32(Assembler::NotEqual, Assembler::ReturnValueRegister,
+ Assembler::TrustedImm32(Value::Integer_Type_Internal));
+ _as->load32(addr, Assembler::ReturnValueRegister);
+ Assembler::Jump isZero = _as->branch32(Assembler::Equal, Assembler::ReturnValueRegister,
+ Assembler::TrustedImm32(0));
+ _as->move(Assembler::TrustedImm32(1), Assembler::ReturnValueRegister);
+ Assembler::Jump intDone = _as->jump();
+
+ // not an int:
+ fallback.link(_as);
generateRuntimeCall(Assembler::ReturnValueRegister, toBoolean,
- Assembler::PointerToValue(source));
+ Assembler::PointerToValue(source));
+
+ isZero.link(_as);
+ intDone.link(_as);
+ boolDone.link(_as);
_as->storeBool(Assembler::ReturnValueRegister, target);
+
break;
}
}
@@ -1713,9 +1736,6 @@ QT_END_NAMESPACE
bool InstructionSelection::visitCJumpDouble(IR::AluOp op, IR::Expr *left, IR::Expr *right,
IR::BasicBlock *iftrue, IR::BasicBlock *iffalse)
{
- if (!isPregOrConst(left) || !isPregOrConst(right))
- return false;
-
if (_as->nextBlock() == iftrue) {
Assembler::Jump target = _as->branchDouble(true, op, left, right);
_as->addPatch(iffalse, target);
@@ -1730,9 +1750,6 @@ bool InstructionSelection::visitCJumpDouble(IR::AluOp op, IR::Expr *left, IR::Ex
bool InstructionSelection::visitCJumpSInt32(IR::AluOp op, IR::Expr *left, IR::Expr *right,
IR::BasicBlock *iftrue, IR::BasicBlock *iffalse)
{
- if (!isPregOrConst(left) || !isPregOrConst(right))
- return false;
-
if (_as->nextBlock() == iftrue) {
Assembler::Jump target = _as->branchInt32(true, op, left, right);
_as->addPatch(iffalse, target);
@@ -1831,7 +1848,7 @@ bool InstructionSelection::visitCJumpStrictUndefined(IR::Binop *binop,
Assembler::RelationalCondition cond = binop->op == IR::OpStrictEqual ? Assembler::Equal
: Assembler::NotEqual;
- const Assembler::RegisterID tagReg = Assembler::ScratchRegister;
+ const Assembler::RegisterID tagReg = Assembler::ReturnValueRegister;
#ifdef QV4_USE_64_BIT_VALUE_ENCODING
Assembler::Pointer addr = _as->loadAddress(Assembler::ScratchRegister, varSrc);
_as->load64(addr, tagReg);
@@ -1930,7 +1947,7 @@ bool InstructionSelection::visitCJumpNullUndefined(IR::Type nullOrUndef, IR::Bin
Assembler::Pointer tagAddr = _as->loadAddress(Assembler::ScratchRegister, varSrc);
tagAddr.offset += 4;
- const Assembler::RegisterID tagReg = Assembler::ScratchRegister;
+ const Assembler::RegisterID tagReg = Assembler::ReturnValueRegister;
_as->load32(tagAddr, tagReg);
if (binop->op == IR::OpNotEqual)
diff --git a/src/qml/jit/qv4isel_masm_p.h b/src/qml/jit/qv4isel_masm_p.h
index 5c693e0736..012745c5f2 100644
--- a/src/qml/jit/qv4isel_masm_p.h
+++ b/src/qml/jit/qv4isel_masm_p.h
@@ -80,61 +80,61 @@ 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<QV4::CompiledData::CompilationUnit> backendCompileStep();
-
- 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 loadThisObject(IR::Expr *temp);
- virtual void loadQmlContext(IR::Expr *target);
- virtual void loadQmlImportedScripts(IR::Expr *target);
- virtual void loadQmlSingleton(const QString &name, IR::Expr *target);
- virtual void loadConst(IR::Const *sourceConst, IR::Expr *target);
- 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 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 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 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 *sourceTemp, IR::Expr *target);
- virtual void binop(IR::AluOp oper, IR::Expr *leftSource, IR::Expr *rightSource, IR::Expr *target);
+ QQmlRefPointer<QV4::CompiledData::CompilationUnit> backendCompileStep() 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 loadThisObject(IR::Expr *temp) override;
+ void loadQmlContext(IR::Expr *target) override;
+ void loadQmlImportedScripts(IR::Expr *target) override;
+ void loadQmlSingleton(const QString &name, IR::Expr *target) override;
+ void loadConst(IR::Const *sourceConst, IR::Expr *target) 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 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 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 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 *sourceTemp, IR::Expr *target) override;
+ void binop(IR::AluOp oper, IR::Expr *leftSource, IR::Expr *rightSource, IR::Expr *target) override;
typedef Assembler::Address Address;
typedef Assembler::Pointer Pointer;
@@ -159,13 +159,13 @@ protected:
return _as->stackLayout().callDataAddress();
}
- 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);
+ 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;
- virtual void visitJump(IR::Jump *);
- virtual void visitCJump(IR::CJump *);
- virtual void visitRet(IR::Ret *);
+ void visitJump(IR::Jump *) override;
+ void visitCJump(IR::CJump *) override;
+ void visitRet(IR::Ret *) override;
bool visitCJumpDouble(IR::AluOp op, IR::Expr *left, IR::Expr *right,
IR::BasicBlock *iftrue, IR::BasicBlock *iffalse);
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp
index a4a96a96a7..b473e96286 100644
--- a/src/qml/jsapi/qjsvalue.cpp
+++ b/src/qml/jsapi/qjsvalue.cpp
@@ -612,8 +612,8 @@ QVariant QJSValue::toVariant() const
if (Object *o = val->as<Object>())
return o->engine()->toVariant(*val, /*typeHint*/ -1, /*createJSValueForObjects*/ false);
- if (val->isString())
- return QVariant(val->stringValue()->toQString());
+ if (String *s = val->stringValue())
+ return QVariant(s->toQString());
if (val->isBoolean())
return QVariant(val->booleanValue());
if (val->isNumber()) {
@@ -885,14 +885,14 @@ QJSValue& QJSValue::operator=(const QJSValue& other)
static bool js_equal(const QString &string, const QV4::Value &value)
{
- if (value.isString())
- return string == value.stringValue()->toQString();
+ if (String *s = value.stringValue())
+ return string == s->toQString();
if (value.isNumber())
return RuntimeHelpers::stringToNumber(string) == value.asDouble();
if (value.isBoolean())
return RuntimeHelpers::stringToNumber(string) == double(value.booleanValue());
- if (value.isObject()) {
- Scope scope(value.objectValue()->engine());
+ if (Object *o = value.objectValue()) {
+ Scope scope(o->engine());
ScopedValue p(scope, RuntimeHelpers::toPrimitive(value, PREFERREDTYPE_HINT));
return js_equal(string, p);
}
@@ -979,8 +979,8 @@ bool QJSValue::strictlyEquals(const QJSValue& other) const
return *variant == *QJSValuePrivate::getVariant(&other);
if (variant->type() == QVariant::Map || variant->type() == QVariant::List)
return false;
- if (ov->isString())
- return variant->toString() == ov->stringValue()->toQString();
+ if (String *s = ov->stringValue())
+ return variant->toString() == s->toQString();
return false;
}
if (!ov)
diff --git a/src/qml/jsruntime/jsruntime.pri b/src/qml/jsruntime/jsruntime.pri
index 4343924436..919524d1ed 100644
--- a/src/qml/jsruntime/jsruntime.pri
+++ b/src/qml/jsruntime/jsruntime.pri
@@ -27,6 +27,7 @@ SOURCES += \
$$PWD/qv4numberobject.cpp \
$$PWD/qv4object.cpp \
$$PWD/qv4objectproto.cpp \
+ $$PWD/qv4qmlcontext.cpp \
$$PWD/qv4regexpobject.cpp \
$$PWD/qv4stringobject.cpp \
$$PWD/qv4variantobject.cpp \
@@ -48,7 +49,6 @@ HEADERS += \
$$PWD/qv4global_p.h \
$$PWD/qv4engine_p.h \
$$PWD/qv4context_p.h \
- $$PWD/qv4context_p_p.h \
$$PWD/qv4math_p.h \
$$PWD/qv4persistent_p.h \
$$PWD/qv4debugging_p.h \
@@ -73,6 +73,7 @@ HEADERS += \
$$PWD/qv4numberobject_p.h \
$$PWD/qv4object_p.h \
$$PWD/qv4objectproto_p.h \
+ $$PWD/qv4qmlcontext_p.h \
$$PWD/qv4regexpobject_p.h \
$$PWD/qv4stringobject_p.h \
$$PWD/qv4variantobject_p.h \
diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp
index 0dfdf25158..5a190d6690 100644
--- a/src/qml/jsruntime/qv4argumentsobject.cpp
+++ b/src/qml/jsruntime/qv4argumentsobject.cpp
@@ -39,7 +39,8 @@
#include <qv4argumentsobject_p.h>
#include <qv4alloca_p.h>
#include <qv4scopedvalue_p.h>
-#include "qv4string_p.h"
+#include <qv4string_p.h>
+#include <qv4function_p.h>
using namespace QV4;
@@ -56,8 +57,6 @@ void Heap::ArgumentsObject::init(QV4::CallContext *context)
Scope scope(v4);
Scoped<QV4::ArgumentsObject> args(scope, this);
- args->setArrayType(Heap::ArrayData::Complex);
-
if (context->d()->strictMode) {
Q_ASSERT(CalleePropertyIndex == args->internalClass()->find(context->d()->engine->id_callee()));
Q_ASSERT(CallerPropertyIndex == args->internalClass()->find(context->d()->engine->id_caller()));
@@ -83,7 +82,7 @@ void ArgumentsObject::fullyCreate()
return;
uint argCount = context()->callData->argc;
- uint numAccessors = qMin(context()->function->formalParameterCount(), argCount);
+ uint numAccessors = qMin(context()->formalParameterCount(), argCount);
ArrayData::realloc(this, Heap::ArrayData::Sparse, argCount, true);
context()->engine->requireArgumentsAccessors(numAccessors);
@@ -110,7 +109,7 @@ bool ArgumentsObject::defineOwnProperty(ExecutionEngine *engine, uint index, con
ScopedProperty map(scope);
PropertyAttributes mapAttrs;
bool isMapped = false;
- uint numAccessors = qMin((int)context()->function->formalParameterCount(), context()->callData->argc);
+ uint numAccessors = qMin((int)context()->formalParameterCount(), context()->callData->argc);
if (pd && index < (uint)numAccessors)
isMapped = arrayData()->attributes(index).isAccessor() &&
pd->getter() == context()->engine->argumentsAccessors[index].getter();
@@ -193,7 +192,7 @@ PropertyAttributes ArgumentsObject::queryIndexed(const Managed *m, uint index)
if (args->fullyCreated())
return Object::queryIndexed(m, index);
- uint numAccessors = qMin((int)args->context()->function->formalParameterCount(), args->context()->callData->argc);
+ uint numAccessors = qMin((int)args->context()->formalParameterCount(), args->context()->callData->argc);
uint argCount = args->context()->callData->argc;
if (index >= argCount)
return PropertyAttributes();
@@ -245,3 +244,11 @@ void ArgumentsObject::markObjects(Heap::Base *that, ExecutionEngine *e)
Object::markObjects(that, e);
}
+
+uint ArgumentsObject::getLength(const Managed *m)
+{
+ const ArgumentsObject *a = static_cast<const ArgumentsObject *>(m);
+ if (a->propertyData(Heap::ArgumentsObject::LengthPropertyIndex)->isInteger())
+ return a->propertyData(Heap::ArgumentsObject::LengthPropertyIndex)->integerValue();
+ return Primitive::toUInt32(a->propertyData(Heap::ArgumentsObject::LengthPropertyIndex)->doubleValue());
+}
diff --git a/src/qml/jsruntime/qv4argumentsobject_p.h b/src/qml/jsruntime/qv4argumentsobject_p.h
index 37a8d0a94a..0a2ea3b42a 100644
--- a/src/qml/jsruntime/qv4argumentsobject_p.h
+++ b/src/qml/jsruntime/qv4argumentsobject_p.h
@@ -132,8 +132,10 @@ struct ArgumentsObject: Object {
static bool deleteIndexedProperty(Managed *m, uint index);
static PropertyAttributes queryIndexed(const Managed *m, uint index);
static void markObjects(Heap::Base *that, ExecutionEngine *e);
+ static uint getLength(const Managed *m);
void fullyCreate();
+
};
}
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index 390a5e7d7a..544d39339b 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -39,7 +39,7 @@
#include <QString>
#include "qv4debugging_p.h"
-#include <qv4context_p_p.h>
+#include <qv4context_p.h>
#include <qv4object_p.h>
#include <qv4objectproto_p.h>
#include <private/qv4mm_p.h>
@@ -47,6 +47,9 @@
#include "qv4function_p.h"
#include "qv4errorobject_p.h"
#include "qv4string_p.h"
+#include "qv4qmlcontext_p.h"
+#include "qv4profiling_p.h"
+#include <private/qqmljavascriptexpression_p.h>
using namespace QV4;
@@ -55,29 +58,31 @@ DEFINE_MANAGED_VTABLE(CallContext);
DEFINE_MANAGED_VTABLE(WithContext);
DEFINE_MANAGED_VTABLE(CatchContext);
DEFINE_MANAGED_VTABLE(GlobalContext);
-DEFINE_MANAGED_VTABLE(QmlContext);
-Heap::CallContext *ExecutionContext::newCallContext(const FunctionObject *function, CallData *callData)
-{
- Q_ASSERT(function->function());
+/* Function *f, int argc */
+#define requiredMemoryForExecutionContect(f, argc) \
+ ((sizeof(CallContext::Data) + 7) & ~7) + \
+ sizeof(Value) * (f->compiledFunction->nLocals + qMax((uint)argc, f->nFormals)) + sizeof(CallData)
+Heap::CallContext *ExecutionContext::newCallContext(Function *function, CallData *callData)
+{
Heap::CallContext *c = d()->engine->memoryManager->allocManaged<CallContext>(
requiredMemoryForExecutionContect(function, callData->argc));
c->init(d()->engine, Heap::ExecutionContext::Type_CallContext);
- c->function = function->d();
+ c->v4Function = function;
- c->strictMode = function->strictMode();
- c->outer = function->scope();
+ c->strictMode = function->isStrict();
+ c->outer = this->d();
c->activation = 0;
- c->compilationUnit = function->function()->compilationUnit;
+ c->compilationUnit = function->compilationUnit;
c->lookups = c->compilationUnit->runtimeLookups;
c->constantTable = c->compilationUnit->constants;
c->locals = (Value *)((quintptr(c + 1) + 7) & ~7);
- const CompiledData::Function *compiledFunction = function->function()->compiledFunction;
+ const CompiledData::Function *compiledFunction = function->compiledFunction;
int nLocals = compiledFunction->nLocals;
if (nLocals)
std::fill(c->locals, c->locals + nLocals, Primitive::undefinedValue());
@@ -102,20 +107,6 @@ Heap::CatchContext *ExecutionContext::newCatchContext(Heap::String *exceptionVar
return d()->engine->memoryManager->alloc<CatchContext>(d(), exceptionVarName, e);
}
-Heap::QmlContext *ExecutionContext::newQmlContext(QmlContextWrapper *qml)
-{
- Heap::QmlContext *c = d()->engine->memoryManager->alloc<QmlContext>(this, qml);
- return c;
-}
-
-Heap::QmlContext *ExecutionContext::newQmlContext(QQmlContextData *context, QObject *scopeObject)
-{
- Scope scope(this);
- Scoped<QmlContextWrapper> qml(scope, QmlContextWrapper::qmlScope(scope.engine, context, scopeObject));
- Heap::QmlContext *c = d()->engine->memoryManager->alloc<QmlContext>(this, qml);
- return c;
-}
-
void ExecutionContext::createMutableBinding(String *name, bool deletable)
{
Scope scope(this);
@@ -182,38 +173,25 @@ void Heap::CatchContext::init(ExecutionContext *outerContext, String *exceptionV
this->exceptionValue = exceptionValue;
}
-void Heap::QmlContext::init(QV4::ExecutionContext *outerContext, QV4::QmlContextWrapper *qml)
-{
- Heap::ExecutionContext::init(outerContext->engine(), Heap::ExecutionContext::Type_QmlContext);
- outer = outerContext->d();
- strictMode = false;
- callData = outer->callData;
- lookups = outer->lookups;
- constantTable = outer->constantTable;
- compilationUnit = outer->compilationUnit;
-
- this->qml = qml->d();
-}
-
Identifier * const *CallContext::formals() const
{
- return (d()->function && d()->function->function) ? d()->function->function->internalClass->nameMap.constData() : 0;
+ return d()->v4Function ? d()->v4Function->internalClass->nameMap.constData() : 0;
}
unsigned int CallContext::formalCount() const
{
- return d()->function ? d()->function->formalParameterCount() : 0;
+ return d()->v4Function ? d()->v4Function->nFormals : 0;
}
Identifier * const *CallContext::variables() const
{
- return (d()->function && d()->function->function) ? d()->function->function->internalClass->nameMap.constData() + d()->function->formalParameterCount() : 0;
+ return d()->v4Function ? d()->v4Function->internalClass->nameMap.constData() + d()->v4Function->nFormals : 0;
}
unsigned int CallContext::variableCount() const
{
- return d()->function ? d()->function->varCount() : 0;
+ return d()->v4Function ? d()->v4Function->compiledFunction->nLocals : 0;
}
@@ -247,9 +225,8 @@ bool ExecutionContext::deleteProperty(String *name)
case Heap::ExecutionContext::Type_CallContext:
case Heap::ExecutionContext::Type_SimpleCallContext: {
Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx->d());
- ScopedFunctionObject f(scope, c->function);
- if (f->needsActivation() || hasWith) {
- uint index = f->function()->internalClass->find(name);
+ if (c->v4Function && (c->v4Function->needsActivation() || hasWith)) {
+ uint index = c->v4Function->internalClass->find(name);
if (index < UINT_MAX)
// ### throw in strict mode?
return false;
@@ -272,7 +249,8 @@ bool ExecutionContext::deleteProperty(String *name)
bool CallContext::needsOwnArguments() const
{
- return d()->function->needsActivation() || argc() < static_cast<int>(d()->function->formalParameterCount());
+ QV4::Function *f = d()->v4Function;
+ return (f && f->needsActivation()) || (argc() < (f ? static_cast<int>(f->nFormals) : 0));
}
void ExecutionContext::markObjects(Heap::Base *m, ExecutionEngine *engine)
@@ -304,14 +282,16 @@ void ExecutionContext::markObjects(Heap::Base *m, ExecutionEngine *engine)
break;
case Heap::ExecutionContext::Type_CallContext: {
QV4::Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx);
+ Q_ASSERT(c->v4Function);
ctx->callData->thisObject.mark(engine);
- for (int arg = 0; arg < qMax(ctx->callData->argc, (int)c->function->formalParameterCount()); ++arg)
+ for (int arg = 0; arg < qMax(ctx->callData->argc, (int)c->v4Function->nFormals); ++arg)
ctx->callData->args[arg].mark(engine);
- for (unsigned local = 0, lastLocal = c->function->varCount(); local < lastLocal; ++local)
+ for (unsigned local = 0, lastLocal = c->v4Function->compiledFunction->nLocals; local < lastLocal; ++local)
c->locals[local].mark(engine);
if (c->activation)
c->activation->mark(engine);
- c->function->mark(engine);
+ if (c->function)
+ c->function->mark(engine);
break;
}
case Heap::ExecutionContext::Type_QmlContext: {
@@ -322,6 +302,51 @@ void ExecutionContext::markObjects(Heap::Base *m, ExecutionEngine *engine)
}
}
+// Do a standard call with this execution context as the outer scope
+void ExecutionContext::call(Scope &scope, CallData *callData, Function *function, const FunctionObject *f)
+{
+ ExecutionContextSaver ctxSaver(scope);
+
+ Scoped<CallContext> ctx(scope, newCallContext(function, callData));
+ if (f)
+ ctx->d()->function = f->d();
+ scope.engine->pushContext(ctx);
+
+ scope.result = Q_V4_PROFILE(scope.engine, function);
+
+ if (function->hasQmlDependencies)
+ QQmlPropertyCapture::registerQmlDependencies(function->compiledFunction, scope);
+}
+
+// Do a simple, fast call with this execution context as the outer scope
+void QV4::ExecutionContext::simpleCall(Scope &scope, CallData *callData, Function *function)
+{
+ Q_ASSERT(function->canUseSimpleFunction());
+
+ ExecutionContextSaver ctxSaver(scope);
+
+ CallContext::Data ctx = CallContext::Data::createOnStack(scope.engine);
+
+ ctx.strictMode = function->isStrict();
+ ctx.callData = callData;
+ ctx.v4Function = function;
+ ctx.compilationUnit = function->compilationUnit;
+ ctx.lookups = function->compilationUnit->runtimeLookups;
+ ctx.constantTable = function->compilationUnit->constants;
+ ctx.outer = this->d();
+ ctx.locals = scope.alloc(function->compiledFunction->nLocals);
+ for (int i = callData->argc; i < (int)function->nFormals; ++i)
+ callData->args[i] = Encode::undefined();
+
+ scope.engine->pushContext(&ctx);
+ Q_ASSERT(scope.engine->current == &ctx);
+
+ scope.result = Q_V4_PROFILE(scope.engine, function);
+
+ if (function->hasQmlDependencies)
+ QQmlPropertyCapture::registerQmlDependencies(function->compiledFunction, scope);
+}
+
void ExecutionContext::setProperty(String *name, const Value &value)
{
Scope scope(this);
@@ -354,13 +379,13 @@ void ExecutionContext::setProperty(String *name, const Value &value)
case Heap::ExecutionContext::Type_CallContext:
case Heap::ExecutionContext::Type_SimpleCallContext: {
Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx->d());
- if (c->function->function) {
- uint index = c->function->function->internalClass->find(name);
+ if (c->v4Function) {
+ uint index = c->v4Function->internalClass->find(name);
if (index < UINT_MAX) {
- if (index < c->function->formalParameterCount()) {
- c->callData->args[c->function->formalParameterCount() - index - 1] = value;
+ if (index < c->v4Function->nFormals) {
+ c->callData->args[c->v4Function->nFormals - index - 1] = value;
} else {
- index -= c->function->formalParameterCount();
+ index -= c->v4Function->nFormals;
c->locals[index] = value;
}
return;
@@ -435,13 +460,12 @@ ReturnedValue ExecutionContext::getProperty(String *name)
case Heap::ExecutionContext::Type_CallContext:
case Heap::ExecutionContext::Type_SimpleCallContext: {
Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx->d());
- ScopedFunctionObject f(scope, c->function);
- if (f->function() && (f->needsActivation() || hasWith || hasCatchScope)) {
- uint index = f->function()->internalClass->find(name);
+ if (c->v4Function && (c->v4Function->needsActivation() || hasWith || hasCatchScope)) {
+ uint index = c->v4Function->internalClass->find(name);
if (index < UINT_MAX) {
- if (index < c->function->formalParameterCount())
- return c->callData->args[c->function->formalParameterCount() - index - 1].asReturnedValue();
- return c->locals[index - c->function->formalParameterCount()].asReturnedValue();
+ if (index < c->v4Function->nFormals)
+ return c->callData->args[c->v4Function->nFormals - index - 1].asReturnedValue();
+ return c->locals[index - c->v4Function->nFormals].asReturnedValue();
}
}
ScopedObject activation(scope, c->activation);
@@ -451,9 +475,9 @@ ReturnedValue ExecutionContext::getProperty(String *name)
if (hasProperty)
return v->asReturnedValue();
}
- if (f->function() && f->function()->isNamedExpression()
- && name->equals(ScopedString(scope, f->function()->name())))
- return f.asReturnedValue();
+ if (c->function && c->v4Function->isNamedExpression()
+ && name->equals(ScopedString(scope, c->v4Function->name())))
+ return c->function->asReturnedValue();
break;
}
case Heap::ExecutionContext::Type_QmlContext: {
@@ -514,13 +538,12 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Value *base)
case Heap::ExecutionContext::Type_CallContext:
case Heap::ExecutionContext::Type_SimpleCallContext: {
Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx->d());
- ScopedFunctionObject f(scope, c->function);
- if (f->function() && (f->needsActivation() || hasWith || hasCatchScope)) {
- uint index = f->function()->internalClass->find(name);
+ if (c->v4Function && (c->v4Function->needsActivation() || hasWith || hasCatchScope)) {
+ uint index = c->v4Function->internalClass->find(name);
if (index < UINT_MAX) {
- if (index < c->function->formalParameterCount())
- return c->callData->args[c->function->formalParameterCount() - index - 1].asReturnedValue();
- return c->locals[index - c->function->formalParameterCount()].asReturnedValue();
+ if (index < c->v4Function->nFormals)
+ return c->callData->args[c->v4Function->nFormals - index - 1].asReturnedValue();
+ return c->locals[index - c->v4Function->nFormals].asReturnedValue();
}
}
ScopedObject activation(scope, c->activation);
@@ -530,9 +553,9 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Value *base)
if (hasProperty)
return v->asReturnedValue();
}
- if (f->function() && f->function()->isNamedExpression()
- && name->equals(ScopedString(scope, f->function()->name())))
- return f.asReturnedValue();
+ if (c->function && c->v4Function->isNamedExpression()
+ && name->equals(ScopedString(scope, c->v4Function->name())))
+ return c->function->asReturnedValue();
break;
}
case Heap::ExecutionContext::Type_QmlContext: {
@@ -551,13 +574,13 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Value *base)
return engine()->throwReferenceError(n);
}
-Heap::FunctionObject *ExecutionContext::getFunctionObject() const
+Function *ExecutionContext::getFunction() const
{
Scope scope(d()->engine);
ScopedContext it(scope, this->d());
for (; it; it = it->d()->outer) {
if (const CallContext *callCtx = it->asCallContext())
- return callCtx->d()->function;
+ return callCtx->d()->v4Function;
else if (it->asCatchContext() || it->asWithContext())
continue; // look in the parent context for a FunctionObject
else
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index 0b42288ccc..c985fdb24d 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -55,8 +55,8 @@
QT_BEGIN_NAMESPACE
-class QQmlContextData;
class QObject;
+class QQmlContextData;
namespace QV4 {
@@ -65,11 +65,13 @@ struct CompilationUnit;
struct Function;
}
-struct QmlContextWrapper;
+struct Function;
struct Identifier;
struct CallContext;
struct CatchContext;
struct WithContext;
+struct QmlContext;
+struct QmlContextWrapper;
struct CallData
{
@@ -91,6 +93,8 @@ struct CallData
namespace Heap {
+struct QmlContext;
+
struct ExecutionContext : Base {
enum ContextType {
Type_GlobalContext = 0x1,
@@ -137,11 +141,15 @@ struct CallContext : ExecutionContext {
{
ExecutionContext::init(engine, t);
function = 0;
+ v4Function = 0;
locals = 0;
activation = 0;
}
+ inline unsigned int formalParameterCount() const;
+
Pointer<FunctionObject> function;
+ QV4::Function *v4Function;
Value *locals;
Pointer<Object> activation;
};
@@ -177,14 +185,6 @@ struct WithContext : ExecutionContext {
};
V4_ASSERT_IS_TRIVIAL(WithContext)
-struct QmlContextWrapper;
-
-struct QmlContext : ExecutionContext {
- void init(QV4::ExecutionContext *outerContext, QV4::QmlContextWrapper *qml);
-
- Pointer<QmlContextWrapper> qml;
-};
-
}
struct Q_QML_EXPORT ExecutionContext : public Managed
@@ -198,11 +198,9 @@ struct Q_QML_EXPORT ExecutionContext : public Managed
ExecutionEngine *engine() const { return d()->engine; }
- Heap::CallContext *newCallContext(const FunctionObject *f, CallData *callData);
+ Heap::CallContext *newCallContext(Function *f, CallData *callData);
Heap::WithContext *newWithContext(Heap::Object *with);
Heap::CatchContext *newCatchContext(Heap::String *exceptionVarName, ReturnedValue exceptionValue);
- Heap::QmlContext *newQmlContext(QmlContextWrapper *qml);
- Heap::QmlContext *newQmlContext(QQmlContextData *context, QObject *scopeObject);
void createMutableBinding(String *name, bool deletable);
@@ -216,7 +214,7 @@ struct Q_QML_EXPORT ExecutionContext : public Managed
inline const CatchContext *asCatchContext() const;
inline const WithContext *asWithContext() const;
- Heap::FunctionObject *getFunctionObject() const;
+ Function *getFunction() const;
static void markObjects(Heap::Base *m, ExecutionEngine *e);
@@ -232,6 +230,9 @@ struct Q_QML_EXPORT ExecutionContext : public Managed
ReturnedValue argument(int i) const {
return d()->callData->argument(i);
}
+
+ void call(Scope &scope, CallData *callData, QV4::Function *function, const QV4::FunctionObject *f = 0);
+ void simpleCall(Scope &scope, CallData *callData, QV4::Function *function);
};
struct Q_QML_EXPORT CallContext : public ExecutionContext
@@ -244,11 +245,11 @@ struct Q_QML_EXPORT CallContext : public ExecutionContext
Identifier * const *variables() const;
unsigned int variableCount() const;
- inline ReturnedValue argument(int i);
+ inline ReturnedValue argument(int i) const;
bool needsOwnArguments() const;
};
-inline ReturnedValue CallContext::argument(int i) {
+inline ReturnedValue CallContext::argument(int i) const {
return i < argc() ? args()[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue();
}
@@ -268,16 +269,6 @@ struct WithContext : public ExecutionContext
V4_MANAGED(WithContext, ExecutionContext)
};
-struct Q_QML_EXPORT QmlContext : public ExecutionContext
-{
- V4_MANAGED(QmlContext, ExecutionContext)
-
- QObject *qmlScope() const;
- QQmlContextData *qmlContext() const;
-
- void takeContextOwnership();
-};
-
inline CallContext *ExecutionContext::asCallContext()
{
return d()->type >= Heap::ExecutionContext::Type_SimpleCallContext ? static_cast<CallContext *>(this) : 0;
@@ -308,10 +299,6 @@ inline Heap::CallContext Heap::CallContext::createOnStack(ExecutionEngine *v4)
return ctxt;
}
-/* Function *f, int argc */
-#define requiredMemoryForExecutionContect(f, argc) \
- ((sizeof(CallContext::Data) + 7) & ~7) + sizeof(Value) * (f->varCount() + qMax((uint)argc, f->formalParameterCount())) + sizeof(CallData)
-
} // namespace QV4
QT_END_NAMESPACE
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index 4f3138a452..8cc6a25fea 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -689,8 +689,8 @@ void DateCtor::construct(const Managed *, Scope &scope, CallData *callData)
} else {
arg = RuntimeHelpers::toPrimitive(arg, PREFERREDTYPE_HINT);
- if (arg->isString())
- t = ParseString(arg->stringValue()->toQString());
+ if (String *s = arg->stringValue())
+ t = ParseString(s->toQString());
else
t = TimeClip(arg->toNumber());
}
@@ -1319,14 +1319,17 @@ ReturnedValue DatePrototype::method_toISOString(CallContext *ctx)
ReturnedValue DatePrototype::method_toJSON(CallContext *ctx)
{
Scope scope(ctx);
- ScopedValue O(scope, RuntimeHelpers::toObject(scope.engine, ctx->thisObject()));
+ ScopedObject O(scope, ctx->thisObject().toObject(scope.engine));
+ if (scope.hasException())
+ return Encode::undefined();
+
ScopedValue tv(scope, RuntimeHelpers::toPrimitive(O, NUMBER_HINT));
if (tv->isNumber() && !std::isfinite(tv->toNumber()))
return Encode::null();
ScopedString s(scope, ctx->d()->engine->newString(QStringLiteral("toISOString")));
- ScopedValue v(scope, O->objectValue()->get(s));
+ ScopedValue v(scope, O->get(s));
FunctionObject *toIso = v->as<FunctionObject>();
if (!toIso)
diff --git a/src/qml/jsruntime/qv4dateobject_p.h b/src/qml/jsruntime/qv4dateobject_p.h
index 2d0648396e..835f6adbe0 100644
--- a/src/qml/jsruntime/qv4dateobject_p.h
+++ b/src/qml/jsruntime/qv4dateobject_p.h
@@ -101,7 +101,7 @@ struct DateObject: Object {
template<>
inline const DateObject *Value::as() const {
- return isManaged() && m() && m()->vtable()->type == Managed::Type_DateObject ? static_cast<const DateObject *>(this) : 0;
+ return isManaged() && m()->vtable()->type == Managed::Type_DateObject ? static_cast<const DateObject *>(this) : 0;
}
struct DateCtor: FunctionObject
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 7265952f72..8f2c5174da 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
#include <qv4engine_p.h>
-#include <qv4context_p.h>
+#include <qv4qmlcontext_p.h>
#include <qv4value_p.h>
#include <qv4object_p.h>
#include <qv4objectproto_p.h>
@@ -71,7 +71,6 @@
#include "qv4typedarray_p.h"
#include <private/qv8engine_p.h>
#include <private/qjsvalue_p.h>
-#include <private/qqmlcontextwrapper_p.h>
#include <private/qqmltypewrapper_p.h>
#include <private/qqmlvaluetypewrapper_p.h>
#include <private/qqmlvaluetype_p.h>
@@ -282,10 +281,10 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
jsObjects[FunctionProto] = memoryManager->allocObject<FunctionPrototype>(functionProtoClass, objectPrototype());
functionClass = emptyClass->addMember(id_prototype(), Attr_NotEnumerable|Attr_NotConfigurable, &index);
Q_ASSERT(index == Heap::FunctionObject::Index_Prototype);
- simpleScriptFunctionClass = functionClass->addMember(id_name(), Attr_ReadOnly, &index);
- Q_ASSERT(index == Heap::SimpleScriptFunction::Index_Name);
- simpleScriptFunctionClass = simpleScriptFunctionClass->addMember(id_length(), Attr_ReadOnly, &index);
- Q_ASSERT(index == Heap::SimpleScriptFunction::Index_Length);
+ scriptFunctionClass = functionClass->addMember(id_name(), Attr_ReadOnly, &index);
+ Q_ASSERT(index == Heap::ScriptFunction::Index_Name);
+ scriptFunctionClass = scriptFunctionClass->addMember(id_length(), Attr_ReadOnly, &index);
+ Q_ASSERT(index == Heap::ScriptFunction::Index_Length);
protoClass = emptyClass->addMember(id_constructor(), Attr_NotEnumerable, &index);
Q_ASSERT(index == Heap::FunctionObject::Index_ProtoConstructor);
@@ -714,6 +713,27 @@ Heap::Object *ExecutionEngine::newForEachIteratorObject(Object *o)
return obj->d();
}
+Heap::QmlContext *ExecutionEngine::qmlContext() const
+{
+ Heap::ExecutionContext *ctx = current;
+
+ // get the correct context when we're within a builtin function
+ if (ctx->type == Heap::ExecutionContext::Type_SimpleCallContext && !ctx->outer)
+ ctx = parentContext(currentContext)->d();
+
+ if (ctx->type != Heap::ExecutionContext::Type_QmlContext && !ctx->outer)
+ return 0;
+
+ while (ctx->outer && ctx->outer->type != Heap::ExecutionContext::Type_GlobalContext)
+ ctx = ctx->outer;
+
+ Q_ASSERT(ctx);
+ if (ctx->type != Heap::ExecutionContext::Type_QmlContext)
+ return 0;
+
+ return static_cast<Heap::QmlContext *>(ctx);
+}
+
QObject *ExecutionEngine::qmlScopeObject() const
{
Heap::QmlContext *ctx = qmlContext();
@@ -760,21 +780,17 @@ QVector<StackFrame> ExecutionEngine::stackTrace(int frameLimit) const
QVector<StackFrame> stack;
ExecutionContext *c = currentContext;
- ScopedFunctionObject function(scope);
while (c && frameLimit) {
- function = c->getFunctionObject();
+ QV4::Function *function = c->getFunction();
if (function) {
StackFrame frame;
- if (const Function *f = function->function())
- frame.source = f->sourceFile();
+ frame.source = function->sourceFile();
name = function->name();
frame.function = name->toQString();
- frame.line = -1;
- frame.column = -1;
- if (function->function())
- // line numbers can be negative for places where you can't set a real breakpoint
- frame.line = qAbs(c->d()->lineNumber);
+ // line numbers can be negative for places where you can't set a real breakpoint
+ frame.line = qAbs(c->d()->lineNumber);
+ frame.column = -1;
stack.append(frame);
--frameLimit;
@@ -850,9 +866,8 @@ QUrl ExecutionEngine::resolvedUrl(const QString &file)
ExecutionContext *c = currentContext;
while (c) {
CallContext *callCtx = c->asCallContext();
- if (callCtx && callCtx->d()->function) {
- if (callCtx->d()->function->function)
- base.setUrl(callCtx->d()->function->function->sourceFile());
+ if (callCtx && callCtx->d()->v4Function) {
+ base.setUrl(callCtx->d()->v4Function->sourceFile());
break;
}
c = parentContext(c);
@@ -1151,8 +1166,8 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::Value &value, int
return value.integerValue();
if (value.isNumber())
return value.asDouble();
- if (value.isString()) {
- const QString &str = value.toQString();
+ if (String *s = value.stringValue()) {
+ const QString &str = s->toQString();
// QChars are stored as a strings
if (typeHint == QVariant::Char && str.size() == 1)
return str.at(0);
@@ -1591,8 +1606,8 @@ bool ExecutionEngine::metaTypeFromJS(const Value *value, int type, void *data)
*reinterpret_cast<unsigned char*>(data) = (unsigned char)(value->toInt32());
return true;
case QMetaType::QChar:
- if (value->isString()) {
- QString str = value->stringValue()->toQString();
+ if (String *s = value->stringValue()) {
+ QString str = s->toQString();
*reinterpret_cast<QChar*>(data) = str.isEmpty() ? QChar() : str.at(0);
} else {
*reinterpret_cast<QChar*>(data) = QChar(ushort(value->toUInt16()));
@@ -1704,10 +1719,10 @@ bool ExecutionEngine::metaTypeFromJS(const Value *value, int type, void *data)
// We have T t, T* is requested, so return &t.
*reinterpret_cast<void* *>(data) = var.data();
return true;
- } else if (value->isObject()) {
+ } else if (Object *o = value->objectValue()) {
// Look in the prototype chain.
QV4::Scope scope(this);
- QV4::ScopedObject proto(scope, value->objectValue()->prototype());
+ QV4::ScopedObject proto(scope, o->prototype());
while (proto) {
bool canCast = false;
if (QV4::VariantObject *vo = proto->as<QV4::VariantObject>()) {
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h
index 843a6f4d94..1c20ad30aa 100644
--- a/src/qml/jsruntime/qv4engine_p.h
+++ b/src/qml/jsruntime/qv4engine_p.h
@@ -128,10 +128,12 @@ public:
--jsStackTop;
return jsStackTop->heapObject();
}
- Value *jsAlloca(int nValues) {
+
+ QML_NEARLY_ALWAYS_INLINE Value *jsAlloca(int nValues) {
Value *ptr = jsStackTop;
jsStackTop = ptr + nValues;
- memset(ptr, 0, nValues*sizeof(Value));
+ for (int i = 0; i < nValues; ++i)
+ ptr[i] = Primitive::undefinedValue();
return ptr;
}
@@ -146,7 +148,7 @@ public:
QQmlEngine *qmlEngine() const;
#else // !V4_BOOTSTRAP
QJSEngine *jsEngine() const { return v8Engine->publicEngine(); }
- QQmlEngine *qmlEngine() const { return v8Engine->engine(); }
+ QQmlEngine *qmlEngine() const { return v8Engine ? v8Engine->engine() : nullptr; }
#endif // V4_BOOTSTRAP
QV8Engine *v8Engine;
@@ -253,7 +255,7 @@ public:
InternalClass *stringClass;
InternalClass *functionClass;
- InternalClass *simpleScriptFunctionClass;
+ InternalClass *scriptFunctionClass;
InternalClass *protoClass;
InternalClass *regExpExecArrayClass;
@@ -546,27 +548,6 @@ inline ExecutionContext *ExecutionEngine::parentContext(ExecutionContext *contex
return o ? context - o : 0;
}
-inline Heap::QmlContext *ExecutionEngine::qmlContext() const
-{
- Heap::ExecutionContext *ctx = current;
-
- // get the correct context when we're within a builtin function
- if (ctx->type == Heap::ExecutionContext::Type_SimpleCallContext && !ctx->outer)
- ctx = parentContext(currentContext)->d();
-
- if (ctx->type != Heap::ExecutionContext::Type_QmlContext && !ctx->outer)
- return 0;
-
- while (ctx->outer && ctx->outer->type != Heap::ExecutionContext::Type_GlobalContext)
- ctx = ctx->outer;
-
- Q_ASSERT(ctx);
- if (ctx->type != Heap::ExecutionContext::Type_QmlContext)
- return 0;
-
- return static_cast<Heap::QmlContext *>(ctx);
-}
-
inline
void Heap::Base::mark(QV4::ExecutionEngine *engine)
{
@@ -582,9 +563,6 @@ void Heap::Base::mark(QV4::ExecutionEngine *engine)
inline void Value::mark(ExecutionEngine *e)
{
- if (!isManaged())
- return;
-
Heap::Base *o = heapObject();
if (o)
o->mark(e);
diff --git a/src/qml/jsruntime/qv4errorobject_p.h b/src/qml/jsruntime/qv4errorobject_p.h
index 42a6e0b4b1..2b3ab25e2d 100644
--- a/src/qml/jsruntime/qv4errorobject_p.h
+++ b/src/qml/jsruntime/qv4errorobject_p.h
@@ -178,7 +178,7 @@ struct ErrorObject: Object {
template<>
inline const ErrorObject *Value::as() const {
- return isManaged() && m() && m()->vtable()->isErrorObject ? reinterpret_cast<const ErrorObject *>(this) : 0;
+ return isManaged() && m()->vtable()->isErrorObject ? reinterpret_cast<const ErrorObject *>(this) : 0;
}
struct EvalErrorObject: ErrorObject {
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp
index caabee322a..358c2d079c 100644
--- a/src/qml/jsruntime/qv4function.cpp
+++ b/src/qml/jsruntime/qv4function.cpp
@@ -55,6 +55,7 @@ Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit,
, compilationUnit(unit)
, code(codePtr)
, codeData(0)
+ , hasQmlDependencies(function->hasQmlDependencies())
{
Q_UNUSED(engine);
@@ -83,6 +84,9 @@ Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit,
internalClass = internalClass->addMember(compilationUnit->runtimeStrings[localsIndices[i]]->identifier, Attr_NotConfigurable);
activationRequired = compiledFunction->nInnerFunctions > 0 || (compiledFunction->flags & (CompiledData::Function::HasDirectEval | CompiledData::Function::UsesArgumentsObject));
+
+ canUseSimpleCall = !needsActivation() && !(compiledFunction->flags & CompiledData::Function::HasCatchOrWith) &&
+ !(compiledFunction->nFormals > QV4::Global::ReservedArgumentCount) && !isNamedExpression();
}
Function::~Function()
diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h
index aeef9ad61b..54d0528c42 100644
--- a/src/qml/jsruntime/qv4function_p.h
+++ b/src/qml/jsruntime/qv4function_p.h
@@ -51,7 +51,9 @@
//
#include "qv4global_p.h"
+#include <private/qqmlglobal_p.h>
#include <private/qv4compileddata_p.h>
+#include <private/qv4context_p.h>
QT_BEGIN_NAMESPACE
@@ -68,6 +70,8 @@ struct Q_QML_EXPORT Function {
InternalClass *internalClass;
uint nFormals;
bool activationRequired;
+ bool hasQmlDependencies;
+ bool canUseSimpleCall;
Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function,
ReturnedValue (*codePtr)(ExecutionEngine *, const uchar *));
@@ -88,8 +92,22 @@ struct Q_QML_EXPORT Function {
inline bool needsActivation() const
{ return activationRequired; }
+ inline bool canUseSimpleFunction() const { return canUseSimpleCall; }
+
+ QQmlSourceLocation sourceLocation() const
+ {
+ return QQmlSourceLocation(sourceFile(), compiledFunction->location.line, compiledFunction->location.column);
+ }
+
};
+
+inline unsigned int Heap::CallContext::formalParameterCount() const
+{
+ return v4Function ? v4Function->nFormals : 0;
+}
+
+
}
QT_END_NAMESPACE
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 2cc58b74a6..64f7b98618 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -47,6 +47,7 @@
#include "qv4arrayobject_p.h"
#include "qv4scopedvalue_p.h"
+#include "qv4argumentsobject_p.h"
#include <private/qqmljsengine_p.h>
#include <private/qqmljslexer_p.h>
@@ -81,7 +82,8 @@ void Heap::FunctionObject::init(QV4::ExecutionContext *scope, QV4::String *name,
void Heap::FunctionObject::init(QV4::ExecutionContext *scope, Function *function, bool createProto)
{
Object::init();
- function = nullptr;
+ this->function = function;
+ function->compilationUnit->addref();
this->scope = scope->d();
Scope s(scope->engine());
ScopedString name(s, function->name());
@@ -91,46 +93,9 @@ void Heap::FunctionObject::init(QV4::ExecutionContext *scope, Function *function
void Heap::FunctionObject::init(QV4::ExecutionContext *scope, const QString &name, bool createProto)
{
- Object::init();
- function = nullptr;
- this->scope = scope->d();
- Scope s(scope->engine());
- ScopedFunctionObject f(s, this);
- ScopedString n(s, s.engine->newString(name));
- f->init(n, createProto);
-}
-
-void Heap::FunctionObject::init(ExecutionContext *scope, const QString &name, bool createProto)
-{
- Object::init();
- function = nullptr;
- this->scope = scope;
- Scope s(scope->engine);
- ScopedFunctionObject f(s, this);
- ScopedString n(s, s.engine->newString(name));
- f->init(n, createProto);
-}
-
-void Heap::FunctionObject::init(QV4::ExecutionContext *scope, const ReturnedValue name)
-{
- Object::init();
- function = nullptr;
- this->scope = scope->d();
- Scope s(scope);
- ScopedFunctionObject f(s, this);
- ScopedString n(s, name);
- f->init(n, false);
-}
-
-void Heap::FunctionObject::init(ExecutionContext *scope, const ReturnedValue name)
-{
- Object::init();
- function = nullptr;
- this->scope = scope;
- Scope s(scope->engine);
- ScopedFunctionObject f(s, this);
- ScopedString n(s, name);
- f->init(n, false);
+ Scope valueScope(scope);
+ ScopedString s(valueScope, valueScope.engine->newString(name));
+ init(scope, s, createProto);
}
void Heap::FunctionObject::init()
@@ -165,8 +130,8 @@ void FunctionObject::init(String *n, bool createProto)
*propertyData(Heap::FunctionObject::Index_Prototype) = Encode::undefined();
}
- ScopedValue v(s, n);
- defineReadonlyProperty(s.engine->id_name(), v);
+ if (n)
+ defineReadonlyProperty(s.engine->id_name(), *n);
}
ReturnedValue FunctionObject::name() const
@@ -193,34 +158,11 @@ void FunctionObject::markObjects(Heap::Base *that, ExecutionEngine *e)
Object::markObjects(that, e);
}
-Heap::FunctionObject *FunctionObject::createScriptFunction(ExecutionContext *scope, Function *function, bool createProto)
+Heap::FunctionObject *FunctionObject::createScriptFunction(ExecutionContext *scope, Function *function)
{
- if (function->needsActivation() ||
- function->compiledFunction->flags & CompiledData::Function::HasCatchOrWith ||
- function->compiledFunction->nFormals > QV4::Global::ReservedArgumentCount ||
- function->isNamedExpression())
- return scope->d()->engine->memoryManager->allocObject<ScriptFunction>(scope, function);
- return scope->d()->engine->memoryManager->allocObject<SimpleScriptFunction>(scope, function, createProto);
+ return scope->d()->engine->memoryManager->allocObject<ScriptFunction>(scope, function);
}
-Heap::FunctionObject *FunctionObject::createQmlFunction(QQmlContextData *qmlContext, QObject *scopeObject, Function *runtimeFunction, const QList<QByteArray> &signalParameters, QString *error)
-{
- ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(qmlContext->engine);
- QV4::Scope valueScope(engine);
- ExecutionContext *global = valueScope.engine->rootContext();
- QV4::Scoped<QmlContext> wrapperContext(valueScope, global->newQmlContext(qmlContext, scopeObject));
-
- if (!signalParameters.isEmpty()) {
- if (error)
- QQmlPropertyCache::signalParameterStringForJS(engine, signalParameters, error);
- runtimeFunction->updateInternalClass(engine, signalParameters);
- }
-
- QV4::ScopedFunctionObject function(valueScope, QV4::FunctionObject::createScriptFunction(wrapperContext, runtimeFunction));
- return function->d();
-}
-
-
bool FunctionObject::isBinding() const
{
return d()->vtable() == QQmlBindingFunction::staticVTable();
@@ -233,14 +175,7 @@ bool FunctionObject::isBoundFunction() const
QQmlSourceLocation FunctionObject::sourceLocation() const
{
- if (isBinding()) {
- Q_ASSERT(as<const QV4::QQmlBindingFunction>());
- return *static_cast<QV4::Heap::QQmlBindingFunction *>(d())->bindingLocation;
- }
- QV4::Function *function = d()->function;
- Q_ASSERT(function);
-
- return QQmlSourceLocation(function->sourceFile(), function->compiledFunction->location.line, function->compiledFunction->location.column);
+ return d()->function->sourceLocation();
}
DEFINE_OBJECT_VTABLE(FunctionCtor);
@@ -346,11 +281,11 @@ ReturnedValue FunctionPrototype::method_toString(CallContext *ctx)
ReturnedValue FunctionPrototype::method_apply(CallContext *ctx)
{
- Scope scope(ctx);
- ScopedFunctionObject o(scope, ctx->thisObject().as<FunctionObject>());
+ FunctionObject *o = ctx->thisObject().as<FunctionObject>();
if (!o)
return ctx->engine()->throwTypeError();
+ Scope scope(ctx);
ScopedValue arg(scope, ctx->argument(1));
ScopedObject arr(scope, arg);
@@ -367,17 +302,24 @@ ReturnedValue FunctionPrototype::method_apply(CallContext *ctx)
ScopedCallData callData(scope, len);
if (len) {
- if (arr->arrayType() != Heap::ArrayData::Simple || arr->protoHasArray()) {
- for (quint32 i = 0; i < len; ++i)
- callData->args[i] = arr->getIndexed(i);
- } else {
- uint alen = arr->arrayData() ? arr->arrayData()->len : 0;
+ if (ArgumentsObject::isNonStrictArgumentsObject(arr) && !arr->cast<ArgumentsObject>()->fullyCreated()) {
+ QV4::ArgumentsObject *a = arr->cast<ArgumentsObject>();
+ int l = qMin(len, (uint)a->d()->context->callData->argc);
+ memcpy(callData->args, a->d()->context->callData->args, l*sizeof(Value));
+ for (quint32 i = l; i < len; ++i)
+ callData->args[i] = Primitive::undefinedValue();
+ } else if (arr->arrayType() == Heap::ArrayData::Simple && !arr->protoHasArray()) {
+ auto sad = static_cast<Heap::SimpleArrayData *>(arr->arrayData());
+ uint alen = sad ? sad->len : 0;
if (alen > len)
alen = len;
for (uint i = 0; i < alen; ++i)
- callData->args[i] = static_cast<Heap::SimpleArrayData *>(arr->arrayData())->data(i);
+ callData->args[i] = sad->data(i);
for (quint32 i = alen; i < len; ++i)
callData->args[i] = Primitive::undefinedValue();
+ } else {
+ for (quint32 i = 0; i < len; ++i)
+ callData->args[i] = arr->getIndexed(i);
}
}
@@ -388,12 +330,11 @@ ReturnedValue FunctionPrototype::method_apply(CallContext *ctx)
ReturnedValue FunctionPrototype::method_call(CallContext *ctx)
{
- Scope scope(ctx);
-
- ScopedFunctionObject o(scope, ctx->thisObject().as<FunctionObject>());
+ FunctionObject *o = ctx->thisObject().as<FunctionObject>();
if (!o)
return ctx->engine()->throwTypeError();
+ Scope scope(ctx);
ScopedCallData callData(scope, ctx->argc() ? ctx->argc() - 1 : 0);
if (ctx->argc()) {
for (int i = 1; i < ctx->argc(); ++i)
@@ -407,11 +348,11 @@ ReturnedValue FunctionPrototype::method_call(CallContext *ctx)
ReturnedValue FunctionPrototype::method_bind(CallContext *ctx)
{
- Scope scope(ctx);
- ScopedFunctionObject target(scope, ctx->thisObject());
+ FunctionObject *target = ctx->thisObject().as<FunctionObject>();
if (!target)
return ctx->engine()->throwTypeError();
+ Scope scope(ctx);
ScopedValue boundThis(scope, ctx->argument(0));
Scoped<MemberData> boundArgs(scope, (Heap::MemberData *)0);
if (ctx->argc() > 1) {
@@ -426,15 +367,10 @@ ReturnedValue FunctionPrototype::method_bind(CallContext *ctx)
DEFINE_OBJECT_VTABLE(ScriptFunction);
-void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function)
-{
- Heap::SimpleScriptFunction::init(scope, function, true);
-}
-
void ScriptFunction::construct(const Managed *that, Scope &scope, CallData *callData)
{
ExecutionEngine *v4 = scope.engine;
- if (v4->hasException) {
+ if (Q_UNLIKELY(v4->hasException)) {
scope.result = Encode::undefined();
return;
}
@@ -447,17 +383,18 @@ void ScriptFunction::construct(const Managed *that, Scope &scope, CallData *call
InternalClass *ic = v4->emptyClass;
ScopedObject proto(scope, f->protoForConstructor());
ScopedObject obj(scope, v4->newObject(ic, proto));
-
callData->thisObject = obj.asReturnedValue();
- Scoped<CallContext> ctx(scope, v4->currentContext->newCallContext(f, callData));
- v4->pushContext(ctx);
- scope.result = Q_V4_PROFILE(v4, f->function());
+ QV4::Function *v4Function = f->function();
+ Q_ASSERT(v4Function);
- if (f->function()->compiledFunction->hasQmlDependencies())
- QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope);
+ ScopedContext c(scope, f->scope());
+ if (v4Function->canUseSimpleCall)
+ c->simpleCall(scope, callData, v4Function);
+ else
+ c->call(scope, callData, v4Function, f);
- if (v4->hasException) {
+ if (Q_UNLIKELY(v4->hasException)) {
scope.result = Encode::undefined();
} else if (!scope.result.isObject()) {
scope.result = obj.asReturnedValue();
@@ -467,27 +404,25 @@ void ScriptFunction::construct(const Managed *that, Scope &scope, CallData *call
void ScriptFunction::call(const Managed *that, Scope &scope, CallData *callData)
{
ExecutionEngine *v4 = scope.engine;
- if (v4->hasException) {
+ if (Q_UNLIKELY(v4->hasException)) {
scope.result = Encode::undefined();
return;
}
CHECK_STACK_LIMITS(v4, scope);
- ExecutionContextSaver ctxSaver(scope);
-
Scoped<ScriptFunction> f(scope, static_cast<const ScriptFunction *>(that));
- Scoped<CallContext> ctx(scope, v4->currentContext->newCallContext(f, callData));
- v4->pushContext(ctx);
- scope.result = Q_V4_PROFILE(v4, f->function());
+ QV4::Function *v4Function = f->function();
+ Q_ASSERT(v4Function);
- if (f->function()->compiledFunction->hasQmlDependencies())
- QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope);
+ ScopedContext c(scope, f->scope());
+ if (v4Function->canUseSimpleCall)
+ c->simpleCall(scope, callData, v4Function);
+ else
+ c->call(scope, callData, v4Function, f);
}
-DEFINE_OBJECT_VTABLE(SimpleScriptFunction);
-
-void Heap::SimpleScriptFunction::init(QV4::ExecutionContext *scope, Function *function, bool createProto)
+void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function)
{
FunctionObject::init();
this->scope = scope->d();
@@ -500,16 +435,10 @@ void Heap::SimpleScriptFunction::init(QV4::ExecutionContext *scope, Function *fu
Scope s(scope);
ScopedFunctionObject f(s, this);
- if (createProto) {
- ScopedString name(s, function->name());
- f->init(name, createProto);
- f->defineReadonlyProperty(scope->d()->engine->id_length(), Primitive::fromInt32(f->formalParameterCount()));
- } else {
- Q_ASSERT(internalClass && internalClass->find(s.engine->id_length()) == Index_Length);
- Q_ASSERT(internalClass && internalClass->find(s.engine->id_name()) == Index_Name);
- *propertyData(Index_Name) = function->name();
- *propertyData(Index_Length) = Primitive::fromInt32(f->formalParameterCount());
- }
+ ScopedString name(s, function->name());
+ f->init(name, true);
+ Q_ASSERT(internalClass && internalClass->find(s.engine->id_length()) == Index_Length);
+ *propertyData(Index_Length) = Primitive::fromInt32(f->formalParameterCount());
if (scope->d()->strictMode) {
ScopedProperty pd(s);
@@ -520,89 +449,12 @@ void Heap::SimpleScriptFunction::init(QV4::ExecutionContext *scope, Function *fu
}
}
-void SimpleScriptFunction::construct(const Managed *that, Scope &scope, CallData *callData)
-{
- ExecutionEngine *v4 = scope.engine;
- if (v4->hasException) {
- scope.result = Encode::undefined();
- return;
- }
- CHECK_STACK_LIMITS(v4, scope);
-
- ExecutionContextSaver ctxSaver(scope);
-
- Scoped<SimpleScriptFunction> f(scope, static_cast<const SimpleScriptFunction *>(that));
-
- InternalClass *ic = scope.engine->emptyClass;
- ScopedObject proto(scope, f->protoForConstructor());
- callData->thisObject = v4->newObject(ic, proto);
-
- CallContext::Data ctx = CallContext::Data::createOnStack(v4);
- ctx.strictMode = f->strictMode();
- ctx.callData = callData;
- ctx.function = f->d();
- ctx.compilationUnit = f->function()->compilationUnit;
- ctx.lookups = ctx.compilationUnit->runtimeLookups;
- ctx.constantTable = ctx.compilationUnit->constants;
- ctx.outer = f->scope();
- ctx.locals = scope.alloc(f->varCount());
- for (int i = callData->argc; i < (int)f->formalParameterCount(); ++i)
- callData->args[i] = Encode::undefined();
- v4->pushContext(&ctx);
- Q_ASSERT(v4->current == &ctx);
-
- scope.result = Q_V4_PROFILE(v4, f->function());
-
- if (f->function()->compiledFunction->hasQmlDependencies())
- QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope);
-
- if (v4->hasException) {
- scope.result = Encode::undefined();
- } else if (!scope.result.isObject()) {
- scope.result = callData->thisObject;
- }
-}
-
-void SimpleScriptFunction::call(const Managed *that, Scope &scope, CallData *callData)
-{
- ExecutionEngine *v4 = scope.engine;
- if (v4->hasException) {
- scope.result = Encode::undefined();
- return;
- }
- CHECK_STACK_LIMITS(v4, scope);
-
- ExecutionContextSaver ctxSaver(scope);
-
- Scoped<SimpleScriptFunction> f(scope, static_cast<const SimpleScriptFunction *>(that));
-
- CallContext::Data ctx = CallContext::Data::createOnStack(v4);
- ctx.strictMode = f->strictMode();
- ctx.callData = callData;
- ctx.function = f->d();
- ctx.compilationUnit = f->function()->compilationUnit;
- ctx.lookups = ctx.compilationUnit->runtimeLookups;
- ctx.constantTable = ctx.compilationUnit->constants;
- ctx.outer = f->scope();
- ctx.locals = scope.alloc(f->varCount());
- for (int i = callData->argc; i < (int)f->formalParameterCount(); ++i)
- callData->args[i] = Encode::undefined();
- v4->pushContext(&ctx);
- Q_ASSERT(v4->current == &ctx);
-
- scope.result = Q_V4_PROFILE(v4, f->function());
-
- if (f->function()->compiledFunction->hasQmlDependencies())
- QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope);
-}
-
-Heap::Object *SimpleScriptFunction::protoForConstructor()
+Heap::Object *ScriptFunction::protoForConstructor() const
{
- Scope scope(engine());
- ScopedObject p(scope, protoProperty());
- if (p)
- return p->d();
- return scope.engine->objectPrototype()->d();
+ const Object *o = d()->protoProperty();
+ if (o)
+ return o->d();
+ return engine()->objectPrototype()->d();
}
diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h
index e58b83e2c3..a02e89e883 100644
--- a/src/qml/jsruntime/qv4functionobject_p.h
+++ b/src/qml/jsruntime/qv4functionobject_p.h
@@ -69,12 +69,9 @@ struct Q_QML_PRIVATE_EXPORT FunctionObject : Object {
Index_ProtoConstructor = 0
};
- void init(QV4::ExecutionContext *scope, QV4::String *name, bool createProto = false);
+ void init(QV4::ExecutionContext *scope, QV4::String *name = 0, bool createProto = false);
void init(QV4::ExecutionContext *scope, QV4::Function *function, bool createProto = false);
- void init(QV4::ExecutionContext *scope, const QString &name = QString(), bool createProto = false);
- void init(ExecutionContext *scope, const QString &name = QString(), bool createProto = false);
- void init(QV4::ExecutionContext *scope, const ReturnedValue name);
- void init(ExecutionContext *scope, const ReturnedValue name);
+ void init(QV4::ExecutionContext *scope, const QString &name, bool createProto = false);
void init();
void destroy();
@@ -82,6 +79,8 @@ struct Q_QML_PRIVATE_EXPORT FunctionObject : Object {
unsigned int varCount() { return function ? function->compiledFunction->nLocals : 0; }
bool needsActivation() const { return function ? function->needsActivation() : false; }
+ const QV4::Object *protoProperty() const { return propertyData(Index_Prototype)->cast<QV4::Object>(); }
+
Pointer<ExecutionContext> scope;
Function *function;
};
@@ -105,15 +104,11 @@ struct IndexedBuiltinFunction : FunctionObject {
uint index;
};
-struct SimpleScriptFunction : FunctionObject {
+struct ScriptFunction : FunctionObject {
enum {
Index_Name = FunctionObject::Index_Prototype + 1,
Index_Length
};
- void init(QV4::ExecutionContext *scope, Function *function, bool createProto);
-};
-
-struct ScriptFunction : SimpleScriptFunction {
void init(QV4::ExecutionContext *scope, Function *function);
};
@@ -150,11 +145,7 @@ struct Q_QML_EXPORT FunctionObject: Object {
static void construct(const Managed *that, Scope &scope, CallData *);
static void call(const Managed *that, Scope &scope, CallData *d);
- static Heap::FunctionObject *createScriptFunction(ExecutionContext *scope, Function *function, bool createProto = true);
- static Heap::FunctionObject *createQmlFunction(QQmlContextData *qmlContext, QObject *scopeObject, QV4::Function *runtimeFunction,
- const QList<QByteArray> &signalParameters = QList<QByteArray>(), QString *error = 0);
-
- ReturnedValue protoProperty() { return propertyData(Heap::FunctionObject::Index_Prototype)->asReturnedValue(); }
+ static Heap::FunctionObject *createScriptFunction(ExecutionContext *scope, Function *function);
bool needsActivation() const { return d()->needsActivation(); }
bool strictMode() const { return d()->function ? d()->function->isStrict() : false; }
@@ -168,7 +159,7 @@ struct Q_QML_EXPORT FunctionObject: Object {
template<>
inline const FunctionObject *Value::as() const {
- return isManaged() && m() && m()->vtable()->isFunctionObject ? reinterpret_cast<const FunctionObject *>(this) : 0;
+ return isManaged() && m()->vtable()->isFunctionObject ? reinterpret_cast<const FunctionObject *>(this) : 0;
}
@@ -225,21 +216,14 @@ void Heap::IndexedBuiltinFunction::init(QV4::ExecutionContext *scope, uint index
}
-struct SimpleScriptFunction: FunctionObject {
- V4_OBJECT2(SimpleScriptFunction, FunctionObject)
- V4_INTERNALCLASS(simpleScriptFunctionClass)
-
- static void construct(const Managed *, Scope &scope, CallData *callData);
- static void call(const Managed *that, Scope &scope, CallData *callData);
-
- Heap::Object *protoForConstructor();
-};
-
-struct ScriptFunction: SimpleScriptFunction {
+struct ScriptFunction : FunctionObject {
V4_OBJECT2(ScriptFunction, FunctionObject)
+ V4_INTERNALCLASS(scriptFunctionClass)
static void construct(const Managed *, Scope &scope, CallData *callData);
static void call(const Managed *that, Scope &scope, CallData *callData);
+
+ Heap::Object *protoForConstructor() const;
};
diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h
index 184375a9b6..c37ad1668d 100644
--- a/src/qml/jsruntime/qv4global_p.h
+++ b/src/qml/jsruntime/qv4global_p.h
@@ -58,6 +58,12 @@
#include <QtCore/qglobal.h>
#include <QString>
+#ifdef QT_NO_DEBUG
+#define QML_NEARLY_ALWAYS_INLINE Q_ALWAYS_INLINE
+#else
+#define QML_NEARLY_ALWAYS_INLINE inline
+#endif
+
#ifdef V4_BOOTSTRAP
#include <private/qtqmldevtoolsglobal_p.h>
#else
diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp
index feb0d90d26..af92ce1ad8 100644
--- a/src/qml/jsruntime/qv4globalobject.cpp
+++ b/src/qml/jsruntime/qv4globalobject.cpp
@@ -357,12 +357,13 @@ void EvalFunction::evalCall(Scope &scope, CallData *callData, bool directCall) c
ctx = v4->pushGlobalContext();
}
- if (!callData->args[0].isString()) {
+ String *scode = callData->args[0].stringValue();
+ if (!scode) {
scope.result = callData->args[0].asReturnedValue();
return;
}
- const QString code = callData->args[0].stringValue()->toQString();
+ const QString code = scode->toQString();
bool inheritContext = !ctx->d()->strictMode;
Script script(ctx, code, QStringLiteral("eval code"));
diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp
index be8057e9f5..1d393cf0aa 100644
--- a/src/qml/jsruntime/qv4include.cpp
+++ b/src/qml/jsruntime/qv4include.cpp
@@ -53,7 +53,6 @@
#include <private/qv4functionobject_p.h>
#include <private/qv4script_p.h>
#include <private/qv4context_p.h>
-#include <private/qqmlcontextwrapper_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp
index 94a6e4daa1..d79e6242ba 100644
--- a/src/qml/jsruntime/qv4jsonobject.cpp
+++ b/src/qml/jsruntime/qv4jsonobject.cpp
@@ -727,8 +727,8 @@ QString Stringify::Str(const QString &key, const Value &v)
return QStringLiteral("null");
if (scope.result.isBoolean())
return scope.result.booleanValue() ? QStringLiteral("true") : QStringLiteral("false");
- if (scope.result.isString())
- return quote(scope.result.stringValue()->toQString());
+ if (String *s = scope.result.stringValue())
+ return quote(s->toQString());
if (scope.result.isNumber()) {
double d = scope.result.toNumber();
@@ -917,7 +917,7 @@ ReturnedValue JsonObject::method_stringify(CallContext *ctx)
Value *v = stringify.propertyList + i;
*v = o->getIndexed(i);
if (v->as<NumberObject>() || v->as<StringObject>() || v->isNumber())
- *v = RuntimeHelpers::toString(scope.engine, *v);
+ *v = v->toString(scope.engine);
if (!v->isString()) {
v->setM(0);
} else {
@@ -940,8 +940,8 @@ ReturnedValue JsonObject::method_stringify(CallContext *ctx)
if (s->isNumber()) {
stringify.gap = QString(qMin(10, (int)s->toInteger()), ' ');
- } else if (s->isString()) {
- stringify.gap = s->stringValue()->toQString().left(10);
+ } else if (String *str = s->stringValue()) {
+ stringify.gap = str->toQString().left(10);
}
@@ -982,8 +982,8 @@ QJsonValue JsonObject::toJsonValue(const Value &value, V4ObjectSet &visitedObjec
return QJsonValue(QJsonValue::Null);
else if (value.isUndefined())
return QJsonValue(QJsonValue::Undefined);
- else if (value.isString())
- return QJsonValue(value.toQString());
+ else if (String *s = value.stringValue())
+ return QJsonValue(s->toQString());
Q_ASSERT(value.isObject());
Scope scope(value.as<Object>()->engine());
diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp
index 84755a6402..52ed449664 100644
--- a/src/qml/jsruntime/qv4lookup.cpp
+++ b/src/qml/jsruntime/qv4lookup.cpp
@@ -118,7 +118,8 @@ ReturnedValue Lookup::lookup(const Object *thisObject, PropertyAttributes *attrs
ReturnedValue Lookup::indexedGetterGeneric(Lookup *l, const Value &object, const Value &index)
{
- if (object.isObject() && index.asArrayIndex() < UINT_MAX) {
+ uint idx;
+ if (object.isObject() && index.asArrayIndex(idx)) {
l->indexedGetter = indexedGetterObjectInt;
return indexedGetterObjectInt(l, object, index);
}
@@ -129,11 +130,12 @@ ReturnedValue Lookup::indexedGetterFallback(Lookup *l, const Value &object, cons
{
Q_UNUSED(l);
Scope scope(l->engine);
- uint idx = index.asArrayIndex();
+ uint idx = 0;
+ bool isInt = index.asArrayIndex(idx);
ScopedObject o(scope, object);
if (!o) {
- if (idx < UINT_MAX) {
+ if (isInt) {
if (const String *str = object.as<String>()) {
if (idx >= (uint)str->toQString().length()) {
return Encode::undefined();
@@ -153,7 +155,7 @@ ReturnedValue Lookup::indexedGetterFallback(Lookup *l, const Value &object, cons
return Encode::undefined();
}
- if (idx < UINT_MAX) {
+ if (isInt) {
if (o->d()->arrayData && !o->d()->arrayData->attrs) {
ScopedValue v(scope, Scoped<ArrayData>(scope, o->arrayData())->get(idx));
if (!v->isEmpty())
@@ -173,16 +175,19 @@ ReturnedValue Lookup::indexedGetterFallback(Lookup *l, const Value &object, cons
ReturnedValue Lookup::indexedGetterObjectInt(Lookup *l, const Value &object, const Value &index)
{
- uint idx = index.asArrayIndex();
- if (idx == UINT_MAX || !object.isObject())
- return indexedGetterFallback(l, object, index);
-
- Object *o = object.objectValue();
- if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) {
- Heap::SimpleArrayData *s = o->d()->arrayData.cast<Heap::SimpleArrayData>();
- if (idx < s->len)
- if (!s->data(idx).isEmpty())
- return s->data(idx).asReturnedValue();
+ uint idx;
+ if (index.asArrayIndex(idx)) {
+ if (Heap::Base *b = object.heapObject()) {
+ if (b->vtable()->isObject) {
+ Heap::Object *o = static_cast<Heap::Object *>(b);
+ if (o->arrayData && o->arrayData->type == Heap::ArrayData::Simple) {
+ Heap::SimpleArrayData *s = o->arrayData.cast<Heap::SimpleArrayData>();
+ if (idx < s->len)
+ if (!s->data(idx).isEmpty())
+ return s->data(idx).asReturnedValue();
+ }
+ }
+ }
}
return indexedGetterFallback(l, object, index);
@@ -190,9 +195,9 @@ ReturnedValue Lookup::indexedGetterObjectInt(Lookup *l, const Value &object, con
void Lookup::indexedSetterGeneric(Lookup *l, const Value &object, const Value &index, const Value &v)
{
- if (object.isObject()) {
- Object *o = object.objectValue();
- if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple && index.asArrayIndex() < UINT_MAX) {
+ if (Object *o = object.objectValue()) {
+ uint idx;
+ if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple && index.asArrayIndex(idx)) {
l->indexedSetter = indexedSetterObjectInt;
indexedSetterObjectInt(l, object, index, v);
return;
@@ -208,8 +213,8 @@ void Lookup::indexedSetterFallback(Lookup *l, const Value &object, const Value &
if (scope.engine->hasException)
return;
- uint idx = index.asArrayIndex();
- if (idx < UINT_MAX) {
+ uint idx;
+ if (index.asArrayIndex(idx)) {
if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) {
Heap::SimpleArrayData *s = o->d()->arrayData.cast<Heap::SimpleArrayData>();
if (idx < s->len) {
@@ -227,18 +232,19 @@ void Lookup::indexedSetterFallback(Lookup *l, const Value &object, const Value &
void Lookup::indexedSetterObjectInt(Lookup *l, const Value &object, const Value &index, const Value &v)
{
- uint idx = index.asArrayIndex();
- if (idx == UINT_MAX || !object.isObject()) {
- indexedSetterGeneric(l, object, index, v);
- return;
- }
-
- Object *o = object.objectValue();
- if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) {
- Heap::SimpleArrayData *s = o->d()->arrayData.cast<Heap::SimpleArrayData>();
- if (idx < s->len) {
- s->data(idx) = v;
- return;
+ uint idx;
+ if (index.asArrayIndex(idx)) {
+ if (Heap::Base *b = object.heapObject()) {
+ if (b->vtable()->isObject) {
+ Heap::Object *o = static_cast<Heap::Object *>(b);
+ if (o->arrayData && o->arrayData->type == Heap::ArrayData::Simple) {
+ Heap::SimpleArrayData *s = o->arrayData.cast<Heap::SimpleArrayData>();
+ if (idx < s->len) {
+ s->data(idx) = v;
+ return;
+ }
+ }
+ }
}
}
indexedSetterFallback(l, object, index, v);
@@ -345,11 +351,11 @@ ReturnedValue Lookup::getterFallback(Lookup *l, ExecutionEngine *engine, const V
ReturnedValue Lookup::getter0(Lookup *l, ExecutionEngine *engine, const Value &object)
{
- if (object.isManaged()) {
- // we can safely cast to a QV4::Object here. If object is actually a string,
- // the internal class won't match
- Object *o = object.objectValue();
- if (l->classList[0] == o->internalClass())
+ // we can safely cast to a QV4::Object here. If object is actually a string,
+ // the internal class won't match
+ Heap::Object *o = static_cast<Heap::Object *>(object.heapObject());
+ if (o) {
+ if (l->classList[0] == o->internalClass)
return o->propertyData(l->index)->asReturnedValue();
}
return getterTwoClasses(l, engine, object);
@@ -357,25 +363,24 @@ ReturnedValue Lookup::getter0(Lookup *l, ExecutionEngine *engine, const Value &o
ReturnedValue Lookup::getter1(Lookup *l, ExecutionEngine *engine, const Value &object)
{
- if (object.isManaged()) {
- // we can safely cast to a QV4::Object here. If object is actually a string,
- // the internal class won't match
- Object *o = object.objectValue();
- if (l->classList[0] == o->internalClass() &&
- l->classList[1] == o->prototype()->internalClass)
- return o->prototype()->propertyData(l->index)->asReturnedValue();
+ // we can safely cast to a QV4::Object here. If object is actually a string,
+ // the internal class won't match
+ Heap::Object *o = static_cast<Heap::Object *>(object.heapObject());
+ if (o) {
+ if (l->classList[0] == o->internalClass && l->classList[1] == o->prototype->internalClass)
+ return o->prototype->propertyData(l->index)->asReturnedValue();
}
return getterTwoClasses(l, engine, object);
}
ReturnedValue Lookup::getter2(Lookup *l, ExecutionEngine *engine, const Value &object)
{
- if (object.isManaged()) {
- // we can safely cast to a QV4::Object here. If object is actually a string,
- // the internal class won't match
- Object *o = object.objectValue();
- if (l->classList[0] == o->internalClass()) {
- Heap::Object *p = o->prototype();
+ // we can safely cast to a QV4::Object here. If object is actually a string,
+ // the internal class won't match
+ Heap::Object *o = static_cast<Heap::Object *>(object.heapObject());
+ if (o) {
+ if (l->classList[0] == o->internalClass) {
+ Heap::Object *p = o->prototype;
if (l->classList[1] == p->internalClass) {
p = p->prototype;
if (l->classList[2] == p->internalClass)
@@ -389,13 +394,13 @@ ReturnedValue Lookup::getter2(Lookup *l, ExecutionEngine *engine, const Value &o
ReturnedValue Lookup::getter0getter0(Lookup *l, ExecutionEngine *engine, const Value &object)
{
- if (object.isManaged()) {
- // we can safely cast to a QV4::Object here. If object is actually a string,
- // the internal class won't match
- Object *o = object.objectValue();
- if (l->classList[0] == o->internalClass())
+ // we can safely cast to a QV4::Object here. If object is actually a string,
+ // the internal class won't match
+ Heap::Object *o = static_cast<Heap::Object *>(object.heapObject());
+ if (o) {
+ if (l->classList[0] == o->internalClass)
return o->propertyData(l->index)->asReturnedValue();
- if (l->classList[2] == o->internalClass())
+ if (l->classList[2] == o->internalClass)
return o->propertyData(l->index2)->asReturnedValue();
}
l->getter = getterFallback;
@@ -404,15 +409,14 @@ ReturnedValue Lookup::getter0getter0(Lookup *l, ExecutionEngine *engine, const V
ReturnedValue Lookup::getter0getter1(Lookup *l, ExecutionEngine *engine, const Value &object)
{
- if (object.isManaged()) {
- // we can safely cast to a QV4::Object here. If object is actually a string,
- // the internal class won't match
- Object *o = object.objectValue();
- if (l->classList[0] == o->internalClass())
+ // we can safely cast to a QV4::Object here. If object is actually a string,
+ // the internal class won't match
+ Heap::Object *o = static_cast<Heap::Object *>(object.heapObject());
+ if (o) {
+ if (l->classList[0] == o->internalClass)
return o->propertyData(l->index)->asReturnedValue();
- if (l->classList[2] == o->internalClass() &&
- l->classList[3] == o->prototype()->internalClass)
- return o->prototype()->propertyData(l->index2)->asReturnedValue();
+ if (l->classList[2] == o->internalClass && l->classList[3] == o->prototype->internalClass)
+ return o->prototype->propertyData(l->index2)->asReturnedValue();
}
l->getter = getterFallback;
return getterFallback(l, engine, object);
@@ -420,16 +424,16 @@ ReturnedValue Lookup::getter0getter1(Lookup *l, ExecutionEngine *engine, const V
ReturnedValue Lookup::getter1getter1(Lookup *l, ExecutionEngine *engine, const Value &object)
{
- if (object.isManaged()) {
- // we can safely cast to a QV4::Object here. If object is actually a string,
- // the internal class won't match
- Object *o = object.objectValue();
- if (l->classList[0] == o->internalClass() &&
- l->classList[1] == o->prototype()->internalClass)
- return o->prototype()->propertyData(l->index)->asReturnedValue();
- if (l->classList[2] == o->internalClass() &&
- l->classList[3] == o->prototype()->internalClass)
- return o->prototype()->propertyData(l->index2)->asReturnedValue();
+ // we can safely cast to a QV4::Object here. If object is actually a string,
+ // the internal class won't match
+ Heap::Object *o = static_cast<Heap::Object *>(object.heapObject());
+ if (o) {
+ if (l->classList[0] == o->internalClass &&
+ l->classList[1] == o->prototype->internalClass)
+ return o->prototype->propertyData(l->index)->asReturnedValue();
+ if (l->classList[2] == o->internalClass &&
+ l->classList[3] == o->prototype->internalClass)
+ return o->prototype->propertyData(l->index2)->asReturnedValue();
return getterFallback(l, engine, object);
}
l->getter = getterFallback;
@@ -439,12 +443,12 @@ ReturnedValue Lookup::getter1getter1(Lookup *l, ExecutionEngine *engine, const V
ReturnedValue Lookup::getterAccessor0(Lookup *l, ExecutionEngine *engine, const Value &object)
{
- if (object.isManaged()) {
- // we can safely cast to a QV4::Object here. If object is actually a string,
- // the internal class won't match
- Object *o = object.objectValue();
- if (l->classList[0] == o->internalClass()) {
- Scope scope(o->engine());
+ // we can safely cast to a QV4::Object here. If object is actually a string,
+ // the internal class won't match
+ Heap::Object *o = static_cast<Heap::Object *>(object.heapObject());
+ if (o) {
+ if (l->classList[0] == o->internalClass) {
+ Scope scope(o->internalClass->engine);
ScopedFunctionObject getter(scope, o->propertyData(l->index + Object::GetterOffset));
if (!getter)
return Encode::undefined();
@@ -461,10 +465,10 @@ ReturnedValue Lookup::getterAccessor0(Lookup *l, ExecutionEngine *engine, const
ReturnedValue Lookup::getterAccessor1(Lookup *l, ExecutionEngine *engine, const Value &object)
{
- if (object.isManaged()) {
- // we can safely cast to a QV4::Object here. If object is actually a string,
- // the internal class won't match
- Heap::Object *o = object.objectValue()->d();
+ // we can safely cast to a QV4::Object here. If object is actually a string,
+ // the internal class won't match
+ Heap::Object *o = static_cast<Heap::Object *>(object.heapObject());
+ if (o) {
if (l->classList[0] == o->internalClass &&
l->classList[1] == o->prototype->internalClass) {
Scope scope(o->internalClass->engine);
@@ -484,10 +488,10 @@ ReturnedValue Lookup::getterAccessor1(Lookup *l, ExecutionEngine *engine, const
ReturnedValue Lookup::getterAccessor2(Lookup *l, ExecutionEngine *engine, const Value &object)
{
- if (object.isManaged()) {
- // we can safely cast to a QV4::Object here. If object is actually a string,
- // the internal class won't match
- Heap::Object *o = object.objectValue()->d();
+ // we can safely cast to a QV4::Object here. If object is actually a string,
+ // the internal class won't match
+ Heap::Object *o = static_cast<Heap::Object *>(object.heapObject());
+ if (o) {
if (l->classList[0] == o->internalClass) {
o = o->prototype;
if (l->classList[1] == o->internalClass) {
diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h
index 1fff5a45da..5c764e7ff0 100644
--- a/src/qml/jsruntime/qv4managed_p.h
+++ b/src/qml/jsruntime/qv4managed_p.h
@@ -107,13 +107,20 @@ inline void qYouForgotTheQ_MANAGED_Macro(T1, T2) {}
(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
+#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
+#elif defined(Q_CC_CLANG) && Q_CC_CLANG >= 306
+#define QT_WARNING_SUPPRESS_GCC_TAUTOLOGICAL_COMPARE_ON \
+ QT_WARNING_PUSH; \
+ QT_WARNING_DISABLE_CLANG("-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
@@ -199,6 +206,18 @@ public:
bool markBit() const { return d()->isMarked(); }
static void destroy(Heap::Base *) {}
+
+ Q_ALWAYS_INLINE Heap::Base *heapObject() const {
+ return m();
+ }
+
+ template<typename T> inline T *cast() {
+ return static_cast<T *>(this);
+ }
+ template<typename T> inline const T *cast() const {
+ return static_cast<const T *>(this);
+ }
+
private:
friend class MemoryManager;
friend struct Identifiers;
@@ -208,14 +227,12 @@ private:
template<>
inline const Managed *Value::as() const {
- if (isManaged())
- return managed();
- return 0;
+ return managed();
}
template<>
inline const Object *Value::as() const {
- return isManaged() && m() && m()->vtable()->isObject ? objectValue() : 0;
+ return objectValue();
}
}
diff --git a/src/qml/jsruntime/qv4memberdata.cpp b/src/qml/jsruntime/qv4memberdata.cpp
index 5646a44891..d5f75415cc 100644
--- a/src/qml/jsruntime/qv4memberdata.cpp
+++ b/src/qml/jsruntime/qv4memberdata.cpp
@@ -52,30 +52,16 @@ void MemberData::markObjects(Heap::Base *that, ExecutionEngine *e)
m->data[i].mark(e);
}
-static Heap::MemberData *reallocateHelper(ExecutionEngine *e, Heap::MemberData *old, uint n)
+Heap::MemberData *MemberData::allocate(ExecutionEngine *e, uint n, Heap::MemberData *old)
{
+ Q_ASSERT(!old || old->size < n);
+
uint alloc = sizeof(Heap::MemberData) + (n)*sizeof(Value);
- Scope scope(e);
- Scoped<MemberData> newMemberData(scope, e->memoryManager->allocManaged<MemberData>(alloc));
+ Heap::MemberData *m = e->memoryManager->allocManaged<MemberData>(alloc);
if (old)
- memcpy(newMemberData->d_unchecked(), old, sizeof(Heap::MemberData) + old->size * sizeof(Value));
+ memcpy(m, old, sizeof(Heap::MemberData) + old->size * sizeof(Value));
else
- newMemberData->d_unchecked()->init();
- newMemberData->d()->size = n;
- return newMemberData->d();
-}
-
-Heap::MemberData *MemberData::allocate(ExecutionEngine *e, uint n)
-{
- return reallocateHelper(e, 0, n);
-}
-
-Heap::MemberData *MemberData::reallocate(ExecutionEngine *e, Heap::MemberData *old, uint n)
-{
- uint s = old ? old->size : 0;
- if (n < s)
- return old;
-
- // n is multiplied by two to leave room for growth
- return reallocateHelper(e, old, qMax((uint)4, 2*n));
+ m->init();
+ m->size = n;
+ return m;
}
diff --git a/src/qml/jsruntime/qv4memberdata_p.h b/src/qml/jsruntime/qv4memberdata_p.h
index 969eee3619..5c89dfe8ec 100644
--- a/src/qml/jsruntime/qv4memberdata_p.h
+++ b/src/qml/jsruntime/qv4memberdata_p.h
@@ -79,8 +79,7 @@ struct MemberData : Managed
Value *data() { return d()->data; }
inline uint size() const { return d()->size; }
- static Heap::MemberData *allocate(QV4::ExecutionEngine *e, uint n);
- static Heap::MemberData *reallocate(QV4::ExecutionEngine *e, Heap::MemberData *old, uint n);
+ static Heap::MemberData *allocate(QV4::ExecutionEngine *e, uint n, Heap::MemberData *old = 0);
static void markObjects(Heap::Base *that, ExecutionEngine *e);
};
diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp
index 9b1f72bc17..3a6b9da763 100644
--- a/src/qml/jsruntime/qv4numberobject.cpp
+++ b/src/qml/jsruntime/qv4numberobject.cpp
@@ -285,7 +285,7 @@ ReturnedValue NumberPrototype::method_toPrecision(CallContext *ctx)
return Encode::undefined();
if (!ctx->argc() || ctx->args()[0].isUndefined())
- return RuntimeHelpers::toString(scope.engine, v);
+ return Encode(v->toString(scope.engine));
int precision = ctx->args()[0].toInt32();
if (precision < 1 || precision > 21) {
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index 00e6d230da..8acca16dd0 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -61,7 +61,9 @@ DEFINE_OBJECT_VTABLE(Object);
void Object::setInternalClass(InternalClass *ic)
{
d()->internalClass = ic;
- ensureMemberData();
+ if ((ic->size > d()->inlineMemberSize && !d()->memberData) ||
+ (d()->memberData && d()->memberData->size < ic->size - d()->inlineMemberSize))
+ d()->memberData = MemberData::allocate(ic->engine, ic->size - d()->inlineMemberSize, d()->memberData);
}
void Object::getProperty(uint index, Property *p, PropertyAttributes *attrs) const
@@ -225,13 +227,6 @@ void Object::markObjects(Heap::Base *that, ExecutionEngine *e)
o->prototype->mark(e);
}
-void Object::ensureMemberData()
-{
- QV4::InternalClass *ic = internalClass();
- if (ic->size > d()->inlineMemberSize)
- d()->memberData = MemberData::reallocate(ic->engine, d()->memberData, ic->size - d()->inlineMemberSize);
-}
-
void Object::insertMember(String *s, const Property *p, PropertyAttributes attributes)
{
uint idx;
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h
index 161c7746da..6c679deb10 100644
--- a/src/qml/jsruntime/qv4object_p.h
+++ b/src/qml/jsruntime/qv4object_p.h
@@ -58,8 +58,6 @@
#include "qv4value_p.h"
#include "qv4internalclass_p.h"
-#include <type_traits>
-
QT_BEGIN_NAMESPACE
@@ -147,7 +145,7 @@ struct ObjectVTable
#define DEFINE_OBJECT_VTABLE_BASE(classname) \
const QV4::ObjectVTable classname::static_vtbl = \
{ \
- DEFINE_MANAGED_VTABLE_INT(classname, (std::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) ? nullptr : &classname::SuperClass::static_vtbl.vTable), \
call, \
construct, \
get, \
@@ -369,8 +367,6 @@ protected:
static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes);
static uint getLength(const Managed *m);
- void ensureMemberData();
-
private:
ReturnedValue internalGet(String *name, bool *hasProperty) const;
ReturnedValue internalGetIndexed(uint index, bool *hasProperty) const;
@@ -502,7 +498,7 @@ inline void Object::arraySet(uint index, const Value &value)
template<>
inline const ArrayObject *Value::as() const {
- return isManaged() && m() && m()->vtable()->type == Managed::Type_ArrayObject ? static_cast<const ArrayObject *>(this) : 0;
+ return isManaged() && m()->vtable()->type == Managed::Type_ArrayObject ? static_cast<const ArrayObject *>(this) : 0;
}
#ifndef V4_BOOTSTRAP
diff --git a/src/qml/jsruntime/qv4objectiterator.cpp b/src/qml/jsruntime/qv4objectiterator.cpp
index 7943a13ac0..59115dfe21 100644
--- a/src/qml/jsruntime/qv4objectiterator.cpp
+++ b/src/qml/jsruntime/qv4objectiterator.cpp
@@ -70,15 +70,16 @@ void ObjectIterator::next(Value *name, uint *index, Property *pd, PropertyAttrib
ScopedString n(scope);
while (1) {
- if (!current->as<Object>())
+ Object *co = current->objectValue();
+ if (!co)
break;
while (1) {
- current->as<Object>()->advanceIterator(this, name, index, pd, attrs);
+ co->advanceIterator(this, name, index, pd, attrs);
if (attrs->isEmpty())
break;
// check the property is not already defined earlier in the proto chain
- if (current->heapObject() != object->heapObject()) {
+ if (co->heapObject() != object->heapObject()) {
o = object->as<Object>();
n = *name;
bool shadowed = false;
@@ -97,7 +98,7 @@ void ObjectIterator::next(Value *name, uint *index, Property *pd, PropertyAttrib
}
if (flags & WithProtoChain)
- current->setM(current->objectValue()->prototype());
+ current->setM(co->prototype());
else
current->setM(0);
@@ -109,7 +110,8 @@ void ObjectIterator::next(Value *name, uint *index, Property *pd, PropertyAttrib
ReturnedValue ObjectIterator::nextPropertyName(Value *value)
{
- if (!object->as<Object>())
+ Object *o = object->objectValue();
+ if (!o)
return Encode::null();
PropertyAttributes attrs;
@@ -121,7 +123,7 @@ ReturnedValue ObjectIterator::nextPropertyName(Value *value)
if (attrs.isEmpty())
return Encode::null();
- *value = object->objectValue()->getValue(p->value, attrs);
+ *value = o->getValue(p->value, attrs);
if (!!name)
return name->asReturnedValue();
@@ -131,7 +133,8 @@ ReturnedValue ObjectIterator::nextPropertyName(Value *value)
ReturnedValue ObjectIterator::nextPropertyNameAsString(Value *value)
{
- if (!object->as<Object>())
+ Object *o = object->objectValue();
+ if (!o)
return Encode::null();
PropertyAttributes attrs;
@@ -143,7 +146,7 @@ ReturnedValue ObjectIterator::nextPropertyNameAsString(Value *value)
if (attrs.isEmpty())
return Encode::null();
- *value = object->objectValue()->getValue(p->value, attrs);
+ *value = o->getValue(p->value, attrs);
if (!!name)
return name->asReturnedValue();
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp
index 6020c48250..8191083544 100644
--- a/src/qml/jsruntime/qv4objectproto.cpp
+++ b/src/qml/jsruntime/qv4objectproto.cpp
@@ -62,26 +62,24 @@ void Heap::ObjectCtor::init(QV4::ExecutionContext *scope)
void ObjectCtor::construct(const Managed *that, Scope &scope, CallData *callData)
{
const ObjectCtor *ctor = static_cast<const ObjectCtor *>(that);
- ExecutionEngine *v4 = ctor->engine();
if (!callData->argc || callData->args[0].isUndefined() || callData->args[0].isNull()) {
- ScopedObject obj(scope, v4->newObject());
- ScopedObject proto(scope, ctor->get(v4->id_prototype()));
+ ScopedObject obj(scope, scope.engine->newObject());
+ ScopedObject proto(scope, ctor->get(scope.engine->id_prototype()));
if (!!proto)
obj->setPrototype(proto);
scope.result = obj.asReturnedValue();
} else {
- scope.result = RuntimeHelpers::toObject(scope.engine, callData->args[0]);
+ scope.result = callData->args[0].toObject(scope.engine);
}
}
-void ObjectCtor::call(const Managed *m, Scope &scope, CallData *callData)
+void ObjectCtor::call(const Managed *, Scope &scope, CallData *callData)
{
- const ObjectCtor *ctor = static_cast<const ObjectCtor *>(m);
- ExecutionEngine *v4 = ctor->engine();
+ ExecutionEngine *v4 = scope.engine;
if (!callData->argc || callData->args[0].isUndefined() || callData->args[0].isNull()) {
scope.result = v4->newObject()->asReturnedValue();
} else {
- scope.result = RuntimeHelpers::toObject(v4, callData->args[0]);
+ scope.result = callData->args[0].toObject(v4);
}
}
@@ -398,7 +396,7 @@ ReturnedValue ObjectPrototype::method_toString(CallContext *ctx)
} else if (ctx->thisObject().isNull()) {
return ctx->d()->engine->newString(QStringLiteral("[object Null]"))->asReturnedValue();
} else {
- ScopedObject obj(scope, RuntimeHelpers::toObject(scope.engine, ctx->thisObject()));
+ ScopedObject obj(scope, ctx->thisObject().toObject(scope.engine));
QString className = obj->className();
return ctx->d()->engine->newString(QStringLiteral("[object %1]").arg(className))->asReturnedValue();
}
diff --git a/src/qml/jsruntime/qv4profiling_p.h b/src/qml/jsruntime/qv4profiling_p.h
index e06cb64a61..d27e853343 100644
--- a/src/qml/jsruntime/qv4profiling_p.h
+++ b/src/qml/jsruntime/qv4profiling_p.h
@@ -86,7 +86,7 @@ QT_END_NAMESPACE
engine->profiler()->trackDealloc(size, type) : false)
#define Q_V4_PROFILE(engine, function)\
- (engine->profiler() &&\
+ (Q_UNLIKELY(engine->profiler()) &&\
(engine->profiler()->featuresEnabled & (1 << Profiling::FeatureFunctionCall)) ?\
Profiling::FunctionCallProfiler::profileCall(engine->profiler(), engine, function) :\
function->code(engine, function->codeData))
diff --git a/src/qml/jsruntime/qv4property_p.h b/src/qml/jsruntime/qv4property_p.h
index 50e8f0ae7f..5069d7690b 100644
--- a/src/qml/jsruntime/qv4property_p.h
+++ b/src/qml/jsruntime/qv4property_p.h
@@ -87,8 +87,8 @@ struct Property {
inline bool isSubset(const PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs) const;
inline void merge(PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs);
- inline Heap::FunctionObject *getter() const { return value.isManaged() ? reinterpret_cast<Heap::FunctionObject *>(value.heapObject()) : 0; }
- inline Heap::FunctionObject *setter() const { return set.isManaged() ? reinterpret_cast<Heap::FunctionObject *>(set.heapObject()) : 0; }
+ inline Heap::FunctionObject *getter() const { return reinterpret_cast<Heap::FunctionObject *>(value.heapObject()); }
+ inline Heap::FunctionObject *setter() const { return reinterpret_cast<Heap::FunctionObject *>(set.heapObject()); }
inline void setGetter(FunctionObject *g) { value = reinterpret_cast<Managed *>(g); }
inline void setSetter(FunctionObject *s) { set = (s ? reinterpret_cast<Managed *>(s) : 0); }
diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/jsruntime/qv4qmlcontext.cpp
index 2418003519..889f4ea288 100644
--- a/src/qml/qml/qqmlcontextwrapper.cpp
+++ b/src/qml/jsruntime/qv4qmlcontext.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include "qqmlcontextwrapper_p.h"
+#include "qv4qmlcontext_p.h"
#include <private/qv8engine_p.h>
#include <private/qqmlengine_p.h>
@@ -60,6 +60,7 @@ QT_BEGIN_NAMESPACE
using namespace QV4;
DEFINE_OBJECT_VTABLE(QmlContextWrapper);
+DEFINE_MANAGED_VTABLE(QmlContext);
void Heap::QmlContextWrapper::init(QQmlContextData *context, QObject *scopeObject, bool ownsContext)
{
@@ -80,29 +81,6 @@ void Heap::QmlContextWrapper::destroy()
Object::destroy();
}
-ReturnedValue QmlContextWrapper::qmlScope(ExecutionEngine *v4, QQmlContextData *ctxt, QObject *scope)
-{
- Scope valueScope(v4);
-
- Scoped<QmlContextWrapper> w(valueScope, v4->memoryManager->allocObject<QmlContextWrapper>(ctxt, scope));
- return w.asReturnedValue();
-}
-
-ReturnedValue QmlContextWrapper::urlScope(ExecutionEngine *v4, const QUrl &url)
-{
- Scope scope(v4);
-
- QQmlContextData *context = new QQmlContextData;
- context->baseUrl = url;
- context->baseUrlString = url.toString();
- context->isInternal = true;
- context->isJSContext = true;
-
- Scoped<QmlContextWrapper> w(scope, v4->memoryManager->allocObject<QmlContextWrapper>(context, (QObject*)0, true));
- w->d()->isNullWrapper = true;
- return w.asReturnedValue();
-}
-
ReturnedValue QmlContextWrapper::get(const Managed *m, String *name, bool *hasProperty)
{
Q_ASSERT(m->as<QmlContextWrapper>());
@@ -320,4 +298,49 @@ void QmlContextWrapper::put(Managed *m, String *name, const Value &value)
Object::put(m, name, value);
}
+void Heap::QmlContext::init(QV4::ExecutionContext *outerContext, QV4::QmlContextWrapper *qml)
+{
+ Heap::ExecutionContext::init(outerContext->engine(), Heap::ExecutionContext::Type_QmlContext);
+ outer = outerContext->d();
+ strictMode = false;
+ callData = outer->callData;
+ lookups = outer->lookups;
+ constantTable = outer->constantTable;
+ compilationUnit = outer->compilationUnit;
+
+ this->qml = qml->d();
+}
+
+Heap::QmlContext *QmlContext::createWorkerContext(ExecutionContext *parent, const QUrl &source, Value *sendFunction)
+{
+ Scope scope(parent);
+
+ QQmlContextData *context = new QQmlContextData;
+ context->baseUrl = source;
+ context->baseUrlString = source.toString();
+ context->isInternal = true;
+ context->isJSContext = true;
+
+ Scoped<QmlContextWrapper> qml(scope, scope.engine->memoryManager->allocObject<QmlContextWrapper>(context, (QObject*)0, true));
+ qml->d()->isNullWrapper = true;
+
+ qml->setReadOnly(false);
+ QV4::ScopedObject api(scope, scope.engine->newObject());
+ api->put(QV4::ScopedString(scope, scope.engine->newString(QStringLiteral("sendMessage"))), *sendFunction);
+ qml->QV4::Object::put(QV4::ScopedString(scope, scope.engine->newString(QStringLiteral("WorkerScript"))), api);
+ qml->setReadOnly(true);
+
+ Heap::QmlContext *c = parent->d()->engine->memoryManager->alloc<QmlContext>(parent, qml);
+ return c;
+}
+
+Heap::QmlContext *QmlContext::create(ExecutionContext *parent, QQmlContextData *context, QObject *scopeObject)
+{
+ Scope scope(parent);
+
+ Scoped<QmlContextWrapper> qml(scope, scope.engine->memoryManager->allocObject<QmlContextWrapper>(context, scopeObject));
+ Heap::QmlContext *c = parent->d()->engine->memoryManager->alloc<QmlContext>(parent, qml);
+ return c;
+}
+
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlcontextwrapper_p.h b/src/qml/jsruntime/qv4qmlcontext_p.h
index 126ffecf0d..9aec7467da 100644
--- a/src/qml/qml/qqmlcontextwrapper_p.h
+++ b/src/qml/jsruntime/qv4qmlcontext_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QQMLCONTEXTWRAPPER_P_H
-#define QQMLCONTEXTWRAPPER_P_H
+#ifndef QV4QMLCONTEXT_P_H
+#define QV4QMLCONTEXT_P_H
//
// W A R N I N G
@@ -55,12 +55,15 @@
#include <private/qtqmlglobal_p.h>
#include <private/qv4object_p.h>
+#include <private/qv4context_p.h>
#include <private/qqmlcontext_p.h>
QT_BEGIN_NAMESPACE
namespace QV4 {
+struct QmlContextWrapper;
+
namespace Heap {
struct QmlContextWrapper : Object {
@@ -74,6 +77,12 @@ struct QmlContextWrapper : Object {
QQmlQPointer<QObject> scopeObject;
};
+struct QmlContext : ExecutionContext {
+ void init(QV4::ExecutionContext *outerContext, QV4::QmlContextWrapper *qml);
+
+ Pointer<QmlContextWrapper> qml;
+};
+
}
struct Q_QML_EXPORT QmlContextWrapper : Object
@@ -81,9 +90,6 @@ struct Q_QML_EXPORT QmlContextWrapper : Object
V4_OBJECT2(QmlContextWrapper, Object)
V4_NEEDS_DESTROY
- static ReturnedValue qmlScope(ExecutionEngine *e, QQmlContextData *ctxt, QObject *scope);
- static ReturnedValue urlScope(ExecutionEngine *v4, const QUrl &);
-
void takeContextOwnership() {
d()->ownsContext = true;
}
@@ -97,9 +103,28 @@ struct Q_QML_EXPORT QmlContextWrapper : Object
static void put(Managed *m, String *name, const Value &value);
};
+struct Q_QML_EXPORT QmlContext : public ExecutionContext
+{
+ V4_MANAGED(QmlContext, ExecutionContext)
+
+ static Heap::QmlContext *createWorkerContext(QV4::ExecutionContext *parent, const QUrl &source, Value *sendFunction);
+ static Heap::QmlContext *create(QV4::ExecutionContext *parent, QQmlContextData *context, QObject *scopeObject);
+
+ QObject *qmlScope() const {
+ return d()->qml->scopeObject;
+ }
+ QQmlContextData *qmlContext() const {
+ return *d()->qml->context;
+ }
+
+ void takeContextOwnership() {
+ d()->qml->ownsContext = true;
+ }
+};
+
}
QT_END_NAMESPACE
-#endif // QV8CONTEXTWRAPPER_P_H
+#endif
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index 6b87f282cf..77dbb18b50 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -48,7 +48,6 @@
#include <private/qqmlglobal_p.h>
#include <private/qqmltypewrapper_p.h>
#include <private/qqmlvaluetypewrapper_p.h>
-#include <private/qqmlcontextwrapper_p.h>
#include <private/qqmllistwrapper_p.h>
#include <private/qqmlbuiltinfunctions_p.h>
#include <private/qv8engine_p.h>
@@ -392,9 +391,10 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, QQmlP
QQmlContextData *callingQmlContext = scope.engine->callingQmlContext();
QV4::Scoped<QQmlBindingFunction> bindingFunction(scope, (const Value &)f);
- bindingFunction->initBindingLocation();
- newBinding = QQmlBinding::create(property, value, object, callingQmlContext);
+ QV4::ScopedContext ctx(scope, bindingFunction->scope());
+ newBinding = QQmlBinding::create(property, bindingFunction->function(), object, callingQmlContext, ctx);
+ newBinding->setSourceLocation(bindingFunction->currentLocation());
newBinding->setTarget(object, *property, nullptr);
}
}
@@ -493,8 +493,7 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, QQmlP
ReturnedValue QObjectWrapper::wrap_slowPath(ExecutionEngine *engine, QObject *object)
{
- if (QQmlData::wasDeleted(object))
- return QV4::Encode::null();
+ Q_ASSERT(!QQmlData::wasDeleted(object));
QQmlData *ddata = QQmlData::get(object, true);
if (!ddata)
diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h
index 504f6a69b8..c7c4f4dd77 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper_p.h
+++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h
@@ -206,14 +206,15 @@ private:
inline ReturnedValue QObjectWrapper::wrap(ExecutionEngine *engine, QObject *object)
{
- if (Q_LIKELY(!QQmlData::wasDeleted(object))) {
- QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
- if (Q_LIKELY(priv->declarativeData)) {
- auto ddata = static_cast<QQmlData *>(priv->declarativeData);
- if (Q_LIKELY(ddata->jsEngineId == engine->m_engineId && !ddata->jsWrapper.isUndefined())) {
- // We own the JS object
- return ddata->jsWrapper.value();
- }
+ if (Q_UNLIKELY(QQmlData::wasDeleted(object)))
+ return QV4::Encode::null();
+
+ QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
+ if (Q_LIKELY(priv->declarativeData)) {
+ auto ddata = static_cast<QQmlData *>(priv->declarativeData);
+ if (Q_LIKELY(ddata->jsEngineId == engine->m_engineId && !ddata->jsWrapper.isUndefined())) {
+ // We own the JS object
+ return ddata->jsWrapper.value();
}
}
diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp
index 4022d98c3f..218695624b 100644
--- a/src/qml/jsruntime/qv4regexpobject.cpp
+++ b/src/qml/jsruntime/qv4regexpobject.cpp
@@ -262,12 +262,12 @@ void RegExpCtor::construct(const Managed *, Scope &scope, CallData *callData)
bool ignoreCase = false;
bool multiLine = false;
if (!f->isUndefined()) {
- f = RuntimeHelpers::toString(scope.engine, f);
+ ScopedString s(scope, f->toString(scope.engine));
if (scope.hasException()) {
scope.result = Encode::undefined();
return;
}
- QString str = f->stringValue()->toQString();
+ QString str = s->toQString();
for (int i = 0; i < str.length(); ++i) {
if (str.at(i) == QLatin1Char('g') && !global) {
global = true;
@@ -356,10 +356,10 @@ ReturnedValue RegExpPrototype::method_exec(CallContext *ctx)
return ctx->engine()->throwTypeError();
ScopedValue arg(scope, ctx->argument(0));
- arg = RuntimeHelpers::toString(scope.engine, arg);
+ ScopedString str(scope, arg->toString(scope.engine));
if (scope.hasException())
return Encode::undefined();
- QString s = arg->stringValue()->toQString();
+ QString s = str->toQString();
int offset = r->global() ? r->lastIndexProperty()->toInt32() : 0;
if (offset < 0 || offset > s.length()) {
@@ -391,11 +391,11 @@ ReturnedValue RegExpPrototype::method_exec(CallContext *ctx)
}
array->setArrayLengthUnchecked(len);
*array->propertyData(Index_ArrayIndex) = Primitive::fromInt32(result);
- *array->propertyData(Index_ArrayInput) = arg;
+ *array->propertyData(Index_ArrayInput) = str;
RegExpCtor::Data *dd = regExpCtor->d();
dd->lastMatch = array;
- dd->lastInput = arg->stringValue()->d();
+ dd->lastInput = str->d();
dd->lastMatchStart = matchOffsets[0];
dd->lastMatchEnd = matchOffsets[1];
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index fffa6b8009..d6c55926b1 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -53,7 +53,7 @@
#include "qv4numberobject_p.h"
#include "private/qlocale_tools_p.h"
#include "qv4scopedvalue_p.h"
-#include <private/qqmlcontextwrapper_p.h>
+#include <private/qv4qmlcontext_p.h>
#include <private/qqmltypewrapper_p.h>
#include <private/qqmlengine_p.h>
#include <private/qqmljavascriptexpression_p.h>
@@ -345,28 +345,29 @@ ReturnedValue Runtime::method_deleteName(ExecutionEngine *engine, int nameIndex)
QV4::ReturnedValue Runtime::method_instanceof(ExecutionEngine *engine, const Value &left, const Value &right)
{
- Scope scope(engine);
- ScopedFunctionObject f(scope, right.as<FunctionObject>());
- if (!f)
+ const FunctionObject *function = right.as<FunctionObject>();
+ if (!function)
return engine->throwTypeError();
- if (f->isBoundFunction())
- f = static_cast<BoundFunction *>(f.getPointer())->target();
+ Heap::FunctionObject *f = function->d();
+ if (function->isBoundFunction())
+ f = function->cast<BoundFunction>()->target();
- ScopedObject v(scope, left.as<Object>());
- if (!v)
+ const Object *o = left.as<Object>();
+ if (!o)
return Encode(false);
+ Heap::Object *v = o->d();
- ScopedObject o(scope, f->protoProperty());
+ o = f->protoProperty();
if (!o)
return engine->throwTypeError();
while (v) {
- v = v->prototype();
+ v = v->prototype;
if (!v)
break;
- else if (o->d() == v->d())
+ else if (o->d() == v)
return Encode(true);
}
@@ -375,13 +376,14 @@ QV4::ReturnedValue Runtime::method_instanceof(ExecutionEngine *engine, const Val
QV4::ReturnedValue Runtime::method_in(ExecutionEngine *engine, const Value &left, const Value &right)
{
- if (!right.isObject())
+ Object *ro = right.objectValue();
+ if (!ro)
return engine->throwTypeError();
Scope scope(engine);
ScopedString s(scope, left.toString(engine));
if (scope.hasException())
return Encode::undefined();
- bool r = right.objectValue()->hasProperty(s);
+ bool r = ro->hasProperty(s);
return Encode(r);
}
@@ -492,8 +494,8 @@ Heap::String *RuntimeHelpers::convertToString(ExecutionEngine *engine, const Val
else
return engine->id_false()->d();
case Value::Managed_Type:
- if (value.isString())
- return value.stringValue()->d();
+ if (String *s = value.stringValue())
+ return s->d();
{
Scope scope(engine);
ScopedValue prim(scope, RuntimeHelpers::toPrimitive(value, STRING_HINT));
@@ -523,8 +525,8 @@ static Heap::String *convert_to_string_add(ExecutionEngine *engine, const Value
else
return engine->id_false()->d();
case Value::Managed_Type:
- if (value.isString())
- return value.stringValue()->d();
+ if (String *s = value.stringValue())
+ return s->d();
{
Scope scope(engine);
ScopedValue prim(scope, RuntimeHelpers::toPrimitive(value, PREFERREDTYPE_HINT));
@@ -543,19 +545,25 @@ QV4::ReturnedValue RuntimeHelpers::addHelper(ExecutionEngine *engine, const Valu
ScopedValue pleft(scope, RuntimeHelpers::toPrimitive(left, PREFERREDTYPE_HINT));
ScopedValue pright(scope, RuntimeHelpers::toPrimitive(right, PREFERREDTYPE_HINT));
- if (pleft->isString() || pright->isString()) {
- if (!pleft->isString())
+ String *sleft = pleft->stringValue();
+ String *sright = pright->stringValue();
+ if (sleft || sright) {
+ if (!sleft) {
pleft = convert_to_string_add(engine, pleft);
- if (!pright->isString())
+ sleft = static_cast<String *>(pleft.ptr);
+ }
+ if (!sright) {
pright = convert_to_string_add(engine, pright);
+ sright = static_cast<String *>(pright.ptr);
+ }
if (scope.engine->hasException)
return Encode::undefined();
- if (!pleft->stringValue()->d()->length())
- return pright->asReturnedValue();
- if (!pright->stringValue()->d()->length())
- return pleft->asReturnedValue();
+ if (!sleft->d()->length())
+ return sright->asReturnedValue();
+ if (!sright->d()->length())
+ return sleft->asReturnedValue();
MemoryManager *mm = engine->memoryManager;
- return (mm->alloc<String>(mm, pleft->stringValue()->d(), pright->stringValue()->d()))->asReturnedValue();
+ return (mm->alloc<String>(mm, sleft->d(), sright->d()))->asReturnedValue();
}
double x = RuntimeHelpers::toNumber(pleft);
double y = RuntimeHelpers::toNumber(pright);
@@ -566,31 +574,28 @@ QV4::ReturnedValue Runtime::method_addString(ExecutionEngine *engine, const Valu
{
Q_ASSERT(left.isString() || right.isString());
- if (left.isString() && right.isString()) {
- if (!left.stringValue()->d()->length())
- return right.asReturnedValue();
- if (!right.stringValue()->d()->length())
- return left.asReturnedValue();
- MemoryManager *mm = engine->memoryManager;
- return (mm->alloc<String>(mm, left.stringValue()->d(), right.stringValue()->d()))->asReturnedValue();
- }
-
Scope scope(engine);
ScopedValue pleft(scope, left);
ScopedValue pright(scope, right);
+ String *sleft = pleft->stringValue();
+ String *sright = pright->stringValue();
- if (!pleft->isString())
- pleft = convert_to_string_add(engine, left);
- if (!pright->isString())
- pright = convert_to_string_add(engine, right);
+ if (!sleft) {
+ pleft = convert_to_string_add(engine, pleft);
+ sleft = static_cast<String *>(pleft.ptr);
+ }
+ if (!sright) {
+ pright = convert_to_string_add(engine, pright);
+ sright = static_cast<String *>(pright.ptr);
+ }
if (scope.engine->hasException)
return Encode::undefined();
- if (!pleft->stringValue()->d()->length())
+ if (!sleft->d()->length())
return pright->asReturnedValue();
- if (!pright->stringValue()->d()->length())
+ if (!sright->d()->length())
return pleft->asReturnedValue();
MemoryManager *mm = engine->memoryManager;
- return (mm->alloc<String>(mm, pleft->stringValue()->d(), pright->stringValue()->d()))->asReturnedValue();
+ return (mm->alloc<String>(mm, sleft->d(), sright->d()))->asReturnedValue();
}
void Runtime::method_setProperty(ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value)
@@ -750,13 +755,15 @@ uint RuntimeHelpers::equalHelper(const Value &x, const Value &y)
#ifdef V4_BOOTSTRAP
Q_UNIMPLEMENTED();
#else
- if ((x.isNumber() || x.isString()) && y.isObject()) {
- Scope scope(y.objectValue()->engine());
- ScopedValue py(scope, RuntimeHelpers::toPrimitive(y, PREFERREDTYPE_HINT));
+ Object *xo = x.objectValue();
+ Object *yo = y.objectValue();
+ if (yo && (x.isNumber() || x.isString())) {
+ Scope scope(yo->engine());
+ ScopedValue py(scope, RuntimeHelpers::objectDefaultValue(yo, PREFERREDTYPE_HINT));
return Runtime::method_compareEqual(x, py);
- } else if (x.isObject() && (y.isNumber() || y.isString())) {
- Scope scope(x.objectValue()->engine());
- ScopedValue px(scope, RuntimeHelpers::toPrimitive(x, PREFERREDTYPE_HINT));
+ } else if (xo && (y.isNumber() || y.isString())) {
+ Scope scope(xo->engine());
+ ScopedValue px(scope, RuntimeHelpers::objectDefaultValue(xo, PREFERREDTYPE_HINT));
return Runtime::method_compareEqual(px, y);
}
#endif
@@ -787,23 +794,27 @@ QV4::Bool Runtime::method_compareGreaterThan(const Value &l, const Value &r)
return l.integerValue() > r.integerValue();
if (l.isNumber() && r.isNumber())
return l.asDouble() > r.asDouble();
- if (l.isString() && r.isString()) {
+ String *sl = l.stringValue();
+ String *sr = r.stringValue();
+ if (sl && sr) {
#ifdef V4_BOOTSTRAP
Q_UNIMPLEMENTED();
return false;
#else
- return r.stringValue()->compare(l.stringValue());
+ return sr->compare(sl);
#endif
}
- if (l.isObject() || r.isObject()) {
+ Object *ro = r.objectValue();
+ Object *lo = l.objectValue();
+ if (ro || lo) {
#ifdef V4_BOOTSTRAP
Q_UNIMPLEMENTED();
#else
- QV4::ExecutionEngine *e = (l.isObject() ? l.objectValue() : r.objectValue())->engine();
+ QV4::ExecutionEngine *e = (lo ? lo : ro)->engine();
QV4::Scope scope(e);
- QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT));
- QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT));
+ QV4::ScopedValue pl(scope, lo ? RuntimeHelpers::objectDefaultValue(lo, QV4::NUMBER_HINT) : l.asReturnedValue());
+ QV4::ScopedValue pr(scope, ro ? RuntimeHelpers::objectDefaultValue(ro, QV4::NUMBER_HINT) : r.asReturnedValue());
return Runtime::method_compareGreaterThan(pl, pr);
#endif
}
@@ -820,23 +831,27 @@ QV4::Bool Runtime::method_compareLessThan(const Value &l, const Value &r)
return l.integerValue() < r.integerValue();
if (l.isNumber() && r.isNumber())
return l.asDouble() < r.asDouble();
- if (l.isString() && r.isString()) {
+ String *sl = l.stringValue();
+ String *sr = r.stringValue();
+ if (sl && sr) {
#ifdef V4_BOOTSTRAP
Q_UNIMPLEMENTED();
return false;
#else
- return l.stringValue()->compare(r.stringValue());
+ return sl->compare(sr);
#endif
}
- if (l.isObject() || r.isObject()) {
+ Object *ro = r.objectValue();
+ Object *lo = l.objectValue();
+ if (ro || lo) {
#ifdef V4_BOOTSTRAP
Q_UNIMPLEMENTED();
#else
- QV4::ExecutionEngine *e = (l.isObject() ? l.objectValue() : r.objectValue())->engine();
+ QV4::ExecutionEngine *e = (lo ? lo : ro)->engine();
QV4::Scope scope(e);
- QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT));
- QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT));
+ QV4::ScopedValue pl(scope, lo ? RuntimeHelpers::objectDefaultValue(lo, QV4::NUMBER_HINT) : l.asReturnedValue());
+ QV4::ScopedValue pr(scope, ro ? RuntimeHelpers::objectDefaultValue(ro, QV4::NUMBER_HINT) : r.asReturnedValue());
return Runtime::method_compareLessThan(pl, pr);
#endif
}
@@ -853,23 +868,27 @@ QV4::Bool Runtime::method_compareGreaterEqual(const Value &l, const Value &r)
return l.integerValue() >= r.integerValue();
if (l.isNumber() && r.isNumber())
return l.asDouble() >= r.asDouble();
- if (l.isString() && r.isString()) {
+ String *sl = l.stringValue();
+ String *sr = r.stringValue();
+ if (sl && sr) {
#ifdef V4_BOOTSTRAP
Q_UNIMPLEMENTED();
return false;
#else
- return !l.stringValue()->compare(r.stringValue());
+ return !sl->compare(sr);
#endif
}
- if (l.isObject() || r.isObject()) {
+ Object *ro = r.objectValue();
+ Object *lo = l.objectValue();
+ if (ro || lo) {
#ifdef V4_BOOTSTRAP
Q_UNIMPLEMENTED();
#else
- QV4::ExecutionEngine *e = (l.isObject() ? l.objectValue() : r.objectValue())->engine();
+ QV4::ExecutionEngine *e = (lo ? lo : ro)->engine();
QV4::Scope scope(e);
- QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT));
- QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT));
+ QV4::ScopedValue pl(scope, lo ? RuntimeHelpers::objectDefaultValue(lo, QV4::NUMBER_HINT) : l.asReturnedValue());
+ QV4::ScopedValue pr(scope, ro ? RuntimeHelpers::objectDefaultValue(ro, QV4::NUMBER_HINT) : r.asReturnedValue());
return Runtime::method_compareGreaterEqual(pl, pr);
#endif
}
@@ -886,23 +905,27 @@ QV4::Bool Runtime::method_compareLessEqual(const Value &l, const Value &r)
return l.integerValue() <= r.integerValue();
if (l.isNumber() && r.isNumber())
return l.asDouble() <= r.asDouble();
- if (l.isString() && r.isString()) {
+ String *sl = l.stringValue();
+ String *sr = r.stringValue();
+ if (sl && sr) {
#ifdef V4_BOOTSTRAP
Q_UNIMPLEMENTED();
return false;
#else
- return !r.stringValue()->compare(l.stringValue());
+ return !sr->compare(sl);
#endif
}
- if (l.isObject() || r.isObject()) {
+ Object *ro = r.objectValue();
+ Object *lo = l.objectValue();
+ if (ro || lo) {
#ifdef V4_BOOTSTRAP
Q_UNIMPLEMENTED();
#else
- QV4::ExecutionEngine *e = (l.isObject() ? l.objectValue() : r.objectValue())->engine();
+ QV4::ExecutionEngine *e = (lo ? lo : ro)->engine();
QV4::Scope scope(e);
- QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT));
- QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT));
+ QV4::ScopedValue pl(scope, lo ? RuntimeHelpers::objectDefaultValue(lo, QV4::NUMBER_HINT) : l.asReturnedValue());
+ QV4::ScopedValue pr(scope, ro ? RuntimeHelpers::objectDefaultValue(ro, QV4::NUMBER_HINT) : r.asReturnedValue());
return Runtime::method_compareLessEqual(pl, pr);
#endif
}
@@ -1045,13 +1068,13 @@ ReturnedValue Runtime::method_callPropertyLookup(ExecutionEngine *engine, uint i
Lookup *l = engine->current->lookups + index;
Value v;
v = l->getter(l, engine, callData->thisObject);
- if (v.isObject()) {
+ Object *o = v.objectValue();
+ if (Q_LIKELY(o)) {
Scope scope(engine);
- v.objectValue()->call(scope, callData);
+ o->call(scope, callData);
return scope.result.asReturnedValue();
- } else {
- return engine->throwTypeError();
}
+ return engine->throwTypeError();
}
ReturnedValue Runtime::method_callElement(ExecutionEngine *engine, const Value &index, CallData *callData)
@@ -1074,12 +1097,12 @@ ReturnedValue Runtime::method_callElement(ExecutionEngine *engine, const Value &
ReturnedValue Runtime::method_callValue(ExecutionEngine *engine, const Value &func, CallData *callData)
{
- if (!func.isObject())
- return engine->throwTypeError(QStringLiteral("%1 is not a function").arg(func.toQStringNoThrow()));
-
- Scope scope(engine);
- func.objectValue()->call(scope, callData);
- return scope.result.asReturnedValue();
+ if (Object *o = func.objectValue()) {
+ Scope scope(engine);
+ o->call(scope, callData);
+ return scope.result.asReturnedValue();
+ }
+ return engine->throwTypeError(QStringLiteral("%1 is not a function").arg(func.toQStringNoThrow()));
}
@@ -1149,14 +1172,13 @@ ReturnedValue Runtime::method_constructPropertyLookup(ExecutionEngine *engine, u
Lookup *l = engine->current->lookups + index;
Value v;
v = l->getter(l, engine, callData->thisObject);
- if (v.isObject()) {
+ Object *o = v.objectValue();
+ if (Q_LIKELY(o)) {
Scope scope(engine);
- ScopedValue result(scope);
- v.objectValue()->construct(scope, callData);
+ o->construct(scope, callData);
return scope.result.asReturnedValue();
- } else {
- return engine->throwTypeError();
}
+ return engine->throwTypeError();
}
@@ -1259,7 +1281,7 @@ ReturnedValue Runtime::method_unwindException(ExecutionEngine *engine)
*
* Instead the push/pop pair acts as a non local scope.
*/
-void Runtime::method_pushWithScope(const Value &o, ExecutionEngine *engine)
+void Runtime::method_pushWithScope(const Value &o, NoThrowEngine *engine)
{
engine->pushContext(engine->currentContext->newWithContext(o.toObject(engine)));
Q_ASSERT(engine->jsStackTop == engine->currentContext + 2);
@@ -1272,7 +1294,7 @@ void Runtime::method_pushCatchScope(NoThrowEngine *engine, int exceptionVarNameI
Q_ASSERT(engine->jsStackTop == engine->currentContext + 2);
}
-void Runtime::method_popScope(ExecutionEngine *engine)
+void Runtime::method_popScope(NoThrowEngine *engine)
{
Q_ASSERT(engine->jsStackTop == engine->currentContext + 2);
engine->popContext();
@@ -1367,29 +1389,6 @@ QV4::ReturnedValue Runtime::method_decrement(const Value &value)
}
}
-#ifndef V4_BOOTSTRAP
-
-QV4::ReturnedValue RuntimeHelpers::toString(ExecutionEngine *engine, const Value &value)
-{
- if (value.isString())
- return value.asReturnedValue();
- return RuntimeHelpers::convertToString(engine, value)->asReturnedValue();
-}
-
-QV4::ReturnedValue RuntimeHelpers::toObject(ExecutionEngine *engine, const Value &value)
-{
- if (value.isObject())
- return value.asReturnedValue();
-
- Heap::Object *o = RuntimeHelpers::convertToObject(engine, value);
- if (!o) // type error
- return Encode::undefined();
-
- return Encode(o);
-}
-
-#endif // V4_BOOTSTRAP
-
ReturnedValue Runtime::method_toDouble(const Value &value)
{
TRACE1(value);
diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h
index a32b3f1663..0d787714cf 100644
--- a/src/qml/jsruntime/qv4runtime_p.h
+++ b/src/qml/jsruntime/qv4runtime_p.h
@@ -106,10 +106,7 @@ struct Q_QML_PRIVATE_EXPORT RuntimeHelpers {
static double toNumber(const Value &value);
static void numberToString(QString *result, double num, int radix = 10);
- static ReturnedValue toString(ExecutionEngine *engine, const Value &value);
static Heap::String *convertToString(ExecutionEngine *engine, const Value &value);
-
- static ReturnedValue toObject(ExecutionEngine *engine, const Value &value);
static Heap::Object *convertToObject(ExecutionEngine *engine, const Value &value);
static Bool equalHelper(const Value &x, const Value &y);
diff --git a/src/qml/jsruntime/qv4runtimeapi_p.h b/src/qml/jsruntime/qv4runtimeapi_p.h
index 040a545b83..355b7890b6 100644
--- a/src/qml/jsruntime/qv4runtimeapi_p.h
+++ b/src/qml/jsruntime/qv4runtimeapi_p.h
@@ -65,7 +65,7 @@ struct ExceptionCheck {
};
// push_catch and pop context methods shouldn't check for exceptions
template <>
-struct ExceptionCheck<void (*)(QV4::ExecutionEngine *)> {
+struct ExceptionCheck<void (*)(QV4::NoThrowEngine *)> {
enum { NeedsCheck = 0 };
};
template <typename A>
@@ -244,9 +244,9 @@ struct Q_QML_PRIVATE_EXPORT Runtime {
// exceptions & scopes
RUNTIME_METHOD(void, throwException, (ExecutionEngine *engine, const Value &value));
RUNTIME_METHOD(ReturnedValue, unwindException, (ExecutionEngine *engine));
- RUNTIME_METHOD(void, pushWithScope, (const Value &o, ExecutionEngine *engine));
+ RUNTIME_METHOD(void, pushWithScope, (const Value &o, NoThrowEngine *engine));
RUNTIME_METHOD(void, pushCatchScope, (NoThrowEngine *engine, int exceptionVarNameIndex));
- RUNTIME_METHOD(void, popScope, (ExecutionEngine *engine));
+ RUNTIME_METHOD(void, popScope, (NoThrowEngine *engine));
// closures
RUNTIME_METHOD(ReturnedValue, closure, (ExecutionEngine *engine, int functionId));
diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h
index 5022d7c3bc..4e627e003f 100644
--- a/src/qml/jsruntime/qv4scopedvalue_p.h
+++ b/src/qml/jsruntime/qv4scopedvalue_p.h
@@ -97,7 +97,7 @@ struct Scope {
engine->jsStackTop = mark;
}
- Value *alloc(int nValues) const {
+ QML_NEARLY_ALWAYS_INLINE Value *alloc(int nValues) const {
return engine->jsAlloca(nValues);
}
@@ -189,63 +189,70 @@ struct Scoped
{
enum ConvertType { Convert };
- inline void setPointer(const Managed *p) {
+ QML_NEARLY_ALWAYS_INLINE void setPointer(const Managed *p) {
ptr->setM(p ? p->m() : 0);
}
- Scoped(const Scope &scope)
+ QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope)
{
ptr = scope.engine->jsAlloca(1);
}
- Scoped(const Scope &scope, const Value &v)
+ QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const Value &v)
{
ptr = scope.engine->jsAlloca(1);
setPointer(v.as<T>());
}
- Scoped(const Scope &scope, Heap::Base *o)
+ QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, Heap::Base *o)
{
Value v;
v = o;
ptr = scope.engine->jsAlloca(1);
setPointer(v.as<T>());
}
- Scoped(const Scope &scope, const ScopedValue &v)
+ QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const ScopedValue &v)
{
ptr = scope.engine->jsAlloca(1);
setPointer(v.ptr->as<T>());
}
- Scoped(const Scope &scope, const Value &v, ConvertType)
+ QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const Value &v, ConvertType)
{
ptr = scope.engine->jsAlloca(1);
ptr->setRawValue(value_convert<T>(scope.engine, v));
}
- Scoped(const Scope &scope, const Value *v)
+ QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const Value *v)
{
ptr = scope.engine->jsAlloca(1);
setPointer(v ? v->as<T>() : 0);
}
- Scoped(const Scope &scope, T *t)
+ QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, T *t)
{
ptr = scope.engine->jsAlloca(1);
setPointer(t);
}
- Scoped(const Scope &scope, typename T::Data *t)
+
+ QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const T *t)
+ {
+ ptr = scope.engine->jsAlloca(1);
+ setPointer(t);
+ }
+
+ QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, typename T::Data *t)
{
ptr = scope.engine->jsAlloca(1);
*ptr = t;
}
- Scoped(const Scope &scope, const ReturnedValue &v)
+ QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const ReturnedValue &v)
{
ptr = scope.engine->jsAlloca(1);
setPointer(QV4::Value::fromReturnedValue(v).as<T>());
}
- Scoped(const Scope &scope, const ReturnedValue &v, ConvertType)
+ QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const ReturnedValue &v, ConvertType)
{
ptr = scope.engine->jsAlloca(1);
ptr->setRawValue(value_convert<T>(scope.engine, QV4::Value::fromReturnedValue(v)));
@@ -291,11 +298,11 @@ struct Scoped
}
T *operator->() {
- return ptr->cast<T>();
+ return getPointer();
}
const T *operator->() const {
- return ptr->cast<T>();
+ return getPointer();
}
bool operator!() const {
@@ -306,14 +313,19 @@ struct Scoped
}
T *getPointer() {
- return ptr->cast<T>();
+ return reinterpret_cast<T *>(ptr);
+ }
+
+ const T *getPointer() const {
+ return reinterpret_cast<T *>(ptr);
}
+
Value *getRef() {
return ptr;
}
- ReturnedValue asReturnedValue() const {
- return ptr->m() ? ptr->rawValue() : Encode::undefined();
+ QML_NEARLY_ALWAYS_INLINE ReturnedValue asReturnedValue() const {
+ return ptr->rawValue();
}
Value *ptr;
@@ -358,8 +370,6 @@ struct ScopedProperty
ScopedProperty(Scope &scope)
{
property = reinterpret_cast<Property*>(scope.alloc(sizeof(Property) / sizeof(Value)));
- property->value = Encode::undefined();
- property->set = Encode::undefined();
}
Property *operator->() { return property; }
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index 552171256f..b54177bee9 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -54,71 +54,12 @@
#include <private/qv4profiling_p.h>
#include <qv4jsir_p.h>
#include <qv4codegen_p.h>
-#include <private/qqmlcontextwrapper_p.h>
#include <QtCore/QDebug>
#include <QtCore/QString>
-QT_BEGIN_NAMESPACE
-
-namespace QV4 {
-namespace Heap {
-
-struct QmlBindingWrapper : FunctionObject {
- void init(QV4::QmlContext *scope, Function *f);
-};
-
-}
-
-struct QmlBindingWrapper : FunctionObject {
- V4_OBJECT2(QmlBindingWrapper, FunctionObject)
-
- static void call(const Managed *that, Scope &scope, CallData *callData);
-};
-
-}
-
-QT_END_NAMESPACE
-
using namespace QV4;
-DEFINE_OBJECT_VTABLE(QmlBindingWrapper);
-
-void Heap::QmlBindingWrapper::init(QV4::QmlContext *scope, Function *f)
-{
- Heap::FunctionObject::init(scope, scope->d()->engine->id_eval(), /*createProto = */ false);
-
- Q_ASSERT(scope->inUse());
-
- function = f;
- if (function)
- function->compilationUnit->addref();
-}
-
-void QmlBindingWrapper::call(const Managed *that, Scope &scope, CallData *callData)
-{
- const QmlBindingWrapper *This = static_cast<const QmlBindingWrapper *>(that);
- ExecutionEngine *v4 = static_cast<const Object *>(that)->engine();
- if (v4->hasException) {
- scope.result = Encode::undefined();
- return;
- }
- CHECK_STACK_LIMITS(v4, scope);
-
- ExecutionContextSaver ctxSaver(scope);
-
- QV4::Function *f = This->function();
- if (!f) {
- scope.result = QV4::Encode::undefined();
- return;
- }
-
- Scoped<CallContext> ctx(scope, v4->currentContext->newCallContext(This, callData));
- v4->pushContext(ctx);
-
- scope.result = Q_V4_PROFILE(v4, f);
-}
-
Script::Script(ExecutionEngine *v4, QmlContext *qml, CompiledData::CompilationUnit *compilationUnit)
: line(0), column(0), scope(v4->rootContext()), strictMode(false), inheritContext(true), parsed(false)
, compilationUnit(compilationUnit), vmFunction(0), parseAsBinding(true)
@@ -230,10 +171,12 @@ ReturnedValue Script::run()
return Q_V4_PROFILE(engine, vmFunction);
} else {
Scoped<QmlContext> qml(valueScope, qmlContext.value());
- ScopedFunctionObject f(valueScope, engine->memoryManager->allocObject<QmlBindingWrapper>(qml, vmFunction));
ScopedCallData callData(valueScope);
callData->thisObject = Primitive::undefinedValue();
- f->call(valueScope, callData);
+ if (vmFunction->canUseSimpleFunction())
+ qml->simpleCall(valueScope, callData, vmFunction);
+ else
+ qml->call(valueScope, callData, vmFunction);
return valueScope.result.asReturnedValue();
}
}
@@ -303,17 +246,6 @@ QQmlRefPointer<QV4::CompiledData::CompilationUnit> Script::precompile(IR::Module
return isel->compile(/*generate unit data*/false);
}
-ReturnedValue Script::qmlBinding()
-{
- if (!parsed)
- parse();
- ExecutionEngine *v4 = scope->engine();
- Scope valueScope(v4);
- Scoped<QmlContext> qml(valueScope, qmlContext.value());
- ScopedObject v(valueScope, v4->memoryManager->allocObject<QmlBindingWrapper>(qml, vmFunction));
- return v.asReturnedValue();
-}
-
QV4::ReturnedValue Script::evaluate(ExecutionEngine *engine, const QString &script, QmlContext *qmlContext)
{
QV4::Scope scope(engine);
diff --git a/src/qml/jsruntime/qv4script_p.h b/src/qml/jsruntime/qv4script_p.h
index 2e87a7692b..f96f0254a5 100644
--- a/src/qml/jsruntime/qv4script_p.h
+++ b/src/qml/jsruntime/qv4script_p.h
@@ -53,7 +53,7 @@
#include "qv4global_p.h"
#include "qv4engine_p.h"
#include "qv4functionobject_p.h"
-#include "qv4context_p.h"
+#include "qv4qmlcontext_p.h"
#include <QQmlError>
@@ -136,7 +136,6 @@ struct Q_QML_EXPORT Script {
void parse();
ReturnedValue run();
- ReturnedValue qmlBinding();
Function *function();
diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp
index 3365ffe637..1efd8cb714 100644
--- a/src/qml/jsruntime/qv4string.cpp
+++ b/src/qml/jsruntime/qv4string.cpp
@@ -46,6 +46,7 @@
#include "qv4stringobject_p.h"
#endif
#include <QtCore/QHash>
+#include <QtCore/private/qnumeric_p.h>
using namespace QV4;
diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h
index 23ec3349b9..4890a85724 100644
--- a/src/qml/jsruntime/qv4string_p.h
+++ b/src/qml/jsruntime/qv4string_p.h
@@ -267,7 +267,7 @@ public:
template<>
inline const String *Value::as() const {
- return isManaged() && m() && m()->vtable()->isString ? static_cast<const String *>(this) : 0;
+ return isManaged() && m()->vtable()->isString ? static_cast<const String *>(this) : 0;
}
#ifndef V4_BOOTSTRAP
diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp
index 829ada0c1a..6fbf1c3c85 100644
--- a/src/qml/jsruntime/qv4stringobject.cpp
+++ b/src/qml/jsruntime/qv4stringobject.cpp
@@ -218,8 +218,8 @@ static QString getThisString(ExecutionContext *ctx)
{
Scope scope(ctx);
ScopedValue t(scope, ctx->thisObject());
- if (t->isString())
- return t->stringValue()->toQString();
+ if (String *s = t->stringValue())
+ return s->toQString();
if (StringObject *thisString = t->as<StringObject>())
return thisString->d()->string->toQString();
if (t->isUndefined() || t->isNull()) {
@@ -282,13 +282,13 @@ ReturnedValue StringPrototype::method_concat(CallContext *context)
if (scope.engine->hasException)
return Encode::undefined();
- ScopedValue v(scope);
+ ScopedString s(scope);
for (int i = 0; i < context->argc(); ++i) {
- v = RuntimeHelpers::toString(scope.engine, context->args()[i]);
+ s = context->args()[i].toString(scope.engine);
if (scope.hasException())
return Encode::undefined();
- Q_ASSERT(v->isString());
- value += v->stringValue()->toQString();
+ Q_ASSERT(s->isString());
+ value += s->toQString();
}
return context->d()->engine->newString(value)->asReturnedValue();
diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp
index 95c95b1974..e34ac9c764 100644
--- a/src/qml/jsruntime/qv4value.cpp
+++ b/src/qml/jsruntime/qv4value.cpp
@@ -77,24 +77,24 @@ int Value::toUInt16() const
bool Value::toBoolean() const
{
- switch (type()) {
- case Value::Undefined_Type:
- case Value::Null_Type:
+ if (isInteger() || isBoolean())
+ return static_cast<bool>(int_32());
+
+ if (isUndefined() || isNull())
return false;
- case Value::Boolean_Type:
- case Value::Integer_Type:
- return (bool)int_32();
- case Value::Managed_Type:
+
+ if (isManaged()) {
#ifdef V4_BOOTSTRAP
Q_UNIMPLEMENTED();
#else
- if (isString())
- return stringValue()->toQString().length() > 0;
+ if (String *s = stringValue())
+ return s->toQString().length() > 0;
#endif
return true;
- default: // double
- return doubleValue() && !std::isnan(doubleValue());
}
+
+ // double
+ return doubleValue() && !std::isnan(doubleValue());
}
double Value::toInteger() const
@@ -114,8 +114,8 @@ double Value::toNumberImpl() const
#ifdef V4_BOOTSTRAP
Q_UNIMPLEMENTED();
#else
- if (isString())
- return RuntimeHelpers::stringToNumber(stringValue()->toQString());
+ if (String *s = stringValue())
+ return RuntimeHelpers::stringToNumber(s->toQString());
{
Q_ASSERT(isObject());
Scope scope(objectValue()->engine());
@@ -150,8 +150,8 @@ QString Value::toQStringNoThrow() const
else
return QStringLiteral("false");
case Value::Managed_Type:
- if (isString())
- return stringValue()->toQString();
+ if (String *s = stringValue())
+ return s->toQString();
{
Q_ASSERT(isObject());
Scope scope(objectValue()->engine());
@@ -203,8 +203,8 @@ QString Value::toQString() const
else
return QStringLiteral("false");
case Value::Managed_Type:
- if (isString())
- return stringValue()->toQString();
+ if (String *s = stringValue())
+ return s->toQString();
{
Q_ASSERT(isObject());
Scope scope(objectValue()->engine());
@@ -228,8 +228,10 @@ QString Value::toQString() const
bool Value::sameValue(Value other) const {
if (_val == other._val)
return true;
- if (isString() && other.isString())
- return stringValue()->isEqualTo(other.stringValue());
+ String *s = stringValue();
+ String *os = other.stringValue();
+ if (s && os)
+ return s->isEqualTo(os);
if (isInteger() && other.isDouble())
return int_32() ? (double(int_32()) == other.doubleValue()) : (other._val == 0);
if (isDouble() && other.isInteger())
@@ -298,15 +300,15 @@ double Primitive::toInteger(double number)
#ifndef V4_BOOTSTRAP
Heap::String *Value::toString(ExecutionEngine *e) const
{
- if (isString())
- return stringValue()->d();
+ if (String *s = stringValue())
+ return s->d();
return RuntimeHelpers::convertToString(e, *this);
}
Heap::Object *Value::toObject(ExecutionEngine *e) const
{
- if (isObject())
- return objectValue()->d();
+ if (Object *o = objectValue())
+ return o->d();
return RuntimeHelpers::convertToObject(e, *this);
}
@@ -330,8 +332,8 @@ uint Value::asArrayLength(bool *ok) const
}
return idx;
}
- if (isString())
- return stringValue()->toUInt(ok);
+ if (String *s = stringValue())
+ return s->toUInt(ok);
uint idx = toUInt32();
double d = toNumber();
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index 6d5cff4ecc..816b8fb11b 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -160,9 +160,9 @@ private:
quint64 _val;
public:
- Q_ALWAYS_INLINE quint64 &rawValueRef() { return _val; }
- Q_ALWAYS_INLINE quint64 rawValue() const { return _val; }
- Q_ALWAYS_INLINE void setRawValue(quint64 raw) { _val = raw; }
+ QML_NEARLY_ALWAYS_INLINE quint64 &rawValueRef() { return _val; }
+ QML_NEARLY_ALWAYS_INLINE quint64 rawValue() const { return _val; }
+ QML_NEARLY_ALWAYS_INLINE void setRawValue(quint64 raw) { _val = raw; }
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
static inline int valueOffset() { return 0; }
@@ -171,23 +171,23 @@ public:
static inline int valueOffset() { return 4; }
static inline int tagOffset() { return 0; }
#endif
- Q_ALWAYS_INLINE void setTagValue(quint32 tag, quint32 value) { _val = quint64(tag) << 32 | value; }
- Q_ALWAYS_INLINE quint32 value() const { return _val & quint64(~quint32(0)); }
- Q_ALWAYS_INLINE quint32 tag() const { return _val >> 32; }
+ QML_NEARLY_ALWAYS_INLINE void setTagValue(quint32 tag, quint32 value) { _val = quint64(tag) << 32 | value; }
+ QML_NEARLY_ALWAYS_INLINE quint32 value() const { return _val & quint64(~quint32(0)); }
+ QML_NEARLY_ALWAYS_INLINE quint32 tag() const { return _val >> 32; }
#if defined(QV4_USE_64_BIT_VALUE_ENCODING)
- Q_ALWAYS_INLINE Heap::Base *m() const
+ QML_NEARLY_ALWAYS_INLINE Heap::Base *m() const
{
Heap::Base *b;
memcpy(&b, &_val, 8);
return b;
}
- Q_ALWAYS_INLINE void setM(Heap::Base *b)
+ QML_NEARLY_ALWAYS_INLINE void setM(Heap::Base *b)
{
memcpy(&_val, &b, 8);
}
#else // !QV4_USE_64_BIT_VALUE_ENCODING
- Q_ALWAYS_INLINE Heap::Base *m() const
+ QML_NEARLY_ALWAYS_INLINE Heap::Base *m() const
{
Q_STATIC_ASSERT(sizeof(Heap::Base*) == sizeof(quint32));
Heap::Base *b;
@@ -195,7 +195,7 @@ public:
memcpy(&b, &v, 4);
return b;
}
- Q_ALWAYS_INLINE void setM(Heap::Base *b)
+ QML_NEARLY_ALWAYS_INLINE void setM(Heap::Base *b)
{
quint32 v;
memcpy(&v, &b, 4);
@@ -203,32 +203,32 @@ public:
}
#endif
- Q_ALWAYS_INLINE int int_32() const
+ QML_NEARLY_ALWAYS_INLINE int int_32() const
{
return int(value());
}
- Q_ALWAYS_INLINE void setInt_32(int i)
+ QML_NEARLY_ALWAYS_INLINE void setInt_32(int i)
{
setTagValue(Integer_Type_Internal, quint32(i));
}
- Q_ALWAYS_INLINE uint uint_32() const { return value(); }
+ QML_NEARLY_ALWAYS_INLINE uint uint_32() const { return value(); }
- Q_ALWAYS_INLINE void setEmpty()
+ QML_NEARLY_ALWAYS_INLINE void setEmpty()
{
setTagValue(Empty_Type_Internal, value());
}
- Q_ALWAYS_INLINE void setEmpty(int i)
+ QML_NEARLY_ALWAYS_INLINE void setEmpty(int i)
{
setTagValue(Empty_Type_Internal, quint32(i));
}
- Q_ALWAYS_INLINE void setEmpty(quint32 i)
+ QML_NEARLY_ALWAYS_INLINE void setEmpty(quint32 i)
{
setTagValue(Empty_Type_Internal, i);
}
- Q_ALWAYS_INLINE quint32 emptyValue()
+ QML_NEARLY_ALWAYS_INLINE quint32 emptyValue()
{
Q_ASSERT(isEmpty());
return quint32(value());
@@ -302,6 +302,7 @@ public:
inline bool isUndefined() const { return _val == 0; }
inline bool isDouble() const { return (_val >> IsDouble_Shift); }
inline bool isManaged() const { return !isUndefined() && ((_val >> IsManagedOrUndefined_Shift) == 0); }
+ inline bool isManagedOrUndefined() const { return ((_val >> IsManagedOrUndefined_Shift) == 0); }
inline bool integerCompatible() const {
return (_val >> IsIntegerConvertible_Shift) == 3;
@@ -317,6 +318,7 @@ public:
inline bool isUndefined() const { return tag() == Managed_Type_Internal && value() == 0; }
inline bool isDouble() const { return (tag() & NotDouble_Mask) != NotDouble_Mask; }
inline bool isManaged() const { return tag() == Managed_Type_Internal && !isUndefined(); }
+ inline bool isManagedOrUndefined() const { return tag() == Managed_Type_Internal; }
inline bool integerCompatible() const { return (tag() & ConvertibleToInt) == ConvertibleToInt; }
static inline bool integerCompatible(Value a, Value b) {
return ((a.tag() & b.tag()) & ConvertibleToInt) == ConvertibleToInt;
@@ -326,7 +328,7 @@ public:
}
inline bool isNaN() const { return (tag() & QV4::Value::NotDouble_Mask) == QV4::Value::NaN_Mask; }
#endif
- Q_ALWAYS_INLINE double doubleValue() const {
+ QML_NEARLY_ALWAYS_INLINE double doubleValue() const {
Q_ASSERT(isDouble());
double d;
quint64 v = _val;
@@ -336,7 +338,7 @@ public:
memcpy(&d, &v, 8);
return d;
}
- Q_ALWAYS_INLINE void setDouble(double d) {
+ QML_NEARLY_ALWAYS_INLINE void setDouble(double d) {
memcpy(&_val, &d, 8);
#ifdef QV4_USE_64_BIT_VALUE_ENCODING
_val ^= NaNEncodeMask;
@@ -371,23 +373,23 @@ public:
return int_32();
}
- Q_ALWAYS_INLINE String *stringValue() const {
+ QML_NEARLY_ALWAYS_INLINE String *stringValue() const {
if (!isString())
return nullptr;
- return m() ? reinterpret_cast<String*>(const_cast<Value *>(this)) : 0;
+ return reinterpret_cast<String*>(const_cast<Value *>(this));
}
- Q_ALWAYS_INLINE Object *objectValue() const {
+ QML_NEARLY_ALWAYS_INLINE Object *objectValue() const {
if (!isObject())
return nullptr;
- return m() ? reinterpret_cast<Object*>(const_cast<Value *>(this)) : 0;
+ return reinterpret_cast<Object*>(const_cast<Value *>(this));
}
- Q_ALWAYS_INLINE Managed *managed() const {
+ QML_NEARLY_ALWAYS_INLINE Managed *managed() const {
if (!isManaged())
return nullptr;
- return m() ? reinterpret_cast<Managed*>(const_cast<Value *>(this)) : 0;
+ return reinterpret_cast<Managed*>(const_cast<Value *>(this));
}
- Q_ALWAYS_INLINE Heap::Base *heapObject() const {
- return isManaged() ? m() : nullptr;
+ QML_NEARLY_ALWAYS_INLINE Heap::Base *heapObject() const {
+ return isManagedOrUndefined() ? m() : nullptr;
}
static inline Value fromHeapObject(Heap::Base *m)
@@ -420,7 +422,7 @@ public:
template <typename T>
const T *as() const {
- if (!m() || !isManaged())
+ if (!isManaged())
return 0;
Q_ASSERT(m()->vtable());
@@ -451,6 +453,7 @@ public:
}
inline uint asArrayIndex() const;
+ inline bool asArrayIndex(uint &idx) const;
#ifndef V4_BOOTSTRAP
uint asArrayLength(bool *ok) const;
#endif
@@ -485,15 +488,13 @@ V4_ASSERT_IS_TRIVIAL(Value)
inline bool Value::isString() const
{
- if (!isManaged())
- return false;
- return m() && m()->vtable()->isString;
+ Heap::Base *b = heapObject();
+ return b && b->vtable()->isString;
}
inline bool Value::isObject() const
{
- if (!isManaged())
- return false;
- return m() && m()->vtable()->isObject;
+ Heap::Base *b = heapObject();
+ return b && b->vtable()->isObject;
}
inline bool Value::isPrimitive() const
@@ -531,6 +532,20 @@ inline uint Value::asArrayIndex() const
return UINT_MAX;
return idx;
}
+
+inline bool Value::asArrayIndex(uint &idx) const
+{
+ if (!isDouble()) {
+ if (isInteger() && int_32() >= 0) {
+ idx = (uint)int_32();
+ return true;
+ }
+ return false;
+ }
+ double d = doubleValue();
+ idx = (uint)d;
+ return (idx == d);
+}
#endif
inline
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index 0f7f6b1f75..622359a7d9 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -169,10 +169,8 @@ static Breakpoint qt_v4LastStop;
static QV4::Function *qt_v4ExtractFunction(QV4::ExecutionContext *context)
{
- QV4::Scope scope(context->engine());
- QV4::ScopedFunctionObject function(scope, context->getFunctionObject());
- if (function)
- return function->function();
+ if (QV4::Function *function = context->getFunction())
+ return function;
else
return context->d()->engine->globalCode;
}
@@ -662,13 +660,13 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code
MOTH_END_INSTR(CallBuiltinPushCatchScope)
MOTH_BEGIN_INSTR(CallBuiltinPushScope)
- engine->runtime.pushWithScope(VALUE(instr.arg), engine);
+ engine->runtime.pushWithScope(VALUE(instr.arg), static_cast<QV4::NoThrowEngine*>(engine));
context = engine->currentContext;
CHECK_EXCEPTION;
MOTH_END_INSTR(CallBuiltinPushScope)
MOTH_BEGIN_INSTR(CallBuiltinPopScope)
- engine->runtime.popScope(engine);
+ engine->runtime.popScope(static_cast<QV4::NoThrowEngine*>(engine));
context = engine->currentContext;
MOTH_END_INSTR(CallBuiltinPopScope)
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp
index 6ef2380561..606d3ec162 100644
--- a/src/qml/memory/qv4mm.cpp
+++ b/src/qml/memory/qv4mm.cpp
@@ -421,11 +421,9 @@ void MemoryManager::mark()
// managed objects in the loop down there doesn't make then end up as leftovers
// on the stack and thus always get collected.
for (PersistentValueStorage::Iterator it = m_weakValues->begin(); it != m_weakValues->end(); ++it) {
- if (!(*it).isManaged())
+ QObjectWrapper *qobjectWrapper = (*it).as<QObjectWrapper>();
+ if (!qobjectWrapper)
continue;
- if (!(*it).as<QObjectWrapper>())
- continue;
- QObjectWrapper *qobjectWrapper = static_cast<QObjectWrapper*>((*it).managed());
QObject *qobject = qobjectWrapper->object();
if (!qobject)
continue;
@@ -453,10 +451,8 @@ void MemoryManager::mark()
void MemoryManager::sweep(bool lastSweep)
{
for (PersistentValueStorage::Iterator it = m_weakValues->begin(); it != m_weakValues->end(); ++it) {
- if (!(*it).isManaged())
- continue;
Managed *m = (*it).managed();
- if (m->markBit())
+ if (!m || m->markBit())
continue;
// we need to call destroyObject on qobjectwrappers now, so that they can emit the destroyed
// signal before we start sweeping the heap
@@ -469,10 +465,8 @@ void MemoryManager::sweep(bool lastSweep)
// onDestruction handlers may have accessed other QObject wrappers and reset their value, so ensure
// that they are all set to undefined.
for (PersistentValueStorage::Iterator it = m_weakValues->begin(); it != m_weakValues->end(); ++it) {
- if (!(*it).isManaged())
- continue;
- Managed *m = (*it).as<Managed>();
- if (m->markBit())
+ Managed *m = (*it).managed();
+ if (!m || m->markBit())
continue;
(*it) = Primitive::undefinedValue();
}
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g
index 161c8ffcde..9cd212015e 100644
--- a/src/qml/parser/qqmljs.g
+++ b/src/qml/parser/qqmljs.g
@@ -5,27 +5,33 @@
--
-- This file is part of the QtQml module of the Qt Toolkit.
--
--- $QT_BEGIN_LICENSE:LGPL21$
+-- $QT_BEGIN_LICENSE:LGPL$
-- Commercial License Usage
-- Licensees holding valid commercial Qt licenses may use this file in
-- accordance with the commercial license agreement provided with the
-- Software or, alternatively, in accordance with the terms contained in
-- a written agreement between you and The Qt Company. For licensing terms
--- and conditions see http://www.qt.io/terms-conditions. For further
--- information use the contact form at http://www.qt.io/contact-us.
+-- and conditions see https://www.qt.io/terms-conditions. For further
+-- information use the contact form at https://www.qt.io/contact-us.
--
-- GNU Lesser General Public License Usage
-- Alternatively, this file may be used under the terms of the GNU Lesser
--- General Public License version 2.1 or version 3 as published by the Free
--- Software Foundation and appearing in the file LICENSE.LGPLv21 and
--- LICENSE.LGPLv3 included in the packaging of this file. Please review the
--- following information to ensure the GNU Lesser General Public License
--- requirements will be met: https://www.gnu.org/licenses/lgpl.html and
--- http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+-- General Public License version 3 as published by the Free Software
+-- Foundation and appearing in the file LICENSE.LGPL3 included in the
+-- packaging of this file. Please review the following information to
+-- ensure the GNU Lesser General Public License version 3 requirements
+-- will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
--
--- As a special exception, The Qt Company gives you certain additional
--- rights. These rights are described in The Qt Company LGPL Exception
--- version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+-- GNU General Public License Usage
+-- Alternatively, this file may be used under the terms of the GNU
+-- General Public License version 2.0 or (at your option) the GNU General
+-- Public license version 3 or any later version approved by the KDE Free
+-- Qt Foundation. The licenses are as published by the Free Software
+-- Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+-- included in the packaging of this file. Please review the following
+-- information to ensure the GNU General Public License requirements will
+-- be met: https://www.gnu.org/licenses/gpl-2.0.html and
+-- https://www.gnu.org/licenses/gpl-3.0.html.
--
-- $QT_END_LICENSE$
--
@@ -136,6 +142,57 @@
**
****************************************************************************/
+#include "qqmljsengine_p.h"
+#include "qqmljslexer_p.h"
+#include "qqmljsast_p.h"
+#include "qqmljsmemorypool_p.h"
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qcoreapplication.h>
+
+#include <string.h>
+
+./
+
+/:/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
//
// W A R N I N G
@@ -273,7 +330,7 @@ public:
inline DiagnosticMessage diagnosticMessage() const
{
- foreach (const DiagnosticMessage &d, diagnostic_messages) {
+ for (const DiagnosticMessage &d : diagnostic_messages) {
if (d.kind != DiagnosticMessage::Warning)
return d;
}
@@ -859,8 +916,40 @@ case $rule_number:
./
UiPropertyType: T_VAR ;
+/.
+case $rule_number: {
+ AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(stringRef(1));
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
UiPropertyType: T_RESERVED_WORD ;
+/.
+case $rule_number: {
+ AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(stringRef(1));
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
UiPropertyType: T_IDENTIFIER ;
+/.
+case $rule_number: {
+ AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(stringRef(1));
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+./
+
+UiPropertyType: UiPropertyType T_DOT T_IDENTIFIER ;
+/.
+case $rule_number: {
+ AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(sym(1).UiQualifiedId, stringRef(3));
+ node->identifierToken = loc(3);
+ sym(1).Node = node;
+} break;
+./
UiParameterListOpt: ;
/.
@@ -879,7 +968,7 @@ case $rule_number: {
UiParameterList: UiPropertyType JsIdentifier ;
/.
case $rule_number: {
- AST::UiParameterList *node = new (pool) AST::UiParameterList(stringRef(1), stringRef(2));
+ AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiQualifiedId->finish(), stringRef(2));
node->propertyTypeToken = loc(1);
node->identifierToken = loc(2);
sym(1).Node = node;
@@ -889,7 +978,7 @@ case $rule_number: {
UiParameterList: UiParameterList T_COMMA UiPropertyType JsIdentifier ;
/.
case $rule_number: {
- AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4));
+ AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, sym(3).UiQualifiedId->finish(), stringRef(4));
node->propertyTypeToken = loc(3);
node->commaToken = loc(2);
node->identifierToken = loc(4);
@@ -901,7 +990,7 @@ UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_AUT
UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_SEMICOLON ;
/.
case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2));
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(nullptr, stringRef(2));
node->type = AST::UiPublicMember::Signal;
node->propertyToken = loc(1);
node->typeToken = loc(2);
@@ -916,7 +1005,7 @@ UiObjectMember: T_SIGNAL T_IDENTIFIER T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_SIGNAL T_IDENTIFIER T_SEMICOLON ;
/.
case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2));
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(nullptr, stringRef(2));
node->type = AST::UiPublicMember::Signal;
node->propertyToken = loc(1);
node->typeToken = loc(2);
@@ -930,7 +1019,7 @@ UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_
UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_SEMICOLON ;
/.
case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6));
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6));
node->typeModifier = stringRef(2);
node->propertyToken = loc(1);
node->typeModifierToken = loc(2);
@@ -945,7 +1034,7 @@ UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ;
UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ;
/.
case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3));
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3));
node->propertyToken = loc(1);
node->typeToken = loc(2);
node->identifierToken = loc(3);
@@ -958,7 +1047,7 @@ UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEM
UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ;
/.
case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4));
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4));
node->isDefaultMember = true;
node->defaultToken = loc(1);
node->propertyToken = loc(2);
@@ -969,10 +1058,27 @@ case $rule_number: {
} break;
./
+UiObjectMember: T_DEFAULT T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_AUTOMATIC_SEMICOLON ;
+UiObjectMember: T_DEFAULT T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_SEMICOLON ;
+/.
+case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(5).UiQualifiedId->finish(), stringRef(7));
+ node->isDefaultMember = true;
+ node->defaultToken = loc(1);
+ node->typeModifier = stringRef(3);
+ node->propertyToken = loc(2);
+ node->typeModifierToken = loc(2);
+ node->typeToken = loc(4);
+ node->identifierToken = loc(7);
+ node->semicolonToken = loc(8);
+ sym(1).Node = node;
+} break;
+./
+
UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ;
/.
case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3),
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3),
sym(5).Statement);
node->propertyToken = loc(1);
node->typeToken = loc(2);
@@ -985,7 +1091,7 @@ case $rule_number: {
UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ;
/.
case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4),
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4),
sym(6).Statement);
node->isReadonlyMember = true;
node->readonlyToken = loc(1);
@@ -1000,7 +1106,7 @@ case $rule_number: {
UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ;
/.
case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4),
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4),
sym(6).Statement);
node->isDefaultMember = true;
node->defaultToken = loc(1);
@@ -1015,7 +1121,7 @@ case $rule_number: {
UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ;
/.
case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6));
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6));
node->typeModifier = stringRef(2);
node->propertyToken = loc(1);
node->typeModifierToken = loc(2);
@@ -1042,7 +1148,7 @@ case $rule_number: {
UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiQualifiedId UiObjectInitializer ;
/.
case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3));
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3));
node->propertyToken = loc(1);
node->typeToken = loc(2);
node->identifierToken = loc(3);
@@ -1065,7 +1171,7 @@ case $rule_number: {
UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON UiQualifiedId UiObjectInitializer ;
/.
case $rule_number: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4));
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4));
node->isReadonlyMember = true;
node->readonlyToken = loc(1);
node->propertyToken = loc(2);
@@ -3003,7 +3109,7 @@ PropertyAssignmentListOpt: PropertyAssignmentList ;
yylloc.startColumn += yylloc.length;
yylloc.length = 0;
- //const QString msg = qApp->translate("QQmlParser", "Missing `;'");
+ //const QString msg = QCoreApplication::translate("QQmlParser", "Missing `;'");
//diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg));
first_token = &token_buffer[0];
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index 846ea42571..9b06bf3d31 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -253,7 +253,7 @@ class QML_PARSER_EXPORT ExpressionNode: public Node
public:
ExpressionNode() {}
- virtual ExpressionNode *expressionCast();
+ ExpressionNode *expressionCast() override;
};
class QML_PARSER_EXPORT Statement: public Node
@@ -261,7 +261,7 @@ class QML_PARSER_EXPORT Statement: public Node
public:
Statement() {}
- virtual Statement *statementCast();
+ Statement *statementCast() override;
};
class QML_PARSER_EXPORT NestedExpression: public ExpressionNode
@@ -2537,11 +2537,11 @@ class QML_PARSER_EXPORT UiParameterList: public Node
public:
QQMLJS_DECLARE_AST_NODE(UiParameterList)
- UiParameterList(const QStringRef &t, const QStringRef &n):
+ UiParameterList(UiQualifiedId *t, const QStringRef &n):
type (t), name (n), next (this)
{ kind = K; }
- UiParameterList(UiParameterList *previous, const QStringRef &t, const QStringRef &n):
+ UiParameterList(UiParameterList *previous, UiQualifiedId *t, const QStringRef &n):
type (t), name (n)
{
kind = K;
@@ -2565,7 +2565,7 @@ public:
}
// attributes
- QStringRef type;
+ UiQualifiedId *type;
QStringRef name;
UiParameterList *next;
SourceLocation commaToken;
@@ -2578,12 +2578,12 @@ class QML_PARSER_EXPORT UiPublicMember: public UiObjectMember
public:
QQMLJS_DECLARE_AST_NODE(UiPublicMember)
- UiPublicMember(const QStringRef &memberType,
+ UiPublicMember(UiQualifiedId *memberType,
const QStringRef &name)
: type(Property), memberType(memberType), name(name), statement(0), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0)
{ kind = K; }
- UiPublicMember(const QStringRef &memberType,
+ UiPublicMember(UiQualifiedId *memberType,
const QStringRef &name,
Statement *statement)
: type(Property), memberType(memberType), name(name), statement(statement), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0)
@@ -2614,7 +2614,7 @@ public:
// attributes
enum { Signal, Property } type;
QStringRef typeModifier;
- QStringRef memberType;
+ UiQualifiedId *memberType;
QStringRef name;
Statement *statement; // initialized with a JS expression
UiObjectMember *binding; // initialized with a QML object or array.
diff --git a/src/qml/parser/qqmljsgrammar.cpp b/src/qml/parser/qqmljsgrammar.cpp
index d7fea7d815..b27f4af080 100644
--- a/src/qml/parser/qqmljsgrammar.cpp
+++ b/src/qml/parser/qqmljsgrammar.cpp
@@ -61,37 +61,38 @@ const short QQmlJSGrammar::lhs [] = {
118, 118, 118, 118, 118, 122, 123, 115, 114, 126,
126, 127, 127, 128, 128, 125, 111, 111, 111, 111,
130, 130, 130, 130, 130, 130, 130, 111, 138, 138,
- 138, 139, 139, 140, 140, 111, 111, 111, 111, 111,
+ 138, 138, 139, 139, 140, 140, 111, 111, 111, 111,
111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
- 111, 111, 111, 124, 124, 124, 124, 124, 124, 124,
+ 111, 111, 111, 111, 111, 111, 124, 124, 124, 124,
+ 124, 124, 124, 143, 143, 143, 143, 143, 143, 143,
143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
- 143, 143, 143, 143, 143, 143, 143, 143, 129, 145,
- 145, 145, 145, 144, 144, 149, 149, 149, 147, 147,
- 150, 150, 150, 150, 153, 153, 153, 153, 153, 153,
+ 143, 129, 145, 145, 145, 145, 144, 144, 149, 149,
+ 149, 147, 147, 150, 150, 150, 150, 153, 153, 153,
153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
- 153, 153, 153, 153, 153, 154, 154, 120, 120, 120,
- 120, 120, 157, 157, 158, 158, 158, 158, 156, 156,
- 159, 159, 160, 160, 161, 161, 161, 162, 162, 162,
- 162, 162, 162, 162, 162, 162, 162, 163, 163, 163,
- 163, 164, 164, 164, 165, 165, 165, 165, 166, 166,
- 166, 166, 166, 166, 166, 167, 167, 167, 167, 167,
- 167, 168, 168, 168, 168, 168, 169, 169, 169, 169,
- 169, 170, 170, 171, 171, 172, 172, 173, 173, 174,
- 174, 175, 175, 176, 176, 177, 177, 178, 178, 179,
- 179, 180, 180, 181, 181, 148, 148, 182, 182, 183,
- 183, 183, 183, 183, 183, 183, 183, 183, 183, 183,
- 183, 109, 109, 184, 184, 185, 185, 186, 186, 108,
- 108, 108, 108, 108, 108, 108, 108, 108, 108, 108,
- 108, 108, 108, 108, 131, 195, 195, 194, 194, 142,
- 142, 196, 196, 197, 197, 199, 199, 198, 200, 203,
- 201, 201, 204, 202, 202, 132, 133, 133, 134, 134,
- 187, 187, 187, 187, 187, 187, 187, 187, 188, 188,
- 188, 188, 189, 189, 189, 189, 190, 190, 135, 136,
- 205, 205, 208, 208, 206, 206, 209, 207, 191, 192,
- 192, 137, 137, 137, 210, 211, 193, 193, 212, 141,
- 155, 155, 213, 213, 152, 152, 151, 151, 214, 112,
- 112, 215, 215, 110, 110, 146, 146, 216};
+ 153, 153, 153, 153, 153, 153, 153, 153, 154, 154,
+ 120, 120, 120, 120, 120, 157, 157, 158, 158, 158,
+ 158, 156, 156, 159, 159, 160, 160, 161, 161, 161,
+ 162, 162, 162, 162, 162, 162, 162, 162, 162, 162,
+ 163, 163, 163, 163, 164, 164, 164, 165, 165, 165,
+ 165, 166, 166, 166, 166, 166, 166, 166, 167, 167,
+ 167, 167, 167, 167, 168, 168, 168, 168, 168, 169,
+ 169, 169, 169, 169, 170, 170, 171, 171, 172, 172,
+ 173, 173, 174, 174, 175, 175, 176, 176, 177, 177,
+ 178, 178, 179, 179, 180, 180, 181, 181, 148, 148,
+ 182, 182, 183, 183, 183, 183, 183, 183, 183, 183,
+ 183, 183, 183, 183, 109, 109, 184, 184, 185, 185,
+ 186, 186, 108, 108, 108, 108, 108, 108, 108, 108,
+ 108, 108, 108, 108, 108, 108, 108, 131, 195, 195,
+ 194, 194, 142, 142, 196, 196, 197, 197, 199, 199,
+ 198, 200, 203, 201, 201, 204, 202, 202, 132, 133,
+ 133, 134, 134, 187, 187, 187, 187, 187, 187, 187,
+ 187, 188, 188, 188, 188, 189, 189, 189, 189, 190,
+ 190, 135, 136, 205, 205, 208, 208, 206, 206, 209,
+ 207, 191, 192, 192, 137, 137, 137, 210, 211, 193,
+ 193, 212, 141, 155, 155, 213, 213, 152, 152, 151,
+ 151, 214, 112, 112, 215, 215, 110, 110, 146, 146,
+ 216};
const short QQmlJSGrammar::rhs [] = {
2, 2, 2, 2, 2, 2, 2, 1, 1, 1,
@@ -99,112 +100,114 @@ const short QQmlJSGrammar::rhs [] = {
3, 5, 5, 4, 4, 2, 2, 0, 1, 1,
2, 1, 3, 2, 3, 2, 1, 5, 4, 4,
1, 1, 1, 1, 1, 1, 1, 3, 1, 1,
- 1, 0, 1, 2, 4, 6, 6, 3, 3, 7,
- 7, 4, 4, 5, 5, 5, 6, 6, 10, 6,
- 7, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 3, 0, 1, 2, 4, 6, 6, 3, 3,
+ 7, 7, 4, 4, 5, 5, 8, 8, 5, 6,
+ 6, 10, 6, 7, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 3, 3, 4, 5, 3, 4, 3, 1, 1,
- 2, 3, 4, 1, 2, 3, 7, 8, 1, 3,
+ 1, 1, 1, 2, 3, 3, 4, 5, 3, 4,
+ 3, 1, 1, 2, 3, 4, 1, 2, 3, 7,
+ 8, 1, 3, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 4,
- 3, 5, 1, 2, 4, 4, 4, 3, 0, 1,
- 1, 3, 1, 1, 1, 2, 2, 1, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 1, 3, 3,
- 3, 1, 3, 3, 1, 3, 3, 3, 1, 3,
- 3, 3, 3, 3, 3, 1, 3, 3, 3, 3,
- 3, 1, 3, 3, 3, 3, 1, 3, 3, 3,
- 3, 1, 3, 1, 3, 1, 3, 1, 3, 1,
- 3, 1, 3, 1, 3, 1, 3, 1, 3, 1,
- 3, 1, 5, 1, 5, 1, 3, 1, 3, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 3, 0, 1, 1, 3, 0, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 3, 1, 2, 0, 1, 3,
- 3, 1, 1, 1, 3, 1, 3, 2, 2, 2,
- 0, 1, 2, 0, 1, 1, 2, 2, 7, 5,
- 7, 7, 7, 5, 9, 10, 7, 8, 2, 2,
- 3, 3, 2, 2, 3, 3, 3, 3, 5, 5,
- 3, 5, 1, 2, 0, 1, 4, 3, 3, 3,
- 3, 3, 3, 4, 5, 2, 2, 2, 1, 8,
- 8, 7, 1, 3, 0, 1, 0, 1, 1, 1,
- 1, 1, 2, 1, 1, 0, 1, 2};
+ 1, 1, 4, 3, 5, 1, 2, 4, 4, 4,
+ 3, 0, 1, 1, 3, 1, 1, 1, 2, 2,
+ 1, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 1, 3, 3, 3, 1, 3, 3, 1, 3, 3,
+ 3, 1, 3, 3, 3, 3, 3, 3, 1, 3,
+ 3, 3, 3, 3, 1, 3, 3, 3, 3, 1,
+ 3, 3, 3, 3, 1, 3, 1, 3, 1, 3,
+ 1, 3, 1, 3, 1, 3, 1, 3, 1, 3,
+ 1, 3, 1, 3, 1, 5, 1, 5, 1, 3,
+ 1, 3, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 3, 0, 1, 1, 3,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 3, 1, 2,
+ 0, 1, 3, 3, 1, 1, 1, 3, 1, 3,
+ 2, 2, 2, 0, 1, 2, 0, 1, 1, 2,
+ 2, 7, 5, 7, 7, 7, 5, 9, 10, 7,
+ 8, 2, 2, 3, 3, 2, 2, 3, 3, 3,
+ 3, 5, 5, 3, 5, 1, 2, 0, 1, 4,
+ 3, 3, 3, 3, 3, 3, 4, 5, 2, 2,
+ 2, 1, 8, 8, 7, 1, 3, 0, 1, 0,
+ 1, 1, 1, 1, 1, 2, 1, 1, 0, 1,
+ 2};
const short QQmlJSGrammar::action_default [] = {
- 0, 0, 28, 0, 0, 0, 28, 0, 185, 252,
- 216, 224, 220, 164, 236, 212, 3, 149, 82, 165,
- 228, 232, 153, 182, 163, 168, 148, 202, 189, 0,
- 89, 90, 85, 0, 79, 74, 356, 0, 0, 0,
- 0, 87, 0, 0, 83, 86, 78, 0, 0, 75,
- 77, 80, 76, 88, 81, 0, 84, 0, 0, 178,
- 0, 0, 165, 184, 167, 166, 0, 0, 0, 180,
- 181, 179, 183, 0, 213, 0, 0, 0, 0, 203,
- 0, 0, 0, 0, 0, 0, 193, 0, 0, 0,
- 187, 188, 186, 191, 195, 194, 192, 190, 205, 204,
- 206, 0, 221, 0, 217, 0, 0, 159, 146, 158,
- 147, 115, 116, 117, 142, 118, 143, 119, 120, 121,
- 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
- 144, 132, 133, 134, 135, 136, 137, 138, 139, 140,
- 141, 145, 0, 0, 157, 253, 160, 0, 161, 0,
- 162, 156, 0, 249, 242, 240, 247, 248, 246, 245,
- 251, 244, 243, 241, 250, 237, 0, 225, 0, 0,
- 229, 0, 0, 233, 0, 0, 159, 151, 0, 150,
- 0, 155, 169, 0, 345, 345, 346, 0, 343, 0,
- 344, 0, 347, 260, 267, 266, 274, 262, 0, 263,
- 0, 348, 0, 355, 264, 265, 82, 270, 268, 352,
- 349, 354, 271, 0, 282, 0, 0, 0, 0, 339,
- 0, 356, 254, 296, 0, 0, 0, 283, 0, 0,
- 272, 273, 0, 261, 269, 297, 298, 0, 345, 0,
- 0, 347, 0, 340, 341, 0, 329, 353, 0, 313,
- 314, 315, 316, 0, 309, 310, 311, 312, 337, 338,
- 0, 0, 0, 0, 0, 301, 302, 303, 258, 256,
- 218, 226, 222, 238, 214, 259, 0, 165, 230, 234,
- 207, 196, 0, 0, 215, 0, 0, 0, 0, 208,
- 0, 0, 0, 0, 0, 200, 198, 201, 199, 197,
- 210, 209, 211, 0, 223, 0, 219, 0, 257, 165,
- 0, 239, 254, 255, 0, 254, 0, 0, 305, 0,
- 0, 0, 307, 0, 227, 0, 0, 231, 0, 0,
- 235, 294, 0, 286, 295, 289, 0, 293, 0, 254,
- 287, 0, 254, 0, 0, 306, 0, 0, 0, 308,
- 0, 0, 0, 300, 0, 299, 82, 109, 357, 0,
- 0, 114, 276, 279, 0, 115, 282, 118, 143, 120,
- 121, 85, 125, 126, 79, 127, 130, 83, 86, 254,
- 80, 88, 133, 81, 135, 84, 137, 138, 283, 140,
- 141, 145, 0, 111, 110, 113, 97, 112, 96, 0,
- 106, 277, 275, 0, 0, 0, 347, 0, 107, 153,
- 154, 159, 0, 152, 0, 317, 318, 0, 345, 0,
- 0, 347, 0, 108, 0, 0, 0, 320, 325, 323,
- 326, 0, 0, 324, 325, 0, 321, 0, 322, 278,
- 328, 0, 278, 327, 0, 330, 331, 0, 278, 332,
- 333, 0, 0, 334, 0, 0, 0, 335, 336, 171,
- 170, 0, 0, 0, 304, 0, 0, 0, 319, 291,
- 284, 0, 292, 288, 0, 290, 280, 0, 281, 285,
- 0, 0, 347, 0, 342, 100, 0, 0, 104, 91,
- 0, 93, 102, 0, 94, 103, 105, 95, 101, 92,
- 0, 98, 175, 173, 177, 174, 172, 176, 350, 6,
- 351, 4, 2, 72, 99, 0, 0, 75, 77, 76,
- 37, 5, 0, 73, 0, 51, 50, 49, 0, 0,
- 64, 0, 65, 41, 42, 43, 44, 46, 47, 68,
- 45, 0, 51, 0, 0, 0, 0, 0, 60, 0,
- 61, 0, 0, 32, 0, 0, 69, 33, 0, 36,
- 34, 30, 0, 35, 31, 0, 62, 0, 63, 153,
- 0, 66, 70, 0, 0, 0, 0, 153, 278, 0,
- 67, 82, 115, 282, 118, 143, 120, 121, 85, 125,
- 126, 127, 130, 83, 86, 254, 88, 133, 81, 135,
- 84, 137, 138, 283, 140, 141, 145, 71, 0, 58,
- 52, 59, 53, 0, 0, 0, 0, 55, 0, 56,
- 57, 54, 0, 0, 0, 0, 48, 0, 38, 39,
- 0, 40, 8, 0, 0, 9, 0, 11, 0, 10,
- 0, 1, 27, 15, 14, 26, 13, 12, 29, 7,
- 0, 18, 0, 19, 0, 24, 25, 0, 20, 21,
- 0, 22, 23, 16, 17, 358};
+ 0, 0, 28, 0, 0, 0, 28, 0, 188, 255,
+ 219, 227, 223, 167, 239, 215, 3, 152, 85, 168,
+ 231, 235, 156, 185, 166, 171, 151, 205, 192, 0,
+ 92, 93, 88, 0, 82, 77, 359, 0, 0, 0,
+ 0, 90, 0, 0, 86, 89, 81, 0, 0, 78,
+ 80, 83, 79, 91, 84, 0, 87, 0, 0, 181,
+ 0, 0, 168, 187, 170, 169, 0, 0, 0, 183,
+ 184, 182, 186, 0, 216, 0, 0, 0, 0, 206,
+ 0, 0, 0, 0, 0, 0, 196, 0, 0, 0,
+ 190, 191, 189, 194, 198, 197, 195, 193, 208, 207,
+ 209, 0, 224, 0, 220, 0, 0, 162, 149, 161,
+ 150, 118, 119, 120, 145, 121, 146, 122, 123, 124,
+ 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
+ 147, 135, 136, 137, 138, 139, 140, 141, 142, 143,
+ 144, 148, 0, 0, 160, 256, 163, 0, 164, 0,
+ 165, 159, 0, 252, 245, 243, 250, 251, 249, 248,
+ 254, 247, 246, 244, 253, 240, 0, 228, 0, 0,
+ 232, 0, 0, 236, 0, 0, 162, 154, 0, 153,
+ 0, 158, 172, 0, 348, 348, 349, 0, 346, 0,
+ 347, 0, 350, 263, 270, 269, 277, 265, 0, 266,
+ 0, 351, 0, 358, 267, 268, 85, 273, 271, 355,
+ 352, 357, 274, 0, 285, 0, 0, 0, 0, 342,
+ 0, 359, 257, 299, 0, 0, 0, 286, 0, 0,
+ 275, 276, 0, 264, 272, 300, 301, 0, 348, 0,
+ 0, 350, 0, 343, 344, 0, 332, 356, 0, 316,
+ 317, 318, 319, 0, 312, 313, 314, 315, 340, 341,
+ 0, 0, 0, 0, 0, 304, 305, 306, 261, 259,
+ 221, 229, 225, 241, 217, 262, 0, 168, 233, 237,
+ 210, 199, 0, 0, 218, 0, 0, 0, 0, 211,
+ 0, 0, 0, 0, 0, 203, 201, 204, 202, 200,
+ 213, 212, 214, 0, 226, 0, 222, 0, 260, 168,
+ 0, 242, 257, 258, 0, 257, 0, 0, 308, 0,
+ 0, 0, 310, 0, 230, 0, 0, 234, 0, 0,
+ 238, 297, 0, 289, 298, 292, 0, 296, 0, 257,
+ 290, 0, 257, 0, 0, 309, 0, 0, 0, 311,
+ 0, 0, 0, 303, 0, 302, 85, 112, 360, 0,
+ 0, 117, 279, 282, 0, 118, 285, 121, 146, 123,
+ 124, 88, 128, 129, 82, 130, 133, 86, 89, 257,
+ 83, 91, 136, 84, 138, 87, 140, 141, 286, 143,
+ 144, 148, 0, 114, 113, 116, 100, 115, 99, 0,
+ 109, 280, 278, 0, 0, 0, 350, 0, 110, 156,
+ 157, 162, 0, 155, 0, 320, 321, 0, 348, 0,
+ 0, 350, 0, 111, 0, 0, 0, 323, 328, 326,
+ 329, 0, 0, 327, 328, 0, 324, 0, 325, 281,
+ 331, 0, 281, 330, 0, 333, 334, 0, 281, 335,
+ 336, 0, 0, 337, 0, 0, 0, 338, 339, 174,
+ 173, 0, 0, 0, 307, 0, 0, 0, 322, 294,
+ 287, 0, 295, 291, 0, 293, 283, 0, 284, 288,
+ 0, 0, 350, 0, 345, 103, 0, 0, 107, 94,
+ 0, 96, 105, 0, 97, 106, 108, 98, 104, 95,
+ 0, 101, 178, 176, 180, 177, 175, 179, 353, 6,
+ 354, 4, 2, 75, 102, 0, 0, 78, 80, 79,
+ 37, 5, 0, 76, 0, 51, 50, 49, 0, 0,
+ 51, 0, 0, 0, 52, 0, 67, 68, 0, 65,
+ 0, 66, 41, 42, 43, 44, 46, 47, 71, 45,
+ 0, 51, 0, 0, 0, 0, 0, 61, 0, 62,
+ 0, 0, 32, 0, 0, 72, 33, 0, 36, 34,
+ 30, 0, 35, 31, 0, 63, 0, 64, 156, 0,
+ 69, 73, 0, 0, 0, 0, 156, 281, 0, 70,
+ 85, 118, 285, 121, 146, 123, 124, 88, 128, 129,
+ 130, 133, 86, 89, 257, 91, 136, 84, 138, 87,
+ 140, 141, 286, 143, 144, 148, 74, 0, 59, 53,
+ 60, 54, 0, 0, 0, 0, 56, 0, 57, 58,
+ 55, 0, 0, 0, 0, 48, 0, 38, 39, 0,
+ 40, 8, 0, 0, 9, 0, 11, 0, 10, 0,
+ 1, 27, 15, 14, 26, 13, 12, 29, 7, 0,
+ 18, 0, 19, 0, 24, 25, 0, 20, 21, 0,
+ 22, 23, 16, 17, 361};
const short QQmlJSGrammar::goto_default [] = {
- 7, 641, 211, 198, 209, 521, 509, 636, 649, 508,
- 635, 639, 637, 645, 22, 642, 640, 638, 18, 520,
- 562, 552, 559, 554, 539, 193, 197, 199, 204, 234,
- 212, 231, 543, 613, 612, 203, 233, 26, 487, 486,
+ 7, 650, 211, 198, 209, 521, 509, 645, 658, 508,
+ 644, 648, 646, 654, 22, 651, 649, 647, 18, 520,
+ 571, 561, 568, 563, 548, 193, 197, 199, 204, 234,
+ 212, 231, 552, 622, 621, 203, 233, 26, 487, 486,
359, 358, 9, 357, 360, 202, 480, 361, 109, 17,
147, 24, 13, 146, 19, 25, 59, 23, 8, 28,
27, 280, 15, 274, 10, 270, 12, 272, 11, 271,
@@ -215,217 +218,225 @@ const short QQmlJSGrammar::goto_default [] = {
0};
const short QQmlJSGrammar::action_index [] = {
- 264, 1225, 2708, 2708, 2606, 938, 94, 104, 119, -106,
- 92, 79, 81, 262, -106, 263, 78, -106, -106, 654,
- 89, 125, 259, 229, -106, -106, -106, 322, 314, 1225,
- -106, -106, -106, 412, -106, -106, 2300, 1713, 1225, 1225,
- 1225, -106, 842, 1225, -106, -106, -106, 1225, 1225, -106,
- -106, -106, -106, -106, -106, 1225, -106, 1225, 1225, -106,
- 1225, 1225, 141, 216, -106, -106, 1225, 1225, 1225, -106,
- -106, -106, 209, 1225, 281, 1225, 1225, 1225, 1225, 367,
- 1225, 1225, 1225, 1225, 1225, 1225, 219, 1225, 1225, 1225,
- 101, 102, 115, 314, 314, 314, 314, 314, 357, 347,
- 337, 1225, 71, 1225, 70, 2198, 1225, 1225, -106, -106,
+ 246, 1285, 2768, 2768, 2666, 998, 98, 198, 86, -106,
+ 26, -15, -39, 234, -106, 314, 54, -106, -106, 714,
+ 89, 151, 212, 219, -106, -106, -106, 412, 279, 1285,
+ -106, -106, -106, 525, -106, -106, 2360, 1675, 1285, 1285,
+ 1285, -106, 902, 1285, -106, -106, -106, 1285, 1285, -106,
+ -106, -106, -106, -106, -106, 1285, -106, 1285, 1285, -106,
+ 1285, 1285, 103, 197, -106, -106, 1285, 1285, 1285, -106,
+ -106, -106, 214, 1285, 297, 1285, 1285, 1285, 1285, 392,
+ 1285, 1285, 1285, 1285, 1285, 1285, 213, 1285, 1285, 1285,
+ 96, 100, 101, 279, 279, 195, 190, 181, 402, 372,
+ 382, 1285, -10, 1285, 106, 2258, 1285, 1285, -106, -106,
-106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
-106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
-106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
- -106, -106, 98, 1225, -106, -106, 66, 65, -106, 1225,
- -106, -106, 1225, -106, -106, -106, -106, -106, -106, -106,
- -106, -106, -106, -106, -106, -106, 1225, 44, 1225, 1225,
- 64, 57, 1225, -106, 2198, 1225, 1225, -106, 137, -106,
- 49, -106, -106, 93, 344, 474, 95, 86, -106, 390,
- -106, 85, 2708, -106, -106, -106, -106, -106, 189, -106,
- 474, -106, 80, -106, -106, -106, 83, -106, -106, -106,
- 2708, -106, -106, 490, -106, 551, 130, 2606, 46, 51,
- 52, 2912, 1225, -106, 63, 1225, 56, -106, 58, 60,
- -106, -106, 474, -106, -106, -106, -106, 61, 474, 62,
- 67, 2708, 68, -106, -106, 2606, -106, -106, 87, -106,
- -106, -106, -106, 110, -106, -106, -106, -106, -106, -106,
- -24, 69, 1225, 122, 143, -106, -106, -106, 1419, -106,
- 74, 76, 77, -106, 269, 73, 72, 611, 75, 114,
- 397, 314, 474, 1225, 287, 1225, 1225, 1225, 1225, 397,
- 1225, 1225, 1225, 1225, 1225, 218, 215, 198, 192, 182,
- 397, 397, 312, 1225, 55, 1225, 59, 1225, -106, 654,
- 1225, -106, 1225, 54, 53, 1225, 50, 2606, -106, 1225,
- 124, 2606, -106, 1225, 90, 1225, 1225, 105, 88, 1225,
- -106, 84, 157, -27, -106, -106, 1225, -106, 474, 1225,
- -106, 82, 1225, 91, 2606, -106, 1225, 120, 2606, -106,
- 1225, 103, 2606, -9, 2606, -106, -2, -106, 11, -30,
- 17, -106, -106, 2606, -37, 469, 15, 551, 138, 1225,
- 2606, 14, -16, 433, 2402, -20, 842, 6, 5, 1324,
- 2402, 4, -36, 2, 1225, 7, -18, 1225, 10, 1225,
- -26, -13, 2504, -106, -106, -106, -106, -106, -106, 1225,
- -106, -106, -106, -33, -59, -25, 2708, 23, -106, 197,
- -106, 1225, -12, -106, 140, -106, -106, 22, 474, -4,
- 26, 2708, 12, -106, 1225, 113, 30, -106, 142, -106,
- 142, 121, 1225, -106, -3, 45, -106, -5, -106, 2606,
- -106, 108, 2606, -106, 207, -106, -106, 106, 2606, 37,
- -106, 25, 36, -106, 474, 38, 40, -106, -106, -106,
- -106, 1225, 136, 2606, -106, 1225, 166, 2606, -106, 13,
- -106, 200, -106, -106, 1225, -106, -106, 474, -106, -106,
- -17, 16, 2708, -11, -106, -106, 131, 1811, -106, -106,
- 1615, -106, -106, 1517, -106, -106, -106, -106, -106, -106,
- 109, -106, -106, -106, -106, -106, -106, -106, -106, -106,
- 2708, -106, -106, -106, 233, -19, 748, 152, -60, 41,
- -106, -106, 191, -106, 177, -106, -106, -106, 387, 203,
- -106, 1906, -106, -106, -106, -106, -106, -106, -106, -106,
- -106, 180, 43, 376, 174, 48, 474, 240, -106, 8,
- -106, 748, 111, -106, -1, 748, -106, -106, 1130, -106,
- -106, -106, 1034, -106, -106, 228, -106, 1906, -106, 295,
- 21, -106, -106, 184, 379, 39, 2001, 288, 2810, 18,
- -106, 34, 482, 33, 551, 138, 1225, 2606, 31, 9,
- 399, 3, 643, 19, 29, 1324, 28, 1, 27, 1225,
- 24, 0, 1225, 20, 1225, -7, -8, -106, 193, -106,
- 205, -106, 47, 42, 329, 208, 319, -106, 128, -106,
- -106, -106, 2096, 748, 1713, 35, -106, 132, -106, -106,
- 32, -106, -106, 748, 748, 94, 748, -106, 250, -106,
- 116, -106, -106, 233, 233, -106, -106, -106, -106, -106,
- 393, -106, 214, -106, 100, -106, -106, 474, -106, -106,
- 96, -106, -106, -106, -106, -106,
+ -106, -106, 136, 1285, -106, -106, 65, 29, -106, 1285,
+ -106, -106, 1285, -106, -106, -106, -106, -106, -106, -106,
+ -106, -106, -106, -106, -106, -106, 1285, -46, 1285, 1285,
+ 30, 27, 1285, -106, 2258, 1285, 1285, -106, 130, -106,
+ -31, -106, -106, -16, 520, 520, 71, 21, -106, 421,
+ -106, 38, 2768, -106, -106, -106, -106, -106, 237, -106,
+ 520, -106, -52, -106, -106, -106, 23, -106, -106, -106,
+ 2768, -106, -106, 596, -106, 588, 141, 2666, 2, 1,
+ -1, 2972, 1285, -106, 13, 1285, 28, -106, -28, -30,
+ -106, -106, 435, -106, -106, -106, -106, 60, 520, 52,
+ 67, 2768, 64, -106, -106, 2666, -106, -106, 126, -106,
+ -106, -106, -106, 73, -106, -106, -106, -106, -106, -106,
+ -18, 34, 1285, 156, 168, -106, -106, -106, 1479, -106,
+ 79, 40, 48, -106, 312, 75, 42, 672, 80, 143,
+ 331, 279, 442, 1285, 316, 1285, 1285, 1285, 1285, 341,
+ 1285, 1285, 1285, 1285, 1285, 279, 360, 360, 196, 225,
+ 443, 357, 351, 1285, -4, 1285, 63, 1285, -106, 714,
+ 1285, -106, 1285, 102, 68, 1285, 62, 2666, -106, 1285,
+ 147, 2666, -106, 1285, 56, 1285, 1285, 91, 87, 1285,
+ -106, 81, 149, 74, -106, -106, 1285, -106, 439, 1285,
+ -106, -44, 1285, -42, 2666, -106, 1285, 153, 2666, -106,
+ 1285, 154, 2666, 10, 2666, -106, 0, -106, 15, -54,
+ 92, -106, -106, 2666, -50, 539, -7, 536, 121, 1285,
+ 2666, 5, -8, 445, 2462, 24, 902, 51, 50, 1384,
+ 2462, 47, 20, 46, 1285, 44, 19, 1285, 41, 1285,
+ 3, -5, 2564, -106, -106, -106, -106, -106, -106, 1285,
+ -106, -106, -106, 6, -17, 11, 2768, -9, -106, 249,
+ -106, 1285, -13, -106, 105, -106, -106, -12, 520, -41,
+ -20, 2768, -45, -106, 1285, 115, 12, -106, 36, -106,
+ 31, 122, 1285, -106, 58, 4, -106, -51, -106, 2666,
+ -106, 146, 2666, -106, 235, -106, -106, 140, 2666, 93,
+ -106, 84, 76, -106, 520, 17, 33, -106, -106, -106,
+ -106, 1285, 134, 2666, -106, 1285, 125, 2666, -106, 55,
+ -106, 163, -106, -106, 1285, -106, -106, 520, -106, -106,
+ 7, 45, 2768, 32, -106, -106, 120, 1773, -106, -106,
+ 1577, -106, -106, 1871, -106, -106, -106, -106, -106, -106,
+ 113, -106, -106, -106, -106, -106, -106, -106, -106, -106,
+ 2768, -106, -106, -106, 109, 35, 808, 206, 49, 61,
+ -106, -106, 229, -106, 203, 37, -106, -106, 611, 183,
+ -106, 124, 39, 389, -106, 97, -106, -106, 252, -106,
+ 2061, -106, -106, -106, -106, -106, -106, -106, -106, -106,
+ 269, -23, 611, 243, 180, 424, 232, -106, 16, -106,
+ 808, 162, -106, 22, 808, -106, -106, 1190, -106, -106,
+ -106, 1094, -106, -106, 248, -106, 2061, -106, 305, -24,
+ -106, -106, 215, 457, 18, 2156, 292, 2870, -11, -106,
+ 14, 599, 9, 528, 119, 1285, 2666, 8, 70, 514,
+ 72, 902, 95, 90, 1384, 85, 59, 77, 1285, 110,
+ 83, 1285, 104, 1285, 82, 78, -106, 205, -106, 236,
+ -106, 57, 25, 611, 167, 517, -106, 107, -106, -106,
+ -106, 1966, 808, 1675, 43, -106, 155, -106, -106, 53,
+ -106, -106, 808, 808, 108, 808, -106, 289, -106, 117,
+ -106, -106, 150, 157, -106, -106, -106, -106, -106, 364,
+ -106, 226, -106, 69, -106, -106, 432, -106, -106, 88,
+ -106, -106, -106, -106, -106,
- -111, 15, 71, 87, 80, 305, -6, -111, -111, -111,
- -111, -111, -111, -111, -111, -111, -111, -111, -111, -42,
- -111, -111, -111, -111, -111, -111, -111, -111, -111, 95,
- -111, -111, -111, 3, -111, -111, -5, -11, 9, 109,
- 91, -111, 62, 45, -111, -111, -111, 50, 63, -111,
- -111, -111, -111, -111, -111, 32, -111, 203, 197, -111,
- 189, 178, -111, -111, -111, -111, 182, 185, 188, -111,
- -111, -111, -111, 193, -111, 198, 168, 113, 114, -111,
- 133, 116, 123, 129, 130, 132, -111, 136, 139, 142,
+ -111, 8, 65, 83, 84, 317, 1, -111, -111, -111,
+ -111, -111, -111, -111, -111, -111, -111, -111, -111, -77,
+ -111, -111, -111, -111, -111, -111, -111, -111, -111, 96,
+ -111, -111, -111, 2, -111, -111, -5, -28, 12, 106,
+ 95, -111, 61, 55, -111, -111, -111, 63, 70, -111,
+ -111, -111, -111, -111, -111, 54, -111, 172, 177, -111,
+ 180, 191, -111, -111, -111, -111, 197, 202, 203, -111,
+ -111, -111, -111, 210, -111, 209, 195, 109, 116, -111,
+ 146, 125, 126, 127, 135, 138, -111, 141, 144, 110,
-111, -111, -111, -111, -111, -111, -111, -111, -111, -111,
- -111, 148, -111, 151, -111, 186, 6, -37, -111, -111,
+ -111, 150, -111, 155, -111, 192, 4, -33, -111, -111,
-111, -111, -111, -111, -111, -111, -111, -111, -111, -111,
-111, -111, -111, -111, -111, -111, -111, -111, -111, -111,
-111, -111, -111, -111, -111, -111, -111, -111, -111, -111,
- -111, -111, -111, 42, -111, -111, -111, -111, -111, 22,
- -111, -111, 2, -111, -111, -111, -111, -111, -111, -111,
- -111, -111, -111, -111, -111, -111, 96, -111, 66, 21,
- -111, -111, 0, -111, 274, 35, 88, -111, -111, -111,
- -111, -111, -111, -111, 41, 75, -111, -111, -111, 49,
- -111, -111, 48, -111, -111, -111, -111, -111, -111, -111,
- 57, -111, -111, -111, -111, -111, -111, -111, -111, -111,
- 77, -111, -111, 54, -111, 27, -111, 243, -111, 25,
- -111, 160, 36, -111, -111, 169, 40, -111, -111, -111,
- -111, -111, 56, -111, -111, -111, -111, -111, 180, -111,
- -111, 163, -111, -111, -111, 246, -111, -111, -111, -111,
+ -111, -111, -111, -9, -111, -111, -111, -111, -111, 7,
+ -111, -111, 40, -111, -111, -111, -111, -111, -111, -111,
+ -111, -111, -111, -111, -111, -111, 99, -111, 52, 31,
+ -111, -111, 30, -111, 253, 44, 87, -111, -111, -111,
+ -111, -111, -111, -111, 45, 86, -111, -111, -111, 41,
+ -111, -111, 5, -111, -111, -111, -111, -111, -111, -111,
+ 50, -111, -111, -111, -111, -111, -111, -111, -111, -111,
+ 154, -111, -111, 26, -111, 49, -111, 330, -111, 28,
+ -111, 248, 27, -111, -111, 124, 51, -111, -111, -111,
+ -111, -111, 46, -111, -111, -111, -111, -111, 196, -111,
+ -111, 185, -111, -111, -111, 194, -111, -111, -111, -111,
-111, -111, -111, -111, -111, -111, -111, -111, -111, -111,
- -111, -111, 8, -111, -111, -111, -111, -111, 69, -111,
+ -111, -111, 15, -111, -111, -111, -111, -111, 74, -111,
-111, -111, -111, -111, -111, -111, -111, -111, -111, -111,
- -111, -111, 61, 211, -111, 272, 257, 256, 236, -111,
- 81, 83, 85, 68, 94, -111, -111, -111, -111, -111,
- -111, -111, -111, 235, -111, 218, -111, 209, -111, -111,
- 244, -111, 227, -111, -111, 228, -111, 238, -111, 33,
- -111, 167, -111, 245, -111, 253, 254, -111, -111, 225,
- -111, -111, -111, -111, -111, -111, 217, -111, 194, 213,
- -111, -111, 208, -111, 207, -111, 52, -111, 205, -111,
- 55, -111, 201, -111, 199, -111, -111, -111, -111, -111,
- -111, -111, -111, 278, -111, 39, -111, 34, -111, 173,
- 219, -111, -111, 53, 231, -111, 73, -111, -111, 44,
- 59, -111, -111, -111, 47, -111, 24, 102, -111, 101,
- -111, -111, 111, -111, -111, -111, -111, -111, -111, 26,
- -111, -111, -111, -111, -111, -111, 65, -111, -111, -111,
- -111, 76, -111, -111, -111, -111, -111, -111, 79, -111,
- -111, 89, -111, -111, 51, -111, -111, -111, -111, -111,
- -62, -111, 37, -111, -63, -111, -111, -111, -111, 387,
- -111, -111, 264, -111, -111, -111, -111, -111, 158, -54,
- -111, -111, 28, -111, 38, -111, 23, -111, -111, -111,
- -111, 43, -111, 78, -111, 58, -111, 67, -111, -111,
- -111, -111, -111, -111, 18, -111, -111, 195, -111, -111,
- -111, -111, 161, -111, -111, -111, -111, 20, -111, -111,
- 157, -111, -111, 31, -111, -111, -111, -111, -111, -111,
+ -111, -111, -16, 230, -111, 233, 269, 251, 265, -111,
+ 80, 81, 82, 88, 89, -111, -111, -111, -111, -111,
+ -111, -111, -111, 216, -111, 255, -111, 259, -111, -111,
+ 223, -111, 68, -111, -111, 217, -111, 236, -111, 24,
+ -111, 244, -111, 227, -111, 226, 257, -111, -111, 263,
+ -111, -111, -111, -111, -111, -111, 249, -111, 113, 163,
+ -111, -111, 212, -111, 173, -111, 48, -111, 211, -111,
+ 53, -111, 206, -111, 204, -111, -111, -111, -111, -111,
+ -111, -111, -111, 199, -111, 23, -111, 25, -111, 134,
+ 175, -111, -111, 37, 200, -111, 222, -111, -111, 57,
+ 56, -111, -111, -111, 124, -111, 32, 43, -111, 105,
+ -111, -111, 139, -111, -111, -111, -111, -111, -111, 38,
+ -111, -111, -111, -111, -111, -111, 75, -111, -111, -111,
+ -111, 71, -111, -111, -111, -111, -111, -111, 72, -111,
+ -111, 85, -111, -111, 59, -111, -111, -111, -111, -111,
+ -37, -111, 62, -111, -58, -111, -111, -111, -111, 286,
+ -111, -111, 250, -111, -111, -111, -111, -111, 153, -57,
+ -111, -111, 33, -111, 34, -111, 36, -111, -111, -111,
+ -111, 47, -111, 77, -111, 29, -111, 67, -111, -111,
+ -111, -111, -111, -111, 42, -111, -111, 214, -111, -111,
+ -111, -111, 229, -111, -111, -111, -111, 35, -111, -111,
+ 145, -111, -111, 3, -111, -111, -111, -111, -111, -111,
-111, -111, -111, -111, -111, -111, -111, -111, -111, -111,
- 206, -111, -111, -111, -111, -111, -7, -111, -111, -111,
- -111, -111, -111, -111, -24, -111, -111, -111, -12, -111,
- -111, 342, -111, -111, -111, -111, -111, -111, -111, -111,
- -111, -111, -111, -16, -32, -111, 5, -111, -111, -111,
- -111, 152, -111, -111, -111, 248, -111, -111, 330, -111,
- -111, -111, 324, -111, -111, -111, -111, 385, -111, -111,
- -21, -111, -111, 1, 14, -111, 367, -111, 232, 12,
- -111, -111, 11, -111, 10, -111, 164, 141, -111, -111,
- 7, -111, 64, -111, -111, 19, -111, -111, -111, 17,
- -111, -1, 60, -111, 46, -111, -111, -111, -111, -111,
- -15, -111, -111, -111, -2, -17, -4, -111, -111, -111,
- -111, -111, 484, 138, 313, -3, -111, -111, -111, -111,
- 4, -111, -111, 13, 16, 97, 127, -111, -111, -111,
- -111, -111, -111, -111, -111, -111, -111, -111, -111, -111,
- -14, -111, -111, -111, -111, -111, -111, -8, -111, -111,
- -111, -111, -111, -111, -111, -111};
+ 207, -111, -111, -111, -111, -111, 39, -111, -111, -111,
+ -111, -111, -111, -111, -24, -111, -111, -111, -12, -27,
+ -111, -111, -111, -14, -111, -111, -111, -111, -111, -111,
+ 333, -111, -111, -111, -111, -111, -111, -111, -111, -111,
+ -111, -111, 6, 22, -111, 20, -111, -111, -111, -111,
+ 159, -111, -111, -111, 246, -111, -111, 332, -111, -111,
+ -111, 436, -111, -111, -111, -111, 388, -111, -111, 18,
+ -111, -111, -6, 19, -111, 352, -111, 225, 14, -111,
+ -111, 13, -111, 11, -111, 167, 136, -111, -111, 10,
+ -111, 64, -111, -111, 9, -111, -111, -111, 124, -111,
+ 0, 69, -111, 60, -111, -111, -111, -111, -111, -10,
+ -111, -111, -111, -1, -11, -2, -111, -111, -111, -111,
+ -111, 370, 142, 315, -3, -111, -111, -111, -111, 17,
+ -111, -111, -13, 21, 133, 221, -111, -111, -111, -111,
+ -111, -111, -111, -111, -111, -111, -111, -111, -111, 16,
+ -111, -111, -111, -111, -111, -111, -15, -111, -111, -111,
+ -111, -111, -111, -111, -111};
const short QQmlJSGrammar::action_info [] = {
- 424, 405, 432, 404, 346, 245, 573, 354, 406, -134,
- 461, -112, -113, -131, -136, 448, 350, -139, 402, 392,
- 268, -123, -142, 465, 399, 398, -131, -139, 465, 461,
- 474, -136, 558, 448, -134, -112, -113, 424, -123, 350,
- -142, 245, 551, 481, 484, 268, 576, 524, 413, 482,
- 438, 558, 439, 261, 558, 615, 420, 452, 418, 421,
- 283, 454, 143, 428, 172, 558, 166, 423, 558, 448,
- 608, 73, 546, 448, 149, 283, 0, 323, 408, 0,
- 544, 307, 268, 0, 0, 0, 143, 184, 350, 448,
- 245, 166, 101, 73, 461, 329, 465, 238, 456, 424,
- 241, 336, 618, 189, 665, 262, 143, 323, 0, 181,
- 317, 143, 451, 0, 315, 442, 143, 143, 192, 555,
- 0, 143, 240, 243, 303, 151, 452, 101, 143, 185,
- 143, 435, 143, 312, 305, 244, 0, 0, 303, 490,
- 555, 60, 60, 342, 143, 143, 191, 432, 252, 251,
- 103, 344, 61, 61, 144, 60, 305, 662, 661, 60,
- 103, 656, 655, 352, 325, 338, 61, 556, 326, 501,
- 61, 257, 256, 426, 143, 168, 436, 664, 663, 169,
- 348, 542, 264, 64, 321, 633, 634, 491, 628, 620,
- 619, 259, 258, 179, 65, 174, 463, 143, 622, 259,
- 258, 416, 415, 525, 267, 265, 525, 87, 477, 88,
- 531, 0, 174, 525, 175, 143, 411, 87, 339, 88,
- 89, 66, 0, 87, 558, 88, 467, 527, 66, 610,
- 89, 175, 266, 411, 525, 567, 89, 525, 526, 0,
- 87, 66, 88, 87, 87, 88, 88, 549, 174, 527,
- 236, 235, 527, 89, 611, 609, 89, 89, 0, 527,
- 526, 478, 476, 526, 532, 530, 67, 175, 446, 445,
- 526, 0, 68, 67, 174, 659, 658, 105, 0, 68,
- 527, 75, 76, 527, 0, 623, 67, 285, 286, 568,
- 566, 526, 68, 175, 526, 176, 106, 652, 107, 75,
- 76, 550, 548, 174, 0, 285, 286, 657, 77, 78,
- 174, 653, 651, 0, 287, 288, 0, 0, 0, 0,
- 0, -99, 175, 0, 176, 0, 77, 78, -99, 175,
- 0, 176, 287, 288, 0, 290, 291, 0, 0, 87,
- 0, 88, 0, 650, 292, 80, 81, 293, 35, 294,
- 0, 0, 89, 82, 83, 0, 0, 84, 35, 85,
- 80, 81, 6, 5, 4, 1, 3, 2, 82, 83,
- 80, 81, 84, 35, 85, 0, 0, 0, 82, 83,
- 80, 81, 84, 0, 85, 49, 52, 50, 82, 83,
- 80, 81, 84, 0, 85, 49, 52, 50, 82, 83,
- 0, 0, 84, 0, 85, 35, 0, 0, 35, 0,
- 49, 52, 50, 46, 34, 51, 35, 0, 0, 35,
- 290, 291, 35, 46, 34, 51, 0, 0, 35, 292,
- 0, 0, 293, 0, 294, 184, 0, 0, 46, 34,
- 51, 35, 49, 52, 50, 49, 52, 50, 184, 0,
- 0, 0, 0, 49, 52, 50, 49, 52, 50, 49,
- 52, 50, 35, 0, 0, 49, 52, 50, 0, 184,
- 46, 34, 51, 46, 34, 51, 0, 0, 49, 52,
- 50, 46, 34, 51, 46, 34, 51, 46, 34, 51,
- 0, 0, 0, 46, 34, 51, 0, 0, 35, 49,
- 52, 50, 0, 35, 0, 0, 46, 34, 51, 0,
- 0, 35, 0, 0, 0, 0, 0, 0, 0, 35,
- 0, 0, 0, 0, 0, 0, 0, 46, 34, 51,
- 250, 249, 0, 0, 0, 49, 52, 50, 0, 0,
- 49, 52, 50, 250, 249, 0, 0, 0, 49, 52,
- 50, 250, 249, 0, 0, 0, 49, 52, 50, 0,
- 0, 0, 0, 46, 34, 51, 0, 0, 46, 34,
- 51, 0, 0, 0, 0, 0, 46, 34, 51, 0,
- 35, 0, 0, 0, 46, 34, 51, 0, 0, 0,
+ -145, 398, 101, 244, 438, 402, 465, 245, 461, 567,
+ 423, 439, -126, 421, 553, -126, -145, 342, 344, 420,
+ 185, 245, 567, 392, 418, 585, 354, 73, 268, 181,
+ 245, 465, 166, 101, 172, 350, 432, 184, 268, 461,
+ 103, 432, 404, 405, 406, 428, 408, 413, -142, 424,
+ 560, -139, 448, -137, -115, 567, 424, -116, -134, 261,
+ 350, 448, 143, 432, 283, 624, 448, 481, 534, 103,
+ 262, 192, 474, 149, 529, 305, 567, 456, 482, 189,
+ 283, 191, 323, 307, -137, 627, 567, 484, 303, 151,
+ 617, 166, -115, 323, 329, 424, 238, -116, 336, 399,
+ 241, 524, -134, 312, 303, 346, 268, 73, 350, 448,
+ 143, -142, 240, 452, 465, 582, 448, -139, 461, 243,
+ 454, 143, 317, 143, 174, 0, 60, 305, 490, 315,
+ 665, 664, 435, 143, 257, 256, 60, 61, 143, 532,
+ 60, 60, 143, 175, 143, 64, 451, 61, 533, 671,
+ 670, 61, 61, 442, 143, 143, 65, 338, 537, 536,
+ 452, 143, 143, 564, 143, 174, 416, 415, 629, 628,
+ 564, 477, 174, 501, 0, 426, 491, 436, 673, 672,
+ 259, 258, 259, 258, 175, 467, 179, 252, 251, 642,
+ 643, 175, 144, 325, 463, 532, 530, 326, 674, 642,
+ 643, 168, 259, 258, 555, 169, 87, 321, 88, 66,
+ 339, 637, 530, 348, 352, 87, 264, 88, 565, 89,
+ 87, 87, 88, 88, 478, 476, 66, 174, 89, 267,
+ 265, 66, 525, 89, 89, 551, 631, 0, 87, 558,
+ 88, 619, 527, 143, 530, 143, 175, 0, 176, 105,
+ 87, 89, 88, 526, 67, 576, 0, 266, 527, 540,
+ 68, 0, 567, 89, 174, 530, 620, 618, 106, 526,
+ 107, 67, 530, 0, 0, 0, 67, 68, 527, 0,
+ 0, 527, 68, 175, 174, 411, 0, 668, 667, 526,
+ 527, 0, 526, 559, 557, 0, 446, 445, 236, 235,
+ 0, 526, 0, 175, 87, 411, 88, 174, 0, 577,
+ 575, 527, 0, 541, 539, 75, 76, 89, 527, 666,
+ 174, 0, 526, 632, 0, -102, 175, 0, 176, 526,
+ 285, 286, 75, 76, 285, 286, 661, 0, -102, 175,
+ 0, 176, 77, 78, 6, 5, 4, 1, 3, 2,
+ 662, 660, 0, 0, 290, 291, 0, 287, 288, 77,
+ 78, 287, 288, 292, 290, 291, 293, 0, 294, 0,
+ 0, 0, 0, 292, 290, 291, 293, 0, 294, 0,
+ 290, 291, 659, 292, 0, 87, 293, 88, 294, 292,
+ 0, 0, 293, 35, 294, 80, 81, 0, 89, 0,
+ 0, 0, 0, 82, 83, 80, 81, 84, 0, 85,
+ 0, 0, 0, 82, 83, 80, 81, 84, 35, 85,
+ 0, 0, 0, 82, 83, 80, 81, 84, 0, 85,
+ 49, 52, 50, 82, 83, 80, 81, 84, 0, 85,
+ 0, 0, 0, 82, 83, 0, 0, 84, 0, 85,
+ 35, 0, 0, 35, 0, 49, 52, 50, 46, 34,
+ 51, 35, 0, 0, 35, 0, 290, 291, 35, 0,
+ 0, 35, 532, 0, 35, 292, 0, 0, 293, 0,
+ 294, 184, 0, 46, 34, 51, 35, 49, 52, 50,
+ 49, 52, 50, 0, 0, 0, 0, 0, 49, 52,
+ 50, 49, 52, 50, 0, 49, 52, 50, 49, 52,
+ 50, 49, 52, 50, 0, 46, 34, 51, 46, 34,
+ 51, 0, 0, 49, 52, 50, 46, 34, 51, 46,
+ 34, 51, 532, 46, 34, 51, 46, 34, 51, 46,
+ 34, 51, 0, 35, 0, 0, 35, 0, 0, 35,
+ 184, 46, 34, 51, 35, 0, 0, 35, 0, 0,
+ 0, 184, 0, 0, 0, 35, 0, 0, 35, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 49, 52, 50, 49, 52, 50, 49, 52, 50, 255,
+ 254, 49, 52, 50, 49, 52, 50, 255, 254, 0,
+ 250, 249, 49, 52, 50, 49, 52, 50, 46, 34,
+ 51, 46, 34, 51, 46, 34, 51, 35, 0, 46,
+ 34, 51, 46, 34, 51, 35, 532, 0, 35, 0,
+ 46, 34, 51, 46, 34, 51, 0, 0, 0, 0,
+ 35, 0, 0, 0, 0, 0, 0, 0, 0, 255,
+ 254, 0, 0, 0, 49, 52, 50, 250, 249, 0,
+ 250, 249, 49, 52, 50, 49, 52, 50, 0, 0,
+ 0, 0, 0, 0, 0, 153, 0, 49, 52, 50,
+ 0, 0, 46, 34, 51, 154, 0, 0, 0, 155,
+ 46, 34, 51, 46, 34, 51, 0, 0, 156, 0,
+ 157, 0, 0, 319, 0, 46, 34, 51, 0, 0,
+ 0, 158, 0, 159, 64, 0, 0, 153, 0, 0,
+ 0, 160, 0, 0, 161, 65, 0, 154, 0, 0,
+ 162, 155, 0, 0, 0, 0, 163, 0, 0, 0,
+ 156, 0, 157, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 164, 158, 0, 159, 64, 0, 0, 0,
+ 0, 0, 0, 160, 0, 0, 161, 65, 0, 0,
+ 0, 0, 162, 0, 0, 0, 0, 0, 163, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 255, 254, 153, 0, 0, 49, 52, 50,
- 0, 0, 0, 0, 154, 0, 0, 0, 155, 0,
- 0, 0, 0, 0, 0, 0, 0, 156, 0, 157,
- 0, 0, 319, 0, 0, 46, 34, 51, 0, 0,
- 158, 0, 159, 64, 0, 30, 31, 153, 0, 0,
- 160, 0, 0, 161, 65, 33, 0, 154, 0, 162,
- 0, 155, 35, 0, 0, 163, 36, 37, 0, 38,
- 156, 0, 157, 0, 0, 0, 42, 0, 0, 0,
- 45, 164, 0, 158, 0, 159, 64, 0, 0, 0,
- 0, 0, 0, 160, 0, 0, 161, 65, 53, 49,
- 52, 50, 162, 54, 0, 0, 0, 0, 163, 0,
- 0, 0, 0, 0, 44, 56, 32, 0, 0, 0,
- 41, 0, 0, 0, 164, 0, 0, 46, 34, 51,
+ 0, 0, 0, 0, 164, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
30, 31, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -460,7 +471,7 @@ const short QQmlJSGrammar::action_info [] = {
0, 0, 0, 0, 0, 0, 219, 0, 0, 0,
0, 0, 0, 35, 0, 0, 0, 36, 37, 0,
38, 0, 0, 0, 0, 0, 0, 516, 0, 0,
- 0, 45, 0, 0, 0, 0, 0, 0, 0, 563,
+ 0, 45, 0, 0, 0, 0, 0, 0, 0, 572,
0, 0, 0, 0, 0, 0, 0, 0, 0, 53,
517, 519, 518, 0, 54, 0, 0, 0, 0, 227,
0, 0, 0, 0, 0, 44, 56, 32, 214, 0,
@@ -470,7 +481,7 @@ const short QQmlJSGrammar::action_info [] = {
0, 0, 219, 0, 0, 0, 0, 0, 0, 35,
0, 0, 0, 36, 37, 0, 38, 0, 0, 0,
0, 0, 0, 516, 0, 0, 0, 45, 0, 0,
- 0, 0, 0, 0, 0, 560, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 569, 0, 0, 0, 0,
0, 0, 0, 0, 0, 53, 517, 519, 518, 0,
54, 0, 0, 0, 0, 227, 0, 0, 0, 0,
0, 44, 56, 32, 214, 0, 0, 41, 0, 0,
@@ -485,7 +496,7 @@ const short QQmlJSGrammar::action_info [] = {
0, 58, 0, 0, 0, 0, 44, 56, 32, 0,
0, 0, 41, 0, 0, 0, 0, 0, 0, 46,
34, 51, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, -132, 0, 0, 0, 29, 30, 31, 0, 0,
+ 0, -135, 0, 0, 0, 29, 30, 31, 0, 0,
0, 0, 0, 0, 0, 0, 33, 0, 0, 0,
0, 0, 0, 35, 0, 0, 0, 36, 37, 0,
38, 0, 0, 0, 39, 0, 40, 42, 43, 0,
@@ -504,12 +515,12 @@ const short QQmlJSGrammar::action_info [] = {
0, 55, 0, 57, 282, 58, 0, 0, 0, 0,
44, 56, 32, 0, 0, 0, 41, 0, 0, 0,
0, 0, 0, 46, 34, 51, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 496, 0, 0, 29, 30,
+ 0, 0, 0, 0, 0, 488, 0, 0, 29, 30,
31, 0, 0, 0, 0, 0, 0, 0, 0, 33,
0, 0, 0, 0, 0, 0, 35, 0, 0, 0,
36, 37, 0, 38, 0, 0, 0, 39, 0, 40,
42, 43, 0, 0, 45, 0, 0, 0, 47, 0,
- 48, 0, 0, 497, 0, 0, 0, 0, 0, 0,
+ 48, 0, 0, 494, 0, 0, 0, 0, 0, 0,
0, 0, 53, 49, 52, 50, 0, 54, 0, 55,
0, 57, 0, 58, 0, 0, 0, 0, 44, 56,
32, 0, 0, 0, 41, 0, 0, 0, 0, 0,
@@ -519,16 +530,16 @@ const short QQmlJSGrammar::action_info [] = {
0, 0, 0, 0, 35, 0, 0, 0, 36, 37,
0, 38, 0, 0, 0, 39, 0, 40, 42, 43,
0, 0, 45, 0, 0, 0, 47, 0, 48, 0,
- 0, 494, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 489, 0, 0, 0, 0, 0, 0, 0, 0,
53, 49, 52, 50, 0, 54, 0, 55, 0, 57,
0, 58, 0, 0, 0, 0, 44, 56, 32, 0,
0, 0, 41, 0, 0, 0, 0, 0, 0, 46,
34, 51, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 488, 0, 0, 29, 30, 31, 0, 0, 0,
+ 0, 496, 0, 0, 29, 30, 31, 0, 0, 0,
0, 0, 0, 0, 0, 33, 0, 0, 0, 0,
0, 0, 35, 0, 0, 0, 36, 37, 0, 38,
0, 0, 0, 39, 0, 40, 42, 43, 0, 0,
- 45, 0, 0, 0, 47, 0, 48, 0, 0, 489,
+ 45, 0, 0, 0, 47, 0, 48, 0, 0, 499,
0, 0, 0, 0, 0, 0, 0, 0, 53, 49,
52, 50, 0, 54, 0, 55, 0, 57, 0, 58,
0, 0, 0, 0, 44, 56, 32, 0, 0, 0,
@@ -538,15 +549,15 @@ const short QQmlJSGrammar::action_info [] = {
0, 0, 0, 33, 0, 0, 0, 0, 0, 0,
35, 0, 0, 0, 36, 37, 0, 38, 0, 0,
0, 39, 0, 40, 42, 43, 0, 0, 45, 0,
- 0, 0, 47, 0, 48, 0, 0, 499, 0, 0,
+ 0, 0, 47, 0, 48, 0, 0, 497, 0, 0,
0, 0, 0, 0, 0, 0, 53, 49, 52, 50,
0, 54, 0, 55, 0, 57, 0, 58, 0, 0,
0, 0, 44, 56, 32, 0, 0, 0, 41, 0,
0, 0, 0, 0, 0, 46, 34, 51, 0, 0,
0, 0, 0, 0, 0, 0, 0, 29, 30, 31,
0, 0, 0, 0, 0, 0, 0, 0, 33, 0,
- 0, 0, 0, 0, 0, 35, 220, 0, 0, 221,
- 37, 0, 38, 0, 0, 0, 39, 0, 40, 42,
+ 0, 0, 0, 0, 0, 35, 220, 0, 0, 587,
+ 633, 0, 38, 0, 0, 0, 39, 0, 40, 42,
43, 0, 0, 45, 0, 0, 0, 47, 0, 48,
0, 0, 0, 0, 0, 0, 0, 223, 0, 0,
0, 53, 49, 52, 50, 224, 54, 0, 55, 226,
@@ -555,7 +566,7 @@ const short QQmlJSGrammar::action_info [] = {
46, 34, 51, 0, 0, 0, 0, 0, 0, 0,
0, 0, 29, 30, 31, 0, 0, 0, 0, 0,
0, 0, 0, 33, 0, 0, 0, 0, 0, 0,
- 35, 220, 0, 0, 578, 37, 0, 38, 0, 0,
+ 35, 220, 0, 0, 221, 37, 0, 38, 0, 0,
0, 39, 0, 40, 42, 43, 0, 0, 45, 0,
0, 0, 47, 0, 48, 0, 0, 0, 0, 0,
0, 0, 223, 0, 0, 0, 53, 49, 52, 50,
@@ -564,8 +575,8 @@ const short QQmlJSGrammar::action_info [] = {
0, 0, 0, 0, 0, 46, 34, 51, 0, 0,
0, 0, 0, 0, 0, 0, 0, 29, 30, 31,
0, 0, 0, 0, 0, 0, 0, 0, 33, 0,
- 0, 0, 0, 0, 0, 35, 220, 0, 0, 578,
- 624, 0, 38, 0, 0, 0, 39, 0, 40, 42,
+ 0, 0, 0, 0, 0, 35, 220, 0, 0, 587,
+ 37, 0, 38, 0, 0, 0, 39, 0, 40, 42,
43, 0, 0, 45, 0, 0, 0, 47, 0, 48,
0, 0, 0, 0, 0, 0, 0, 223, 0, 0,
0, 53, 49, 52, 50, 224, 54, 0, 55, 226,
@@ -633,164 +644,165 @@ const short QQmlJSGrammar::action_info [] = {
55, 226, 57, 227, 58, 228, 229, 0, 0, 44,
56, 32, 214, 216, 0, 41, 0, 0, 0, 0,
0, 0, 46, 34, 51, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 582, 112, 113, 0, 0, 584,
- 117, 586, 30, 31, 587, 0, 120, 0, 0, 0,
- 122, 589, 590, 0, 0, 0, 0, 0, 0, 35,
- 591, 126, 127, 221, 37, 0, 38, 0, 0, 0,
- 39, 0, 40, 592, 43, 0, 0, 594, 0, 0,
- 0, 47, 0, 48, 0, 0, 0, 0, 0, 595,
- 0, 223, 0, 0, 0, 596, 49, 52, 50, 597,
- 598, 599, 55, 601, 602, 603, 604, 605, 606, 0,
- 0, 593, 600, 588, 583, 585, 130, 41, 0, 0,
+ 0, 0, 0, 0, 591, 112, 113, 0, 0, 593,
+ 117, 595, 30, 31, 596, 0, 120, 0, 0, 0,
+ 122, 598, 599, 0, 0, 0, 0, 0, 0, 35,
+ 600, 126, 127, 221, 37, 0, 38, 0, 0, 0,
+ 39, 0, 40, 601, 43, 0, 0, 603, 0, 0,
+ 0, 47, 0, 48, 0, 0, 0, 0, 0, 604,
+ 0, 223, 0, 0, 0, 605, 49, 52, 50, 606,
+ 607, 608, 55, 610, 611, 612, 613, 614, 615, 0,
+ 0, 602, 609, 597, 592, 594, 130, 41, 0, 0,
0, 0, 0, 0, 46, 374, 380, 0, 0, 0,
0, 0, 0, 0, 0, 0, 365, 112, 113, 0,
0, 367, 117, 369, 30, 31, 370, 0, 120, 0,
0, 0, 122, 372, 373, 0, 0, 0, 0, 0,
0, 35, 375, 126, 127, 221, 37, 0, 38, 0,
0, 0, 39, 0, 40, 376, 43, 0, 0, 378,
- 0, 0, 0, 47, 0, 48, 0, -278, 0, 0,
+ 0, 0, 0, 47, 0, 48, 0, -281, 0, 0,
0, 379, 0, 223, 0, 0, 0, 381, 49, 52,
50, 382, 383, 384, 55, 386, 387, 388, 389, 390,
391, 0, 0, 377, 385, 371, 366, 368, 130, 41,
0, 0, 0, 0, 0, 0, 46, 374, 380, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 545, 572, 565, 632, 654, 148, 529, 541, 528, 142,
- 660, 263, 500, 393, 617, 616, 621, 614, 16, 629,
- 444, 183, 313, 547, 447, 183, 631, 643, 253, 248,
- 644, 485, 575, 574, 607, 152, 320, 437, 178, 313,
- 441, 433, 173, 183, 165, 253, 462, 313, 457, 447,
- 444, 453, 253, 458, 425, 347, 455, 248, 351, 188,
- 475, 466, 498, 171, 150, 447, 206, 190, 400, 468,
- 0, 183, 248, 495, 469, 237, 409, 393, 409, 331,
- 464, 247, 512, 206, 145, 206, 62, 409, 507, 206,
- 0, 511, 0, 188, 0, 206, 206, 188, 206, 62,
- 62, 504, 460, 417, 62, 206, 505, 206, 647, 646,
- 407, 0, 0, 410, 62, 410, 459, 62, 148, 506,
- 62, 187, 62, 277, 410, 419, 412, 298, 281, 393,
- 148, 0, 0, 0, 422, 62, 170, 62, 180, 62,
- 295, 514, 296, 260, 297, 62, 648, 503, 62, 62,
- 62, 182, 514, 299, 394, 62, 62, 460, 459, 206,
- 362, 630, 362, 62, 167, 502, 514, 62, 62, 322,
- 62, 553, 444, 99, 100, 93, 206, 62, 356, 206,
- 510, 206, 94, 62, 62, 206, 62, 62, 95, 96,
- 62, 97, 86, 62, 90, 493, 62, 91, 188, 492,
- 92, 355, 62, 353, 108, 62, 483, 349, 242, 345,
- 247, 313, 331, 469, 102, 104, 313, 206, 62, 206,
- 182, 260, 62, 206, 206, 206, 239, 62, 98, 182,
- 313, 313, 62, 110, 362, 72, 62, 206, 69, 62,
- 318, 70, 62, 62, 71, 260, 63, 62, 246, 393,
- 581, 62, 62, 460, 0, 74, 206, 62, 79, 459,
- 0, 206, 514, 309, 206, 62, 362, 557, 281, 0,
- 281, 309, 62, 0, 284, 403, 281, 281, 0, 309,
- 401, 0, 206, 306, 281, 308, 343, 479, 340, 62,
- 62, 341, 108, 337, 281, 281, 206, 302, 309, 62,
- 0, 330, 304, 281, 281, 314, 316, 62, 309, 0,
- 62, 62, 281, 281, 324, 281, 281, 301, 300, 514,
- 311, 110, 177, 0, 327, 0, 62, 569, 522, 564,
- 328, 281, 553, 289, 627, 561, 0, 0, 514, 0,
- 513, 523, 0, 0, 514, 0, 0, 522, 0, 0,
- 0, 0, 443, 522, 0, 485, 0, 0, 0, 513,
- 523, 0, 0, 0, 0, 513, 523, 533, 534, 535,
- 536, 540, 537, 538, 0, 0, 0, 0, 0, 0,
- 0, 577, 0, 0, 0, 0, 0, 0, 0, 362,
- 579, 580, 533, 534, 535, 536, 540, 537, 538, 569,
- 0, 0, 0, 0, 0, 206, 0, 0, 570, 571,
- 533, 534, 535, 536, 540, 537, 538, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 152, 652, 331, 669, 535, 531, 538, 142, 528, 148,
+ 641, 16, 313, 393, 485, 500, 626, 630, 263, 638,
+ 183, 625, 623, 206, 574, 447, 583, 320, 183, 253,
+ 313, 248, 466, 145, 663, 653, 616, 584, 556, 640,
+ 581, 248, 437, 253, 248, 495, 183, 178, 453, 150,
+ 462, 347, 455, 550, 554, 183, 351, 447, 458, 190,
+ 313, 457, 425, 188, 469, 441, 433, 253, 237, 468,
+ 0, 313, 173, 171, 393, 409, 447, 498, 409, 464,
+ 400, 0, 165, 206, 475, 206, 512, 511, 0, 0,
+ 188, 0, 0, 206, 0, 206, 0, 62, 0, 459,
+ 417, 206, 206, 206, 188, 0, 62, 0, 62, 62,
+ 507, 504, 410, 148, 62, 410, 460, 62, 419, 505,
+ 407, 412, 170, 62, 62, 459, 506, 444, 277, 148,
+ 422, 331, 187, 281, 62, 62, 62, 180, 260, 295,
+ 296, 297, 62, 62, 656, 655, 314, 298, 299, 62,
+ 62, 503, 182, 62, 206, 362, 514, 393, 247, 62,
+ 62, 460, 502, 62, 62, 639, 313, 167, 92, 99,
+ 62, 206, 206, 514, 510, 345, 100, 260, 562, 62,
+ 62, 62, 394, 493, 93, 94, 95, 492, 62, 62,
+ 182, 206, 62, 206, 96, 62, 246, 97, 62, 90,
+ 62, 401, 91, 206, 62, 86, 355, 340, 353, 62,
+ 108, 247, 206, 349, 188, 313, 102, 206, 393, 104,
+ 313, 62, 206, 182, 206, 206, 62, 362, 459, 206,
+ 242, 62, 469, 460, 62, 514, 409, 63, 318, 110,
+ 657, 341, 239, 590, 403, 62, 322, 206, 72, 62,
+ 362, 62, 362, 69, 206, 98, 62, 62, 70, 71,
+ 514, 0, 206, 62, 62, 566, 356, 0, 206, 79,
+ 62, 108, 74, 410, 483, 281, 0, 309, 0, 0,
+ 62, 62, 281, 304, 62, 281, 281, 62, 362, 281,
+ 343, 0, 281, 284, 289, 316, 324, 327, 0, 311,
+ 110, 177, 0, 309, 206, 62, 479, 0, 281, 62,
+ 281, 309, 301, 309, 281, 0, 281, 309, 281, 62,
+ 306, 0, 281, 62, 281, 337, 302, 0, 281, 578,
+ 300, 514, 260, 328, 562, 308, 636, 570, 443, 330,
+ 522, 0, 0, 0, 0, 0, 514, 0, 206, 0,
+ 0, 0, 513, 523, 0, 522, 0, 485, 542, 543,
+ 544, 545, 549, 546, 547, 0, 586, 513, 523, 0,
+ 0, 0, 0, 0, 440, 588, 589, 542, 543, 544,
+ 545, 549, 546, 547, 586, 0, 0, 0, 0, 0,
+ 0, 0, 0, 634, 635, 542, 543, 544, 545, 549,
+ 546, 547, 578, 0, 0, 0, 0, 0, 0, 0,
+ 0, 579, 580, 542, 543, 544, 545, 549, 546, 547,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 573, 0, 0, 0, 0, 0, 0, 0, 0,
+ 514, 0, 0, 0, 0, 0, 0, 0, 0, 522,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 513, 523, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 440, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 577, 0,
- 0, 0, 0, 0, 0, 0, 0, 625, 626, 533,
- 534, 535, 536, 540, 537, 538, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0};
+ 0, 0, 0, 0, 0, 0, 0};
const short QQmlJSGrammar::action_check [] = {
- 36, 60, 5, 36, 31, 7, 66, 16, 33, 7,
- 36, 7, 7, 7, 7, 33, 36, 7, 55, 8,
- 36, 7, 7, 36, 7, 55, 7, 7, 36, 36,
- 17, 7, 33, 33, 7, 7, 7, 36, 7, 36,
- 7, 7, 34, 60, 55, 36, 7, 66, 60, 33,
- 55, 33, 7, 77, 33, 8, 60, 20, 36, 33,
- 1, 36, 8, 33, 7, 33, 2, 55, 33, 33,
- 29, 1, 24, 33, 8, 1, -1, 2, 55, -1,
- 37, 8, 36, -1, -1, -1, 8, 36, 36, 33,
- 7, 2, 48, 1, 36, 7, 36, 36, 60, 36,
- 33, 17, 60, 8, 0, 36, 8, 2, -1, 60,
- 60, 8, 6, -1, 61, 7, 8, 8, 33, 8,
- -1, 8, 60, 55, 48, 60, 20, 48, 8, 36,
- 8, 10, 8, 61, 79, 55, -1, -1, 48, 8,
- 8, 40, 40, 61, 8, 8, 60, 5, 61, 62,
- 79, 60, 51, 51, 56, 40, 79, 61, 62, 40,
- 79, 61, 62, 60, 50, 8, 51, 56, 54, 60,
- 51, 61, 62, 60, 8, 50, 55, 61, 62, 54,
- 60, 29, 60, 42, 60, 91, 92, 56, 56, 61,
- 62, 61, 62, 56, 53, 15, 60, 8, 7, 61,
- 62, 61, 62, 29, 61, 62, 29, 25, 8, 27,
- 7, -1, 15, 29, 34, 8, 36, 25, 61, 27,
- 38, 12, -1, 25, 33, 27, 60, 75, 12, 36,
- 38, 34, 89, 36, 29, 7, 38, 29, 86, -1,
- 25, 12, 27, 25, 25, 27, 27, 7, 15, 75,
- 61, 62, 75, 38, 61, 62, 38, 38, -1, 75,
- 86, 61, 62, 86, 61, 62, 57, 34, 61, 62,
- 86, -1, 63, 57, 15, 61, 62, 15, -1, 63,
- 75, 18, 19, 75, -1, 94, 57, 18, 19, 61,
- 62, 86, 63, 34, 86, 36, 34, 47, 36, 18,
- 19, 61, 62, 15, -1, 18, 19, 93, 45, 46,
- 15, 61, 62, -1, 45, 46, -1, -1, -1, -1,
- -1, 33, 34, -1, 36, -1, 45, 46, 33, 34,
- -1, 36, 45, 46, -1, 23, 24, -1, -1, 25,
- -1, 27, -1, 93, 32, 23, 24, 35, 29, 37,
- -1, -1, 38, 31, 32, -1, -1, 35, 29, 37,
- 23, 24, 98, 99, 100, 101, 102, 103, 31, 32,
- 23, 24, 35, 29, 37, -1, -1, -1, 31, 32,
- 23, 24, 35, -1, 37, 66, 67, 68, 31, 32,
- 23, 24, 35, -1, 37, 66, 67, 68, 31, 32,
- -1, -1, 35, -1, 37, 29, -1, -1, 29, -1,
- 66, 67, 68, 94, 95, 96, 29, -1, -1, 29,
- 23, 24, 29, 94, 95, 96, -1, -1, 29, 32,
- -1, -1, 35, -1, 37, 36, -1, -1, 94, 95,
- 96, 29, 66, 67, 68, 66, 67, 68, 36, -1,
- -1, -1, -1, 66, 67, 68, 66, 67, 68, 66,
- 67, 68, 29, -1, -1, 66, 67, 68, -1, 36,
- 94, 95, 96, 94, 95, 96, -1, -1, 66, 67,
- 68, 94, 95, 96, 94, 95, 96, 94, 95, 96,
- -1, -1, -1, 94, 95, 96, -1, -1, 29, 66,
- 67, 68, -1, 29, -1, -1, 94, 95, 96, -1,
- -1, 29, -1, -1, -1, -1, -1, -1, -1, 29,
- -1, -1, -1, -1, -1, -1, -1, 94, 95, 96,
- 61, 62, -1, -1, -1, 66, 67, 68, -1, -1,
- 66, 67, 68, 61, 62, -1, -1, -1, 66, 67,
- 68, 61, 62, -1, -1, -1, 66, 67, 68, -1,
- -1, -1, -1, 94, 95, 96, -1, -1, 94, 95,
- 96, -1, -1, -1, -1, -1, 94, 95, 96, -1,
- 29, -1, -1, -1, 94, 95, 96, -1, -1, -1,
+ 7, 55, 48, 55, 55, 55, 36, 7, 36, 33,
+ 55, 7, 7, 33, 37, 7, 7, 61, 60, 60,
+ 36, 7, 33, 8, 36, 7, 16, 1, 36, 60,
+ 7, 36, 2, 48, 7, 36, 5, 36, 36, 36,
+ 79, 5, 36, 60, 33, 33, 55, 60, 7, 36,
+ 34, 7, 33, 7, 7, 33, 36, 7, 7, 77,
+ 36, 33, 8, 5, 1, 8, 33, 60, 29, 79,
+ 36, 33, 17, 8, 37, 79, 33, 60, 33, 8,
+ 1, 60, 2, 8, 7, 60, 33, 55, 48, 60,
+ 29, 2, 7, 2, 7, 36, 36, 7, 17, 7,
+ 33, 66, 7, 61, 48, 31, 36, 1, 36, 33,
+ 8, 7, 60, 20, 36, 66, 33, 7, 36, 55,
+ 36, 8, 60, 8, 15, -1, 40, 79, 8, 61,
+ 61, 62, 10, 8, 61, 62, 40, 51, 8, 15,
+ 40, 40, 8, 34, 8, 42, 6, 51, 24, 61,
+ 62, 51, 51, 7, 8, 8, 53, 8, 61, 62,
+ 20, 8, 8, 8, 8, 15, 61, 62, 61, 62,
+ 8, 8, 15, 60, -1, 60, 56, 55, 61, 62,
+ 61, 62, 61, 62, 34, 60, 56, 61, 62, 91,
+ 92, 34, 56, 50, 60, 15, 29, 54, 0, 91,
+ 92, 50, 61, 62, 24, 54, 25, 60, 27, 12,
+ 61, 56, 29, 60, 60, 25, 60, 27, 56, 38,
+ 25, 25, 27, 27, 61, 62, 12, 15, 38, 61,
+ 62, 12, 29, 38, 38, 29, 7, -1, 25, 7,
+ 27, 36, 75, 8, 29, 8, 34, -1, 36, 15,
+ 25, 38, 27, 86, 57, 7, -1, 89, 75, 7,
+ 63, -1, 33, 38, 15, 29, 61, 62, 34, 86,
+ 36, 57, 29, -1, -1, -1, 57, 63, 75, -1,
+ -1, 75, 63, 34, 15, 36, -1, 61, 62, 86,
+ 75, -1, 86, 61, 62, -1, 61, 62, 61, 62,
+ -1, 86, -1, 34, 25, 36, 27, 15, -1, 61,
+ 62, 75, -1, 61, 62, 18, 19, 38, 75, 93,
+ 15, -1, 86, 94, -1, 33, 34, -1, 36, 86,
+ 18, 19, 18, 19, 18, 19, 47, -1, 33, 34,
+ -1, 36, 45, 46, 98, 99, 100, 101, 102, 103,
+ 61, 62, -1, -1, 23, 24, -1, 45, 46, 45,
+ 46, 45, 46, 32, 23, 24, 35, -1, 37, -1,
+ -1, -1, -1, 32, 23, 24, 35, -1, 37, -1,
+ 23, 24, 93, 32, -1, 25, 35, 27, 37, 32,
+ -1, -1, 35, 29, 37, 23, 24, -1, 38, -1,
+ -1, -1, -1, 31, 32, 23, 24, 35, -1, 37,
+ -1, -1, -1, 31, 32, 23, 24, 35, 29, 37,
+ -1, -1, -1, 31, 32, 23, 24, 35, -1, 37,
+ 66, 67, 68, 31, 32, 23, 24, 35, -1, 37,
+ -1, -1, -1, 31, 32, -1, -1, 35, -1, 37,
+ 29, -1, -1, 29, -1, 66, 67, 68, 94, 95,
+ 96, 29, -1, -1, 29, -1, 23, 24, 29, -1,
+ -1, 29, 15, -1, 29, 32, -1, -1, 35, -1,
+ 37, 36, -1, 94, 95, 96, 29, 66, 67, 68,
+ 66, 67, 68, -1, -1, -1, -1, -1, 66, 67,
+ 68, 66, 67, 68, -1, 66, 67, 68, 66, 67,
+ 68, 66, 67, 68, -1, 94, 95, 96, 94, 95,
+ 96, -1, -1, 66, 67, 68, 94, 95, 96, 94,
+ 95, 96, 15, 94, 95, 96, 94, 95, 96, 94,
+ 95, 96, -1, 29, -1, -1, 29, -1, -1, 29,
+ 36, 94, 95, 96, 29, -1, -1, 29, -1, -1,
+ -1, 36, -1, -1, -1, 29, -1, -1, 29, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 66, 67, 68, 66, 67, 68, 66, 67, 68, 61,
+ 62, 66, 67, 68, 66, 67, 68, 61, 62, -1,
+ 61, 62, 66, 67, 68, 66, 67, 68, 94, 95,
+ 96, 94, 95, 96, 94, 95, 96, 29, -1, 94,
+ 95, 96, 94, 95, 96, 29, 15, -1, 29, -1,
+ 94, 95, 96, 94, 95, 96, -1, -1, -1, -1,
+ 29, -1, -1, -1, -1, -1, -1, -1, -1, 61,
+ 62, -1, -1, -1, 66, 67, 68, 61, 62, -1,
+ 61, 62, 66, 67, 68, 66, 67, 68, -1, -1,
+ -1, -1, -1, -1, -1, 3, -1, 66, 67, 68,
+ -1, -1, 94, 95, 96, 13, -1, -1, -1, 17,
+ 94, 95, 96, 94, 95, 96, -1, -1, 26, -1,
+ 28, -1, -1, 31, -1, 94, 95, 96, -1, -1,
+ -1, 39, -1, 41, 42, -1, -1, 3, -1, -1,
+ -1, 49, -1, -1, 52, 53, -1, 13, -1, -1,
+ 58, 17, -1, -1, -1, -1, 64, -1, -1, -1,
+ 26, -1, 28, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, 80, 39, -1, 41, 42, -1, -1, -1,
+ -1, -1, -1, 49, -1, -1, 52, 53, -1, -1,
+ -1, -1, 58, -1, -1, -1, -1, -1, 64, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 61, 62, 3, -1, -1, 66, 67, 68,
- -1, -1, -1, -1, 13, -1, -1, -1, 17, -1,
- -1, -1, -1, -1, -1, -1, -1, 26, -1, 28,
- -1, -1, 31, -1, -1, 94, 95, 96, -1, -1,
- 39, -1, 41, 42, -1, 12, 13, 3, -1, -1,
- 49, -1, -1, 52, 53, 22, -1, 13, -1, 58,
- -1, 17, 29, -1, -1, 64, 33, 34, -1, 36,
- 26, -1, 28, -1, -1, -1, 43, -1, -1, -1,
- 47, 80, -1, 39, -1, 41, 42, -1, -1, -1,
- -1, -1, -1, 49, -1, -1, 52, 53, 65, 66,
- 67, 68, 58, 70, -1, -1, -1, -1, 64, -1,
- -1, -1, -1, -1, 81, 82, 83, -1, -1, -1,
- 87, -1, -1, -1, 80, -1, -1, 94, 95, 96,
+ -1, -1, -1, -1, 80, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
12, 13, -1, -1, -1, -1, -1, -1, -1, -1,
@@ -1020,65 +1032,60 @@ const short QQmlJSGrammar::action_check [] = {
-1, -1, -1, -1, -1, -1, 94, 95, 96, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
- 32, 22, 18, 9, 18, 42, 18, 14, 32, 3,
- 18, 3, 3, 18, 18, 32, 18, 32, 3, 22,
- 3, 18, 3, 18, 25, 18, 22, 14, 18, 18,
- 14, 42, 18, 32, 22, 77, 3, 100, 3, 3,
- 3, 103, 42, 18, 42, 18, 3, 3, 25, 25,
- 3, 105, 18, 25, 3, 3, 18, 18, 3, 18,
- 42, 3, 42, 42, 42, 25, 18, 18, 42, 2,
- -1, 18, 18, 42, 18, 18, 14, 18, 14, 18,
- 2, 4, 2, 18, 42, 18, 54, 14, 56, 18,
- -1, 4, -1, 18, -1, 18, 18, 18, 18, 54,
- 54, 56, 56, 44, 54, 18, 56, 18, 11, 12,
- 45, -1, -1, 51, 54, 51, 56, 54, 42, 56,
- 54, 46, 54, 54, 51, 46, 50, 59, 59, 18,
- 42, -1, -1, -1, 45, 54, 70, 54, 50, 54,
- 59, 14, 59, 2, 59, 54, 19, 56, 54, 54,
- 54, 56, 14, 59, 43, 54, 54, 56, 56, 18,
- 2, 23, 2, 54, 68, 56, 14, 54, 54, 2,
- 54, 19, 3, 60, 60, 59, 18, 54, 18, 18,
- 109, 18, 59, 54, 54, 18, 54, 54, 59, 59,
- 54, 59, 59, 54, 58, 38, 54, 58, 18, 42,
- 58, 2, 54, 2, 18, 54, 45, 2, 45, 2,
- 4, 3, 18, 18, 66, 64, 3, 18, 54, 18,
- 56, 2, 54, 18, 18, 18, 46, 54, 60, 56,
- 3, 3, 54, 47, 2, 57, 54, 18, 56, 54,
- 2, 56, 54, 54, 56, 2, 57, 54, 2, 18,
- 18, 54, 54, 56, -1, 62, 18, 54, 60, 56,
- -1, 18, 14, 54, 18, 54, 2, 19, 59, -1,
- 59, 54, 54, -1, 63, 44, 59, 59, -1, 54,
- 2, -1, 18, 65, 59, 76, 78, 92, 94, 54,
- 54, 78, 18, 76, 59, 59, 18, 61, 54, 54,
- -1, 76, 67, 59, 59, 78, 78, 54, 54, -1,
- 54, 54, 59, 59, 69, 59, 59, 61, 61, 14,
- 76, 47, 48, -1, 71, -1, 54, 14, 23, 5,
- 76, 59, 19, 61, 21, 5, -1, -1, 14, -1,
- 35, 36, -1, -1, 14, -1, -1, 23, -1, -1,
- -1, -1, 88, 23, -1, 42, -1, -1, -1, 35,
- 36, -1, -1, -1, -1, 35, 36, 25, 26, 27,
- 28, 29, 30, 31, -1, -1, -1, -1, -1, -1,
- -1, 14, -1, -1, -1, -1, -1, -1, -1, 2,
- 23, 24, 25, 26, 27, 28, 29, 30, 31, 14,
- -1, -1, -1, -1, -1, 18, -1, -1, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 77, 14, 18, 18, 18, 32, 18, 3, 32, 42,
+ 9, 3, 3, 18, 42, 3, 18, 18, 3, 22,
+ 18, 32, 32, 18, 18, 25, 32, 3, 18, 18,
+ 3, 18, 3, 42, 18, 14, 22, 18, 18, 22,
+ 22, 18, 100, 18, 18, 42, 18, 3, 105, 42,
+ 3, 3, 18, 14, 32, 18, 3, 25, 25, 18,
+ 3, 25, 3, 18, 18, 3, 103, 18, 18, 2,
+ -1, 3, 42, 42, 18, 14, 25, 42, 14, 2,
+ 42, -1, 42, 18, 42, 18, 2, 4, -1, -1,
+ 18, -1, -1, 18, -1, 18, -1, 54, -1, 56,
+ 44, 18, 18, 18, 18, -1, 54, -1, 54, 54,
+ 56, 56, 51, 42, 54, 51, 56, 54, 46, 56,
+ 45, 50, 70, 54, 54, 56, 56, 3, 54, 42,
+ 45, 18, 46, 59, 54, 54, 54, 50, 2, 59,
+ 59, 59, 54, 54, 11, 12, 78, 59, 59, 54,
+ 54, 56, 56, 54, 18, 2, 14, 18, 4, 54,
+ 54, 56, 56, 54, 54, 23, 3, 68, 58, 60,
+ 54, 18, 18, 14, 109, 2, 60, 2, 19, 54,
+ 54, 54, 43, 38, 59, 59, 59, 42, 54, 54,
+ 56, 18, 54, 18, 59, 54, 2, 59, 54, 58,
+ 54, 2, 58, 18, 54, 59, 2, 94, 2, 54,
+ 18, 4, 18, 2, 18, 3, 66, 18, 18, 64,
+ 3, 54, 18, 56, 18, 18, 54, 2, 56, 18,
+ 45, 54, 18, 56, 54, 14, 14, 57, 2, 47,
+ 19, 78, 46, 18, 44, 54, 2, 18, 57, 54,
+ 2, 54, 2, 56, 18, 60, 54, 54, 56, 56,
+ 14, -1, 18, 54, 54, 19, 18, -1, 18, 60,
+ 54, 18, 62, 51, 45, 59, -1, 54, -1, -1,
+ 54, 54, 59, 67, 54, 59, 59, 54, 2, 59,
+ 78, -1, 59, 63, 61, 78, 69, 71, -1, 76,
+ 47, 48, -1, 54, 18, 54, 92, -1, 59, 54,
+ 59, 54, 61, 54, 59, -1, 59, 54, 59, 54,
+ 65, -1, 59, 54, 59, 76, 61, -1, 59, 14,
+ 61, 14, 2, 76, 19, 76, 21, 5, 88, 76,
+ 23, -1, -1, -1, -1, -1, 14, -1, 18, -1,
+ -1, -1, 35, 36, -1, 23, -1, 42, 25, 26,
+ 27, 28, 29, 30, 31, -1, 14, 35, 36, -1,
+ -1, -1, -1, -1, 88, 23, 24, 25, 26, 27,
+ 28, 29, 30, 31, 14, -1, -1, -1, -1, -1,
+ -1, -1, -1, 23, 24, 25, 26, 27, 28, 29,
+ 30, 31, 14, -1, -1, -1, -1, -1, -1, -1,
+ -1, 23, 24, 25, 26, 27, 28, 29, 30, 31,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 88, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 14, -1,
- -1, -1, -1, -1, -1, -1, -1, 23, 24, 25,
- 26, 27, 28, 29, 30, 31, -1, -1, -1, -1,
+ -1, 5, -1, -1, -1, -1, -1, -1, -1, -1,
+ 14, -1, -1, -1, -1, -1, -1, -1, -1, 23,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 35, 36, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1};
+ -1, -1, -1, -1, -1, -1, -1};
QT_END_NAMESPACE
diff --git a/src/qml/parser/qqmljsgrammar_p.h b/src/qml/parser/qqmljsgrammar_p.h
index fadbe80c64..050ef6c288 100644
--- a/src/qml/parser/qqmljsgrammar_p.h
+++ b/src/qml/parser/qqmljsgrammar_p.h
@@ -167,15 +167,15 @@ public:
T_XOR = 79,
T_XOR_EQ = 80,
- ACCEPT_STATE = 665,
- RULE_COUNT = 358,
- STATE_COUNT = 666,
+ ACCEPT_STATE = 674,
+ RULE_COUNT = 361,
+ STATE_COUNT = 675,
TERMINAL_COUNT = 106,
NON_TERMINAL_COUNT = 111,
- GOTO_INDEX_OFFSET = 666,
- GOTO_INFO_OFFSET = 3018,
- GOTO_CHECK_OFFSET = 3018
+ GOTO_INDEX_OFFSET = 675,
+ GOTO_INFO_OFFSET = 3078,
+ GOTO_CHECK_OFFSET = 3078
};
static const char *const spell [];
diff --git a/src/qml/parser/qqmljsmemorypool_p.h b/src/qml/parser/qqmljsmemorypool_p.h
index 08609e2961..536f5d4239 100644
--- a/src/qml/parser/qqmljsmemorypool_p.h
+++ b/src/qml/parser/qqmljsmemorypool_p.h
@@ -122,6 +122,7 @@ private:
_allocatedBlocks *= 2;
_blocks = (char **) realloc(_blocks, sizeof(char *) * _allocatedBlocks);
+ Q_CHECK_PTR(_blocks);
for (int index = _blockCount; index < _allocatedBlocks; ++index)
_blocks[index] = 0;
@@ -129,8 +130,10 @@ private:
char *&block = _blocks[_blockCount];
- if (! block)
+ if (! block) {
block = (char *) malloc(BLOCK_SIZE);
+ Q_CHECK_PTR(block);
+ }
_ptr = block;
_end = _ptr + BLOCK_SIZE;
diff --git a/src/qml/parser/qqmljsparser.cpp b/src/qml/parser/qqmljsparser.cpp
index 92d12aee9c..50518a92ee 100644
--- a/src/qml/parser/qqmljsparser.cpp
+++ b/src/qml/parser/qqmljsparser.cpp
@@ -436,31 +436,55 @@ case 47:
sym(1).Node = node;
} break;
+case 48: {
+ AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(stringRef(1));
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 49: {
+ AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(stringRef(1));
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+
+case 50: {
+ AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(stringRef(1));
+ node->identifierToken = loc(1);
+ sym(1).Node = node;
+} break;
+
case 51: {
- sym(1).Node = 0;
+ AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(sym(1).UiQualifiedId, stringRef(3));
+ node->identifierToken = loc(3);
+ sym(1).Node = node;
} break;
case 52: {
- sym(1).Node = sym(1).UiParameterList->finish ();
+ sym(1).Node = 0;
} break;
case 53: {
- AST::UiParameterList *node = new (pool) AST::UiParameterList(stringRef(1), stringRef(2));
+ sym(1).Node = sym(1).UiParameterList->finish ();
+} break;
+
+case 54: {
+ AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiQualifiedId->finish(), stringRef(2));
node->propertyTypeToken = loc(1);
node->identifierToken = loc(2);
sym(1).Node = node;
} break;
-case 54: {
- AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4));
+case 55: {
+ AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, sym(3).UiQualifiedId->finish(), stringRef(4));
node->propertyTypeToken = loc(3);
node->commaToken = loc(2);
node->identifierToken = loc(4);
sym(1).Node = node;
} break;
-case 56: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2));
+case 57: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(nullptr, stringRef(2));
node->type = AST::UiPublicMember::Signal;
node->propertyToken = loc(1);
node->typeToken = loc(2);
@@ -470,8 +494,8 @@ case 56: {
sym(1).Node = node;
} break;
-case 58: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2));
+case 59: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(nullptr, stringRef(2));
node->type = AST::UiPublicMember::Signal;
node->propertyToken = loc(1);
node->typeToken = loc(2);
@@ -480,8 +504,8 @@ case 58: {
sym(1).Node = node;
} break;
-case 60: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6));
+case 61: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6));
node->typeModifier = stringRef(2);
node->propertyToken = loc(1);
node->typeModifierToken = loc(2);
@@ -491,8 +515,8 @@ case 60: {
sym(1).Node = node;
} break;
-case 62: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3));
+case 63: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3));
node->propertyToken = loc(1);
node->typeToken = loc(2);
node->identifierToken = loc(3);
@@ -500,8 +524,8 @@ case 62: {
sym(1).Node = node;
} break;
-case 64: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4));
+case 65: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4));
node->isDefaultMember = true;
node->defaultToken = loc(1);
node->propertyToken = loc(2);
@@ -511,8 +535,21 @@ case 64: {
sym(1).Node = node;
} break;
-case 65: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3),
+case 67: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(5).UiQualifiedId->finish(), stringRef(7));
+ node->isDefaultMember = true;
+ node->defaultToken = loc(1);
+ node->typeModifier = stringRef(3);
+ node->propertyToken = loc(2);
+ node->typeModifierToken = loc(2);
+ node->typeToken = loc(4);
+ node->identifierToken = loc(7);
+ node->semicolonToken = loc(8);
+ sym(1).Node = node;
+} break;
+
+case 68: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3),
sym(5).Statement);
node->propertyToken = loc(1);
node->typeToken = loc(2);
@@ -521,8 +558,8 @@ case 65: {
sym(1).Node = node;
} break;
-case 66: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4),
+case 69: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4),
sym(6).Statement);
node->isReadonlyMember = true;
node->readonlyToken = loc(1);
@@ -533,8 +570,8 @@ case 66: {
sym(1).Node = node;
} break;
-case 67: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4),
+case 70: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4),
sym(6).Statement);
node->isDefaultMember = true;
node->defaultToken = loc(1);
@@ -545,8 +582,8 @@ case 67: {
sym(1).Node = node;
} break;
-case 68: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6));
+case 71: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6));
node->typeModifier = stringRef(2);
node->propertyToken = loc(1);
node->typeModifierToken = loc(2);
@@ -569,8 +606,8 @@ case 68: {
sym(1).Node = node;
} break;
-case 69: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3));
+case 72: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3));
node->propertyToken = loc(1);
node->typeToken = loc(2);
node->identifierToken = loc(3);
@@ -589,8 +626,8 @@ case 69: {
sym(1).Node = node;
} break;
-case 70: {
- AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4));
+case 73: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4));
node->isReadonlyMember = true;
node->readonlyToken = loc(1);
node->propertyToken = loc(2);
@@ -611,57 +648,57 @@ case 70: {
sym(1).Node = node;
} break;
-case 71: {
+case 74: {
sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node);
} break;
-case 72: {
+case 75: {
sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node);
} break;
-case 80: {
+case 83: {
AST::ThisExpression *node = new (pool) AST::ThisExpression();
node->thisToken = loc(1);
sym(1).Node = node;
} break;
-case 81: {
+case 84: {
AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1));
node->identifierToken = loc(1);
sym(1).Node = node;
} break;
-case 82: {
+case 85: {
AST::NullExpression *node = new (pool) AST::NullExpression();
node->nullToken = loc(1);
sym(1).Node = node;
} break;
-case 83: {
+case 86: {
AST::TrueLiteral *node = new (pool) AST::TrueLiteral();
node->trueToken = loc(1);
sym(1).Node = node;
} break;
-case 84: {
+case 87: {
AST::FalseLiteral *node = new (pool) AST::FalseLiteral();
node->falseToken = loc(1);
sym(1).Node = node;
} break;
-case 85: {
+case 88: {
AST::NumericLiteral *node = new (pool) AST::NumericLiteral(sym(1).dval);
node->literalToken = loc(1);
sym(1).Node = node;
} break;
-case 86:
-case 87: {
+case 89:
+case 90: {
AST::StringLiteral *node = new (pool) AST::StringLiteral(stringRef(1));
node->literalToken = loc(1);
sym(1).Node = node;
} break;
-case 88: {
+case 91: {
bool rx = lexer->scanRegExp(Lexer::NoPrefix);
if (!rx) {
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
@@ -677,7 +714,7 @@ case 88: {
sym(1).Node = node;
} break;
-case 89: {
+case 92: {
bool rx = lexer->scanRegExp(Lexer::EqualPrefix);
if (!rx) {
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
@@ -693,28 +730,28 @@ case 89: {
sym(1).Node = node;
} break;
-case 90: {
+case 93: {
AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral((AST::Elision *) 0);
node->lbracketToken = loc(1);
node->rbracketToken = loc(2);
sym(1).Node = node;
} break;
-case 91: {
+case 94: {
AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).Elision->finish());
node->lbracketToken = loc(1);
node->rbracketToken = loc(3);
sym(1).Node = node;
} break;
-case 92: {
+case 95: {
AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish ());
node->lbracketToken = loc(1);
node->rbracketToken = loc(3);
sym(1).Node = node;
} break;
-case 93: {
+case 96: {
AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (),
(AST::Elision *) 0);
node->lbracketToken = loc(1);
@@ -723,7 +760,7 @@ case 93: {
sym(1).Node = node;
} break;
-case 94: {
+case 97: {
AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (),
sym(4).Elision->finish());
node->lbracketToken = loc(1);
@@ -732,7 +769,7 @@ case 94: {
sym(1).Node = node;
} break;
-case 95: {
+case 98: {
AST::ObjectLiteral *node = 0;
if (sym(2).Node)
node = new (pool) AST::ObjectLiteral(
@@ -744,7 +781,7 @@ case 95: {
sym(1).Node = node;
} break;
-case 96: {
+case 99: {
AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral(
sym(2).PropertyAssignmentList->finish ());
node->lbraceToken = loc(1);
@@ -752,14 +789,14 @@ case 96: {
sym(1).Node = node;
} break;
-case 97: {
+case 100: {
AST::NestedExpression *node = new (pool) AST::NestedExpression(sym(2).Expression);
node->lparenToken = loc(1);
node->rparenToken = loc(3);
sym(1).Node = node;
} break;
-case 98: {
+case 101: {
if (AST::ArrayMemberExpression *mem = AST::cast<AST::ArrayMemberExpression *>(sym(1).Expression)) {
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken,
QLatin1String("Ignored annotation")));
@@ -779,48 +816,48 @@ case 98: {
}
} break;
-case 99: {
+case 102: {
sym(1).Node = new (pool) AST::ElementList((AST::Elision *) 0, sym(1).Expression);
} break;
-case 100: {
+case 103: {
sym(1).Node = new (pool) AST::ElementList(sym(1).Elision->finish(), sym(2).Expression);
} break;
-case 101: {
+case 104: {
AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList,
(AST::Elision *) 0, sym(3).Expression);
node->commaToken = loc(2);
sym(1).Node = node;
} break;
-case 102: {
+case 105: {
AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, sym(3).Elision->finish(),
sym(4).Expression);
node->commaToken = loc(2);
sym(1).Node = node;
} break;
-case 103: {
+case 106: {
AST::Elision *node = new (pool) AST::Elision();
node->commaToken = loc(1);
sym(1).Node = node;
} break;
-case 104: {
+case 107: {
AST::Elision *node = new (pool) AST::Elision(sym(1).Elision);
node->commaToken = loc(2);
sym(1).Node = node;
} break;
-case 105: {
+case 108: {
AST::PropertyNameAndValue *node = new (pool) AST::PropertyNameAndValue(
sym(1).PropertyName, sym(3).Expression);
node->colonToken = loc(2);
sym(1).Node = node;
} break;
-case 106: {
+case 109: {
AST::PropertyGetterSetter *node = new (pool) AST::PropertyGetterSetter(
sym(2).PropertyName, sym(6).FunctionBody);
node->getSetToken = loc(1);
@@ -831,7 +868,7 @@ case 106: {
sym(1).Node = node;
} break;
-case 107: {
+case 110: {
AST::PropertyGetterSetter *node = new (pool) AST::PropertyGetterSetter(
sym(2).PropertyName, sym(4).FormalParameterList, sym(7).FunctionBody);
node->getSetToken = loc(1);
@@ -842,56 +879,56 @@ case 107: {
sym(1).Node = node;
} break;
-case 108: {
+case 111: {
sym(1).Node = new (pool) AST::PropertyAssignmentList(sym(1).PropertyAssignment);
} break;
-case 109: {
+case 112: {
AST::PropertyAssignmentList *node = new (pool) AST::PropertyAssignmentList(
sym(1).PropertyAssignmentList, sym(3).PropertyAssignment);
node->commaToken = loc(2);
sym(1).Node = node;
} break;
-case 110: {
+case 113: {
AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
node->propertyNameToken = loc(1);
sym(1).Node = node;
} break;
-case 111: {
+case 114: {
AST::StringLiteralPropertyName *node = new (pool) AST::StringLiteralPropertyName(stringRef(1));
node->propertyNameToken = loc(1);
sym(1).Node = node;
} break;
-case 112: {
+case 115: {
AST::NumericLiteralPropertyName *node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval);
node->propertyNameToken = loc(1);
sym(1).Node = node;
} break;
-case 113: {
+case 116: {
AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1));
node->propertyNameToken = loc(1);
sym(1).Node = node;
} break;
-case 149: {
+case 152: {
AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression);
node->lbracketToken = loc(2);
node->rbracketToken = loc(4);
sym(1).Node = node;
} break;
-case 150: {
+case 153: {
AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3));
node->dotToken = loc(2);
node->identifierToken = loc(3);
sym(1).Node = node;
} break;
-case 151: {
+case 154: {
AST::NewMemberExpression *node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList);
node->newToken = loc(1);
node->lparenToken = loc(3);
@@ -899,384 +936,384 @@ case 151: {
sym(1).Node = node;
} break;
-case 153: {
+case 156: {
AST::NewExpression *node = new (pool) AST::NewExpression(sym(2).Expression);
node->newToken = loc(1);
sym(1).Node = node;
} break;
-case 154: {
+case 157: {
AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList);
node->lparenToken = loc(2);
node->rparenToken = loc(4);
sym(1).Node = node;
} break;
-case 155: {
+case 158: {
AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList);
node->lparenToken = loc(2);
node->rparenToken = loc(4);
sym(1).Node = node;
} break;
-case 156: {
+case 159: {
AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression);
node->lbracketToken = loc(2);
node->rbracketToken = loc(4);
sym(1).Node = node;
} break;
-case 157: {
+case 160: {
AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3));
node->dotToken = loc(2);
node->identifierToken = loc(3);
sym(1).Node = node;
} break;
-case 158: {
+case 161: {
sym(1).Node = 0;
} break;
-case 159: {
+case 162: {
sym(1).Node = sym(1).ArgumentList->finish();
} break;
-case 160: {
+case 163: {
sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression);
} break;
-case 161: {
+case 164: {
AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression);
node->commaToken = loc(2);
sym(1).Node = node;
} break;
-case 165: {
+case 168: {
AST::PostIncrementExpression *node = new (pool) AST::PostIncrementExpression(sym(1).Expression);
node->incrementToken = loc(2);
sym(1).Node = node;
} break;
-case 166: {
+case 169: {
AST::PostDecrementExpression *node = new (pool) AST::PostDecrementExpression(sym(1).Expression);
node->decrementToken = loc(2);
sym(1).Node = node;
} break;
-case 168: {
+case 171: {
AST::DeleteExpression *node = new (pool) AST::DeleteExpression(sym(2).Expression);
node->deleteToken = loc(1);
sym(1).Node = node;
} break;
-case 169: {
+case 172: {
AST::VoidExpression *node = new (pool) AST::VoidExpression(sym(2).Expression);
node->voidToken = loc(1);
sym(1).Node = node;
} break;
-case 170: {
+case 173: {
AST::TypeOfExpression *node = new (pool) AST::TypeOfExpression(sym(2).Expression);
node->typeofToken = loc(1);
sym(1).Node = node;
} break;
-case 171: {
+case 174: {
AST::PreIncrementExpression *node = new (pool) AST::PreIncrementExpression(sym(2).Expression);
node->incrementToken = loc(1);
sym(1).Node = node;
} break;
-case 172: {
+case 175: {
AST::PreDecrementExpression *node = new (pool) AST::PreDecrementExpression(sym(2).Expression);
node->decrementToken = loc(1);
sym(1).Node = node;
} break;
-case 173: {
+case 176: {
AST::UnaryPlusExpression *node = new (pool) AST::UnaryPlusExpression(sym(2).Expression);
node->plusToken = loc(1);
sym(1).Node = node;
} break;
-case 174: {
+case 177: {
AST::UnaryMinusExpression *node = new (pool) AST::UnaryMinusExpression(sym(2).Expression);
node->minusToken = loc(1);
sym(1).Node = node;
} break;
-case 175: {
+case 178: {
AST::TildeExpression *node = new (pool) AST::TildeExpression(sym(2).Expression);
node->tildeToken = loc(1);
sym(1).Node = node;
} break;
-case 176: {
+case 179: {
AST::NotExpression *node = new (pool) AST::NotExpression(sym(2).Expression);
node->notToken = loc(1);
sym(1).Node = node;
} break;
-case 178: {
+case 181: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::Mul, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 179: {
+case 182: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::Div, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 180: {
+case 183: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::Mod, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 182: {
+case 185: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::Add, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 183: {
+case 186: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::Sub, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 185: {
+case 188: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::LShift, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 186: {
+case 189: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::RShift, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 187: {
+case 190: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::URShift, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 189: {
+case 192: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::Lt, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 190: {
+case 193: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::Gt, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 191: {
+case 194: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::Le, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 192: {
+case 195: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::Ge, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 193: {
+case 196: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::InstanceOf, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 194: {
+case 197: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::In, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 196: {
+case 199: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::Lt, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 197: {
+case 200: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::Gt, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 198: {
+case 201: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::Le, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 199: {
+case 202: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::Ge, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 200: {
+case 203: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::InstanceOf, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 202: {
+case 205: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::Equal, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 203: {
+case 206: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::NotEqual, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 204: {
+case 207: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::StrictEqual, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 205: {
+case 208: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::StrictNotEqual, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 207: {
+case 210: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::Equal, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 208: {
+case 211: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::NotEqual, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 209: {
+case 212: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::StrictEqual, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 210: {
+case 213: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::StrictNotEqual, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 212: {
+case 215: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::BitAnd, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 214: {
+case 217: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::BitAnd, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 216: {
+case 219: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::BitXor, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 218: {
+case 221: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::BitXor, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 220: {
+case 223: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::BitOr, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 222: {
+case 225: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::BitOr, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 224: {
+case 227: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::And, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 226: {
+case 229: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::And, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 228: {
+case 231: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::Or, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 230: {
+case 233: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::Or, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 232: {
+case 235: {
AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression,
sym(3).Expression, sym(5).Expression);
node->questionToken = loc(2);
@@ -1284,7 +1321,7 @@ case 232: {
sym(1).Node = node;
} break;
-case 234: {
+case 237: {
AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression,
sym(3).Expression, sym(5).Expression);
node->questionToken = loc(2);
@@ -1292,112 +1329,112 @@ case 234: {
sym(1).Node = node;
} break;
-case 236: {
+case 239: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
sym(2).ival, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 238: {
+case 241: {
AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
sym(2).ival, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
} break;
-case 239: {
+case 242: {
sym(1).ival = QSOperator::Assign;
} break;
-case 240: {
+case 243: {
sym(1).ival = QSOperator::InplaceMul;
} break;
-case 241: {
+case 244: {
sym(1).ival = QSOperator::InplaceDiv;
} break;
-case 242: {
+case 245: {
sym(1).ival = QSOperator::InplaceMod;
} break;
-case 243: {
+case 246: {
sym(1).ival = QSOperator::InplaceAdd;
} break;
-case 244: {
+case 247: {
sym(1).ival = QSOperator::InplaceSub;
} break;
-case 245: {
+case 248: {
sym(1).ival = QSOperator::InplaceLeftShift;
} break;
-case 246: {
+case 249: {
sym(1).ival = QSOperator::InplaceRightShift;
} break;
-case 247: {
+case 250: {
sym(1).ival = QSOperator::InplaceURightShift;
} break;
-case 248: {
+case 251: {
sym(1).ival = QSOperator::InplaceAnd;
} break;
-case 249: {
+case 252: {
sym(1).ival = QSOperator::InplaceXor;
} break;
-case 250: {
+case 253: {
sym(1).ival = QSOperator::InplaceOr;
} break;
-case 252: {
+case 255: {
AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression);
node->commaToken = loc(2);
sym(1).Node = node;
} break;
-case 253: {
+case 256: {
sym(1).Node = 0;
} break;
-case 256: {
+case 259: {
AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression);
node->commaToken = loc(2);
sym(1).Node = node;
} break;
-case 257: {
+case 260: {
sym(1).Node = 0;
} break;
-case 274: {
+case 277: {
AST::Block *node = new (pool) AST::Block(sym(2).StatementList);
node->lbraceToken = loc(1);
node->rbraceToken = loc(3);
sym(1).Node = node;
} break;
-case 275: {
+case 278: {
sym(1).Node = new (pool) AST::StatementList(sym(1).Statement);
} break;
-case 276: {
+case 279: {
sym(1).Node = new (pool) AST::StatementList(sym(1).StatementList, sym(2).Statement);
} break;
-case 277: {
+case 280: {
sym(1).Node = 0;
} break;
-case 278: {
+case 281: {
sym(1).Node = sym(1).StatementList->finish ();
} break;
-case 280: {
+case 283: {
AST::VariableStatement *node = new (pool) AST::VariableStatement(
sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST));
node->declarationKindToken = loc(1);
@@ -1405,76 +1442,76 @@ case 280: {
sym(1).Node = node;
} break;
-case 281: {
+case 284: {
sym(1).ival = T_CONST;
} break;
-case 282: {
+case 285: {
sym(1).ival = T_VAR;
} break;
-case 283: {
+case 286: {
sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration);
} break;
-case 284: {
+case 287: {
AST::VariableDeclarationList *node = new (pool) AST::VariableDeclarationList(
sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
node->commaToken = loc(2);
sym(1).Node = node;
} break;
-case 285: {
+case 288: {
sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration);
} break;
-case 286: {
+case 289: {
sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
} break;
-case 287: {
+case 290: {
AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression);
node->identifierToken = loc(1);
sym(1).Node = node;
} break;
-case 288: {
+case 291: {
AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression);
node->identifierToken = loc(1);
sym(1).Node = node;
} break;
-case 289: {
+case 292: {
// ### TODO: AST for initializer
sym(1) = sym(2);
} break;
-case 290: {
+case 293: {
sym(1).Node = 0;
} break;
-case 292: {
+case 295: {
// ### TODO: AST for initializer
sym(1) = sym(2);
} break;
-case 293: {
+case 296: {
sym(1).Node = 0;
} break;
-case 295: {
+case 298: {
AST::EmptyStatement *node = new (pool) AST::EmptyStatement();
node->semicolonToken = loc(1);
sym(1).Node = node;
} break;
-case 297: {
+case 300: {
AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(sym(1).Expression);
node->semicolonToken = loc(2);
sym(1).Node = node;
} break;
-case 298: {
+case 301: {
AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement);
node->ifToken = loc(1);
node->lparenToken = loc(2);
@@ -1483,7 +1520,7 @@ case 298: {
sym(1).Node = node;
} break;
-case 299: {
+case 302: {
AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement);
node->ifToken = loc(1);
node->lparenToken = loc(2);
@@ -1491,7 +1528,7 @@ case 299: {
sym(1).Node = node;
} break;
-case 302: {
+case 305: {
AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression);
node->doToken = loc(1);
node->whileToken = loc(3);
@@ -1501,7 +1538,7 @@ case 302: {
sym(1).Node = node;
} break;
-case 303: {
+case 306: {
AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement);
node->whileToken = loc(1);
node->lparenToken = loc(2);
@@ -1509,7 +1546,7 @@ case 303: {
sym(1).Node = node;
} break;
-case 304: {
+case 307: {
AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression,
sym(5).Expression, sym(7).Expression, sym(9).Statement);
node->forToken = loc(1);
@@ -1520,7 +1557,7 @@ case 304: {
sym(1).Node = node;
} break;
-case 305: {
+case 308: {
AST::LocalForStatement *node = new (pool) AST::LocalForStatement(
sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression,
sym(8).Expression, sym(10).Statement);
@@ -1533,7 +1570,7 @@ case 305: {
sym(1).Node = node;
} break;
-case 306: {
+case 309: {
AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression,
sym(5).Expression, sym(7).Statement);
node->forToken = loc(1);
@@ -1543,7 +1580,7 @@ case 306: {
sym(1).Node = node;
} break;
-case 307: {
+case 310: {
AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement(
sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement);
node->forToken = loc(1);
@@ -1554,14 +1591,14 @@ case 307: {
sym(1).Node = node;
} break;
-case 309: {
+case 312: {
AST::ContinueStatement *node = new (pool) AST::ContinueStatement();
node->continueToken = loc(1);
node->semicolonToken = loc(2);
sym(1).Node = node;
} break;
-case 311: {
+case 314: {
AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2));
node->continueToken = loc(1);
node->identifierToken = loc(2);
@@ -1569,14 +1606,14 @@ case 311: {
sym(1).Node = node;
} break;
-case 313: {
+case 316: {
AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef());
node->breakToken = loc(1);
node->semicolonToken = loc(2);
sym(1).Node = node;
} break;
-case 315: {
+case 318: {
AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2));
node->breakToken = loc(1);
node->identifierToken = loc(2);
@@ -1584,14 +1621,14 @@ case 315: {
sym(1).Node = node;
} break;
-case 317: {
+case 320: {
AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression);
node->returnToken = loc(1);
node->semicolonToken = loc(3);
sym(1).Node = node;
} break;
-case 318: {
+case 321: {
AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement);
node->withToken = loc(1);
node->lparenToken = loc(2);
@@ -1599,7 +1636,7 @@ case 318: {
sym(1).Node = node;
} break;
-case 319: {
+case 322: {
AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock);
node->switchToken = loc(1);
node->lparenToken = loc(2);
@@ -1607,83 +1644,83 @@ case 319: {
sym(1).Node = node;
} break;
-case 320: {
+case 323: {
AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses);
node->lbraceToken = loc(1);
node->rbraceToken = loc(3);
sym(1).Node = node;
} break;
-case 321: {
+case 324: {
AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses);
node->lbraceToken = loc(1);
node->rbraceToken = loc(5);
sym(1).Node = node;
} break;
-case 322: {
+case 325: {
sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause);
} break;
-case 323: {
+case 326: {
sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause);
} break;
-case 324: {
+case 327: {
sym(1).Node = 0;
} break;
-case 325: {
+case 328: {
sym(1).Node = sym(1).CaseClauses->finish ();
} break;
-case 326: {
+case 329: {
AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList);
node->caseToken = loc(1);
node->colonToken = loc(3);
sym(1).Node = node;
} break;
-case 327: {
+case 330: {
AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList);
node->defaultToken = loc(1);
node->colonToken = loc(2);
sym(1).Node = node;
} break;
-case 328: {
+case 331: {
AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement);
node->identifierToken = loc(1);
node->colonToken = loc(2);
sym(1).Node = node;
} break;
-case 330: {
+case 333: {
AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression);
node->throwToken = loc(1);
node->semicolonToken = loc(3);
sym(1).Node = node;
} break;
-case 331: {
+case 334: {
AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch);
node->tryToken = loc(1);
sym(1).Node = node;
} break;
-case 332: {
+case 335: {
AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally);
node->tryToken = loc(1);
sym(1).Node = node;
} break;
-case 333: {
+case 336: {
AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally);
node->tryToken = loc(1);
sym(1).Node = node;
} break;
-case 334: {
+case 337: {
AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block);
node->catchToken = loc(1);
node->lparenToken = loc(2);
@@ -1692,20 +1729,20 @@ case 334: {
sym(1).Node = node;
} break;
-case 335: {
+case 338: {
AST::Finally *node = new (pool) AST::Finally(sym(2).Block);
node->finallyToken = loc(1);
sym(1).Node = node;
} break;
-case 337: {
+case 340: {
AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement();
node->debuggerToken = loc(1);
node->semicolonToken = loc(2);
sym(1).Node = node;
} break;
-case 339: {
+case 342: {
AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
node->functionToken = loc(1);
node->identifierToken = loc(2);
@@ -1716,7 +1753,7 @@ case 339: {
sym(1).Node = node;
} break;
-case 340: {
+case 343: {
AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody);
node->functionToken = loc(1);
if (! stringRef(2).isNull())
@@ -1728,7 +1765,7 @@ case 340: {
sym(1).Node = node;
} break;
-case 341: {
+case 344: {
AST::FunctionExpression *node = new (pool) AST::FunctionExpression(QStringRef(), sym(3).FormalParameterList, sym(6).FunctionBody);
node->functionToken = loc(1);
node->lparenToken = loc(2);
@@ -1738,56 +1775,56 @@ case 341: {
sym(1).Node = node;
} break;
-case 342: {
+case 345: {
AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1));
node->identifierToken = loc(1);
sym(1).Node = node;
} break;
-case 343: {
+case 346: {
AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3));
node->commaToken = loc(2);
node->identifierToken = loc(3);
sym(1).Node = node;
} break;
-case 344: {
+case 347: {
sym(1).Node = 0;
} break;
-case 345: {
+case 348: {
sym(1).Node = sym(1).FormalParameterList->finish ();
} break;
-case 346: {
+case 349: {
sym(1).Node = 0;
} break;
-case 348: {
+case 351: {
sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ());
} break;
-case 350: {
+case 353: {
sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ());
} break;
-case 351: {
+case 354: {
sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement);
} break;
-case 352: {
+case 355: {
sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement);
} break;
-case 353: {
+case 356: {
sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement);
} break;
-case 354: {
+case 357: {
sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration);
} break;
-case 355: {
+case 358: {
sym(1).Node = 0;
} break;
diff --git a/src/qml/parser/qqmljsparser_p.h b/src/qml/parser/qqmljsparser_p.h
index 00ffb6aca3..f382cd7563 100644
--- a/src/qml/parser/qqmljsparser_p.h
+++ b/src/qml/parser/qqmljsparser_p.h
@@ -246,9 +246,9 @@ protected:
-#define J_SCRIPT_REGEXPLITERAL_RULE1 88
+#define J_SCRIPT_REGEXPLITERAL_RULE1 91
-#define J_SCRIPT_REGEXPLITERAL_RULE2 89
+#define J_SCRIPT_REGEXPLITERAL_RULE2 92
QT_QML_END_NAMESPACE
diff --git a/src/qml/qml/qml.pri b/src/qml/qml/qml.pri
index 8d8da3742d..412dc6cba2 100644
--- a/src/qml/qml/qml.pri
+++ b/src/qml/qml/qml.pri
@@ -42,7 +42,6 @@ SOURCES += \
$$PWD/qqmlabstracturlinterceptor.cpp \
$$PWD/qqmlapplicationengine.cpp \
$$PWD/qqmllistwrapper.cpp \
- $$PWD/qqmlcontextwrapper.cpp \
$$PWD/qqmlvaluetypewrapper.cpp \
$$PWD/qqmltypewrapper.cpp \
$$PWD/qqmlfileselector.cpp \
@@ -113,8 +112,6 @@ HEADERS += \
$$PWD/qqmlapplicationengine_p.h \
$$PWD/qqmlapplicationengine.h \
$$PWD/qqmllistwrapper_p.h \
- $$PWD/qqmlcontextwrapper_p.h \
- $$PWD/qqmlvaluetypewrapper_p.h \
$$PWD/qqmltypewrapper_p.h \
$$PWD/qqmlfileselector_p.h \
$$PWD/qqmlfileselector.h \
diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h
index 39764b8001..f0973338ea 100644
--- a/src/qml/qml/qqml.h
+++ b/src/qml/qml/qqml.h
@@ -526,6 +526,7 @@ QT_WARNING_POP
//The C++ version of protected namespaces in qmldir
Q_QML_EXPORT bool qmlProtectModule(const char* uri, int majVersion);
+Q_QML_EXPORT void qmlRegisterModule(const char *uri, int versionMajor, int versionMinor);
template<typename T>
QObject *qmlAttachedPropertiesObject(const QObject *obj, bool create = true)
diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp
index 1a912d53e6..8a97b7eba7 100644
--- a/src/qml/qml/qqmlapplicationengine.cpp
+++ b/src/qml/qml/qqmlapplicationengine.cpp
@@ -58,7 +58,7 @@ QQmlApplicationEnginePrivate::~QQmlApplicationEnginePrivate()
void QQmlApplicationEnginePrivate::cleanUp()
{
qDeleteAll(objects);
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
qDeleteAll(translators);
#endif
}
@@ -70,7 +70,7 @@ void QQmlApplicationEnginePrivate::init()
q, SLOT(_q_finishLoad(QObject*)));
q->connect(q, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit()));
q->connect(q, &QQmlApplicationEngine::exit, QCoreApplication::instance(), &QCoreApplication::exit);
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
QTranslator* qtTranslator = new QTranslator;
if (qtTranslator->load(QLatin1String("qt_") + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
QCoreApplication::installTranslator(qtTranslator);
@@ -82,7 +82,7 @@ void QQmlApplicationEnginePrivate::init()
void QQmlApplicationEnginePrivate::loadTranslations(const QUrl &rootFile)
{
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
if (rootFile.scheme() != QLatin1String("file") && rootFile.scheme() != QLatin1String("qrc"))
return;
diff --git a/src/qml/qml/qqmlapplicationengine_p.h b/src/qml/qml/qqmlapplicationengine_p.h
index e1d1b4a7bb..8c342a43a9 100644
--- a/src/qml/qml/qqmlapplicationengine_p.h
+++ b/src/qml/qml/qqmlapplicationengine_p.h
@@ -78,7 +78,7 @@ public:
QSignalMapper statusMapper;
QObject *appObj;
-#ifndef QT_NO_TRANSLATIONS
+#if QT_CONFIG(translation)
QList<QTranslator *> translators;
#endif
};
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index 4fe76ddf29..284ae1f36f 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -46,7 +46,6 @@
#include <private/qqmlprofiler_p.h>
#include <private/qqmlexpression_p.h>
#include <private/qqmlscriptstring_p.h>
-#include <private/qqmlcontextwrapper_p.h>
#include <private/qqmlbuiltinfunctions_p.h>
#include <private/qqmlvmemetaobject_p.h>
#include <private/qqmlvaluetypewrapper_p.h>
@@ -58,18 +57,6 @@
QT_BEGIN_NAMESPACE
-QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QString &str, QObject *obj, QQmlContext *ctxt)
-{
- QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property);
- b->setNotifyOnValueChanged(true);
- b->QQmlJavaScriptExpression::setContext(QQmlContextData::get(ctxt));
- b->setScopeObject(obj);
-
- b->createQmlBinding(b->context(), obj, str, QString(), 0);
-
- return b;
-}
-
QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QQmlScriptString &script, QObject *obj, QQmlContext *ctxt)
{
QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property);
@@ -98,7 +85,9 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QQmlScr
QV4::ExecutionEngine *v4 = QQmlEnginePrivate::get(b->context()->engine)->v4engine();
if (runtimeFunction) {
- b->m_function.set(v4, QV4::FunctionObject::createQmlFunction(ctxtdata, b->scopeObject(), runtimeFunction));
+ QV4::Scope scope(v4);
+ QV4::Scoped<QV4::QmlContext> qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxtdata, b->scopeObject()));
+ b->setupFunction(qmlContext, runtimeFunction);
} else {
QString code = scriptPrivate->script;
b->createQmlBinding(b->context(), b->scopeObject(), code, url, scriptPrivate->lineNumber);
@@ -107,26 +96,11 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QQmlScr
return b;
}
-QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QString &str, QObject *obj, QQmlContextData *ctxt)
-{
- QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property);
-
- b->setNotifyOnValueChanged(true);
- b->QQmlJavaScriptExpression::setContext(ctxt);
- b->setScopeObject(obj);
-
- b->createQmlBinding(ctxt, obj, str, QString(), 0);
-
- return b;
-}
-
QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QString &str, QObject *obj,
- QQmlContextData *ctxt, const QString &url, quint16 lineNumber,
- quint16 columnNumber)
+ QQmlContextData *ctxt, const QString &url, quint16 lineNumber)
{
QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property);
- Q_UNUSED(columnNumber);
b->setNotifyOnValueChanged(true);
b->QQmlJavaScriptExpression::setContext(ctxt);
b->setScopeObject(obj);
@@ -136,7 +110,8 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QString
return b;
}
-QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QV4::Value &functionPtr, QObject *obj, QQmlContextData *ctxt)
+QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, QV4::Function *function,
+ QObject *obj, QQmlContextData *ctxt, QV4::ExecutionContext *scope)
{
QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property);
@@ -144,7 +119,8 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QV4::Va
b->QQmlJavaScriptExpression::setContext(ctxt);
b->setScopeObject(obj);
- b->m_function.set(functionPtr.as<QV4::Object>()->engine(), functionPtr);
+ Q_ASSERT(scope);
+ b->setupFunction(scope, function);
return b;
}
@@ -183,14 +159,12 @@ void QQmlBinding::update(QQmlPropertyData::WriteFlags flags)
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context()->engine);
QV4::Scope scope(ep->v4engine());
- QV4::ScopedFunctionObject f(scope, m_function.value());
- Q_ASSERT(f);
if (canUseAccessor())
flags.setFlag(QQmlPropertyData::BypassInterceptor);
- QQmlBindingProfiler prof(ep->profiler, this, f);
- doUpdate(watcher, flags, scope, f);
+ QQmlBindingProfiler prof(ep->profiler, this, function());
+ doUpdate(watcher, flags, scope);
if (!watcher.wasDeleted())
setUpdatingFlag(false);
@@ -205,8 +179,7 @@ class QQmlBindingBinding: public QQmlBinding
{
protected:
void doUpdate(const DeleteWatcher &,
- QQmlPropertyData::WriteFlags flags, QV4::Scope &,
- const QV4::ScopedFunctionObject &) Q_DECL_OVERRIDE Q_DECL_FINAL
+ QQmlPropertyData::WriteFlags flags, QV4::Scope &) Q_DECL_OVERRIDE Q_DECL_FINAL
{
Q_ASSERT(!m_targetIndex.hasValueTypeIndex());
QQmlPropertyData *pd = nullptr;
@@ -222,8 +195,7 @@ class QQmlNonbindingBinding: public QQmlBinding
{
protected:
void doUpdate(const DeleteWatcher &watcher,
- QQmlPropertyData::WriteFlags flags, QV4::Scope &scope,
- const QV4::ScopedFunctionObject &f) Q_DECL_OVERRIDE Q_DECL_FINAL
+ QQmlPropertyData::WriteFlags flags, QV4::Scope &scope) Q_DECL_OVERRIDE Q_DECL_FINAL
{
auto ep = QQmlEnginePrivate::get(scope.engine);
ep->referenceScarceResources();
@@ -240,7 +212,7 @@ protected:
if (!watcher.wasDeleted()) {
if (error) {
- delayedError()->setErrorLocation(f->sourceLocation());
+ delayedError()->setErrorLocation(sourceLocation());
delayedError()->setErrorObject(m_target.data());
}
@@ -250,10 +222,9 @@ protected:
clearError();
}
+ cancelPermanentGuards();
}
- cancelPermanentGuards();
-
ep->dereferenceScarceResources();
}
@@ -451,14 +422,10 @@ QVariant QQmlBinding::evaluate()
QString QQmlBinding::expressionIdentifier() const
{
- QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context()->engine);
- QV4::Scope scope(ep->v4engine());
- QV4::ScopedValue f(scope, m_function.value());
- QV4::Function *function = f->as<QV4::FunctionObject>()->function();
-
- QString url = function->sourceFile();
- quint16 lineNumber = function->compiledFunction->location.line;
- quint16 columnNumber = function->compiledFunction->location.column;
+ auto f = function();
+ QString url = f->sourceFile();
+ quint16 lineNumber = f->compiledFunction->location.line;
+ quint16 columnNumber = f->compiledFunction->location.column;
return url + QString::asprintf(":%u:%u", uint(lineNumber), uint(columnNumber));
}
@@ -489,9 +456,7 @@ void QQmlBinding::setEnabled(bool e, QQmlPropertyData::WriteFlags flags)
QString QQmlBinding::expression() const
{
- QV4::Scope scope(QQmlEnginePrivate::get(context()->engine)->v4engine());
- QV4::ScopedValue v(scope, m_function.value());
- return v->toQStringNoThrow();
+ return QStringLiteral("function() { [code] }");
}
void QQmlBinding::setTarget(const QQmlProperty &prop)
diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h
index be23a96d01..0f2fb329f5 100644
--- a/src/qml/qml/qqmlbinding_p.h
+++ b/src/qml/qml/qqmlbinding_p.h
@@ -72,12 +72,11 @@ class Q_QML_PRIVATE_EXPORT QQmlBinding : public QQmlJavaScriptExpression,
{
friend class QQmlAbstractBinding;
public:
- static QQmlBinding *create(const QQmlPropertyData *, const QString &, QObject *, QQmlContext *);
static QQmlBinding *create(const QQmlPropertyData *, const QQmlScriptString &, QObject *, QQmlContext *);
- static QQmlBinding *create(const QQmlPropertyData *, const QString &, QObject *, QQmlContextData *);
static QQmlBinding *create(const QQmlPropertyData *, const QString &, QObject *, QQmlContextData *,
- const QString &url, quint16 lineNumber, quint16 columnNumber);
- static QQmlBinding *create(const QQmlPropertyData *, const QV4::Value &, QObject *, QQmlContextData *);
+ const QString &url = QString(), quint16 lineNumber = 0);
+ static QQmlBinding *create(const QQmlPropertyData *property, QV4::Function *function,
+ QObject *obj, QQmlContextData *ctxt, QV4::ExecutionContext *scope);
~QQmlBinding();
void setTarget(const QQmlProperty &);
@@ -103,8 +102,7 @@ public:
protected:
virtual void doUpdate(const DeleteWatcher &watcher,
- QQmlPropertyData::WriteFlags flags, QV4::Scope &scope,
- const QV4::ScopedFunctionObject &f) = 0;
+ QQmlPropertyData::WriteFlags flags, QV4::Scope &scope) = 0;
void getPropertyData(QQmlPropertyData **propertyData, QQmlPropertyData *valueTypeData) const;
int getPropertyType() const;
diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp
index dfb1b98ca0..254d5e1907 100644
--- a/src/qml/qml/qqmlboundsignal.cpp
+++ b/src/qml/qml/qqmlboundsignal.cpp
@@ -98,20 +98,20 @@ QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index,
function += parameterString;
function += QLatin1String(") { ") + expression + QLatin1String(" })");
- m_function.set(v4, evalFunction(context(), scopeObject(), function, fileName, line));
-
- if (m_function.isNullOrUndefined())
- return; // could not evaluate function. Not valid.
-
+ QV4::Scope valueScope(v4);
+ QV4::ScopedFunctionObject f(valueScope, evalFunction(context(), scopeObject(), function, fileName, line));
+ QV4::ScopedContext context(valueScope, f->scope());
+ setupFunction(context, f->function());
}
-QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, QQmlContextData *ctxt, QObject *scope, const QV4::Value &function)
+QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, QQmlContextData *ctxt, QObject *scopeObject,
+ QV4::Function *function, QV4::ExecutionContext *scope)
: QQmlJavaScriptExpression(),
m_index(index),
m_target(target)
{
- m_function.set(function.as<QV4::Object>()->engine(), function);
- init(ctxt, scope);
+ setupFunction(scope, function);
+ init(ctxt, scopeObject);
}
QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, QQmlContextData *ctxt, QObject *scope, QV4::Function *runtimeFunction)
@@ -122,14 +122,22 @@ QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index,
// It's important to call init first, because m_index gets remapped in case of cloned signals.
init(ctxt, scope);
- QMetaMethod signal = QMetaObjectPrivate::signal(m_target->metaObject(), m_index);
- QString error;
QV4::ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(ctxt->engine);
- m_function.set(engine, QV4::FunctionObject::createQmlFunction(ctxt, scope, runtimeFunction, signal.parameterNames(), &error));
- if (!error.isEmpty()) {
- qmlInfo(scopeObject()) << error;
- m_function.clear();
+
+ QList<QByteArray> signalParameters = QMetaObjectPrivate::signal(m_target->metaObject(), m_index).parameterNames();
+ if (!signalParameters.isEmpty()) {
+ QString error;
+ QQmlPropertyCache::signalParameterStringForJS(engine, signalParameters, &error);
+ if (!error.isEmpty()) {
+ qmlInfo(scopeObject()) << error;
+ return;
+ }
+ runtimeFunction->updateInternalClass(engine, signalParameters);
}
+
+ QV4::Scope valueScope(engine);
+ QV4::Scoped<QV4::QmlContext> qmlContext(valueScope, QV4::QmlContext::create(engine->rootContext(), ctxt, scope));
+ setupFunction(qmlContext, runtimeFunction);
}
void QQmlBoundSignalExpression::init(QQmlContextData *ctxt, QObject *scope)
@@ -157,41 +165,13 @@ void QQmlBoundSignalExpression::expressionChanged()
// bound signals do not notify on change.
}
-QQmlSourceLocation QQmlBoundSignalExpression::sourceLocation() const
-{
- QV4::Function *f = function();
- if (f) {
- QQmlSourceLocation loc;
- loc.sourceFile = f->sourceFile();
- loc.line = f->compiledFunction->location.line;
- loc.column = f->compiledFunction->location.column;
- return loc;
- }
- return QQmlSourceLocation();
-}
-
QString QQmlBoundSignalExpression::expression() const
{
- if (expressionFunctionValid()) {
- Q_ASSERT (context() && engine());
- QV4::Scope scope(QQmlEnginePrivate::get(engine())->v4engine());
- QV4::ScopedValue v(scope, m_function.value());
- return v->toQStringNoThrow();
- }
+ if (expressionFunctionValid())
+ return QStringLiteral("function() { [code] }");
return QString();
}
-QV4::Function *QQmlBoundSignalExpression::function() const
-{
- if (expressionFunctionValid()) {
- Q_ASSERT (context() && engine());
- QV4::Scope scope(QQmlEnginePrivate::get(engine())->v4engine());
- QV4::ScopedFunctionObject v(scope, m_function.value());
- return v ? v->function() : 0;
- }
- return 0;
-}
-
// Parts of this function mirror code in QQmlExpressionPrivate::value() and v8value().
// Changes made here may need to be made there and vice versa.
void QQmlBoundSignalExpression::evaluate(void **a)
diff --git a/src/qml/qml/qqmlboundsignal_p.h b/src/qml/qml/qqmlboundsignal_p.h
index 4356c6cbfa..3a0b8aed59 100644
--- a/src/qml/qml/qqmlboundsignal_p.h
+++ b/src/qml/qml/qqmlboundsignal_p.h
@@ -73,7 +73,7 @@ public:
const QString &parameterString = QString());
QQmlBoundSignalExpression(QObject *target, int index,
- QQmlContextData *ctxt, QObject *scope, const QV4::Value &function);
+ QQmlContextData *ctxt, QObject *scopeObject, QV4::Function *function, QV4::ExecutionContext *scope);
QQmlBoundSignalExpression(QObject *target, int index,
QQmlContextData *ctxt, QObject *scope, QV4::Function *runtimeFunction);
@@ -86,9 +86,7 @@ public:
void evaluate(void **a);
void evaluate(const QList<QVariant> &args);
- QQmlSourceLocation sourceLocation() const;
QString expression() const;
- QV4::Function *function() const;
QObject *target() const { return m_target; }
QQmlEngine *engine() const { return context() ? context()->engine : 0; }
@@ -98,7 +96,7 @@ private:
void init(QQmlContextData *ctxt, QObject *scope);
- bool expressionFunctionValid() const { return !m_function.isNullOrUndefined(); }
+ bool expressionFunctionValid() const { return function() != 0; }
int m_index;
QObject *m_target;
diff --git a/src/qml/qml/qqmlcontext_p.h b/src/qml/qml/qqmlcontext_p.h
index 162fbcc8f6..4d2bb72352 100644
--- a/src/qml/qml/qqmlcontext_p.h
+++ b/src/qml/qml/qqmlcontext_p.h
@@ -197,7 +197,7 @@ public:
{
inline ContextGuard();
inline ContextGuard &operator=(QObject *obj);
- inline void objectDestroyed(QObject *);
+ inline void objectDestroyed(QObject *) override;
inline bool wasSet() const;
diff --git a/src/qml/qml/qqmldelayedcallqueue.cpp b/src/qml/qml/qqmldelayedcallqueue.cpp
index d10a8c7718..7552e1e82b 100644
--- a/src/qml/qml/qqmldelayedcallqueue.cpp
+++ b/src/qml/qml/qqmldelayedcallqueue.cpp
@@ -43,7 +43,6 @@
#include <private/qqmljavascriptexpression_p.h>
#include <private/qv4value_p.h>
#include <private/qv4qobjectwrapper_p.h>
-#include <private/qqmlcontextwrapper_p.h>
#include <QQmlError>
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 3fa5838e10..c2915c840b 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -443,7 +443,7 @@ The following functions are also on the Qt object.
\li \c "osx" - \macos
\li \c "unix" - Other Unix-based OS
\li \c "windows" - Windows
- \li \c "winrt" - Windows Runtime
+ \li \c "winrt" - WinRT / UWP
\li \c "winphone" - Windows Phone
\endlist
\endtable
diff --git a/src/qml/qml/qqmlerror.cpp b/src/qml/qml/qqmlerror.cpp
index b309550ca8..0a6c7b4960 100644
--- a/src/qml/qml/qqmlerror.cpp
+++ b/src/qml/qml/qqmlerror.cpp
@@ -285,7 +285,7 @@ QDebug operator<<(QDebug debug, const QQmlError &error)
if (f.open(QIODevice::ReadOnly)) {
QByteArray data = f.readAll();
QTextStream stream(data, QIODevice::ReadOnly);
-#ifndef QT_NO_TEXTCODEC
+#if QT_CONFIG(textcodec)
stream.setCodec("UTF-8");
#endif
const QString code = stream.readAll();
diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp
index 01d4722ca6..1e1fbcf448 100644
--- a/src/qml/qml/qqmlexpression.cpp
+++ b/src/qml/qml/qqmlexpression.cpp
@@ -75,7 +75,9 @@ void QQmlExpressionPrivate::init(QQmlContextData *ctxt, QV4::Function *runtimeFu
{
expressionFunctionValid = true;
QV4::ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(ctxt->engine);
- m_function.set(engine, QV4::FunctionObject::createQmlFunction(ctxt, me, runtimeFunction));
+ QV4::Scope scope(engine);
+ QV4::Scoped<QV4::QmlContext> qmlContext(scope, QV4::QmlContext::create(engine->rootContext(), ctxt, me));
+ setupFunction(qmlContext, runtimeFunction);
QQmlJavaScriptExpression::setContext(ctxt);
setScopeObject(me);
diff --git a/src/qml/qml/qqmlglobal.cpp b/src/qml/qml/qqmlglobal.cpp
index 722527a546..f967dacd34 100644
--- a/src/qml/qml/qqmlglobal.cpp
+++ b/src/qml/qml/qqmlglobal.cpp
@@ -326,7 +326,6 @@ QObject *QQmlGuiProvider::application(QObject *) { return new QQmlApplication();
QStringList QQmlGuiProvider::fontFamilies() { return QStringList(); }
bool QQmlGuiProvider::openUrlExternally(QUrl &) { return false; }
-#ifndef QT_NO_IM
QObject *QQmlGuiProvider::inputMethod()
{
// We don't have any input method code by default
@@ -335,7 +334,6 @@ QObject *QQmlGuiProvider::inputMethod()
QQmlEngine::setObjectOwnership(o, QQmlEngine::JavaScriptOwnership);
return o;
}
-#endif
QObject *QQmlGuiProvider::styleHints()
{
diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h
index 0f5cf3a392..707814e781 100644
--- a/src/qml/qml/qqmlglobal_p.h
+++ b/src/qml/qml/qqmlglobal_p.h
@@ -307,9 +307,7 @@ class Q_QML_PRIVATE_EXPORT QQmlGuiProvider
public:
virtual ~QQmlGuiProvider();
virtual QObject *application(QObject *parent);
-#ifndef QT_NO_IM
virtual QObject *inputMethod();
-#endif
virtual QObject *styleHints();
virtual QStringList fontFamilies();
virtual bool openUrlExternally(QUrl &);
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index 4ded0f93bb..8712b638c5 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -177,7 +177,7 @@ QQmlType *getTypeForUrl(const QString &urlString, const QHashedStringRef& typeNa
} // namespace
-#ifndef QT_NO_LIBRARY
+#if QT_CONFIG(library)
struct RegisteredPlugin {
QString uri;
QPluginLoader* loader;
@@ -302,7 +302,7 @@ public:
const QString &uri, const QString &url,
int vmaj, int vmin, QV4::CompiledData::Import::ImportType type,
QList<QQmlError> *errors, bool lowPrecedence = false);
-#ifndef QT_NO_LIBRARY
+#if QT_CONFIG(library)
bool populatePluginPairVector(QVector<StaticPluginPair> &result, const QString &uri, const QStringList &versionUris,
const QString &qmldirPath, QList<QQmlError> *errors);
#endif
@@ -897,7 +897,7 @@ static QStringList versionUriList(const QString &uri, int vmaj, int vmin)
return result;
}
-#ifndef QT_NO_LIBRARY
+#if QT_CONFIG(library)
static QVector<QStaticPlugin> makePlugins()
{
QVector<QStaticPlugin> plugins;
@@ -966,7 +966,7 @@ bool QQmlImportsPrivate::importExtension(const QString &qmldirFilePath,
const QQmlTypeLoader::QmldirContent *qmldir,
QList<QQmlError> *errors)
{
-#if !defined(QT_NO_LIBRARY)
+#if QT_CONFIG(library)
Q_ASSERT(qmldir);
if (qmlImportTrace())
@@ -1094,7 +1094,7 @@ bool QQmlImportsPrivate::importExtension(const QString &qmldirFilePath,
}
return false;
-#endif // QT_NO_LIBRARY
+#endif // library
return true;
}
@@ -1950,7 +1950,7 @@ bool QQmlImportDatabase::registerPluginTypes(QObject *instance, const QString &b
bool QQmlImportDatabase::importStaticPlugin(QObject *instance, const QString &basePath,
const QString &uri, const QString &typeNamespace, int vmaj, QList<QQmlError> *errors)
{
-#ifndef QT_NO_LIBRARY
+#if QT_CONFIG(library)
// Dynamic plugins are differentiated by their filepath. For static plugins we
// don't have that information so we use their address as key instead.
const QString uniquePluginID = QString::asprintf("%p", instance);
@@ -2003,7 +2003,7 @@ bool QQmlImportDatabase::importStaticPlugin(QObject *instance, const QString &ba
bool QQmlImportDatabase::importDynamicPlugin(const QString &filePath, const QString &uri,
const QString &typeNamespace, int vmaj, QList<QQmlError> *errors)
{
-#ifndef QT_NO_LIBRARY
+#if QT_CONFIG(library)
QFileInfo fileInfo(filePath);
const QString absoluteFilePath = fileInfo.absoluteFilePath();
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index 8020bdb2be..17cccc0bbd 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -48,6 +48,7 @@
#include <private/qv4scopedvalue_p.h>
#include <private/qqmlglobal_p.h>
#include <private/qv4qobjectwrapper_p.h>
+#include <private/qqmlbuiltinfunctions_p.h>
QT_BEGIN_NAMESPACE
@@ -94,7 +95,9 @@ QQmlJavaScriptExpression::QQmlJavaScriptExpression()
: m_error(0),
m_context(0),
m_prevExpression(0),
- m_nextExpression(0)
+ m_nextExpression(0),
+ m_v4Function(0),
+ m_sourceLocation(0)
{
}
@@ -110,6 +113,8 @@ QQmlJavaScriptExpression::~QQmlJavaScriptExpression()
clearPermanentGuards();
if (m_scopeObject.isT2()) // notify DeleteWatcher of our deletion.
m_scopeObject.asT2()->_s = 0;
+
+ delete m_sourceLocation;
}
void QQmlJavaScriptExpression::setNotifyOnValueChanged(bool v)
@@ -128,6 +133,22 @@ void QQmlJavaScriptExpression::resetNotifyOnValueChanged()
setNotifyOnValueChanged(false);
}
+QQmlSourceLocation QQmlJavaScriptExpression::sourceLocation() const
+{
+ if (m_sourceLocation)
+ return *m_sourceLocation;
+ if (m_v4Function)
+ return m_v4Function->sourceLocation();
+ return QQmlSourceLocation();
+}
+
+void QQmlJavaScriptExpression::setSourceLocation(const QQmlSourceLocation &location)
+{
+ if (m_sourceLocation)
+ delete m_sourceLocation;
+ m_sourceLocation = new QQmlSourceLocation(location);
+}
+
void QQmlJavaScriptExpression::setContext(QQmlContextData *context)
{
if (m_prevExpression) {
@@ -149,6 +170,11 @@ void QQmlJavaScriptExpression::setContext(QQmlContextData *context)
}
}
+QV4::Function *QQmlJavaScriptExpression::function() const
+{
+ return m_v4Function;
+}
+
void QQmlJavaScriptExpression::refresh()
{
}
@@ -159,8 +185,8 @@ void QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, bool *isUndefin
{
Q_ASSERT(m_context && m_context->engine);
- QV4::Value *f = m_function.valueRef();
- if (!f || f->isUndefined()) {
+ QV4::Function *v4Function = function();
+ if (!v4Function) {
if (isUndefined)
*isUndefined = true;
return;
@@ -191,7 +217,13 @@ void QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, bool *isUndefin
callData->thisObject = value;
}
- f->as<QV4::FunctionObject>()->call(scope, callData);
+ QV4::ExecutionContext *outer = static_cast<QV4::ExecutionContext *>(m_qmlScope.valueRef());
+ if (v4Function->canUseSimpleFunction()) {
+ outer->simpleCall(scope, callData, v4Function);
+ } else {
+ outer->call(scope, callData, v4Function);
+ }
+
if (scope.hasException()) {
if (watcher.wasDeleted())
scope.engine->catchException(); // ignore exception
@@ -374,7 +406,7 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scopeObje
QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine());
QV4::Scope scope(v4);
- QV4::Scoped<QV4::QmlContext> qmlContext(scope, v4->rootContext()->newQmlContext(ctxt, scopeObject));
+ QV4::Scoped<QV4::QmlContext> qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxt, scopeObject));
QV4::Script script(v4, qmlContext, code, filename, line);
QV4::ScopedValue result(scope);
script.parse();
@@ -404,12 +436,9 @@ void QQmlJavaScriptExpression::createQmlBinding(QQmlContextData *ctxt, QObject *
QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine());
QV4::Scope scope(v4);
- QV4::Scoped<QV4::QmlContext> qmlContext(scope, v4->rootContext()->newQmlContext(ctxt, qmlScope));
+ QV4::Scoped<QV4::QmlContext> qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxt, qmlScope));
QV4::Script script(v4, qmlContext, code, filename, line);
- QV4::ScopedValue result(scope);
script.parse();
- if (!v4->hasException)
- result = script.qmlBinding();
if (v4->hasException) {
QQmlError error = v4->catchExceptionAsQmlError();
if (error.description().isEmpty())
@@ -420,11 +449,19 @@ void QQmlJavaScriptExpression::createQmlBinding(QQmlContextData *ctxt, QObject *
error.setUrl(QUrl::fromLocalFile(filename));
error.setObject(qmlScope);
ep->warning(error);
- result = QV4::Encode::undefined();
+ return;
}
- m_function.set(v4, result);
+ setupFunction(qmlContext, script.vmFunction);
}
+void QQmlJavaScriptExpression::setupFunction(QV4::ExecutionContext *qmlContext, QV4::Function *f)
+{
+ if (!qmlContext || !f)
+ return;
+ m_qmlScope.set(qmlContext->engine(), *qmlContext);
+ m_v4Function = f;
+ m_compilationUnit = m_v4Function->compilationUnit;
+}
void QQmlJavaScriptExpression::clearActiveGuards()
{
diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h
index a0735d91de..646cc5ab3d 100644
--- a/src/qml/qml/qqmljavascriptexpression_p.h
+++ b/src/qml/qml/qqmljavascriptexpression_p.h
@@ -113,11 +113,16 @@ public:
inline QObject *scopeObject() const;
inline void setScopeObject(QObject *v);
+ QQmlSourceLocation sourceLocation() const;
+ void setSourceLocation(const QQmlSourceLocation &location);
+
bool isValid() const { return context() != 0; }
QQmlContextData *context() const { return m_context; }
void setContext(QQmlContextData *context);
+ QV4::Function *function() const;
+
virtual void refresh();
class DeleteWatcher {
@@ -154,6 +159,8 @@ protected:
}
}
+ void setupFunction(QV4::ExecutionContext *qmlContext, QV4::Function *f);
+
private:
friend class QQmlContextData;
friend class QQmlPropertyCapture;
@@ -173,8 +180,10 @@ private:
QQmlJavaScriptExpression *m_nextExpression;
bool m_permanentDependenciesRegistered = false;
-protected:
- QV4::PersistentValue m_function;
+ QV4::PersistentValue m_qmlScope;
+ QQmlRefPointer<QV4::CompiledData::CompilationUnit> m_compilationUnit;
+ QV4::Function *m_v4Function;
+ QQmlSourceLocation *m_sourceLocation; // used for Qt.binding() created functions
};
class QQmlPropertyCapture
diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp
index 6f66475aa5..3876e774c3 100644
--- a/src/qml/qml/qqmllocale.cpp
+++ b/src/qml/qml/qqmllocale.cpp
@@ -107,8 +107,8 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleString(QV4::CallContext *ct
QLocale::FormatType enumFormat = QLocale::LongFormat;
QString formattedDt;
if (ctx->argc() == 2) {
- if (ctx->args()[1].isString()) {
- QString format = ctx->args()[1].stringValue()->toQString();
+ if (String *s = ctx->args()[1].stringValue()) {
+ QString format = s->toQString();
formattedDt = r->d()->locale->toString(dt, format);
} else if (ctx->args()[1].isNumber()) {
quint32 intFormat = ctx->args()[1].toNumber();
@@ -152,8 +152,8 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleTimeString(QV4::CallContext
QLocale::FormatType enumFormat = QLocale::LongFormat;
QString formattedTime;
if (ctx->argc() == 2) {
- if (ctx->args()[1].isString()) {
- QString format = ctx->args()[1].stringValue()->toQString();
+ if (String *s = ctx->args()[1].stringValue()) {
+ QString format = s->toQString();
formattedTime = r->d()->locale->toString(time, format);
} else if (ctx->args()[1].isNumber()) {
quint32 intFormat = ctx->args()[1].toNumber();
@@ -197,8 +197,8 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleDateString(QV4::CallContext
QLocale::FormatType enumFormat = QLocale::LongFormat;
QString formattedDate;
if (ctx->argc() == 2) {
- if (ctx->args()[1].isString()) {
- QString format = ctx->args()[1].stringValue()->toQString();
+ if (String *s = ctx->args()[1].stringValue()) {
+ QString format = s->toQString();
formattedDate = r->d()->locale->toString(date, format);
} else if (ctx->args()[1].isNumber()) {
quint32 intFormat = ctx->args()[1].toNumber();
@@ -217,11 +217,13 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleDateString(QV4::CallContext
QV4::ReturnedValue QQmlDateExtension::method_fromLocaleString(QV4::CallContext *ctx)
{
QV4::ExecutionEngine * const engine = ctx->d()->engine;
- if (ctx->argc() == 1 && ctx->args()[0].isString()) {
- QLocale locale;
- QString dateString = ctx->args()[0].stringValue()->toQString();
- QDateTime dt = locale.toDateTime(dateString);
- return QV4::Encode(engine->newDateObject(dt));
+ if (ctx->argc() == 1) {
+ if (String *s = ctx->args()[0].stringValue()) {
+ QLocale locale;
+ QString dateString = s->toQString();
+ QDateTime dt = locale.toDateTime(dateString);
+ return QV4::Encode(engine->newDateObject(dt));
+ }
}
QV4::Scope scope(ctx);
@@ -235,8 +237,8 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleString(QV4::CallContext *
QDateTime dt;
QString dateString = ctx->args()[1].toQStringNoThrow();
if (ctx->argc() == 3) {
- if (ctx->args()[2].isString()) {
- QString format = ctx->args()[2].stringValue()->toQString();
+ if (String *s = ctx->args()[2].stringValue()) {
+ QString format = s->toQString();
dt = r->d()->locale->toDateTime(dateString, format);
} else if (ctx->args()[2].isNumber()) {
quint32 intFormat = ctx->args()[2].toNumber();
@@ -256,13 +258,15 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(QV4::CallConte
{
QV4::ExecutionEngine * const engine = ctx->d()->engine;
- if (ctx->argc() == 1 && ctx->args()[0].isString()) {
- QLocale locale;
- QString timeString = ctx->args()[0].stringValue()->toQString();
- QTime time = locale.toTime(timeString);
- QDateTime dt = QDateTime::currentDateTime();
- dt.setTime(time);
- return QV4::Encode(engine->newDateObject(dt));
+ if (ctx->argc() == 1) {
+ if (String *s = ctx->args()[0].stringValue()) {
+ QLocale locale;
+ QString timeString = s->toQString();
+ QTime time = locale.toTime(timeString);
+ QDateTime dt = QDateTime::currentDateTime();
+ dt.setTime(time);
+ return QV4::Encode(engine->newDateObject(dt));
+ }
}
if (ctx->argc() < 1 || ctx->argc() > 3 || !isLocaleObject(ctx->args()[0]))
@@ -276,8 +280,8 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(QV4::CallConte
QTime tm;
QString dateString = ctx->args()[1].toQStringNoThrow();
if (ctx->argc() == 3) {
- if (ctx->args()[2].isString()) {
- QString format = ctx->args()[2].stringValue()->toQString();
+ if (String *s = ctx->args()[2].stringValue()) {
+ QString format = s->toQString();
tm = r->d()->locale->toTime(dateString, format);
} else if (ctx->args()[2].isNumber()) {
quint32 intFormat = ctx->args()[2].toNumber();
@@ -303,11 +307,13 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::CallConte
{
QV4::ExecutionEngine * const engine = ctx->d()->engine;
- if (ctx->argc() == 1 && ctx->args()[0].isString()) {
- QLocale locale;
- QString dateString = ctx->args()[0].stringValue()->toQString();
- QDate date = locale.toDate(dateString);
- return QV4::Encode(engine->newDateObject(QDateTime(date)));
+ if (ctx->argc() == 1) {
+ if (String *s = ctx->args()[0].stringValue()) {
+ QLocale locale;
+ QString dateString = s->toQString();
+ QDate date = locale.toDate(dateString);
+ return QV4::Encode(engine->newDateObject(QDateTime(date)));
+ }
}
if (ctx->argc() < 1 || ctx->argc() > 3 || !isLocaleObject(ctx->args()[0]))
@@ -321,8 +327,8 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::CallConte
QDate dt;
QString dateString = ctx->args()[1].toQStringNoThrow();
if (ctx->argc() == 3) {
- if (ctx->args()[2].isString()) {
- QString format = ctx->args()[2].stringValue()->toQString();
+ if (String *s = ctx->args()[2].stringValue()) {
+ QString format = s->toQString();
dt = r->d()->locale->toDate(dateString, format);
} else if (ctx->args()[2].isNumber()) {
quint32 intFormat = ctx->args()[2].toNumber();
diff --git a/src/qml/qml/qqmlloggingcategory.cpp b/src/qml/qml/qqmlloggingcategory.cpp
index fd8fb477c7..70e59db07b 100644
--- a/src/qml/qml/qqmlloggingcategory.cpp
+++ b/src/qml/qml/qqmlloggingcategory.cpp
@@ -112,13 +112,13 @@ void QQmlLoggingCategory::componentComplete()
{
m_initialized = true;
if (m_name.isNull())
- qmlInfo(this) << QString(QLatin1String("Declaring the name of the LoggingCategory is mandatory and cannot be changed later !"));
+ qmlInfo(this) << QLatin1String("Declaring the name of the LoggingCategory is mandatory and cannot be changed later !");
}
void QQmlLoggingCategory::setName(const QString &name)
{
if (m_initialized) {
- qmlInfo(this) << QString(QLatin1String("The name of a LoggingCategory cannot be changed after the Item is created"));
+ qmlInfo(this) << QLatin1String("The name of a LoggingCategory cannot be changed after the Item is created");
return;
}
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index 7b758566b7..520c44f4da 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -1158,7 +1158,7 @@ void qmlClearTypeRegistrations() // Declared in qqml.h
data->uriToModule.clear();
QQmlEnginePrivate::baseModulesUninitialized = true; //So the engine re-registers its types
-#ifndef QT_NO_LIBRARY
+#if QT_CONFIG(library)
qmlClearEnginePlugins();
#endif
}
@@ -1268,6 +1268,19 @@ bool checkRegistration(QQmlType::RegistrationType typeType, QQmlMetaTypeData *da
}
// NOTE: caller must hold a QMutexLocker on "data"
+QQmlTypeModule *getTypeModule(const QHashedString &uri, int majorVersion, QQmlMetaTypeData *data)
+{
+ QQmlMetaTypeData::VersionedUri versionedUri(uri, majorVersion);
+ QQmlTypeModule *module = data->uriToModule.value(versionedUri);
+ if (!module) {
+ module = new QQmlTypeModule;
+ module->d->uri = versionedUri;
+ data->uriToModule.insert(versionedUri, module);
+ }
+ return module;
+}
+
+// NOTE: caller must hold a QMutexLocker on "data"
void addTypeToData(QQmlType* type, QQmlMetaTypeData *data)
{
if (!type->elementName().isEmpty())
@@ -1293,13 +1306,8 @@ void addTypeToData(QQmlType* type, QQmlMetaTypeData *data)
if (!type->module().isEmpty()) {
const QHashedString &mod = type->module();
- QQmlMetaTypeData::VersionedUri versionedUri(mod, type->majorVersion());
- QQmlTypeModule *module = data->uriToModule.value(versionedUri);
- if (!module) {
- module = new QQmlTypeModule;
- module->d->uri = versionedUri;
- data->uriToModule.insert(versionedUri, module);
- }
+ QQmlTypeModule *module = getTypeModule(mod, type->majorVersion(), data);
+ Q_ASSERT(module);
module->d->add(type);
}
}
@@ -1442,6 +1450,20 @@ bool qmlProtectModule(const char *uri, int majVersion)
return false;
}
+//From qqml.h
+void qmlRegisterModule(const char *uri, int versionMajor, int versionMinor)
+{
+ QMutexLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+
+ QQmlTypeModule *module = getTypeModule(QString::fromUtf8(uri), versionMajor, data);
+ Q_ASSERT(module);
+
+ QQmlTypeModulePrivate *p = QQmlTypeModulePrivate::get(module);
+ p->minMinorVersion = qMin(p->minMinorVersion, versionMinor);
+ p->maxMinorVersion = qMax(p->maxMinorVersion, versionMinor);
+}
+
bool QQmlMetaType::namespaceContainsRegistrations(const QString &uri, int majorVersion)
{
const QQmlMetaTypeData *data = metaTypeData();
diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h
index cc0e0ad71e..2b615e645a 100644
--- a/src/qml/qml/qqmlmetatype_p.h
+++ b/src/qml/qml/qqmlmetatype_p.h
@@ -266,6 +266,7 @@ public:
private:
//Used by register functions and creates the QQmlTypeModule for them
+ friend QQmlTypeModule *getTypeModule(const QHashedString &uri, int majorVersion, QQmlMetaTypeData *data);
friend void addTypeToData(QQmlType* type, QQmlMetaTypeData *data);
friend struct QQmlMetaTypeData;
friend Q_QML_EXPORT void qmlClearTypeRegistrations();
diff --git a/src/qml/qml/qqmlnotifier.cpp b/src/qml/qml/qqmlnotifier.cpp
index 19f03eae80..185f9687fb 100644
--- a/src/qml/qml/qqmlnotifier.cpp
+++ b/src/qml/qml/qqmlnotifier.cpp
@@ -71,6 +71,12 @@ namespace {
};
}
+void QQmlNotifier::notify(QQmlData *ddata, int notifierIndex)
+{
+ if (QQmlNotifierEndpoint *ep = ddata->notify(notifierIndex))
+ emitNotify(ep, Q_NULLPTR);
+}
+
void QQmlNotifier::emitNotify(QQmlNotifierEndpoint *endpoint, void **a)
{
QVarLengthArray<NotifyListTraversalData> stack;
diff --git a/src/qml/qml/qqmlnotifier_p.h b/src/qml/qml/qqmlnotifier_p.h
index 4db0dd038a..dad79e0e55 100644
--- a/src/qml/qml/qqmlnotifier_p.h
+++ b/src/qml/qml/qqmlnotifier_p.h
@@ -65,6 +65,8 @@ public:
inline ~QQmlNotifier();
inline void notify();
+ static void notify(QQmlData *ddata, int notifierIndex);
+
private:
friend class QQmlData;
friend class QQmlNotifierEndpoint;
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 2218f277d6..2e2a3fb303 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -44,7 +44,6 @@
#include <private/qv4function_p.h>
#include <private/qv4functionobject_p.h>
#include <private/qv4qobjectwrapper_p.h>
-#include <private/qqmlcontextwrapper_p.h>
#include <private/qqmlbinding_p.h>
#include <private/qqmlstringconverters_p.h>
#include <private/qqmlboundsignal_p.h>
@@ -402,7 +401,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
}
}
break;
-#ifndef QT_NO_DATESTRING
+#if QT_CONFIG(datestring)
case QVariant::Date: {
bool ok = false;
QDate value = QQmlStringConverters::dateFromString(binding->valueAsString(qmlUnit), &ok);
@@ -430,7 +429,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
-#endif // QT_NO_DATESTRING
+#endif // datestring
case QVariant::Point: {
bool ok = false;
QPoint value = QQmlStringConverters::pointFFromString(binding->valueAsString(qmlUnit), &ok).toPoint();
@@ -793,14 +792,13 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con
QV4::Function *runtimeFunction = compilationUnit->runtimeFunctions[binding->value.compiledScriptIndex];
QV4::Scope scope(v4);
- QV4::ScopedContext qmlContext(scope, currentQmlContext());
- QV4::ScopedFunctionObject function(scope, QV4::FunctionObject::createScriptFunction(qmlContext, runtimeFunction, /*createProto*/ false));
+ QV4::Scoped<QV4::QmlContext> qmlContext(scope, currentQmlContext());
if (binding->flags & QV4::CompiledData::Binding::IsSignalHandlerExpression) {
int signalIndex = _propertyCache->methodIndexToSignalIndex(property->coreIndex());
QQmlBoundSignal *bs = new QQmlBoundSignal(_bindingTarget, signalIndex, _scopeObject, engine);
QQmlBoundSignalExpression *expr = new QQmlBoundSignalExpression(_bindingTarget, signalIndex,
- context, _scopeObject, function);
+ context, _scopeObject, runtimeFunction, qmlContext);
bs->takeExpression(expr);
} else {
@@ -810,13 +808,14 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con
// the result is written to a value type virtual property, that contains the sub-index
// of the "x" property.
QQmlBinding *qmlBinding;
+ const QQmlPropertyData *prop = property;
+ const QQmlPropertyData *subprop = nullptr;
if (_valueTypeProperty) {
- qmlBinding = QQmlBinding::create(_valueTypeProperty, function, _scopeObject, context);
- qmlBinding->setTarget(_bindingTarget, *_valueTypeProperty, property);
- } else {
- qmlBinding = QQmlBinding::create(property, function, _scopeObject, context);
- qmlBinding->setTarget(_bindingTarget, *property, nullptr);
+ prop = _valueTypeProperty;
+ subprop = property;
}
+ qmlBinding = QQmlBinding::create(prop, runtimeFunction, _scopeObject, context, qmlContext);
+ qmlBinding->setTarget(_bindingTarget, *prop, subprop);
sharedState->allCreatedBindings.push(QQmlAbstractBinding::Ptr(qmlBinding));
@@ -1016,8 +1015,8 @@ void QQmlObjectCreator::registerObjectWithContextById(const QV4::CompiledData::O
QV4::Heap::QmlContext *QQmlObjectCreator::currentQmlContext()
{
- if (!_qmlContext->objectValue())
- _qmlContext->setM(v4->rootContext()->newQmlContext(context, _scopeObject));
+ if (!_qmlContext->isManaged())
+ _qmlContext->setM(QV4::QmlContext::create(v4->rootContext(), context, _scopeObject));
return _qmlContext->d();
}
diff --git a/src/qml/qml/qqmlopenmetaobject_p.h b/src/qml/qml/qqmlopenmetaobject_p.h
index 183baec941..4bb92489a5 100644
--- a/src/qml/qml/qqmlopenmetaobject_p.h
+++ b/src/qml/qml/qqmlopenmetaobject_p.h
@@ -83,7 +83,7 @@ public:
protected:
virtual void propertyCreated(int, QMetaPropertyBuilder &);
- virtual void clear();
+ void clear() override;
private:
QQmlOpenMetaObjectTypePrivate *d;
diff --git a/src/qml/qml/qqmlproperty_p.h b/src/qml/qml/qqmlproperty_p.h
index 2565ec0ce6..53062a2f13 100644
--- a/src/qml/qml/qqmlproperty_p.h
+++ b/src/qml/qml/qqmlproperty_p.h
@@ -115,30 +115,26 @@ public:
};
Q_DECLARE_FLAGS(BindingFlags, BindingFlag)
- static void setBinding(QQmlAbstractBinding *binding, BindingFlags flags = None, QQmlPropertyData::WriteFlags writeFlags = QQmlPropertyData::DontRemoveBinding);
+ static void setBinding(QQmlAbstractBinding *binding, BindingFlags flags = None,
+ QQmlPropertyData::WriteFlags writeFlags = QQmlPropertyData::DontRemoveBinding);
static void removeBinding(const QQmlProperty &that);
static void removeBinding(QObject *o, QQmlPropertyIndex index);
static void removeBinding(QQmlAbstractBinding *b);
static QQmlAbstractBinding *binding(QObject *, QQmlPropertyIndex index);
- static QQmlProperty restore(QObject *, const QQmlPropertyData &, const QQmlPropertyData *,
- QQmlContextData *);
+ static QQmlProperty restore(QObject *, const QQmlPropertyData &, const QQmlPropertyData *, QQmlContextData *);
int signalIndex() const;
- static inline QQmlPropertyPrivate *get(const QQmlProperty &p) {
- return p.d;
- }
+ static inline QQmlPropertyPrivate *get(const QQmlProperty &p) { return p.d; }
// "Public" (to QML) methods
static QQmlAbstractBinding *binding(const QQmlProperty &that);
static void setBinding(const QQmlProperty &that, QQmlAbstractBinding *);
static QQmlBoundSignalExpression *signalExpression(const QQmlProperty &that);
- static void setSignalExpression(const QQmlProperty &that,
- QQmlBoundSignalExpression *);
- static void takeSignalExpression(const QQmlProperty &that,
- QQmlBoundSignalExpression *);
+ static void setSignalExpression(const QQmlProperty &that, QQmlBoundSignalExpression *);
+ static void takeSignalExpression(const QQmlProperty &that, QQmlBoundSignalExpression *);
static bool write(const QQmlProperty &that, const QVariant &, QQmlPropertyData::WriteFlags);
static QQmlPropertyIndex propertyIndex(const QQmlProperty &that);
static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &);
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index b645d47c39..562aa1c88a 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -978,7 +978,8 @@ int QQmlPropertyCache::originalClone(QObject *object, int index)
return index;
}
-static QQmlPropertyData qQmlPropertyCacheCreate(const QMetaObject *metaObject, const QStringRef &property)
+template<typename T>
+static QQmlPropertyData qQmlPropertyCacheCreate(const QMetaObject *metaObject, const T& propertyName)
{
Q_ASSERT(metaObject);
@@ -995,8 +996,6 @@ static QQmlPropertyData qQmlPropertyCacheCreate(const QMetaObject *metaObject, c
// These indices don't apply to gadgets, so don't block them.
const bool preventDestruction = metaObject->superClass() || metaObject == &QObject::staticMetaObject;
- const QByteArray propertyName = property.toUtf8();
-
int methodCount = metaObject->methodCount();
for (int ii = methodCount - 1; ii >= 0; --ii) {
if (preventDestruction && (ii == destroyedIdx1 || ii == destroyedIdx2 || ii == deleteLaterIdx))
@@ -1038,19 +1037,19 @@ static QQmlPropertyData qQmlPropertyCacheCreate(const QMetaObject *metaObject, c
return rv;
}
-static inline QQmlPropertyData qQmlPropertyCacheCreate(const QMetaObject *metaObject, const QString &property)
+static inline const char *qQmlPropertyCacheToString(QLatin1String string)
{
- return qQmlPropertyCacheCreate(metaObject, QStringRef(&property));
+ return string.data();
}
-static inline const QStringRef &qQmlPropertyCacheToString(const QStringRef &string)
+static inline QByteArray qQmlPropertyCacheToString(const QStringRef &string)
{
- return string;
+ return string.toUtf8();
}
-static inline QString qQmlPropertyCacheToString(const QV4::String *string)
+static inline QByteArray qQmlPropertyCacheToString(const QV4::String *string)
{
- return string->toQString();
+ return string->toQString().toUtf8();
}
template<typename T>
@@ -1101,6 +1100,13 @@ QQmlPropertyCache::property(QJSEngine *engine, QObject *obj, const QStringRef &n
return qQmlPropertyCacheProperty<const QStringRef &>(engine, obj, name, context, local);
}
+QQmlPropertyData *
+QQmlPropertyCache::property(QJSEngine *engine, QObject *obj, const QLatin1String &name,
+ QQmlContextData *context, QQmlPropertyData &local)
+{
+ return qQmlPropertyCacheProperty<const QLatin1String &>(engine, obj, name, context, local);
+}
+
// these two functions are copied from qmetaobject.cpp
static inline const QMetaObjectPrivate *priv(const uint* data)
{ return reinterpret_cast<const QMetaObjectPrivate*>(data); }
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h
index d34d1bf387..64be1cb206 100644
--- a/src/qml/qml/qqmlpropertycache_p.h
+++ b/src/qml/qml/qqmlpropertycache_p.h
@@ -408,6 +408,8 @@ public:
static QQmlPropertyData *property(QJSEngine *, QObject *, const QStringRef &,
QQmlContextData *, QQmlPropertyData &);
+ static QQmlPropertyData *property(QJSEngine *, QObject *, const QLatin1String &,
+ QQmlContextData *, QQmlPropertyData &);
static QQmlPropertyData *property(QJSEngine *, QObject *, const QV4::String *,
QQmlContextData *, QQmlPropertyData &);
diff --git a/src/qml/qml/qqmlstringconverters.cpp b/src/qml/qml/qqmlstringconverters.cpp
index d2b3577a1f..e53f90b45b 100644
--- a/src/qml/qml/qqmlstringconverters.cpp
+++ b/src/qml/qml/qqmlstringconverters.cpp
@@ -71,14 +71,14 @@ QVariant QQmlStringConverters::variantFromString(const QString &s, int preferred
return QVariant(int(qRound(s.toDouble(ok))));
case QMetaType::UInt:
return QVariant(uint(qRound(s.toDouble(ok))));
-#ifndef QT_NO_DATESTRING
+#if QT_CONFIG(datestring)
case QMetaType::QDate:
return QVariant::fromValue(dateFromString(s, ok));
case QMetaType::QTime:
return QVariant::fromValue(timeFromString(s, ok));
case QMetaType::QDateTime:
return QVariant::fromValue(dateTimeFromString(s, ok));
-#endif // QT_NO_DATESTRING
+#endif // datestring
case QMetaType::QPointF:
return QVariant::fromValue(pointFFromString(s, ok));
case QMetaType::QPoint:
@@ -106,7 +106,7 @@ unsigned QQmlStringConverters::rgbaFromString(const QString &s, bool *ok)
return QQml_colorProvider()->rgbaFromString(s, ok);
}
-#ifndef QT_NO_DATESTRING
+#if QT_CONFIG(datestring)
QDate QQmlStringConverters::dateFromString(const QString &s, bool *ok)
{
QDate d = QDate::fromString(s, Qt::ISODate);
@@ -130,7 +130,7 @@ QDateTime QQmlStringConverters::dateTimeFromString(const QString &s, bool *ok)
d.setTimeSpec(Qt::UTC);
return d;
}
-#endif // QT_NO_DATESTRING
+#endif // datestring
//expects input of "x,y"
QPointF QQmlStringConverters::pointFFromString(const QString &s, bool *ok)
@@ -229,7 +229,7 @@ bool QQmlStringConverters::createFromString(int type, const QString &s, void *da
*p = uint(qRound(s.toDouble(&ok)));
return ok;
}
-#ifndef QT_NO_DATESTRING
+#if QT_CONFIG(datestring)
case QMetaType::QDate:
{
Q_ASSERT(n >= sizeof(QDate));
@@ -251,7 +251,7 @@ bool QQmlStringConverters::createFromString(int type, const QString &s, void *da
*p = dateTimeFromString(s, &ok);
return ok;
}
-#endif // QT_NO_DATESTRING
+#endif // datestring
case QMetaType::QPointF:
{
Q_ASSERT(n >= sizeof(QPointF));
diff --git a/src/qml/qml/qqmlstringconverters_p.h b/src/qml/qml/qqmlstringconverters_p.h
index b67cefaf35..af344e3344 100644
--- a/src/qml/qml/qqmlstringconverters_p.h
+++ b/src/qml/qml/qqmlstringconverters_p.h
@@ -72,7 +72,7 @@ namespace QQmlStringConverters
Q_QML_PRIVATE_EXPORT QVariant colorFromString(const QString &, bool *ok = 0);
Q_QML_PRIVATE_EXPORT unsigned rgbaFromString(const QString &, bool *ok = 0);
-#ifndef QT_NO_DATESTRING
+#if QT_CONFIG(datestring)
Q_QML_PRIVATE_EXPORT QDate dateFromString(const QString &, bool *ok = 0);
Q_QML_PRIVATE_EXPORT QTime timeFromString(const QString &, bool *ok = 0);
Q_QML_PRIVATE_EXPORT QDateTime dateTimeFromString(const QString &, bool *ok = 0);
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 3885e6ea0b..76ac15e2f1 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -39,7 +39,6 @@
#include "qqmltypeloader_p.h"
#include "qqmlabstracturlinterceptor.h"
-#include "qqmlcontextwrapper_p.h"
#include "qqmlexpression_p.h"
#include <private/qqmlengine_p.h>
@@ -2836,7 +2835,7 @@ QV4::ReturnedValue QQmlScriptData::scriptValueForContext(QQmlContextData *parent
return QV4::Encode::undefined();
}
- QV4::Scoped<QV4::QmlContext> qmlContext(scope, v4->rootContext()->newQmlContext(ctxt, 0));
+ QV4::Scoped<QV4::QmlContext> qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxt, 0));
qmlContext->takeContextOwnership();
m_program->qmlContext.set(scope.engine, qmlContext);
diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h
index abbbf89ea2..b1d6451974 100644
--- a/src/qml/qml/qqmltypeloader_p.h
+++ b/src/qml/qml/qqmltypeloader_p.h
@@ -577,8 +577,8 @@ public:
void setPriority(int);
protected:
- virtual void dataReceived(const Data &);
- virtual void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit*);
+ void dataReceived(const Data &) override;
+ void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit*) override;
private:
QString m_content;
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp
index 5c3ad6b2a6..fd1e9cc2be 100644
--- a/src/qml/qml/qqmltypewrapper.cpp
+++ b/src/qml/qml/qqmltypewrapper.cpp
@@ -38,7 +38,6 @@
****************************************************************************/
#include "qqmltypewrapper_p.h"
-#include <private/qqmlcontextwrapper_p.h>
#include <private/qv8engine_p.h>
#include <private/qqmlengine_p.h>
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index 43b9e4bd3b..6ce52bb9e5 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -43,7 +43,6 @@
#include <private/qqmlvaluetype_p.h>
#include <private/qqmlbinding_p.h>
#include <private/qqmlglobal_p.h>
-#include <private/qqmlcontextwrapper_p.h>
#include <private/qqmlbuiltinfunctions_p.h>
#include <private/qv4engine_p.h>
@@ -390,6 +389,7 @@ ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, String *name, bool *ha
// These four types are the most common used by the value type wrappers
VALUE_TYPE_LOAD(QMetaType::QReal, qreal, qreal);
+ VALUE_TYPE_LOAD(QMetaType::Int || result->isEnum(), int, int);
VALUE_TYPE_LOAD(QMetaType::Int, int, int);
VALUE_TYPE_LOAD(QMetaType::QString, QString, v4->newString);
VALUE_TYPE_LOAD(QMetaType::Bool, bool, bool);
@@ -453,9 +453,10 @@ void QQmlValueTypeWrapper::put(Managed *m, String *name, const Value &value)
cacheData.setCoreIndex(reference->d()->property);
QV4::Scoped<QQmlBindingFunction> bindingFunction(scope, (const Value &)f);
- bindingFunction->initBindingLocation();
- QQmlBinding *newBinding = QQmlBinding::create(&cacheData, value, reference->d()->object, context);
+ QV4::ScopedContext ctx(scope, bindingFunction->scope());
+ QQmlBinding *newBinding = QQmlBinding::create(&cacheData, bindingFunction->function(), reference->d()->object, context, ctx);
+ newBinding->setSourceLocation(bindingFunction->currentLocation());
newBinding->setTarget(reference->d()->object, cacheData, pd);
QQmlPropertyPrivate::setBinding(newBinding);
return;
diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp
index 01c4f476d6..72d4ab7e8f 100644
--- a/src/qml/qml/qqmlvme.cpp
+++ b/src/qml/qml/qqmlvme.cpp
@@ -62,7 +62,6 @@
#include "qqmlpropertyvalueinterceptor_p.h"
#include "qqmlvaluetypeproxybinding_p.h"
#include "qqmlexpression_p.h"
-#include "qqmlcontextwrapper_p.h"
#include <QStack>
#include <QPointF>
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index 791870b831..545daa96f8 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -489,9 +489,9 @@ QString QQmlVMEMetaObject::readPropertyAsString(int id) const
QV4::Scope scope(cache->engine);
QV4::ScopedValue sv(scope, *(md->data() + id));
- if (!sv->isString())
- return QString();
- return sv->stringValue()->toQString();
+ if (QV4::String *s = sv->stringValue())
+ return s->toQString();
+ return QString();
}
QUrl QQmlVMEMetaObject::readPropertyAsUrl(int id) const
diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h
index 9a13e0047d..bb6fede7c8 100644
--- a/src/qml/qml/qqmlvmemetaobject_p.h
+++ b/src/qml/qml/qqmlvmemetaobject_p.h
@@ -83,7 +83,7 @@ public:
inline QQmlVMEVariantQObjectPtr();
inline ~QQmlVMEVariantQObjectPtr();
- inline void objectDestroyed(QObject *);
+ inline void objectDestroyed(QObject *) override;
inline void setGuardedValue(QObject *obj, QQmlVMEMetaObject *target, int index);
QQmlVMEMetaObject *m_target;
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index b4be709b37..22c3c49c58 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -50,7 +50,6 @@
#include <private/qv4domerrors_p.h>
#include <private/qv4engine_p.h>
#include <private/qv4functionobject_p.h>
-#include <private/qqmlcontextwrapper_p.h>
#include <private/qv4scopedvalue_p.h>
#include <QtCore/qobject.h>
@@ -70,7 +69,7 @@
using namespace QV4;
-#if !defined(QT_NO_XMLSTREAMREADER) && QT_CONFIG(qml_network)
+#if QT_CONFIG(xmlstreamreader) && QT_CONFIG(qml_network)
#define V4THROW_REFERENCE(string) { \
ScopedObject error(scope, ctx->engine()->newReferenceErrorObject(QStringLiteral(string))); \
@@ -1069,7 +1068,7 @@ private:
QByteArray m_mime;
QByteArray m_charset;
QTextCodec *m_textCodec;
-#ifndef QT_NO_TEXTCODEC
+#if QT_CONFIG(textcodec)
QTextCodec* findTextCodec() const;
#endif
void readEncoding();
@@ -1511,7 +1510,7 @@ QV4::ReturnedValue QQmlXMLHttpRequest::xmlResponseBody(QV4::ExecutionEngine* eng
return m_parsedDocument.value();
}
-#ifndef QT_NO_TEXTCODEC
+#if QT_CONFIG(textcodec)
QTextCodec* QQmlXMLHttpRequest::findTextCodec() const
{
QTextCodec *codec = 0;
@@ -1540,7 +1539,7 @@ QTextCodec* QQmlXMLHttpRequest::findTextCodec() const
QString QQmlXMLHttpRequest::responseBody()
{
-#ifndef QT_NO_TEXTCODEC
+#if QT_CONFIG(textcodec)
if (!m_textCodec)
m_textCodec = findTextCodec();
if (m_textCodec)
@@ -2057,6 +2056,6 @@ void *qt_add_qmlxmlhttprequest(ExecutionEngine *v4)
QT_END_NAMESPACE
-#endif // QT_NO_XMLSTREAMREADER && qml_network
+#endif // xmlstreamreader && qml_network
#include <qqmlxmlhttprequest.moc>
diff --git a/src/qml/qml/qqmlxmlhttprequest_p.h b/src/qml/qml/qqmlxmlhttprequest_p.h
index fdb6194537..f2836d8301 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) && QT_CONFIG(qml_network)
+#if QT_CONFIG(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 && qml_network
+#endif // xmlstreamreader && qml_network
#endif // QQMLXMLHTTPREQUEST_P_H
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index cf0fd57773..19dc100f40 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -148,9 +148,7 @@ void Heap::QtObject::init(QQmlEngine *qmlEngine)
o->defineAccessorProperty(QStringLiteral("platform"), QV4::QtObject::method_get_platform, 0);
o->defineAccessorProperty(QStringLiteral("application"), QV4::QtObject::method_get_application, 0);
-#ifndef QT_NO_IM
o->defineAccessorProperty(QStringLiteral("inputMethod"), QV4::QtObject::method_get_inputMethod, 0);
-#endif
o->defineAccessorProperty(QStringLiteral("styleHints"), QV4::QtObject::method_get_styleHints, 0);
o->defineDefaultProperty(QStringLiteral("callLater"), QV4::QtObject::method_callLater);
@@ -1031,7 +1029,7 @@ ReturnedValue QtObject::method_exit(CallContext *ctx)
/*!
\qmlmethod object Qt::createQmlObject(string qml, object parent, string filepath)
-Returns a new object created from the given \a string of QML which will have the specified \a parent,
+Returns a new object created from the given \a qml string which will have the specified \a parent,
or \c null if there was an error in creating the object.
If \a filepath is specified, it will be used for error reporting for the created object.
@@ -1305,30 +1303,15 @@ ReturnedValue QtObject::method_locale(CallContext *ctx)
void Heap::QQmlBindingFunction::init(const QV4::FunctionObject *originalFunction)
{
- QV4::Heap::FunctionObject::init(originalFunction->scope(), originalFunction->name());
- bindingLocation = new QQmlSourceLocation;
- this->originalFunction = originalFunction->d();
+ Scope scope(originalFunction->engine());
+ ScopedContext context(scope, originalFunction->scope());
+ FunctionObject::init(context, originalFunction->function());
}
-void QQmlBindingFunction::initBindingLocation()
+QQmlSourceLocation QQmlBindingFunction::currentLocation() const
{
QV4::StackFrame frame = engine()->currentStackFrame();
- d()->bindingLocation->sourceFile = frame.source;
- d()->bindingLocation->line = frame.line;
-}
-
-void QQmlBindingFunction::call(const Managed *that, Scope &scope, CallData *callData)
-{
- ScopedFunctionObject function(scope, static_cast<const QQmlBindingFunction*>(that)->d()->originalFunction);
- function->call(scope, callData);
-}
-
-void QQmlBindingFunction::markObjects(Heap::Base *that, ExecutionEngine *e)
-{
- QQmlBindingFunction::Data *This = static_cast<QQmlBindingFunction::Data *>(that);
- if (This->originalFunction)
- This->originalFunction->mark(e);
- QV4::FunctionObject::markObjects(that, e);
+ return QQmlSourceLocation(frame.source, frame.line, 0);
}
DEFINE_OBJECT_VTABLE(QQmlBindingFunction);
@@ -1423,13 +1406,11 @@ ReturnedValue QtObject::method_get_application(CallContext *ctx)
return QV4::QObjectWrapper::wrap(ctx->d()->engine, qt->d()->application);
}
-#ifndef QT_NO_IM
ReturnedValue QtObject::method_get_inputMethod(CallContext *ctx)
{
QObject *o = QQml_guiProvider()->inputMethod();
return QV4::QObjectWrapper::wrap(ctx->d()->engine, o);
}
-#endif
ReturnedValue QtObject::method_get_styleHints(CallContext *ctx)
{
@@ -1740,7 +1721,7 @@ void QV4::GlobalExtensions::init(Object *globalObject, QJSEngine::Extensions ext
Scope scope(v4);
if (extensions.testFlag(QJSEngine::TranslationExtension)) {
- #ifndef QT_NO_TRANSLATION
+ #if QT_CONFIG(translation)
globalObject->defineDefaultProperty(QStringLiteral("qsTranslate"), QV4::GlobalExtensions::method_qsTranslate);
globalObject->defineDefaultProperty(QStringLiteral("QT_TRANSLATE_NOOP"), QV4::GlobalExtensions::method_qsTranslateNoOp);
globalObject->defineDefaultProperty(QStringLiteral("qsTr"), QV4::GlobalExtensions::method_qsTr);
@@ -1767,7 +1748,7 @@ void QV4::GlobalExtensions::init(Object *globalObject, QJSEngine::Extensions ext
}
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
/*!
\qmlmethod string Qt::qsTranslate(string context, string sourceText, string disambiguation, int n)
@@ -2015,7 +1996,7 @@ ReturnedValue GlobalExtensions::method_qsTrIdNoOp(CallContext *ctx)
return QV4::Encode::undefined();
return ctx->args()[0].asReturnedValue();
}
-#endif // QT_NO_TRANSLATION
+#endif // translation
QV4::ReturnedValue GlobalExtensions::method_gc(CallContext *ctx)
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
index 7602a92582..fe43532647 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
@@ -82,13 +82,6 @@ struct ConsoleObject : Object {
struct QQmlBindingFunction : FunctionObject {
void init(const QV4::FunctionObject *originalFunction);
- void destroy() {
- delete bindingLocation;
- Object::destroy();
- }
- Pointer<FunctionObject> originalFunction;
- // Set when the binding is created later
- QQmlSourceLocation *bindingLocation;
};
}
@@ -135,9 +128,7 @@ struct QtObject : Object
static ReturnedValue method_get_platform(CallContext *ctx);
static ReturnedValue method_get_application(CallContext *ctx);
-#ifndef QT_NO_IM
static ReturnedValue method_get_inputMethod(CallContext *ctx);
-#endif
static ReturnedValue method_get_styleHints(CallContext *ctx);
static ReturnedValue method_callLater(CallContext *ctx);
@@ -166,10 +157,10 @@ struct ConsoleObject : Object
};
-struct GlobalExtensions {
+struct Q_QML_PRIVATE_EXPORT GlobalExtensions {
static void init(Object *globalObject, QJSEngine::Extensions extensions);
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
static ReturnedValue method_qsTranslate(CallContext *ctx);
static ReturnedValue method_qsTranslateNoOp(CallContext *ctx);
static ReturnedValue method_qsTr(CallContext *ctx);
@@ -187,13 +178,8 @@ struct GlobalExtensions {
struct QQmlBindingFunction : public QV4::FunctionObject
{
V4_OBJECT2(QQmlBindingFunction, FunctionObject)
- V4_NEEDS_DESTROY
-
- void initBindingLocation(); // from caller stack trace
-
- static void call(const Managed *that, Scope &scope, CallData *callData);
- static void markObjects(Heap::Base *that, ExecutionEngine *e);
+ QQmlSourceLocation currentLocation() const; // from caller stack trace
};
}
diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp
index b0599dd0a2..dadff819cf 100644
--- a/src/qml/qml/v8/qv8engine.cpp
+++ b/src/qml/qml/v8/qv8engine.cpp
@@ -52,7 +52,6 @@
#include <private/qqmlplatform_p.h>
#include <private/qjsvalue_p.h>
#include <private/qqmltypewrapper_p.h>
-#include <private/qqmlcontextwrapper_p.h>
#include <private/qqmlvaluetypewrapper_p.h>
#include <private/qqmllistwrapper_p.h>
#include <private/qv4scopedvalue_p.h>
@@ -160,7 +159,7 @@ QV8Engine::~QV8Engine()
qDeleteAll(m_extensionData);
m_extensionData.clear();
-#if !defined(QT_NO_XMLSTREAMREADER) && QT_CONFIG(qml_network)
+#if QT_CONFIG(xmlstreamreader) && QT_CONFIG(qml_network)
qt_rem_qmlxmlhttprequest(m_v4Engine, m_xmlHttpRequestData);
m_xmlHttpRequestData = 0;
#endif
@@ -195,7 +194,7 @@ void QV8Engine::initializeGlobal()
QQmlDateExtension::registerExtension(m_v4Engine);
QQmlNumberExtension::registerExtension(m_v4Engine);
-#if !defined(QT_NO_XMLSTREAMREADER) && QT_CONFIG(qml_network)
+#if QT_CONFIG(xmlstreamreader) && QT_CONFIG(qml_network)
qt_add_domexceptions(m_v4Engine);
m_xmlHttpRequestData = qt_add_qmlxmlhttprequest(m_v4Engine);
#endif
diff --git a/src/qml/types/qqmlconnections.cpp b/src/qml/types/qqmlconnections.cpp
index 1e9e0149dc..2aed4d9972 100644
--- a/src/qml/types/qqmlconnections.cpp
+++ b/src/qml/types/qqmlconnections.cpp
@@ -165,9 +165,9 @@ private:
void QQmlConnections::setTarget(QObject *obj)
{
Q_D(QQmlConnections);
- d->targetSet = true; // even if setting to 0, it is *set*
- if (d->target == obj)
+ if (d->targetSet && d->target == obj)
return;
+ d->targetSet = true; // even if setting to 0, it is *set*
foreach (QQmlBoundSignal *s, d->boundsignals) {
// It is possible that target is being changed due to one of our signal
// handlers -> use deleteLater().
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index c4fabbedcc..be10b270ae 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -213,6 +213,7 @@ QQmlDelegateModelPrivate::QQmlDelegateModelPrivate(QQmlContext *ctxt)
, m_reset(false)
, m_transaction(false)
, m_incubatorCleanupScheduled(false)
+ , m_waitingToFetchMore(false)
, m_cacheItems(0)
, m_items(0)
, m_persistedItems(0)
@@ -227,6 +228,15 @@ QQmlDelegateModelPrivate::~QQmlDelegateModelPrivate()
m_cacheMetaType->release();
}
+void QQmlDelegateModelPrivate::requestMoreIfNecessary()
+{
+ Q_Q(QQmlDelegateModel);
+ if (!m_waitingToFetchMore && m_adaptorModel.canFetchMore()) {
+ m_waitingToFetchMore = true;
+ QCoreApplication::postEvent(q, new QEvent(QEvent::UpdateRequest));
+ }
+}
+
void QQmlDelegateModelPrivate::init()
{
Q_Q(QQmlDelegateModel);
@@ -334,9 +344,7 @@ void QQmlDelegateModel::componentComplete()
&inserts);
d->itemsInserted(inserts);
d->emitChanges();
-
- if (d->m_adaptorModel.canFetchMore())
- QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));
+ d->requestMoreIfNecessary();
}
/*!
@@ -375,8 +383,7 @@ void QQmlDelegateModel::setModel(const QVariant &model)
if (d->m_complete) {
_q_itemsInserted(0, d->m_adaptorModel.count());
- if (d->m_adaptorModel.canFetchMore())
- QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));
+ d->requestMoreIfNecessary();
}
}
@@ -922,7 +929,6 @@ void QQmlDelegateModelPrivate::setInitialState(QQDMIncubationTask *incubationTas
QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, bool asynchronous)
{
- Q_Q(QQmlDelegateModel);
if (!m_delegate || index < 0 || index >= m_compositor.count(group)) {
qWarning() << "DelegateModel::item: index out range" << index << m_compositor.count(group);
return 0;
@@ -989,8 +995,8 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, bo
QQmlContextData::get(m_context));
}
- if (index == m_compositor.count(group) - 1 && m_adaptorModel.canFetchMore())
- QCoreApplication::postEvent(q, new QEvent(QEvent::UpdateRequest));
+ if (index == m_compositor.count(group) - 1)
+ requestMoreIfNecessary();
// Remove the temporary reference count.
cacheItem->scriptRef -= 1;
@@ -1110,6 +1116,7 @@ bool QQmlDelegateModel::event(QEvent *e)
{
Q_D(QQmlDelegateModel);
if (e->type() == QEvent::UpdateRequest) {
+ d->m_waitingToFetchMore = false;
d->m_adaptorModel.fetchMore();
} else if (e->type() == QEvent::User) {
d->m_incubatorCleanupScheduled = false;
diff --git a/src/qml/types/qqmldelegatemodel_p_p.h b/src/qml/types/qqmldelegatemodel_p_p.h
index f4ffdf38aa..4c2841b8ba 100644
--- a/src/qml/types/qqmldelegatemodel_p_p.h
+++ b/src/qml/types/qqmldelegatemodel_p_p.h
@@ -149,7 +149,6 @@ public:
int groups;
int index;
-
Q_SIGNALS:
void modelIndexChanged();
@@ -261,6 +260,7 @@ public:
void init();
void connectModel(QQmlAdaptorModel *model);
+ void requestMoreIfNecessary();
QObject *object(Compositor::Group group, int index, bool asynchronous);
QQmlDelegateModel::ReleaseFlags release(QObject *object);
QString stringValue(Compositor::Group group, int index, const QString &name);
@@ -294,7 +294,7 @@ public:
const QVector<Compositor::Remove> &removes, const QVector<Compositor::Insert> &inserts);
void itemsChanged(const QVector<Compositor::Change> &changes);
void emitChanges();
- void emitModelUpdated(const QQmlChangeSet &changeSet, bool reset);
+ void emitModelUpdated(const QQmlChangeSet &changeSet, bool reset) override;
bool insert(Compositor::insert_iterator &before, const QV4::Value &object, int groups);
@@ -329,6 +329,7 @@ public:
bool m_reset : 1;
bool m_transaction : 1;
bool m_incubatorCleanupScheduled : 1;
+ bool m_waitingToFetchMore : 1;
union {
struct {
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp
index 062f7a2a74..1a2e4c7f6f 100644
--- a/src/qml/types/qqmllistmodel.cpp
+++ b/src/qml/types/qqmllistmodel.cpp
@@ -45,10 +45,12 @@
#include <private/qqmlcustomparser_p.h>
#include <private/qqmlengine_p.h>
+#include <private/qqmlnotifier_p.h>
#include <private/qv4object_p.h>
#include <private/qv4dateobject_p.h>
#include <private/qv4objectiterator_p.h>
+#include <private/qv4alloca_p.h>
#include <qqmlcontext.h>
#include <qqmlinfo.h>
@@ -57,6 +59,7 @@
#include <QtCore/qstack.h>
#include <QXmlStreamReader>
#include <QtCore/qdatetime.h>
+#include <QScopedValueRollback>
QT_BEGIN_NAMESPACE
@@ -502,10 +505,10 @@ void ListModel::set(int elementIndex, QV4::Object *object)
break;
// Add the value now
- if (propertyValue->isString()) {
+ if (QV4::String *s = propertyValue->stringValue()) {
const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::String);
if (r.type == ListLayout::Role::String)
- e->setStringPropertyFast(r, propertyValue->stringValue()->toQString());
+ e->setStringPropertyFast(r, s->toQString());
} else if (propertyValue->isNumber()) {
const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Number);
if (r.type == ListLayout::Role::Number) {
@@ -1262,9 +1265,14 @@ ModelNodeMetaObject *ModelNodeMetaObject::get(QObject *obj)
void ModelNodeMetaObject::updateValues()
{
- if (!m_initialized)
+ const int roleCount = m_model->m_listModel->roleCount();
+ if (!m_initialized) {
+ int *changedRoles = reinterpret_cast<int *>(alloca(roleCount * sizeof(int)));
+ for (int i = 0; i < roleCount; ++i)
+ changedRoles[i] = i;
+ emitDirectNotifies(changedRoles, roleCount);
return;
- int roleCount = m_model->m_listModel->roleCount();
+ }
for (int i=0 ; i < roleCount ; ++i) {
const ListLayout::Role &role = m_model->m_listModel->getExistingRole(i);
QByteArray name = role.name.toUtf8();
@@ -1275,8 +1283,10 @@ void ModelNodeMetaObject::updateValues()
void ModelNodeMetaObject::updateValues(const QVector<int> &roles)
{
- if (!m_initialized)
+ if (!m_initialized) {
+ emitDirectNotifies(roles.constData(), roles.count());
return;
+ }
int roleCount = roles.count();
for (int i=0 ; i < roleCount ; ++i) {
int roleIndex = roles.at(i);
@@ -1303,6 +1313,22 @@ void ModelNodeMetaObject::propertyWritten(int index)
m_model->emitItemsChanged(m_elementIndex, 1, QVector<int>(1, roleIndex));
}
+// Does the emission of the notifiers when we haven't created the meta-object yet
+void ModelNodeMetaObject::emitDirectNotifies(const int *changedRoles, int roleCount)
+{
+ Q_ASSERT(!m_initialized);
+ QQmlData *ddata = QQmlData::get(object(), /*create*/false);
+ if (!ddata)
+ return;
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(qmlEngine(m_model));
+ if (!ep)
+ return;
+ for (int i = 0; i < roleCount; ++i) {
+ const int changedRole = changedRoles[i];
+ QQmlNotifier::notify(ddata, changedRole);
+ }
+}
+
namespace QV4 {
void ModelObject::put(Managed *m, String *name, const Value &value)
@@ -1329,6 +1355,18 @@ ReturnedValue ModelObject::get(const Managed *m, String *name, bool *hasProperty
return QObjectWrapper::get(m, name, hasProperty);
if (hasProperty)
*hasProperty = true;
+
+ if (QQmlEngine *qmlEngine = that->engine()->qmlEngine()) {
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(qmlEngine);
+ if (ep && ep->propertyCapture) {
+ QObjectPrivate *op = QObjectPrivate::get(that->object());
+ // Temporarily hide the dynamic meta-object, to prevent it from being created when the capture
+ // triggers a QObject::connectNotify() by calling obj->metaObject().
+ QScopedValueRollback<QDynamicMetaObjectData*> metaObjectBlocker(op->metaObject, 0);
+ ep->propertyCapture->captureProperty(that->object(), -1, role->index);
+ }
+ }
+
const int elementIndex = that->d()->m_elementIndex;
QVariant value = that->d()->m_model->data(elementIndex, role->index);
return that->engine()->fromVariant(value);
diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h
index ddf77e52c0..cdce78e542 100644
--- a/src/qml/types/qqmllistmodel_p_p.h
+++ b/src/qml/types/qqmllistmodel_p_p.h
@@ -153,6 +153,8 @@ private:
setValue(name, val);
}
+ void emitDirectNotifies(const int *changedRoles, int roleCount);
+
void initialize();
bool m_initialized;
};
diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp
index cdcc894da9..5f716da17a 100644
--- a/src/qml/types/qquickworkerscript.cpp
+++ b/src/qml/types/qquickworkerscript.cpp
@@ -42,7 +42,6 @@
#include "qqmllistmodelworkeragent_p.h"
#include <private/qqmlengine_p.h>
#include <private/qqmlexpression_p.h>
-#include <private/qqmlcontextwrapper_p.h>
#include <QtCore/qcoreevent.h>
#include <QtCore/qcoreapplication.h>
@@ -318,19 +317,8 @@ QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::getWorker(WorkerScript *scri
QV4::ExecutionEngine *v4 = QV8Engine::getV4(workerEngine);
QV4::Scope scope(v4);
-
- QV4::Scoped<QV4::QmlContextWrapper> w(scope, QV4::QmlContextWrapper::urlScope(v4, script->source));
- Q_ASSERT(!!w);
- w->setReadOnly(false);
-
- QV4::ScopedObject api(scope, v4->newObject());
- api->put(QV4::ScopedString(scope, v4->newString(QStringLiteral("sendMessage"))), QV4::ScopedValue(scope, workerEngine->sendFunction(script->id)));
-
- w->QV4::Object::put(QV4::ScopedString(scope, v4->newString(QStringLiteral("WorkerScript"))), api);
-
- w->setReadOnly(true);
-
- script->qmlContext.set(v4, v4->rootContext()->newQmlContext(w));
+ QV4::ScopedValue v(scope, workerEngine->sendFunction(script->id));
+ script->qmlContext.set(v4, QV4::QmlContext::createWorkerContext(v4->rootContext(), script->source, v));
}
return script->qmlContext.value();
diff --git a/src/qml/util/qqmladaptormodel_p.h b/src/qml/util/qqmladaptormodel_p.h
index 8e400f9146..78d964236e 100644
--- a/src/qml/util/qqmladaptormodel_p.h
+++ b/src/qml/util/qqmladaptormodel_p.h
@@ -143,7 +143,7 @@ public:
inline void fetchMore() { return accessors->fetchMore(*this); }
protected:
- void objectDestroyed(QObject *);
+ void objectDestroyed(QObject *) override;
};
class QQmlAdaptorModelProxyInterface
diff --git a/src/qmldebug/qqmlenginecontrolclient_p.h b/src/qmldebug/qqmlenginecontrolclient_p.h
index 6affc46ffc..9b4ea3acb1 100644
--- a/src/qmldebug/qqmlenginecontrolclient_p.h
+++ b/src/qmldebug/qqmlenginecontrolclient_p.h
@@ -78,7 +78,7 @@ protected:
QQmlEngineControlClient(QQmlEngineControlClientPrivate &dd);
private:
- void messageReceived(const QByteArray &);
+ void messageReceived(const QByteArray &) override;
};
QT_END_NAMESPACE
diff --git a/src/qmldebug/qqmlprofilerclient_p.h b/src/qmldebug/qqmlprofilerclient_p.h
index b4054ed0d9..a328cad26c 100644
--- a/src/qmldebug/qqmlprofilerclient_p.h
+++ b/src/qmldebug/qqmlprofilerclient_p.h
@@ -73,7 +73,7 @@ protected:
QQmlProfilerClient(QQmlProfilerClientPrivate &dd);
private:
- virtual void messageReceived(const QByteArray &message);
+ void messageReceived(const QByteArray &message) override;
virtual void traceStarted(qint64 time, int engineId);
virtual void traceFinished(qint64 time, int engineId);
diff --git a/src/qmltest/qmltest.pro b/src/qmltest/qmltest.pro
index 9852861334..d13e162ff4 100644
--- a/src/qmltest/qmltest.pro
+++ b/src/qmltest/qmltest.pro
@@ -2,7 +2,7 @@ TARGET = QtQuickTest
DEFINES += QT_NO_URL_CAST_FROM_STRING QT_NO_FOREACH
QT = core testlib-private
-QT_PRIVATE = quick qml-private gui core-private
+QT_PRIVATE = quick qml-private gui core-private gui-private
# Testlib is only a private dependency, which results in our users not
# inheriting testlibs's MODULE_CONFIG transitively. Make it explicit.
diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp
index 0e348eee11..70733da121 100644
--- a/src/qmltest/quicktest.cpp
+++ b/src/qmltest/quicktest.cpp
@@ -266,7 +266,7 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD
QuickTestResult::parseArgs(testArgC, testArgV.data());
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
QTranslator translator;
if (!translationFile.isEmpty()) {
if (translator.load(translationFile)) {
diff --git a/src/qmltest/quicktestevent.cpp b/src/qmltest/quicktestevent.cpp
index 7a2ec30a5a..4b1adf5a90 100644
--- a/src/qmltest/quicktestevent.cpp
+++ b/src/qmltest/quicktestevent.cpp
@@ -42,6 +42,7 @@
#include <QtQml/qqml.h>
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickwindow.h>
+#include <qpa/qwindowsysteminterface.h>
QT_BEGIN_NAMESPACE
@@ -183,6 +184,7 @@ namespace QtQuickTest
case MouseMove:
// with move event the button is NoButton, but 'buttons' holds the currently pressed buttons
me = QMouseEvent(QEvent::MouseMove, pos, window->mapToGlobal(pos), Qt::NoButton, button, stateKey);
+ me.setTimestamp(++lastMouseTimestamp);
break;
default:
QTEST_ASSERT(false);
@@ -196,7 +198,7 @@ namespace QtQuickTest
}
}
-#ifndef QT_NO_WHEELEVENT
+#if QT_CONFIG(wheelevent)
static void mouseWheel(QWindow* window, QObject* item, Qt::MouseButtons buttons,
Qt::KeyboardModifiers stateKey,
QPointF _pos, int xDelta, int yDelta, int delay = -1)
@@ -240,7 +242,7 @@ bool QuickTestEvent::mousePress
return true;
}
-#ifndef QT_NO_WHEELEVENT
+#if QT_CONFIG(wheelevent)
bool QuickTestEvent::mouseWheel(
QObject *item, qreal x, qreal y, int buttons,
int modifiers, int xDelta, int yDelta, int delay)
@@ -346,4 +348,96 @@ QWindow *QuickTestEvent::activeWindow()
return eventWindow();
}
+QQuickTouchEventSequence::QQuickTouchEventSequence(QuickTestEvent *testEvent, QObject *item)
+ : QObject(testEvent)
+ , m_sequence(QTest::touchEvent(testEvent->eventWindow(item), testEvent->touchDevice()))
+ , m_testEvent(testEvent)
+{
+}
+
+QObject *QQuickTouchEventSequence::press(int touchId, QObject *item, qreal x, qreal y)
+{
+ QWindow *view = m_testEvent->eventWindow(item);
+ if (view) {
+ QPointF pos(x, y);
+ QQuickItem *quickItem = qobject_cast<QQuickItem *>(item);
+ if (quickItem) {
+ pos = quickItem->mapToScene(pos);
+ }
+ m_sequence.press(touchId, pos.toPoint(), view);
+ }
+ return this;
+}
+
+QObject *QQuickTouchEventSequence::move(int touchId, QObject *item, qreal x, qreal y)
+{
+ QWindow *view = m_testEvent->eventWindow(item);
+ if (view) {
+ QPointF pos(x, y);
+ QQuickItem *quickItem = qobject_cast<QQuickItem *>(item);
+ if (quickItem) {
+ pos = quickItem->mapToScene(pos);
+ }
+ m_sequence.move(touchId, pos.toPoint(), view);
+ }
+ return this;
+}
+
+QObject *QQuickTouchEventSequence::release(int touchId, QObject *item, qreal x, qreal y)
+{
+ QWindow *view = m_testEvent->eventWindow(item);
+ if (view) {
+ QPointF pos(x, y);
+ QQuickItem *quickItem = qobject_cast<QQuickItem *>(item);
+ if (quickItem) {
+ pos = quickItem->mapToScene(pos);
+ }
+ m_sequence.release(touchId, pos.toPoint(), view);
+ }
+ return this;
+}
+
+QObject *QQuickTouchEventSequence::stationary(int touchId)
+{
+ m_sequence.stationary(touchId);
+ return this;
+}
+
+QObject *QQuickTouchEventSequence::commit()
+{
+ m_sequence.commit();
+ return this;
+}
+
+/*!
+ Return a simulated touchscreen, creating one if necessary
+
+ \internal
+*/
+
+QTouchDevice *QuickTestEvent::touchDevice()
+{
+ static QTouchDevice *device(nullptr);
+
+ if (!device) {
+ device = new QTouchDevice;
+ device->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(device);
+ }
+ return device;
+}
+
+/*!
+ Creates a new QQuickTouchEventSequence.
+
+ If valid, \a item determines the QWindow that touch events are sent to.
+ Test code should use touchEvent() from the QML TestCase type.
+
+ \internal
+*/
+QQuickTouchEventSequence *QuickTestEvent::touchEvent(QObject *item)
+{
+ return new QQuickTouchEventSequence(this, item);
+}
+
QT_END_NAMESPACE
diff --git a/src/qmltest/quicktestevent_p.h b/src/qmltest/quicktestevent_p.h
index 1adf8f3317..89065b8880 100644
--- a/src/qmltest/quicktestevent_p.h
+++ b/src/qmltest/quicktestevent_p.h
@@ -54,8 +54,28 @@
#include <QtQuickTest/quicktestglobal.h>
#include <QtCore/qobject.h>
#include <QtGui/QWindow>
+#include <QtTest/qtesttouch.h>
+
QT_BEGIN_NAMESPACE
+class QuickTestEvent;
+class Q_QUICK_TEST_EXPORT QQuickTouchEventSequence : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QQuickTouchEventSequence(QuickTestEvent *testEvent, QObject *item = nullptr);
+public slots:
+ QObject* press(int touchId, QObject *item, qreal x, qreal y);
+ QObject* move(int touchId, QObject *item, qreal x, qreal y);
+ QObject* release(int touchId, QObject *item, qreal x, qreal y);
+ QObject* stationary(int touchId);
+ QObject* commit();
+
+private:
+ QTest::QTouchEventSequence m_sequence;
+ QuickTestEvent * const m_testEvent;
+};
+
class Q_QUICK_TEST_EXPORT QuickTestEvent : public QObject
{
Q_OBJECT
@@ -86,14 +106,18 @@ public Q_SLOTS:
int modifiers, int delay);
bool mouseMove(QObject *item, qreal x, qreal y, int delay, int buttons);
-#ifndef QT_NO_WHEELEVENT
+#if QT_CONFIG(wheelevent)
bool mouseWheel(QObject *item, qreal x, qreal y, int buttons,
int modifiers, int xDelta, int yDelta, int delay);
#endif
+ QQuickTouchEventSequence *touchEvent(QObject *item = nullptr);
private:
QWindow *eventWindow(QObject *item = 0);
QWindow *activeWindow();
+ QTouchDevice *touchDevice();
+
+ friend class QQuickTouchEventSequence;
};
QT_END_NAMESPACE
diff --git a/src/quick/accessible/qaccessiblequickitem.cpp b/src/quick/accessible/qaccessiblequickitem.cpp
index 03236ce2f7..fbde5d354d 100644
--- a/src/quick/accessible/qaccessiblequickitem.cpp
+++ b/src/quick/accessible/qaccessiblequickitem.cpp
@@ -47,7 +47,7 @@
#include "QtQuick/qquicktextdocument.h"
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
: QAccessibleObject(item), m_doc(textDocument())
@@ -591,6 +591,6 @@ void QAccessibleQuickItem::setSelection(int /* selectionIndex */, int /* startOf
}
-#endif // QT_NO_ACCESSIBILITY
+#endif // accessibility
QT_END_NAMESPACE
diff --git a/src/quick/accessible/qaccessiblequickitem_p.h b/src/quick/accessible/qaccessiblequickitem_p.h
index 7445fd1400..577a105627 100644
--- a/src/quick/accessible/qaccessiblequickitem_p.h
+++ b/src/quick/accessible/qaccessiblequickitem_p.h
@@ -57,7 +57,7 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
class QTextDocument;
@@ -141,7 +141,7 @@ private:
QRect itemScreenRect(QQuickItem *item);
QList<QQuickItem *> accessibleUnignoredChildren(QQuickItem *item, bool paintOrder = false);
-#endif // QT_NO_ACCESSIBILITY
+#endif // accessibility
QT_END_NAMESPACE
diff --git a/src/quick/accessible/qaccessiblequickview.cpp b/src/quick/accessible/qaccessiblequickview.cpp
index edd39ed9db..222690e4f2 100644
--- a/src/quick/accessible/qaccessiblequickview.cpp
+++ b/src/quick/accessible/qaccessiblequickview.cpp
@@ -46,7 +46,7 @@
#include "qaccessiblequickitem_p.h"
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
QT_BEGIN_NAMESPACE
@@ -145,4 +145,4 @@ int QAccessibleQuickWindow::indexOfChild(const QAccessibleInterface *iface) cons
QT_END_NAMESPACE
-#endif // QT_NO_ACCESSIBILITY
+#endif // accessibility
diff --git a/src/quick/accessible/qaccessiblequickview_p.h b/src/quick/accessible/qaccessiblequickview_p.h
index e9c150ac22..7c103380cb 100644
--- a/src/quick/accessible/qaccessiblequickview_p.h
+++ b/src/quick/accessible/qaccessiblequickview_p.h
@@ -56,7 +56,7 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
class QAccessibleQuickWindow : public QAccessibleObject
{
@@ -80,7 +80,7 @@ private:
QList<QQuickItem *> rootItems() const;
};
-#endif // QT_NO_ACCESSIBILITY
+#endif // accessibility
QT_END_NAMESPACE
diff --git a/src/quick/accessible/qquickaccessiblefactory.cpp b/src/quick/accessible/qquickaccessiblefactory.cpp
index 69a74f2b3d..a1fa695e5a 100644
--- a/src/quick/accessible/qquickaccessiblefactory.cpp
+++ b/src/quick/accessible/qquickaccessiblefactory.cpp
@@ -44,7 +44,7 @@
#include <QtQuick/private/qquickitem_p.h>
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
QAccessibleInterface *qQuickAccessibleFactory(const QString &classname, QObject *object)
{
diff --git a/src/quick/accessible/qquickaccessiblefactory_p.h b/src/quick/accessible/qquickaccessiblefactory_p.h
index 6407b70223..ab8eb12ca4 100644
--- a/src/quick/accessible/qquickaccessiblefactory_p.h
+++ b/src/quick/accessible/qquickaccessiblefactory_p.h
@@ -54,7 +54,7 @@
#include <QtGui/qaccessible.h>
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
QAccessibleInterface *qQuickAccessibleFactory(const QString &classname, QObject *object);
diff --git a/src/quick/designer/qquickdesignercustomobjectdata.cpp b/src/quick/designer/qquickdesignercustomobjectdata.cpp
index e37254d165..ca9c1259fd 100644
--- a/src/quick/designer/qquickdesignercustomobjectdata.cpp
+++ b/src/quick/designer/qquickdesignercustomobjectdata.cpp
@@ -258,7 +258,7 @@ void QQuickDesignerCustomObjectData::setPropertyBinding(QQmlContext *context,
if (property.isProperty()) {
QQmlBinding *binding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core,
- expression, object(), context);
+ expression, object(), QQmlContextData::get(context));
binding->setTarget(property);
binding->setNotifyOnValueChanged(true);
diff --git a/src/quick/designer/qquickdesignersupport.cpp b/src/quick/designer/qquickdesignersupport.cpp
index 3ff5a3ce96..749ece8221 100644
--- a/src/quick/designer/qquickdesignersupport.cpp
+++ b/src/quick/designer/qquickdesignersupport.cpp
@@ -95,7 +95,7 @@ void QQuickDesignerSupport::refFromEffectItem(QQuickItem *referencedItem, bool h
texture->setRect(referencedItem->boundingRect());
texture->setSize(referencedItem->boundingRect().size().toSize());
texture->setRecursive(true);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
#ifndef QT_OPENGL_ES
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL)
texture->setFormat(GL_RGBA8);
diff --git a/src/quick/designer/qquickdesignerwindowmanager.cpp b/src/quick/designer/qquickdesignerwindowmanager.cpp
index 2d37db08e7..e2d7b98c33 100644
--- a/src/quick/designer/qquickdesignerwindowmanager.cpp
+++ b/src/quick/designer/qquickdesignerwindowmanager.cpp
@@ -39,7 +39,7 @@
#include "qquickdesignerwindowmanager_p.h"
#include "private/qquickwindow_p.h"
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <QtQuick/private/qsgdefaultrendercontext_p.h>
#endif
#include <QtQuick/QQuickWindow>
@@ -67,7 +67,7 @@ void QQuickDesignerWindowManager::windowDestroyed(QQuickWindow *)
void QQuickDesignerWindowManager::makeOpenGLContext(QQuickWindow *window)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (!m_openGlContext) {
m_openGlContext.reset(new QOpenGLContext());
m_openGlContext->setFormat(window->requestedFormat());
diff --git a/src/quick/designer/qquickdesignerwindowmanager_p.h b/src/quick/designer/qquickdesignerwindowmanager_p.h
index 209d703d0a..5322b6c421 100644
--- a/src/quick/designer/qquickdesignerwindowmanager_p.h
+++ b/src/quick/designer/qquickdesignerwindowmanager_p.h
@@ -57,7 +57,7 @@
#include <private/qtquickglobal_p.h>
#include <QtQuick/private/qsgcontext_p.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <QtGui/QOpenGLContext>
#endif
@@ -97,7 +97,7 @@ public:
static void createOpenGLContext(QQuickWindow *window);
private:
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QScopedPointer<QOpenGLContext> m_openGlContext;
#endif
QScopedPointer<QSGContext> m_sgContext;
diff --git a/src/quick/doc/src/concepts/visualcanvas/adaptations.qdoc b/src/quick/doc/src/concepts/visualcanvas/adaptations.qdoc
index 9ce26e1bb8..3fd92177f9 100644
--- a/src/quick/doc/src/concepts/visualcanvas/adaptations.qdoc
+++ b/src/quick/doc/src/concepts/visualcanvas/adaptations.qdoc
@@ -58,6 +58,8 @@ The supported backends are the following
\li Direct3D 12 - Requested by the string \c{"d3d12"} or the enum value QSGRendererInterface::Direct3D12.
+\li OpenVG - Requested by the string \c{"openvg"} or the enum value QSGRendererInterface::OpenVG.
+
\endlist
When in doubt which backend is in use, enable basic scenegraph information
@@ -92,6 +94,14 @@ running on Windows 10, both for Win32 and UWP applications. The details for
this adaptation are available here:
\l{qtquick-visualcanvas-adaptations-d3d12.html}{Direct3D 12 Adaptation}
+\section1 OpenVG
+
+The OpenVG adaptation is an alternative renderer for \l {Qt Quick} 2 that will
+renderer the contents of the scene graph using OpenVG commands to provide
+hardware-acclerated 2D vector and raster graphics. The details for this
+adaptation are available here:
+\l{qtquick-visualcanvas-scenegraph-openvg.html}{OpenVG Adaptation}
+
*/
@@ -387,3 +397,73 @@ between the frames). By default blocking present is disabled.
\endlist
*/
+
+/*!
+\title Qt Quick OpenVG Adaptation
+\page qtquick-visualcanvas-adaptations-openvg.html
+
+The OpenVG adaptation is an alternative renderer for \l {Qt Quick} 2 that will
+renderer the contents of the scene graph using OpenVG commands to provide
+hardware-acclerated 2D vector and raster graphics. Much like the Software
+adaptation, some features and optimizations are no longer available. Most
+Qt Quick 2 applications will run without modification though any attempts to
+use unsupported features will be ignored.
+
+\section2 EGL Requirement
+Unlike the defualt OpenGL Renderer, there is no built in support for acquiring
+an OpenVG context. This means that the renderer has the responsbility of
+requesting and managing the the current context. To do this EGL has to be used
+directly in the OpenVG renderer. This means that the OpenVG renderer is only
+usable with platform plugins that support creating QWindows with support for
+QSurfaceFormat::OpenVG. From this window, the renderer can get an EGLSurface
+which can be used with an EGLContext to render OpenVG content.
+
+\section2 Renderer
+The OpenVG Renderer works by using the OpenVG API to send commands and data to
+a Vector GPU which will render the scenegraph in an accelerated manner, offloading
+graphics rendering from the CPU. Many operations like the rendering of rectangles
+and fonts glyphs ideal for OpenVG because these can be represented as paths which
+are stroked and filled. Rendering scenegraph items that would typically involve
+textures are handled in the OpenVG renderer by using VGImage. In addition when
+rendering to offscreen surfaces (like when using Layers), the scene subtree is
+rendered to a VGImage which can be reused in the scene.
+
+\section2 Render Loop
+The OpenVG Renderer mirrors the behavior of the Basic render loop and will execute
+all OpenVG commands in a single thread.
+
+See the \l{qtquick-visualcanvas-scenegraph.html}{Scene Graph page} for more
+information on render loops
+
+\section2 Shader Effects
+ShaderEffect components in QtQuick 2 can not be rendered by the OpenVG adaptation.
+While it is possible to user ShaderEffectSource and QML Item Layers (which are both
+offscreen surfaces), it is not actually possible to apply shader effects to them
+via the ShaderEffect item. This is because OpenVG lacks an API for applying per
+vertex and per fragment shader operations. It may be possible however to take
+advantage of Image Filter operations in the OpenVG API to get similar effects to
+what is provided by ShaderEffects in custom items. To integrate custom OpenVG
+rendering, use QSGRenderNode in combination with QSGRendererInterface.
+
+\section2 Qt Graphical Effects Module
+\l {Qt Graphical Effects} uses ShaderEffect items to render effects. If you use
+graphical effects from this module, then you should not hide the source
+item so that the original item can still be rendered.
+
+\section2 Particle Effects
+It is not possible to render particle effects with the OpenVG adaptation. Whenever
+possible, remove particles completely from the scene. Otherwise they will still
+require some processing, even though they are not visible.
+
+\section2 Rendering Text
+The text rendering with the OpenVG adaptation is based on rendering the glpyh
+paths, and does not use the distance fields technique used by the OpenGL backend.
+
+\section2 Perspective Transforms
+The OpenVG API does not allow paths to be transformed with non-affine transforms,
+while it is possible with Qt Quick. This means that rendering components using
+paths like Rectangles and Text, when applying perspective transforms the OpenVG
+backend will first render to a VGImage before applying transformations. This uses
+more memory at runtime and is a slower path so avoid doing this if necessary.
+
+*/
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp
index dcad719ef0..78db92ba8a 100644
--- a/src/quick/items/context2d/qquickcanvasitem.cpp
+++ b/src/quick/items/context2d/qquickcanvasitem.cpp
@@ -802,7 +802,7 @@ QSGTextureProvider *QQuickCanvasItem::textureProvider() const
return QQuickItem::textureProvider();
Q_D(const QQuickCanvasItem);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QQuickWindow *w = window();
if (!w || !w->isSceneGraphInitialized()
|| QThread::currentThread() != QQuickWindowPrivate::get(w)->context->thread()) {
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index 2483a8eadb..bcaedd67b4 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -75,7 +75,7 @@
#include <private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <private/qsgdefaultrendercontext_p.h>
#endif
@@ -3997,7 +3997,7 @@ public:
~QQuickContext2DThreadCleanup()
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
context->makeCurrent(surface);
delete texture;
context->doneCurrent();
@@ -4038,7 +4038,7 @@ QQuickContext2D::~QQuickContext2D()
delete m_buffer;
if (m_renderTarget == QQuickCanvasItem::FramebufferObject) {
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_renderStrategy == QQuickCanvasItem::Immediate && m_glContext) {
Q_ASSERT(QThread::currentThread() == m_glContext->thread());
m_glContext->makeCurrent(m_surface.data());
@@ -4115,7 +4115,7 @@ void QQuickContext2D::init(QQuickCanvasItem *canvasItem, const QVariantMap &args
m_texture = new QQuickContext2DImageTexture;
break;
case QQuickCanvasItem::FramebufferObject:
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
m_texture = new QQuickContext2DFBOTexture;
#else
// It shouldn't be possible to use a FramebufferObject without OpenGL
@@ -4134,7 +4134,7 @@ void QQuickContext2D::init(QQuickCanvasItem *canvasItem, const QVariantMap &args
m_thread = QThread::currentThread();
QThread *renderThread = m_thread;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QQuickWindow *window = canvasItem->window();
QQuickWindowPrivate *wd = QQuickWindowPrivate::get(window);
QThread *sceneGraphThread = wd->context->thread();
@@ -4151,7 +4151,7 @@ void QQuickContext2D::init(QQuickCanvasItem *canvasItem, const QVariantMap &args
if (renderThread && renderThread != QThread::currentThread())
m_texture->moveToThread(renderThread);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_renderTarget == QQuickCanvasItem::FramebufferObject && renderThread != sceneGraphThread) {
auto openglRenderContext = static_cast<const QSGDefaultRenderContext *>(QQuickWindowPrivate::get(window)->context);
QOpenGLContext *cc = openglRenderContext->openglContext();
@@ -4212,7 +4212,7 @@ QImage QQuickContext2D::toImage(const QRectF& bounds)
flush();
m_texture->grabImage(bounds);
} else {
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QQuickWindow *window = m_canvas->window();
QOpenGLContext *ctx = window ? window->openglContext() : 0;
if (ctx && ctx->isValid()) {
diff --git a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp
index 8d659040b3..b985cb0ccc 100644
--- a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp
+++ b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp
@@ -43,7 +43,7 @@
#include <QtCore/QMutex>
#include <QtQuick/qsgtexture.h>
#include <QtGui/QPaintEngine>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <QtGui/QOpenGLContext>
# include <QtGui/private/qopenglpaintengine_p.h>
#endif
diff --git a/src/quick/items/context2d/qquickcontext2dtexture.cpp b/src/quick/items/context2d/qquickcontext2dtexture.cpp
index 4435c0c37b..38b5f054bf 100644
--- a/src/quick/items/context2d/qquickcontext2dtexture.cpp
+++ b/src/quick/items/context2d/qquickcontext2dtexture.cpp
@@ -44,7 +44,7 @@
#include <QtQuick/private/qsgtexture_p.h>
#include "qquickcontext2dcommandbuffer_p.h"
#include <QOpenGLPaintDevice>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
#include <QOpenGLFramebufferObject>
#include <QOpenGLFramebufferObjectFormat>
#include <QOpenGLFunctions>
@@ -53,7 +53,7 @@
#include <QtGui/QGuiApplication>
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
#define QT_MINIMUM_FBO_SIZE 64
static inline int qt_next_power_of_two(int v)
@@ -90,7 +90,7 @@ struct GLAcquireContext {
#endif
QQuickContext2DTexture::QQuickContext2DTexture()
: m_context(0)
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
, m_gl(0)
#endif
, m_surface(0)
@@ -254,7 +254,7 @@ void QQuickContext2DTexture::paint(QQuickContext2DCommandBuffer *ccb)
return;
}
QQuickContext2D::mutex.unlock();
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
GLAcquireContext currentContext(m_gl, m_surface);
#endif
if (!m_tiledCanvas) {
@@ -383,7 +383,7 @@ bool QQuickContext2DTexture::event(QEvent *e)
}
return QObject::event(e);
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
static inline QSize npotAdjustedSize(const QSize &size)
{
static bool checked = false;
diff --git a/src/quick/items/context2d/qquickcontext2dtexture_p.h b/src/quick/items/context2d/qquickcontext2dtexture_p.h
index 678e33826d..97135816a2 100644
--- a/src/quick/items/context2d/qquickcontext2dtexture_p.h
+++ b/src/quick/items/context2d/qquickcontext2dtexture_p.h
@@ -58,7 +58,7 @@ QT_REQUIRE_CONFIG(quick_canvas);
#include <QtQuick/qsgtexture.h>
#include "qquickcanvasitem_p.h"
#include "qquickcontext2d_p.h"
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <QOpenGLContext>
# include <QOpenGLFramebufferObject>
#endif
@@ -125,7 +125,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) override;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
void initializeOpenGL(QOpenGLContext *gl, QOffscreenSurface *s) {
m_gl = gl;
m_surface = s;
@@ -157,7 +157,7 @@ protected:
QList<QQuickContext2DTile*> m_tiles;
QQuickContext2D *m_context;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QOpenGLContext *m_gl;
#endif
QSurface *m_surface;
@@ -180,7 +180,7 @@ protected:
uint m_painting : 1;
uint m_onCustomThread : 1; // Not GUI and not SGRender
};
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
class QQuickContext2DFBOTexture : public QQuickContext2DTexture
{
Q_OBJECT
diff --git a/src/quick/items/context2d/qquickcontext2dtile.cpp b/src/quick/items/context2d/qquickcontext2dtile.cpp
index 95b6c9d961..d31fee7f91 100644
--- a/src/quick/items/context2d/qquickcontext2dtile.cpp
+++ b/src/quick/items/context2d/qquickcontext2dtile.cpp
@@ -38,7 +38,7 @@
****************************************************************************/
#include "qquickcontext2dtile_p.h"
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <QOpenGLFramebufferObject>
# include <QOpenGLFramebufferObjectFormat>
# include <QOpenGLPaintDevice>
@@ -97,7 +97,7 @@ QPainter* QQuickContext2DTile::createPainter(bool smooth, bool antialiasing)
return 0;
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QQuickContext2DFBOTile::QQuickContext2DFBOTile()
: QQuickContext2DTile()
, m_fbo(0)
diff --git a/src/quick/items/context2d/qquickcontext2dtile_p.h b/src/quick/items/context2d/qquickcontext2dtile_p.h
index 02238a882b..d5255edcfc 100644
--- a/src/quick/items/context2d/qquickcontext2dtile_p.h
+++ b/src/quick/items/context2d/qquickcontext2dtile_p.h
@@ -56,7 +56,7 @@
QT_REQUIRE_CONFIG(quick_canvas);
#include "qquickcontext2d_p.h"
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <QOpenGLFramebufferObject>
#endif
QT_BEGIN_NAMESPACE
@@ -87,7 +87,7 @@ protected:
QPainter m_painter;
};
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
class QQuickContext2DFBOTile : public QQuickContext2DTile
{
public:
diff --git a/src/quick/items/qquickaccessibleattached.cpp b/src/quick/items/qquickaccessibleattached.cpp
index 41c036c7a8..4e918802d1 100644
--- a/src/quick/items/qquickaccessibleattached.cpp
+++ b/src/quick/items/qquickaccessibleattached.cpp
@@ -39,7 +39,7 @@
#include "qquickaccessibleattached_p.h"
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
#include "private/qquickitem_p.h"
diff --git a/src/quick/items/qquickaccessibleattached_p.h b/src/quick/items/qquickaccessibleattached_p.h
index 7054d9d9c9..215a1e5db6 100644
--- a/src/quick/items/qquickaccessibleattached_p.h
+++ b/src/quick/items/qquickaccessibleattached_p.h
@@ -56,7 +56,7 @@
#include <QtCore/qobject.h>
#include <QtCore/qstring.h>
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
#include <QtGui/qaccessible.h>
#include <private/qtquickglobal_p.h>
@@ -265,6 +265,6 @@ QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickAccessibleAttached)
QML_DECLARE_TYPEINFO(QQuickAccessibleAttached, QML_HAS_ATTACHED_PROPERTIES)
-#endif // QT_NO_ACCESSIBILITY
+#endif // accessibility
#endif
diff --git a/src/quick/items/qquickanchors.cpp b/src/quick/items/qquickanchors.cpp
index a7a4a2b882..4162314cd3 100644
--- a/src/quick/items/qquickanchors.cpp
+++ b/src/quick/items/qquickanchors.cpp
@@ -617,74 +617,75 @@ void QQuickAnchorsPrivate::updateVerticalAnchors()
if (fill || centerIn || !isItemComplete())
return;
- if (updatingVerticalAnchor < 2) {
- ++updatingVerticalAnchor;
- if (usedAnchors & QQuickAnchors::TopAnchor) {
- //Handle stretching
- bool invalid = true;
+ if (Q_UNLIKELY(updatingVerticalAnchor > 1)) {
+ // ### Make this certain :)
+ qmlInfo(item) << QQuickAnchors::tr("Possible anchor loop detected on vertical anchor.");
+ return;
+ }
+
+ ++updatingVerticalAnchor;
+ if (usedAnchors & QQuickAnchors::TopAnchor) {
+ //Handle stretching
+ bool invalid = true;
+ qreal height = 0.0;
+ if (usedAnchors & QQuickAnchors::BottomAnchor) {
+ invalid = calcStretch(topAnchorItem, topAnchorLine,
+ bottomAnchorItem, bottomAnchorLine,
+ topMargin, -bottomMargin, QQuickAnchors::TopAnchor, height);
+ } else if (usedAnchors & QQuickAnchors::VCenterAnchor) {
+ invalid = calcStretch(topAnchorItem, topAnchorLine,
+ vCenterAnchorItem, vCenterAnchorLine,
+ topMargin, vCenterOffset, QQuickAnchors::TopAnchor, height);
+ height *= 2;
+ }
+ if (!invalid)
+ setItemHeight(height);
+
+ //Handle top
+ if (topAnchorItem == readParentItem(item)) {
+ setItemY(adjustedPosition(topAnchorItem, topAnchorLine) + topMargin);
+ } else if (readParentItem(topAnchorItem) == readParentItem(item)) {
+ setItemY(position(topAnchorItem, topAnchorLine) + topMargin);
+ }
+ } else if (usedAnchors & QQuickAnchors::BottomAnchor) {
+ //Handle stretching (top + bottom case is handled above)
+ if (usedAnchors & QQuickAnchors::VCenterAnchor) {
qreal height = 0.0;
- if (usedAnchors & QQuickAnchors::BottomAnchor) {
- invalid = calcStretch(topAnchorItem, topAnchorLine,
- bottomAnchorItem, bottomAnchorLine,
- topMargin, -bottomMargin, QQuickAnchors::TopAnchor, height);
- } else if (usedAnchors & QQuickAnchors::VCenterAnchor) {
- invalid = calcStretch(topAnchorItem, topAnchorLine,
- vCenterAnchorItem, vCenterAnchorLine,
- topMargin, vCenterOffset, QQuickAnchors::TopAnchor, height);
- height *= 2;
- }
+ bool invalid = calcStretch(vCenterAnchorItem, vCenterAnchorLine,
+ bottomAnchorItem, bottomAnchorLine,
+ vCenterOffset, -bottomMargin, QQuickAnchors::TopAnchor,
+ height);
if (!invalid)
- setItemHeight(height);
-
- //Handle top
- if (topAnchorItem == readParentItem(item)) {
- setItemY(adjustedPosition(topAnchorItem, topAnchorLine) + topMargin);
- } else if (readParentItem(topAnchorItem) == readParentItem(item)) {
- setItemY(position(topAnchorItem, topAnchorLine) + topMargin);
- }
- } else if (usedAnchors & QQuickAnchors::BottomAnchor) {
- //Handle stretching (top + bottom case is handled above)
- if (usedAnchors & QQuickAnchors::VCenterAnchor) {
- qreal height = 0.0;
- bool invalid = calcStretch(vCenterAnchorItem, vCenterAnchorLine,
- bottomAnchorItem, bottomAnchorLine,
- vCenterOffset, -bottomMargin, QQuickAnchors::TopAnchor,
- height);
- if (!invalid)
- setItemHeight(height*2);
- }
+ setItemHeight(height*2);
+ }
- //Handle bottom
- if (bottomAnchorItem == readParentItem(item)) {
- setItemY(adjustedPosition(bottomAnchorItem, bottomAnchorLine) - readHeight(item) - bottomMargin);
- } else if (readParentItem(bottomAnchorItem) == readParentItem(item)) {
- setItemY(position(bottomAnchorItem, bottomAnchorLine) - readHeight(item) - bottomMargin);
- }
- } else if (usedAnchors & QQuickAnchors::VCenterAnchor) {
- //(stetching handled above)
-
- //Handle vCenter
- if (vCenterAnchorItem == readParentItem(item)) {
- setItemY(adjustedPosition(vCenterAnchorItem, vCenterAnchorLine)
- - vcenter(item) + vCenterOffset);
- } else if (readParentItem(vCenterAnchorItem) == readParentItem(item)) {
- setItemY(position(vCenterAnchorItem, vCenterAnchorLine) - vcenter(item) + vCenterOffset);
- }
- } else if (usedAnchors & QQuickAnchors::BaselineAnchor) {
- //Handle baseline
- if (baselineAnchorItem == readParentItem(item)) {
- setItemY(adjustedPosition(baselineAnchorItem, baselineAnchorLine)
- - readBaselineOffset(item) + baselineOffset);
- } else if (readParentItem(baselineAnchorItem) == readParentItem(item)) {
- setItemY(position(baselineAnchorItem, baselineAnchorLine)
- - readBaselineOffset(item) + baselineOffset);
- }
+ //Handle bottom
+ if (bottomAnchorItem == readParentItem(item)) {
+ setItemY(adjustedPosition(bottomAnchorItem, bottomAnchorLine) - readHeight(item) - bottomMargin);
+ } else if (readParentItem(bottomAnchorItem) == readParentItem(item)) {
+ setItemY(position(bottomAnchorItem, bottomAnchorLine) - readHeight(item) - bottomMargin);
+ }
+ } else if (usedAnchors & QQuickAnchors::VCenterAnchor) {
+ //(stetching handled above)
+
+ //Handle vCenter
+ if (vCenterAnchorItem == readParentItem(item)) {
+ setItemY(adjustedPosition(vCenterAnchorItem, vCenterAnchorLine)
+ - vcenter(item) + vCenterOffset);
+ } else if (readParentItem(vCenterAnchorItem) == readParentItem(item)) {
+ setItemY(position(vCenterAnchorItem, vCenterAnchorLine) - vcenter(item) + vCenterOffset);
+ }
+ } else if (usedAnchors & QQuickAnchors::BaselineAnchor) {
+ //Handle baseline
+ if (baselineAnchorItem == readParentItem(item)) {
+ setItemY(adjustedPosition(baselineAnchorItem, baselineAnchorLine)
+ - readBaselineOffset(item) + baselineOffset);
+ } else if (readParentItem(baselineAnchorItem) == readParentItem(item)) {
+ setItemY(position(baselineAnchorItem, baselineAnchorLine)
+ - readBaselineOffset(item) + baselineOffset);
}
- --updatingVerticalAnchor;
- } else {
- // ### Make this certain :)
- qmlInfo(item) << QQuickAnchors::tr("Possible anchor loop detected on vertical anchor.");
}
+ --updatingVerticalAnchor;
}
static inline QQuickAnchors::Anchor reverseAnchorLine(QQuickAnchors::Anchor anchorLine)
diff --git a/src/quick/items/qquickanchors_p_p.h b/src/quick/items/qquickanchors_p_p.h
index 221b4ccb40..906f607302 100644
--- a/src/quick/items/qquickanchors_p_p.h
+++ b/src/quick/items/qquickanchors_p_p.h
@@ -113,12 +113,12 @@ public:
, inDestructor(false)
, baselineAnchorLine(QQuickAnchors::InvalidAnchor)
, centerAligned(true)
+ , usedAnchors(QQuickAnchors::InvalidAnchor)
+ , componentComplete(true)
, updatingFill(0)
, updatingCenterIn(0)
, updatingHorizontalAnchor(0)
, updatingVerticalAnchor(0)
- , componentComplete(true)
- , usedAnchors(QQuickAnchors::InvalidAnchor)
{
}
@@ -198,13 +198,16 @@ public:
uint inDestructor : 1;
QQuickAnchors::Anchor baselineAnchorLine : 7;
uint centerAligned : 1;
- uint updatingFill : 2;
- uint updatingCenterIn : 2;
- uint updatingHorizontalAnchor : 2;
- uint updatingVerticalAnchor : 2;
-
- uint componentComplete : 1;
uint usedAnchors : 7; // QQuickAnchors::Anchors
+ uint componentComplete : 1;
+
+ // Instead of using a mostly empty bit field, we can stretch the following fields up to be full
+ // bytes. The advantage is that incrementing/decrementing does not need any combining ands/ors.
+ qint8 updatingFill;
+ qint8 updatingCenterIn;
+ qint8 updatingHorizontalAnchor;
+ qint8 updatingVerticalAnchor;
+
static inline QQuickAnchorsPrivate *get(QQuickAnchors *o) {
return static_cast<QQuickAnchorsPrivate *>(QObjectPrivate::get(o));
diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp
index cbb052856e..7a112e840a 100644
--- a/src/quick/items/qquickdrag.cpp
+++ b/src/quick/items/qquickdrag.cpp
@@ -55,7 +55,7 @@
#include <QtGui/qstylehints.h>
#include <QtGui/qguiapplication.h>
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
QT_BEGIN_NAMESPACE
@@ -995,4 +995,4 @@ QQuickDragAttached *QQuickDrag::qmlAttachedProperties(QObject *obj)
QT_END_NAMESPACE
-#endif // QT_NO_DRAGANDDROP
+#endif // draganddrop
diff --git a/src/quick/items/qquickdrag_p.h b/src/quick/items/qquickdrag_p.h
index f9faca55e0..357f72b3e7 100644
--- a/src/quick/items/qquickdrag_p.h
+++ b/src/quick/items/qquickdrag_p.h
@@ -60,7 +60,7 @@
#include <QtCore/qstringlist.h>
#include <QtCore/qurl.h>
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
QT_BEGIN_NAMESPACE
@@ -77,7 +77,7 @@ class QQuickDragGrabber
QIntrusiveListNode node;
protected:
- void objectDestroyed(QQuickItem *) { delete this; }
+ void objectDestroyed(QQuickItem *) override { delete this; }
};
typedef QIntrusiveList<Item, &Item::node> ItemList;
@@ -318,6 +318,6 @@ QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickDrag)
QML_DECLARE_TYPEINFO(QQuickDrag, QML_HAS_ATTACHED_PROPERTIES)
-#endif // QT_NO_DRAGANDDROP
+#endif // draganddrop
#endif
diff --git a/src/quick/items/qquickdroparea.cpp b/src/quick/items/qquickdroparea.cpp
index 70d76c99a1..b314390915 100644
--- a/src/quick/items/qquickdroparea.cpp
+++ b/src/quick/items/qquickdroparea.cpp
@@ -43,7 +43,7 @@
#include <private/qv4arraybuffer_p.h>
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
QT_BEGIN_NAMESPACE
@@ -618,4 +618,4 @@ void QQuickDropEvent::accept(QQmlV4Function *args)
QT_END_NAMESPACE
-#endif // QT_NO_DRAGANDDROP
+#endif // draganddrop
diff --git a/src/quick/items/qquickdroparea_p.h b/src/quick/items/qquickdroparea_p.h
index ecd4da4367..0c4c072db7 100644
--- a/src/quick/items/qquickdroparea_p.h
+++ b/src/quick/items/qquickdroparea_p.h
@@ -55,7 +55,7 @@
#include <QtGui/qevent.h>
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
QT_BEGIN_NAMESPACE
@@ -190,6 +190,6 @@ QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickDropEvent)
QML_DECLARE_TYPE(QQuickDropArea)
-#endif // QT_NO_DRAGANDDROP
+#endif // draganddrop
#endif // QQUICKDROPAREA_P_H
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index 1fd9014408..f8038ed11f 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -634,7 +634,7 @@ void QQuickEventTouchPoint::reset(const QTouchEvent::TouchPoint &tp, ulong times
QQuickEventPoint::reset(tp.state(), tp.scenePos(), tp.id(), timestamp, tp.velocity());
m_rotation = tp.rotation();
m_pressure = tp.pressure();
- m_uniqueId = tp.uniqueId();
+// m_uniqueId = tp.uniqueId();
}
/*!
diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h
index 7753a447a6..e8bc307b1a 100644
--- a/src/quick/items/qquickevents_p_p.h
+++ b/src/quick/items/qquickevents_p_p.h
@@ -326,7 +326,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickEventTouchPoint : public QQuickEventPoint
Q_OBJECT
Q_PROPERTY(qreal rotation READ rotation)
Q_PROPERTY(qreal pressure READ pressure)
- Q_PROPERTY(QPointerUniqueId uniqueId READ uniqueId)
+// TODO rename to QPointingDeviceUniqueId
+// Q_PROPERTY(QPointerUniqueId uniqueId READ uniqueId)
public:
QQuickEventTouchPoint(QQuickPointerTouchEvent *parent);
@@ -335,12 +336,12 @@ public:
qreal rotation() const { return m_rotation; }
qreal pressure() const { return m_pressure; }
- QPointerUniqueId uniqueId() const { return m_uniqueId; }
+// QPointerUniqueId uniqueId() const { return m_uniqueId; }
private:
qreal m_rotation;
qreal m_pressure;
- QPointerUniqueId m_uniqueId;
+// QPointerUniqueId m_uniqueId;
Q_DISABLE_COPY(QQuickEventTouchPoint)
};
@@ -584,7 +585,7 @@ QML_DECLARE_TYPE(QQuickMouseEvent)
QML_DECLARE_TYPE(QQuickWheelEvent)
QML_DECLARE_TYPE(QQuickCloseEvent)
QML_DECLARE_TYPE(QQuickPointerDevice)
-QML_DECLARE_TYPE(QPointerUniqueId)
+//QML_DECLARE_TYPE(QPointerUniqueId)
QML_DECLARE_TYPE(QQuickPointerEvent)
#endif // QQUICKEVENTS_P_P_H
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index ef5ece625e..5561f8d976 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -1405,7 +1405,7 @@ void QQuickFlickable::mouseReleaseEvent(QMouseEvent *event)
}
}
-#ifndef QT_NO_WHEELEVENT
+#if QT_CONFIG(wheelevent)
void QQuickFlickable::wheelEvent(QWheelEvent *event)
{
Q_D(QQuickFlickable);
diff --git a/src/quick/items/qquickflickable_p.h b/src/quick/items/qquickflickable_p.h
index 2da4781f37..7384c7271a 100644
--- a/src/quick/items/qquickflickable_p.h
+++ b/src/quick/items/qquickflickable_p.h
@@ -249,7 +249,7 @@ protected:
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
-#ifndef QT_NO_WHEELEVENT
+#if QT_CONFIG(wheelevent)
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
#endif
void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
diff --git a/src/quick/items/qquickgraphicsinfo.cpp b/src/quick/items/qquickgraphicsinfo.cpp
index 761d0c3cad..f735f17a4d 100644
--- a/src/quick/items/qquickgraphicsinfo.cpp
+++ b/src/quick/items/qquickgraphicsinfo.cpp
@@ -257,7 +257,7 @@ void QQuickGraphicsInfo::updateInfo()
}
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_window && m_window->isSceneGraphInitialized()) {
QOpenGLContext *context = m_window->openglContext();
if (context)
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 3604dfde13..97a4e51def 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -74,7 +74,7 @@
#include <private/qv4qobjectwrapper_p.h>
#include <private/qdebug_p.h>
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
# include <QtGui/qcursor.h>
#endif
@@ -319,7 +319,7 @@ void QQuickItemKeyFilter::keyReleased(QKeyEvent *event, bool post)
if (m_next) m_next->keyReleased(event, post);
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
void QQuickItemKeyFilter::inputMethodEvent(QInputMethodEvent *event, bool post)
{
if (m_next)
@@ -333,7 +333,13 @@ QVariant QQuickItemKeyFilter::inputMethodQuery(Qt::InputMethodQuery query) const
if (m_next) return m_next->inputMethodQuery(query);
return QVariant();
}
-#endif // QT_NO_IM
+#endif // im
+
+void QQuickItemKeyFilter::shortcutOverride(QKeyEvent *event)
+{
+ if (m_next)
+ m_next->shortcutOverride(event);
+}
void QQuickItemKeyFilter::componentComplete()
{
@@ -937,6 +943,46 @@ bool QQuickKeysAttached::isConnected(const char *signalName) const
*/
/*!
+ \qmlsignal QtQuick::Keys::shortcutOverride(KeyEvent event)
+ \since 5.9
+
+ This signal is emitted when a key has been pressed that could potentially
+ be used as a shortcut. The \a event parameter provides information about
+ the event.
+
+ Set \c event.accepted to \c true if you wish to prevent the pressed key
+ from being used as a shortcut by other types, such as \l Shortcut. For
+ example:
+
+ \code
+ Item {
+ id: escapeItem
+ focus: true
+
+ // Ensure that we get escape key press events first.
+ Keys.onShortcutOverride: event.accepted = (event.key === Qt.Key_Escape)
+
+ Keys.onEscapePressed: {
+ console.log("escapeItem is handling escape");
+ event.accepted = true;
+ }
+ }
+
+ Shortcut {
+ sequence: "Escape"
+ onActivated: console.log("Shortcut is handling escape")
+ }
+ \endcode
+
+ As with the other signals, \c shortcutOverride will only be emitted for an
+ item if that item has \l {Item::}{activeFocus}.
+
+ The corresponding handler is \c onShortcutOverride.
+
+ \sa Shortcut
+*/
+
+/*!
\qmlsignal QtQuick::Keys::digit0Pressed(KeyEvent event)
This signal is emitted when the digit '0' has been pressed. The \a event
@@ -1300,7 +1346,7 @@ void QQuickKeysAttached::setPriority(Priority order)
void QQuickKeysAttached::componentComplete()
{
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
Q_D(QQuickKeysAttached);
if (d->item) {
for (QQuickItem *targetItem : qAsConst(d->targets)) {
@@ -1389,7 +1435,7 @@ void QQuickKeysAttached::keyReleased(QKeyEvent *event, bool post)
if (!event->isAccepted()) QQuickItemKeyFilter::keyReleased(event, post);
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
void QQuickKeysAttached::inputMethodEvent(QInputMethodEvent *event, bool post)
{
Q_D(QQuickKeysAttached);
@@ -1426,7 +1472,17 @@ QVariant QQuickKeysAttached::inputMethodQuery(Qt::InputMethodQuery query) const
}
return QQuickItemKeyFilter::inputMethodQuery(query);
}
-#endif // QT_NO_IM
+#endif // im
+
+void QQuickKeysAttached::shortcutOverride(QKeyEvent *event)
+{
+ Q_D(QQuickKeysAttached);
+ QQuickKeyEvent &keyEvent = d->theKeyEvent;
+ keyEvent.reset(*event);
+ emit shortcutOverride(&keyEvent);
+
+ event->setAccepted(keyEvent.isAccepted());
+}
QQuickKeysAttached *QQuickKeysAttached::qmlAttachedProperties(QObject *obj)
{
@@ -1677,7 +1733,7 @@ void QQuickEnterKeyAttached::setType(Qt::EnterKeyType type)
{
if (keyType != type) {
keyType = type;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (itemPrivate && itemPrivate->activeFocus)
QGuiApplication::inputMethod()->update(Qt::ImEnterKeyType);
#endif
@@ -2310,29 +2366,31 @@ QQuickItem::~QQuickItem()
while (!d->childItems.isEmpty())
d->childItems.constFirst()->setParentItem(0);
- const auto listeners = d->changeListeners; // NOTE: intentional copy (QTBUG-54732)
- for (const QQuickItemPrivate::ChangeListener &change : listeners) {
- QQuickAnchorsPrivate *anchor = change.listener->anchorPrivate();
- if (anchor)
- anchor->clearItem(this);
- }
+ if (!d->changeListeners.isEmpty()) {
+ const auto listeners = d->changeListeners; // NOTE: intentional copy (QTBUG-54732)
+ for (const QQuickItemPrivate::ChangeListener &change : listeners) {
+ QQuickAnchorsPrivate *anchor = change.listener->anchorPrivate();
+ if (anchor)
+ anchor->clearItem(this);
+ }
- /*
+ /*
update item anchors that depended on us unless they are our child (and will also be destroyed),
or our sibling, and our parent is also being destroyed.
*/
- for (const QQuickItemPrivate::ChangeListener &change : listeners) {
- QQuickAnchorsPrivate *anchor = change.listener->anchorPrivate();
- if (anchor && anchor->item && anchor->item->parentItem() && anchor->item->parentItem() != this)
- anchor->update();
- }
+ for (const QQuickItemPrivate::ChangeListener &change : listeners) {
+ QQuickAnchorsPrivate *anchor = change.listener->anchorPrivate();
+ if (anchor && anchor->item && anchor->item->parentItem() && anchor->item->parentItem() != this)
+ anchor->update();
+ }
- for (const QQuickItemPrivate::ChangeListener &change : listeners) {
- if (change.types & QQuickItemPrivate::Destroyed)
- change.listener->itemDestroyed(this);
- }
+ for (const QQuickItemPrivate::ChangeListener &change : listeners) {
+ if (change.types & QQuickItemPrivate::Destroyed)
+ change.listener->itemDestroyed(this);
+ }
- d->changeListeners.clear();
+ d->changeListeners.clear();
+ }
/*
Remove any references our transforms have to us, in case they try to
@@ -2366,7 +2424,7 @@ bool QQuickItemPrivate::canAcceptTabFocus(QQuickItem *item)
if (item == item->window()->contentItem())
return true;
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
if (QObject *acc = qmlAttachedPropertiesObject<QQuickAccessibleAttached>(item, false)) {
int role = acc->property("role").toInt();
if (role == QAccessible::EditableText
@@ -2603,7 +2661,7 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
if (parentItem) {
QQuickItem *itemAncestor = parentItem;
while (itemAncestor != 0) {
- if (itemAncestor == this) {
+ if (Q_UNLIKELY(itemAncestor == this)) {
qWarning() << "QQuickItem::setParentItem: Parent" << parentItem << "is already part of the subtree of" << this;
return;
}
@@ -2855,7 +2913,7 @@ void QQuickItemPrivate::addChild(QQuickItem *child)
childItems.append(child);
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
QQuickItemPrivate *childPrivate = QQuickItemPrivate::get(child);
// if the added child has a cursor and we do not currently have any children
@@ -2883,7 +2941,7 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
childItems.removeOne(child);
Q_ASSERT(!childItems.contains(child));
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
QQuickItemPrivate *childPrivate = QQuickItemPrivate::get(child);
// turn it off, if nothing else is using it
@@ -2958,7 +3016,7 @@ void QQuickItemPrivate::derefWindow()
if (polishScheduled)
c->itemsToPolish.removeOne(q);
c->removeGrabber(q);
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
if (c->cursorItem == q) {
c->cursorItem = 0;
window->unsetCursor();
@@ -3553,10 +3611,12 @@ QQuickAnchors *QQuickItemPrivate::anchors() const
void QQuickItemPrivate::siblingOrderChanged()
{
Q_Q(QQuickItem);
- const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
- for (const QQuickItemPrivate::ChangeListener &change : listeners) {
- if (change.types & QQuickItemPrivate::SiblingOrder) {
- change.listener->itemSiblingOrderChanged(q);
+ if (!changeListeners.isEmpty()) {
+ const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
+ for (const QQuickItemPrivate::ChangeListener &change : listeners) {
+ if (change.types & QQuickItemPrivate::SiblingOrder) {
+ change.listener->itemSiblingOrderChanged(q);
+ }
}
}
}
@@ -3658,20 +3718,18 @@ void QQuickItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeo
QQuickAnchorsPrivate::get(d->_anchors)->updateMe();
QQuickGeometryChange change;
- QRectF diff(newGeometry.x() - oldGeometry.x(),
- newGeometry.y() - oldGeometry.y(),
- newGeometry.width() - oldGeometry.width(),
- newGeometry.height() - oldGeometry.height());
- change.setXChange(diff.x() != 0);
- change.setYChange(diff.y() != 0);
- change.setWidthChange(diff.width() != 0);
- change.setHeightChange(diff.height() != 0);
-
- const auto listeners = d->changeListeners; // NOTE: intentional copy (QTBUG-54732)
- for (const QQuickItemPrivate::ChangeListener &listener : listeners) {
- if (listener.types & QQuickItemPrivate::Geometry) {
- if (change.matches(listener.gTypes))
- listener.listener->itemGeometryChanged(this, change, diff);
+ change.setXChange(newGeometry.x() != oldGeometry.x());
+ change.setYChange(newGeometry.y() != oldGeometry.y());
+ change.setWidthChange(newGeometry.width() != oldGeometry.width());
+ change.setHeightChange(newGeometry.height() != oldGeometry.height());
+
+ if (!d->changeListeners.isEmpty()) {
+ const auto listeners = d->changeListeners; // NOTE: intentional copy (QTBUG-54732)
+ for (const QQuickItemPrivate::ChangeListener &listener : listeners) {
+ if (listener.types & QQuickItemPrivate::Geometry) {
+ if (change.matches(listener.gTypes))
+ listener.listener->itemGeometryChanged(this, change, oldGeometry);
+ }
}
}
@@ -3844,7 +3902,7 @@ void QQuickItem::keyReleaseEvent(QKeyEvent *event)
event->ignore();
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
/*!
This event handler can be reimplemented in a subclass to receive input
method events for an item. The event information is provided by the
@@ -3854,7 +3912,7 @@ void QQuickItem::inputMethodEvent(QInputMethodEvent *event)
{
event->ignore();
}
-#endif // QT_NO_IM
+#endif // im
/*!
This event handler can be reimplemented in a subclass to receive focus-in
@@ -3863,7 +3921,7 @@ void QQuickItem::inputMethodEvent(QInputMethodEvent *event)
*/
void QQuickItem::focusInEvent(QFocusEvent * /*event*/)
{
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
if (QAccessible::isActive()) {
if (QObject *acc = QQuickAccessibleAttached::findAccessible(this)) {
QAccessibleEvent ev(acc, QAccessible::Focus);
@@ -3941,7 +3999,7 @@ void QQuickItem::touchUngrabEvent()
// XXX todo
}
-#ifndef QT_NO_WHEELEVENT
+#if QT_CONFIG(wheelevent)
/*!
This event handler can be reimplemented in a subclass to receive
wheel events for an item. The event information is provided by the
@@ -3999,7 +4057,7 @@ void QQuickItem::hoverLeaveEvent(QHoverEvent *event)
Q_UNUSED(event);
}
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
/*!
This event handler can be reimplemented in a subclass to receive drag-enter
events for an item. The event information is provided by the
@@ -4059,7 +4117,7 @@ void QQuickItem::dropEvent(QDropEvent *event)
{
Q_UNUSED(event);
}
-#endif // QT_NO_DRAGANDDROP
+#endif // draganddrop
/*!
Reimplement this method to filter the mouse events that are received by
@@ -4090,7 +4148,7 @@ void QQuickItem::windowDeactivateEvent()
}
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
/*!
This method is only relevant for input items.
@@ -4148,7 +4206,7 @@ QVariant QQuickItem::inputMethodQuery(Qt::InputMethodQuery query) const
return v;
}
-#endif // QT_NO_IM
+#endif // im
QQuickAnchorLine QQuickItemPrivate::left() const
{
@@ -4228,12 +4286,14 @@ void QQuickItem::setBaselineOffset(qreal offset)
d->baselineOffset = offset;
- const auto listeners = d->changeListeners; // NOTE: intentional copy (QTBUG-54732)
- for (const QQuickItemPrivate::ChangeListener &change : listeners) {
- if (change.types & QQuickItemPrivate::Geometry) {
- QQuickAnchorsPrivate *anchor = change.listener->anchorPrivate();
- if (anchor)
- anchor->updateVerticalAnchors();
+ if (!d->changeListeners.isEmpty()) {
+ const auto listeners = d->changeListeners; // NOTE: intentional copy (QTBUG-54732)
+ for (const QQuickItemPrivate::ChangeListener &change : listeners) {
+ if (change.types & QQuickItemPrivate::Geometry) {
+ QQuickAnchorsPrivate *anchor = change.listener->anchorPrivate();
+ if (anchor)
+ anchor->updateVerticalAnchors();
+ }
}
}
@@ -4991,7 +5051,7 @@ void QQuickItemPrivate::deliverKeyEvent(QKeyEvent *e)
}
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
void QQuickItemPrivate::deliverInputMethodEvent(QInputMethodEvent *e)
{
Q_Q(QQuickItem);
@@ -5017,7 +5077,14 @@ void QQuickItemPrivate::deliverInputMethodEvent(QInputMethodEvent *e)
extra->keyHandler->inputMethodEvent(e, true);
}
}
-#endif // QT_NO_IM
+#endif // im
+
+void QQuickItemPrivate::deliverShortcutOverrideEvent(QKeyEvent *event)
+{
+ if (extra.isAllocated() && extra->keyHandler) {
+ extra->keyHandler->shortcutOverride(event);
+ }
+}
void QQuickItemPrivate::handlePointerEvent(QQuickPointerEvent *event)
{
@@ -5049,7 +5116,7 @@ void QQuickItem::itemChange(ItemChange change, const ItemChangeData &value)
emit windowChanged(value.window);
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
/*!
Notify input method on updated query values if needed. \a queries indicates
the changed attributes.
@@ -5059,7 +5126,7 @@ void QQuickItem::updateInputMethod(Qt::InputMethodQueries queries)
if (hasActiveFocus())
QGuiApplication::inputMethod()->update(queries);
}
-#endif // QT_NO_IM
+#endif // im
/*! \internal */
// XXX todo - do we want/need this anymore?
@@ -5801,7 +5868,7 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
}
itemChange(QQuickItem::ItemVisibleHasChanged, effectiveVisible);
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
if (isAccessible) {
QAccessibleEvent ev(q, effectiveVisible ? QAccessible::ObjectShow : QAccessible::ObjectHide);
QAccessible::updateAccessibility(&ev);
@@ -5992,20 +6059,24 @@ void QQuickItemPrivate::itemChange(QQuickItem::ItemChange change, const QQuickIt
switch (change) {
case QQuickItem::ItemChildAddedChange: {
q->itemChange(change, data);
- const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
- for (const QQuickItemPrivate::ChangeListener &change : listeners) {
- if (change.types & QQuickItemPrivate::Children) {
- change.listener->itemChildAdded(q, data.item);
+ if (!changeListeners.isEmpty()) {
+ const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
+ for (const QQuickItemPrivate::ChangeListener &change : listeners) {
+ if (change.types & QQuickItemPrivate::Children) {
+ change.listener->itemChildAdded(q, data.item);
+ }
}
}
break;
}
case QQuickItem::ItemChildRemovedChange: {
q->itemChange(change, data);
- const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
- for (const QQuickItemPrivate::ChangeListener &change : listeners) {
- if (change.types & QQuickItemPrivate::Children) {
- change.listener->itemChildRemoved(q, data.item);
+ if (!changeListeners.isEmpty()) {
+ const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
+ for (const QQuickItemPrivate::ChangeListener &change : listeners) {
+ if (change.types & QQuickItemPrivate::Children) {
+ change.listener->itemChildRemoved(q, data.item);
+ }
}
}
break;
@@ -6015,30 +6086,36 @@ void QQuickItemPrivate::itemChange(QQuickItem::ItemChange change, const QQuickIt
break;
case QQuickItem::ItemVisibleHasChanged: {
q->itemChange(change, data);
- const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
- for (const QQuickItemPrivate::ChangeListener &change : listeners) {
- if (change.types & QQuickItemPrivate::Visibility) {
- change.listener->itemVisibilityChanged(q);
+ if (!changeListeners.isEmpty()) {
+ const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
+ for (const QQuickItemPrivate::ChangeListener &change : listeners) {
+ if (change.types & QQuickItemPrivate::Visibility) {
+ change.listener->itemVisibilityChanged(q);
+ }
}
}
break;
}
case QQuickItem::ItemParentHasChanged: {
q->itemChange(change, data);
- const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
- for (const QQuickItemPrivate::ChangeListener &change : listeners) {
- if (change.types & QQuickItemPrivate::Parent) {
- change.listener->itemParentChanged(q, data.item);
+ if (!changeListeners.isEmpty()) {
+ const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
+ for (const QQuickItemPrivate::ChangeListener &change : listeners) {
+ if (change.types & QQuickItemPrivate::Parent) {
+ change.listener->itemParentChanged(q, data.item);
+ }
}
}
break;
}
case QQuickItem::ItemOpacityHasChanged: {
q->itemChange(change, data);
- const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
- for (const QQuickItemPrivate::ChangeListener &change : listeners) {
- if (change.types & QQuickItemPrivate::Opacity) {
- change.listener->itemOpacityChanged(q);
+ if (!changeListeners.isEmpty()) {
+ const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
+ for (const QQuickItemPrivate::ChangeListener &change : listeners) {
+ if (change.types & QQuickItemPrivate::Opacity) {
+ change.listener->itemOpacityChanged(q);
+ }
}
}
break;
@@ -6048,10 +6125,12 @@ void QQuickItemPrivate::itemChange(QQuickItem::ItemChange change, const QQuickIt
break;
case QQuickItem::ItemRotationHasChanged: {
q->itemChange(change, data);
- const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
- for (const QQuickItemPrivate::ChangeListener &change : listeners) {
- if (change.types & QQuickItemPrivate::Rotation) {
- change.listener->itemRotationChanged(q);
+ if (!changeListeners.isEmpty()) {
+ const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
+ for (const QQuickItemPrivate::ChangeListener &change : listeners) {
+ if (change.types & QQuickItemPrivate::Rotation) {
+ change.listener->itemRotationChanged(q);
+ }
}
}
break;
@@ -6410,10 +6489,12 @@ void QQuickItem::resetWidth()
void QQuickItemPrivate::implicitWidthChanged()
{
Q_Q(QQuickItem);
- const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
- for (const QQuickItemPrivate::ChangeListener &change : listeners) {
- if (change.types & QQuickItemPrivate::ImplicitWidth) {
- change.listener->itemImplicitWidthChanged(q);
+ if (!changeListeners.isEmpty()) {
+ const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
+ for (const QQuickItemPrivate::ChangeListener &change : listeners) {
+ if (change.types & QQuickItemPrivate::ImplicitWidth) {
+ change.listener->itemImplicitWidthChanged(q);
+ }
}
}
emit q->implicitWidthChanged();
@@ -6574,10 +6655,12 @@ void QQuickItem::resetHeight()
void QQuickItemPrivate::implicitHeightChanged()
{
Q_Q(QQuickItem);
- const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
- for (const QQuickItemPrivate::ChangeListener &change : listeners) {
- if (change.types & QQuickItemPrivate::ImplicitHeight) {
- change.listener->itemImplicitHeightChanged(q);
+ if (!changeListeners.isEmpty()) {
+ const auto listeners = changeListeners; // NOTE: intentional copy (QTBUG-54732)
+ for (const QQuickItemPrivate::ChangeListener &change : listeners) {
+ if (change.types & QQuickItemPrivate::ImplicitHeight) {
+ change.listener->itemImplicitHeightChanged(q);
+ }
}
}
emit q->implicitHeightChanged();
@@ -7069,7 +7152,7 @@ void QQuickItem::setAcceptHoverEvents(bool enabled)
void QQuickItemPrivate::setHasCursorInChild(bool hasCursor)
{
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
Q_Q(QQuickItem);
// if we're asked to turn it off (because of an unsetcursor call, or a node
@@ -7118,7 +7201,7 @@ void QQuickItemPrivate::setHasHoverInChild(bool hasHover)
}
}
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
/*!
Returns the cursor shape for this item.
@@ -7604,7 +7687,7 @@ bool QQuickItem::event(QEvent *ev)
updatePolish();
break;
#endif
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
case QEvent::InputMethodQuery: {
QInputMethodQueryEvent *query = static_cast<QInputMethodQueryEvent *>(ev);
Qt::InputMethodQueries queries = query->queries();
@@ -7621,7 +7704,7 @@ bool QQuickItem::event(QEvent *ev)
case QEvent::InputMethod:
inputMethodEvent(static_cast<QInputMethodEvent *>(ev));
break;
-#endif // QT_NO_IM
+#endif // im
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
@@ -7647,6 +7730,9 @@ bool QQuickItem::event(QEvent *ev)
case QEvent::KeyRelease:
d->deliverKeyEvent(static_cast<QKeyEvent*>(ev));
break;
+ case QEvent::ShortcutOverride:
+ d->deliverShortcutOverrideEvent(static_cast<QKeyEvent*>(ev));
+ break;
case QEvent::FocusIn:
focusInEvent(static_cast<QFocusEvent*>(ev));
break;
@@ -7665,12 +7751,12 @@ bool QQuickItem::event(QEvent *ev)
case QEvent::MouseButtonDblClick:
mouseDoubleClickEvent(static_cast<QMouseEvent*>(ev));
break;
-#ifndef QT_NO_WHEELEVENT
+#if QT_CONFIG(wheelevent)
case QEvent::Wheel:
wheelEvent(static_cast<QWheelEvent*>(ev));
break;
#endif
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
case QEvent::DragEnter:
dragEnterEvent(static_cast<QDragEnterEvent*>(ev));
break;
@@ -7683,12 +7769,12 @@ bool QQuickItem::event(QEvent *ev)
case QEvent::Drop:
dropEvent(static_cast<QDropEvent*>(ev));
break;
-#endif // QT_NO_DRAGANDDROP
-#ifndef QT_NO_GESTURES
+#endif // draganddrop
+#if QT_CONFIG(gestures)
case QEvent::NativeGesture:
ev->ignore();
break;
-#endif // QT_NO_GESTURES
+#endif // gestures
default:
return QObject::event(ev);
}
@@ -8286,7 +8372,7 @@ QQuickItemPrivate::ExtraData::ExtraData()
}
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
QAccessible::Role QQuickItemPrivate::accessibleRole() const
{
Q_Q(const QQuickItem);
diff --git a/src/quick/items/qquickitem.h b/src/quick/items/qquickitem.h
index b1b1d627b1..c9494d91bd 100644
--- a/src/quick/items/qquickitem.h
+++ b/src/quick/items/qquickitem.h
@@ -153,7 +153,7 @@ class Q_QUICK_EXPORT QQuickItem : public QObject, public QQmlParserStatus
public:
enum Flag {
ItemClipsChildrenToShape = 0x01,
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
ItemAcceptsInputMethod = 0x02,
#endif
ItemIsFocusScope = 0x04,
@@ -292,7 +292,7 @@ public:
bool acceptHoverEvents() const;
void setAcceptHoverEvents(bool enabled);
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
QCursor cursor() const;
void setCursor(const QCursor &cursor);
void unsetCursor();
@@ -340,7 +340,7 @@ public:
Q_REVISION(1) Q_INVOKABLE QQuickItem *nextItemInFocusChain(bool forward = true);
Q_INVOKABLE QQuickItem *childAt(qreal x, qreal y) const;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
#endif
@@ -393,7 +393,7 @@ protected:
bool isComponentComplete() const;
virtual void itemChange(ItemChange, const ItemChangeData &);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
void updateInputMethod(Qt::InputMethodQueries queries = Qt::ImQueryInput);
#endif
@@ -406,7 +406,7 @@ protected:
virtual void keyPressEvent(QKeyEvent *event);
virtual void keyReleaseEvent(QKeyEvent *event);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
virtual void inputMethodEvent(QInputMethodEvent *);
#endif
virtual void focusInEvent(QFocusEvent *);
@@ -417,14 +417,14 @@ protected:
virtual void mouseDoubleClickEvent(QMouseEvent *event);
virtual void mouseUngrabEvent(); // XXX todo - params?
virtual void touchUngrabEvent();
-#ifndef QT_NO_WHEELEVENT
+#if QT_CONFIG(wheelevent)
virtual void wheelEvent(QWheelEvent *event);
#endif
virtual void touchEvent(QTouchEvent *event);
virtual void hoverEnterEvent(QHoverEvent *event);
virtual void hoverMoveEvent(QHoverEvent *event);
virtual void hoverLeaveEvent(QHoverEvent *event);
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
virtual void dragEnterEvent(QDragEnterEvent *);
virtual void dragMoveEvent(QDragMoveEvent *);
virtual void dragLeaveEvent(QDragLeaveEvent *);
diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h
index 49d0949fb8..e7ead7fa87 100644
--- a/src/quick/items/qquickitem_p.h
+++ b/src/quick/items/qquickitem_p.h
@@ -349,7 +349,7 @@ public:
#if QT_CONFIG(quick_shadereffect)
mutable QQuickItemLayer *layer;
#endif
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
QCursor cursor;
#endif
QPointF userTransformOriginPoint;
@@ -536,7 +536,7 @@ public:
virtual void implicitWidthChanged();
virtual void implicitHeightChanged();
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
virtual QAccessible::Role accessibleRole() const;
#endif
@@ -558,9 +558,10 @@ public:
virtual void transformChanged();
void deliverKeyEvent(QKeyEvent *);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
void deliverInputMethodEvent(QInputMethodEvent *);
#endif
+ void deliverShortcutOverrideEvent(QKeyEvent *);
virtual void handlePointerEvent(QQuickPointerEvent *);
@@ -622,10 +623,11 @@ public:
virtual void keyPressed(QKeyEvent *event, bool post);
virtual void keyReleased(QKeyEvent *event, bool post);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
virtual void inputMethodEvent(QInputMethodEvent *event, bool post);
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
#endif
+ virtual void shortcutOverride(QKeyEvent *event);
virtual void componentComplete();
bool m_processPost;
@@ -817,6 +819,7 @@ Q_SIGNALS:
void priorityChanged();
void pressed(QQuickKeyEvent *event);
void released(QQuickKeyEvent *event);
+ void shortcutOverride(QQuickKeyEvent *event);
void digit0Pressed(QQuickKeyEvent *event);
void digit1Pressed(QQuickKeyEvent *event);
void digit2Pressed(QQuickKeyEvent *event);
@@ -861,10 +864,11 @@ Q_SIGNALS:
private:
void keyPressed(QKeyEvent *event, bool post) Q_DECL_OVERRIDE;
void keyReleased(QKeyEvent *event, bool post) Q_DECL_OVERRIDE;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
void inputMethodEvent(QInputMethodEvent *, bool post) Q_DECL_OVERRIDE;
QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE;
#endif
+ void shortcutOverride(QKeyEvent *event) override;
static QByteArray keyToSignal(int key);
bool isConnected(const char *signalName) const;
diff --git a/src/quick/items/qquickitemchangelistener_p.h b/src/quick/items/qquickitemchangelistener_p.h
index 19ff73056b..83c69a9330 100644
--- a/src/quick/items/qquickitemchangelistener_p.h
+++ b/src/quick/items/qquickitemchangelistener_p.h
@@ -115,12 +115,14 @@ private:
int kind;
};
+#define QT_QUICK_NEW_GEOMETRY_CHANGED_HANDLING
+
class QQuickItemChangeListener
{
public:
virtual ~QQuickItemChangeListener() {}
- virtual void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF & /* diff */) {}
+ virtual void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF & /* oldGeometry */) {}
virtual void itemSiblingOrderChanged(QQuickItem *) {}
virtual void itemVisibilityChanged(QQuickItem *) {}
virtual void itemOpacityChanged(QQuickItem *) {}
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp
index 0705d9b504..dbe30fbc83 100644
--- a/src/quick/items/qquickitemsmodule.cpp
+++ b/src/quick/items/qquickitemsmodule.cpp
@@ -96,7 +96,7 @@
#include "qquickspritesequence_p.h"
#include "qquickanimatedsprite_p.h"
#endif
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include "qquickopenglinfo_p.h"
#endif
#include "qquickgraphicsinfo_p.h"
@@ -278,7 +278,7 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterType<QQuickPathInterpolator>("QtQuick",2,0,"PathInterpolator");
#endif
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
qmlRegisterType<QQuickDropArea>("QtQuick", 2, 0, "DropArea");
qmlRegisterType<QQuickDropEvent>();
qmlRegisterType<QQuickDropAreaDrag>();
@@ -289,7 +289,7 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterType<QQuickTouchPoint>("QtQuick", 2, 0, "TouchPoint");
qmlRegisterType<QQuickGrabGestureEvent>();
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
qmlRegisterUncreatableType<QQuickAccessibleAttached>("QtQuick", 2, 0, "Accessible",QQuickAccessibleAttached::tr("Accessible is only available via attached properties"));
#endif
@@ -325,7 +325,7 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterType<QQuickShaderEffect, 1>(uri, 2, 4, "ShaderEffect");
#endif
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
qmlRegisterUncreatableType<QQuickOpenGLInfo>(uri, 2, 4,"OpenGLInfo", QQuickOpenGLInfo::tr("OpenGLInfo is only available via attached properties"));
#endif
qmlRegisterType<QQuickPinchArea, 1>(uri, 2, 5,"PinchArea");
@@ -368,6 +368,8 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
#if QT_CONFIG(quick_shadereffect)
qmlRegisterType<QQuickBorderImageMesh>("QtQuick", 2, 8, "BorderImageMesh");
#endif
+
+ qmlRegisterType<QQuickMouseArea, 9>(uri, 2, 9, "MouseArea");
}
static void initResources()
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index d02ed07de0..7d98cc2693 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -1207,10 +1207,10 @@ void QQuickItemViewPrivate::showVisibleItems() const
}
void QQuickItemViewPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change,
- const QRectF &diff)
+ const QRectF &oldGeometry)
{
Q_Q(QQuickItemView);
- QQuickFlickablePrivate::itemGeometryChanged(item, change, diff);
+ QQuickFlickablePrivate::itemGeometryChanged(item, change, oldGeometry);
if (!q->isComponentComplete())
return;
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index 30625c7ea8..f89a995e76 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -131,7 +131,7 @@ public:
void updateAverage();
- void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) Q_DECL_OVERRIDE;
+ void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
void fixupPosition() Q_DECL_OVERRIDE;
void fixup(AxisData &data, qreal minExtent, qreal maxExtent) Q_DECL_OVERRIDE;
bool flick(QQuickItemViewPrivate::AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
@@ -1401,11 +1401,11 @@ bool QQuickListViewPrivate::hasStickyFooter() const
}
void QQuickListViewPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change,
- const QRectF &diff)
+ const QRectF &oldGeometry)
{
Q_Q(QQuickListView);
- QQuickItemViewPrivate::itemGeometryChanged(item, change, diff);
+ QQuickItemViewPrivate::itemGeometryChanged(item, change, oldGeometry);
if (!q->isComponentComplete())
return;
@@ -1426,24 +1426,22 @@ void QQuickListViewPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometry
// position all subsequent items
if (visibleItems.count() && item == visibleItems.constFirst()->item) {
FxListItemSG *listItem = static_cast<FxListItemSG*>(visibleItems.constFirst());
- const QRectF oldGeometry(item->x() - diff.x(),
- item->y() - diff.y(),
- item->width() - diff.width(),
- item->height() - diff.height());
if (listItem->transitionScheduledOrRunning())
return;
if (orient == QQuickListView::Vertical) {
const qreal oldItemEndPosition = verticalLayoutDirection == QQuickItemView::BottomToTop ? -oldGeometry.y() : oldGeometry.y() + oldGeometry.height();
+ const qreal heightDiff = item->height() - oldGeometry.height();
if (verticalLayoutDirection == QQuickListView::TopToBottom && oldItemEndPosition < q->contentY())
- listItem->setPosition(listItem->position() - diff.height(), true);
+ listItem->setPosition(listItem->position() - heightDiff, true);
else if (verticalLayoutDirection == QQuickListView::BottomToTop && oldItemEndPosition > q->contentY())
- listItem->setPosition(listItem->position() + diff.height(), true);
+ listItem->setPosition(listItem->position() + heightDiff, true);
} else {
const qreal oldItemEndPosition = q->effectiveLayoutDirection() == Qt::RightToLeft ? -oldGeometry.x() : oldGeometry.x() + oldGeometry.width();
+ const qreal widthDiff = item->width() - oldGeometry.width();
if (q->effectiveLayoutDirection() == Qt::LeftToRight && oldItemEndPosition < q->contentX())
- listItem->setPosition(listItem->position() - diff.width(), true);
+ listItem->setPosition(listItem->position() - widthDiff, true);
else if (q->effectiveLayoutDirection() == Qt::RightToLeft && oldItemEndPosition > q->contentX())
- listItem->setPosition(listItem->position() + diff.width(), true);
+ listItem->setPosition(listItem->position() + widthDiff, true);
}
}
forceLayoutPolish();
diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp
index 9aea9c50df..eeec562e3c 100644
--- a/src/quick/items/qquickloader.cpp
+++ b/src/quick/items/qquickloader.cpp
@@ -65,12 +65,12 @@ QQuickLoaderPrivate::~QQuickLoaderPrivate()
disposeInitialPropertyValues();
}
-void QQuickLoaderPrivate::itemGeometryChanged(QQuickItem *resizeItem, QQuickGeometryChange change
- , const QRectF &diff)
+void QQuickLoaderPrivate::itemGeometryChanged(QQuickItem *resizeItem, QQuickGeometryChange change,
+ const QRectF &oldGeometry)
{
if (resizeItem == item)
_q_updateSize(false);
- QQuickItemChangeListener::itemGeometryChanged(resizeItem, change, diff);
+ QQuickItemChangeListener::itemGeometryChanged(resizeItem, change, oldGeometry);
}
void QQuickLoaderPrivate::itemImplicitWidthChanged(QQuickItem *)
diff --git a/src/quick/items/qquickloader_p_p.h b/src/quick/items/qquickloader_p_p.h
index a0a9ca0601..9b6267e011 100644
--- a/src/quick/items/qquickloader_p_p.h
+++ b/src/quick/items/qquickloader_p_p.h
@@ -84,7 +84,7 @@ public:
QQuickLoaderPrivate();
~QQuickLoaderPrivate();
- void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) Q_DECL_OVERRIDE;
+ void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
void itemImplicitWidthChanged(QQuickItem *) Q_DECL_OVERRIDE;
void itemImplicitHeightChanged(QQuickItem *) Q_DECL_OVERRIDE;
void clear();
diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp
index 6bd83dd808..79c957832a 100644
--- a/src/quick/items/qquickmousearea.cpp
+++ b/src/quick/items/qquickmousearea.cpp
@@ -60,11 +60,12 @@ Q_DECLARE_LOGGING_CATEGORY(DBG_HOVER_TRACE)
QQuickMouseAreaPrivate::QQuickMouseAreaPrivate()
: enabled(true), scrollGestureEnabled(true), hovered(false), longPress(false),
moved(false), stealMouse(false), doubleClick(false), preventStealing(false),
- propagateComposedEvents(false), overThreshold(false), pressed(0)
-#ifndef QT_NO_DRAGANDDROP
+ propagateComposedEvents(false), overThreshold(false), pressed(0),
+ pressAndHoldInterval(-1)
+#if QT_CONFIG(draganddrop)
, drag(0)
#endif
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
, cursor(0)
#endif
{
@@ -72,10 +73,10 @@ QQuickMouseAreaPrivate::QQuickMouseAreaPrivate()
QQuickMouseAreaPrivate::~QQuickMouseAreaPrivate()
{
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
delete drag;
#endif
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
delete cursor;
#endif
}
@@ -435,7 +436,7 @@ QQuickMouseArea::QQuickMouseArea(QQuickItem *parent)
{
Q_D(QQuickMouseArea);
d->init();
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
// Explcitly call setCursor on QQuickItem since
// it internally keeps a boolean hasCursor that doesn't
// get set to true unless you call setCursor
@@ -679,13 +680,13 @@ void QQuickMouseArea::mousePressEvent(QMouseEvent *event)
} else {
d->longPress = false;
d->saveEvent(event);
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
if (d->drag)
d->drag->setActive(false);
#endif
setHovered(true);
d->startScene = event->windowPos();
- d->pressAndHoldTimer.start(QGuiApplication::styleHints()->mousePressAndHoldInterval(), this);
+ d->pressAndHoldTimer.start(pressAndHoldInterval(), this);
setKeepMouseGrab(d->stealMouse);
event->setAccepted(setPressed(event->button(), true, event->source()));
}
@@ -705,7 +706,7 @@ void QQuickMouseArea::mouseMoveEvent(QMouseEvent *event)
// ### can GV handle this for us?
setHovered(contains(d->lastPos));
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
if (d->drag && d->drag->target()) {
if (!d->moved) {
d->targetStartPos = d->drag->target()->parentItem()
@@ -788,7 +789,7 @@ void QQuickMouseArea::mouseReleaseEvent(QMouseEvent *event)
setPressed(event->button(), false, event->source());
if (!d->pressed) {
// no other buttons are pressed
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
if (d->drag)
d->drag->setActive(false);
#endif
@@ -866,7 +867,7 @@ void QQuickMouseArea::hoverLeaveEvent(QHoverEvent *event)
setHovered(false);
}
-#ifndef QT_NO_WHEELEVENT
+#if QT_CONFIG(wheelevent)
void QQuickMouseArea::wheelEvent(QWheelEvent *event)
{
Q_D(QQuickMouseArea);
@@ -897,7 +898,7 @@ void QQuickMouseArea::ungrabMouse()
d->overThreshold = false;
setKeepMouseGrab(false);
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
if (d->drag)
d->drag->setActive(false);
#endif
@@ -980,7 +981,7 @@ bool QQuickMouseArea::childMouseEventFilter(QQuickItem *i, QEvent *e)
Q_D(QQuickMouseArea);
if (!d->pressed &&
(!d->enabled || !isVisible()
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
|| !d->drag || !d->drag->filterChildren()
#endif
)
@@ -1003,7 +1004,7 @@ void QQuickMouseArea::timerEvent(QTimerEvent *event)
Q_D(QQuickMouseArea);
if (event->timerId() == d->pressAndHoldTimer.timerId()) {
d->pressAndHoldTimer.stop();
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
bool dragged = d->drag && d->drag->active();
#else
bool dragged = false;
@@ -1179,7 +1180,7 @@ bool QQuickMouseArea::setPressed(Qt::MouseButton button, bool p, Qt::MouseEventS
{
Q_D(QQuickMouseArea);
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
bool dragged = d->drag && d->drag->active();
#else
bool dragged = false;
@@ -1276,7 +1277,7 @@ bool QQuickMouseArea::setPressed(Qt::MouseButton button, bool p, Qt::MouseEventS
\sa Qt::CursorShape
*/
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
Qt::CursorShape QQuickMouseArea::cursorShape() const
{
return cursor().shape();
@@ -1294,6 +1295,48 @@ void QQuickMouseArea::setCursorShape(Qt::CursorShape shape)
#endif
+
+/*!
+ \qmlproperty int QtQuick::MouseArea::pressAndHoldInterval
+ \since 5.9
+
+ This property overrides the elapsed time in milliseconds before
+ \c pressAndHold is emitted.
+
+ If not explicitly set -- or after reset -- the value follows
+ \c QStyleHints::mousePressAndHoldInterval.
+
+ Typically it's sufficient to set this property globally using the
+ application style hint. This property should be used when varying intervals
+ are needed for certain MouseAreas.
+
+ \sa pressAndHold
+*/
+int QQuickMouseArea::pressAndHoldInterval() const
+{
+ Q_D(const QQuickMouseArea);
+ return d->pressAndHoldInterval > -1 ?
+ d->pressAndHoldInterval : QGuiApplication::styleHints()->mousePressAndHoldInterval();
+}
+
+void QQuickMouseArea::setPressAndHoldInterval(int interval)
+{
+ Q_D(QQuickMouseArea);
+ if (interval != d->pressAndHoldInterval) {
+ d->pressAndHoldInterval = interval;
+ emit pressAndHoldIntervalChanged();
+ }
+}
+
+void QQuickMouseArea::resetPressAndHoldInterval()
+{
+ Q_D(QQuickMouseArea);
+ if (d->pressAndHoldInterval > -1) {
+ d->pressAndHoldInterval = -1;
+ emit pressAndHoldIntervalChanged();
+ }
+}
+
/*!
\qmlpropertygroup QtQuick::MouseArea::drag
\qmlproperty Item QtQuick::MouseArea::drag.target
@@ -1343,7 +1386,7 @@ void QQuickMouseArea::setCursorShape(Qt::CursorShape shape)
*/
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
QQuickDrag *QQuickMouseArea::drag()
{
Q_D(QQuickMouseArea);
diff --git a/src/quick/items/qquickmousearea_p.h b/src/quick/items/qquickmousearea_p.h
index 5cd86541d4..ee166a2082 100644
--- a/src/quick/items/qquickmousearea_p.h
+++ b/src/quick/items/qquickmousearea_p.h
@@ -75,15 +75,16 @@ class Q_QUICK_PRIVATE_EXPORT QQuickMouseArea : public QQuickItem
Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedButtonsChanged)
Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
Q_PROPERTY(bool hoverEnabled READ hoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged)
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
Q_PROPERTY(QQuickDrag *drag READ drag CONSTANT) //### add flicking to QQuickDrag or add a QQuickFlick ???
#endif
Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged)
Q_PROPERTY(bool propagateComposedEvents READ propagateComposedEvents WRITE setPropagateComposedEvents NOTIFY propagateComposedEventsChanged)
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
Q_PROPERTY(Qt::CursorShape cursorShape READ cursorShape WRITE setCursorShape RESET unsetCursor NOTIFY cursorShapeChanged)
#endif
Q_PROPERTY(bool containsPress READ containsPress NOTIFY containsPressChanged REVISION 1)
+ Q_PROPERTY(int pressAndHoldInterval READ pressAndHoldInterval WRITE setPressAndHoldInterval NOTIFY pressAndHoldIntervalChanged RESET resetPressAndHoldInterval REVISION 9)
public:
QQuickMouseArea(QQuickItem *parent=0);
@@ -110,7 +111,7 @@ public:
bool hoverEnabled() const;
void setHoverEnabled(bool h);
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
QQuickDrag *drag();
#endif
@@ -120,11 +121,15 @@ public:
bool propagateComposedEvents() const;
void setPropagateComposedEvents(bool propagate);
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
Qt::CursorShape cursorShape() const;
void setCursorShape(Qt::CursorShape shape);
#endif
+ int pressAndHoldInterval() const;
+ void setPressAndHoldInterval(int interval);
+ void resetPressAndHoldInterval();
+
Q_SIGNALS:
void hoveredChanged();
void pressedChanged();
@@ -133,7 +138,7 @@ Q_SIGNALS:
void pressedButtonsChanged();
void acceptedButtonsChanged();
void hoverEnabledChanged();
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
void cursorShapeChanged();
#endif
void positionChanged(QQuickMouseEvent *mouse);
@@ -152,6 +157,7 @@ Q_SIGNALS:
void exited();
void canceled();
Q_REVISION(1) void containsPressChanged();
+ Q_REVISION(9) void pressAndHoldIntervalChanged();
protected:
void setHovered(bool);
@@ -166,7 +172,7 @@ protected:
void hoverEnterEvent(QHoverEvent *event) Q_DECL_OVERRIDE;
void hoverMoveEvent(QHoverEvent *event) Q_DECL_OVERRIDE;
void hoverLeaveEvent(QHoverEvent *event) Q_DECL_OVERRIDE;
-#ifndef QT_NO_WHEELEVENT
+#if QT_CONFIG(wheelevent)
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
#endif
bool childMouseEventFilter(QQuickItem *i, QEvent *e) Q_DECL_OVERRIDE;
diff --git a/src/quick/items/qquickmousearea_p_p.h b/src/quick/items/qquickmousearea_p_p.h
index b59e02910f..2fa5f7cd44 100644
--- a/src/quick/items/qquickmousearea_p_p.h
+++ b/src/quick/items/qquickmousearea_p_p.h
@@ -95,7 +95,8 @@ public:
bool propagateComposedEvents : 1;
bool overThreshold : 1;
Qt::MouseButtons pressed;
-#ifndef QT_NO_DRAGANDDROP
+ int pressAndHoldInterval;
+#if QT_CONFIG(draganddrop)
QQuickDrag *drag;
#endif
QPointF startScene;
@@ -106,7 +107,7 @@ public:
Qt::MouseButtons lastButtons;
Qt::KeyboardModifiers lastModifiers;
QBasicTimer pressAndHoldTimer;
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
QCursor *cursor;
#endif
QQuickMouseEvent quickMouseEvent;
diff --git a/src/quick/items/qquickopenglshadereffectnode.cpp b/src/quick/items/qquickopenglshadereffectnode.cpp
index e01ecc59e3..2d2cffbeed 100644
--- a/src/quick/items/qquickopenglshadereffectnode.cpp
+++ b/src/quick/items/qquickopenglshadereffectnode.cpp
@@ -260,11 +260,11 @@ void QQuickCustomMaterialShader::compile()
m_log.clear();
m_compiled = true;
- if (!program()->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShader())) {
+ if (!program()->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, vertexShader())) {
m_log += QLatin1String("*** Vertex shader ***\n") + program()->log();
m_compiled = false;
}
- if (!program()->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShader())) {
+ if (!program()->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShader())) {
m_log += QLatin1String("*** Fragment shader ***\n") + program()->log();
m_compiled = false;
}
diff --git a/src/quick/items/qquickpainteditem.cpp b/src/quick/items/qquickpainteditem.cpp
index e565fceab8..3911bb0f28 100644
--- a/src/quick/items/qquickpainteditem.cpp
+++ b/src/quick/items/qquickpainteditem.cpp
@@ -662,7 +662,7 @@ QSGTextureProvider *QQuickPaintedItem::textureProvider() const
return QQuickItem::textureProvider();
Q_D(const QQuickPaintedItem);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QQuickWindow *w = window();
if (!w || !w->openglContext() || QThread::currentThread() != w->openglContext()->thread()) {
qWarning("QQuickPaintedItem::textureProvider: can only be queried on the rendering thread of an exposed window");
diff --git a/src/quick/items/qquickpincharea.cpp b/src/quick/items/qquickpincharea.cpp
index fd8971c845..6295aa1932 100644
--- a/src/quick/items/qquickpincharea.cpp
+++ b/src/quick/items/qquickpincharea.cpp
@@ -682,7 +682,7 @@ bool QQuickPinchArea::event(QEvent *event)
return QQuickItem::event(event);
switch (event->type()) {
-#ifndef QT_NO_GESTURES
+#if QT_CONFIG(gestures)
case QEvent::NativeGesture: {
QNativeGestureEvent *gesture = static_cast<QNativeGestureEvent *>(event);
switch (gesture->gestureType()) {
@@ -775,7 +775,7 @@ bool QQuickPinchArea::event(QEvent *event)
return QQuickItem::event(event);
}
} break;
-#endif // QT_NO_GESTURES
+#endif // gestures
case QEvent::Wheel:
event->ignore();
return false;
diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp
index 74aa2da9e0..13e13890b7 100644
--- a/src/quick/items/qquickrendercontrol.cpp
+++ b/src/quick/items/qquickrendercontrol.cpp
@@ -44,7 +44,7 @@
#include <QtCore/QTime>
#include <QtQuick/private/qquickanimatorcontroller_p.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <QtGui/QOpenGLContext>
# include <QtQuick/private/qsgdefaultrendercontext_p.h>
#if QT_CONFIG(quick_shadereffect)
@@ -62,7 +62,7 @@
#include <QtCore/private/qobject_p.h>
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha);
#endif
/*!
@@ -227,7 +227,7 @@ void QQuickRenderControl::initialize(QOpenGLContext *gl)
{
Q_D(QQuickRenderControl);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (!d->window) {
qWarning("QQuickRenderControl::initialize called with no associated window");
return;
@@ -379,7 +379,7 @@ QImage QQuickRenderControl::grab()
QImage grabContent;
if (d->window->rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL) {
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
render();
grabContent = qt_gl_read_framebuffer(d->window->size() * d->window->effectiveDevicePixelRatio(), false, false);
#endif
diff --git a/src/quick/items/qquickshadereffect.cpp b/src/quick/items/qquickshadereffect.cpp
index 5670696ce2..7926607e33 100644
--- a/src/quick/items/qquickshadereffect.cpp
+++ b/src/quick/items/qquickshadereffect.cpp
@@ -40,7 +40,7 @@
#include <private/qquickshadereffect_p.h>
#include <private/qsgcontextplugin_p.h>
#include <private/qquickitem_p.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
#include <private/qquickopenglshadereffect_p.h>
#endif
#include <private/qquickgenericshadereffect_p.h>
@@ -499,14 +499,14 @@ QSGContextFactoryInterface::Flags qsg_backend_flags();
QQuickShaderEffect::QQuickShaderEffect(QQuickItem *parent)
: QQuickItem(*new QQuickShaderEffectPrivate, parent),
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
m_glImpl(nullptr),
#endif
m_impl(nullptr)
{
setFlag(QQuickItem::ItemHasContents);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (!qsg_backend_flags().testFlag(QSGContextFactoryInterface::SupportsShaderEffectNode))
m_glImpl = new QQuickOpenGLShaderEffect(this, this);
@@ -539,7 +539,7 @@ QQuickShaderEffect::QQuickShaderEffect(QQuickItem *parent)
QByteArray QQuickShaderEffect::fragmentShader() const
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl)
return m_glImpl->fragmentShader();
#endif
@@ -548,7 +548,7 @@ QByteArray QQuickShaderEffect::fragmentShader() const
void QQuickShaderEffect::setFragmentShader(const QByteArray &code)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl) {
m_glImpl->setFragmentShader(code);
return;
@@ -578,7 +578,7 @@ void QQuickShaderEffect::setFragmentShader(const QByteArray &code)
QByteArray QQuickShaderEffect::vertexShader() const
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl)
return m_glImpl->vertexShader();
#endif
@@ -587,7 +587,7 @@ QByteArray QQuickShaderEffect::vertexShader() const
void QQuickShaderEffect::setVertexShader(const QByteArray &code)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl) {
m_glImpl->setVertexShader(code);
return;
@@ -607,7 +607,7 @@ void QQuickShaderEffect::setVertexShader(const QByteArray &code)
bool QQuickShaderEffect::blending() const
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl)
return m_glImpl->blending();
#endif
@@ -616,7 +616,7 @@ bool QQuickShaderEffect::blending() const
void QQuickShaderEffect::setBlending(bool enable)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl) {
m_glImpl->setBlending(enable);
return;
@@ -640,7 +640,7 @@ void QQuickShaderEffect::setBlending(bool enable)
QVariant QQuickShaderEffect::mesh() const
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl)
return m_glImpl->mesh();
#endif
@@ -649,7 +649,7 @@ QVariant QQuickShaderEffect::mesh() const
void QQuickShaderEffect::setMesh(const QVariant &mesh)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl) {
m_glImpl->setMesh(mesh);
return;
@@ -674,7 +674,7 @@ void QQuickShaderEffect::setMesh(const QVariant &mesh)
QQuickShaderEffect::CullMode QQuickShaderEffect::cullMode() const
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl)
return m_glImpl->cullMode();
#endif
@@ -683,7 +683,7 @@ QQuickShaderEffect::CullMode QQuickShaderEffect::cullMode() const
void QQuickShaderEffect::setCullMode(CullMode face)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl) {
m_glImpl->setCullMode(face);
return;
@@ -715,7 +715,7 @@ void QQuickShaderEffect::setCullMode(CullMode face)
bool QQuickShaderEffect::supportsAtlasTextures() const
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl)
return m_glImpl->supportsAtlasTextures();
#endif
@@ -724,7 +724,7 @@ bool QQuickShaderEffect::supportsAtlasTextures() const
void QQuickShaderEffect::setSupportsAtlasTextures(bool supports)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl) {
m_glImpl->setSupportsAtlasTextures(supports);
return;
@@ -771,7 +771,7 @@ void QQuickShaderEffect::setSupportsAtlasTextures(bool supports)
QString QQuickShaderEffect::log() const
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl)
return m_glImpl->log();
#endif
@@ -780,7 +780,7 @@ QString QQuickShaderEffect::log() const
QQuickShaderEffect::Status QQuickShaderEffect::status() const
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl)
return m_glImpl->status();
#endif
@@ -789,7 +789,7 @@ QQuickShaderEffect::Status QQuickShaderEffect::status() const
bool QQuickShaderEffect::event(QEvent *e)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl) {
m_glImpl->handleEvent(e);
return QQuickItem::event(e);
@@ -801,7 +801,7 @@ bool QQuickShaderEffect::event(QEvent *e)
void QQuickShaderEffect::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl) {
m_glImpl->handleGeometryChanged(newGeometry, oldGeometry);
QQuickItem::geometryChanged(newGeometry, oldGeometry);
@@ -814,7 +814,7 @@ void QQuickShaderEffect::geometryChanged(const QRectF &newGeometry, const QRectF
QSGNode *QQuickShaderEffect::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl)
return m_glImpl->handleUpdatePaintNode(oldNode, updatePaintNodeData);
#endif
@@ -823,7 +823,7 @@ QSGNode *QQuickShaderEffect::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDa
void QQuickShaderEffect::componentComplete()
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl) {
m_glImpl->maybeUpdateShaders();
QQuickItem::componentComplete();
@@ -836,7 +836,7 @@ void QQuickShaderEffect::componentComplete()
void QQuickShaderEffect::itemChange(ItemChange change, const ItemChangeData &value)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl) {
m_glImpl->handleItemChange(change, value);
QQuickItem::itemChange(change, value);
@@ -854,7 +854,7 @@ bool QQuickShaderEffect::isComponentComplete() const
QString QQuickShaderEffect::parseLog() // for OpenGL-based autotests
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_glImpl)
return m_glImpl->parseLog();
#endif
@@ -864,7 +864,7 @@ QString QQuickShaderEffect::parseLog() // for OpenGL-based autotests
void QQuickShaderEffectPrivate::updatePolish()
{
Q_Q(QQuickShaderEffect);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (q->m_glImpl) {
q->m_glImpl->maybeUpdateShaders();
return;
diff --git a/src/quick/items/qquickshadereffect_p.h b/src/quick/items/qquickshadereffect_p.h
index 2b7ff4cf6e..7885daffbb 100644
--- a/src/quick/items/qquickshadereffect_p.h
+++ b/src/quick/items/qquickshadereffect_p.h
@@ -135,7 +135,7 @@ protected:
void itemChange(ItemChange change, const ItemChangeData &value) override;
private:
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QQuickOpenGLShaderEffect *m_glImpl;
#endif
QQuickGenericShaderEffect *m_impl;
diff --git a/src/quick/items/qquickspriteengine.cpp b/src/quick/items/qquickspriteengine.cpp
index 74b04a75ad..f54a8911b2 100644
--- a/src/quick/items/qquickspriteengine.cpp
+++ b/src/quick/items/qquickspriteengine.cpp
@@ -664,13 +664,14 @@ uint QQuickStochasticEngine::updateSprites(uint time)//### would returning a lis
//Sprite State Update;
m_timeOffset = time;
m_addAdvance = false;
- while (!m_stateUpdates.isEmpty() && time >= m_stateUpdates.constFirst().first){
- const auto copy = m_stateUpdates.constFirst().second;
+ int i = 0;
+ for (; i < m_stateUpdates.count() && time >= m_stateUpdates.at(i).first; ++i) {
+ const auto copy = m_stateUpdates.at(i).second;
for (int idx : copy)
advance(idx);
- m_stateUpdates.pop_front();
}
+ m_stateUpdates.remove(0, i);
m_advanceTime.start();
m_addAdvance = true;
if (m_stateUpdates.isEmpty())
@@ -760,13 +761,13 @@ void QQuickStochasticEngine::addToUpdateList(uint t, int idx)
m_stateUpdates[i].second << idx;
return;
} else if (m_stateUpdates.at(i).first > t) {
- QList<int> tmpList;
+ QVector<int> tmpList;
tmpList << idx;
m_stateUpdates.insert(i, qMakePair(t, tmpList));
return;
}
}
- QList<int> tmpList;
+ QVector<int> tmpList;
tmpList << idx;
m_stateUpdates << qMakePair(t, tmpList);
}
diff --git a/src/quick/items/qquickspriteengine_p.h b/src/quick/items/qquickspriteengine_p.h
index 89de9ce4f2..90ee68b2f6 100644
--- a/src/quick/items/qquickspriteengine_p.h
+++ b/src/quick/items/qquickspriteengine_p.h
@@ -254,7 +254,7 @@ protected:
QVector<int> m_goals;
QVector<int> m_duration;
QVector<int> m_startTimes;
- QList<QPair<uint, QList<int> > > m_stateUpdates;//### This could be done faster - priority queue?
+ QVector<QPair<uint, QVector<int> > > m_stateUpdates;//### This could be done faster - priority queue?
QTime m_advanceTime;
uint m_timeOffset;
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index 2bfb4501fc..e37a7e6d5e 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -1819,7 +1819,7 @@ bool QQuickTextPrivate::setHAlign(QQuickText::HAlignment alignment, bool forceAl
bool QQuickTextPrivate::determineHorizontalAlignment()
{
if (hAlignImplicit) {
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
bool alignToRight = text.isEmpty() ? QGuiApplication::inputMethod()->inputDirection() == Qt::RightToLeft : rightToLeftText;
#else
bool alignToRight = rightToLeftText;
@@ -2713,12 +2713,12 @@ QString QQuickText::hoveredLink() const
if (d->extra.isAllocated())
return d->extra->hoveredLink;
} else {
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
if (QQuickWindow *wnd = window()) {
QPointF pos = QCursor::pos(wnd->screen()) - wnd->position() - mapToScene(QPointF(0, 0));
return d->anchorAt(pos);
}
-#endif // QT_NO_CURSOR
+#endif // cursor
}
return QString();
}
diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp
index fe29249934..555fd233b3 100644
--- a/src/quick/items/qquicktextcontrol.cpp
+++ b/src/quick/items/qquicktextcontrol.cpp
@@ -79,9 +79,6 @@ const int textCursorWidth = 1;
QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(DBG_HOVER_TRACE)
-#ifndef QT_NO_CONTEXTMENU
-#endif
-
// could go into QTextCursor...
static QTextLine currentTextLine(const QTextCursor &cursor)
{
@@ -99,7 +96,7 @@ static QTextLine currentTextLine(const QTextCursor &cursor)
QQuickTextControlPrivate::QQuickTextControlPrivate()
: doc(0),
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
preeditCursor(0),
#endif
interactionFlags(Qt::TextEditorInteraction),
@@ -123,7 +120,7 @@ QQuickTextControlPrivate::QQuickTextControlPrivate()
bool QQuickTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e)
{
-#ifdef QT_NO_SHORTCUT
+#if !QT_CONFIG(shortcut)
Q_UNUSED(e);
#endif
@@ -139,7 +136,7 @@ bool QQuickTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e)
if (false) {
}
-#ifndef QT_NO_SHORTCUT
+#if QT_CONFIG(shortcut)
if (e == QKeySequence::MoveToNextChar) {
op = QTextCursor::Right;
}
@@ -232,7 +229,7 @@ bool QQuickTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e)
else if (e == QKeySequence::MoveToEndOfDocument) {
op = QTextCursor::End;
}
-#endif // QT_NO_SHORTCUT
+#endif // shortcut
else {
return false;
}
@@ -290,7 +287,7 @@ void QQuickTextControlPrivate::setContent(Qt::TextFormat format, const QString &
{
Q_Q(QQuickTextControl);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
cancelPreedit();
#endif
@@ -326,7 +323,7 @@ void QQuickTextControlPrivate::setContent(Qt::TextFormat format, const QString &
formatCursor.setCharFormat(charFormatForInsertion);
formatCursor.endEditBlock();
} else {
-#ifndef QT_NO_TEXTHTMLPARSER
+#if QT_CONFIG(texthtmlparser)
doc->setHtml(text);
#else
doc->setPlainText(text);
@@ -407,7 +404,7 @@ void QQuickTextControlPrivate::selectionChanged(bool forceEmitSelectionChanged /
{
Q_Q(QQuickTextControl);
if (forceEmitSelectionChanged) {
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (hasFocus)
qGuiApp->inputMethod()->update(Qt::ImCurrentSelection);
#endif
@@ -429,7 +426,7 @@ void QQuickTextControlPrivate::selectionChanged(bool forceEmitSelectionChanged /
lastSelectionEnd = selectionEnd;
if (!forceEmitSelectionChanged) {
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (hasFocus)
qGuiApp->inputMethod()->update(Qt::ImCurrentSelection);
#endif
@@ -443,7 +440,7 @@ void QQuickTextControlPrivate::_q_updateCurrentCharFormatAndSelection()
selectionChanged();
}
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void QQuickTextControlPrivate::setClipboardSelection()
{
QClipboard *clipboard = QGuiApplication::clipboard();
@@ -544,7 +541,7 @@ void QQuickTextControlPrivate::extendWordwiseSelection(int suggestedNewPosition,
}
if (interactionFlags & Qt::TextSelectableByMouse) {
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
setClipboardSelection();
#endif
selectionChanged(true);
@@ -574,7 +571,7 @@ void QQuickTextControlPrivate::extendBlockwiseSelection(int suggestedNewPosition
}
if (interactionFlags & Qt::TextSelectableByMouse) {
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
setClipboardSelection();
#endif
selectionChanged(true);
@@ -611,7 +608,7 @@ void QQuickTextControl::clear()
}
QQuickTextControl::QQuickTextControl(QTextDocument *doc, QObject *parent)
- : QObject(*new QQuickTextControlPrivate, parent)
+ : QInputControl(TextEdit, *new QQuickTextControlPrivate, parent)
{
Q_D(QQuickTextControl);
Q_ASSERT(doc);
@@ -656,7 +653,7 @@ void QQuickTextControl::updateCursorRectangle(bool force)
void QQuickTextControl::setTextCursor(const QTextCursor &cursor)
{
Q_D(QQuickTextControl);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
d->commitPreedit();
#endif
d->cursorIsFocusIndicator = false;
@@ -677,7 +674,7 @@ QTextCursor QQuickTextControl::textCursor() const
return d->cursor;
}
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void QQuickTextControl::cut()
{
@@ -759,7 +756,7 @@ void QQuickTextControl::processEvent(QEvent *e, const QMatrix &matrix)
QHoverEvent *ev = static_cast<QHoverEvent *>(e);
d->hoverEvent(ev, matrix.map(ev->posF()));
break; }
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
case QEvent::InputMethod:
d->inputMethodEvent(static_cast<QInputMethodEvent *>(e));
break;
@@ -795,7 +792,7 @@ void QQuickTextControl::processEvent(QEvent *e, const QMatrix &matrix)
break;
}
}
-#ifndef QT_NO_SHORTCUT
+#if QT_CONFIG(shortcut)
} else if (ke == QKeySequence::Copy
|| ke == QKeySequence::Paste
|| ke == QKeySequence::Cut
@@ -873,20 +870,20 @@ void QQuickTextControlPrivate::keyPressEvent(QKeyEvent *e)
return;
}
-#ifndef QT_NO_SHORTCUT
+#if QT_CONFIG(shortcut)
if (e == QKeySequence::SelectAll) {
e->accept();
q->selectAll();
return;
}
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
else if (e == QKeySequence::Copy) {
e->accept();
q->copy();
return;
}
#endif
-#endif // QT_NO_SHORTCUT
+#endif // shortcut
if (interactionFlags & Qt::TextSelectableByKeyboard
&& cursorMoveKeyEvent(e))
@@ -924,7 +921,7 @@ void QQuickTextControlPrivate::keyPressEvent(QKeyEvent *e)
}
goto accept;
}
-#ifndef QT_NO_SHORTCUT
+#if QT_CONFIG(shortcut)
else if (e == QKeySequence::InsertParagraphSeparator) {
cursor.insertBlock();
e->accept();
@@ -937,14 +934,14 @@ void QQuickTextControlPrivate::keyPressEvent(QKeyEvent *e)
#endif
if (false) {
}
-#ifndef QT_NO_SHORTCUT
+#if QT_CONFIG(shortcut)
else if (e == QKeySequence::Undo) {
q->undo();
}
else if (e == QKeySequence::Redo) {
q->redo();
}
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
else if (e == QKeySequence::Cut) {
q->cut();
}
@@ -975,7 +972,7 @@ void QQuickTextControlPrivate::keyPressEvent(QKeyEvent *e)
cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
cursor.removeSelectedText();
}
-#endif // QT_NO_SHORTCUT
+#endif // shortcut
else {
goto process;
}
@@ -983,8 +980,7 @@ void QQuickTextControlPrivate::keyPressEvent(QKeyEvent *e)
process:
{
- QString text = e->text();
- if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t'))) {
+ if (q->isAcceptableInput(e)) {
if (overwriteMode
// no need to call deleteChar() if we have a selection, insertText
// does it already
@@ -993,7 +989,7 @@ process:
cursor.deleteChar();
}
- cursor.insertText(text);
+ cursor.insertText(e->text());
selectionChanged();
} else {
e->ignore();
@@ -1019,7 +1015,7 @@ QRectF QQuickTextControlPrivate::rectForPosition(int position) const
const QTextLayout *layout = block.layout();
const QPointF layoutPos = q->blockBoundingRect(block).topLeft();
int relativePos = position - block.position();
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (preeditCursor != 0) {
int preeditPos = layout->preeditAreaPosition();
if (relativePos == preeditPos)
@@ -1083,7 +1079,7 @@ void QQuickTextControlPrivate::mousePressEvent(QMouseEvent *e, const QPointF &po
const QTextCursor oldSelection = cursor;
const int oldCursorPos = cursor.position();
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
commitPreedit();
#endif
@@ -1157,7 +1153,7 @@ void QQuickTextControlPrivate::mouseMoveEvent(QMouseEvent *e, const QPointF &mou
int newCursorPos = q->hitTest(mousePos, Qt::FuzzyHit);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (isPreediting()) {
// note: oldCursorPos not including preedit
int selectionStartPos = q->hitTest(mousePressPos, Qt::FuzzyHit);
@@ -1183,7 +1179,7 @@ void QQuickTextControlPrivate::mouseMoveEvent(QMouseEvent *e, const QPointF &mou
extendBlockwiseSelection(newCursorPos);
else if (selectedWordOnDoubleClick.hasSelection())
extendWordwiseSelection(newCursorPos, mouseX);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
else if (!isPreediting())
setCursorPosition(newCursorPos, QTextCursor::KeepAnchor);
#endif
@@ -1194,7 +1190,7 @@ void QQuickTextControlPrivate::mouseMoveEvent(QMouseEvent *e, const QPointF &mou
q->updateCursorRectangle(true);
}
_q_updateCurrentCharFormatAndSelection();
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (qGuiApp)
qGuiApp->inputMethod()->update(Qt::ImQueryInput);
#endif
@@ -1221,7 +1217,7 @@ void QQuickTextControlPrivate::mouseReleaseEvent(QMouseEvent *e, const QPointF &
if (mousePressed) {
mousePressed = false;
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
setClipboardSelection();
selectionChanged(true);
} else if (e->button() == Qt::MidButton
@@ -1270,7 +1266,7 @@ void QQuickTextControlPrivate::mouseDoubleClickEvent(QMouseEvent *e, const QPoin
Q_Q(QQuickTextControl);
if (e->button() == Qt::LeftButton && (interactionFlags & Qt::TextSelectableByMouse)) {
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
commitPreedit();
#endif
@@ -1291,7 +1287,7 @@ void QQuickTextControlPrivate::mouseDoubleClickEvent(QMouseEvent *e, const QPoin
tripleClickTimer.start(QGuiApplication::styleHints()->mouseDoubleClickInterval(), q);
if (doEmit) {
selectionChanged();
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
setClipboardSelection();
#endif
emit q->cursorPositionChanged();
@@ -1304,7 +1300,7 @@ void QQuickTextControlPrivate::mouseDoubleClickEvent(QMouseEvent *e, const QPoin
bool QQuickTextControlPrivate::sendMouseEventToInputContext(QMouseEvent *e, const QPointF &pos)
{
-#if !defined(QT_NO_IM)
+#if QT_CONFIG(im)
Q_Q(QQuickTextControl);
Q_UNUSED(e);
@@ -1328,7 +1324,7 @@ bool QQuickTextControlPrivate::sendMouseEventToInputContext(QMouseEvent *e, cons
return false;
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
void QQuickTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
{
Q_Q(QQuickTextControl);
@@ -1481,7 +1477,7 @@ QVariant QQuickTextControl::inputMethodQuery(Qt::InputMethodQuery property, QVar
return QVariant();
}
}
-#endif // QT_NO_IM
+#endif // im
void QQuickTextControlPrivate::focusEvent(QFocusEvent *e)
{
@@ -1611,7 +1607,7 @@ void QQuickTextControl::moveCursor(QTextCursor::MoveOperation op, QTextCursor::M
bool QQuickTextControl::canPaste() const
{
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
Q_D(const QQuickTextControl);
if (d->interactionFlags & Qt::TextEditable) {
const QMimeData *md = QGuiApplication::clipboard()->mimeData();
@@ -1661,7 +1657,7 @@ void QQuickTextControl::insertFromMimeData(const QMimeData *source)
bool hasData = false;
QTextDocumentFragment fragment;
-#ifndef QT_NO_TEXTHTMLPARSER
+#if QT_CONFIG(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).
const QString richtext = QLatin1String("<meta name=\"qrichtext\" content=\"1\" />")
@@ -1680,7 +1676,7 @@ void QQuickTextControl::insertFromMimeData(const QMimeData *source)
}
#else
fragment = QTextDocumentFragment::fromPlainText(source->text());
-#endif // QT_NO_TEXTHTMLPARSER
+#endif // texthtmlparser
if (hasData)
d->cursor.insertFragment(fragment);
@@ -1751,7 +1747,7 @@ void QQuickTextControlPrivate::activateLinkUnderCursor(QString href)
emit q_func()->linkActivated(href);
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
bool QQuickTextControlPrivate::isPreediting() const
{
QTextLayout *layout = cursor.block().layout();
@@ -1789,7 +1785,7 @@ void QQuickTextControlPrivate::cancelPreedit()
QInputMethodEvent event;
QCoreApplication::sendEvent(q->parent(), &event);
}
-#endif // QT_NO_IM
+#endif // im
void QQuickTextControl::setTextInteractionFlags(Qt::TextInteractionFlags flags)
{
@@ -1813,7 +1809,7 @@ QString QQuickTextControl::toPlainText() const
return document()->toPlainText();
}
-#ifndef QT_NO_TEXTHTMLPARSER
+#if QT_CONFIG(texthtmlparser)
QString QQuickTextControl::toHtml() const
{
return document()->toHtml();
@@ -1840,7 +1836,7 @@ QRectF QQuickTextControl::blockBoundingRect(const QTextBlock &block) const
QString QQuickTextControl::preeditText() const
{
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
Q_D(const QQuickTextControl);
QTextLayout *layout = d->cursor.block().layout();
if (!layout)
@@ -1857,7 +1853,7 @@ QStringList QQuickTextEditMimeData::formats() const
{
if (!fragment.isEmpty())
return QStringList() << QString::fromLatin1("text/plain") << QString::fromLatin1("text/html")
-#ifndef QT_NO_TEXTODFWRITER
+#if QT_CONFIG(textodfwriter)
<< QString::fromLatin1("application/vnd.oasis.opendocument.text")
#endif
;
@@ -1875,10 +1871,10 @@ QVariant QQuickTextEditMimeData::retrieveData(const QString &mimeType, QVariant:
void QQuickTextEditMimeData::setup() const
{
QQuickTextEditMimeData *that = const_cast<QQuickTextEditMimeData *>(this);
-#ifndef QT_NO_TEXTHTMLPARSER
+#if QT_CONFIG(texthtmlparser)
that->setData(QLatin1String("text/html"), fragment.toHtml("utf-8").toUtf8());
#endif
-#ifndef QT_NO_TEXTODFWRITER
+#if QT_CONFIG(textodfwriter)
{
QBuffer buffer;
QTextDocumentWriter writer(&buffer, "ODF");
diff --git a/src/quick/items/qquicktextcontrol_p.h b/src/quick/items/qquicktextcontrol_p.h
index e06e3b8b29..70104a97e0 100644
--- a/src/quick/items/qquicktextcontrol_p.h
+++ b/src/quick/items/qquicktextcontrol_p.h
@@ -59,6 +59,7 @@
#include <QtGui/qabstracttextdocumentlayout.h>
#include <QtGui/qtextdocumentfragment.h>
#include <QtGui/qclipboard.h>
+#include <QtGui/private/qinputcontrol_p.h>
#include <QtCore/qmimedata.h>
QT_BEGIN_NAMESPACE
@@ -71,7 +72,7 @@ class QAbstractScrollArea;
class QEvent;
class QTimerEvent;
-class Q_AUTOTEST_EXPORT QQuickTextControl : public QObject
+class Q_AUTOTEST_EXPORT QQuickTextControl : public QInputControl
{
Q_OBJECT
Q_DECLARE_PRIVATE(QQuickTextControl)
@@ -89,7 +90,7 @@ public:
QString toPlainText() const;
-#ifndef QT_NO_TEXTHTMLPARSER
+#if QT_CONFIG(texthtmlparser)
QString toHtml() const;
#endif
@@ -129,7 +130,7 @@ public Q_SLOTS:
void setPlainText(const QString &text);
void setHtml(const QString &text);
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void cut();
void copy();
void paste(QClipboard::Mode mode = QClipboard::Clipboard);
@@ -164,7 +165,7 @@ public:
virtual void processEvent(QEvent *e, const QMatrix &matrix);
void processEvent(QEvent *e, const QPointF &coordinateOffset = QPointF());
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
virtual QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const;
#endif
diff --git a/src/quick/items/qquicktextcontrol_p_p.h b/src/quick/items/qquicktextcontrol_p_p.h
index 0f78feb5de..0582e6d113 100644
--- a/src/quick/items/qquicktextcontrol_p_p.h
+++ b/src/quick/items/qquicktextcontrol_p_p.h
@@ -90,7 +90,7 @@ public:
void _q_updateCurrentCharFormatAndSelection();
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void setClipboardSelection();
#endif
@@ -114,14 +114,14 @@ public:
void mouseDoubleClickEvent(QMouseEvent *event, const QPointF &pos);
bool sendMouseEventToInputContext(QMouseEvent *event, const QPointF &pos);
void focusEvent(QFocusEvent *e);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
void inputMethodEvent(QInputMethodEvent *);
#endif
void hoverEvent(QHoverEvent *e, const QPointF &pos);
void activateLinkUnderCursor(QString href = QString());
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
bool isPreediting() const;
void commitPreedit();
void cancelPreedit();
@@ -143,7 +143,7 @@ public:
QBasicTimer cursorBlinkTimer;
QBasicTimer tripleClickTimer;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
int preeditCursor;
#endif
diff --git a/src/quick/items/qquicktextdocument.cpp b/src/quick/items/qquicktextdocument.cpp
index 287e07e980..61d75fe99b 100644
--- a/src/quick/items/qquicktextdocument.cpp
+++ b/src/quick/items/qquicktextdocument.cpp
@@ -230,7 +230,7 @@ void QQuickTextDocumentWithImageResources::setText(const QString &text)
{
clearResources();
-#ifndef QT_NO_TEXTHTMLPARSER
+#if QT_CONFIG(texthtmlparser)
setHtml(text);
#else
setPlainText(text);
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index 4a5358faae..106acf57cf 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -190,7 +190,7 @@ QString QQuickTextEdit::text() const
Q_D(const QQuickTextEdit);
if (!d->textCached && isComponentComplete()) {
QQuickTextEditPrivate *d = const_cast<QQuickTextEditPrivate *>(d_func());
-#ifndef QT_NO_TEXTHTMLPARSER
+#if QT_CONFIG(texthtmlparser)
if (d->richText)
d->text = d->control->toHtml();
else
@@ -381,7 +381,7 @@ void QQuickTextEdit::setText(const QString &text)
if (!isComponentComplete()) {
d->text = text;
} else if (d->richText) {
-#ifndef QT_NO_TEXTHTMLPARSER
+#if QT_CONFIG(texthtmlparser)
d->control->setHtml(text);
#else
d->control->setPlainText(text);
@@ -458,7 +458,7 @@ void QQuickTextEdit::setTextFormat(TextFormat format)
bool wasRich = d->richText;
d->richText = format == RichText || (format == AutoText && (wasRich || Qt::mightBeRichText(text())));
-#ifndef QT_NO_TEXTHTMLPARSER
+#if QT_CONFIG(texthtmlparser)
if (isComponentComplete()) {
if (wasRich && !d->richText) {
d->control->setPlainText(!d->textCached ? d->control->toHtml() : d->text);
@@ -540,7 +540,7 @@ void QQuickTextEdit::setFont(const QFont &font)
}
updateSize();
updateWholeDocument();
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
updateInputMethod(Qt::ImCursorRectangle | Qt::ImAnchorRectangle | Qt::ImFont);
#endif
}
@@ -738,7 +738,7 @@ bool QQuickTextEditPrivate::determineHorizontalAlignment()
Q_Q(QQuickTextEdit);
if (hAlignImplicit && q->isComponentComplete()) {
Qt::LayoutDirection direction = contentDirection;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (direction == Qt::LayoutDirectionAuto) {
const QString preeditText = control->textCursor().block().layout()->preeditAreaText();
direction = textDirection(preeditText);
@@ -764,7 +764,7 @@ void QQuickTextEditPrivate::mirrorChange()
}
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
Qt::InputMethodHints QQuickTextEditPrivate::effectiveInputMethodHints() const
{
return inputMethodHints | Qt::ImhMultiLine;
@@ -892,7 +892,7 @@ void QQuickTextEdit::setWrapMode(WrapMode mode)
/*!
\qmlproperty int QtQuick::TextEdit::lineCount
- Returns the total number of lines in the textEdit item.
+ Returns the total number of lines in the TextEdit item.
*/
int QQuickTextEdit::lineCount() const
{
@@ -1012,7 +1012,7 @@ int QQuickTextEdit::positionAt(qreal x, qreal y) const
y -= d->yoff;
int r = d->document->documentLayout()->hitTest(QPointF(x, y), Qt::FuzzyHit);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
QTextCursor cursor = d->control->textCursor();
if (r > cursor.position()) {
// The cursor position includes positions within the preedit text, but only positions in the
@@ -1261,7 +1261,7 @@ int QQuickTextEdit::selectionEnd() const
QString QQuickTextEdit::selectedText() const
{
Q_D(const QQuickTextEdit);
-#ifndef QT_NO_TEXTHTMLPARSER
+#if QT_CONFIG(texthtmlparser)
return d->richText
? d->control->textCursor().selectedText()
: d->control->textCursor().selection().toPlainText();
@@ -1379,17 +1379,17 @@ void QQuickTextEdit::setTextMargin(qreal margin)
Qt::InputMethodHints QQuickTextEdit::inputMethodHints() const
{
-#ifdef QT_NO_IM
+#if !QT_CONFIG(im)
return Qt::ImhNone;
#else
Q_D(const QQuickTextEdit);
return d->inputMethodHints;
-#endif // QT_NO_IM
+#endif // im
}
void QQuickTextEdit::setInputMethodHints(Qt::InputMethodHints hints)
{
-#ifdef QT_NO_IM
+#if !QT_CONFIG(im)
Q_UNUSED(hints);
#else
Q_D(QQuickTextEdit);
@@ -1400,7 +1400,7 @@ void QQuickTextEdit::setInputMethodHints(Qt::InputMethodHints hints)
d->inputMethodHints = hints;
updateInputMethod(Qt::ImHints);
emit inputMethodHintsChanged();
-#endif // QT_NO_IM
+#endif // im
}
void QQuickTextEdit::geometryChanged(const QRectF &newGeometry,
@@ -1427,7 +1427,7 @@ void QQuickTextEdit::componentComplete()
QQuickImplicitSizeItem::componentComplete();
d->document->setBaseUrl(baseUrl());
-#ifndef QT_NO_TEXTHTML_PARSER
+#if QT_CONFIG(texthtmlparser)
if (d->richText)
d->control->setHtml(d->text);
else
@@ -1554,7 +1554,7 @@ void QQuickTextEdit::setReadOnly(bool r)
if (r == isReadOnly())
return;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
setFlag(QQuickItem::ItemAcceptsInputMethod, !r);
#endif
Qt::TextInteractionFlags flags = Qt::LinksAccessibleByMouse;
@@ -1569,7 +1569,7 @@ void QQuickTextEdit::setReadOnly(bool r)
d->control->setTextInteractionFlags(flags);
d->control->moveCursor(QTextCursor::End);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
updateInputMethod(Qt::ImEnabled);
#endif
q_canPasteChanged();
@@ -1748,7 +1748,7 @@ bool QQuickTextEdit::isRightToLeft(int start, int end)
}
}
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
/*!
\qmlmethod QtQuick::TextEdit::cut()
@@ -1781,7 +1781,7 @@ void QQuickTextEdit::paste()
Q_D(QQuickTextEdit);
d->control->paste();
}
-#endif // QT_NO_CLIPBOARD
+#endif // clipboard
/*!
@@ -1822,7 +1822,7 @@ void QQuickTextEdit::mousePressEvent(QMouseEvent *event)
bool hadActiveFocus = hasActiveFocus();
forceActiveFocus(Qt::MouseFocusReason);
// re-open input panel on press if already focused
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (hasActiveFocus() && hadActiveFocus && !isReadOnly())
qGuiApp->inputMethod()->show();
#else
@@ -1870,7 +1870,7 @@ void QQuickTextEdit::mouseMoveEvent(QMouseEvent *event)
QQuickImplicitSizeItem::mouseMoveEvent(event);
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
/*!
\overload
Handles the given input method \a event.
@@ -1923,7 +1923,7 @@ QVariant QQuickTextEdit::inputMethodQuery(Qt::InputMethodQuery property) const
{
return inputMethodQuery(property, QVariant());
}
-#endif // QT_NO_IM
+#endif // im
void QQuickTextEdit::triggerPreprocess()
{
@@ -2197,12 +2197,12 @@ bool QQuickTextEdit::canRedo() const
*/
bool QQuickTextEdit::isInputMethodComposing() const
{
-#ifdef QT_NO_IM
+#if !QT_CONFIG(im)
return false;
#else
Q_D(const QQuickTextEdit);
return d->control->hasImState();
-#endif // QT_NO_IM
+#endif // im
}
QQuickTextEditPrivate::ExtraData::ExtraData()
@@ -2223,14 +2223,14 @@ void QQuickTextEditPrivate::init()
{
Q_Q(QQuickTextEdit);
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
if (QGuiApplication::clipboard()->supportsSelection())
q->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton);
else
#endif
q->setAcceptedMouseButtons(Qt::LeftButton);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
q->setFlag(QQuickItem::ItemAcceptsInputMethod);
#endif
q->setFlag(QQuickItem::ItemHasContents);
@@ -2255,7 +2255,7 @@ void QQuickTextEditPrivate::init()
qmlobject_connect(control, QQuickTextControl, SIGNAL(overwriteModeChanged(bool)), q, QQuickTextEdit, SIGNAL(overwriteModeChanged(bool)));
qmlobject_connect(control, QQuickTextControl, SIGNAL(textChanged()), q, QQuickTextEdit, SLOT(q_textChanged()));
qmlobject_connect(control, QQuickTextControl, SIGNAL(preeditTextChanged()), q, QQuickTextEdit, SIGNAL(preeditTextChanged()));
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
qmlobject_connect(QGuiApplication::clipboard(), QClipboard, SIGNAL(dataChanged()), q, QQuickTextEdit, SLOT(q_canPasteChanged()));
#endif
qmlobject_connect(document, QQuickTextDocumentWithImageResources, SIGNAL(undoAvailable(bool)), q, QQuickTextEdit, SIGNAL(canUndoChanged()));
@@ -2341,7 +2341,7 @@ void QQuickTextEdit::q_contentsChange(int pos, int charsRemoved, int charsAdded)
void QQuickTextEdit::moveCursorDelegate()
{
Q_D(QQuickTextEdit);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
updateInputMethod();
#endif
emit cursorRectangleChanged();
@@ -2350,6 +2350,7 @@ void QQuickTextEdit::moveCursorDelegate()
QRectF cursorRect = cursorRectangle();
d->cursorItem->setX(cursorRect.x());
d->cursorItem->setY(cursorRect.y());
+ d->cursorItem->setHeight(cursorRect.height());
}
void QQuickTextEdit::updateSelection()
@@ -2581,7 +2582,7 @@ void QQuickTextEditPrivate::updateDefaultTextOption()
else
opt.setAlignment(Qt::Alignment(vAlign));
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (contentDirection == Qt::LayoutDirectionAuto) {
opt.setTextDirection(qGuiApp->inputMethod()->inputDirection());
} else
@@ -2626,14 +2627,14 @@ void QQuickTextEditPrivate::handleFocusEvent(QFocusEvent *event)
control->processEvent(event, QPointF(-xoff, -yoff));
if (focus) {
q->q_updateAlignment();
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (focusOnPress && !q->isReadOnly())
qGuiApp->inputMethod()->show();
q->connect(QGuiApplication::inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)),
q, SLOT(q_updateAlignment()));
#endif
} else {
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
q->disconnect(QGuiApplication::inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)),
q, SLOT(q_updateAlignment()));
#endif
@@ -2684,7 +2685,7 @@ QString QQuickTextEdit::getText(int start, int end) const
QTextCursor cursor(d->document);
cursor.setPosition(start, QTextCursor::MoveAnchor);
cursor.setPosition(end, QTextCursor::KeepAnchor);
-#ifndef QT_NO_TEXTHTMLPARSER
+#if QT_CONFIG(texthtmlparser)
return d->richText
? cursor.selectedText()
: cursor.selection().toPlainText();
@@ -2713,7 +2714,7 @@ QString QQuickTextEdit::getFormattedText(int start, int end) const
cursor.setPosition(end, QTextCursor::KeepAnchor);
if (d->richText) {
-#ifndef QT_NO_TEXTHTMLPARSER
+#if QT_CONFIG(texthtmlparser)
return cursor.selection().toHtml();
#else
return cursor.selection().toPlainText();
@@ -2737,7 +2738,7 @@ void QQuickTextEdit::insert(int position, const QString &text)
cursor.setPosition(position);
d->richText = d->richText || (d->format == AutoText && Qt::mightBeRichText(text));
if (d->richText) {
-#ifndef QT_NO_TEXTHTMLPARSER
+#if QT_CONFIG(texthtmlparser)
cursor.insertHtml(text);
#else
cursor.insertText(text);
@@ -2830,12 +2831,12 @@ QString QQuickTextEdit::hoveredLink() const
if (const_cast<QQuickTextEditPrivate *>(d)->isLinkHoveredConnected()) {
return d->control->hoveredLink();
} else {
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
if (QQuickWindow *wnd = window()) {
QPointF pos = QCursor::pos(wnd->screen()) - wnd->position() - mapToScene(QPointF(0, 0));
return d->control->anchorAt(pos);
}
-#endif // QT_NO_CURSOR
+#endif // cursor
}
return QString();
}
@@ -2880,7 +2881,7 @@ void QQuickTextEdit::append(const QString &text)
if (!d->document->isEmpty())
cursor.insertBlock();
-#ifndef QT_NO_TEXTHTMLPARSER
+#if QT_CONFIG(texthtmlparser)
if (d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(text))) {
cursor.insertHtml(text);
} else {
@@ -2888,7 +2889,7 @@ void QQuickTextEdit::append(const QString &text)
}
#else
cursor.insertText(text);
-#endif // QT_NO_TEXTHTMLPARSER
+#endif // texthtmlparser
cursor.endEditBlock();
d->control->updateCursorRectangle(false);
diff --git a/src/quick/items/qquicktextedit_p.h b/src/quick/items/qquicktextedit_p.h
index 42c9064860..c8d3515be1 100644
--- a/src/quick/items/qquicktextedit_p.h
+++ b/src/quick/items/qquicktextedit_p.h
@@ -242,7 +242,7 @@ public:
QRectF cursorRectangle() const;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
QVariant inputMethodQuery(Qt::InputMethodQuery property) const Q_DECL_OVERRIDE;
Q_REVISION(4) Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const;
#endif
@@ -347,7 +347,7 @@ public Q_SLOTS:
void select(int start, int end);
void deselect();
bool isRightToLeft(int start, int end);
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void cut();
void copy();
void paste();
@@ -399,7 +399,7 @@ protected:
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
void inputMethodEvent(QInputMethodEvent *e) Q_DECL_OVERRIDE;
#endif
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) Q_DECL_OVERRIDE;
diff --git a/src/quick/items/qquicktextedit_p_p.h b/src/quick/items/qquicktextedit_p_p.h
index 1613dd7676..03bce00cb0 100644
--- a/src/quick/items/qquicktextedit_p_p.h
+++ b/src/quick/items/qquicktextedit_p_p.h
@@ -119,7 +119,7 @@ public:
#endif
, contentDirection(Qt::LayoutDirectionAuto)
, mouseSelectionMode(QQuickTextEdit::SelectCharacters)
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
, inputMethodHints(Qt::ImhNone)
#endif
, updateType(UpdatePaintNode)
@@ -156,7 +156,7 @@ public:
void addCurrentTextNodeToRoot(QQuickTextNodeEngine *, QSGTransformNode *, QQuickTextNode*, TextNodeIterator&, int startPos);
QQuickTextNode* createTextNode();
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
Qt::InputMethodHints effectiveInputMethodHints() const;
#endif
@@ -208,7 +208,7 @@ public:
QQuickTextEdit::RenderType renderType;
Qt::LayoutDirection contentDirection;
QQuickTextEdit::SelectionMode mouseSelectionMode;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
Qt::InputMethodHints inputMethodHints;
#endif
UpdateType updateType;
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index fbfaa0e199..27f3dcecfa 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -57,12 +57,13 @@
#include <QtGui/qinputmethod.h>
#include <QtCore/qmath.h>
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
#include "qaccessible.h"
#include "qquickaccessibleattached_p.h"
#endif
#include <QtGui/private/qtextengine_p.h>
+#include <QtGui/private/qinputcontrol_p.h>
QT_BEGIN_NAMESPACE
@@ -142,7 +143,7 @@ void QQuickTextInput::setText(const QString &s)
if (s == text())
return;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
d->cancelPreedit();
#endif
d->internalSetText(s, -1, false);
@@ -400,7 +401,7 @@ void QQuickTextInput::setFont(const QFont &font)
if (oldFont != d->font) {
d->updateLayout();
updateCursorRectangle();
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
updateInputMethod(Qt::ImCursorRectangle | Qt::ImFont | Qt::ImAnchorRectangle);
#endif
}
@@ -575,7 +576,7 @@ bool QQuickTextInputPrivate::setHAlign(QQuickTextInput::HAlignment alignment, bo
Qt::LayoutDirection QQuickTextInputPrivate::textDirection() const
{
QString text = m_text;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (text.isEmpty())
text = m_textLayout.preeditAreaText();
#endif
@@ -602,7 +603,7 @@ Qt::LayoutDirection QQuickTextInputPrivate::layoutDirection() const
Qt::LayoutDirection direction = m_layoutDirection;
if (direction == Qt::LayoutDirectionAuto) {
direction = textDirection();
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (direction == Qt::LayoutDirectionAuto)
direction = QGuiApplication::inputMethod()->inputDirection();
#endif
@@ -615,7 +616,7 @@ bool QQuickTextInputPrivate::determineHorizontalAlignment()
if (hAlignImplicit) {
// if no explicit alignment has been set, follow the natural layout direction of the text
Qt::LayoutDirection direction = textDirection();
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (direction == Qt::LayoutDirectionAuto)
direction = QGuiApplication::inputMethod()->inputDirection();
#endif
@@ -707,12 +708,12 @@ void QQuickTextInput::setReadOnly(bool ro)
if (d->m_readOnly == ro)
return;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
setFlag(QQuickItem::ItemAcceptsInputMethod, !ro);
#endif
d->m_readOnly = ro;
d->setCursorPosition(d->end());
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
updateInputMethod(Qt::ImEnabled);
#endif
q_canPasteChanged();
@@ -830,7 +831,7 @@ QRectF QQuickTextInput::cursorRectangle() const
Q_D(const QQuickTextInput);
int c = d->m_cursor;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
c += d->m_preeditCursor;
#endif
if (d->m_echoMode == NoEcho)
@@ -994,17 +995,17 @@ void QQuickTextInput::setAutoScroll(bool b)
QValidator* QQuickTextInput::validator() const
{
-#ifdef QT_NO_VALIDATOR
+#if !QT_CONFIG(validator)
return 0;
#else
Q_D(const QQuickTextInput);
return d->m_validator;
-#endif // QT_NO_VALIDATOR
+#endif // validator
}
void QQuickTextInput::setValidator(QValidator* v)
{
-#ifdef QT_NO_VALIDATOR
+#if !QT_CONFIG(validator)
Q_UNUSED(v);
#else
Q_D(QQuickTextInput);
@@ -1029,16 +1030,16 @@ void QQuickTextInput::setValidator(QValidator* v)
d->checkIsValid();
emit validatorChanged();
-#endif // QT_NO_VALIDATOR
+#endif // validator
}
-#ifndef QT_NO_VALIDATOR
+#if QT_CONFIG(validator)
void QQuickTextInput::q_validatorChanged()
{
Q_D(QQuickTextInput);
d->checkIsValid();
}
-#endif // QT_NO_VALIDATOR
+#endif // validator
QRectF QQuickTextInputPrivate::anchorRectangle() const
{
@@ -1056,7 +1057,7 @@ QRectF QQuickTextInputPrivate::anchorRectangle() const
else
a = m_selstart == m_cursor ? m_selend : m_selstart;
if (a >= 0) {
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
a += m_preeditCursor;
#endif
if (m_echoMode == QQuickTextInput::NoEcho)
@@ -1151,7 +1152,7 @@ bool QQuickTextInput::hasAcceptableInput() const
The corresponding handler is \c onEditingFinished.
*/
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
Qt::InputMethodHints QQuickTextInputPrivate::effectiveInputMethodHints() const
{
Qt::InputMethodHints hints = inputMethodHints;
@@ -1192,7 +1193,7 @@ void QQuickTextInput::setEchoMode(QQuickTextInput::EchoMode echo)
d->cancelPasswordEchoTimer();
d->m_echoMode = echo;
d->m_passwordEchoEditing = false;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
updateInputMethod(Qt::ImHints);
#endif
d->updateDisplayText();
@@ -1249,17 +1250,17 @@ void QQuickTextInput::setEchoMode(QQuickTextInput::EchoMode echo)
Qt::InputMethodHints QQuickTextInput::inputMethodHints() const
{
-#ifdef QT_NO_IM
+#if !QT_CONFIG(im)
return Qt::ImhNone;
#else
Q_D(const QQuickTextInput);
return d->inputMethodHints;
-#endif // QT_NO_IM
+#endif // im
}
void QQuickTextInput::setInputMethodHints(Qt::InputMethodHints hints)
{
-#ifdef QT_NO_IM
+#if !QT_CONFIG(im)
Q_UNUSED(hints);
#else
Q_D(QQuickTextInput);
@@ -1270,7 +1271,7 @@ void QQuickTextInput::setInputMethodHints(Qt::InputMethodHints hints)
d->inputMethodHints = hints;
updateInputMethod(Qt::ImHints);
emit inputMethodHintsChanged();
-#endif // QT_NO_IM
+#endif // im
}
/*!
@@ -1319,7 +1320,7 @@ QRectF QQuickTextInput::positionToRectangle(int pos) const
Q_D(const QQuickTextInput);
if (d->m_echoMode == NoEcho)
pos = 0;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
else if (pos > d->m_cursor)
pos += d->preeditAreaText().length();
#endif
@@ -1389,7 +1390,7 @@ void QQuickTextInput::positionAt(QQmlV4Function *args) const
int pos = d->positionAt(x, y, position);
const int cursor = d->m_cursor;
if (pos > cursor) {
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
const int preeditLength = d->preeditAreaText().length();
pos = pos > cursor + preeditLength
? pos - preeditLength
@@ -1470,7 +1471,7 @@ void QQuickTextInput::keyPressEvent(QKeyEvent* ev)
QQuickImplicitSizeItem::keyPressEvent(ev);
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
void QQuickTextInput::inputMethodEvent(QInputMethodEvent *ev)
{
Q_D(QQuickTextInput);
@@ -1493,7 +1494,7 @@ void QQuickTextInput::mouseDoubleClickEvent(QMouseEvent *event)
Q_D(QQuickTextInput);
if (d->selectByMouse && event->button() == Qt::LeftButton) {
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
d->commitPreedit();
#endif
int cursor = d->positionAt(event->localPos());
@@ -1549,7 +1550,7 @@ void QQuickTextInput::mouseMoveEvent(QMouseEvent *event)
if (qAbs(int(event->localPos().x() - d->pressPos.x())) > QGuiApplication::styleHints()->startDragDistance())
setKeepMouseGrab(true);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (d->composeMode()) {
// start selection
int startPos = d->positionAt(d->pressPos);
@@ -1576,7 +1577,7 @@ void QQuickTextInput::mouseReleaseEvent(QMouseEvent *event)
d->selectPressed = false;
setKeepMouseGrab(false);
}
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
if (QGuiApplication::clipboard()->supportsSelection()) {
if (event->button() == Qt::LeftButton) {
d->copy(QClipboard::Selection);
@@ -1596,7 +1597,7 @@ void QQuickTextInput::mouseReleaseEvent(QMouseEvent *event)
bool QQuickTextInputPrivate::sendMouseEventToInputContext(QMouseEvent *event)
{
-#if !defined QT_NO_IM
+#if QT_CONFIG(im)
if (composeMode()) {
int tmp_cursor = positionAt(event->localPos());
int mousePos = tmp_cursor - m_cursor;
@@ -1623,7 +1624,7 @@ void QQuickTextInput::mouseUngrabEvent()
bool QQuickTextInput::event(QEvent* ev)
{
-#ifndef QT_NO_SHORTCUT
+#if QT_CONFIG(shortcut)
Q_D(QQuickTextInput);
if (ev->type() == QEvent::ShortcutOverride) {
if (d->m_readOnly)
@@ -1723,7 +1724,7 @@ void QQuickTextInputPrivate::ensureVisible(int position, int preeditCursor, int
// left
hscroll = width - widthUsed;
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (preeditLength > 0) {
// check to ensure long pre-edit text doesn't push the cursor
// off to the left
@@ -1740,7 +1741,7 @@ void QQuickTextInputPrivate::ensureVisible(int position, int preeditCursor, int
void QQuickTextInputPrivate::updateHorizontalScroll()
{
if (autoScroll && m_echoMode != QQuickTextInput::NoEcho) {
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
const int preeditLength = m_textLayout.preeditAreaText().length();
ensureVisible(m_cursor, m_preeditCursor, preeditLength);
#else
@@ -1754,7 +1755,7 @@ void QQuickTextInputPrivate::updateHorizontalScroll()
void QQuickTextInputPrivate::updateVerticalScroll()
{
Q_Q(QQuickTextInput);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
const int preeditLength = m_textLayout.preeditAreaText().length();
#endif
const qreal height = qMax<qreal>(0, q->height() - q->topPadding() - q->bottomPadding());
@@ -1766,7 +1767,7 @@ void QQuickTextInputPrivate::updateVerticalScroll()
vscroll = -QQuickTextUtil::alignedY(
heightUsed, height, vAlign & ~(Qt::AlignAbsolute|Qt::AlignHorizontal_Mask));
} else {
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
QTextLine currentLine = m_textLayout.lineForTextPosition(m_cursor + preeditLength);
#else
QTextLine currentLine = m_textLayout.lineForTextPosition(m_cursor);
@@ -1786,7 +1787,7 @@ void QQuickTextInputPrivate::updateVerticalScroll()
// right
vscroll = heightUsed - height;
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (preeditLength > 0) {
// check to ensure long pre-edit text doesn't push the cursor
// off the top
@@ -1827,7 +1828,7 @@ void QQuickTextInput::ensureActiveFocus()
{
bool hadActiveFocus = hasActiveFocus();
forceActiveFocus();
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
Q_D(QQuickTextInput);
// re-open input panel on press if already focused
if (hasActiveFocus() && hadActiveFocus && !d->m_readOnly)
@@ -1877,7 +1878,7 @@ QSGNode *QQuickTextInput::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
}
if (!d->m_textLayout.text().isEmpty()
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
|| !d->m_textLayout.preeditAreaText().isEmpty()
#endif
) {
@@ -1900,7 +1901,7 @@ QSGNode *QQuickTextInput::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
return node;
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
QVariant QQuickTextInput::inputMethodQuery(Qt::InputMethodQuery property) const
{
return inputMethodQuery(property, QVariant());
@@ -1957,7 +1958,7 @@ QVariant QQuickTextInput::inputMethodQuery(Qt::InputMethodQuery property, QVaria
return QQuickItem::inputMethodQuery(property);
}
}
-#endif // QT_NO_IM
+#endif // im
/*!
\qmlmethod QtQuick::TextInput::deselect()
@@ -1997,7 +1998,7 @@ bool QQuickTextInput::isRightToLeft(int start, int end)
}
}
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
/*!
\qmlmethod QtQuick::TextInput::cut()
@@ -2042,7 +2043,7 @@ void QQuickTextInput::paste()
if (!d->m_readOnly)
d->paste();
}
-#endif // QT_NO_CLIPBOARD
+#endif // clipboard
/*!
\qmlmethod QtQuick::TextInput::undo()
@@ -2416,7 +2417,7 @@ void QQuickTextInput::setPersistentSelection(bool on)
*/
bool QQuickTextInput::canPaste() const
{
-#if !defined(QT_NO_CLIPBOARD)
+#if QT_CONFIG(clipboard)
Q_D(const QQuickTextInput);
if (!d->canPasteValid) {
if (const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData())
@@ -2597,7 +2598,7 @@ void QQuickTextInputPrivate::handleFocusEvent(QFocusEvent *event)
}
if (focus) {
q->q_updateAlignment();
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (focusOnPress && !m_readOnly)
qGuiApp->inputMethod()->show();
q->connect(QGuiApplication::inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)),
@@ -2617,7 +2618,7 @@ void QQuickTextInputPrivate::handleFocusEvent(QFocusEvent *event)
if (hasAcceptableInput(m_text) == AcceptableInput || fixup())
emit q->editingFinished();
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
q->disconnect(QGuiApplication::inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)),
q, SLOT(q_updateAlignment()));
#endif
@@ -2645,7 +2646,7 @@ void QQuickTextInput::focusOutEvent(QFocusEvent *event)
*/
bool QQuickTextInput::isInputMethodComposing() const
{
-#ifdef QT_NO_IM
+#if !QT_CONFIG(im)
return false;
#else
Q_D(const QQuickTextInput);
@@ -2670,21 +2671,21 @@ QQuickTextInputPrivate::ExtraData::ExtraData()
void QQuickTextInputPrivate::init()
{
Q_Q(QQuickTextInput);
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
if (QGuiApplication::clipboard()->supportsSelection())
q->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton);
else
#endif
q->setAcceptedMouseButtons(Qt::LeftButton);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
q->setFlag(QQuickItem::ItemAcceptsInputMethod);
#endif
q->setFlag(QQuickItem::ItemHasContents);
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
qmlobject_connect(QGuiApplication::clipboard(), QClipboard, SIGNAL(dataChanged()),
q, QQuickTextInput, SLOT(q_canPasteChanged()));
-#endif // QT_NO_CLIPBOARD
+#endif // clipboard
lastSelectionStart = 0;
lastSelectionEnd = 0;
@@ -2695,6 +2696,8 @@ void QQuickTextInputPrivate::init()
option.setUseDesignMetrics(renderType != QQuickTextInput::NativeRendering);
m_textLayout.setTextOption(option);
}
+
+ m_inputControl = new QInputControl(QInputControl::LineEdit, q);
}
void QQuickTextInputPrivate::resetInputMethod()
@@ -2723,7 +2726,7 @@ void QQuickTextInput::updateCursorRectangle(bool scroll)
d->cursorItem->setPosition(r.topLeft());
d->cursorItem->setHeight(r.height());
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
updateInputMethod(Qt::ImCursorRectangle | Qt::ImAnchorRectangle);
#endif
}
@@ -2783,7 +2786,7 @@ void QQuickTextInput::q_canPasteChanged()
{
Q_D(QQuickTextInput);
bool old = d->canPaste;
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
if (const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData())
d->canPaste = !d->m_readOnly && mimeData->hasText();
else
@@ -2877,7 +2880,7 @@ qreal QQuickTextInputPrivate::getImplicitWidth() const
option.setAlignment(Qt::Alignment(q->effectiveHAlign()));
layout.setTextOption(option);
layout.setFont(font);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
layout.setPreeditArea(m_textLayout.preeditAreaPosition(), m_textLayout.preeditAreaText());
#endif
layout.beginLayout();
@@ -3054,7 +3057,7 @@ void QQuickTextInputPrivate::updateBaselineOffset()
q->setBaselineOffset(fm.ascent() + yoff + q->topPadding());
}
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
/*!
\internal
@@ -3091,9 +3094,9 @@ void QQuickTextInputPrivate::paste(QClipboard::Mode clipboardMode)
}
}
-#endif // !QT_NO_CLIPBOARD
+#endif // clipboard
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
/*!
\internal
*/
@@ -3125,7 +3128,7 @@ void QQuickTextInputPrivate::cancelPreedit()
QInputMethodEvent ev;
QCoreApplication::sendEvent(q, &ev);
}
-#endif // QT_NO_IM
+#endif // im
/*!
\internal
@@ -3225,7 +3228,7 @@ void QQuickTextInputPrivate::clear()
void QQuickTextInputPrivate::setSelection(int start, int length)
{
Q_Q(QQuickTextInput);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
commitPreedit();
#endif
@@ -3257,7 +3260,7 @@ void QQuickTextInputPrivate::setSelection(int start, int length)
}
emit q->selectionChanged();
emitCursorPositionChanged();
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
q->updateInputMethod(Qt::ImCursorRectangle | Qt::ImAnchorRectangle | Qt::ImCursorPosition | Qt::ImAnchorPosition
| Qt::ImCurrentSelection);
#endif
@@ -3287,7 +3290,7 @@ void QQuickTextInputPrivate::updatePasswordEchoEditing(bool editing)
*/
bool QQuickTextInputPrivate::fixup() // this function assumes that validate currently returns != Acceptable
{
-#ifndef QT_NO_VALIDATOR
+#if QT_CONFIG(validator)
if (m_validator) {
QString textCopy = m_text;
int cursorCopy = m_cursor;
@@ -3311,7 +3314,7 @@ bool QQuickTextInputPrivate::fixup() // this function assumes that validate curr
void QQuickTextInputPrivate::moveCursor(int pos, bool mark)
{
Q_Q(QQuickTextInput);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
commitPreedit();
#endif
@@ -3339,12 +3342,12 @@ void QQuickTextInputPrivate::moveCursor(int pos, bool mark)
emit q->selectionChanged();
}
emitCursorPositionChanged();
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
q->updateInputMethod();
#endif
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
/*!
\internal
@@ -3461,7 +3464,7 @@ void QQuickTextInputPrivate::processInputMethodEvent(QInputMethodEvent *event)
| Qt::ImCurrentSelection);
}
}
-#endif // QT_NO_IM
+#endif // im
/*!
\internal
@@ -3501,7 +3504,7 @@ bool QQuickTextInputPrivate::finishChange(int validateFromState, bool update, bo
Q_Q(QQuickTextInput);
Q_UNUSED(update)
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
bool inputMethodAttributesChanged = m_textDirty || m_selDirty;
#endif
bool alignmentChanged = false;
@@ -3513,7 +3516,7 @@ bool QQuickTextInputPrivate::finishChange(int validateFromState, bool update, bo
bool wasAcceptable = m_acceptableInput;
m_validInput = true;
m_acceptableInput = true;
-#ifndef QT_NO_VALIDATOR
+#if QT_CONFIG(validator)
if (m_validator) {
QString textCopy = m_text;
int cursorCopy = m_cursor;
@@ -3563,7 +3566,7 @@ bool QQuickTextInputPrivate::finishChange(int validateFromState, bool update, bo
if (m_textDirty) {
textChanged = true;
m_textDirty = false;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
m_preeditDirty = false;
#endif
alignmentChanged = determineHorizontalAlignment();
@@ -3575,7 +3578,7 @@ bool QQuickTextInputPrivate::finishChange(int validateFromState, bool update, bo
if (m_acceptableInput != wasAcceptable)
emit q->acceptableInputChanged();
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (m_preeditDirty) {
m_preeditDirty = false;
if (determineHorizontalAlignment()) {
@@ -3590,7 +3593,7 @@ bool QQuickTextInputPrivate::finishChange(int validateFromState, bool update, bo
emit q->selectionChanged();
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
inputMethodAttributesChanged |= (m_cursor != m_lastCursorPos);
if (inputMethodAttributesChanged)
q->updateInputMethod();
@@ -3624,7 +3627,7 @@ void QQuickTextInputPrivate::internalSetText(const QString &txt, int pos, bool e
m_textDirty = (oldText != m_text);
bool changed = finishChange(-1, true, edited);
-#ifdef QT_NO_ACCESSIBILITY
+#if !QT_CONFIG(accessibility)
Q_UNUSED(changed)
#else
Q_Q(QQuickTextInput);
@@ -3970,7 +3973,7 @@ bool QQuickTextInputPrivate::isValidInput(QChar key, QChar mask) const
*/
QQuickTextInputPrivate::ValidatorState QQuickTextInputPrivate::hasAcceptableInput(const QString &str) const
{
-#ifndef QT_NO_VALIDATOR
+#if QT_CONFIG(validator)
QString textCopy = str;
int cursorCopy = m_cursor;
if (m_validator) {
@@ -4280,7 +4283,7 @@ bool QQuickTextInputPrivate::emitCursorPositionChanged()
}
}
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
if (QAccessible::isActive()) {
if (QObject *acc = QQuickAccessibleAttached::findAccessible(q, QAccessible::EditableText)) {
QAccessibleTextCursorEvent ev(acc, m_cursor);
@@ -4391,7 +4394,7 @@ void QQuickTextInputPrivate::processKeyEvent(QKeyEvent* event)
if (false) {
}
-#ifndef QT_NO_SHORTCUT
+#if QT_CONFIG(shortcut)
else if (event == QKeySequence::Undo) {
q->undo();
}
@@ -4401,7 +4404,7 @@ void QQuickTextInputPrivate::processKeyEvent(QKeyEvent* event)
else if (event == QKeySequence::SelectAll) {
selectAll();
}
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
else if (event == QKeySequence::Copy) {
copy();
}
@@ -4418,7 +4421,7 @@ void QQuickTextInputPrivate::processKeyEvent(QKeyEvent* event)
if (!m_readOnly)
deleteEndOfLine();
}
-#endif //QT_NO_CLIPBOARD
+#endif // clipboard
else if (event == QKeySequence::MoveToStartOfLine || event == QKeySequence::MoveToStartOfBlock) {
home(0);
}
@@ -4490,13 +4493,13 @@ void QQuickTextInputPrivate::processKeyEvent(QKeyEvent* event)
} else if (event == QKeySequence::DeleteCompleteLine) {
if (!m_readOnly) {
selectAll();
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
copy();
#endif
del();
}
}
-#endif // QT_NO_SHORTCUT
+#endif // shortcut
else {
bool handled = false;
if (event->modifiers() & Qt::ControlModifier) {
@@ -4529,8 +4532,7 @@ void QQuickTextInputPrivate::processKeyEvent(QKeyEvent* event)
}
if (unknown && !m_readOnly) {
- QString t = event->text();
- if (!t.isEmpty() && t.at(0).isPrint()) {
+ if (m_inputControl->isAcceptableInput(event)) {
if (overwriteMode
// no need to call del() if we have a selection, insert
// does it already
@@ -4539,7 +4541,7 @@ void QQuickTextInputPrivate::processKeyEvent(QKeyEvent* event)
del();
}
- insert(t);
+ insert(event->text());
event->accept();
return;
}
diff --git a/src/quick/items/qquicktextinput_p.h b/src/quick/items/qquicktextinput_p.h
index d0461f551e..f4545e1574 100644
--- a/src/quick/items/qquicktextinput_p.h
+++ b/src/quick/items/qquicktextinput_p.h
@@ -266,7 +266,7 @@ public:
bool hasAcceptableInput() const;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
QVariant inputMethodQuery(Qt::InputMethodQuery property) const Q_DECL_OVERRIDE;
Q_REVISION(3) Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const;
#endif
@@ -372,7 +372,7 @@ protected:
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void keyPressEvent(QKeyEvent* ev) Q_DECL_OVERRIDE;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
void inputMethodEvent(QInputMethodEvent *) Q_DECL_OVERRIDE;
#endif
void mouseUngrabEvent() Q_DECL_OVERRIDE;
@@ -389,7 +389,7 @@ public Q_SLOTS:
void select(int start, int end);
void deselect();
bool isRightToLeft(int start, int end);
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void cut();
void copy();
void paste();
@@ -409,7 +409,7 @@ private Q_SLOTS:
void q_updateAlignment();
void triggerPreprocess();
-#ifndef QT_NO_VALIDATOR
+#if QT_CONFIG(validator)
void q_validatorChanged();
#endif
diff --git a/src/quick/items/qquicktextinput_p_p.h b/src/quick/items/qquicktextinput_p_p.h
index 93a8778c40..0bf5779a53 100644
--- a/src/quick/items/qquicktextinput_p_p.h
+++ b/src/quick/items/qquicktextinput_p_p.h
@@ -70,6 +70,7 @@
QT_BEGIN_NAMESPACE
class QQuickTextNode;
+class QInputControl;
class Q_QUICK_PRIVATE_EXPORT QQuickTextInputPrivate : public QQuickImplicitSizeItemPrivate
{
@@ -104,7 +105,7 @@ public:
, selectionColor(QRgb(0xFF000080))
, selectedTextColor(QRgb(0xFFFFFFFF))
, m_cursor(0)
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
, m_preeditCursor(0)
#endif
, m_blinkEnabled(false)
@@ -114,7 +115,7 @@ public:
, m_undoState(0)
, m_selstart(0)
, m_selend(0)
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
, inputMethodHints(Qt::ImhNone)
#endif
, hAlign(QQuickTextInput::AlignLeft)
@@ -148,7 +149,7 @@ public:
, m_separator(0)
, m_readOnly(0)
, m_textDirty(0)
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
, m_preeditDirty(0)
#endif
, m_selDirty(0)
@@ -176,7 +177,7 @@ public:
bool setHAlign(QQuickTextInput::HAlignment, bool forceAlign = false);
void mirrorChange() Q_DECL_OVERRIDE;
bool sendMouseEventToInputContext(QMouseEvent *event);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
Qt::InputMethodHints effectiveInputMethodHints() const;
#endif
void handleFocusEvent(QFocusEvent *event);
@@ -211,7 +212,7 @@ public:
QPointF tripleClickStartPoint;
QPointer<QQmlComponent> cursorComponent;
-#ifndef QT_NO_VALIDATOR
+#if QT_CONFIG(validator)
QPointer<QValidator> m_validator;
#endif
@@ -228,6 +229,7 @@ public:
QQuickItem *cursorItem;
QQuickTextNode *textNode;
MaskInputData *m_maskData;
+ QInputControl *m_inputControl;
QList<int> m_transactions;
QVector<Command> m_history;
@@ -240,7 +242,7 @@ public:
int lastSelectionStart;
int lastSelectionEnd;
int m_cursor;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
int m_preeditCursor;
#endif
bool m_blinkEnabled;
@@ -257,7 +259,7 @@ public:
UpdatePaintNode
};
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
Qt::InputMethodHints inputMethodHints;
#endif
QQuickTextInput::HAlignment hAlign;
@@ -290,7 +292,7 @@ public:
bool m_separator : 1;
bool m_readOnly : 1;
bool m_textDirty : 1;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
bool m_preeditDirty : 1;
#endif
bool m_selDirty : 1;
@@ -362,12 +364,12 @@ public:
QString realText() const;
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void copy(QClipboard::Mode mode = QClipboard::Clipboard) const;
void paste(QClipboard::Mode mode = QClipboard::Clipboard);
#endif
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
void commitPreedit();
void cancelPreedit();
#endif
@@ -419,7 +421,7 @@ public:
}
// input methods
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
bool composeMode() const { return !m_textLayout.preeditAreaText().isEmpty(); }
QString preeditAreaText() const { return m_textLayout.preeditAreaText(); }
@@ -441,7 +443,7 @@ public:
}
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
void processInputMethodEvent(QInputMethodEvent *event);
#endif
void processKeyEvent(QKeyEvent* ev);
@@ -496,7 +498,7 @@ private:
void deleteEndOfLine();
enum ValidatorState {
-#ifndef QT_NO_VALIDATOR
+#if QT_CONFIG(validator)
InvalidInput = QValidator::Invalid,
IntermediateInput = QValidator::Intermediate,
AcceptableInput = QValidator::Acceptable
diff --git a/src/quick/items/qquicktextnode.cpp b/src/quick/items/qquicktextnode.cpp
index 8716f98bff..cf4e71adf5 100644
--- a/src/quick/items/qquicktextnode.cpp
+++ b/src/quick/items/qquicktextnode.cpp
@@ -99,10 +99,12 @@ QSGGlyphNode *QQuickTextNode::addGlyphs(const QPointF &position, const QGlyphRun
bool preferNativeGlyphNode = m_useNativeRenderer;
if (!preferNativeGlyphNode) {
QRawFontPrivate *fontPriv = QRawFontPrivate::get(font);
- if (fontPriv->fontEngine->hasUnreliableGlyphOutline())
+ if (fontPriv->fontEngine->hasUnreliableGlyphOutline()) {
preferNativeGlyphNode = true;
- else
- preferNativeGlyphNode = !QFontDatabase().isSmoothlyScalable(font.familyName(), font.styleName());
+ } else {
+ QFontEngine *fe = QRawFontPrivate::get(font)->fontEngine;
+ preferNativeGlyphNode = !fe->isSmoothlyScalable;
+ }
}
QSGGlyphNode *node = sg->sceneGraphContext()->createGlyphNode(sg, preferNativeGlyphNode);
@@ -160,18 +162,14 @@ void QQuickTextNode::addImage(const QRectF &rect, const QImage &image)
QSGRenderContext *sg = QQuickItemPrivate::get(m_ownerElement)->sceneGraphRenderContext();
QSGInternalImageNode *node = sg->sceneGraphContext()->createInternalImageNode();
QSGTexture *texture = sg->createTexture(image);
- if (m_ownerElement->smooth()) {
+ if (m_ownerElement->smooth())
texture->setFiltering(QSGTexture::Linear);
- texture->setMipmapFiltering(QSGTexture::Linear);
- }
m_textures.append(texture);
node->setTargetRect(rect);
node->setInnerTargetRect(rect);
node->setTexture(texture);
- if (m_ownerElement->smooth()) {
+ if (m_ownerElement->smooth())
node->setFiltering(QSGTexture::Linear);
- node->setMipmapFiltering(QSGTexture::Linear);
- }
appendChildNode(node);
node->update();
}
@@ -239,7 +237,7 @@ void QQuickTextNode::addTextLayout(const QPointF &position, QTextLayout *textLay
engine.setAnchorColor(anchorColor);
engine.setPosition(position);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
int preeditLength = textLayout->preeditAreaText().length();
int preeditPosition = textLayout->preeditAreaPosition();
#endif
@@ -258,7 +256,7 @@ void QQuickTextNode::addTextLayout(const QPointF &position, QTextLayout *textLay
int length = line.textLength();
int end = start + length;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (preeditPosition >= 0
&& preeditPosition >= start
&& preeditPosition < end) {
diff --git a/src/quick/items/qquicktextnodeengine.cpp b/src/quick/items/qquicktextnodeengine.cpp
index 4631b2e724..c179ab7163 100644
--- a/src/quick/items/qquicktextnodeengine.cpp
+++ b/src/quick/items/qquicktextnodeengine.cpp
@@ -423,7 +423,10 @@ void QQuickTextNodeEngine::addImage(const QRectF &rect, const QImage &image, qre
QRectF searchRect = rect;
if (layoutPosition == QTextFrameFormat::InFlow) {
if (m_currentLineTree.isEmpty()) {
- searchRect.moveTopLeft(m_position + m_currentLine.position() + QPointF(0,1));
+ if (m_currentTextDirection == Qt::RightToLeft)
+ searchRect.moveTopRight(m_position + m_currentLine.rect().topRight() + QPointF(0, 1));
+ else
+ searchRect.moveTopLeft(m_position + m_currentLine.position() + QPointF(0,1));
} else {
const BinaryTreeNode *lastNode = m_currentLineTree.data() + m_currentLineTree.size() - 1;
if (lastNode->glyphRun.isRightToLeft()) {
@@ -947,11 +950,13 @@ void QQuickTextNodeEngine::mergeFormats(QTextLayout *textLayout, QVarLengthArray
void QQuickTextNodeEngine::addTextBlock(QTextDocument *textDocument, const QTextBlock &block, const QPointF &position, const QColor &textColor, const QColor &anchorColor, int selectionStart, int selectionEnd)
{
Q_ASSERT(textDocument);
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
int preeditLength = block.isValid() ? block.layout()->preeditAreaText().length() : 0;
int preeditPosition = block.isValid() ? block.layout()->preeditAreaPosition() : -1;
#endif
+ setCurrentTextDirection(block.textDirection());
+
QVarLengthArray<QTextLayout::FormatRange> colorChanges;
mergeFormats(block.layout(), &colorChanges);
@@ -1065,7 +1070,7 @@ void QQuickTextNodeEngine::addTextBlock(QTextDocument *textDocument, const QText
setTextColor(textColor);
int fragmentEnd = textPos + fragment.length();
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (preeditPosition >= 0
&& (preeditPosition + block.position()) >= textPos
&& (preeditPosition + block.position()) <= fragmentEnd) {
@@ -1087,7 +1092,7 @@ void QQuickTextNodeEngine::addTextBlock(QTextDocument *textDocument, const QText
++blockIterator;
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (preeditLength >= 0 && textPos <= block.position() + preeditPosition) {
setPosition(blockPosition);
textPos = block.position() + preeditPosition;
diff --git a/src/quick/items/qquicktextnodeengine_p.h b/src/quick/items/qquicktextnodeengine_p.h
index 91ed6f4430..18c624513a 100644
--- a/src/quick/items/qquicktextnodeengine_p.h
+++ b/src/quick/items/qquicktextnodeengine_p.h
@@ -144,7 +144,11 @@ public:
int selectionState;
};
- QQuickTextNodeEngine() : m_hasSelection(false), m_hasContents(false) {}
+ QQuickTextNodeEngine()
+ : m_currentTextDirection(Qt::LeftToRight)
+ , m_hasSelection(false)
+ , m_hasContents(false)
+ {}
bool hasContents() const { return m_hasContents; }
void addTextBlock(QTextDocument *, const QTextBlock &, const QPointF &position, const QColor &textColor, const QColor& anchorColor, int selectionStart, int selectionEnd);
@@ -158,6 +162,11 @@ public:
m_currentLine = currentLine;
}
+ void setCurrentTextDirection(Qt::LayoutDirection textDirection)
+ {
+ m_currentTextDirection = textDirection;
+ }
+
void addBorder(const QRectF &rect, qreal border, QTextFrameFormat::BorderStyle borderStyle,
const QBrush &borderBrush);
void addFrameDecorations(QTextDocument *document, QTextFrame *frame);
@@ -247,6 +256,7 @@ private:
QPointF m_position;
QTextLine m_currentLine;
+ Qt::LayoutDirection m_currentTextDirection;
QList<QPair<QRectF, QColor> > m_backgrounds;
QList<QRectF> m_selectionRects;
diff --git a/src/quick/items/qquickview.cpp b/src/quick/items/qquickview.cpp
index a167f01484..573440ff7f 100644
--- a/src/quick/items/qquickview.cpp
+++ b/src/quick/items/qquickview.cpp
@@ -111,14 +111,14 @@ void QQuickViewPrivate::execute()
}
void QQuickViewPrivate::itemGeometryChanged(QQuickItem *resizeItem, QQuickGeometryChange change,
- const QRectF &diff)
+ const QRectF &oldGeometry)
{
Q_Q(QQuickView);
if (resizeItem == root && resizeMode == QQuickView::SizeViewToRootObject) {
// wait for both width and height to be changed
resizetimer.start(0,q);
}
- QQuickItemChangeListener::itemGeometryChanged(resizeItem, change, diff);
+ QQuickItemChangeListener::itemGeometryChanged(resizeItem, change, oldGeometry);
}
/*!
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 8a90afe113..96c2937038 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -63,7 +63,6 @@
#include <QtGui/qpainter.h>
#include <QtGui/qevent.h>
#include <QtGui/qmatrix4x4.h>
-#include <QtGui/qstylehints.h>
#include <QtCore/qvarlengtharray.h>
#include <QtCore/qabstractanimation.h>
#include <QtCore/QLibraryInfo>
@@ -75,7 +74,7 @@
#include <private/qqmlmemoryprofiler_p.h>
#include <private/qqmldebugserviceinterfaces_p.h>
#include <private/qqmldebugconnector_p.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <private/qopenglvertexarrayobject_p.h>
# include <private/qsgdefaultrendercontext_p.h>
#endif
@@ -96,7 +95,7 @@ bool QQuickWindowPrivate::defaultAlphaBuffer = false;
void QQuickWindowPrivate::updateFocusItemTransform()
{
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
Q_Q(QQuickWindow);
QQuickItem *focus = q->activeFocusItem();
if (focus && QGuiApplication::focusObject() == focus) {
@@ -173,7 +172,7 @@ private:
#include "qquickwindow.moc"
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
/*!
Returns an accessibility interface for this window, or 0 if such an
interface cannot be created.
@@ -257,7 +256,7 @@ void QQuickWindow::focusInEvent(QFocusEvent *ev)
d->updateFocusItemTransform();
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
static bool transformDirtyOnItemOrAncestor(const QQuickItem *item)
{
while (item) {
@@ -298,7 +297,7 @@ void QQuickWindowPrivate::polishItems()
if (recursionSafeguard == 0)
qWarning("QQuickWindow: possible QQuickItem::polish() loop");
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (QQuickItem *focusItem = q_func()->activeFocusItem()) {
// If the current focus item, or any of its anchestors, has changed location
// inside the window, we need inform IM about it. This to ensure that overlays
@@ -455,13 +454,15 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size)
fboId = renderTargetId;
renderer->setDeviceRect(rect);
renderer->setViewportRect(rect);
+ renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), rect.size()));
+ renderer->setDevicePixelRatio(1);
} else {
QRect rect(QPoint(0, 0), devicePixelRatio * size);
renderer->setDeviceRect(rect);
renderer->setViewportRect(rect);
+ renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size));
+ renderer->setDevicePixelRatio(devicePixelRatio);
}
- renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size));
- renderer->setDevicePixelRatio(devicePixelRatio);
context->renderNextFrame(renderer, fboId);
}
@@ -472,10 +473,10 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size)
QQuickWindowPrivate::QQuickWindowPrivate()
: contentItem(0)
, activeFocusItem(0)
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
, cursorItem(0)
#endif
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
, dragGrabber(0)
#endif
, touchMouseId(-1)
@@ -501,7 +502,7 @@ QQuickWindowPrivate::QQuickWindowPrivate()
, vaoHelper(0)
, incubationController(0)
{
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
dragGrabber = new QQuickDragGrabber;
#endif
}
@@ -897,7 +898,7 @@ void QQuickWindowPrivate::setFocusInScope(QQuickItem *scope, QQuickItem *item, Q
}
if (oldActiveFocusItem) {
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
QGuiApplication::inputMethod()->commit();
#endif
@@ -1003,7 +1004,7 @@ void QQuickWindowPrivate::clearFocusInScope(QQuickItem *scope, QQuickItem *item,
oldActiveFocusItem = activeFocusItem;
newActiveFocusItem = scope;
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
QGuiApplication::inputMethod()->commit();
#endif
@@ -1279,7 +1280,7 @@ QQuickWindow::~QQuickWindow()
}
delete d->incubationController; d->incubationController = 0;
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
delete d->dragGrabber; d->dragGrabber = 0;
#endif
delete d->contentItem; d->contentItem = 0;
@@ -1548,7 +1549,7 @@ bool QQuickWindow::event(QEvent *e)
d->clearHover();
d->lastMousePosition = QPointF();
break;
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
case QEvent::DragEnter:
case QEvent::DragLeave:
case QEvent::DragMove:
@@ -1568,7 +1569,7 @@ bool QQuickWindow::event(QEvent *e)
e->setAccepted(qev.isAccepted());
} break;
case QEvent::FocusAboutToChange:
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
if (d->activeFocusItem)
qGuiApp->inputMethod()->commit();
#endif
@@ -1580,7 +1581,7 @@ bool QQuickWindow::event(QEvent *e)
d->windowManager->handleUpdateRequest(this);
break;
}
-#ifndef QT_NO_GESTURES
+#if QT_CONFIG(gestures)
case QEvent::NativeGesture:
d->deliverNativeGestureEvent(d->contentItem, static_cast<QNativeGestureEvent*>(e));
break;
@@ -1783,7 +1784,7 @@ bool QQuickWindowPrivate::deliverHoverEvent(QQuickItem *item, const QPointF &sce
return false;
}
-#ifndef QT_NO_WHEELEVENT
+#if QT_CONFIG(wheelevent)
bool QQuickWindowPrivate::deliverWheelEvent(QQuickItem *item, QWheelEvent *event)
{
QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
@@ -1837,9 +1838,9 @@ void QQuickWindow::wheelEvent(QWheelEvent *event)
d->deliverWheelEvent(d->contentItem, event);
d->lastWheelEventAccepted = event->isAccepted();
}
-#endif // QT_NO_WHEELEVENT
+#endif // wheelevent
-#ifndef QT_NO_GESTURES
+#if QT_CONFIG(gestures)
bool QQuickWindowPrivate::deliverNativeGestureEvent(QQuickItem *item, QNativeGestureEvent *event)
{
QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
@@ -1871,7 +1872,7 @@ bool QQuickWindowPrivate::deliverNativeGestureEvent(QQuickItem *item, QNativeGes
return false;
}
-#endif // QT_NO_GESTURES
+#endif // gestures
bool QQuickWindowPrivate::deliverTouchCancelEvent(QTouchEvent *event)
{
@@ -2054,7 +2055,7 @@ void QQuickWindowPrivate::handleMouseEvent(QMouseEvent *event)
qCDebug(DBG_HOVER_TRACE) << this;
- #ifndef QT_NO_CURSOR
+ #if QT_CONFIG(cursor)
updateCursor(event->windowPos());
#endif
@@ -2380,7 +2381,7 @@ bool QQuickWindowPrivate::deliverMatchingPointsToItem(QQuickItem *item, QQuickPo
return eventAccepted;
}
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
void QQuickWindowPrivate::deliverDragEvent(QQuickDragGrabber *grabber, QEvent *event)
{
grabber->resetTarget();
@@ -2501,9 +2502,9 @@ bool QQuickWindowPrivate::deliverDragEvent(QQuickDragGrabber *grabber, QQuickIte
return accepted;
}
-#endif // QT_NO_DRAGANDDROP
+#endif // draganddrop
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
void QQuickWindowPrivate::updateCursor(const QPointF &scenePos)
{
Q_Q(QQuickWindow);
@@ -2660,24 +2661,6 @@ bool QQuickWindowPrivate::dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent
return overThreshold;
}
-bool QQuickWindowPrivate::dragOverThreshold(qreal d, Qt::Axis axis, const QTouchEvent::TouchPoint *tp, int startDragThreshold)
-{
- QStyleHints *styleHints = qApp->styleHints();
- bool overThreshold = qAbs(d) > (startDragThreshold >= 0 ? startDragThreshold : styleHints->startDragDistance());
- qreal velocity = axis == Qt::XAxis ? tp->velocity().x() : tp->velocity().y();
- overThreshold |= qAbs(velocity) > styleHints->startDragVelocity();
- return overThreshold;
-}
-
-bool QQuickWindowPrivate::dragOverThreshold(qreal d, Qt::Axis axis, const QQuickEventPoint *p, int startDragThreshold)
-{
- QStyleHints *styleHints = qApp->styleHints();
- bool overThreshold = qAbs(d) > (startDragThreshold >= 0 ? startDragThreshold : styleHints->startDragDistance());
- qreal velocity = axis == Qt::XAxis ? p->velocity().x() : p->velocity().y();
- overThreshold |= qAbs(velocity) > styleHints->startDragVelocity();
- return overThreshold;
-}
-
/*!
\qmlproperty list<Object> Window::data
\default
@@ -3156,10 +3139,12 @@ void QQuickWindowPrivate::updateDirtyNode(QQuickItem *item)
if (itemPriv->paintNode && itemPriv->paintNode->parent() == 0) {
QSGNode *before = qquickitem_before_paintNode(itemPriv);
- if (before)
+ if (before && before->parent()) {
+ Q_ASSERT(before->parent() == itemPriv->childContainerNode());
itemPriv->childContainerNode()->insertChildNodeAfter(itemPriv->paintNode, before);
- else
+ } else {
itemPriv->childContainerNode()->prependChildNode(itemPriv->paintNode);
+ }
}
} else if (itemPriv->paintNode) {
delete itemPriv->paintNode;
@@ -3213,7 +3198,7 @@ void QQuickWindow::maybeUpdate()
void QQuickWindow::cleanupSceneGraph()
{
Q_D(QQuickWindow);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
delete d->vaoHelper;
d->vaoHelper = 0;
#endif
@@ -3252,7 +3237,7 @@ void QQuickWindow::setTransientParent_helper(QQuickWindow *window)
QOpenGLContext *QQuickWindow::openglContext() const
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
Q_D(const QQuickWindow);
if (d->context && d->context->isValid()) {
QSGRendererInterface *rif = d->context->sceneGraphContext()->rendererInterface(d->context);
@@ -3380,7 +3365,7 @@ bool QQuickWindow::isSceneGraphInitialized() const
The corresponding handler is \c onClosing.
*/
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
/*!
Sets the render target for this window to be \a fbo.
@@ -3468,7 +3453,7 @@ QSize QQuickWindow::renderTargetSize() const
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
/*!
Returns the render target for this window.
@@ -3507,7 +3492,7 @@ QImage QQuickWindow::grabWindow()
return d->windowManager->grab(this);
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (!isVisible() && !d->renderControl) {
auto openglRenderContext = static_cast<QSGDefaultRenderContext *>(d->context);
if (!openglRenderContext->openglContext()) {
@@ -3865,7 +3850,7 @@ QSGTexture *QQuickWindow::createTextureFromImage(const QImage &image, CreateText
*/
QSGTexture *QQuickWindow::createTextureFromId(uint id, const QSize &size, CreateTextureOptions options) const
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (openglContext()) {
QSGPlainTexture *texture = new QSGPlainTexture();
texture->setTextureId(id);
@@ -3948,7 +3933,7 @@ void QQuickWindow::setDefaultAlphaBuffer(bool useAlpha)
{
QQuickWindowPrivate::defaultAlphaBuffer = useAlpha;
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
/*!
\since 5.2
diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h
index 7e1e45f345..27a73988ae 100644
--- a/src/quick/items/qquickwindow.h
+++ b/src/quick/items/qquickwindow.h
@@ -115,19 +115,19 @@ public:
bool sendEvent(QQuickItem *, QEvent *);
QImage grabWindow();
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
void setRenderTarget(QOpenGLFramebufferObject *fbo);
QOpenGLFramebufferObject *renderTarget() const;
#endif
void setRenderTarget(uint fboId, const QSize &size);
uint renderTargetId() const;
QSize renderTargetSize() const;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
void resetOpenGLState();
#endif
QQmlIncubationController *incubationController() const;
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
QAccessibleInterface *accessibleRoot() const Q_DECL_OVERRIDE;
#endif
@@ -209,7 +209,7 @@ protected:
void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;
void mouseDoubleClickEvent(QMouseEvent *) Q_DECL_OVERRIDE;
void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
-#ifndef QT_NO_WHEELEVENT
+#if QT_CONFIG(wheelevent)
void wheelEvent(QWheelEvent *) Q_DECL_OVERRIDE;
#endif
diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h
index cedfd765da..30e3b71d0a 100644
--- a/src/quick/items/qquickwindow_p.h
+++ b/src/quick/items/qquickwindow_p.h
@@ -66,6 +66,8 @@
#include <qopenglcontext.h>
#include <QtGui/qopenglframebufferobject.h>
#include <QtGui/qevent.h>
+#include <QtGui/qstylehints.h>
+#include <QtGui/qguiapplication.h>
QT_BEGIN_NAMESPACE
@@ -125,10 +127,10 @@ public:
void deliverKeyEvent(QKeyEvent *e);
// Keeps track of the item currently receiving mouse events
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
QQuickItem *cursorItem;
#endif
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
QQuickDragGrabber *dragGrabber;
#endif
int touchMouseId;
@@ -146,10 +148,10 @@ public:
static QMouseEvent *cloneMouseEvent(QMouseEvent *event, QPointF *transformedLocalPos = 0);
void deliverMouseEvent(QQuickPointerMouseEvent *pointerEvent);
bool sendFilteredMouseEvent(QQuickItem *, QQuickItem *, QEvent *, QSet<QQuickItem *> *);
-#ifndef QT_NO_WHEELEVENT
+#if QT_CONFIG(wheelevent)
bool deliverWheelEvent(QQuickItem *, QWheelEvent *);
#endif
-#ifndef QT_NO_GESTURES
+#if QT_CONFIG(gestures)
bool deliverNativeGestureEvent(QQuickItem *, QNativeGestureEvent *);
#endif
@@ -179,11 +181,11 @@ public:
Qt::KeyboardModifiers modifiers, ulong timestamp, bool accepted);
bool clearHover(ulong timestamp = 0);
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
void deliverDragEvent(QQuickDragGrabber *, QEvent *);
bool deliverDragEvent(QQuickDragGrabber *, QQuickItem *, QDragMoveEvent *);
#endif
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
void updateCursor(const QPointF &scenePos);
QQuickItem *findCursorItem(QQuickItem *item, const QPointF &scenePos);
#endif
@@ -270,8 +272,19 @@ public:
static bool defaultAlphaBuffer;
static bool dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent *event, int startDragThreshold = -1);
- static bool dragOverThreshold(qreal d, Qt::Axis axis, const QTouchEvent::TouchPoint *tp, int startDragThreshold = -1);
- static bool dragOverThreshold(qreal d, Qt::Axis axis, const QQuickEventPoint *tp, int startDragThreshold = -1);
+
+ template <typename TEventPoint>
+ static bool dragOverThreshold(qreal d, Qt::Axis axis, const TEventPoint *p, int startDragThreshold = -1)
+ {
+ QStyleHints *styleHints = qApp->styleHints();
+ bool overThreshold = qAbs(d) > (startDragThreshold >= 0 ? startDragThreshold : styleHints->startDragDistance());
+ const bool dragVelocityLimitAvailable = (styleHints->startDragVelocity() > 0);
+ if (!overThreshold && dragVelocityLimitAvailable) {
+ qreal velocity = axis == Qt::XAxis ? p->velocity().x() : p->velocity().y();
+ overThreshold |= qAbs(velocity) > styleHints->startDragVelocity();
+ }
+ return overThreshold;
+ }
// data property
static void data_append(QQmlListProperty<QObject> *, QObject *);
diff --git a/src/quick/qtquick2.cpp b/src/quick/qtquick2.cpp
index 4028c63da5..c6b89fabd3 100644
--- a/src/quick/qtquick2.cpp
+++ b/src/quick/qtquick2.cpp
@@ -130,6 +130,7 @@ void QQmlQtQuick2DebugStatesDelegate::updateBinding(QQmlContext *context,
const QString &fileName, int line, int column,
bool *inBaseState)
{
+ Q_UNUSED(column);
typedef QPointer<QQuickState> QuickStatePointer;
QObject *object = property.object();
QString propertyName = property.name();
@@ -144,7 +145,7 @@ void QQmlQtQuick2DebugStatesDelegate::updateBinding(QQmlContext *context,
newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core,
expression.toString(), object,
QQmlContextData::get(context), fileName,
- line, column);
+ line);
newBinding->setTarget(property);
}
@@ -196,7 +197,7 @@ void QQmlQtQuick2Module::defineModule()
QQuickValueTypes::registerValueTypes();
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
QAccessible::installFactory(&qQuickAccessibleFactory);
#endif
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp
index 05d5daa686..d71b0c3e2a 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp
@@ -215,7 +215,7 @@ QSGRendererInterface::ShaderSourceTypes QSGSoftwareContext::shaderSourceType() c
void *QSGSoftwareContext::getResource(QQuickWindow *window, Resource resource) const
{
- if (resource == Painter && window && window->isSceneGraphInitialized())
+ if (resource == PainterResource && window && window->isSceneGraphInitialized())
return static_cast<QSGSoftwareRenderContext *>(QQuickWindowPrivate::get(window)->context)->m_activePainter;
return nullptr;
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp
index 19a963b403..6856d34616 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp
@@ -143,7 +143,8 @@ void QSGSoftwareRenderLoop::renderWindow(QQuickWindow *window)
if (profileFrames)
polishTime = renderTimer.nsecsElapsed();
Q_QUICK_SG_PROFILE_SWITCH(QQuickProfiler::SceneGraphPolishFrame,
- QQuickProfiler::SceneGraphRenderLoopFrame);
+ QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphPolishPolish);
emit window->afterAnimating();
@@ -151,7 +152,8 @@ void QSGSoftwareRenderLoop::renderWindow(QQuickWindow *window)
if (profileFrames)
syncTime = renderTimer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopSync);
//Tell the renderer about the windows backing store
auto softwareRenderer = static_cast<QSGSoftwareRenderer*>(cd->renderer);
@@ -162,7 +164,8 @@ void QSGSoftwareRenderLoop::renderWindow(QQuickWindow *window)
if (profileFrames)
renderTime = renderTimer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopRender);
if (data.grabOnly) {
grabContent = m_backingStores[window]->handle()->toImage();
@@ -178,7 +181,8 @@ void QSGSoftwareRenderLoop::renderWindow(QQuickWindow *window)
qint64 swapTime = 0;
if (profileFrames)
swapTime = renderTimer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame);
+ Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopSwap);
if (QSG_RASTER_LOG_TIME_RENDERLOOP().isDebugEnabled()) {
static QTime lastFrameTime = QTime::currentTime();
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp
index 5d5485ed8f..df5ec9b745 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp
@@ -484,7 +484,8 @@ void QSGSoftwareRenderThread::syncAndRender()
if (syncRequested)
sync(exposeRequested);
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopSync);
if (!syncResultedInChanges && !repaintRequested) {
qCDebug(QSG_RASTER_LOG_RENDERLOOP, "RT - no changes, render aborted");
@@ -510,7 +511,8 @@ void QSGSoftwareRenderThread::syncAndRender()
softwareRenderer->setBackingStore(backingStore);
wd->renderSceneGraph(exposedWindow->size());
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopRender);
if (softwareRenderer && (!wd->customRenderStage || !wd->customRenderStage->swap()))
backingStore->flush(softwareRenderer->flushRegion());
@@ -526,7 +528,8 @@ void QSGSoftwareRenderThread::syncAndRender()
wd->fireFrameSwapped();
} else {
- Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphRenderLoopFrame, 1);
+ Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopSync, 1);
qCDebug(QSG_RASTER_LOG_RENDERLOOP, "RT - window not ready, skipping render");
}
@@ -538,7 +541,8 @@ void QSGSoftwareRenderThread::syncAndRender()
mutex.unlock();
}
- Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame);
+ Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopSwap);
}
template<class T> T *windowFor(const QVector<T> &list, QQuickWindow *window)
@@ -951,7 +955,8 @@ void QSGSoftwareThreadedRenderLoop::polishAndSync(QSGSoftwareThreadedRenderLoop:
QQuickWindowPrivate *wd = QQuickWindowPrivate::get(window);
wd->polishItems();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync,
+ QQuickProfiler::SceneGraphPolishAndSyncPolish);
w->updateDuringSync = false;
@@ -965,13 +970,15 @@ void QSGSoftwareThreadedRenderLoop::polishAndSync(QSGSoftwareThreadedRenderLoop:
qCDebug(QSG_RASTER_LOG_RENDERLOOP, "polishAndSync - wait for sync");
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync,
+ QQuickProfiler::SceneGraphPolishAndSyncWait);
w->thread->waitCondition.wait(&w->thread->mutex);
lockedForSync = false;
w->thread->mutex.unlock();
qCDebug(QSG_RASTER_LOG_RENDERLOOP, "polishAndSync - unlock after sync");
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync,
+ QQuickProfiler::SceneGraphPolishAndSyncSync);
if (!animationTimer && m_anim->isRunning()) {
qCDebug(QSG_RASTER_LOG_RENDERLOOP, "polishAndSync - advancing animations");
@@ -983,7 +990,8 @@ void QSGSoftwareThreadedRenderLoop::polishAndSync(QSGSoftwareThreadedRenderLoop:
w->window->requestUpdate();
}
- Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphPolishAndSync);
+ Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphPolishAndSync,
+ QQuickProfiler::SceneGraphPolishAndSyncAnimations);
}
#include "qsgsoftwarethreadedrenderloop.moc"
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
index 49bbbf0ba8..6771c0e940 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
@@ -90,7 +90,7 @@ DECLARE_DEBUG_VAR(noclip)
static QElapsedTimer qsg_renderer_timer;
#define QSGNODE_TRAVERSE(NODE) for (QSGNode *child = NODE->firstChild(); child; child = child->nextSibling())
-#define SHADOWNODE_TRAVERSE(NODE) for (Node *child = NODE->firstChild; child; child = child->nextSibling)
+#define SHADOWNODE_TRAVERSE(NODE) for (Node *child = NODE->firstChild(); child; child = child->sibling())
static inline int size_of_type(GLenum type)
{
@@ -170,7 +170,8 @@ ShaderManager::Shader *ShaderManager::prepareMaterial(QSGMaterial *material)
qCDebug(QSG_LOG_TIME_COMPILATION, "shader compiled in %dms", (int) qsg_renderer_timer.elapsed());
- Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphContextFrame);
+ Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphContextFrame,
+ QQuickProfiler::SceneGraphContextMaterialCompile);
rewrittenShaders[type] = shader;
return shader;
@@ -201,7 +202,8 @@ ShaderManager::Shader *ShaderManager::prepareMaterialNoRewrite(QSGMaterial *mate
qCDebug(QSG_LOG_TIME_COMPILATION, "shader compiled in %dms (no rewrite)", (int) qsg_renderer_timer.elapsed());
- Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphContextFrame);
+ Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphContextFrame,
+ QQuickProfiler::SceneGraphContextMaterialCompile);
return shader;
}
@@ -510,7 +512,7 @@ void Updater::updateRootTransforms(Node *node, Node *root, const QMatrix4x4 &com
while (n != root) {
if (n->type() == QSGNode::TransformNodeType)
m = static_cast<QSGTransformNode *>(n->sgNode)->matrix() * m;
- n = n->parent;
+ n = n->parent();
}
m = combined * m;
@@ -1013,16 +1015,8 @@ void Renderer::nodeWasAdded(QSGNode *node, Node *shadowParent)
Node *snode = m_nodeAllocator.allocate();
snode->sgNode = node;
m_nodes.insert(node, snode);
- if (shadowParent) {
- snode->parent = shadowParent;
- if (shadowParent->lastChild) {
- shadowParent->lastChild->nextSibling = snode;
- shadowParent->lastChild = snode;
- } else {
- shadowParent->firstChild = snode;
- shadowParent->lastChild = snode;
- }
- }
+ if (shadowParent)
+ shadowParent->append(snode);
if (node->type() == QSGNode::GeometryNodeType) {
snode->data = m_elementAllocator.allocate();
@@ -1054,17 +1048,12 @@ void Renderer::nodeWasRemoved(Node *node)
// here, because we delete 'child' (when recursed, down below), so we'd
// have a use-after-free.
{
- Node *child = node->firstChild;
- Node *nextChild = 0;
-
+ Node *child = node->firstChild();
while (child) {
- // Get the next child now before we proceed
- nextChild = child->nextSibling;
-
// Remove (and delete) child
+ node->remove(child);
nodeWasRemoved(child);
-
- child = nextChild;
+ child = node->firstChild();
}
}
@@ -1110,6 +1099,7 @@ void Renderer::nodeWasRemoved(Node *node)
}
Q_ASSERT(m_nodes.contains(node->sgNode));
+
m_nodeAllocator.release(m_nodes.take(node->sgNode));
}
@@ -1120,13 +1110,13 @@ void Renderer::turnNodeIntoBatchRoot(Node *node)
node->isBatchRoot = true;
node->becameBatchRoot = true;
- Node *p = node->parent;
+ Node *p = node->parent();
while (p) {
if (p->type() == QSGNode::ClipNodeType || p->isBatchRoot) {
registerBatchRoot(node, p);
break;
}
- p = p->parent;
+ p = p->parent();
}
SHADOWNODE_TRAVERSE(node)
@@ -1255,33 +1245,18 @@ void Renderer::nodeChanged(QSGNode *node, QSGNode::DirtyState state)
| QSGNode::DirtyForceUpdate);
if (dirtyChain != 0) {
dirtyChain = QSGNode::DirtyState(dirtyChain << 16);
- Node *sn = shadowNode->parent;
+ Node *sn = shadowNode->parent();
while (sn) {
sn->dirtyState |= dirtyChain;
- sn = sn->parent;
+ sn = sn->parent();
}
}
// Delete happens at the very end because it deletes the shadownode.
if (state & QSGNode::DirtyNodeRemoved) {
- Node *parent = shadowNode->parent;
- if (parent) {
- Q_ASSERT(parent->firstChild);
- Q_ASSERT(parent->lastChild);
- shadowNode->parent = 0;
- Node *child = parent->firstChild;
- if (child == shadowNode) {
- parent->firstChild = shadowNode->nextSibling;
- if (parent->lastChild == shadowNode)
- parent->lastChild = 0;
- } else {
- while (child->nextSibling != shadowNode)
- child = child->nextSibling;
- child->nextSibling = shadowNode->nextSibling;
- if (shadowNode == parent->lastChild)
- parent->lastChild = child;
- }
- }
+ Node *parent = shadowNode->parent();
+ if (parent)
+ parent->remove(shadowNode);
nodeWasRemoved(shadowNode);
Q_ASSERT(m_nodes.value(node) == 0);
}
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
index d5e94cea3e..322192944b 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
@@ -451,11 +451,73 @@ struct Batch
struct Node
{
QSGNode *sgNode;
- Node *parent;
void *data;
- Node *firstChild;
- Node *nextSibling;
- Node *lastChild;
+
+ Node *m_parent;
+ Node *m_child;
+ Node *m_next;
+ Node *m_prev;
+
+ Node *parent() const { return m_parent; }
+
+ void append(Node *child) {
+ Q_ASSERT(child);
+ Q_ASSERT(!hasChild(child));
+ Q_ASSERT(child->m_parent == 0);
+ Q_ASSERT(child->m_next == 0);
+ Q_ASSERT(child->m_prev == 0);
+
+ if (!m_child) {
+ child->m_next = child;
+ child->m_prev = child;
+ m_child = child;
+ } else {
+ m_child->m_prev->m_next = child;
+ child->m_prev = m_child->m_prev;
+ m_child->m_prev = child;
+ child->m_next = m_child;
+ }
+ child->setParent(this);
+ }
+
+ void remove(Node *child) {
+ Q_ASSERT(child);
+ Q_ASSERT(hasChild(child));
+
+ // only child..
+ if (child->m_next == child) {
+ m_child = 0;
+ } else {
+ if (m_child == child)
+ m_child = child->m_next;
+ child->m_next->m_prev = child->m_prev;
+ child->m_prev->m_next = child->m_next;
+ }
+ child->m_next = 0;
+ child->m_prev = 0;
+ child->setParent(0);
+ }
+
+ Node *firstChild() const { return m_child; }
+
+ Node *sibling() const {
+ Q_ASSERT(m_parent);
+ return m_next == m_parent->m_child ? 0 : m_next;
+ }
+
+ void setParent(Node *p) {
+ Q_ASSERT(m_parent == 0 || p == 0);
+ m_parent = p;
+ }
+
+ bool hasChild(Node *child) const {
+ Node *n = m_child;
+ while (n && n != child)
+ n = n->sibling();
+ return n;
+ }
+
+
QSGNode::DirtyState dirtyState;
diff --git a/src/quick/scenegraph/coreapi/qsggeometry.cpp b/src/quick/scenegraph/coreapi/qsggeometry.cpp
index b43a2bc2ba..a278c6079b 100644
--- a/src/quick/scenegraph/coreapi/qsggeometry.cpp
+++ b/src/quick/scenegraph/coreapi/qsggeometry.cpp
@@ -39,7 +39,7 @@
#include "qsggeometry.h"
#include "qsggeometry_p.h"
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <qopenglcontext.h>
# include <qopenglfunctions.h>
# include <private/qopenglextensions_p.h>
@@ -441,7 +441,7 @@ QSGGeometry::QSGGeometry(const QSGGeometry::AttributeSet &attributes,
Q_UNUSED(m_reserved_bits);
Q_ASSERT(m_attributes.count > 0);
Q_ASSERT(m_attributes.stride > 0);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
Q_ASSERT_X(indexType != GL_UNSIGNED_INT
|| static_cast<QOpenGLExtensions *>(QOpenGLContext::currentContext()->functions())
->hasOpenGLExtension(QOpenGLExtensions::ElementIndexUint),
diff --git a/src/quick/scenegraph/coreapi/qsggeometry.h b/src/quick/scenegraph/coreapi/qsggeometry.h
index 00acb51c8a..7a916610e3 100644
--- a/src/quick/scenegraph/coreapi/qsggeometry.h
+++ b/src/quick/scenegraph/coreapi/qsggeometry.h
@@ -88,15 +88,7 @@ public:
UnsignedShortType = 0x1403,
IntType = 0x1404,
UnsignedIntType = 0x1405,
- FloatType = 0x1406,
-
- TypeByte = ByteType,
- TypeUnsignedByte = UnsignedByteType,
- TypeShort = ShortType,
- TypeUnsignedShort = UnsignedShortType,
- TypeInt = IntType,
- TypeUnsignedInt = UnsignedIntType,
- TypeFloat = FloatType
+ FloatType = 0x1406
};
struct Q_QUICK_EXPORT Attribute
diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.cpp b/src/quick/scenegraph/coreapi/qsgmaterial.cpp
index 13598bbe1d..8d666d3d0b 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterial.cpp
+++ b/src/quick/scenegraph/coreapi/qsgmaterial.cpp
@@ -40,7 +40,7 @@
#include "qsgmaterial.h"
#include "qsgrenderer_p.h"
#include "qsgmaterialshader_p.h"
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <private/qsgshadersourcebuilder_p.h>
# include <private/qsgdefaultcontext_p.h>
# include <private/qsgdefaultrendercontext_p.h>
@@ -64,7 +64,7 @@ void qsg_set_material_failure()
qsg_material_failure = true;
}
#endif
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
const char *QSGMaterialShaderPrivate::loadShaderSource(QOpenGLShader::ShaderType type) const
{
const QStringList files = m_sourceFiles[type];
@@ -227,7 +227,7 @@ QSGMaterialShader::~QSGMaterialShader()
defines the attribute register position in the vertex shader.
*/
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
/*!
\fn const char *QSGMaterialShader::vertexShader() const
@@ -320,7 +320,7 @@ void QSGMaterialShader::updateState(const RenderState & /* state */, QSGMaterial
{
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
/*!
Sets the GLSL source file for the shader stage \a type to \a sourceFile. The
default implementation of the vertexShader() and fragmentShader() functions
@@ -364,8 +364,8 @@ void QSGMaterialShader::compile()
{
Q_ASSERT_X(!m_program.isLinked(), "QSGSMaterialShader::compile()", "Compile called multiple times!");
- program()->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShader());
- program()->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShader());
+ program()->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, vertexShader());
+ program()->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShader());
char const *const *attr = attributeNames();
#ifndef QT_NO_DEBUG
@@ -550,7 +550,7 @@ QRect QSGMaterialShader::RenderState::deviceRect() const
return static_cast<const QSGRenderer *>(m_data)->deviceRect();
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
/*!
Returns the QOpenGLContext that is being used for rendering
diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.h b/src/quick/scenegraph/coreapi/qsgmaterial.h
index 114651653f..c002cd5d5e 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterial.h
+++ b/src/quick/scenegraph/coreapi/qsgmaterial.h
@@ -41,7 +41,7 @@
#define QSGMATERIAL_H
#include <QtQuick/qtquickglobal.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <QtGui/qopenglshaderprogram.h>
#endif
#include <QtGui/QMatrix4x4>
@@ -84,7 +84,7 @@ public:
QRect deviceRect() const;
float determinant() const;
float devicePixelRatio() const;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QOpenGLContext *context() const;
#endif
private:
@@ -101,7 +101,7 @@ public:
// First time a material is used, oldMaterial is null.
virtual void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
virtual char const *const *attributeNames() const = 0; // Array must end with null.
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
inline QOpenGLShaderProgram *program() { return &m_program; }
#endif
protected:
@@ -110,19 +110,19 @@ protected:
friend class QSGDefaultRenderContext;
friend class QSGBatchRenderer::ShaderManager;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
void setShaderSourceFile(QOpenGLShader::ShaderType type, const QString &sourceFile);
void setShaderSourceFiles(QOpenGLShader::ShaderType type, const QStringList &sourceFiles);
virtual void compile();
#endif
virtual void initialize() { }
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
virtual const char *vertexShader() const;
virtual const char *fragmentShader() const;
#endif
private:
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QOpenGLShaderProgram m_program;
#endif
QScopedPointer<QSGMaterialShaderPrivate> d_ptr;
diff --git a/src/quick/scenegraph/coreapi/qsgmaterialshader_p.h b/src/quick/scenegraph/coreapi/qsgmaterialshader_p.h
index 0dbce010db..47f5e5de09 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterialshader_p.h
+++ b/src/quick/scenegraph/coreapi/qsgmaterialshader_p.h
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
class Q_QUICK_PRIVATE_EXPORT QSGMaterialShaderPrivate
{
public:
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
const char *loadShaderSource(QOpenGLShader::ShaderType type) const;
QHash<QOpenGLShader::ShaderType, QStringList> m_sourceFiles;
diff --git a/src/quick/scenegraph/coreapi/qsgrenderer.cpp b/src/quick/scenegraph/coreapi/qsgrenderer.cpp
index 220e6ab212..e5d464930c 100644
--- a/src/quick/scenegraph/coreapi/qsgrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgrenderer.cpp
@@ -39,7 +39,7 @@
#include "qsgrenderer_p.h"
#include "qsgnodeupdater_p.h"
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <QtGui/QOpenGLFramebufferObject>
# include <QtGui/QOpenGLContext>
# include <QtGui/QOpenGLFunctions>
@@ -67,7 +67,7 @@ int qt_sg_envInt(const char *name, int defaultValue)
void QSGBindable::clear(QSGAbstractRenderer::ClearMode mode) const
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
GLuint bits = 0;
if (mode & QSGAbstractRenderer::ClearColorBuffer) bits |= GL_COLOR_BUFFER_BIT;
if (mode & QSGAbstractRenderer::ClearDepthBuffer) bits |= GL_DEPTH_BUFFER_BIT;
@@ -81,11 +81,11 @@ void QSGBindable::clear(QSGAbstractRenderer::ClearMode mode) const
// Reactivate the color buffer after switching to the stencil.
void QSGBindable::reactivate() const
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QOpenGLContext::currentContext()->functions()->glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
#endif
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QSGBindableFboId::QSGBindableFboId(GLuint id)
: m_id(id)
{
@@ -181,7 +181,7 @@ bool QSGRenderer::isMirrored() const
void QSGRenderer::renderScene(uint fboId)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (fboId) {
QSGBindableFboId bindable(fboId);
renderScene(bindable);
@@ -220,9 +220,10 @@ void QSGRenderer::renderScene(const QSGBindable &bindable)
bindable.bind();
if (profileFrames)
bindTime = frameTimer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame,
+ QQuickProfiler::SceneGraphRendererBinding);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
// Sanity check that attribute registers are disabled
if (qsg_sanity_check) {
GLint count = 0;
@@ -240,7 +241,8 @@ void QSGRenderer::renderScene(const QSGBindable &bindable)
render();
if (profileFrames)
renderTime = frameTimer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRendererFrame);
+ Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRendererFrame,
+ QQuickProfiler::SceneGraphRendererRender);
m_is_rendering = false;
m_changed_emitted = false;
@@ -304,13 +306,15 @@ void QSGRenderer::preprocess()
bool profileFrames = QSG_LOG_TIME_RENDERER().isDebugEnabled();
if (profileFrames)
preprocessTime = frameTimer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame,
+ QQuickProfiler::SceneGraphRendererPreprocess);
nodeUpdater()->updateStates(root);
if (profileFrames)
updatePassTime = frameTimer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame,
+ QQuickProfiler::SceneGraphRendererUpdate);
}
void QSGRenderer::addNodesToPreprocess(QSGNode *node)
diff --git a/src/quick/scenegraph/coreapi/qsgrenderer_p.h b/src/quick/scenegraph/coreapi/qsgrenderer_p.h
index 3fb23fe3cd..4589685765 100644
--- a/src/quick/scenegraph/coreapi/qsgrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgrenderer_p.h
@@ -133,7 +133,7 @@ public:
virtual void clear(QSGAbstractRenderer::ClearMode mode) const;
virtual void reactivate() const;
};
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
class QSGBindableFboId : public QSGBindable
{
public:
diff --git a/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp b/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp
index fa543aecad..3b0b2faf97 100644
--- a/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp
+++ b/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp
@@ -77,14 +77,15 @@ QT_BEGIN_NAMESPACE
\value Software The Qt Quick 2D Renderer is in use
\value OpenGL OpenGL ES 2.0 or higher
\value Direct3D12 Direct3D 12
+ \value OpenVG OpenVG via EGL
*/
/*!
\enum QSGRendererInterface::Resource
- \value Device The graphics device, when applicable.
- \value CommandQueue The graphics command queue used by the scenegraph, when applicable.
- \value CommandList The command list or buffer used by the scenegraph, when applicable.
- \value Painter The active QPainter used by the scenegraph, when running with the software backend.
+ \value DeviceResource The graphics device, when applicable.
+ \value CommandQueueResource The graphics command queue used by the scenegraph, when applicable.
+ \value CommandListResource The command list or buffer used by the scenegraph, when applicable.
+ \value PainterResource The active QPainter used by the scenegraph, when running with the software backend.
*/
/*!
diff --git a/src/quick/scenegraph/coreapi/qsgrendererinterface.h b/src/quick/scenegraph/coreapi/qsgrendererinterface.h
index a50b362aeb..722488201b 100644
--- a/src/quick/scenegraph/coreapi/qsgrendererinterface.h
+++ b/src/quick/scenegraph/coreapi/qsgrendererinterface.h
@@ -53,14 +53,15 @@ public:
Unknown,
Software,
OpenGL,
- Direct3D12
+ Direct3D12,
+ OpenVG
};
enum Resource {
- Device,
- CommandQueue,
- CommandList,
- Painter
+ DeviceResource,
+ CommandQueueResource,
+ CommandListResource,
+ PainterResource
};
enum ShaderType {
diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp
index 9923fa6e24..412023564f 100644
--- a/src/quick/scenegraph/qsgadaptationlayer.cpp
+++ b/src/quick/scenegraph/qsgadaptationlayer.cpp
@@ -73,7 +73,7 @@ QSGDistanceFieldGlyphCache::QSGDistanceFieldGlyphCache(QSGDistanceFieldGlyphCach
// this allows us to call pathForGlyph once and reuse the result.
m_referenceFont.setPixelSize(QT_DISTANCEFIELD_BASEFONTSIZE(m_doubleGlyphResolution) * QT_DISTANCEFIELD_SCALE(m_doubleGlyphResolution));
Q_ASSERT(m_referenceFont.isValid());
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
m_coreProfile = (c->format().profile() == QSurfaceFormat::CoreProfile);
#else
Q_UNUSED(c)
@@ -189,7 +189,8 @@ void QSGDistanceFieldGlyphCache::update()
int count = m_pendingGlyphs.size();
if (profileFrames)
renderTime = qsg_render_timer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphAdaptationLayerFrame);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphAdaptationLayerFrame,
+ QQuickProfiler::SceneGraphAdaptationLayerGlyphRender);
m_pendingGlyphs.reset();
@@ -210,6 +211,7 @@ void QSGDistanceFieldGlyphCache::update()
int((now - (renderTime / 1000000))));
}
Q_QUICK_SG_PROFILE_END_WITH_PAYLOAD(QQuickProfiler::SceneGraphAdaptationLayerFrame,
+ QQuickProfiler::SceneGraphAdaptationLayerGlyphStore,
(qint64)count);
}
diff --git a/src/quick/scenegraph/qsgadaptationlayer_p.h b/src/quick/scenegraph/qsgadaptationlayer_p.h
index 5880c67af0..bf267ccf92 100644
--- a/src/quick/scenegraph/qsgadaptationlayer_p.h
+++ b/src/quick/scenegraph/qsgadaptationlayer_p.h
@@ -141,7 +141,7 @@ public:
virtual void update() = 0;
- virtual void accept(QSGNodeVisitorEx *visitor) { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); }
+ void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); }
};
@@ -165,7 +165,7 @@ public:
virtual void update() = 0;
- virtual void accept(QSGNodeVisitorEx *visitor) { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); }
+ void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); }
};
class Q_QUICK_PRIVATE_EXPORT QSGPainterNode : public QSGVisitableNode
@@ -188,7 +188,7 @@ public:
virtual void update() = 0;
virtual QSGTexture *texture() const = 0;
- virtual void accept(QSGNodeVisitorEx *visitor) { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); }
+ void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); }
};
class Q_QUICK_EXPORT QSGLayer : public QSGDynamicTexture
@@ -231,7 +231,7 @@ public:
virtual void update() = 0;
- virtual void accept(QSGNodeVisitorEx *visitor) { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); }
+ void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); }
};
#endif
@@ -389,7 +389,7 @@ public:
void setOwnerElement(QQuickItem *ownerElement) { m_ownerElement = ownerElement; }
QQuickItem *ownerElement() const { return m_ownerElement; }
- virtual void accept(QSGNodeVisitorEx *visitor) { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); }
+ void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); }
protected:
QRectF m_bounding_rect;
QQuickItem *m_ownerElement;
diff --git a/src/quick/scenegraph/qsgbasicglyphnode_p.h b/src/quick/scenegraph/qsgbasicglyphnode_p.h
index 1d09367ea5..0a43d17d2b 100644
--- a/src/quick/scenegraph/qsgbasicglyphnode_p.h
+++ b/src/quick/scenegraph/qsgbasicglyphnode_p.h
@@ -63,16 +63,16 @@ public:
QSGBasicGlyphNode();
virtual ~QSGBasicGlyphNode();
- virtual QPointF baseLine() const { return m_baseLine; }
- virtual void setGlyphs(const QPointF &position, const QGlyphRun &glyphs);
- virtual void setColor(const QColor &color);
+ QPointF baseLine() const override { return m_baseLine; }
+ void setGlyphs(const QPointF &position, const QGlyphRun &glyphs) override;
+ void setColor(const QColor &color) override;
- virtual void setPreferredAntialiasingMode(AntialiasingMode) { }
- virtual void setStyle(QQuickText::TextStyle);
- virtual void setStyleColor(const QColor &);
+ void setPreferredAntialiasingMode(AntialiasingMode) override { }
+ void setStyle(QQuickText::TextStyle) override;
+ void setStyleColor(const QColor &) override;
virtual void setMaterialColor(const QColor &color) = 0;
- virtual void update() = 0;
+ void update() override = 0;
protected:
QGlyphRun m_glyphs;
diff --git a/src/quick/scenegraph/qsgcontextplugin.cpp b/src/quick/scenegraph/qsgcontextplugin.cpp
index 7fab9aeae8..635308c38a 100644
--- a/src/quick/scenegraph/qsgcontextplugin.cpp
+++ b/src/quick/scenegraph/qsgcontextplugin.cpp
@@ -45,7 +45,7 @@
// Built-in adaptations
#include <QtQuick/private/qsgsoftwareadaptation_p.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
#include <QtQuick/private/qsgdefaultcontext_p.h>
#endif
@@ -62,7 +62,7 @@ QSGContextPlugin::~QSGContextPlugin()
{
}
-#ifndef QT_NO_LIBRARY
+#if QT_CONFIG(library)
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QSGContextFactoryInterface_iid, QLatin1String("/scenegraph")))
#endif
@@ -128,7 +128,7 @@ QSGAdaptationBackendData *contextFactory()
if (requestedBackend.isEmpty() && qEnvironmentVariableIsSet("QT_QUICK_BACKEND"))
requestedBackend = QString::fromLocal8Bit(qgetenv("QT_QUICK_BACKEND"));
-#ifdef QT_NO_OPENGL
+#if !QT_CONFIG(opengl)
// If this is a build without OpenGL, and no backend has been set
// default to the software renderer
if (requestedBackend.isEmpty())
@@ -148,7 +148,7 @@ QSGAdaptationBackendData *contextFactory()
}
}
-#ifndef QT_NO_LIBRARY
+#if QT_CONFIG(library)
// Then try the plugins.
if (!backendData->factory) {
const int index = loader()->indexOf(requestedBackend);
@@ -165,7 +165,7 @@ QSGAdaptationBackendData *contextFactory()
qPrintable(QLibraryInfo::location(QLibraryInfo::PluginsPath)));
}
}
-#endif // QT_NO_LIBRARY
+#endif // library
}
}
@@ -185,7 +185,7 @@ QSGContext *QSGContext::createDefaultContext()
QSGAdaptationBackendData *backendData = contextFactory();
if (backendData->factory)
return backendData->factory->create(backendData->name);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
return new QSGDefaultContext();
#else
return nullptr;
diff --git a/src/quick/scenegraph/qsgcontextplugin_p.h b/src/quick/scenegraph/qsgcontextplugin_p.h
index 08c3d21408..5914b42809 100644
--- a/src/quick/scenegraph/qsgcontextplugin_p.h
+++ b/src/quick/scenegraph/qsgcontextplugin_p.h
@@ -90,10 +90,10 @@ public:
explicit QSGContextPlugin(QObject *parent = 0);
virtual ~QSGContextPlugin();
- virtual QStringList keys() const = 0;
+ virtual QStringList keys() const override = 0;
- virtual QQuickTextureFactory *createTextureFactoryFromImage(const QImage &) { return 0; }
- virtual QSGRenderLoop *createWindowManager() { return 0; }
+ QQuickTextureFactory *createTextureFactoryFromImage(const QImage &) override { return 0; }
+ QSGRenderLoop *createWindowManager() override { return 0; }
};
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h
index 9ad99e5c54..57dc4a5d07 100644
--- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h
+++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h
@@ -72,10 +72,10 @@ public:
QSGDefaultDistanceFieldGlyphCache(QSGDistanceFieldGlyphCacheManager *man, QOpenGLContext *c, const QRawFont &font);
virtual ~QSGDefaultDistanceFieldGlyphCache();
- void requestGlyphs(const QSet<glyph_t> &glyphs);
- void storeGlyphs(const QList<QDistanceField> &glyphs);
- void referenceGlyphs(const QSet<glyph_t> &glyphs);
- void releaseGlyphs(const QSet<glyph_t> &glyphs);
+ void requestGlyphs(const QSet<glyph_t> &glyphs) override;
+ void storeGlyphs(const QList<QDistanceField> &glyphs) override;
+ void referenceGlyphs(const QSet<glyph_t> &glyphs) override;
+ void releaseGlyphs(const QSet<glyph_t> &glyphs) override;
bool useTextureResizeWorkaround() const;
bool useTextureUploadWorkaround() const;
@@ -119,19 +119,13 @@ private:
const QString source = QLatin1String(qopenglslMainWithTexCoordsVertexShader)
+ QLatin1String(qopenglslUntransformedPositionVertexShader);
- QOpenGLShader *vertexShader = new QOpenGLShader(QOpenGLShader::Vertex, m_blitProgram);
- vertexShader->compileSourceCode(source);
-
- m_blitProgram->addShader(vertexShader);
+ m_blitProgram->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, source);
}
{
const QString source = QLatin1String(qopenglslMainFragmentShader)
+ QLatin1String(qopenglslImageSrcFragmentShader);
- QOpenGLShader *fragmentShader = new QOpenGLShader(QOpenGLShader::Fragment, m_blitProgram);
- fragmentShader->compileSourceCode(source);
-
- m_blitProgram->addShader(fragmentShader);
+ m_blitProgram->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, source);
}
m_blitProgram->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR);
m_blitProgram->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR);
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h b/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h
index caa7dfad07..b0a2788dd8 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h
@@ -71,9 +71,9 @@ public:
QSGTextMaskMaterial(const QRawFont &font, QFontEngine::GlyphFormat glyphFormat = QFontEngine::Format_None);
virtual ~QSGTextMaskMaterial();
- 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 setColor(const QColor &c) { m_color = QVector4D(c.redF(), c.greenF(), c.blueF(), c.alphaF()); }
void setColor(const QVector4D &color) { m_color = color; }
@@ -115,10 +115,10 @@ public:
void setStyleColor(const QVector4D &color) { m_styleColor = color; }
const QVector4D &styleColor() const { return m_styleColor; }
- virtual QSGMaterialType *type() const;
- virtual QSGMaterialShader *createShader() const;
+ QSGMaterialType *type() const override;
+ QSGMaterialShader *createShader() const override;
- int compare(const QSGMaterial *other) const;
+ int compare(const QSGMaterial *other) const override;
private:
QVector2D m_styleShift;
@@ -131,8 +131,8 @@ public:
QSGOutlinedTextMaterial(const QRawFont &font);
~QSGOutlinedTextMaterial() { }
- QSGMaterialType *type() const;
- QSGMaterialShader *createShader() const;
+ QSGMaterialType *type() const override;
+ QSGMaterialShader *createShader() const override;
};
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgdefaultrendercontext.cpp b/src/quick/scenegraph/qsgdefaultrendercontext.cpp
index 1a17453baf..2c5b4ff5c8 100644
--- a/src/quick/scenegraph/qsgdefaultrendercontext.cpp
+++ b/src/quick/scenegraph/qsgdefaultrendercontext.cpp
@@ -262,8 +262,8 @@ void QSGDefaultRenderContext::compileShader(QSGMaterialShader *shader, QSGMateri
"QSGRenderContext::compile()",
"materials with custom compile step cannot have custom vertex/fragment code");
QOpenGLShaderProgram *p = shader->program();
- p->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexCode ? vertexCode : shader->vertexShader());
- p->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentCode ? fragmentCode : shader->fragmentShader());
+ p->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, vertexCode ? vertexCode : shader->vertexShader());
+ p->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, fragmentCode ? fragmentCode : shader->fragmentShader());
p->link();
if (!p->isLinked())
qWarning() << "shader compilation failed:" << endl << p->log();
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.h b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.h
index 22c68558ef..c0c6bda718 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.h
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.h
@@ -67,19 +67,19 @@ public:
QSGDistanceFieldGlyphNode(QSGRenderContext *context);
~QSGDistanceFieldGlyphNode();
- virtual QPointF baseLine() const { return m_baseLine; }
- virtual void setGlyphs(const QPointF &position, const QGlyphRun &glyphs);
- virtual void setColor(const QColor &color);
+ QPointF baseLine() const override { return m_baseLine; }
+ void setGlyphs(const QPointF &position, const QGlyphRun &glyphs) override;
+ void setColor(const QColor &color) override;
- virtual void setPreferredAntialiasingMode(AntialiasingMode mode);
+ void setPreferredAntialiasingMode(AntialiasingMode mode) override;
- virtual void setStyle(QQuickText::TextStyle style);
- virtual void setStyleColor(const QColor &color);
+ void setStyle(QQuickText::TextStyle style) override;
+ void setStyleColor(const QColor &color) override;
- virtual void update();
- void preprocess();
+ void update() override;
+ void preprocess() override;
- void invalidateGlyphs(const QVector<quint32> &glyphs);
+ void invalidateGlyphs(const QVector<quint32> &glyphs) override;
void updateGeometry();
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h b/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
index 38dcf3d307..c13a0898eb 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
@@ -63,9 +63,9 @@ public:
QSGDistanceFieldTextMaterial();
~QSGDistanceFieldTextMaterial();
- 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;
virtual void setColor(const QColor &color);
const QVector4D &color() const { return m_color; }
@@ -97,9 +97,9 @@ public:
QSGDistanceFieldStyledTextMaterial();
~QSGDistanceFieldStyledTextMaterial();
- virtual QSGMaterialType *type() const = 0;
- virtual QSGMaterialShader *createShader() const = 0;
- virtual int compare(const QSGMaterial *other) const;
+ QSGMaterialType *type() const override = 0;
+ QSGMaterialShader *createShader() const override = 0;
+ int compare(const QSGMaterial *other) const override;
void setStyleColor(const QColor &color);
const QVector4D &styleColor() const { return m_styleColor; }
@@ -114,8 +114,8 @@ public:
QSGDistanceFieldOutlineTextMaterial();
~QSGDistanceFieldOutlineTextMaterial();
- virtual QSGMaterialType *type() const;
- virtual QSGMaterialShader *createShader() const;
+ QSGMaterialType *type() const override;
+ QSGMaterialShader *createShader() const override;
};
class Q_QUICK_PRIVATE_EXPORT QSGDistanceFieldShiftedStyleTextMaterial : public QSGDistanceFieldStyledTextMaterial
@@ -124,9 +124,9 @@ public:
QSGDistanceFieldShiftedStyleTextMaterial();
~QSGDistanceFieldShiftedStyleTextMaterial();
- 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 setShift(const QPointF &shift) { m_shift = shift; }
const QPointF &shift() const { return m_shift; }
@@ -138,17 +138,17 @@ protected:
class Q_QUICK_PRIVATE_EXPORT QSGHiQSubPixelDistanceFieldTextMaterial : public QSGDistanceFieldTextMaterial
{
public:
- virtual QSGMaterialType *type() const;
- virtual QSGMaterialShader *createShader() const;
- void setColor(const QColor &color) { m_color = QVector4D(color.redF(), color.greenF(), color.blueF(), color.alphaF()); }
+ QSGMaterialType *type() const override;
+ QSGMaterialShader *createShader() const override;
+ void setColor(const QColor &color) override { m_color = QVector4D(color.redF(), color.greenF(), color.blueF(), color.alphaF()); }
};
class Q_QUICK_PRIVATE_EXPORT QSGLoQSubPixelDistanceFieldTextMaterial : public QSGDistanceFieldTextMaterial
{
public:
- virtual QSGMaterialType *type() const;
- virtual QSGMaterialShader *createShader() const;
- void setColor(const QColor &color) { m_color = QVector4D(color.redF(), color.greenF(), color.blueF(), color.alphaF()); }
+ QSGMaterialType *type() const override;
+ QSGMaterialShader *createShader() const override;
+ void setColor(const QColor &color) override { m_color = QVector4D(color.redF(), color.greenF(), color.blueF(), color.alphaF()); }
};
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp
index 9ddbe5aa1d..48288bfc62 100644
--- a/src/quick/scenegraph/qsgrenderloop.cpp
+++ b/src/quick/scenegraph/qsgrenderloop.cpp
@@ -58,7 +58,7 @@
#include <QtQuick/private/qsgcontext_p.h>
#include <private/qquickprofiler_p.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <QtGui/QOpenGLContext>
# include <private/qsgdefaultrendercontext_p.h>
#if QT_CONFIG(quick_shadereffect)
@@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE
extern bool qsg_useConsistentTiming();
extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
/*!
expectations for this manager to work:
- one opengl context to render multiple windows
@@ -119,7 +119,7 @@ void QSGRenderLoop::cleanup()
void QSGRenderLoop::postJob(QQuickWindow *window, QRunnable *job)
{
Q_ASSERT(job);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
Q_ASSERT(window);
if (window->openglContext()) {
window->openglContext()->makeCurrent(window);
@@ -131,7 +131,7 @@ void QSGRenderLoop::postJob(QQuickWindow *window, QRunnable *job)
#endif
delete job;
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
class QSGGuiThreadRenderLoop : public QSGRenderLoop
{
Q_OBJECT
@@ -182,7 +182,7 @@ QSGRenderLoop *QSGRenderLoop::instance()
const_cast<QLoggingCategory &>(QSG_LOG_INFO()).setEnabled(QtDebugMsg, true);
s_instance = QSGContext::createWindowManager();
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (!s_instance) {
enum RenderLoopType {
@@ -272,7 +272,7 @@ void QSGRenderLoop::handleContextCreationFailure(QQuickWindow *window,
if (!signalEmitted)
qFatal("%s", qPrintable(untranslatedMessage));
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QSGGuiThreadRenderLoop::QSGGuiThreadRenderLoop()
: gl(0)
{
@@ -401,7 +401,8 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window)
if (profileFrames)
polishTime = renderTimer.nsecsElapsed();
Q_QUICK_SG_PROFILE_SWITCH(QQuickProfiler::SceneGraphPolishFrame,
- QQuickProfiler::SceneGraphRenderLoopFrame);
+ QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphPolishPolish);
emit window->afterAnimating();
@@ -409,13 +410,15 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window)
if (profileFrames)
syncTime = renderTimer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopSync);
cd->renderSceneGraph(window->size());
if (profileFrames)
renderTime = renderTimer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopRender);
if (data.grabOnly) {
bool alpha = window->format().alphaBufferSize() > 0 && window->color().alpha() != 255;
@@ -432,7 +435,8 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window)
qint64 swapTime = 0;
if (profileFrames)
swapTime = renderTimer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame);
+ Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopSwap);
if (QSG_LOG_TIME_RENDERLOOP().isDebugEnabled()) {
static QTime lastFrameTime = QTime::currentTime();
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
index 693012154e..4543782d5b 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp
+++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
@@ -602,7 +602,8 @@ void QSGRenderThread::syncAndRender()
if (profileFrames)
syncTime = threadTimer.nsecsElapsed();
#endif
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopSync);
if (!syncResultedInChanges && !repaintRequested && sgrc->isValid()) {
qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "- no changes, render aborted";
@@ -634,12 +635,14 @@ void QSGRenderThread::syncAndRender()
d->renderSceneGraph(windowSize);
if (profileFrames)
renderTime = threadTimer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopRender);
if (!d->customRenderStage || !d->customRenderStage->swap())
gl->swapBuffers(window);
d->fireFrameSwapped();
} else {
- Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphRenderLoopFrame, 1);
+ Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopSync, 1);
qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "- window not ready, skipping render";
}
@@ -664,7 +667,8 @@ void QSGRenderThread::syncAndRender()
int(threadTimer.elapsed() - renderTime / 1000000));
- Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame);
+ Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopSwap);
}
@@ -1169,7 +1173,8 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose)
if (profileFrames)
polishTime = timer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync,
+ QQuickProfiler::SceneGraphPolishAndSyncPolish);
w->updateDuringSync = false;
@@ -1184,7 +1189,8 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose)
qCDebug(QSG_LOG_RENDERLOOP) << "- wait for sync";
if (profileFrames)
waitTime = timer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync,
+ QQuickProfiler::SceneGraphPolishAndSyncWait);
w->thread->waitCondition.wait(&w->thread->mutex);
m_lockedForSync = false;
w->thread->mutex.unlock();
@@ -1192,7 +1198,8 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose)
if (profileFrames)
syncTime = timer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync,
+ QQuickProfiler::SceneGraphPolishAndSyncSync);
if (m_animation_timer == 0 && m_animation_driver->isRunning()) {
qCDebug(QSG_LOG_RENDERLOOP) << "- advancing animations";
@@ -1213,7 +1220,8 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose)
<< ", animations=" << (timer.nsecsElapsed() - syncTime) / 1000000
<< " - (on Gui thread) " << window;
- Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphPolishAndSync);
+ Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphPolishAndSync,
+ QQuickProfiler::SceneGraphPolishAndSyncAnimations);
}
bool QSGThreadedRenderLoop::event(QEvent *e)
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop_p.h b/src/quick/scenegraph/qsgthreadedrenderloop_p.h
index 0ab83b444a..32bfcb7148 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop_p.h
+++ b/src/quick/scenegraph/qsgthreadedrenderloop_p.h
@@ -68,29 +68,29 @@ public:
QSGThreadedRenderLoop();
~QSGThreadedRenderLoop();
- void show(QQuickWindow *) {}
- void hide(QQuickWindow *);
+ void show(QQuickWindow *) override {}
+ void hide(QQuickWindow *) override;
- void windowDestroyed(QQuickWindow *window);
- void exposureChanged(QQuickWindow *window);
+ void windowDestroyed(QQuickWindow *window) override;
+ void exposureChanged(QQuickWindow *window) override;
- QImage grab(QQuickWindow *);
+ QImage grab(QQuickWindow *) override;
- void update(QQuickWindow *window);
- void maybeUpdate(QQuickWindow *window);
- void handleUpdateRequest(QQuickWindow *window);
+ void update(QQuickWindow *window) override;
+ void maybeUpdate(QQuickWindow *window) override;
+ void handleUpdateRequest(QQuickWindow *window) override;
- QSGContext *sceneGraphContext() const;
- QSGRenderContext *createRenderContext(QSGContext *) const;
+ QSGContext *sceneGraphContext() const override;
+ QSGRenderContext *createRenderContext(QSGContext *) const override;
- QAnimationDriver *animationDriver() const;
+ QAnimationDriver *animationDriver() const override;
- void releaseResources(QQuickWindow *window);
+ void releaseResources(QQuickWindow *window) override;
- bool event(QEvent *);
- void postJob(QQuickWindow *window, QRunnable *job);
+ bool event(QEvent *) override;
+ void postJob(QQuickWindow *window, QRunnable *job) override;
- bool interleaveIncubation() const;
+ bool interleaveIncubation() const override;
public Q_SLOTS:
void animationStarted();
diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp
index 2a2d8be657..e944ddbc4f 100644
--- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp
+++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp
@@ -71,9 +71,9 @@ static QElapsedTimer qsg_render_timer;
if (QSG_LOG_TIME_RENDERLOOP().isDebugEnabled()) \
sampleName = qsg_render_timer.nsecsElapsed(); \
-#define QSG_RENDER_TIMING_SAMPLE(frameType, sampleName) \
+#define QSG_RENDER_TIMING_SAMPLE(frameType, sampleName, position) \
QSG_LOG_TIME_SAMPLE(sampleName) \
- Q_QUICK_SG_PROFILE_RECORD(frameType);
+ Q_QUICK_SG_PROFILE_RECORD(frameType, position);
QSGWindowsRenderLoop::QSGWindowsRenderLoop()
@@ -405,7 +405,7 @@ void QSGWindowsRenderLoop::render()
"animations ticked in %dms",
int((qsg_render_timer.nsecsElapsed() - time_start)/1000000));
- Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphWindowsAnimations);
+ Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphWindowsAnimations, 1);
// It is not given that animations triggered another maybeUpdate()
// and thus another render pass, so to keep things running,
@@ -456,22 +456,26 @@ void QSGWindowsRenderLoop::renderWindow(QQuickWindow *window)
d->polishItems();
QSG_LOG_TIME_SAMPLE(time_polished);
Q_QUICK_SG_PROFILE_SWITCH(QQuickProfiler::SceneGraphPolishFrame,
- QQuickProfiler::SceneGraphRenderLoopFrame);
+ QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphPolishPolish);
emit window->afterAnimating();
RLDEBUG(" - syncing");
d->syncSceneGraph();
- QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_synced);
+ QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_synced,
+ QQuickProfiler::SceneGraphRenderLoopSync);
RLDEBUG(" - rendering");
d->renderSceneGraph(window->size());
- QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_rendered);
+ QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_rendered,
+ QQuickProfiler::SceneGraphRenderLoopRender);
RLDEBUG(" - swapping");
if (!d->customRenderStage || !d->customRenderStage->swap())
m_gl->swapBuffers(window);
- QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_swapped);
+ QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_swapped,
+ QQuickProfiler::SceneGraphRenderLoopSwap);
RLDEBUG(" - frameDone");
d->fireFrameSwapped();
@@ -484,7 +488,8 @@ void QSGWindowsRenderLoop::renderWindow(QQuickWindow *window)
<< ", swap=" << (time_swapped - time_rendered) / 1000000
<< " - " << window;
- Q_QUICK_SG_PROFILE_REPORT(QQuickProfiler::SceneGraphRenderLoopFrame);
+ Q_QUICK_SG_PROFILE_REPORT(QQuickProfiler::SceneGraphRenderLoopFrame,
+ QQuickProfiler::SceneGraphRenderLoopSwap);
}
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgwindowsrenderloop_p.h b/src/quick/scenegraph/qsgwindowsrenderloop_p.h
index 9e5d7f04d3..1940a66af2 100644
--- a/src/quick/scenegraph/qsgwindowsrenderloop_p.h
+++ b/src/quick/scenegraph/qsgwindowsrenderloop_p.h
@@ -70,31 +70,31 @@ public:
explicit QSGWindowsRenderLoop();
~QSGWindowsRenderLoop();
- 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 exposureChanged(QQuickWindow *window);
- QImage grab(QQuickWindow *window);
+ void exposureChanged(QQuickWindow *window) override;
+ QImage grab(QQuickWindow *window) override;
- void update(QQuickWindow *window);
- void maybeUpdate(QQuickWindow *window);
+ void update(QQuickWindow *window) override;
+ void maybeUpdate(QQuickWindow *window) override;
- QAnimationDriver *animationDriver() const { return m_animationDriver; }
+ QAnimationDriver *animationDriver() const override { return m_animationDriver; }
- QSGContext *sceneGraphContext() const { return m_sg; }
- QSGRenderContext *createRenderContext(QSGContext *) const;
+ QSGContext *sceneGraphContext() const override { return m_sg; }
+ QSGRenderContext *createRenderContext(QSGContext *) const override;
- void releaseResources(QQuickWindow *) { }
+ void releaseResources(QQuickWindow *) override { }
void render();
void renderWindow(QQuickWindow *window);
- bool event(QEvent *event);
+ bool event(QEvent *event) override;
bool anyoneShowing() const;
- bool interleaveIncubation() const;
+ bool interleaveIncubation() const override;
public Q_SLOTS:
void started();
diff --git a/src/quick/scenegraph/util/qsgatlastexture.cpp b/src/quick/scenegraph/util/qsgatlastexture.cpp
index 40c3293c7b..c864ea9496 100644
--- a/src/quick/scenegraph/util/qsgatlastexture.cpp
+++ b/src/quick/scenegraph/util/qsgatlastexture.cpp
@@ -117,8 +117,9 @@ QSGTexture *Manager::create(const QImage &image, bool hasAlphaChannel)
if (image.width() < m_atlas_size_limit && image.height() < m_atlas_size_limit) {
if (!m_atlas)
m_atlas = new Atlas(m_atlas_size);
+ // t may be null for atlas allocation failure
t = m_atlas->create(image);
- if (!hasAlphaChannel && t->hasAlphaChannel())
+ if (t && !hasAlphaChannel && t->hasAlphaChannel())
t->setHasAlphaChannel(false);
}
return t;
@@ -394,9 +395,12 @@ void Atlas::bind(QSGTexture::Filtering filtering)
bool profileFrames = QSG_LOG_TIME_TEXTURE().isDebugEnabled();
if (profileFrames)
qsg_renderer_timer.start();
- // Skip bind, convert, swizzle; they're irrelevant
+
Q_QUICK_SG_PROFILE_START(QQuickProfiler::SceneGraphTexturePrepare);
- Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphTexturePrepare, 3);
+
+ // Skip bind, convert, swizzle; they're irrelevant
+ Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphTexturePrepare,
+ QQuickProfiler::SceneGraphTexturePrepareStart, 3);
Texture *t = m_pending_uploads.at(i);
if (m_externalFormat == GL_BGRA &&
@@ -414,10 +418,14 @@ void Atlas::bind(QSGTexture::Filtering filtering)
<< "ms (" << t->textureSize().width() << "x"
<< t->textureSize().height() << ")";
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare,
+ QQuickProfiler::SceneGraphTexturePrepareUpload);
+
// Skip mipmap; unused
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare);
- Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphTexturePrepare, 1);
- Q_QUICK_SG_PROFILE_REPORT(QQuickProfiler::SceneGraphTexturePrepare);
+ Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphTexturePrepare,
+ QQuickProfiler::SceneGraphTexturePrepareUpload, 1);
+ Q_QUICK_SG_PROFILE_REPORT(QQuickProfiler::SceneGraphTexturePrepare,
+ QQuickProfiler::SceneGraphTexturePrepareMipmap);
}
GLenum f = filtering == QSGTexture::Nearest ? GL_NEAREST : GL_LINEAR;
diff --git a/src/quick/scenegraph/util/qsgdefaultimagenode.cpp b/src/quick/scenegraph/util/qsgdefaultimagenode.cpp
index 6afe591dca..63773887a0 100644
--- a/src/quick/scenegraph/util/qsgdefaultimagenode.cpp
+++ b/src/quick/scenegraph/util/qsgdefaultimagenode.cpp
@@ -173,33 +173,4 @@ bool QSGDefaultImageNode::ownsTexture() const
return m_ownsTexture;
}
-void QSGDefaultImageNode::rebuildGeometry(QSGGeometry *g,
- QSGTexture *texture,
- const QRectF &rect,
- QRectF sourceRect,
- TextureCoordinatesTransformMode texCoordMode)
-{
- if (!texture)
- return;
-
- if (!sourceRect.width() || !sourceRect.height()) {
- QSize ts = texture->textureSize();
- sourceRect = QRectF(0, 0, ts.width(), ts.height());
- }
-
- // Maybe transform the texture coordinates
- if (texCoordMode.testFlag(QSGImageNode::MirrorHorizontally)) {
- float tmp = sourceRect.left();
- sourceRect.setLeft(sourceRect.right());
- sourceRect.setRight(tmp);
- }
- if (texCoordMode.testFlag(QSGImageNode::MirrorVertically)) {
- float tmp = sourceRect.top();
- sourceRect.setTop(sourceRect.bottom());
- sourceRect.setBottom(tmp);
- }
-
- QSGGeometry::updateTexturedRectGeometry(g, rect, texture->convertToNormalizedSourceRect(sourceRect));
-}
-
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgdefaultimagenode_p.h b/src/quick/scenegraph/util/qsgdefaultimagenode_p.h
index eb6c487c18..bb9ebec885 100644
--- a/src/quick/scenegraph/util/qsgdefaultimagenode_p.h
+++ b/src/quick/scenegraph/util/qsgdefaultimagenode_p.h
@@ -85,12 +85,6 @@ public:
void setOwnsTexture(bool owns) override;
bool ownsTexture() const override;
- static void rebuildGeometry(QSGGeometry *g,
- QSGTexture *texture,
- const QRectF &rect,
- QRectF sourceRect,
- TextureCoordinatesTransformMode texCoordMode);
-
private:
QSGGeometry m_geometry;
QSGOpaqueTextureMaterial m_opaque_material;
diff --git a/src/quick/scenegraph/util/qsgdefaultninepatchnode.cpp b/src/quick/scenegraph/util/qsgdefaultninepatchnode.cpp
index e5a53a3617..6023a9af93 100644
--- a/src/quick/scenegraph/util/qsgdefaultninepatchnode.cpp
+++ b/src/quick/scenegraph/util/qsgdefaultninepatchnode.cpp
@@ -81,56 +81,4 @@ void QSGDefaultNinePatchNode::update()
markDirty(QSGNode::DirtyGeometry | QSGNode::DirtyMaterial);
}
-void QSGDefaultNinePatchNode::rebuildGeometry(QSGTexture *texture, QSGGeometry *geometry, const QVector4D &padding,
- const QRectF &bounds, qreal dpr)
-{
- if (padding.x() <= 0 && padding.y() <= 0 && padding.z() <= 0 && padding.w() <= 0) {
- geometry->allocate(4, 0);
- QSGGeometry::updateTexturedRectGeometry(geometry, bounds, texture->normalizedTextureSubRect());
- return;
- }
-
- QRectF tc = texture->normalizedTextureSubRect();
- QSize ts = texture->textureSize();
- ts.setHeight(ts.height() / dpr);
- ts.setWidth(ts.width() / dpr);
-
- qreal invtw = tc.width() / ts.width();
- qreal invth = tc.height() / ts.height();
-
- struct Coord { qreal p; qreal t; };
- Coord cx[4] = { { bounds.left(), tc.left() },
- { bounds.left() + padding.x(), tc.left() + padding.x() * invtw },
- { bounds.right() - padding.z(), tc.right() - padding.z() * invtw },
- { bounds.right(), tc.right() }
- };
- Coord cy[4] = { { bounds.top(), tc.top() },
- { bounds.top() + padding.y(), tc.top() + padding.y() * invth },
- { bounds.bottom() - padding.w(), tc.bottom() - padding.w() * invth },
- { bounds.bottom(), tc.bottom() }
- };
-
- geometry->allocate(16, 28);
- QSGGeometry::TexturedPoint2D *v = geometry->vertexDataAsTexturedPoint2D();
- for (int y = 0; y < 4; ++y) {
- for (int x = 0; x < 4; ++x) {
- v->set(cx[x].p, cy[y].p, cx[x].t, cy[y].t);
- ++v;
- }
- }
-
- quint16 *i = geometry->indexDataAsUShort();
- for (int r = 0; r < 3; ++r) {
- if (r > 0)
- *i++ = 4 * r;
- for (int c = 0; c < 4; ++c) {
- i[0] = 4 * r + c;
- i[1] = 4 * r + c + 4;
- i += 2;
- }
- if (r < 2)
- *i++ = 4 * r + 3 + 4;
- }
-}
-
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgdefaultninepatchnode_p.h b/src/quick/scenegraph/util/qsgdefaultninepatchnode_p.h
index 675cf48f47..3752a75ac6 100644
--- a/src/quick/scenegraph/util/qsgdefaultninepatchnode_p.h
+++ b/src/quick/scenegraph/util/qsgdefaultninepatchnode_p.h
@@ -70,9 +70,6 @@ public:
void setPadding(qreal left, qreal top, qreal right, qreal bottom) override;
void update() override;
- static void rebuildGeometry(QSGTexture *texture, QSGGeometry *geometry, const QVector4D &padding,
- const QRectF &bounds, qreal dpr);
-
private:
QRectF m_bounds;
qreal m_devicePixelRatio;
diff --git a/src/quick/scenegraph/util/qsgdistancefieldutil.cpp b/src/quick/scenegraph/util/qsgdistancefieldutil.cpp
index 65a6bcd52c..9ca9cdb107 100644
--- a/src/quick/scenegraph/util/qsgdistancefieldutil.cpp
+++ b/src/quick/scenegraph/util/qsgdistancefieldutil.cpp
@@ -40,7 +40,7 @@
#include "qsgdistancefieldutil_p.h"
#include <private/qsgadaptationlayer_p.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <QtGui/private/qopenglengineshadersource_p.h>
#endif
#include <QtQuick/private/qsgcontext_p.h>
@@ -84,32 +84,12 @@ QSGDistanceFieldGlyphCacheManager::~QSGDistanceFieldGlyphCacheManager()
QSGDistanceFieldGlyphCache *QSGDistanceFieldGlyphCacheManager::cache(const QRawFont &font)
{
- return m_caches.value(fontKey(font), 0);
+ return m_caches.value(font, 0);
}
void QSGDistanceFieldGlyphCacheManager::insertCache(const QRawFont &font, QSGDistanceFieldGlyphCache *cache)
{
- m_caches.insert(fontKey(font), cache);
-}
-
-QString QSGDistanceFieldGlyphCacheManager::fontKey(const QRawFont &font)
-{
- QFontEngine *fe = QRawFontPrivate::get(font)->fontEngine;
- if (!fe->faceId().filename.isEmpty()) {
- QByteArray keyName = fe->faceId().filename;
- if (font.style() != QFont::StyleNormal)
- keyName += QByteArray(" I");
- if (font.weight() != QFont::Normal)
- keyName += ' ' + QByteArray::number(font.weight());
- keyName += QByteArray(" DF");
- return QString::fromUtf8(keyName);
- } else {
- return QString::fromLatin1("%1_%2_%3_%4")
- .arg(font.familyName())
- .arg(font.styleName())
- .arg(font.weight())
- .arg(font.style());
- }
+ m_caches.insert(font, cache);
}
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgdistancefieldutil_p.h b/src/quick/scenegraph/util/qsgdistancefieldutil_p.h
index 354a48a81e..ad366cb4d4 100644
--- a/src/quick/scenegraph/util/qsgdistancefieldutil_p.h
+++ b/src/quick/scenegraph/util/qsgdistancefieldutil_p.h
@@ -80,9 +80,7 @@ public:
void setAntialiasingSpreadFunc(AntialiasingSpreadFunc func) { m_antialiasingSpread_func = func; }
private:
- static QString fontKey(const QRawFont &font);
-
- QHash<QString, QSGDistanceFieldGlyphCache *> m_caches;
+ QHash<QRawFont, QSGDistanceFieldGlyphCache *> m_caches;
ThresholdFunc m_threshold_func;
AntialiasingSpreadFunc m_antialiasingSpread_func;
diff --git a/src/quick/scenegraph/util/qsgengine.cpp b/src/quick/scenegraph/util/qsgengine.cpp
index ad1fcfa470..09e4cdf5a7 100644
--- a/src/quick/scenegraph/util/qsgengine.cpp
+++ b/src/quick/scenegraph/util/qsgengine.cpp
@@ -44,7 +44,7 @@
#include <private/qsgrenderer_p.h>
#include <private/qsgtexture_p.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <QtGui/QOpenGLContext>
# include <private/qsgdefaultrendercontext_p.h>
#endif
@@ -116,7 +116,7 @@ QSGEngine::~QSGEngine()
void QSGEngine::initialize(QOpenGLContext *context)
{
Q_D(QSGEngine);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (context && QOpenGLContext::currentContext() != context) {
qWarning("WARNING: The context must be current before calling QSGEngine::initialize.");
return;
@@ -125,7 +125,7 @@ void QSGEngine::initialize(QOpenGLContext *context)
if (d->sgRenderContext && !d->sgRenderContext->isValid()) {
d->sgRenderContext->setAttachToGraphicsContext(false);
d->sgRenderContext->initialize(context);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (context)
connect(context, &QOpenGLContext::aboutToBeDestroyed, this, &QSGEngine::invalidate);
#endif
diff --git a/src/quick/scenegraph/util/qsgflatcolormaterial.cpp b/src/quick/scenegraph/util/qsgflatcolormaterial.cpp
index 2ce27275cd..8ab7669891 100644
--- a/src/quick/scenegraph/util/qsgflatcolormaterial.cpp
+++ b/src/quick/scenegraph/util/qsgflatcolormaterial.cpp
@@ -39,7 +39,7 @@
#include "qsgflatcolormaterial.h"
#include <private/qsgmaterialshader_p.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <qopenglshaderprogram.h>
#endif
@@ -57,7 +57,7 @@ public:
private:
virtual void initialize();
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
int m_matrix_id;
int m_color_id;
#endif
@@ -68,7 +68,7 @@ QSGMaterialType FlatColorMaterialShader::type;
FlatColorMaterialShader::FlatColorMaterialShader()
: QSGMaterialShader(*new QSGMaterialShaderPrivate)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/flatcolor.vert"));
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/flatcolor.frag"));
#endif
@@ -76,7 +76,7 @@ FlatColorMaterialShader::FlatColorMaterialShader()
void FlatColorMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
Q_ASSERT(oldEffect == 0 || newEffect->type() == oldEffect->type());
QSGFlatColorMaterial *oldMaterial = static_cast<QSGFlatColorMaterial *>(oldEffect);
QSGFlatColorMaterial *newMaterial = static_cast<QSGFlatColorMaterial *>(newEffect);
@@ -109,7 +109,7 @@ char const *const *FlatColorMaterialShader::attributeNames() const
void FlatColorMaterialShader::initialize()
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
m_matrix_id = program()->uniformLocation("matrix");
m_color_id = program()->uniformLocation("color");
#endif
diff --git a/src/quick/scenegraph/util/qsgimagenode.cpp b/src/quick/scenegraph/util/qsgimagenode.cpp
index a78bfc1c66..c03c91d1cb 100644
--- a/src/quick/scenegraph/util/qsgimagenode.cpp
+++ b/src/quick/scenegraph/util/qsgimagenode.cpp
@@ -187,4 +187,33 @@ QT_BEGIN_NAMESPACE
\return \c true if the node takes ownership of the texture; otherwise \c false.
*/
+void QSGImageNode::rebuildGeometry(QSGGeometry *g,
+ QSGTexture *texture,
+ const QRectF &rect,
+ QRectF sourceRect,
+ TextureCoordinatesTransformMode texCoordMode)
+{
+ if (!texture)
+ return;
+
+ if (!sourceRect.width() || !sourceRect.height()) {
+ QSize ts = texture->textureSize();
+ sourceRect = QRectF(0, 0, ts.width(), ts.height());
+ }
+
+ // Maybe transform the texture coordinates
+ if (texCoordMode.testFlag(QSGImageNode::MirrorHorizontally)) {
+ float tmp = sourceRect.left();
+ sourceRect.setLeft(sourceRect.right());
+ sourceRect.setRight(tmp);
+ }
+ if (texCoordMode.testFlag(QSGImageNode::MirrorVertically)) {
+ float tmp = sourceRect.top();
+ sourceRect.setTop(sourceRect.bottom());
+ sourceRect.setBottom(tmp);
+ }
+
+ QSGGeometry::updateTexturedRectGeometry(g, rect, texture->convertToNormalizedSourceRect(sourceRect));
+}
+
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgimagenode.h b/src/quick/scenegraph/util/qsgimagenode.h
index 7eab42c4e6..d25e732e4b 100644
--- a/src/quick/scenegraph/util/qsgimagenode.h
+++ b/src/quick/scenegraph/util/qsgimagenode.h
@@ -79,6 +79,12 @@ public:
virtual void setOwnsTexture(bool owns) = 0;
virtual bool ownsTexture() const = 0;
+
+ static void rebuildGeometry(QSGGeometry *g,
+ QSGTexture *texture,
+ const QRectF &rect,
+ QRectF sourceRect,
+ TextureCoordinatesTransformMode texCoordMode);
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QSGImageNode::TextureCoordinatesTransformMode)
diff --git a/src/quick/scenegraph/util/qsgninepatchnode.cpp b/src/quick/scenegraph/util/qsgninepatchnode.cpp
index 9c167ca76f..33568b5488 100644
--- a/src/quick/scenegraph/util/qsgninepatchnode.cpp
+++ b/src/quick/scenegraph/util/qsgninepatchnode.cpp
@@ -74,4 +74,56 @@ QT_BEGIN_NAMESPACE
\internal
*/
+void QSGNinePatchNode::rebuildGeometry(QSGTexture *texture, QSGGeometry *geometry, const QVector4D &padding,
+ const QRectF &bounds, qreal dpr)
+{
+ if (padding.x() <= 0 && padding.y() <= 0 && padding.z() <= 0 && padding.w() <= 0) {
+ geometry->allocate(4, 0);
+ QSGGeometry::updateTexturedRectGeometry(geometry, bounds, texture->normalizedTextureSubRect());
+ return;
+ }
+
+ QRectF tc = texture->normalizedTextureSubRect();
+ QSize ts = texture->textureSize();
+ ts.setHeight(ts.height() / dpr);
+ ts.setWidth(ts.width() / dpr);
+
+ qreal invtw = tc.width() / ts.width();
+ qreal invth = tc.height() / ts.height();
+
+ struct Coord { qreal p; qreal t; };
+ Coord cx[4] = { { bounds.left(), tc.left() },
+ { bounds.left() + padding.x(), tc.left() + padding.x() * invtw },
+ { bounds.right() - padding.z(), tc.right() - padding.z() * invtw },
+ { bounds.right(), tc.right() }
+ };
+ Coord cy[4] = { { bounds.top(), tc.top() },
+ { bounds.top() + padding.y(), tc.top() + padding.y() * invth },
+ { bounds.bottom() - padding.w(), tc.bottom() - padding.w() * invth },
+ { bounds.bottom(), tc.bottom() }
+ };
+
+ geometry->allocate(16, 28);
+ QSGGeometry::TexturedPoint2D *v = geometry->vertexDataAsTexturedPoint2D();
+ for (int y = 0; y < 4; ++y) {
+ for (int x = 0; x < 4; ++x) {
+ v->set(cx[x].p, cy[y].p, cx[x].t, cy[y].t);
+ ++v;
+ }
+ }
+
+ quint16 *i = geometry->indexDataAsUShort();
+ for (int r = 0; r < 3; ++r) {
+ if (r > 0)
+ *i++ = 4 * r;
+ for (int c = 0; c < 4; ++c) {
+ i[0] = 4 * r + c;
+ i[1] = 4 * r + c + 4;
+ i += 2;
+ }
+ if (r < 2)
+ *i++ = 4 * r + 3 + 4;
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgninepatchnode.h b/src/quick/scenegraph/util/qsgninepatchnode.h
index 8677a432ba..8509cbd326 100644
--- a/src/quick/scenegraph/util/qsgninepatchnode.h
+++ b/src/quick/scenegraph/util/qsgninepatchnode.h
@@ -55,6 +55,10 @@ public:
virtual void setDevicePixelRatio(qreal ratio) = 0;
virtual void setPadding(qreal left, qreal top, qreal right, qreal bottom) = 0;
virtual void update() = 0;
+
+ static void rebuildGeometry(QSGTexture *texture, QSGGeometry *geometry,
+ const QVector4D &padding,
+ const QRectF &bounds, qreal dpr);
};
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgshadersourcebuilder.cpp b/src/quick/scenegraph/util/qsgshadersourcebuilder.cpp
index 25af1997a8..d8f92919cb 100644
--- a/src/quick/scenegraph/util/qsgshadersourcebuilder.cpp
+++ b/src/quick/scenegraph/util/qsgshadersourcebuilder.cpp
@@ -217,11 +217,11 @@ void QSGShaderSourceBuilder::initializeProgramFromFiles(QOpenGLShaderProgram *pr
QSGShaderSourceBuilder builder;
builder.appendSourceFile(vertexShader);
- program->addShaderFromSourceCode(QOpenGLShader::Vertex, builder.source());
+ program->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, builder.source());
builder.clear();
builder.appendSourceFile(fragmentShader);
- program->addShaderFromSourceCode(QOpenGLShader::Fragment, builder.source());
+ program->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, builder.source());
}
QByteArray QSGShaderSourceBuilder::source() const
diff --git a/src/quick/scenegraph/util/qsgsimplematerial.h b/src/quick/scenegraph/util/qsgsimplematerial.h
index 01f98767fd..0e7219d7bd 100644
--- a/src/quick/scenegraph/util/qsgsimplematerial.h
+++ b/src/quick/scenegraph/util/qsgsimplematerial.h
@@ -48,9 +48,9 @@ template <typename State>
class QSGSimpleMaterialShader : public QSGMaterialShader
{
public:
- void initialize() {
+ void initialize() override {
QSGMaterialShader::initialize();
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
m_id_matrix = program()->uniformLocation(uniformMatrixName());
if (m_id_matrix < 0) {
qFatal("QSGSimpleMaterialShader does not implement 'uniform highp mat4 %s;' in its vertex shader",
@@ -74,7 +74,7 @@ public:
const char *uniformMatrixName() const { return "qt_Matrix"; }
const char *uniformOpacityName() const { return "qt_Opacity"; }
- void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
+ void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
virtual void updateState(const State *newState, const State *oldState) = 0;
@@ -82,7 +82,7 @@ public:
virtual QList<QByteArray> attributes() const = 0;
- char const *const *attributeNames() const
+ char const *const *attributeNames() const override
{
if (m_attribute_pointers.size())
return m_attribute_pointers.constData();
@@ -197,7 +197,7 @@ QSGMaterialType QSGSimpleMaterial<State>::m_type;
template <typename State>
Q_INLINE_TEMPLATE void QSGSimpleMaterialShader<State>::updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (state.isMatrixDirty())
program()->setUniformValue(m_id_matrix, state.combinedMatrix());
if (state.isOpacityDirty() && m_id_opacity >= 0)
diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp
index 4cf339aeb8..47248f2f37 100644
--- a/src/quick/scenegraph/util/qsgtexture.cpp
+++ b/src/quick/scenegraph/util/qsgtexture.cpp
@@ -45,7 +45,7 @@
#include <private/qqmlglobal_p.h>
#include <QtGui/qguiapplication.h>
#include <QtGui/qpa/qplatformnativeinterface.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <qopenglfunctions.h>
# include <QtGui/qopenglcontext.h>
# include <QtGui/qopenglfunctions.h>
@@ -70,7 +70,7 @@
#include <QHash>
#endif
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
static QElapsedTimer qsg_renderer_timer;
#endif
@@ -86,7 +86,7 @@ static const bool qsg_leak_check = !qEnvironmentVariableIsEmpty("QML_LEAK_CHECK"
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
inline static bool isPowerOfTwo(int x)
{
// Assumption: x >= 1
@@ -284,7 +284,7 @@ Q_GLOBAL_STATIC(QMutex, qsg_valid_texture_mutex)
bool qsg_safeguard_texture(QSGTexture *texture)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QMutexLocker locker(qsg_valid_texture_mutex());
if (!qsg_valid_texture_set()->contains(texture)) {
qWarning() << "Invalid texture accessed:" << (void *) texture;
@@ -527,7 +527,7 @@ QSGTexture::WrapMode QSGTexture::verticalWrapMode() const
*/
void QSGTexture::updateBindOptions(bool force)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
Q_D(QSGTexture);
QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
force |= isAtlasTexture();
@@ -582,7 +582,7 @@ QSGPlainTexture::QSGPlainTexture()
QSGPlainTexture::~QSGPlainTexture()
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_texture_id && m_owns_texture && QOpenGLContext::currentContext())
QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &m_texture_id);
#endif
@@ -617,7 +617,7 @@ int QSGPlainTexture::textureId() const
// or ~QSGPlainTexture so just keep it minimal here.
return 0;
} else if (m_texture_id == 0){
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
// Generate a texture id for use later and return it.
QOpenGLContext::currentContext()->functions()->glGenTextures(1, &const_cast<QSGPlainTexture *>(this)->m_texture_id);
#endif
@@ -629,7 +629,7 @@ int QSGPlainTexture::textureId() const
void QSGPlainTexture::setTextureId(int id)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (m_texture_id && m_owns_texture)
QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &m_texture_id);
#endif
@@ -643,7 +643,7 @@ void QSGPlainTexture::setTextureId(int id)
void QSGPlainTexture::bind()
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QOpenGLContext *context = QOpenGLContext::currentContext();
QOpenGLFunctions *funcs = context->functions();
if (!m_dirty_texture) {
@@ -673,7 +673,8 @@ void QSGPlainTexture::bind()
(int) qsg_renderer_timer.elapsed(),
m_texture_size.width(),
m_texture_size.height());
- Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphTextureDeletion);
+ Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphTextureDeletion,
+ QQuickProfiler::SceneGraphTextureDeletionDelete);
}
m_texture_id = 0;
m_texture_size = QSize();
@@ -689,7 +690,8 @@ void QSGPlainTexture::bind()
qint64 bindTime = 0;
if (profileFrames)
bindTime = qsg_renderer_timer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare,
+ QQuickProfiler::SceneGraphTexturePrepareBind);
// ### TODO: check for out-of-memory situations...
@@ -730,7 +732,8 @@ void QSGPlainTexture::bind()
qint64 convertTime = 0;
if (profileFrames)
convertTime = qsg_renderer_timer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare,
+ QQuickProfiler::SceneGraphTexturePrepareConvert);
updateBindOptions(m_dirty_bind_options);
@@ -773,14 +776,16 @@ void QSGPlainTexture::bind()
qint64 swizzleTime = 0;
if (profileFrames)
swizzleTime = qsg_renderer_timer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare,
+ QQuickProfiler::SceneGraphTexturePrepareSwizzle);
funcs->glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, m_texture_size.width(), m_texture_size.height(), 0, externalFormat, GL_UNSIGNED_BYTE, tmp.constBits());
qint64 uploadTime = 0;
if (profileFrames)
uploadTime = qsg_renderer_timer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare);
+ Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare,
+ QQuickProfiler::SceneGraphTexturePrepareUpload);
if (mipmapFiltering() != QSGTexture::None) {
funcs->glGenerateMipmap(GL_TEXTURE_2D);
@@ -803,7 +808,8 @@ void QSGPlainTexture::bind()
int((mipmapTime - uploadTime)/1000000),
m_texture_size != m_image.size() ? " (scaled to GL_MAX_TEXTURE_SIZE)" : "");
}
- Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphTexturePrepare);
+ Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphTexturePrepare,
+ QQuickProfiler::SceneGraphTexturePrepareMipmap);
m_texture_rect = QRectF(0, 0, 1, 1);
diff --git a/src/quick/scenegraph/util/qsgtexture_p.h b/src/quick/scenegraph/util/qsgtexture_p.h
index e09cbdbef1..b6fcfc31c4 100644
--- a/src/quick/scenegraph/util/qsgtexture_p.h
+++ b/src/quick/scenegraph/util/qsgtexture_p.h
@@ -53,7 +53,7 @@
#include <QtQuick/qtquickglobal.h>
#include <private/qobject_p.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <QtGui/qopengl.h>
#endif
#include "qsgtexture.h"
diff --git a/src/quick/scenegraph/util/qsgtexturematerial.cpp b/src/quick/scenegraph/util/qsgtexturematerial.cpp
index 119828bc81..9326ea640d 100644
--- a/src/quick/scenegraph/util/qsgtexturematerial.cpp
+++ b/src/quick/scenegraph/util/qsgtexturematerial.cpp
@@ -39,14 +39,14 @@
#include "qsgtexturematerial_p.h"
#include "qsgtexture_p.h"
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <QtGui/qopenglshaderprogram.h>
# include <QtGui/qopenglfunctions.h>
#endif
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
inline static bool isPowerOfTwo(int x)
{
// Assumption: x >= 1
@@ -59,7 +59,7 @@ QSGMaterialType QSGOpaqueTextureMaterialShader::type;
QSGOpaqueTextureMaterialShader::QSGOpaqueTextureMaterialShader()
: QSGMaterialShader()
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/opaquetexture.vert"));
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/opaquetexture.frag"));
#endif
@@ -73,7 +73,7 @@ char const *const *QSGOpaqueTextureMaterialShader::attributeNames() const
void QSGOpaqueTextureMaterialShader::initialize()
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
m_matrix_id = program()->uniformLocation("qt_Matrix");
#endif
}
@@ -95,7 +95,7 @@ void QSGOpaqueTextureMaterialShader::updateState(const RenderState &state, QSGMa
t->setHorizontalWrapMode(tx->horizontalWrapMode());
t->setVerticalWrapMode(tx->verticalWrapMode());
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
bool npotSupported = const_cast<QOpenGLContext *>(state.context())
->functions()->hasOpenGLFeature(QOpenGLFunctions::NPOTTextureRepeat);
if (!npotSupported) {
@@ -115,7 +115,7 @@ void QSGOpaqueTextureMaterialShader::updateState(const RenderState &state, QSGMa
t->bind();
else
t->updateBindOptions();
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (state.isMatrixDirty())
program()->setUniformValue(m_matrix_id, state.combinedMatrix());
#endif
@@ -379,7 +379,7 @@ QSGMaterialShader *QSGTextureMaterial::createShader() const
QSGTextureMaterialShader::QSGTextureMaterialShader()
: QSGOpaqueTextureMaterialShader()
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/texture.frag"));
#endif
}
@@ -387,7 +387,7 @@ QSGTextureMaterialShader::QSGTextureMaterialShader()
void QSGTextureMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
{
Q_ASSERT(oldEffect == 0 || newEffect->type() == oldEffect->type());
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (state.isOpacityDirty())
program()->setUniformValue(m_opacity_id, state.opacity());
#endif
@@ -397,7 +397,7 @@ void QSGTextureMaterialShader::updateState(const RenderState &state, QSGMaterial
void QSGTextureMaterialShader::initialize()
{
QSGOpaqueTextureMaterialShader::initialize();
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
m_opacity_id = program()->uniformLocation("opacity");
#endif
}
diff --git a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp
index 847ec289d8..8c305d7fd4 100644
--- a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp
+++ b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp
@@ -38,7 +38,7 @@
****************************************************************************/
#include "qsgvertexcolormaterial.h"
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <qopenglshaderprogram.h>
#endif
QT_BEGIN_NAMESPACE
@@ -55,7 +55,7 @@ public:
private:
virtual void initialize();
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
int m_matrix_id;
int m_opacity_id;
#endif
@@ -66,7 +66,7 @@ QSGMaterialType QSGVertexColorMaterialShader::type;
QSGVertexColorMaterialShader::QSGVertexColorMaterialShader()
: QSGMaterialShader()
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/vertexcolor.vert"));
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/vertexcolor.frag"));
#endif
@@ -74,7 +74,7 @@ QSGVertexColorMaterialShader::QSGVertexColorMaterialShader()
void QSGVertexColorMaterialShader::updateState(const RenderState &state, QSGMaterial * /*newEffect*/, QSGMaterial *)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (state.isOpacityDirty())
program()->setUniformValue(m_opacity_id, state.opacity());
@@ -93,7 +93,7 @@ char const *const *QSGVertexColorMaterialShader::attributeNames() const
void QSGVertexColorMaterialShader::initialize()
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
m_matrix_id = program()->uniformLocation("matrix");
m_opacity_id = program()->uniformLocation("opacity");
#endif
diff --git a/src/quick/util/qquickanimatorjob_p.h b/src/quick/util/qquickanimatorjob_p.h
index d7aaa988a9..a3ced4c21b 100644
--- a/src/quick/util/qquickanimatorjob_p.h
+++ b/src/quick/util/qquickanimatorjob_p.h
@@ -290,7 +290,7 @@ public:
private:
QSGOpacityNode *m_opacityNode;
};
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
class Q_QUICK_PRIVATE_EXPORT QQuickUniformAnimatorJob : public QQuickAnimatorJob
{
public:
diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp
index 7692cc79f9..5a723e4432 100644
--- a/src/quick/util/qquickglobal.cpp
+++ b/src/quick/util/qquickglobal.cpp
@@ -783,7 +783,7 @@ public:
return new QQuickApplication(parent);
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
QInputMethod *inputMethod()
{
QInputMethod *im = qGuiApp->inputMethod();
diff --git a/src/quick/util/qquickprofiler_p.h b/src/quick/util/qquickprofiler_p.h
index 66ed212722..d2fa935ad4 100644
--- a/src/quick/util/qquickprofiler_p.h
+++ b/src/quick/util/qquickprofiler_p.h
@@ -152,7 +152,6 @@ private:
template<uint size>
struct TimingData {
qint64 values[size][s_numSceneGraphTimings + 1];
- int offsets[size];
};
QThreadStorage<TimingData<NumRenderThreadFrameTypes> > renderThreadTimings;
@@ -167,15 +166,6 @@ public:
else
return guiThreadTimings.values[type - NumRenderThreadFrameTypes];
}
-
- template<SceneGraphFrameType type>
- int &offset()
- {
- if (type < NumRenderThreadFrameTypes)
- return renderThreadTimings.localData().offsets[type];
- else
- return guiThreadTimings.offsets[type - NumRenderThreadFrameTypes];
- }
};
class Q_QUICK_PRIVATE_EXPORT QQuickProfiler : public QObject, public QQmlProfilerDefinitions {
@@ -187,6 +177,59 @@ public:
RenderThread
};
+ enum SceneGraphContextStage {
+ SceneGraphContextStart,
+ SceneGraphContextMaterialCompile
+ };
+
+ enum SceneGraphRendererStage {
+ SceneGraphRendererStart,
+ SceneGraphRendererPreprocess,
+ SceneGraphRendererUpdate,
+ SceneGraphRendererBinding,
+ SceneGraphRendererRender
+ };
+
+ enum SceneGraphAdaptationLayerStage {
+ SceneGraphAdaptationLayerStart,
+ SceneGraphAdaptationLayerGlyphRender,
+ SceneGraphAdaptationLayerGlyphStore
+ };
+
+ enum SceneGraphRenderLoopStage {
+ SceneGraphRenderLoopStart,
+ SceneGraphRenderLoopSync,
+ SceneGraphRenderLoopRender,
+ SceneGraphRenderLoopSwap
+ };
+
+ enum SceneGraphPolishStage {
+ SceneGraphPolishStart,
+ SceneGraphPolishPolish
+ };
+
+ enum SceneGraphPolishAndSyncStage {
+ SceneGraphPolishAndSyncStart,
+ SceneGraphPolishAndSyncPolish,
+ SceneGraphPolishAndSyncWait,
+ SceneGraphPolishAndSyncSync,
+ SceneGraphPolishAndSyncAnimations
+ };
+
+ enum SceneGraphTexturePrepareStage {
+ SceneGraphTexturePrepareStart,
+ SceneGraphTexturePrepareBind,
+ SceneGraphTexturePrepareConvert,
+ SceneGraphTexturePrepareSwizzle,
+ SceneGraphTexturePrepareUpload,
+ SceneGraphTexturePrepareMipmap
+ };
+
+ enum SceneGraphTextureDeletionStage {
+ SceneGraphTextureDeletionStart,
+ SceneGraphTextureDeletionDelete
+ };
+
template<EventType DetailType, InputEventType InputType>
static void inputEvent(int x, int y = 0)
{
@@ -209,7 +252,6 @@ public:
static void startSceneGraphFrame()
{
startSceneGraphFrame<FrameType1>();
- s_instance->m_sceneGraphData.offset<FrameType2>() = 0;
s_instance->m_sceneGraphData.timings<FrameType2>()[0] =
s_instance->m_sceneGraphData.timings<FrameType1>()[0];
}
@@ -217,50 +259,45 @@ public:
template<SceneGraphFrameType FrameType>
static void startSceneGraphFrame()
{
- s_instance->m_sceneGraphData.offset<FrameType>() = 0;
s_instance->m_sceneGraphData.timings<FrameType>()[0] = s_instance->timestamp();
}
template<SceneGraphFrameType FrameType>
- static void recordSceneGraphTimestamp()
+ static void recordSceneGraphTimestamp(uint position)
{
- s_instance->m_sceneGraphData.timings<FrameType>()
- [++s_instance->m_sceneGraphData.offset<FrameType>()] = s_instance->timestamp();
+ s_instance->m_sceneGraphData.timings<FrameType>()[position] = s_instance->timestamp();
}
template<SceneGraphFrameType FrameType, uint Skip>
- static void skipSceneGraphTimestamps()
+ static void skipSceneGraphTimestamps(uint position)
{
qint64 *timings = s_instance->m_sceneGraphData.timings<FrameType>();
- const qint64 last = timings[s_instance->m_sceneGraphData.offset<FrameType>()];
+ const qint64 last = timings[position];
for (uint i = 0; i < Skip; ++i)
- timings[++s_instance->m_sceneGraphData.offset<FrameType>()] = last;
+ timings[++position] = last;
}
template<SceneGraphFrameType FrameType, bool Record>
- static void reportSceneGraphFrame(quint64 payload = ~0)
+ static void reportSceneGraphFrame(uint position, quint64 payload = ~0)
{
qint64 *timings = s_instance->m_sceneGraphData.timings<FrameType>();
- int &offset = s_instance->m_sceneGraphData.offset<FrameType>();
if (Record)
- timings[++offset] = s_instance->timestamp();
+ timings[position] = s_instance->timestamp();
s_instance->processMessage(QQuickProfilerData(
- timings[offset], 1 << SceneGraphFrame, 1 << FrameType,
- offset > 0 ? timings[1] - timings[0] : payload,
- offset > 1 ? timings[2] - timings[1] : payload,
- offset > 2 ? timings[3] - timings[2] : payload,
- offset > 3 ? timings[4] - timings[3] : payload,
- offset > 4 ? timings[5] - timings[4] : payload));
+ timings[position], 1 << SceneGraphFrame, 1 << FrameType,
+ position > 0 ? timings[1] - timings[0] : payload,
+ position > 1 ? timings[2] - timings[1] : payload,
+ position > 2 ? timings[3] - timings[2] : payload,
+ position > 3 ? timings[4] - timings[3] : payload,
+ position > 4 ? timings[5] - timings[4] : payload));
}
template<SceneGraphFrameType FrameType, bool Record, SceneGraphFrameType SwitchTo>
- static void reportSceneGraphFrame(quint64 payload = ~0)
+ static void reportSceneGraphFrame(uint position, quint64 payload = ~0)
{
- reportSceneGraphFrame<FrameType, Record>(payload);
- s_instance->m_sceneGraphData.offset<SwitchTo>() = 0;
+ reportSceneGraphFrame<FrameType, Record>(position, payload);
s_instance->m_sceneGraphData.timings<SwitchTo>()[0] =
- s_instance->m_sceneGraphData.timings<FrameType>()
- [s_instance->m_sceneGraphData.offset<FrameType>()];
+ s_instance->m_sceneGraphData.timings<FrameType>()[position];
}
template<PixmapEventType PixmapState>
@@ -326,38 +363,52 @@ protected:
#define Q_QUICK_PROFILE(feature, Method)\
Q_QUICK_PROFILE_IF_ENABLED(feature, QQuickProfiler::Method)
+// Record current timestamp for \a Type at position 0.
#define Q_QUICK_SG_PROFILE_START(Type)\
Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\
(QQuickProfiler::startSceneGraphFrame<Type>()))
-#define Q_QUICK_SG_PROFILE_RECORD(Type)\
+// Record current timestamp for \a Type at \a position.
+#define Q_QUICK_SG_PROFILE_RECORD(Type, position)\
Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\
- (QQuickProfiler::recordSceneGraphTimestamp<Type>()))
+ (QQuickProfiler::recordSceneGraphTimestamp<Type>(position)))
-#define Q_QUICK_SG_PROFILE_SKIP(Type, Skip)\
+// Use the timestamp for \a Type at position \a position and repeat it \a Skip times in subsequent
+// positions.
+#define Q_QUICK_SG_PROFILE_SKIP(Type, position, Skip)\
Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\
- (QQuickProfiler::skipSceneGraphTimestamps<Type, Skip>()))
+ (QQuickProfiler::skipSceneGraphTimestamps<Type, Skip>(position)))
+// Record current timestamp for both \a Type1 and \a Type2 at position 0.
#define Q_QUICK_SG_PROFILE_START_SYNCHRONIZED(Type1, Type2)\
Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\
(QQuickProfiler::startSceneGraphFrame<Type1, Type2>()))
-#define Q_QUICK_SG_PROFILE_SWITCH(Type1, Type2) \
+// report \a Type1, using the current timestamp at \a position, and switch to \a Typ2, using
+// the current timestamp at position 0.
+#define Q_QUICK_SG_PROFILE_SWITCH(Type1, Type2, position)\
Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\
- (QQuickProfiler::reportSceneGraphFrame<Type1, true, Type2>()))
+ (QQuickProfiler::reportSceneGraphFrame<Type1, true, Type2>(\
+ position)))
-#define Q_QUICK_SG_PROFILE_REPORT(Type)\
+// report \a Type, using data points 0 to \a position, including \a position.
+#define Q_QUICK_SG_PROFILE_REPORT(Type, position)\
Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\
- (QQuickProfiler::reportSceneGraphFrame<Type, false>()))
+ (QQuickProfiler::reportSceneGraphFrame<Type, false>(position)))
-#define Q_QUICK_SG_PROFILE_END(Type)\
+// report \a Type, using data points 0 to \a position, including \a position, and setting the
+// timestamp at \a position to the current one.
+#define Q_QUICK_SG_PROFILE_END(Type, position)\
Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\
- (QQuickProfiler::reportSceneGraphFrame<Type, true>()))
+ (QQuickProfiler::reportSceneGraphFrame<Type, true>(position)))
-#define Q_QUICK_SG_PROFILE_END_WITH_PAYLOAD(Type, Payload)\
+// report \a Type, using data points 0 to \a position, including \a position, and setting the
+// timestamp at \a position to the current one. Remaining data points up to position 5 are filled
+// with \a Payload.
+#define Q_QUICK_SG_PROFILE_END_WITH_PAYLOAD(Type, position, Payload)\
Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\
- (QQuickProfiler::reportSceneGraphFrame<Type, true>(Payload)))
-
+ (QQuickProfiler::reportSceneGraphFrame<Type, true>(position,\
+ Payload)))
#define Q_QUICK_INPUT_PROFILE(Type, DetailType, A, B)\
Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileInputEvents,\
diff --git a/src/quick/util/qquickpropertychanges.cpp b/src/quick/util/qquickpropertychanges.cpp
index 4dfeb7cc4a..fafa2edd0b 100644
--- a/src/quick/util/qquickpropertychanges.cpp
+++ b/src/quick/util/qquickpropertychanges.cpp
@@ -455,14 +455,14 @@ QQuickPropertyChanges::ActionList QQuickPropertyChanges::actions()
QQmlBinding *newBinding = 0;
if (e.id != QQmlBinding::Invalid) {
QV4::Scope scope(QQmlEnginePrivate::getV4Engine(qmlEngine(this)));
- QV4::ScopedValue function(scope, QV4::FunctionObject::createQmlFunction(context, object(), d->compilationUnit->runtimeFunctions.at(e.id)));
+ QV4::Scoped<QV4::QmlContext> qmlContext(scope, QV4::QmlContext::create(scope.engine->rootContext(), context, object()));
newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core,
- function, object(), context);
+ d->compilationUnit->runtimeFunctions.at(e.id), object(), context, qmlContext);
}
// QQmlBinding *newBinding = e.id != QQmlBinding::Invalid ? QQmlBinding::createBinding(e.id, object(), qmlContext(this)) : 0;
if (!newBinding)
newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core,
- e.expression, object(), context, e.url.toString(), e.line, e.column);
+ e.expression, object(), context, e.url.toString(), e.line);
if (d->isExplicit) {
// in this case, we don't want to assign a binding, per se,
@@ -629,7 +629,7 @@ void QQuickPropertyChanges::changeExpression(const QString &name, const QString
auto prop = d->property(name);
QQmlBinding *newBinding = QQmlBinding::create(
&QQmlPropertyPrivate::get(prop)->core, expression, object(),
- qmlContext(this));
+ QQmlContextData::get(qmlContext(this)));
newBinding->setTarget(prop);
QQmlPropertyPrivate::setBinding(newBinding, QQmlPropertyPrivate::None, QQmlPropertyData::DontRemoveBinding | QQmlPropertyData::BypassInterceptor);
}
@@ -651,7 +651,7 @@ void QQuickPropertyChanges::changeExpression(const QString &name, const QString
auto prop = d->property(name);
QQmlBinding *newBinding = QQmlBinding::create(
&QQmlPropertyPrivate::get(prop)->core, expression, object(),
- qmlContext(this));
+ QQmlContextData::get(qmlContext(this)));
newBinding->setTarget(prop);
QQmlPropertyPrivate::setBinding(newBinding, QQmlPropertyPrivate::None, QQmlPropertyData::DontRemoveBinding | QQmlPropertyData::BypassInterceptor);
} else {
@@ -664,7 +664,7 @@ void QQuickPropertyChanges::changeExpression(const QString &name, const QString
QQmlBinding *newBinding = QQmlBinding::create(
&QQmlPropertyPrivate::get(action.property)->core, expression,
- object(), qmlContext(this));
+ object(), QQmlContextData::get(qmlContext(this)));
if (d->isExplicit) {
// don't assign the binding, merely evaluate the expression.
// XXX TODO: add a static QQmlJavaScriptExpression::evaluate(QString)
diff --git a/src/quick/util/qquickshortcut.cpp b/src/quick/util/qquickshortcut.cpp
index a0a58f2e02..72d9c889e3 100644
--- a/src/quick/util/qquickshortcut.cpp
+++ b/src/quick/util/qquickshortcut.cpp
@@ -73,7 +73,7 @@
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
+ \sa Keys, {Keys::}{shortcutOverride()}
*/
/*! \qmlsignal QtQuick::Shortcut::activated()
diff --git a/src/quick/util/qquickstate_p_p.h b/src/quick/util/qquickstate_p_p.h
index af97390efb..eba1dabecf 100644
--- a/src/quick/util/qquickstate_p_p.h
+++ b/src/quick/util/qquickstate_p_p.h
@@ -217,7 +217,7 @@ public:
setObject(static_cast<QQuickStateOperation *>(obj));
}
QList<OperationGuard> *list;
- void objectDestroyed(QQuickStateOperation *) {
+ void objectDestroyed(QQuickStateOperation *) override {
// we assume priv will always be destroyed after objectDestroyed calls
list->removeOne(*this);
}
diff --git a/src/quick/util/qquickutilmodule.cpp b/src/quick/util/qquickutilmodule.cpp
index cb586d1565..77dae0d001 100644
--- a/src/quick/util/qquickutilmodule.cpp
+++ b/src/quick/util/qquickutilmodule.cpp
@@ -67,7 +67,7 @@ Q_DECLARE_METATYPE(QKeySequence::StandardKey)
void QQuickUtilModule::defineModule()
{
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
qmlRegisterUncreatableType<QInputMethod>("QtQuick",2,0,"InputMethod",
QInputMethod::tr("InputMethod is an abstract class"));
#endif
@@ -94,7 +94,7 @@ void QQuickUtilModule::defineModule()
qmlRegisterType<QQuickTransition>("QtQuick",2,0,"Transition");
qmlRegisterType<QQuickVector3dAnimation>("QtQuick",2,0,"Vector3dAnimation");
-#ifndef QT_NO_VALIDATOR
+#if QT_CONFIG(validator)
qmlRegisterType<QValidator>();
qmlRegisterType<QQuickIntValidator>("QtQuick",2,0,"IntValidator");
qmlRegisterType<QQuickDoubleValidator>("QtQuick",2,0,"DoubleValidator");
diff --git a/src/quick/util/qquickvalidator.cpp b/src/quick/util/qquickvalidator.cpp
index 67cb6a6c05..015a376603 100644
--- a/src/quick/util/qquickvalidator.cpp
+++ b/src/quick/util/qquickvalidator.cpp
@@ -41,7 +41,7 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_VALIDATOR
+#if QT_CONFIG(validator)
/*!
\qmltype IntValidator
@@ -221,7 +221,7 @@ void QQuickDoubleValidator::resetLocaleName()
By default, this property contains a regular expression with the pattern .* that matches any string.
*/
-#endif // QT_NO_VALIDATOR
+#endif // validator
QT_END_NAMESPACE
diff --git a/src/quick/util/qquickvalidator_p.h b/src/quick/util/qquickvalidator_p.h
index 97adfb742a..ba188e947a 100644
--- a/src/quick/util/qquickvalidator_p.h
+++ b/src/quick/util/qquickvalidator_p.h
@@ -56,7 +56,7 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_VALIDATOR
+#if QT_CONFIG(validator)
class Q_AUTOTEST_EXPORT QQuickIntValidator : public QIntValidator
{
Q_OBJECT
@@ -90,7 +90,7 @@ Q_SIGNALS:
QT_END_NAMESPACE
-#ifndef QT_NO_VALIDATOR
+#if QT_CONFIG(validator)
QML_DECLARE_TYPE(QValidator)
QML_DECLARE_TYPE(QQuickIntValidator)
QML_DECLARE_TYPE(QQuickDoubleValidator)
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index de3692afb0..4ed41a0c6c 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -59,7 +59,7 @@
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qpa/qplatformintegration.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
#include <QtGui/QOpenGLContext>
#include <QtGui/QOpenGLFunctions>
#include <QtGui/private/qopenglextensions_p.h>
@@ -76,7 +76,7 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha);
#endif
@@ -108,7 +108,7 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
useSoftwareRenderer = true;
if (!useSoftwareRenderer) {
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface))
setRenderToTexture();
else
@@ -121,7 +121,7 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
if (!engine.isNull() && !engine.data()->incubationController())
engine.data()->setIncubationController(offscreenWindow->incubationController());
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
q->setAcceptDrops(true);
#endif
@@ -143,7 +143,7 @@ void QQuickWidgetPrivate::ensureEngine() const
void QQuickWidgetPrivate::invalidateRenderControl()
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (!useSoftwareRenderer) {
if (!context) // this is not an error, could be called before creating the context, or multiple times
return;
@@ -183,7 +183,7 @@ QQuickWidgetPrivate::QQuickWidgetPrivate()
, offscreenWindow(0)
, offscreenSurface(0)
, renderControl(0)
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
, fbo(0)
, resolvedFbo(0)
, context(0)
@@ -206,7 +206,7 @@ QQuickWidgetPrivate::~QQuickWidgetPrivate()
delete renderControl;
delete offscreenWindow;
} else {
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
// context and offscreenSurface are current at this stage, if the context was created.
Q_ASSERT(!context || (QOpenGLContext::currentContext() == context && context->surface() == offscreenSurface));
delete renderControl; // always delete the rendercontrol first
@@ -245,20 +245,20 @@ void QQuickWidgetPrivate::execute()
}
void QQuickWidgetPrivate::itemGeometryChanged(QQuickItem *resizeItem, QQuickGeometryChange change,
- const QRectF &diff)
+ const QRectF &oldGeometry)
{
Q_Q(QQuickWidget);
if (resizeItem == root && resizeMode == QQuickWidget::SizeViewToRootObject) {
// wait for both width and height to be changed
resizetimer.start(0,q);
}
- QQuickItemChangeListener::itemGeometryChanged(resizeItem, change, diff);
+ QQuickItemChangeListener::itemGeometryChanged(resizeItem, change, oldGeometry);
}
void QQuickWidgetPrivate::render(bool needsSync)
{
if (!useSoftwareRenderer) {
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
// createFramebufferObject() bails out when the size is empty. In this case
// we cannot render either.
if (!fbo)
@@ -327,7 +327,7 @@ void QQuickWidgetPrivate::renderSceneGraph()
render(true);
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
if (q->window()->graphicsProxyWidget())
QWidgetPrivate::nearestGraphicsProxyWidget(q)->update();
else
@@ -343,7 +343,7 @@ void QQuickWidgetPrivate::renderSceneGraph()
QImage QQuickWidgetPrivate::grabFramebuffer()
{
if (!useSoftwareRenderer) {
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (!context)
return QImage();
@@ -835,7 +835,7 @@ void QQuickWidgetPrivate::handleContextCreationFailure(const QSurfaceFormat &for
// Never called by Software Rendering backend
void QQuickWidgetPrivate::createContext()
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
Q_Q(QQuickWidget);
// On hide-show we may invalidate() (when !isPersistentSceneGraph) but our
@@ -886,7 +886,7 @@ void QQuickWidgetPrivate::destroyContext()
{
delete offscreenSurface;
offscreenSurface = 0;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
delete context;
context = 0;
#endif
@@ -914,7 +914,7 @@ void QQuickWidget::createFramebufferObject()
return;
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QOpenGLContext *context = d->offscreenWindow->openglContext();
if (!context) {
@@ -995,7 +995,7 @@ void QQuickWidget::destroyFramebufferObject()
return;
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
delete d->fbo;
d->fbo = 0;
delete d->resolvedFbo;
@@ -1078,7 +1078,7 @@ void QQuickWidgetPrivate::setRootObject(QObject *obj)
}
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
GLuint QQuickWidgetPrivate::textureId() const
{
Q_Q(const QQuickWidget);
@@ -1180,7 +1180,7 @@ void QQuickWidget::resizeEvent(QResizeEvent *e)
createFramebufferObject();
}
} else {
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (d->context) {
// Bail out when receiving a resize after scenegraph invalidation. This can happen
// during hide - resize - show sequences and also during application exit.
@@ -1335,7 +1335,7 @@ void QQuickWidget::mouseReleaseEvent(QMouseEvent *e)
e->setAccepted(mappedEvent.isAccepted());
}
-#ifndef QT_NO_WHEELEVENT
+#if QT_CONFIG(wheelevent)
/*! \reimp */
void QQuickWidget::wheelEvent(QWheelEvent *e)
{
@@ -1408,14 +1408,14 @@ bool QQuickWidget::event(QEvent *e)
d->offscreenWindow->setScreen(newScreen);
if (d->offscreenSurface)
d->offscreenSurface->setScreen(newScreen);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (d->context)
d->context->setScreen(newScreen);
#endif
}
if (d->useSoftwareRenderer
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
|| d->fbo
#endif
) {
@@ -1442,7 +1442,7 @@ bool QQuickWidget::event(QEvent *e)
return QWidget::event(e);
}
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
/*! \reimp */
void QQuickWidget::dragEnterEvent(QDragEnterEvent *e)
@@ -1477,7 +1477,7 @@ void QQuickWidget::dropEvent(QDropEvent *e)
d->offscreenWindow->event(e);
}
-#endif // QT_NO_DRAGANDDROP
+#endif // draganddrop
// TODO: try to separate the two cases of
// 1. render() unconditionally without sync
@@ -1589,9 +1589,6 @@ QQuickWindow *QQuickWidget::quickWindow() const
return d->offscreenWindow;
}
-QT_END_NAMESPACE
-
-
void QQuickWidget::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
@@ -1612,3 +1609,5 @@ void QQuickWidget::paintEvent(QPaintEvent *event)
}
}
}
+
+QT_END_NAMESPACE
diff --git a/src/quickwidgets/qquickwidget.h b/src/quickwidgets/qquickwidget.h
index 56e6b01ac5..2d159778ed 100644
--- a/src/quickwidgets/qquickwidget.h
+++ b/src/quickwidgets/qquickwidget.h
@@ -131,11 +131,11 @@ protected:
void focusInEvent(QFocusEvent * event) override;
void focusOutEvent(QFocusEvent * event) override;
-#ifndef QT_NO_WHEELEVENT
+#if QT_CONFIG(wheelevent)
void wheelEvent(QWheelEvent *) override;
#endif
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
void dragEnterEvent(QDragEnterEvent *) override;
void dragMoveEvent(QDragMoveEvent *) override;
void dragLeaveEvent(QDragLeaveEvent *) override;
diff --git a/src/quickwidgets/qquickwidget_p.h b/src/quickwidgets/qquickwidget_p.h
index 3d64981797..559321cd51 100644
--- a/src/quickwidgets/qquickwidget_p.h
+++ b/src/quickwidgets/qquickwidget_p.h
@@ -87,7 +87,7 @@ public:
~QQuickWidgetPrivate();
void execute();
- void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) Q_DECL_OVERRIDE;
+ void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
void initResize();
void updateSize();
void updatePosition();
@@ -101,7 +101,7 @@ public:
QObject *focusObject() Q_DECL_OVERRIDE;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
GLuint textureId() const Q_DECL_OVERRIDE;
QImage grabFramebuffer() Q_DECL_OVERRIDE;
#else
@@ -126,7 +126,7 @@ public:
QOffscreenSurface *offscreenSurface;
QQuickRenderControl *renderControl;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QOpenGLFramebufferObject *fbo;
QOpenGLFramebufferObject *resolvedFbo;
QOpenGLContext *context;
diff --git a/sync.profile b/sync.profile
index cde4afa693..6cab0ae358 100644
--- a/sync.profile
+++ b/sync.profile
@@ -13,14 +13,3 @@
);
%deprecatedheaders = (
);
-# Module dependencies.
-# Every module that is required to build this module should have one entry.
-# Each of the module version specifiers can take one of the following values:
-# - A specific Git revision.
-# - any git symbolic ref resolvable from the module's repository (e.g. "refs/heads/master" to track master branch)
-# - an empty string to use the same branch under test (dependencies will become "refs/heads/master" if we are in the master branch)
-#
-%dependencies = (
- "qtbase" => "5.8",
- "qtxmlpatterns" => "5.8",
-);
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 556f5ddc7a..f25742fb14 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -2,6 +2,7 @@ TEMPLATE=subdirs
SUBDIRS=\
qml \
quick \
+ quicktest \
qmltest \
qmldevtools \
cmake \
diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/data/test.qml b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/data/test.qml
index a36d0cae91..0fa9f1ffd8 100644
--- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/data/test.qml
+++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/data/test.qml
@@ -36,6 +36,7 @@ Item {
var b = {a: "hello", d: 1 }
var c
var d = 12
+ console.log("Component.onCompleted");
}
function foo() {
var a = [1, 2]
diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp
index 8d1a165243..3aa3a5c87e 100644
--- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp
+++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp
@@ -142,24 +142,36 @@ void tst_QQmlDebuggingEnabler::cleanup()
void tst_QQmlDebuggingEnabler::data()
{
+ QTest::addColumn<QString>("connector");
QTest::addColumn<bool>("blockMode");
QTest::addColumn<QStringList>("services");
- QTest::newRow("noblock,all") << false << QStringList();
- QTest::newRow("block,all") << true << QStringList();
- QTest::newRow("noblock,debugger") << false << QQmlDebuggingEnabler::debuggerServices();
- QTest::newRow("block,debugger") << true << QQmlDebuggingEnabler::debuggerServices();
- QTest::newRow("noblock,inspector") << false << QQmlDebuggingEnabler::inspectorServices();
- QTest::newRow("block,inspector") << true << QQmlDebuggingEnabler::inspectorServices();
- QTest::newRow("noblock,profiler") << false << QQmlDebuggingEnabler::profilerServices();
- QTest::newRow("block,profiler") << true << QQmlDebuggingEnabler::profilerServices();
- QTest::newRow("noblock,debugger+inspector")
- << false << QQmlDebuggingEnabler::debuggerServices() +
- QQmlDebuggingEnabler::inspectorServices();
- QTest::newRow("block,debugger+inspector")
- << true << QQmlDebuggingEnabler::debuggerServices() +
- QQmlDebuggingEnabler::inspectorServices();
-
+ QStringList connectors({
+ QLatin1String("QQmlDebugServer"),
+ QLatin1String("QQmlNativeDebugConnector")
+ });
+
+ QList<bool> blockModes({ true, false });
+
+ QList<QStringList> serviceLists({
+ QStringList(),
+ QQmlDebuggingEnabler::nativeDebuggerServices(),
+ QQmlDebuggingEnabler::debuggerServices(),
+ QQmlDebuggingEnabler::inspectorServices(),
+ QQmlDebuggingEnabler::profilerServices(),
+ QQmlDebuggingEnabler::debuggerServices() + QQmlDebuggingEnabler::inspectorServices()
+ });
+
+ foreach (const QString &connector, connectors) {
+ foreach (bool blockMode, blockModes) {
+ foreach (const QStringList &serviceList, serviceLists) {
+ QString name = connector + QLatin1Char(',')
+ + QLatin1String(blockMode ? "block" : "noblock") + QLatin1Char(',')
+ + serviceList.join(QLatin1Char('-'));
+ QTest::newRow(name.toUtf8().constData()) << connector << blockMode << serviceList;
+ }
+ }
+ }
}
void tst_QQmlDebuggingEnabler::qmlscene_data()
@@ -169,27 +181,36 @@ void tst_QQmlDebuggingEnabler::qmlscene_data()
void tst_QQmlDebuggingEnabler::qmlscene()
{
+ QFETCH(QString, connector);
QFETCH(bool, blockMode);
QFETCH(QStringList, services);
- connection = new QQmlDebugConnection();
- QList<QQmlDebugClient *> clients = QQmlDebugTest::createOtherClients(connection);
process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene",
this);
process->setMaximumBindErrors(1);
process->start(QStringList()
- << QString::fromLatin1("-qmljsdebugger=port:5555,5565%1%2%3")
+ << QString::fromLatin1("-qmljsdebugger=connector:%1%2%3%4")
+ .arg(connector + (connector == QLatin1String("QQmlDebugServer") ?
+ QLatin1String(",port:5555,5565") : QString()))
.arg(blockMode ? QLatin1String(",block") : QString())
.arg(services.isEmpty() ? QString() : QString::fromLatin1(",services:"))
.arg(services.isEmpty() ? QString() : services.join(","))
<< testFile(QLatin1String("test.qml")));
- QVERIFY(process->waitForSessionStart());
- connection->connectToHost("127.0.0.1", process->debugPort());
- QVERIFY(connection->waitForConnected());
- foreach (QQmlDebugClient *client, clients)
- QCOMPARE(client->state(), (services.isEmpty() || services.contains(client->name())) ?
- QQmlDebugClient::Enabled : QQmlDebugClient::Unavailable);
+ if (connector == QLatin1String("QQmlDebugServer")) {
+ QVERIFY(process->waitForSessionStart());
+ connection = new QQmlDebugConnection();
+ QList<QQmlDebugClient *> clients = QQmlDebugTest::createOtherClients(connection);
+ connection->connectToHost("127.0.0.1", process->debugPort());
+ QVERIFY(connection->waitForConnected());
+ foreach (QQmlDebugClient *client, clients)
+ QCOMPARE(client->state(), (services.isEmpty() || services.contains(client->name())) ?
+ QQmlDebugClient::Enabled : QQmlDebugClient::Unavailable);
+ }
+
+ QCOMPARE(process->state(), QLatin1String("running"));
+ if (!blockMode)
+ QTRY_VERIFY(process->output().contains(QLatin1String("qml: Component.onCompleted")));
}
void tst_QQmlDebuggingEnabler::custom_data()
@@ -199,13 +220,12 @@ void tst_QQmlDebuggingEnabler::custom_data()
void tst_QQmlDebuggingEnabler::custom()
{
+ QFETCH(QString, connector);
QFETCH(bool, blockMode);
QFETCH(QStringList, services);
const int portFrom = 5555;
const int portTo = 5565;
- connection = new QQmlDebugConnection();
- QList<QQmlDebugClient *> clients = QQmlDebugTest::createOtherClients(connection);
process = new QQmlDebugProcess(QCoreApplication::applicationDirPath() +
QLatin1String("/qqmldebuggingenablerserver"), this);
process->setMaximumBindErrors(portTo - portFrom);
@@ -214,18 +234,28 @@ void tst_QQmlDebuggingEnabler::custom()
if (blockMode)
args << QLatin1String("-block");
- args << QString::number(portFrom) << QString::number(portTo);
+ args << QLatin1String("-connector") << connector
+ << QString::number(portFrom) << QString::number(portTo);
+
if (!services.isEmpty())
args << QLatin1String("-services") << services;
process->start(args);
- QVERIFY(process->waitForSessionStart());
- connection->connectToHost("127.0.0.1", process->debugPort());
- QVERIFY(connection->waitForConnected());
- foreach (QQmlDebugClient *client, clients)
- QCOMPARE(client->state(), (services.isEmpty() || services.contains(client->name())) ?
- QQmlDebugClient::Enabled : QQmlDebugClient::Unavailable);
+ if (connector == QLatin1String("QQmlDebugServer")) {
+ QVERIFY(process->waitForSessionStart());
+ connection = new QQmlDebugConnection();
+ QList<QQmlDebugClient *> clients = QQmlDebugTest::createOtherClients(connection);
+ connection->connectToHost("127.0.0.1", process->debugPort());
+ QVERIFY(connection->waitForConnected());
+ foreach (QQmlDebugClient *client, clients)
+ QCOMPARE(client->state(), (services.isEmpty() || services.contains(client->name())) ?
+ QQmlDebugClient::Enabled : QQmlDebugClient::Unavailable);
+ }
+
+ QCOMPARE(process->state(), QLatin1String("running"));
+ if (!blockMode)
+ QTRY_VERIFY(process->output().contains(QLatin1String("QQmlEngine created")));
}
QTEST_MAIN(tst_QQmlDebuggingEnabler)
diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp
index cfbb31f9e1..a064bbbacc 100644
--- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp
+++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp
@@ -28,6 +28,7 @@
#include <QtCore/qcoreapplication.h>
#include <QtCore/qlibraryinfo.h>
+#include <QtCore/qdebug.h>
#include <QtQml/qqmldebug.h>
#include <QtQml/qqmlengine.h>
@@ -40,12 +41,18 @@ int main(int argc, char *argv[])
QCoreApplication app(argc, argv);
QStringList arguments = app.arguments();
arguments.removeFirst();
+ QString connector = QLatin1String("QQmlDebugServer");
if (arguments.size() && arguments.first() == QLatin1String("-block")) {
block = QQmlDebuggingEnabler::WaitForClient;
arguments.removeFirst();
}
+ if (arguments.size() >= 2 && arguments.first() == QLatin1String("-connector")) {
+ arguments.removeFirst();
+ connector = arguments.takeFirst();
+ }
+
if (arguments.size() >= 2) {
portFrom = arguments.takeFirst().toInt();
portTo = arguments.takeFirst().toInt();
@@ -54,12 +61,20 @@ int main(int argc, char *argv[])
if (arguments.size() && arguments.takeFirst() == QLatin1String("-services"))
QQmlDebuggingEnabler::setServices(arguments);
- if (!portFrom || !portTo)
- qFatal("Port range has to be specified.");
+ if (connector == QLatin1String("QQmlDebugServer")) {
+ if (!portFrom || !portTo)
+ qFatal("Port range has to be specified.");
+
+ while (portFrom <= portTo)
+ QQmlDebuggingEnabler::startTcpDebugServer(portFrom++, block);
+ } else if (connector == QLatin1String("QQmlNativeDebugConnector")) {
+ QVariantHash configuration;
+ configuration[QLatin1String("block")] = (block == QQmlDebuggingEnabler::WaitForClient);
+ QQmlDebuggingEnabler::startDebugConnector(connector, configuration);
+ }
- while (portFrom <= portTo)
- QQmlDebuggingEnabler::startTcpDebugServer(portFrom++, block);
QQmlEngine engine;
+ qDebug() << "QQmlEngine created\n";
Q_UNUSED(engine);
return app.exec();
}
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro
index 79e772c1ee..cbaf3b5309 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro
+++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro
@@ -9,6 +9,7 @@ SOURCES += tst_qqmldebugjs.cpp
INCLUDEPATH += ../../shared
include(../../../../shared/util.pri)
include(../../shared/debugutil.pri)
+include(../../shared/qqmlenginedebugclient.pri)
TESTDATA = data/*
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp
index d1150be831..31b8d63ec2 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp
+++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp
@@ -27,6 +27,7 @@
****************************************************************************/
#include "debugutil_p.h"
+#include "../../shared/qqmlenginedebugclient.h"
#include "../../../../shared/util.h"
#include <private/qqmldebugclient_p.h>
@@ -52,6 +53,7 @@ const char *STEPACTION = "stepaction";
const char *STEPCOUNT = "stepcount";
const char *EXPRESSION = "expression";
const char *FRAME = "frame";
+const char *CONTEXT = "context";
const char *GLOBAL = "global";
const char *DISABLEBREAK = "disable_break";
const char *HANDLES = "handles";
@@ -215,6 +217,8 @@ private slots:
void evaluateInLocalScope_data() { targetData(); }
void evaluateInLocalScope();
+ void evaluateInContext();
+
void getScripts_data() { targetData(); }
void getScripts();
@@ -257,7 +261,7 @@ public:
void interrupt();
void continueDebugging(StepAction stepAction);
- void evaluate(QString expr, int frame = -1);
+ void evaluate(QString expr, int frame = -1, int context = -1);
void lookup(QList<int> handles, bool includeSource = false);
void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false);
void frame(int number = -1);
@@ -280,6 +284,7 @@ signals:
void connected();
void interruptRequested();
void result();
+ void failure();
void stopped();
private:
@@ -340,13 +345,14 @@ void QJSDebugClient::continueDebugging(StepAction action)
sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
}
-void QJSDebugClient::evaluate(QString expr, int frame)
+void QJSDebugClient::evaluate(QString expr, int frame, int context)
{
// { "seq" : <number>,
// "type" : "request",
// "command" : "evaluate",
// "arguments" : { "expression" : <expression to evaluate>,
- // "frame" : <number>
+ // "frame" : <number>,
+ // "context" : <object ID>
// }
// }
VARIANTMAPINIT;
@@ -358,6 +364,9 @@ void QJSDebugClient::evaluate(QString expr, int frame)
if (frame != -1)
args.setProperty(QLatin1String(FRAME),QJSValue(frame));
+ if (context != -1)
+ args.setProperty(QLatin1String(CONTEXT), QJSValue(context));
+
if (!args.isUndefined()) {
jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
}
@@ -684,6 +693,7 @@ void QJSDebugClient::messageReceived(const QByteArray &data)
if (type == "response") {
if (!value.value("success").toBool()) {
+ emit failure();
qDebug() << "Received success == false response from application";
return;
}
@@ -1394,6 +1404,58 @@ void tst_QQmlDebugJS::evaluateInLocalScope()
QCOMPARE(body.value("value").toInt(),10);
}
+void tst_QQmlDebugJS::evaluateInContext()
+{
+ connection = new QQmlDebugConnection();
+ process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath)
+ + "/qmlscene", this);
+ client = new QJSDebugClient(connection);
+ QScopedPointer<QQmlEngineDebugClient> engineClient(new QQmlEngineDebugClient(connection));
+ process->start(QStringList() << QLatin1String(BLOCKMODE) << testFile(ONCOMPLETED_QMLFILE));
+
+ QVERIFY(process->waitForSessionStart());
+
+ connection->connectToHost("127.0.0.1", process->debugPort());
+ QVERIFY(connection->waitForConnected());
+
+ QTRY_COMPARE(client->state(), QQmlEngineDebugClient::Enabled);
+ QTRY_COMPARE(engineClient->state(), QQmlEngineDebugClient::Enabled);
+ client->connect();
+
+ // "a" not accessible without extra context
+ client->evaluate(QLatin1String("a + 10"), -1, -1);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(failure())));
+
+ bool success = false;
+ engineClient->queryAvailableEngines(&success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(engineClient.data(), SIGNAL(result())));
+
+ QVERIFY(engineClient->engines().count());
+ engineClient->queryRootContexts(engineClient->engines()[0].debugId, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(engineClient.data(), SIGNAL(result())));
+
+ auto contexts = engineClient->rootContext().contexts;
+ QCOMPARE(contexts.count(), 1);
+ auto objects = contexts[0].objects;
+ QCOMPARE(objects.count(), 1);
+ engineClient->queryObjectRecursive(objects[0], &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(engineClient.data(), SIGNAL(result())));
+ auto object = engineClient->object();
+
+ // "a" accessible in context of surrounding object
+ client->evaluate(QLatin1String("a + 10"), -1, object.debugId);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+
+ QString jsonString = client->response;
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+ QTRY_COMPARE(body.value("value").toInt(), 20);
+}
+
void tst_QQmlDebugJS::getScripts()
{
//void scripts(int types = -1, QList<int> ids = QList<int>(), bool includeSource = false, QVariant filter = QVariant());
diff --git a/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp b/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp
index a503da4e4b..8d21a8a45a 100644
--- a/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp
+++ b/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp
@@ -51,12 +51,6 @@ private:
QQmlDebugConnection *m_conn;
QQmlDebugTestService *m_service;
- bool connect();
-
-signals:
- void waiting();
- void parallel();
-
private slots:
void initTestCase();
@@ -75,12 +69,13 @@ void tst_QQmlDebugLocal::initTestCase()
const QString waitingMsg = QString("QML Debugger: Connecting to socket %1...").arg(fileName);
QTest::ignoreMessage(QtDebugMsg, waitingMsg.toLatin1().constData());
+ QQmlDebuggingEnabler::connectToLocalDebugger(fileName);
+
+ QTest::qWait(1000);
m_conn = new QQmlDebugConnection(this);
m_conn->startLocalServer(fileName);
- QQmlDebuggingEnabler::connectToLocalDebugger(fileName);
-
new QQmlEngine(this);
QQmlDebugTestClient client("tst_QQmlDebugLocal::handshake()", m_conn);
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
index c4b17aa60a..692e70d7da 100644
--- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
@@ -618,7 +618,7 @@ void tst_QQmlProfilerService::scenegraphData()
// if the clocks are acting up.
qint64 contextFrameTime = -1;
qint64 renderFrameTime = -1;
-#ifndef QT_NO_OPENGL //Software renderer doesn't have context frames
+#if QT_CONFIG(opengl) //Software renderer doesn't have context frames
foreach (const QQmlProfilerData &msg, m_client->asynchronousMessages) {
if (msg.messageType == QQmlProfilerDefinitions::SceneGraphFrame) {
if (msg.detailType == QQmlProfilerDefinitions::SceneGraphContextFrame) {
diff --git a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
index a23b7e37eb..6793596174 100644
--- a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
+++ b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
@@ -41,6 +41,7 @@
#include <private/qv4isel_moth_p.h>
#include <private/qv4string_p.h>
#include <private/qqmlbuiltinfunctions_p.h>
+#include <private/qqmldebugservice_p.h>
using namespace QV4;
using namespace QV4::Debugging;
@@ -203,8 +204,8 @@ public slots:
while (!m_expressionRequests.isEmpty()) {
Q_ASSERT(debugger->state() == QV4Debugger::Paused);
ExpressionRequest request = m_expressionRequests.takeFirst();
- ExpressionEvalJob job(debugger->engine(), request.frameNr, request.expression,
- &collector);
+ ExpressionEvalJob job(debugger->engine(), request.frameNr, request.context,
+ request.expression, &collector);
debugger->runInEngine(&job);
m_expressionResults << job.returnValue();
m_expressionRefs << job.refs();
@@ -276,6 +277,7 @@ public:
struct ExpressionRequest {
QString expression;
int frameNr;
+ int context;
};
QVector<ExpressionRequest> m_expressionRequests;
QList<QJsonObject> m_expressionResults;
@@ -726,24 +728,34 @@ void tst_qv4debugger::evaluateExpression()
TestAgent::ExpressionRequest request;
request.expression = "x";
request.frameNr = 0;
+ request.context = -1; // no extra context
m_debuggerAgent->m_expressionRequests << request;
request.expression = "x";
request.frameNr = 1;
m_debuggerAgent->m_expressionRequests << request;
+ request.context = 5355; // invalid context object
+ m_debuggerAgent->m_expressionRequests << request;
+
+ QObject object; // some object without QML context
+ request.context = QQmlDebugService::idForObject(&object);
+ m_debuggerAgent->m_expressionRequests << request;
+
debugger()->addBreakPoint("evaluateExpression", 3);
evaluateJavaScript(script, "evaluateExpression");
- QCOMPARE(m_debuggerAgent->m_expressionRefs.count(), 2);
+ QCOMPARE(m_debuggerAgent->m_expressionRefs.count(), 4);
QCOMPARE(m_debuggerAgent->m_expressionRefs[0].size(), 1);
QJsonObject result0 = m_debuggerAgent->m_expressionRefs[0].first().toObject();
QCOMPARE(result0.value("type").toString(), QStringLiteral("number"));
QCOMPARE(result0.value("value").toInt(), 10);
- QCOMPARE(m_debuggerAgent->m_expressionRefs[1].size(), 1);
- QJsonObject result1 = m_debuggerAgent->m_expressionRefs[1].first().toObject();
- QCOMPARE(result1.value("type").toString(), QStringLiteral("number"));
- QCOMPARE(result1.value("value").toInt(), 20);
+ for (int i = 1; i < 4; ++i) {
+ QCOMPARE(m_debuggerAgent->m_expressionRefs[i].size(), 1);
+ QJsonObject result1 = m_debuggerAgent->m_expressionRefs[1].first().toObject();
+ QCOMPARE(result1.value("type").toString(), QStringLiteral("number"));
+ QCOMPARE(result1.value("value").toInt(), 20);
+ }
}
QTEST_MAIN(tst_qv4debugger)
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index f6fbb8c37e..82bc3d0c59 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -196,6 +196,8 @@ private slots:
void basicBlockMergeAfterLoopPeeling();
+ void malformedExpression();
+
signals:
void testSignal();
};
@@ -4079,6 +4081,12 @@ void tst_QJSEngine::basicBlockMergeAfterLoopPeeling()
}
+void tst_QJSEngine::malformedExpression()
+{
+ QJSEngine engine;
+ engine.evaluate("5%55555&&5555555\n7-0");
+}
+
QTEST_MAIN(tst_QJSEngine)
#include "tst_qjsengine.moc"
diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
index d28bbc1ffa..12c33909cf 100644
--- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
+++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
@@ -1372,6 +1372,33 @@ void tst_QJSValue::hasProperty_changePrototype()
QVERIFY(obj.hasOwnProperty("foo"));
}
+void tst_QJSValue::hasProperty_QTBUG56830_data()
+{
+ QTest::addColumn<QString>("key");
+ QTest::addColumn<QString>("lookup");
+
+ QTest::newRow("bugreport-1") << QStringLiteral("240000000000") << QStringLiteral("3776798720");
+ QTest::newRow("bugreport-2") << QStringLiteral("240000000001") << QStringLiteral("3776798721");
+ QTest::newRow("biggest-ok-before-bug") << QStringLiteral("238609294221") << QStringLiteral("2386092941");
+ QTest::newRow("smallest-bugged") << QStringLiteral("238609294222") << QStringLiteral("2386092942");
+ QTest::newRow("biggest-bugged") << QStringLiteral("249108103166") << QStringLiteral("12884901886");
+ QTest::newRow("smallest-ok-after-bug") << QStringLiteral("249108103167") << QStringLiteral("12884901887");
+}
+
+void tst_QJSValue::hasProperty_QTBUG56830()
+{
+ QFETCH(QString, key);
+ QFETCH(QString, lookup);
+
+ QJSEngine eng;
+ const QJSValue value(42);
+
+ QJSValue obj = eng.newObject();
+ obj.setProperty(key, value);
+ QVERIFY(obj.hasProperty(key));
+ QVERIFY(!obj.hasProperty(lookup));
+}
+
void tst_QJSValue::deleteProperty_basic()
{
QJSEngine eng;
diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.h b/tests/auto/qml/qjsvalue/tst_qjsvalue.h
index 6ed880c865..b8b9f4403c 100644
--- a/tests/auto/qml/qjsvalue/tst_qjsvalue.h
+++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.h
@@ -92,6 +92,8 @@ private slots:
void hasProperty_basic();
void hasProperty_globalObject();
void hasProperty_changePrototype();
+ void hasProperty_QTBUG56830_data();
+ void hasProperty_QTBUG56830();
void deleteProperty_basic();
void deleteProperty_globalObject();
diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
index e2c0055ea1..8af446173d 100644
--- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
+++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
@@ -549,7 +549,6 @@ void tst_qmldiskcache::cacheResources()
{
CleanlyLoadingComponent component(&engine, QUrl("qrc:/test.qml"));
- qDebug() << component.errorString();
QScopedPointer<QObject> obj(component.create());
QVERIFY(!obj.isNull());
QCOMPARE(obj->property("value").toInt(), 20);
@@ -558,12 +557,36 @@ void tst_qmldiskcache::cacheResources()
const QStringList entries = QDir(qmlCacheDirectory).entryList(QDir::NoDotAndDotDot | QDir::Files);
QCOMPARE(entries.count(), 1);
+ QDateTime cacheFileTimeStamp;
+
{
QFile cacheFile(qmlCacheDirectory + QLatin1Char('/') + entries.constFirst());
QVERIFY2(cacheFile.open(QIODevice::ReadOnly), qPrintable(cacheFile.errorString()));
QV4::CompiledData::Unit unit;
QVERIFY(cacheFile.read(reinterpret_cast<char *>(&unit), sizeof(unit)) == sizeof(unit));
- QCOMPARE(qint64(unit.sourceTimeStamp), QFileInfo(QCoreApplication::applicationFilePath()).lastModified().toMSecsSinceEpoch());
+
+ cacheFileTimeStamp = QFileInfo(cacheFile.fileName()).lastModified();
+
+ QDateTime referenceTimeStamp = QFileInfo(":/test.qml").lastModified();
+ if (!referenceTimeStamp.isValid())
+ referenceTimeStamp = QFileInfo(QCoreApplication::applicationFilePath()).lastModified();
+ QCOMPARE(qint64(unit.sourceTimeStamp), referenceTimeStamp.toMSecsSinceEpoch());
+ }
+
+ waitForFileSystem();
+
+ {
+ CleanlyLoadingComponent component(&engine, QUrl("qrc:///test.qml"));
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+ QCOMPARE(obj->property("value").toInt(), 20);
+ }
+
+ {
+ const QStringList entries = QDir(qmlCacheDirectory).entryList(QDir::NoDotAndDotDot | QDir::Files);
+ QCOMPARE(entries.count(), 1);
+
+ QCOMPARE(QFileInfo(qmlCacheDirectory + QLatin1Char('/') + entries.constFirst()).lastModified().toMSecsSinceEpoch(), cacheFileTimeStamp.toMSecsSinceEpoch());
}
}
diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp
index 7e4a643ffa..3ed0aa7446 100644
--- a/tests/auto/qml/qmlmin/tst_qmlmin.cpp
+++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp
@@ -86,7 +86,6 @@ void tst_qmlmin::initTestCase()
// Add invalid files (i.e. files with syntax errors)
invalidFiles << "tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml";
- invalidFiles << "tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml";
invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.2.qml";
invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.3.qml";
invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.5.qml";
diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
index a401e04020..98b92e5fab 100644
--- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
+++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
@@ -96,7 +96,7 @@ void tst_qqmlapplicationengine::application()
Note that checking the output means that on builds with extra debugging, this might fail with a false positive.
Also the testapp is automatically built and installed in shadow builds, so it does NOT use testData
*/
-#ifndef QT_NO_PROCESS
+#if QT_CONFIG(process)
QDir::setCurrent(buildDir);
QProcess *testProcess = new QProcess(this);
QStringList args;
@@ -114,9 +114,9 @@ void tst_qqmlapplicationengine::application()
QVERIFY(QString(test_stderr).endsWith(QString(test_stderr_target)));
delete testProcess;
QDir::setCurrent(srcDir);
-#else // !QT_NO_PROCESS
+#else // process
QSKIP("No process support");
-#endif // QT_NO_PROCESS
+#endif // process
}
void tst_qqmlapplicationengine::applicationProperties()
diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
index 723f575330..f2b0b9973e 100644
--- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
+++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
@@ -37,7 +37,9 @@
#include <QtQuick/private/qquickmousearea_p.h>
#include <private/qv8engine_p.h>
#include <private/qqmlcontext_p.h>
+#include <private/qv4qmlcontext_p.h>
#include <private/qv4scopedvalue_p.h>
+#include <private/qv4qmlcontext_p.h>
#include <qcolor.h>
#include "../../shared/util.h"
#include "testhttpserver.h"
diff --git a/tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml b/tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml
new file mode 100644
index 0000000000..d5aa0f102a
--- /dev/null
+++ b/tests/auto/qml/qqmlconnections/data/test-connection-implicit.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.0
+
+Item {
+ width: 50
+
+ property bool tested: false
+
+ Connections { onWidthChanged: tested = true }
+}
diff --git a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp
index 615de0885a..b3ac1ce958 100644
--- a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp
+++ b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp
@@ -52,6 +52,7 @@ private slots:
void rewriteErrors();
void singletonTypeTarget();
void enableDisable_QTBUG_36350();
+ void clearImplicitTarget();
private:
QQmlEngine engine;
@@ -352,6 +353,32 @@ void tst_qqmlconnections::enableDisable_QTBUG_36350()
delete item;
}
+//QTBUG-56499
+void tst_qqmlconnections::clearImplicitTarget()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("test-connection-implicit.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
+
+ QVERIFY(item != 0);
+
+ // normal case: fire Connections
+ item->setWidth(100.);
+ QCOMPARE(item->property("tested").toBool(), true);
+
+ item->setProperty("tested", false);
+ // clear the implicit target
+ QQmlConnections *connections = item->findChild<QQmlConnections*>();
+ QVERIFY(connections);
+ connections->setTarget(0);
+
+ // target cleared: no longer fire Connections
+ item->setWidth(150.);
+ QCOMPARE(item->property("tested").toBool(), false);
+
+ delete item;
+}
+
QTEST_MAIN(tst_qqmlconnections)
#include "tst_qqmlconnections.moc"
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index be04ec2bf3..88a8886ecb 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -36,7 +36,7 @@
#include <QtCore/qnumeric.h>
#include <private/qqmlengine_p.h>
#include <private/qqmlvmemetaobject_p.h>
-#include <private/qqmlcontextwrapper_p.h>
+#include <private/qv4qmlcontext_p.h>
#include "testtypes.h"
#include "testhttpserver.h"
#include "../../shared/util.h"
@@ -3986,7 +3986,7 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) {
{
QV4::Scope scope(QV8Engine::getV4((engine)));
- QV4::ScopedValue temporaryScope(scope, QV4::QmlContextWrapper::qmlScope(scope.engine, scriptContext, 0));
+ QV4::ScopedContext temporaryScope(scope, QV4::QmlContext::create(scope.engine->rootContext(), scriptContext, 0));
Q_UNUSED(temporaryScope)
}
diff --git a/tests/auto/qml/qqmllanguage/data/QtObjectWithChildren.qml b/tests/auto/qml/qqmllanguage/data/QtObjectWithChildren.qml
new file mode 100644
index 0000000000..bb28e22110
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/QtObjectWithChildren.qml
@@ -0,0 +1,5 @@
+import QtQml 2.0
+
+QtObject {
+ default property list<QtObject> myChildren;
+}
diff --git a/tests/auto/qml/qqmllanguage/data/defaultListProperty.qml b/tests/auto/qml/qqmllanguage/data/defaultListProperty.qml
new file mode 100644
index 0000000000..d68ffd2979
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/defaultListProperty.qml
@@ -0,0 +1,6 @@
+import QtQml 2.0
+
+QtObjectWithChildren {
+ QtObject {
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml
index 319e1f5bc5..f028e5dcac 100644
--- a/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml
@@ -1,7 +1,7 @@
import QtQuick 2.0
import QtQuick 2.0 as Qt47
-Qt.QtObject {
+Qt47.QtObject {
property Qt47.QtObject objectProperty
property list<Qt47.QtObject> objectPropertyList
diff --git a/tests/auto/qml/qqmllanguage/data/namespacedPropertyTypes.qml b/tests/auto/qml/qqmllanguage/data/namespacedPropertyTypes.qml
new file mode 100644
index 0000000000..5ad62edab3
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/namespacedPropertyTypes.qml
@@ -0,0 +1,8 @@
+import QtQuick 2.0 as MyQuick
+
+MyQuick.Item {
+ property MyQuick.Item myProp;
+ property list<MyQuick.Item> myList;
+ default property list<MyQuick.Item> myDefaultList;
+ signal mySignal(MyQuick.Item someItem)
+}
diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp
index 3af7645ff7..bc8c192a61 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.cpp
+++ b/tests/auto/qml/qqmllanguage/testtypes.cpp
@@ -128,12 +128,11 @@ void CustomBinding::componentComplete()
QQmlContextData *context = QQmlContextData::get(qmlContext(this));
- QV4::Scope scope(QQmlEnginePrivate::getV4Engine(qmlEngine(this)));
- QV4::ScopedValue function(scope, QV4::FunctionObject::createQmlFunction(context, m_target, compilationUnit->runtimeFunctions[bindingId]));
-
QQmlProperty property(m_target, name, qmlContext(this));
+ QV4::Scope scope(QQmlEnginePrivate::getV4Engine(qmlEngine(this)));
+ QV4::Scoped<QV4::QmlContext> qmlContext(scope, QV4::QmlContext::create(scope.engine->rootContext(), context, m_target));
QQmlBinding *qmlBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core,
- function, m_target, context);
+ compilationUnit->runtimeFunctions[bindingId], m_target, context, qmlContext);
qmlBinding->setTarget(property);
QQmlPropertyPrivate::setBinding(property, qmlBinding);
}
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index ad06946b0b..f586f7d429 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -254,6 +254,9 @@ private slots:
void arrayBuffer_data();
void arrayBuffer();
+ void defaultListProperty();
+ void namespacedPropertyTypes();
+
private:
QQmlEngine engine;
QStringList defaultImportPathList;
@@ -1395,7 +1398,6 @@ void tst_qqmllanguage::dynamicObjectProperties()
}
{
QQmlComponent component(&engine, testFileUrl("dynamicObjectProperties.2.qml"));
- QEXPECT_FAIL("", "QTBUG-10822", Abort);
VERIFY_ERRORS(0);
QObject *object = component.create();
QVERIFY(object != 0);
@@ -4233,6 +4235,21 @@ void tst_qqmllanguage::arrayBuffer()
QCOMPARE(object->property("ok").toBool(), true);
}
+void tst_qqmllanguage::defaultListProperty()
+{
+ QQmlComponent component(&engine, testFileUrl("defaultListProperty.qml"));
+ VERIFY_ERRORS(0);
+ QScopedPointer<QObject> o(component.create());
+}
+
+void tst_qqmllanguage::namespacedPropertyTypes()
+{
+ QQmlComponent component(&engine, testFileUrl("namespacedPropertyTypes.qml"));
+ VERIFY_ERRORS(0);
+ QScopedPointer<QObject> o(component.create());
+ QVERIFY(!o.isNull());
+}
+
QTEST_MAIN(tst_qqmllanguage)
#include "tst_qqmllanguage.moc"
diff --git a/tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml b/tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml
new file mode 100644
index 0000000000..6bf750dcda
--- /dev/null
+++ b/tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml
@@ -0,0 +1,27 @@
+import QtQuick 2.0
+
+QtObject {
+ property ListModel model: ListModel {
+ ListElement { modified: false }
+ ListElement { modified: false }
+ ListElement { modified: false }
+ ListElement { modified: false }
+ ListElement { modified: false }
+ }
+
+ property bool isModified: {
+ for (var i = 0; i < model.count; ++i) {
+ if (model.get(i).modified)
+ return true;
+ }
+ return false;
+ }
+
+ property bool success: false
+ Component.onCompleted: {
+ // trigger read and setup of property captures
+ success = isModified
+ model.setProperty(0, "modified", true)
+ success = isModified
+ }
+}
diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp
index cd497cbd79..555ca5713e 100644
--- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp
+++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp
@@ -122,6 +122,7 @@ private slots:
void datetime_data();
void about_to_be_signals();
void modify_through_delegate();
+ void bindingsOnGetResult();
};
bool tst_qqmllistmodel::compareVariantList(const QVariantList &testList, QVariant object)
@@ -1469,6 +1470,18 @@ void tst_qqmllistmodel::modify_through_delegate()
QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("age")).toInt(), 18);
}
+void tst_qqmllistmodel::bindingsOnGetResult()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("bindingsOnGetResult.qml"));
+ QVERIFY2(!component.isError(), qPrintable(component.errorString()));
+
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+
+ QVERIFY(obj->property("success").toBool());
+}
+
QTEST_MAIN(tst_qqmllistmodel)
#include "tst_qqmllistmodel.moc"
diff --git a/tests/auto/qml/qqmlmoduleplugin/data/works22.qml b/tests/auto/qml/qqmlmoduleplugin/data/works22.qml
new file mode 100644
index 0000000000..571a7e754d
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/data/works22.qml
@@ -0,0 +1,3 @@
+import org.qtproject.AutoTestQmlPluginType 2.2
+
+MyPluginType { valueOnlyIn2: 123 }
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.2.2.pro b/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.2.2.pro
new file mode 100644
index 0000000000..eec5f23a7b
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.2.2.pro
@@ -0,0 +1,12 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core qml
+DESTDIR = ../imports/org/qtproject/AutoTestQmlPluginType.2.2
+
+QT += core-private gui-private qml-private
+
+IMPORT_FILES = \
+ qmldir
+
+include (../../../shared/imports.pri)
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.cpp
new file mode 100644
index 0000000000..ecec870374
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QStringList>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+class MyPluginType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+ Q_PROPERTY(int valueOnlyIn2 READ value WRITE setValue)
+
+public:
+ MyPluginType(QObject *parent=0) : QObject(parent)
+ {
+ qWarning("import2.2 worked");
+ }
+
+ int value() const { return v; }
+ void setValue(int i) { v = i; }
+
+private:
+ int v;
+};
+
+
+class MyPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
+
+public:
+ MyPlugin()
+ {
+ qWarning("plugin2.2 created");
+ }
+
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "org.qtproject.AutoTestQmlPluginType");
+ qmlRegisterType<MyPluginType>(uri, 2, 0, "MyPluginType");
+ qmlRegisterModule(uri, 2, 2);
+ }
+};
+
+#include "plugin.moc"
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/qmldir b/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/qmldir
new file mode 100644
index 0000000000..0a8b5d46eb
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/qmldir
@@ -0,0 +1 @@
+plugin plugin
diff --git a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro
index 889968f6cc..0f548aa6f8 100644
--- a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro
+++ b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro
@@ -20,7 +20,8 @@ SUBDIRS =\
protectedModule\
plugin/childplugin\
plugin.2/childplugin\
- plugin.2.1/childplugin
+ plugin.2.1/childplugin\
+ plugin.2.2
tst_qqmlmoduleplugin_pro.depends += plugin
SUBDIRS += tst_qqmlmoduleplugin.pro
diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
index 265492b435..8600e1e8ab 100644
--- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
+++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
@@ -52,8 +52,7 @@ public:
private slots:
virtual void initTestCase();
void importsPlugin();
- void importsPlugin2();
- void importsPlugin21();
+ void importsPlugin_data();
void importsMixedQmlCppPlugin();
void incorrectPluginCase();
void importPluginWithQmlFile();
@@ -70,6 +69,7 @@ private slots:
void importStrictModule();
void importStrictModule_data();
void importProtectedModule();
+ void importVersionedModule();
void importsChildPlugin();
void importsChildPlugin2();
void importsChildPlugin21();
@@ -130,29 +130,15 @@ void tst_qqmlmoduleplugin::initTestCase()
void tst_qqmlmoduleplugin::importsPlugin()
{
- QQmlEngine engine;
- engine.addImportPath(m_importsDirectory);
- QTest::ignoreMessage(QtWarningMsg, "plugin created");
- QTest::ignoreMessage(QtWarningMsg, "import worked");
- QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlPluginType' does not contain a module identifier directive - it cannot be protected from external registrations.");
- QQmlComponent component(&engine, testFileUrl(QStringLiteral("works.qml")));
- foreach (QQmlError err, component.errors())
- qWarning() << err;
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("value").toInt(),123);
- delete object;
-}
+ QFETCH(QString, suffix);
+ QFETCH(QString, qmlFile);
-void tst_qqmlmoduleplugin::importsPlugin2()
-{
QQmlEngine engine;
engine.addImportPath(m_importsDirectory);
- QTest::ignoreMessage(QtWarningMsg, "plugin2 created");
- QTest::ignoreMessage(QtWarningMsg, "import2 worked");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(QString("plugin%1 created").arg(suffix)));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(QString("import%1 worked").arg(suffix)));
QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlPluginType' does not contain a module identifier directive - it cannot be protected from external registrations.");
- QQmlComponent component(&engine, testFileUrl(QStringLiteral("works2.qml")));
+ QQmlComponent component(&engine, testFileUrl(qmlFile));
foreach (QQmlError err, component.errors())
qWarning() << err;
VERIFY_ERRORS(0);
@@ -162,21 +148,15 @@ void tst_qqmlmoduleplugin::importsPlugin2()
delete object;
}
-void tst_qqmlmoduleplugin::importsPlugin21()
+void tst_qqmlmoduleplugin::importsPlugin_data()
{
- QQmlEngine engine;
- engine.addImportPath(m_importsDirectory);
- QTest::ignoreMessage(QtWarningMsg, "plugin2.1 created");
- QTest::ignoreMessage(QtWarningMsg, "import2.1 worked");
- QTest::ignoreMessage(QtWarningMsg, "Module 'org.qtproject.AutoTestQmlPluginType' does not contain a module identifier directive - it cannot be protected from external registrations.");
- QQmlComponent component(&engine, testFileUrl(QStringLiteral("works21.qml")));
- foreach (QQmlError err, component.errors())
- qWarning() << err;
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("value").toInt(),123);
- delete object;
+ QTest::addColumn<QString>("suffix");
+ QTest::addColumn<QString>("qmlFile");
+
+ QTest::newRow("1.0") << "" << "works.qml";
+ QTest::newRow("2.0") << "2" << "works2.qml";
+ QTest::newRow("2.1") << "2.1" << "works21.qml";
+ QTest::newRow("2.2") << "2.2" << "works22.qml";
}
void tst_qqmlmoduleplugin::incorrectPluginCase()
@@ -578,6 +558,32 @@ void tst_qqmlmoduleplugin::importProtectedModule()
QVERIFY(object != 0);
}
+void tst_qqmlmoduleplugin::importVersionedModule()
+{
+ qmlRegisterType<QObject>("org.qtproject.VersionedModule", 1, 0, "TestType");
+ qmlRegisterModule("org.qtproject.VersionedModule", 1, 1);
+
+ QQmlEngine engine;
+ engine.addImportPath(m_importsDirectory);
+
+ QUrl url(testFileUrl("empty.qml"));
+
+ QQmlComponent component(&engine);
+ component.setData("import org.qtproject.VersionedModule 1.0\n TestType {}\n", url);
+ QScopedPointer<QObject> object10(component.create());
+ QVERIFY(!object10.isNull());
+
+ component.setData("import org.qtproject.VersionedModule 1.1\n TestType {}\n", url);
+ QScopedPointer<QObject> object11(component.create());
+ QVERIFY(!object11.isNull());
+
+ component.setData("import org.qtproject.VersionedModule 1.2\n TestType {}\n", url);
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ QScopedPointer<QObject> object12(component.create());
+ QVERIFY(object12.isNull());
+ QCOMPARE(component.errorString(), QString("%1:1 module \"org.qtproject.VersionedModule\" version 1.2 is not installed\n").arg(url.toString()));
+}
+
void tst_qqmlmoduleplugin::importsChildPlugin()
{
QQmlEngine engine;
diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
index fe73610bcc..385ffc523a 100644
--- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
+++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
@@ -157,7 +157,7 @@ void tst_qqmlproperty::qmlmetaproperty()
QObject *obj = new QObject;
- QQmlAbstractBinding::Ptr binding(QQmlBinding::create(nullptr, QLatin1String("null"), 0, engine.rootContext()));
+ QQmlAbstractBinding::Ptr binding(QQmlBinding::create(nullptr, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext())));
QVERIFY(binding);
QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(obj, QObjectPrivate::get(obj)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1);
QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr);
@@ -399,7 +399,7 @@ void tst_qqmlproperty::qmlmetaproperty_object()
{
QQmlProperty prop(&object);
- QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext()));
+ QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext())));
QVERIFY(binding);
QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1);
QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr);
@@ -447,7 +447,7 @@ void tst_qqmlproperty::qmlmetaproperty_object()
{
QQmlProperty prop(&dobject);
- QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext()));
+ QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext())));
static_cast<QQmlBinding *>(binding.data())->setTarget(prop);
QVERIFY(binding);
QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1);
@@ -504,7 +504,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string()
{
QQmlProperty prop(&object, QString("defaultProperty"));
- QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext()));
+ QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext())));
QVERIFY(binding);
QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1);
QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr);
@@ -552,7 +552,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string()
{
QQmlProperty prop(&dobject, QString("defaultProperty"));
- QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext()));
+ QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext())));
static_cast<QQmlBinding *>(binding.data())->setTarget(prop);
QVERIFY(binding);
QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1);
@@ -603,7 +603,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string()
{
QQmlProperty prop(&dobject, QString("onClicked"));
- QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext()));
+ QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext())));
static_cast<QQmlBinding *>(binding.data())->setTarget(prop);
QVERIFY(binding);
QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1);
@@ -653,7 +653,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string()
{
QQmlProperty prop(&dobject, QString("onPropertyWithNotifyChanged"));
- QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext()));
+ QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext())));
static_cast<QQmlBinding *>(binding.data())->setTarget(prop);
QVERIFY(binding);
QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1);
@@ -709,7 +709,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_context()
{
QQmlProperty prop(&object, engine.rootContext());
- QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext()));
+ QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext())));
QVERIFY(binding);
QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1);
QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr);
@@ -757,7 +757,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_context()
{
QQmlProperty prop(&dobject, engine.rootContext());
- QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext()));
+ QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext())));
static_cast<QQmlBinding *>(binding.data())->setTarget(prop);
QVERIFY(binding);
QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1);
@@ -814,7 +814,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context()
{
QQmlProperty prop(&object, QString("defaultProperty"), engine.rootContext());
- QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext()));
+ QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext())));
QVERIFY(binding);
QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1);
QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr);
@@ -862,7 +862,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context()
{
QQmlProperty prop(&dobject, QString("defaultProperty"), engine.rootContext());
- QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext()));
+ QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext())));
static_cast<QQmlBinding *>(binding.data())->setTarget(prop);
QVERIFY(binding);
QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1);
@@ -913,7 +913,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context()
{
QQmlProperty prop(&dobject, QString("onClicked"), engine.rootContext());
- QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext()));
+ QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext())));
static_cast<QQmlBinding *>(binding.data())->setTarget(prop);
QVERIFY(binding);
QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1);
@@ -963,7 +963,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context()
{
QQmlProperty prop(&dobject, QString("onPropertyWithNotifyChanged"), engine.rootContext());
- QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext()));
+ QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext())));
static_cast<QQmlBinding *>(binding.data())->setTarget(prop);
QVERIFY(binding);
QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1);
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
index 803bad197a..163ce11cb8 100644
--- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
+++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
@@ -91,6 +91,7 @@ private slots:
void gadgetInheritance();
void toStringConversion();
void enumerableProperties();
+ void enumProperties();
private:
QQmlEngine engine;
@@ -322,7 +323,7 @@ void tst_qqmlvaluetypes::locale()
QScopedPointer<QObject> object(component.create());
QVERIFY(!object.isNull());
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
QVERIFY(QQml_guiProvider()->inputMethod());
QInputMethod *inputMethod = qobject_cast<QInputMethod*>(QQml_guiProvider()->inputMethod());
QLocale locale = inputMethod->locale();
@@ -349,7 +350,7 @@ void tst_qqmlvaluetypes::locale()
}
QCOMPARE(weekDays, locale.weekdays());
QCOMPARE(object->property("zeroDigit").toString().at(0), locale.zeroDigit());
-#endif // QT_NO_IM
+#endif // im
}
}
@@ -1703,6 +1704,39 @@ void tst_qqmlvaluetypes::enumerableProperties()
QVERIFY(names.contains(QStringLiteral("derivedProperty")));
}
+struct GadgetWithEnum
+{
+ Q_GADGET
+public:
+
+ enum MyEnum { FirstValue, SecondValue };
+
+ Q_ENUM(MyEnum)
+ Q_PROPERTY(MyEnum enumProperty READ enumProperty)
+
+ MyEnum enumProperty() const { return SecondValue; }
+};
+
+void tst_qqmlvaluetypes::enumProperties()
+{
+ QJSEngine engine;
+
+ // When creating the property cache for the gadget when MyEnum is _not_ a registered
+ // meta-type, then QMetaProperty::type() will return QMetaType::Int and consequently
+ // property-read meta-calls will return an int (as expected in this test). However if we
+ // explicitly register the gadget, then QMetaProperty::type() will return the user-type
+ // and QQmlValueTypeWrapper should still handle that and return an integer/number for the
+ // enum property when it is read.
+ qRegisterMetaType<GadgetWithEnum::MyEnum>();
+
+ GadgetWithEnum g;
+ QJSValue value = engine.toScriptValue(g);
+
+ QJSValue enumValue = value.property("enumProperty");
+ QVERIFY(enumValue.isNumber());
+ QCOMPARE(enumValue.toInt(), int(g.enumProperty()));
+}
+
QTEST_MAIN(tst_qqmlvaluetypes)
diff --git a/tests/auto/qmltest-blacklist/animators/tst_stopped.qml b/tests/auto/qmltest-blacklist/animators/tst_stopped.qml
index 56bec4e452..a70da63e13 100644
--- a/tests/auto/qmltest-blacklist/animators/tst_stopped.qml
+++ b/tests/auto/qmltest-blacklist/animators/tst_stopped.qml
@@ -37,7 +37,7 @@ Item {
TestCase {
id: testcase
name: "animators-stopped"
- when: root.done
+ when: false
function test_endresult() {
verify(true);
}
diff --git a/tests/auto/qmltest/events/tst_touch.qml b/tests/auto/qmltest/events/tst_touch.qml
new file mode 100644
index 0000000000..5b209a6d0b
--- /dev/null
+++ b/tests/auto/qmltest/events/tst_touch.qml
@@ -0,0 +1,182 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Jeremy Katz
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.0
+import QtTest 1.0
+
+MultiPointTouchArea {
+ id: touchArea
+ width: 100
+ height: 100
+
+ SignalSpy {
+ id: touchUpdatedSpy
+ target: touchArea
+ signalName: "touchUpdated"
+ }
+
+ SignalSpy {
+ id: interiorSpy
+ target: interior
+ signalName: "touchUpdated"
+ }
+
+ MultiPointTouchArea {
+ id: interior
+ width: parent.width / 2
+ height: parent.height
+ anchors.right: parent.right
+ }
+
+ Window {
+ width: 100; height: 100
+
+ SignalSpy {
+ id: subWindowSpy
+ target: subWindowTouchArea
+ signalName: "touchUpdated"
+ }
+
+ MultiPointTouchArea {
+ id: subWindowTouchArea
+ anchors.fill: parent
+ }
+ }
+
+ TestCase {
+ when: windowShown
+ name: "touch"
+
+ function comparePoint(point, id, x, y) {
+ var retval = true;
+ var pointId = point.pointId & 0xFFFFFF; //strip device identifier
+ if (pointId !== id) {
+ warn("Unexpected pointId: " + pointId + ". Expected " + id);
+ retval = false;
+ }
+ if (point.x !== x) {
+ warn("Unexpected x: " + point.x + ". Expected " + x);
+ retval = false;
+ }
+ if (point.y !== y) {
+ warn("Unexpected y: " + point.y + ". Expected " + y);
+ retval = false;
+ }
+ return retval;
+ }
+
+ function cleanup() {
+ touchUpdatedSpy.clear();
+ interiorSpy.clear();
+ subWindowSpy.clear();
+ }
+
+ function test_secondWindow() {
+ var first = 1;
+ var sequence = touchEvent(subWindowTouchArea);
+ sequence.press(first, 0, 0, 0);
+ sequence.commit();
+ sequence.release(first, subWindowTouchArea, 0, 0)
+ sequence.commit();
+ compare(subWindowSpy.count, 2);
+ var touchPoint = subWindowSpy.signalArguments[0][0][0];
+ verify(comparePoint(touchPoint, first, 0, 0));
+ }
+
+ function initTestCase() {
+ waitForRendering(touchArea) // when: windowShown may be insufficient
+ }
+
+ function test_childMapping() {
+ var sequence = touchEvent(touchArea);
+
+ var first = 1;
+ // Test mapping touches to a child item
+ sequence.press(first, interior, 0, 0);
+ sequence.commit();
+
+ // Map touches to the parent at the same point
+ sequence.move(first, touchArea, interior.x, interior.y);
+ sequence.commit();
+
+ sequence.release(first, touchArea, interior.x, interior.y);
+ sequence.commit();
+
+ compare(interiorSpy.count, 3);
+ verify(comparePoint(interiorSpy.signalArguments[0][0][0], first, 0, 0));
+ verify(comparePoint(interiorSpy.signalArguments[1][0][0], first, 0, 0));
+ }
+
+ function test_fullSequence() {
+ var sequence = touchEvent(touchArea);
+ verify(sequence);
+
+ var first = 1;
+ var second = 2;
+
+ sequence.press(first, null, 0, 0);
+ sequence.commit();
+ compare(touchUpdatedSpy.count, 1);
+ var touchPoints = touchUpdatedSpy.signalArguments[0][0];
+ compare(touchPoints.length, 1);
+ verify(comparePoint(touchPoints[0], first, 0, 0));
+
+ sequence.stationary(first);
+ sequence.press(second, null, 1, 0);
+ sequence.commit();
+ compare(touchUpdatedSpy.count, 2);
+ touchPoints = touchUpdatedSpy.signalArguments[1][0];
+ compare(touchPoints.length, 2);
+ verify(comparePoint(touchPoints[0], first, 0, 0));
+ verify(comparePoint(touchPoints[1], second, 1, 0));
+
+ sequence.release(first);
+ sequence.move(second, null, 1, 1);
+ sequence.commit();
+ compare(touchUpdatedSpy.count, 3);
+ touchPoints = touchUpdatedSpy.signalArguments[2][0];
+ compare(touchPoints.length, 1);
+ verify(comparePoint(touchPoints[0], second, 1, 1));
+
+ sequence.release(second, null, 0, 1);
+ sequence.commit();
+ compare(touchUpdatedSpy.count, 4);
+ touchPoints = touchUpdatedSpy.signalArguments[3][0];
+ compare(touchPoints.length, 0);
+ }
+
+ function test_simpleChain() {
+ var first = 1;
+ touchEvent(touchArea).press(first).commit().release(first).commit();
+ compare(touchUpdatedSpy.count, 2);
+ var touchPoint = touchUpdatedSpy.signalArguments[0][0][0];
+ verify(comparePoint(touchPoint, first, touchArea.width / 2, touchArea.height / 2));
+ }
+ }
+}
diff --git a/tests/auto/qmltest/selftests/tst_createTemporaryObject.qml b/tests/auto/qmltest/selftests/tst_createTemporaryObject.qml
new file mode 100644
index 0000000000..c4912c7388
--- /dev/null
+++ b/tests/auto/qmltest/selftests/tst_createTemporaryObject.qml
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Window 2.2
+import QtTest 1.2
+
+TestCase {
+ id: testCase
+ name: "tst_createTemporaryObject"
+ width: 100
+ height: 100
+ when: windowShown
+
+ property var createdObjectNames: []
+
+ function verifyNoChildren() {
+ for (var i = 0; i < createdObjectNames.length; ++i) {
+ verify(!findChild(testCase, createdObjectNames[i]));
+ }
+ }
+
+ function init() {
+ // The items are destroyed after cleanup(), so we check here after every test,
+ // and once for the last test in cleanupTestCase().
+ verifyNoChildren();
+ }
+
+ function cleanupTestCase() {
+ verifyNoChildren();
+ }
+
+ function test_fromQml_data() {
+ return [
+ { tag: "QtObject", qml: "import QtQml 2.0; QtObject {}" },
+ { tag: "Item", qml: "import QtQuick 2.0; Item {}" },
+ ];
+ }
+
+ function test_fromQml(data) {
+ var object = createTemporaryQmlObject(data.qml, testCase);
+ verify(object);
+
+ object.objectName = data.tag + "FromQml";
+ compare(findChild(testCase, object.objectName), object);
+
+ createdObjectNames.push(object.objectName);
+ }
+
+ Component {
+ id: objectComponent
+
+ QtObject {}
+ }
+
+ Component {
+ id: itemComponent
+
+ Item {}
+ }
+
+ Component {
+ id: windowComponent
+
+ Window {}
+ }
+
+ function test_fromComponent_data() {
+ return [
+ { tag: "QtObject", component: objectComponent },
+ { tag: "Item", component: itemComponent },
+ { tag: "Window", component: windowComponent },
+ ];
+ }
+
+ function test_fromComponent(data) {
+ var object = createTemporaryObject(data.component, testCase);
+ verify(object);
+
+ object.objectName = data.tag + "FromComponent";
+ compare(findChild(testCase, object.objectName), object);
+
+ if (object.hasOwnProperty("contentItem"))
+ object.contentItem.objectName = "WindowContentItemFromComponent";
+
+ createdObjectNames.push(object.objectName);
+ }
+}
diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp
index 872a71011d..1ca809c05f 100644
--- a/tests/auto/quick/examples/tst_examples.cpp
+++ b/tests/auto/quick/examples/tst_examples.cpp
@@ -103,7 +103,7 @@ tst_examples::tst_examples()
excludedFiles << "views/visualdatamodel/slideshow.qml";
#endif
-#ifdef QT_NO_OPENGL
+#if !QT_CONFIG(opengl)
//No support for Particles
excludedFiles << "examples/qml/dynamicscene/dynamicscene.qml";
excludedFiles << "examples/quick/animation/basics/color-animation.qml";
diff --git a/tests/auto/quick/nokeywords/tst_nokeywords.cpp b/tests/auto/quick/nokeywords/tst_nokeywords.cpp
index 6c94b484ae..ad77743ddd 100644
--- a/tests/auto/quick/nokeywords/tst_nokeywords.cpp
+++ b/tests/auto/quick/nokeywords/tst_nokeywords.cpp
@@ -48,7 +48,7 @@
#include <QtQuick/private/qsgadaptationlayer_p.h>
#include <QtQuick/private/qsgcontext_p.h>
#include <QtQuick/private/qsgcontextplugin_p.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
#include <QtQuick/private/qsgdefaultdistancefieldglyphcache_p.h>
#include <QtQuick/private/qsgdefaultglyphnode_p.h>
#include <QtQuick/private/qsgdefaultinternalimagenode_p.h>
diff --git a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
index 5d242fab9e..71b0160c8e 100644
--- a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
+++ b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
@@ -76,7 +76,7 @@ private slots:
void statusChanges_data();
void sourceSizeChanges();
void progressAndStatusChanges();
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
void borderImageMesh();
#endif
@@ -583,7 +583,7 @@ void tst_qquickborderimage::progressAndStatusChanges()
delete obj;
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
void tst_qquickborderimage::borderImageMesh()
{
QQuickView *window = new QQuickView;
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index b774481592..942e99018f 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -1225,7 +1225,7 @@ void tst_qquickflickable::flickOnRelease()
QTRY_VERIFY(!flickable->isMoving());
#ifdef Q_OS_MAC
-# ifndef QT_NO_OPENGL
+# if QT_CONFIG(opengl)
QEXPECT_FAIL("", "QTBUG-26094 stopping on a full pixel doesn't work on OS X", Continue);
# endif
#endif
diff --git a/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp b/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp
index 256fa43d2e..650892d650 100644
--- a/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp
+++ b/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp
@@ -35,7 +35,7 @@
#include "../../shared/util.h"
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
#include <QtGui/qopenglcontext.h>
#include <QtGui/qsurfaceformat.h>
#endif
@@ -67,7 +67,7 @@ void tst_QQuickGraphicsInfo::testProperties()
QCOMPARE(obj->property("api").toInt(), expectedAPI);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (expectedAPI == QSGRendererInterface::OpenGL) {
QCOMPARE(obj->property("shaderType").toInt(), int(QSGRendererInterface::GLSL));
QVERIFY(view.openglContext());
diff --git a/tests/auto/quick/qquickitem/data/shortcutOverride.qml b/tests/auto/quick/qquickitem/data/shortcutOverride.qml
new file mode 100644
index 0000000000..fab9175c17
--- /dev/null
+++ b/tests/auto/quick/qquickitem/data/shortcutOverride.qml
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Window 2.1
+
+Item {
+ property int escapeHandlerActivationCount: 0
+ property int shortcutActivationCount: 0
+ property alias escapeItem: escapeItem
+
+ Item {
+ id: escapeItem
+ objectName: "escapeItem"
+ focus: true
+
+ // By accepting shortcut override events when the key is Qt.Key_Escape,
+ // we can ensure that our Keys.onEscapePressed handler (below) will be called.
+ Keys.onShortcutOverride: event.accepted = (event.key === Qt.Key_Escape)
+
+ Keys.onEscapePressed: {
+ // Pretend that we just did some really important stuff that was triggered
+ // by the escape key (like might occur in a popup that has a keyboard shortcut editor, for example).
+ // Now that we're done, we no longer need focus, so we won't accept future shorcut override events.
+ focus = false;
+ event.accepted = true;
+ ++escapeHandlerActivationCount;
+ }
+ }
+
+ Shortcut {
+ sequence: "Escape"
+ onActivated: ++shortcutActivationCount
+ }
+}
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
index d0139b6cdf..8d974f4d17 100644
--- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
@@ -172,6 +172,8 @@ private slots:
void ignoreButtonPressNotInAcceptedMouseButtons();
+ void shortcutOverride();
+
private:
enum PaintOrderOp {
@@ -2036,6 +2038,39 @@ void tst_qquickitem::ignoreButtonPressNotInAcceptedMouseButtons()
QCOMPARE(item.releaseCount, 1);
}
+void tst_qquickitem::shortcutOverride()
+{
+ QQuickView view;
+ view.setSource(testFileUrl("shortcutOverride.qml"));
+ ensureFocus(&view);
+
+ QCOMPARE(view.rootObject()->property("escapeHandlerActivationCount").toInt(), 0);
+ QCOMPARE(view.rootObject()->property("shortcutActivationCount").toInt(), 0);
+
+ QQuickItem *escapeItem = view.rootObject()->property("escapeItem").value<QQuickItem*>();
+ QVERIFY(escapeItem);
+ QVERIFY(escapeItem->hasActiveFocus());
+
+ // escapeItem's onEscapePressed handler should accept the first escape press event.
+ QTest::keyPress(&view, Qt::Key_Escape);
+ QCOMPARE(view.rootObject()->property("escapeHandlerActivationCount").toInt(), 1);
+ QCOMPARE(view.rootObject()->property("shortcutActivationCount").toInt(), 0);
+ // Now it shouldn't have focus, so it can't handle the next escape press event.
+ QVERIFY(!escapeItem->hasActiveFocus());
+
+ QTest::keyRelease(&view, Qt::Key_Escape);
+ QCOMPARE(view.rootObject()->property("escapeHandlerActivationCount").toInt(), 1);
+ QCOMPARE(view.rootObject()->property("shortcutActivationCount").toInt(), 0);
+
+ QTest::keyPress(&view, Qt::Key_Escape);
+ QCOMPARE(view.rootObject()->property("escapeHandlerActivationCount").toInt(), 1);
+ QCOMPARE(view.rootObject()->property("shortcutActivationCount").toInt(), 1);
+
+ QTest::keyRelease(&view, Qt::Key_Escape);
+ QCOMPARE(view.rootObject()->property("escapeHandlerActivationCount").toInt(), 1);
+ QCOMPARE(view.rootObject()->property("shortcutActivationCount").toInt(), 1);
+}
+
QTEST_MAIN(tst_qquickitem)
#include "tst_qquickitem.moc"
diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
index 6554d749dd..cc74b7e07d 100644
--- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
@@ -2726,9 +2726,9 @@ struct TestListener : public QQuickItemChangeListener
{
TestListener(bool remove = false) : remove(remove) { }
- void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange, const QRectF &diff) override
+ void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange, const QRectF &oldGeometry) override
{
- record(item, QQuickItemPrivate::Geometry, diff);
+ record(item, QQuickItemPrivate::Geometry, oldGeometry);
}
void itemSiblingOrderChanged(QQuickItem *item) override
{
@@ -2810,20 +2810,20 @@ void tst_QQuickItem::changeListener()
item->setImplicitWidth(10);
QCOMPARE(itemListener.count(QQuickItemPrivate::ImplicitWidth), 1);
QCOMPARE(itemListener.count(QQuickItemPrivate::Geometry), 1);
- QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,10,0)));
+ QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,0,0)));
item->setImplicitHeight(20);
QCOMPARE(itemListener.count(QQuickItemPrivate::ImplicitHeight), 1);
QCOMPARE(itemListener.count(QQuickItemPrivate::Geometry), 2);
- QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,0,20)));
+ QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,10,0)));
item->setWidth(item->width() + 30);
QCOMPARE(itemListener.count(QQuickItemPrivate::Geometry), 3);
- QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,30,0)));
+ QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,10,20)));
item->setHeight(item->height() + 40);
QCOMPARE(itemListener.count(QQuickItemPrivate::Geometry), 4);
- QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,0,40)));
+ QCOMPARE(itemListener.value(QQuickItemPrivate::Geometry), QVariant(QRectF(0,0,40,20)));
item->setOpacity(0.5);
QCOMPARE(itemListener.count(QQuickItemPrivate::Opacity), 1);
@@ -3133,7 +3133,7 @@ void tst_QQuickItem::parentLoop()
{
QQuickView *window = new QQuickView(0);
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
QRegularExpression msgRegexp = QRegularExpression("QQuickItem::setParentItem: Parent QQuickItem\\(.*\\) is already part of the subtree of QQuickItem\\(.*\\)");
QTest::ignoreMessage(QtWarningMsg, msgRegexp);
#endif
@@ -3304,7 +3304,7 @@ void tst_QQuickItem::grab()
QVERIFY(root);
QQuickItem *item = root->findChild<QQuickItem *>("myItem");
QVERIFY(item);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
{ // Default size (item is 100x100)
QSharedPointer<QQuickItemGrabResult> result = item->grabToImage();
QSignalSpy spy(result.data(), SIGNAL(ready()));
diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
index 2576a1b0fc..44310008d6 100644
--- a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
+++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
@@ -61,7 +61,7 @@ private slots:
void initTestCase() Q_DECL_OVERRIDE;
void layerEnabled();
void layerSmooth();
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
void layerMipmap();
void layerEffect();
#endif
@@ -105,7 +105,7 @@ tst_QQuickItemLayer::tst_QQuickItemLayer()
void tst_QQuickItemLayer::initTestCase()
{
QQmlDataTest::initTestCase();
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QWindow window;
QOpenGLContext context;
window.setSurfaceType(QWindow::OpenGLSurface);
@@ -177,7 +177,7 @@ void tst_QQuickItemLayer::layerEnabled()
QVERIFY(fb.pixel(0, 0) != fb.pixel(0, fb.height() - 1));
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
// The test draws a one pixel wide line and scales it down by more than a a factor 2
// If mipmpping works, the pixels should be gray, not white or black
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index b0d903908f..61ba2caaf7 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -2373,7 +2373,7 @@ void tst_QQuickListView::sectionsPositioning()
QTRY_COMPARE(item->y(), qreal(i*20*6));
}
- QTRY_VERIFY(topItem = findVisibleChild(contentItem, "sect_aaa")); // section header
+ QTRY_VERIFY((topItem = findVisibleChild(contentItem, "sect_aaa"))); // section header
QCOMPARE(topItem->y(), 10.);
// remove section boundary
@@ -2389,7 +2389,8 @@ void tst_QQuickListView::sectionsPositioning()
QTRY_COMPARE(item->y(), qreal(i*20*6));
}
- QVERIFY(topItem = findVisibleChild(contentItem, "sect_1"));
+ topItem = findVisibleChild(contentItem, "sect_1");
+ QVERIFY(topItem);
QTRY_COMPARE(topItem->y(), 120.);
// Change the next section
@@ -2974,31 +2975,38 @@ void tst_QQuickListView::itemListFlicker()
QTRY_COMPARE(model->count(), 3);
QTRY_COMPARE(listview->currentIndex(), 0);
- QQuickItem *item;
-
- QVERIFY(item = findItem<QQuickItem>(contentItem, "item1"));
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "item1");
+ QVERIFY(item);
QVERIFY(delegateVisible(item));
- QVERIFY(item = findItem<QQuickItem>(contentItem, "item2"));
+ item = findItem<QQuickItem>(contentItem, "item2");
+ QVERIFY(item);
QVERIFY(delegateVisible(item));
- QVERIFY(item = findItem<QQuickItem>(contentItem, "item3"));
+ item = findItem<QQuickItem>(contentItem, "item3");
+ QVERIFY(item);
QVERIFY(delegateVisible(item));
listview->setCurrentIndex(1);
- QVERIFY(item = findItem<QQuickItem>(contentItem, "item1"));
+ item = findItem<QQuickItem>(contentItem, "item1");
+ QVERIFY(item);
QVERIFY(delegateVisible(item));
- QVERIFY(item = findItem<QQuickItem>(contentItem, "item2"));
+ item = findItem<QQuickItem>(contentItem, "item2");
+ QVERIFY(item);
QVERIFY(delegateVisible(item));
- QVERIFY(item = findItem<QQuickItem>(contentItem, "item3"));
+ item = findItem<QQuickItem>(contentItem, "item3");
+ QVERIFY(item);
QVERIFY(delegateVisible(item));
listview->setCurrentIndex(2);
- QVERIFY(item = findItem<QQuickItem>(contentItem, "item1"));
+ item = findItem<QQuickItem>(contentItem, "item1");
+ QVERIFY(item);
QVERIFY(delegateVisible(item));
- QVERIFY(item = findItem<QQuickItem>(contentItem, "item2"));
+ item = findItem<QQuickItem>(contentItem, "item2");
+ QVERIFY(item);
QVERIFY(delegateVisible(item));
- QVERIFY(item = findItem<QQuickItem>(contentItem, "item3"));
+ item = findItem<QQuickItem>(contentItem, "item3");
+ QVERIFY(item);
QVERIFY(delegateVisible(item));
}
@@ -5335,14 +5343,17 @@ void tst_QQuickListView::creationContext()
QVERIFY(rootItem);
QVERIFY(rootItem->property("count").toInt() > 0);
- QQuickItem *item;
- QVERIFY(item = findItem<QQuickItem>(rootItem, "listItem"));
+ QQuickItem *item = findItem<QQuickItem>(rootItem, "listItem");
+ QVERIFY(item);
QCOMPARE(item->property("text").toString(), QString("Hello!"));
- QVERIFY(item = rootItem->findChild<QQuickItem *>("header"));
+ item = rootItem->findChild<QQuickItem *>("header");
+ QVERIFY(item);
QCOMPARE(item->property("text").toString(), QString("Hello!"));
- QVERIFY(item = rootItem->findChild<QQuickItem *>("footer"));
+ item = rootItem->findChild<QQuickItem *>("footer");
+ QVERIFY(item);
QCOMPARE(item->property("text").toString(), QString("Hello!"));
- QVERIFY(item = rootItem->findChild<QQuickItem *>("section"));
+ item = rootItem->findChild<QQuickItem *>("section");
+ QVERIFY(item);
QCOMPARE(item->property("text").toString(), QString("Hello!"));
}
@@ -5604,42 +5615,49 @@ void tst_QQuickListView::unrequestedVisibility()
QVERIFY(QTest::qWaitForWindowExposed(window));
- QQuickListView *leftview = findItem<QQuickListView>(window->rootObject(), "leftList");
- QTRY_VERIFY(leftview != 0);
+ QQuickListView *leftview;
+ QTRY_VERIFY((leftview = findItem<QQuickListView>(window->rootObject(), "leftList")));
- QQuickListView *rightview = findItem<QQuickListView>(window->rootObject(), "rightList");
- QTRY_VERIFY(rightview != 0);
+ QQuickListView *rightview;
+ QTRY_VERIFY((rightview = findItem<QQuickListView>(window->rootObject(), "rightList")));
QQuickItem *leftContent = leftview->contentItem();
- QTRY_VERIFY(leftContent != 0);
+ QTRY_VERIFY((leftContent = leftview->contentItem()));
- QQuickItem *rightContent = rightview->contentItem();
- QTRY_VERIFY(rightContent != 0);
+ QQuickItem *rightContent;
+ QTRY_VERIFY((rightContent = rightview->contentItem()));
rightview->setCurrentIndex(20);
QTRY_COMPARE(leftview->contentY(), 0.0);
QTRY_COMPARE(rightview->contentY(), 100.0);
- QQuickItem *item;
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ const QString wrapperObjectName = QStringLiteral("wrapper");
+ QQuickItem *item = findItem<QQuickItem>(leftContent, wrapperObjectName, 1);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 1);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 19));
+ item = findItem<QQuickItem>(leftContent, wrapperObjectName, 19);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 19));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 19);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 16));
+ item = findItem<QQuickItem>(leftContent, wrapperObjectName, 16);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 17));
+ item = findItem<QQuickItem>(leftContent, wrapperObjectName, 17);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 3));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 3);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 4));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 4);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
rightview->setCurrentIndex(0);
@@ -5647,106 +5665,139 @@ void tst_QQuickListView::unrequestedVisibility()
QTRY_COMPARE(leftview->contentY(), 0.0);
QTRY_COMPARE(rightview->contentY(), 0.0);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ item = findItem<QQuickItem>(leftContent, wrapperObjectName, 1);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 1);
+ QVERIFY(item);
QTRY_COMPARE(delegateVisible(item), true);
- QVERIFY(!findItem<QQuickItem>(leftContent, "wrapper", 19));
- QVERIFY(!findItem<QQuickItem>(rightContent, "wrapper", 19));
+ QVERIFY(!findItem<QQuickItem>(leftContent, wrapperObjectName, 19));
+ QVERIFY(!findItem<QQuickItem>(rightContent, wrapperObjectName, 19));
leftview->setCurrentIndex(20);
QTRY_COMPARE(leftview->contentY(), 100.0);
QTRY_COMPARE(rightview->contentY(), 0.0);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ item = findItem<QQuickItem>(leftContent, wrapperObjectName, 1);
+ QVERIFY(item);
QTRY_COMPARE(delegateVisible(item), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 1);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 19));
+ item = findItem<QQuickItem>(leftContent, wrapperObjectName, 19);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 19));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 19);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
+ item = findItem<QQuickItem>(leftContent, wrapperObjectName, 3);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
+ item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 16);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 17);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
model.moveItems(19, 1, 1);
QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
- QTRY_VERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QTRY_VERIFY((item = findItem<QQuickItem>(leftContent, wrapperObjectName, 1)));
QCOMPARE(delegateVisible(item), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 1);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 19));
+ item = findItem<QQuickItem>(leftContent, wrapperObjectName, 19);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 19));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 19);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
+ item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ item = findItem<QQuickItem>(leftContent, wrapperObjectName, 5);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 16);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 17);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
model.moveItems(3, 4, 1);
QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
+ item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ item = findItem<QQuickItem>(leftContent, wrapperObjectName, 5);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 16);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 17);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
model.moveItems(4, 3, 1);
QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
+ item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ item = findItem<QQuickItem>(leftContent, wrapperObjectName, 5);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 16);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 17);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
model.moveItems(16, 17, 1);
QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
+ item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ item = findItem<QQuickItem>(leftContent, wrapperObjectName, 5);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 16);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 17);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
model.moveItems(17, 16, 1);
QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
+ item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ item = findItem<QQuickItem>(leftContent, wrapperObjectName, 5);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 16);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
+ item = findItem<QQuickItem>(rightContent, wrapperObjectName, 17);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
delete window;
@@ -7249,14 +7300,14 @@ void tst_QQuickListView::displayMargin()
QQuickItem *content = listview->contentItem();
QVERIFY(content != 0);
- QQuickItem *item0;
- QQuickItem *item14;
-
- QVERIFY(item0 = findItem<QQuickItem>(content, "delegate", 0));
+ QQuickItem *item0 = findItem<QQuickItem>(content, "delegate", 0);
+ QVERIFY(item0);
QCOMPARE(delegateVisible(item0), true);
// the 14th item should be within the end margin
- QVERIFY(item14 = findItem<QQuickItem>(content, "delegate", 13));
+
+ QQuickItem *item14 = findItem<QQuickItem>(content, "delegate", 13);
+ QVERIFY(item14);
QCOMPARE(delegateVisible(item14), true);
// the 15th item should be outside the end margin
@@ -7273,7 +7324,6 @@ void tst_QQuickListView::displayMargin()
void tst_QQuickListView::negativeDisplayMargin()
{
- QQuickItem *item;
QScopedPointer<QQuickView> window(createView());
window->setSource(testFileUrl("negativeDisplayMargin.qml"));
window->show();
@@ -7289,22 +7339,26 @@ void tst_QQuickListView::negativeDisplayMargin()
QQuickItem *content = innerList->contentItem();
QVERIFY(content != 0);
- QVERIFY(item = findItem<QQuickItem>(content, "delegate", 0));
+ QQuickItem *item = findItem<QQuickItem>(content, "delegate", 0);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(content, "delegate", 7));
+ item = findItem<QQuickItem>(content, "delegate", 7);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), true);
- QVERIFY(item = findItem<QQuickItem>(content, "delegate", 8));
+ item = findItem<QQuickItem>(content, "delegate", 8);
+ QVERIFY(item);
QCOMPARE(delegateVisible(item), false);
// Flick until contentY means that delegate8 should be visible
listview->setProperty("contentY", 500);
- QVERIFY(item = findItem<QQuickItem>(content, "delegate", 8));
+ item = findItem<QQuickItem>(content, "delegate", 8);
+ QVERIFY(item);
QTRY_COMPARE(delegateVisible(item), true);
listview->setProperty("contentY", 1000);
- QTRY_VERIFY(item = findItem<QQuickItem>(content, "delegate", 14));
+ QTRY_VERIFY((item = findItem<QQuickItem>(content, "delegate", 14)));
QTRY_COMPARE(delegateVisible(item), true);
listview->setProperty("contentY", 0);
diff --git a/tests/auto/quick/qquickmousearea/data/pressAndHold.qml b/tests/auto/quick/qquickmousearea/data/pressAndHold.qml
new file mode 100644
index 0000000000..bde195965e
--- /dev/null
+++ b/tests/auto/quick/qquickmousearea/data/pressAndHold.qml
@@ -0,0 +1,12 @@
+import QtQuick 2.9
+
+Item {
+ width: 100
+ height: 100
+
+ MouseArea {
+ id: mouseArea
+ objectName: "mouseArea"
+ anchors.fill: parent
+ }
+}
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
index f22528a8a0..c8351b9e18 100644
--- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -59,7 +59,7 @@ static bool initView(QQuickView &v, const QUrl &url, bool moveMouseOut, QByteArr
const QSize size = v.size();
const QPoint offset = QPoint(size.width() / 2, size.height() / 2);
v.setFramePosition(screenGeometry.center() - offset);
-#ifndef QT_NO_CURSOR // Get the cursor out of the way.
+#if QT_CONFIG(cursor) // Get the cursor out of the way.
if (moveMouseOut)
QCursor::setPos(v.geometry().topRight() + QPoint(100, 100));
#else
@@ -116,7 +116,7 @@ private slots:
void pressedMultipleButtons_data();
void pressedMultipleButtons();
void changeAxis();
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
void cursorShape();
#endif
void moveAndReleaseWithoutPress();
@@ -127,6 +127,8 @@ private slots:
void containsPress();
void ignoreBySource();
void notPressedAfterStolenGrab();
+ void pressAndHold_data();
+ void pressAndHold();
private:
int startDragDistance() const {
@@ -1692,7 +1694,7 @@ void tst_QQuickMouseArea::changeAxis()
QCOMPARE(blackRect->y(), 94.0);
}
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
void tst_QQuickMouseArea::cursorShape()
{
QQmlEngine engine;
@@ -2098,6 +2100,49 @@ void tst_QQuickMouseArea::notPressedAfterStolenGrab()
QVERIFY(!ma->pressed());
}
+void tst_QQuickMouseArea::pressAndHold_data()
+{
+ QTest::addColumn<int>("pressAndHoldInterval");
+ QTest::addColumn<int>("waitTime");
+
+ QTest::newRow("default") << -1 << QGuiApplication::styleHints()->mousePressAndHoldInterval();
+ QTest::newRow("short") << 500 << 500;
+ QTest::newRow("long") << 1000 << 1000;
+}
+
+void tst_QQuickMouseArea::pressAndHold()
+{
+ QFETCH(int, pressAndHoldInterval);
+ QFETCH(int, waitTime);
+
+ QQuickView window;
+ QByteArray errorMessage;
+ QVERIFY2(initView(window, testFileUrl("pressAndHold.qml"), true, &errorMessage), errorMessage.constData());
+ window.show();
+ window.requestActivate();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QQuickItem *root = window.rootObject();
+ QVERIFY(root != 0);
+
+ QQuickMouseArea *mouseArea = window.rootObject()->findChild<QQuickMouseArea*>("mouseArea");
+ QVERIFY(mouseArea != 0);
+
+ QSignalSpy pressAndHoldSpy(mouseArea, &QQuickMouseArea::pressAndHold);
+
+ if (pressAndHoldInterval > -1)
+ mouseArea->setPressAndHoldInterval(pressAndHoldInterval);
+ else
+ mouseArea->resetPressAndHoldInterval();
+
+ QElapsedTimer t;
+ t.start();
+ QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, QPoint(50, 50));
+ QVERIFY(pressAndHoldSpy.wait());
+ // should be off by no more than 20% of waitTime
+ QVERIFY(qAbs(t.elapsed() - waitTime) < (waitTime * 0.2));
+ QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, QPoint(50, 50));
+}
+
QTEST_MAIN(tst_QQuickMouseArea)
#include "tst_qquickmousearea.moc"
diff --git a/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp b/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp
index 44d7b40ed9..1716bdeafb 100644
--- a/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp
+++ b/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp
@@ -32,7 +32,7 @@
#include <QtQuick/qquickview.h>
#include <private/qquickitem_p.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
#include <private/qsgdefaultpainternode_p.h>
#else
#include <private/qsgsoftwarepainternode_p.h>
@@ -73,7 +73,7 @@ public:
++paintRequests;
clipRect = painter->clipBoundingRect();
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data)
{
paintNode = static_cast<QSGDefaultPainterNode *>(QQuickPaintedItem::updatePaintNode(oldNode, data));
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index d013d190ec..ba3d182efc 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -1633,8 +1633,8 @@ void tst_QQuickPathView::creationContext()
QVERIFY(rootItem);
QVERIFY(rootItem->property("count").toInt() > 0);
- QQuickItem *item;
- QVERIFY(item = findItem<QQuickItem>(rootItem, "listItem", 0));
+ QQuickItem *item = findItem<QQuickItem>(rootItem, "listItem", 0);
+ QVERIFY(item);
QCOMPARE(item->property("text").toString(), QString("Hello!"));
}
@@ -1685,7 +1685,8 @@ void tst_QQuickPathView::currentOffsetOnInsertion()
QCOMPARE(currentIndexSpy.count(), 1);
// currentIndex is now 1
- QVERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 1));
+ item = findItem<QQuickRectangle>(pathview, "wrapper", 1);
+ QVERIFY(item);
// verify that current item (item 1) is still at offset 0.5
QCOMPARE(item->position() + offset, start);
@@ -1697,7 +1698,8 @@ void tst_QQuickPathView::currentOffsetOnInsertion()
QCOMPARE(currentIndexSpy.count(), 2);
// currentIndex is now 2
- QVERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 2));
+ item = findItem<QQuickRectangle>(pathview, "wrapper", 2);
+ QVERIFY(item);
// verify that current item (item 2) is still at offset 0.5
QCOMPARE(item->position() + offset, start);
@@ -1709,7 +1711,8 @@ void tst_QQuickPathView::currentOffsetOnInsertion()
QCOMPARE(currentIndexSpy.count(), 3);
// currentIndex is now 1
- QVERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 1));
+ item = findItem<QQuickRectangle>(pathview, "wrapper", 1);
+ QVERIFY(item);
// verify that current item (item 1) is still at offset 0.5
QCOMPARE(item->position() + offset, start);
diff --git a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp
index 80c6c9e553..e854a109a1 100644
--- a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp
+++ b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp
@@ -35,7 +35,7 @@
#include "testhttpserver.h"
#include <QtNetwork/QNetworkConfigurationManager>
-#ifndef QT_NO_CONCURRENT
+#if QT_CONFIG(concurrent)
#include <qtconcurrentrun.h>
#include <qfuture.h>
#endif
@@ -57,7 +57,7 @@ private slots:
void massive();
void cancelcrash();
void shrinkcache();
-#ifndef QT_NO_CONCURRENT
+#if QT_CONFIG(concurrent)
void networkCrash();
#endif
void lockingCrash();
@@ -105,7 +105,7 @@ void tst_qquickpixmapcache::initTestCase()
QVERIFY2(server.listen(), qPrintable(server.errorString()));
-#ifndef QT_NO_BEARERMANAGEMENT
+#if QT_CONFIG(bearermanagement)
// This avoids a race condition/deadlock bug in network config
// manager when it is accessed by the HTTP server thread before
// anything else. Bug report can be found at:
@@ -372,7 +372,7 @@ void tst_qquickpixmapcache::shrinkcache()
}
}
-#ifndef QT_NO_CONCURRENT
+#if QT_CONFIG(concurrent)
void createNetworkServer(TestHTTPServer *server)
{
@@ -382,7 +382,7 @@ void createNetworkServer(TestHTTPServer *server)
eventLoop.exec();
}
-#ifndef QT_NO_CONCURRENT
+#if QT_CONFIG(concurrent)
// QT-3957
void tst_qquickpixmapcache::networkCrash()
{
diff --git a/tests/auto/quick/qquicktextedit/data/cursorHeight.qml b/tests/auto/quick/qquicktextedit/data/cursorHeight.qml
new file mode 100644
index 0000000000..b831a9eb6f
--- /dev/null
+++ b/tests/auto/quick/qquicktextedit/data/cursorHeight.qml
@@ -0,0 +1,20 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 300
+ height: 300
+ color: "white"
+
+ TextEdit {
+ objectName: "textEditObject"
+ width: 300
+ height: 300
+ text: "<span style=\"font-size:20pt;\">Blah</span><br>blah"
+ textFormat: TextEdit.RichText
+ cursorDelegate: Rectangle {
+ objectName: "cursorInstance"
+ color: "red"
+ width: 2
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index 5ed0e9eea7..ac57a05176 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -140,9 +140,10 @@ private slots:
void cursorVisible();
void delegateLoading_data();
void delegateLoading();
+ void cursorDelegateHeight();
void navigation();
void readOnly();
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void copyAndPaste();
void canPaste();
void canPasteEmpty();
@@ -152,7 +153,7 @@ private slots:
void inputMethodUpdate();
void openInputPanel();
void geometrySignals();
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void pastingRichText_QTBUG_14003();
#endif
void implicitSize_data();
@@ -928,7 +929,6 @@ void tst_qquicktextedit::hAlignVisual()
const int left = numberOfNonWhitePixels(centeredSection1, centeredSection2, image);
const int mid = numberOfNonWhitePixels(centeredSection2, centeredSection3, image);
const int right = numberOfNonWhitePixels(centeredSection3, centeredSection3End, image);
- image.save("test3.png");
QVERIFY2(left < mid, msgNotLessThan(left, mid).constData());
QVERIFY2(mid < right, msgNotLessThan(mid, right).constData());
}
@@ -2848,6 +2848,43 @@ void tst_qquicktextedit::delegateLoading()
//QVERIFY(!delegate);
}
+void tst_qquicktextedit::cursorDelegateHeight()
+{
+ QQuickView view(testFileUrl("cursorHeight.qml"));
+ view.show();
+ view.requestActivate();
+ QTest::qWaitForWindowActive(&view);
+ QQuickTextEdit *textEditObject = view.rootObject()->findChild<QQuickTextEdit*>("textEditObject");
+ QVERIFY(textEditObject);
+ // Delegate creation is deferred until focus in or cursor visibility is forced.
+ QVERIFY(!textEditObject->findChild<QQuickItem*>("cursorInstance"));
+ QVERIFY(!textEditObject->isCursorVisible());
+
+ // Test that the delegate gets created.
+ textEditObject->setFocus(true);
+ QVERIFY(textEditObject->isCursorVisible());
+ QQuickItem* delegateObject = textEditObject->findChild<QQuickItem*>("cursorInstance");
+ QVERIFY(delegateObject);
+
+ const int largerHeight = textEditObject->cursorRectangle().height();
+
+ textEditObject->setCursorPosition(0);
+ QCOMPARE(delegateObject->x(), textEditObject->cursorRectangle().x());
+ QCOMPARE(delegateObject->y(), textEditObject->cursorRectangle().y());
+ QCOMPARE(delegateObject->height(), textEditObject->cursorRectangle().height());
+
+ // Move the cursor to the next line, which has a smaller font.
+ textEditObject->setCursorPosition(5);
+ QCOMPARE(delegateObject->x(), textEditObject->cursorRectangle().x());
+ QCOMPARE(delegateObject->y(), textEditObject->cursorRectangle().y());
+ QVERIFY(textEditObject->cursorRectangle().height() < largerHeight);
+ QCOMPARE(delegateObject->height(), textEditObject->cursorRectangle().height());
+
+ // Test that the delegate gets deleted
+ textEditObject->setCursorDelegate(0);
+ QVERIFY(!textEditObject->findChild<QQuickItem*>("cursorInstance"));
+}
+
/*
TextEdit element should only handle left/right keys until the cursor reaches
the extent of the text, then they should ignore the keys.
@@ -2886,7 +2923,7 @@ void tst_qquicktextedit::navigation()
QCOMPARE(input->hasActiveFocus(), false);
}
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void tst_qquicktextedit::copyAndPaste()
{
if (!PlatformQuirks::isClipboardAvailable())
@@ -2963,7 +3000,7 @@ void tst_qquicktextedit::copyAndPaste()
}
#endif
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void tst_qquicktextedit::canPaste()
{
QGuiApplication::clipboard()->setText("Some text");
@@ -2981,7 +3018,7 @@ void tst_qquicktextedit::canPaste()
}
#endif
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void tst_qquicktextedit::canPasteEmpty()
{
QGuiApplication::clipboard()->clear();
@@ -2999,7 +3036,7 @@ void tst_qquicktextedit::canPasteEmpty()
}
#endif
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void tst_qquicktextedit::middleClickPaste()
{
if (!PlatformQuirks::isClipboardAvailable())
@@ -3301,7 +3338,7 @@ void tst_qquicktextedit::geometrySignals()
delete o;
}
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void tst_qquicktextedit::pastingRichText_QTBUG_14003()
{
QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.PlainText }";
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index 8dc3053d89..1451f8e2fc 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -145,7 +145,7 @@ private slots:
void cursorRectangle();
void navigation();
void navigation_RTL();
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void copyAndPaste();
void copyAndPasteKeySequence();
void canPasteEmpty();
@@ -2532,7 +2532,7 @@ void tst_qquicktextinput::navigation_RTL()
QVERIFY(input->hasActiveFocus());
}
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void tst_qquicktextinput::copyAndPaste()
{
if (!PlatformQuirks::isClipboardAvailable())
@@ -2630,7 +2630,7 @@ void tst_qquicktextinput::copyAndPaste()
}
#endif
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void tst_qquicktextinput::copyAndPasteKeySequence()
{
if (!PlatformQuirks::isClipboardAvailable())
@@ -2698,7 +2698,7 @@ void tst_qquicktextinput::copyAndPasteKeySequence()
}
#endif
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void tst_qquicktextinput::canPasteEmpty()
{
QGuiApplication::clipboard()->clear();
@@ -2714,7 +2714,7 @@ void tst_qquicktextinput::canPasteEmpty()
}
#endif
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void tst_qquicktextinput::canPaste()
{
QGuiApplication::clipboard()->setText("Some text");
@@ -2730,7 +2730,7 @@ void tst_qquicktextinput::canPaste()
}
#endif
-#ifndef QT_NO_CLIPBOARD
+#if QT_CONFIG(clipboard)
void tst_qquicktextinput::middleClickPaste()
{
if (!PlatformQuirks::isClipboardAvailable())
@@ -3052,7 +3052,7 @@ void tst_qquicktextinput::cursorRectangle_data()
<< false;
}
-#ifndef QT_NO_IM
+#if QT_CONFIG(im)
#define COMPARE_INPUT_METHOD_QUERY(type, input, property, method, result) \
QCOMPARE((type) input->inputMethodQuery(property).method(), result);
#else
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index bfffa6f7f5..300ca392f9 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -284,7 +284,7 @@ public:
private slots:
void cleanup();
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
void openglContextCreatedSignal();
#endif
void aboutToStopSignal();
@@ -351,7 +351,7 @@ private slots:
void qobjectEventFilter_key();
void qobjectEventFilter_mouse();
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
void cursor();
#endif
@@ -374,14 +374,14 @@ private:
QTouchDevice *touchDevice;
QTouchDevice *touchDeviceWithVelocity;
};
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
Q_DECLARE_METATYPE(QOpenGLContext *);
#endif
void tst_qquickwindow::cleanup()
{
QVERIFY(QGuiApplication::topLevelWindows().isEmpty());
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
void tst_qquickwindow::openglContextCreatedSignal()
{
qRegisterMetaType<QOpenGLContext *>();
@@ -1346,7 +1346,7 @@ void tst_qquickwindow::headless()
if (isGL)
QVERIFY(!window->isSceneGraphInitialized());
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (QGuiApplication::platformName() == QLatin1String("windows")
&& QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) {
QSKIP("Crashes on Windows/ANGLE, QTBUG-42967");
@@ -1534,7 +1534,7 @@ void tst_qquickwindow::ownershipRootItem()
QVERIFY(!accessor->isRootItemDestroyed());
}
-#ifndef QT_NO_CURSOR
+#if QT_CONFIG(cursor)
void tst_qquickwindow::cursor()
{
QQuickWindow window;
@@ -1707,7 +1707,7 @@ void tst_qquickwindow::hideThenDelete()
QTest::qWaitForWindowExposed(&window);
const bool threaded = QQuickWindowPrivate::get(&window)->context->thread() != QGuiApplication::instance()->thread();
const bool isGL = window.rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (isGL)
openglDestroyed = new QSignalSpy(window.openglContext(), SIGNAL(aboutToBeDestroyed()));
#endif
@@ -1736,7 +1736,7 @@ void tst_qquickwindow::hideThenDelete()
}
QVERIFY(sgInvalidated->size() > 0);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (openglDestroyed)
QVERIFY(openglDestroyed->size() > 0);
#endif
@@ -2147,7 +2147,7 @@ void tst_qquickwindow::defaultSurfaceFormat()
QCOMPARE(format.profile(), reqFmt.profile());
QCOMPARE(int(format.options()), int(reqFmt.options()));
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
// Depth and stencil should be >= what has been requested. For real. But use
// the context since the window's surface format is only partially updated
// on most platforms.
@@ -2202,7 +2202,7 @@ public:
}
static int deleted;
};
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
class GlRenderJob : public QRunnable
{
public:
@@ -2273,7 +2273,7 @@ void tst_qquickwindow::testRenderJob()
QTRY_COMPARE(RenderJob::deleted, 1);
QCOMPARE(completedJobs.size(), 1);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (window.rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL) {
// Do a synchronized GL job.
GLubyte readPixel[4] = {0, 0, 0, 0};
diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
index f6d624d871..2cd3a041c8 100644
--- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp
+++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
@@ -28,7 +28,7 @@
#include <qtest.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
#include <QOffscreenSurface>
#include <QOpenGLContext>
#include <QOpenGLFunctions>
@@ -37,7 +37,7 @@
#include <QtQuick>
#include <QtQml>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
#include <private/qopenglcontext_p.h>
#endif
@@ -105,7 +105,7 @@ private slots:
void render_data();
void render();
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
void hideWithOtherContext();
#endif
void createTextureFromImage_data();
@@ -130,7 +130,7 @@ void tst_SceneGraph::initTestCase()
QSGRenderLoop *loop = QSGRenderLoop::instance();
qDebug() << "RenderLoop: " << loop;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QOpenGLContext context;
context.setFormat(loop->sceneGraphContext()->defaultSurfaceFormat());
context.create();
@@ -222,7 +222,7 @@ void tst_SceneGraph::manyWindows_data()
QTest::newRow("rects,subwindow,sharing") << QStringLiteral("manyWindows_rects.qml") << false << true;
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
struct ShareContextResetter {
public:
~ShareContextResetter() { qt_gl_set_global_share_context(0); }
@@ -234,7 +234,7 @@ void tst_SceneGraph::manyWindows()
QFETCH(QString, file);
QFETCH(bool, toplevel);
QFETCH(bool, shared);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QOpenGLContext sharedGLContext;
ShareContextResetter cleanup; // To avoid dangling pointer in case of test-failure.
if (shared) {
@@ -479,7 +479,7 @@ void tst_SceneGraph::render()
}
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
// Testcase for QTBUG-34898. We make another context current on another surface
// in the GUI thread and hide the QQuickWindow while the other context is
// current on the other window.
diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp
index ab58aee648..cb2b8be97a 100644
--- a/tests/auto/quick/shared/viewtestutil.cpp
+++ b/tests/auto/quick/shared/viewtestutil.cpp
@@ -61,7 +61,7 @@ void QQuickViewTestUtil::centerOnScreen(QQuickView *window)
void QQuickViewTestUtil::moveMouseAway(QQuickView *window)
{
-#ifndef QT_NO_CURSOR // Get the cursor out of the way.
+#if QT_CONFIG(cursor) // Get the cursor out of the way.
QCursor::setPos(window->geometry().topRight() + QPoint(100, 100));
#else
Q_UNUSED(window)
diff --git a/tests/auto/quicktest/quicktest.pro b/tests/auto/quicktest/quicktest.pro
new file mode 100644
index 0000000000..3b4ec23a64
--- /dev/null
+++ b/tests/auto/quicktest/quicktest.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+SUBDIRS = \
+ signalspy
diff --git a/tests/auto/quicktest/signalspy/data/signalspy.qml b/tests/auto/quicktest/signalspy/data/signalspy.qml
new file mode 100644
index 0000000000..6c365e296a
--- /dev/null
+++ b/tests/auto/quicktest/signalspy/data/signalspy.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtTest 1.1
+import MyImport 1.0
+
+Rectangle {
+ id:rect
+ width: 200
+ height: 200
+ color:"red"
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ }
+
+ MyPropertyMap {
+ id: propertyMap
+ objectName: "propertyMap"
+ }
+
+ SignalSpy {
+ objectName: "mouseSpy"
+ target: mouseArea
+ signalName: "pressed"
+ }
+
+ SignalSpy {
+ objectName: "propertyMapSpy"
+ target: propertyMap
+ signalName: "mySignal"
+ }
+}
diff --git a/tests/auto/quicktest/signalspy/mypropertymap.cpp b/tests/auto/quicktest/signalspy/mypropertymap.cpp
new file mode 100644
index 0000000000..91bd93dde0
--- /dev/null
+++ b/tests/auto/quicktest/signalspy/mypropertymap.cpp
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mypropertymap.h"
+
+MyPropertyMap::MyPropertyMap(QObject *parent): QQmlPropertyMap(this, parent)
+{
+}
+
+MyPropertyMap::~MyPropertyMap()
+{
+}
+
diff --git a/tests/auto/quicktest/signalspy/mypropertymap.h b/tests/auto/quicktest/signalspy/mypropertymap.h
new file mode 100644
index 0000000000..d69548fe88
--- /dev/null
+++ b/tests/auto/quicktest/signalspy/mypropertymap.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QQmlPropertyMap>
+
+class MyPropertyMap : public QQmlPropertyMap
+{
+ Q_OBJECT
+
+public:
+ MyPropertyMap(QObject *parent = nullptr);
+ ~MyPropertyMap();
+
+Q_SIGNALS:
+ void mySignal();
+};
diff --git a/tests/auto/quicktest/signalspy/signalspy.pro b/tests/auto/quicktest/signalspy/signalspy.pro
new file mode 100644
index 0000000000..c8f9be1f36
--- /dev/null
+++ b/tests/auto/quicktest/signalspy/signalspy.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_signalspy
+macos:CONFIG -= app_bundle
+
+SOURCES += tst_signalspy.cpp mypropertymap.cpp
+HEADERS += mypropertymap.h
+QT += quick testlib
+
+include (../../shared/util.pri)
diff --git a/tests/auto/quicktest/signalspy/tst_signalspy.cpp b/tests/auto/quicktest/signalspy/tst_signalspy.cpp
new file mode 100644
index 0000000000..f54da7819c
--- /dev/null
+++ b/tests/auto/quicktest/signalspy/tst_signalspy.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+
+#include <qqmlengine.h>
+#include <qquickitem.h>
+#include <qquickview.h>
+
+#include "../../shared/util.h"
+#include "mypropertymap.h"
+
+class tst_SignalSpy : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_SignalSpy();
+
+private slots:
+ void testValid();
+ void testCount();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_SignalSpy::tst_SignalSpy()
+{
+ qmlRegisterType<MyPropertyMap>("MyImport", 1, 0, "MyPropertyMap");
+}
+
+void tst_SignalSpy::testValid()
+{
+ QQuickView window;
+ window.setSource(testFileUrl("signalspy.qml"));
+ QVERIFY(window.rootObject() != 0);
+
+ QObject *mouseSpy = window.rootObject()->findChild<QObject*>("mouseSpy");
+ QVERIFY(mouseSpy->property("valid").toBool());
+
+ QObject *propertyMapSpy = window.rootObject()->findChild<QObject*>("propertyMapSpy");
+ QVERIFY(propertyMapSpy->property("valid").toBool());
+}
+
+void tst_SignalSpy::testCount()
+{
+ QQuickView window;
+ window.resize(200, 200);
+ window.setSource(testFileUrl("signalspy.qml"));
+ window.show();
+ QTest::qWaitForWindowActive(&window);
+ QVERIFY(window.rootObject() != 0);
+
+ QObject *mouseSpy = window.rootObject()->findChild<QObject*>("mouseSpy");
+ QCOMPARE(mouseSpy->property("count").toInt(), 0);
+
+ QObject *propertyMapSpy = window.rootObject()->findChild<QObject*>("propertyMapSpy");
+ QCOMPARE(propertyMapSpy->property("count").toInt(), 0);
+
+ QTest::mouseClick(&window, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(100, 100));
+ QTRY_COMPARE(mouseSpy->property("count").toInt(), 1);
+
+ MyPropertyMap *propertyMap = static_cast<MyPropertyMap *>(window.rootObject()->findChild<QObject*>("propertyMap"));
+ Q_EMIT propertyMap->mySignal();
+ QCOMPARE(propertyMapSpy->property("count").toInt(), 1);
+}
+
+QTEST_MAIN(tst_SignalSpy)
+
+#include "tst_signalspy.moc"
diff --git a/tests/auto/shared/platformquirks.h b/tests/auto/shared/platformquirks.h
index 5e4929230a..5252e8cfe2 100644
--- a/tests/auto/shared/platformquirks.h
+++ b/tests/auto/shared/platformquirks.h
@@ -39,7 +39,7 @@ struct PlatformQuirks
{
static inline bool isClipboardAvailable()
{
-#if defined(QT_NO_CLIPBOARD)
+#if !QT_CONFIG(clipboard)
return false;
#elif defined(Q_OS_OSX)
PasteboardRef pasteboard;
diff --git a/tests/benchmarks/qml/compilation/tst_compilation.cpp b/tests/benchmarks/qml/compilation/tst_compilation.cpp
index 690e193b53..61339c6f60 100644
--- a/tests/benchmarks/qml/compilation/tst_compilation.cpp
+++ b/tests/benchmarks/qml/compilation/tst_compilation.cpp
@@ -75,7 +75,7 @@ void tst_compilation::boomblock()
QQmlComponent c(&engine);
c.setData(data, QUrl());
}
-#ifdef QT_NO_OPENGL
+#if !QT_CONFIG(opengl)
QSKIP("boomblock imports Particles which requires OpenGL Support");
#endif
QBENCHMARK {
diff --git a/tests/benchmarks/qml/creation/tst_creation.cpp b/tests/benchmarks/qml/creation/tst_creation.cpp
index a1c09db158..9fc67ada71 100644
--- a/tests/benchmarks/qml/creation/tst_creation.cpp
+++ b/tests/benchmarks/qml/creation/tst_creation.cpp
@@ -221,12 +221,15 @@ inline void QQmlGraphics_setParent_noEvent(QObject *object, QObject *parent)
void tst_creation::itemtree_notree_cpp()
{
+ std::vector<QQuickItem *> kids;
+ kids.resize(30);
QBENCHMARK {
QQuickItem *item = new QQuickItem;
for (int i = 0; i < 30; ++i) {
QQuickItem *child = new QQuickItem;
- Q_UNUSED(child);
+ kids[i] = child;
}
+ qDeleteAll(kids);
delete item;
}
}
@@ -258,12 +261,13 @@ void tst_creation::itemtree_cpp()
void tst_creation::itemtree_data_cpp()
{
+ QQmlEngine engine;
QBENCHMARK {
QQuickItem *item = new QQuickItem;
for (int i = 0; i < 30; ++i) {
QQuickItem *child = new QQuickItem;
QQmlGraphics_setParent_noEvent(child,item);
- QQmlListReference ref(item, "data");
+ QQmlListReference ref(item, "data", &engine);
ref.append(child);
}
delete item;
diff --git a/tests/benchmarks/qml/qml.pro b/tests/benchmarks/qml/qml.pro
index 2cf2dff413..f1fe87e532 100644
--- a/tests/benchmarks/qml/qml.pro
+++ b/tests/benchmarks/qml/qml.pro
@@ -14,5 +14,3 @@ SUBDIRS += \
creation
qtHaveModule(opengl): SUBDIRS += painting qquickwindow
-
-include(../trusted-benchmarks.pri)
diff --git a/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_ltr.qml b/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_ltr.qml
new file mode 100644
index 0000000000..b8f0458818
--- /dev/null
+++ b/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_ltr.qml
@@ -0,0 +1,14 @@
+import QtQuick 2.0
+
+Item {
+ width: 320
+ height: 480
+
+ Text {
+ anchors.centerIn: parent
+ font.family: "Arial"
+ font.pixelSize: 16
+ textFormat: Text.RichText
+ text: "<img width=16 height=16 src=\"data/logo.png\" />This image is in the start of the text"
+ }
+}
diff --git a/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_rtl.qml b/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_rtl.qml
new file mode 100644
index 0000000000..e5bea08e62
--- /dev/null
+++ b/tests/manual/scenegraph_lancelot/data/text/text_flow_image_start_rtl.qml
@@ -0,0 +1,14 @@
+import QtQuick 2.0
+
+Item {
+ width: 320
+ height: 480
+
+ Text {
+ anchors.centerIn: parent
+ font.family: "Arial"
+ font.pixelSize: 16
+ textFormat: Text.RichText
+ text: "<img width=16 height=16 src=\"data/logo.png\" />هو أمّا حكومة"
+ }
+}
diff --git a/tests/tests.pro b/tests/tests.pro
index f5731b2f34..ab94786b31 100644
--- a/tests/tests.pro
+++ b/tests/tests.pro
@@ -1,2 +1,3 @@
TEMPLATE = subdirs
-SUBDIRS += auto benchmarks
+SUBDIRS += auto
+contains(QT_CONFIG, release): SUBDIRS += benchmarks
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index fdfc66f3a6..5e8b872821 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -215,7 +215,7 @@ public Q_SLOTS:
returnCode = retCode;
}
-#if defined(QT_GUI_LIB) && !defined(QT_NO_OPENGL)
+#if defined(QT_GUI_LIB) && QT_CONFIG(opengl)
void onOpenGlContextCreated(QOpenGLContext *context);
#endif
};
@@ -237,7 +237,7 @@ void LoadWatcher::contain(QObject *o, const QUrl &containPath)
void LoadWatcher::checkForWindow(QObject *o)
{
-#if defined(QT_GUI_LIB) && !defined(QT_NO_OPENGL)
+#if defined(QT_GUI_LIB) && QT_CONFIG(opengl)
if (verboseMode && o->isWindowType() && o->inherits("QQuickWindow")) {
connect(o, SIGNAL(openglContextCreated(QOpenGLContext*)),
this, SLOT(onOpenGlContextCreated(QOpenGLContext*)));
@@ -247,7 +247,7 @@ void LoadWatcher::checkForWindow(QObject *o)
#endif // QT_GUI_LIB && !QT_NO_OPENGL
}
-#if defined(QT_GUI_LIB) && !defined(QT_NO_OPENGL)
+#if defined(QT_GUI_LIB) && QT_CONFIG(opengl)
void LoadWatcher::onOpenGlContextCreated(QOpenGLContext *context)
{
context->makeCurrent(qobject_cast<QWindow *>(sender()));
@@ -453,6 +453,7 @@ int main(int argc, char *argv[])
app->setApplicationName("Qml Runtime");
app->setOrganizationName("QtProject");
app->setOrganizationDomain("qt-project.org");
+ QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
qmlRegisterType<Config>("QmlRuntime.Config", 1, 0, "Configuration");
qmlRegisterType<PartialScene>("QmlRuntime.Config", 1, 0, "PartialScene");
@@ -523,7 +524,7 @@ int main(int argc, char *argv[])
if (quietMode && verboseMode)
verboseMode = false;
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
//qt_ translations loaded by QQmlApplicationEngine
QString sysLocale = QLocale::system().name();
@@ -568,7 +569,7 @@ int main(int argc, char *argv[])
for (const QString &path : qAsConst(files)) {
//QUrl::fromUserInput doesn't treat no scheme as relative file paths
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
QRegularExpression urlRe("[[:word:]]+://.*");
if (urlRe.match(path).hasMatch()) { //Treat as a URL
QUrl url = QUrl::fromUserInput(path);
diff --git a/tools/qmleasing/main.cpp b/tools/qmleasing/main.cpp
index ab137d5eb4..389503507e 100644
--- a/tools/qmleasing/main.cpp
+++ b/tools/qmleasing/main.cpp
@@ -33,6 +33,7 @@
int main(int argc, char ** argv)
{
QApplication app(argc, argv);
+ QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
MainWindow mainWindow;
mainWindow.show();
diff --git a/tools/qmleasing/mainwindow.h b/tools/qmleasing/mainwindow.h
index 9af5c8050c..7ca4dbfd5c 100644
--- a/tools/qmleasing/mainwindow.h
+++ b/tools/qmleasing/mainwindow.h
@@ -51,9 +51,9 @@ public slots:
void importData(int result);
protected:
- virtual void moveEvent(QMoveEvent *event);
- virtual void resizeEvent(QResizeEvent *event);
- virtual void closeEvent(QCloseEvent *event);
+ void moveEvent(QMoveEvent *event) override;
+ void resizeEvent(QResizeEvent *event) override;
+ void closeEvent(QCloseEvent *event) override;
void initQml();
private:
diff --git a/tools/qmleasing/splineeditor.cpp b/tools/qmleasing/splineeditor.cpp
index d54a101b69..cd0c0b3ae0 100644
--- a/tools/qmleasing/splineeditor.cpp
+++ b/tools/qmleasing/splineeditor.cpp
@@ -224,7 +224,7 @@ void SplineEditor::mouseReleaseEvent(QMouseEvent *e)
}
}
-#ifndef QT_NO_CONTEXTMENU
+#if QT_CONFIG(contextmenu)
void SplineEditor::contextMenuEvent(QContextMenuEvent *e)
{
int index = findControlPoint(e->pos());
@@ -244,7 +244,7 @@ void SplineEditor::contextMenuEvent(QContextMenuEvent *e)
addPoint(e->pos());
}
}
-#endif // QT_NO_CONTEXTMENU
+#endif // contextmenu
void SplineEditor::invalidate()
{
diff --git a/tools/qmleasing/splineeditor.h b/tools/qmleasing/splineeditor.h
index 243e199cd0..8dd47c3a89 100644
--- a/tools/qmleasing/splineeditor.h
+++ b/tools/qmleasing/splineeditor.h
@@ -75,13 +75,13 @@ public slots:
void setEasingCurve(const QString &code);
protected:
- void paintEvent(QPaintEvent *);
- void mousePressEvent(QMouseEvent *);
- void mouseMoveEvent(QMouseEvent *);
- void mouseReleaseEvent(QMouseEvent *);
-#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QContextMenuEvent *);
-#endif // QT_NO_CONTEXTMENU
+ void paintEvent(QPaintEvent *) override;
+ void mousePressEvent(QMouseEvent *) override;
+ void mouseMoveEvent(QMouseEvent *) override;
+ void mouseReleaseEvent(QMouseEvent *) override;
+#if QT_CONFIG(contextmenu)
+ void contextMenuEvent(QContextMenuEvent *) override;
+#endif // contextmenu
void invalidate();
void invalidateSmoothList();
diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp
index 8f476649e9..84f0d6deb1 100644
--- a/tools/qmlimportscanner/main.cpp
+++ b/tools/qmlimportscanner/main.cpp
@@ -485,6 +485,7 @@ QVariantList findQmlImportsRecursively(const QStringList &qmlDirs, const QString
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
+ QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
QStringList args = app.arguments();
const QString appName = QFileInfo(app.applicationFilePath()).baseName();
if (args.size() < 2) {
@@ -520,7 +521,8 @@ int main(int argc, char *argv[])
std::cerr << "-importPath requires an argument\n";
argReceiver = &qmlImportPaths;
} else {
- std::cerr << "Invalid argument: \"" << qPrintable(arg) << "\"\n";
+ std::cerr << qPrintable(appName) << ": Invalid argument: \""
+ << qPrintable(arg) << "\"\n";
return 1;
}
@@ -529,7 +531,13 @@ int main(int argc, char *argv[])
if (arg.startsWith(QLatin1Char('-')) && arg != QLatin1String("-"))
break;
++i;
- *argReceiver += arg;
+ if (!QFile::exists(arg)) {
+ std::cerr << qPrintable(appName) << ": No such file or directory: \""
+ << qPrintable(arg) << "\"\n";
+ return 1;
+ } else {
+ *argReceiver += arg;
+ }
}
}
diff --git a/tools/qmljs/qmljs.cpp b/tools/qmljs/qmljs.cpp
index d09d2f7d0c..54e1b6cea8 100644
--- a/tools/qmljs/qmljs.cpp
+++ b/tools/qmljs/qmljs.cpp
@@ -42,6 +42,7 @@
#include "private/qv4context_p.h"
#include "private/qv4script_p.h"
#include "private/qv4string_p.h"
+#include "private/qqmlbuiltinfunctions_p.h"
#ifdef V4_ENABLE_JIT
# include "private/qv4isel_masm_p.h"
@@ -60,57 +61,6 @@ QT_REQUIRE_CONFIG(qml_interpreter);
#include <iostream>
-namespace builtins {
-
-using namespace QV4;
-
-struct Print: FunctionObject
-{
- struct Data : Heap::FunctionObject {
- void init(ExecutionContext *scope)
- {
- Heap::FunctionObject::init(scope, QStringLiteral("print"));
- }
- };
- V4_OBJECT(FunctionObject)
-
- static void call(const Managed *, Scope &scope, CallData *callData)
- {
- for (int i = 0; i < callData->argc; ++i) {
- QString s = callData->args[i].toQStringNoThrow();
- if (i)
- std::cout << ' ';
- std::cout << qPrintable(s);
- }
- std::cout << std::endl;
- scope.result = Encode::undefined();
- }
-};
-
-DEFINE_OBJECT_VTABLE(Print);
-
-struct GC: public FunctionObject
-{
- struct Data : Heap::FunctionObject {
- void init(ExecutionContext *scope)
- {
- Heap::FunctionObject::init(scope, QStringLiteral("gc"));
- }
-
- };
- V4_OBJECT(FunctionObject)
-
- static void call(const Managed *m, Scope &scope, CallData *)
- {
- static_cast<const GC *>(m)->engine()->memoryManager->runGC();
- scope.result = Encode::undefined();
- }
-};
-
-DEFINE_OBJECT_VTABLE(GC);
-
-} // builtins
-
static void showException(QV4::ExecutionContext *ctx, const QV4::Value &exception, const QV4::StackTrace &trace)
{
QV4::Scope scope(ctx);
@@ -135,6 +85,7 @@ static void showException(QV4::ExecutionContext *ctx, const QV4::Value &exceptio
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
+ QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
QStringList args = app.arguments();
args.removeFirst();
@@ -199,10 +150,7 @@ int main(int argc, char *argv[])
QV4::Scope scope(&vm);
QV4::ScopedContext ctx(scope, vm.rootContext());
- QV4::ScopedObject print(scope, vm.memoryManager->allocObject<builtins::Print>(vm.rootContext()));
- vm.globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("print"))).getPointer(), print);
- QV4::ScopedObject gc(scope, vm.memoryManager->allocObject<builtins::GC>(ctx));
- vm.globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("gc"))).getPointer(), gc);
+ QV4::GlobalExtensions::init(vm.globalObject, QJSEngine::ConsoleExtension | QJSEngine::GarbageCollectionExtension);
for (const QString &fn : qAsConst(args)) {
QFile file(fn);
diff --git a/tools/qmlmin/main.cpp b/tools/qmlmin/main.cpp
index d2bad9d0d5..6877ca7442 100644
--- a/tools/qmlmin/main.cpp
+++ b/tools/qmlmin/main.cpp
@@ -533,6 +533,7 @@ static void usage(bool showHelp = false)
int runQmlmin(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
+ QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
const QStringList args = app.arguments();
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp
index 3294fa1e87..92a8465d9f 100644
--- a/tools/qmlplugindump/main.cpp
+++ b/tools/qmlplugindump/main.cpp
@@ -72,11 +72,12 @@
#include <qt_windows.h>
#endif
+namespace {
-static const uint qtQmlMajorVersion = 2;
-static const uint qtQmlMinorVersion = 2;
-static const uint qtQuickMajorVersion = 2;
-static const uint qtQuickMinorVersion = 8;
+const uint qtQmlMajorVersion = 2;
+const uint qtQmlMinorVersion = 2;
+const uint qtQuickMajorVersion = 2;
+const uint qtQuickMinorVersion = 8;
const QString qtQuickQualifiedName = QString::fromLatin1("QtQuick %1.%2")
.arg(qtQuickMajorVersion)
@@ -89,6 +90,8 @@ bool creatable = true;
QString currentProperty;
QString inObjectInstantiation;
+}
+
static QString enquote(const QString &string)
{
QString s = string;
@@ -987,6 +990,7 @@ int main(int argc, char *argv[])
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);
QGuiApplication app(argc, argv);
+ QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
const QStringList args = app.arguments();
const QString appName = QFileInfo(app.applicationFilePath()).baseName();
if (args.size() < 2) {
diff --git a/tools/qmlprofiler/qmlprofilerclient.h b/tools/qmlprofiler/qmlprofilerclient.h
index 1da04db42a..a04a412bb0 100644
--- a/tools/qmlprofiler/qmlprofilerclient.h
+++ b/tools/qmlprofiler/qmlprofilerclient.h
@@ -50,24 +50,24 @@ signals:
void error(const QString &error);
private:
- virtual void stateChanged(State state);
+ void stateChanged(State state) override;
- void traceStarted(qint64 time, int engineId);
- void traceFinished(qint64 time, int engineId);
- void rangeStart(QQmlProfilerDefinitions::RangeType type, qint64 startTime);
- void rangeData(QQmlProfilerDefinitions::RangeType type, qint64 time, const QString &data);
+ void traceStarted(qint64 time, int engineId) override;
+ void traceFinished(qint64 time, int engineId) override;
+ void rangeStart(QQmlProfilerDefinitions::RangeType type, qint64 startTime) override;
+ void rangeData(QQmlProfilerDefinitions::RangeType type, qint64 time, const QString &data) override;
void rangeLocation(QQmlProfilerDefinitions::RangeType type, qint64 time,
- const QQmlEventLocation &location);
- void rangeEnd(QQmlProfilerDefinitions::RangeType type, qint64 endTime);
- void animationFrame(qint64 time, int frameRate, int animationCount, int threadId);
+ const QQmlEventLocation &location) override;
+ void rangeEnd(QQmlProfilerDefinitions::RangeType type, qint64 endTime) override;
+ void animationFrame(qint64 time, int frameRate, int animationCount, int threadId) override;
void sceneGraphEvent(QQmlProfilerDefinitions::SceneGraphFrameType type, qint64 time,
qint64 numericData1, qint64 numericData2, qint64 numericData3,
- qint64 numericData4, qint64 numericData5);
+ qint64 numericData4, qint64 numericData5) override;
void pixmapCacheEvent(QQmlProfilerDefinitions::PixmapEventType type, qint64 time,
- const QString &url, int numericData1, int numericData2);
- void memoryAllocation(QQmlProfilerDefinitions::MemoryType type, qint64 time, qint64 amount);
- void inputEvent(QQmlProfilerDefinitions::InputEventType type, qint64 time, int a, int b);
- void complete();
+ const QString &url, int numericData1, int numericData2) override;
+ void memoryAllocation(QQmlProfilerDefinitions::MemoryType type, qint64 time, qint64 amount) override;
+ void inputEvent(QQmlProfilerDefinitions::InputEventType type, qint64 time, int a, int b) override;
+ void complete() override;
};
#endif // QMLPROFILERCLIENT_H
diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp
index 9e1002166d..1e8d91a95b 100644
--- a/tools/qmlscene/main.cpp
+++ b/tools/qmlscene/main.cpp
@@ -289,7 +289,7 @@ static bool checkVersion(const QUrl &url)
static void displayFileDialog(Options *options)
{
-#if defined(QT_WIDGETS_LIB) && !defined(QT_NO_FILEDIALOG)
+#if defined(QT_WIDGETS_LIB) && QT_CONFIG(filedialog)
QString fileName = QFileDialog::getOpenFileName(0, "Open QML file", QString(), "QML Files (*.qml)");
if (!fileName.isEmpty()) {
QFileInfo fi(fileName);
@@ -301,7 +301,7 @@ static void displayFileDialog(Options *options)
#endif
}
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
static void loadTranslationFile(QTranslator &translator, const QString& directory)
{
translator.load(QLatin1String("qml_" )+QLocale::system().name(), directory + QLatin1String("/i18n"));
@@ -361,7 +361,7 @@ static void usage()
puts(" ");
exit(1);
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
// Listen on GL context creation of the QQuickWindow in order to print diagnostic output.
class DiagnosticGlContextCreationListener : public QObject {
Q_OBJECT
@@ -405,7 +405,7 @@ static void setWindowTitle(bool verbose, const QObject *topLevel, QWindow *windo
if (verbose) {
newTitle += QLatin1String(" [Qt ") + QLatin1String(QT_VERSION_STR) + QLatin1Char(' ')
+ QGuiApplication::platformName() + QLatin1Char(' ');
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
newTitle += QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL
? QLatin1String("GL") : QLatin1String("GLES");
#endif
@@ -467,6 +467,7 @@ int main(int argc, char ** argv)
app.setApplicationName("QtQmlViewer");
app.setOrganizationName("QtProject");
app.setOrganizationDomain("qt-project.org");
+ QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
const QStringList arguments = QCoreApplication::arguments();
for (int i = 1, size = arguments.size(); i < size; ++i) {
@@ -508,7 +509,7 @@ int main(int argc, char ** argv)
}
}
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
QTranslator translator;
QTranslator qtTranslator;
QString sysLocale = QLocale::system().name();
@@ -544,7 +545,7 @@ int main(int argc, char ** argv)
if (!options.url.isEmpty()) {
if (!options.versionDetection || checkVersion(options.url)) {
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
QTranslator translator;
#endif
@@ -558,7 +559,7 @@ int main(int argc, char ** argv)
engine.addPluginPath(pluginPaths.at(i));
if (options.url.isLocalFile()) {
QFileInfo fi(options.url.toLocalFile());
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
loadTranslationFile(translator, fi.path());
#endif
loadDummyDataFiles(engine, fi.path());
@@ -597,7 +598,7 @@ int main(int argc, char ** argv)
if (window) {
setWindowTitle(options.verbose, topLevel, window.data());
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (options.verbose)
new DiagnosticGlContextCreationListener(window.data());
#endif
diff --git a/tools/qmltime/qmltime.cpp b/tools/qmltime/qmltime.cpp
index 8afaebc413..4c282dd8f4 100644
--- a/tools/qmltime/qmltime.cpp
+++ b/tools/qmltime/qmltime.cpp
@@ -205,6 +205,7 @@ void usage(const char *name)
int main(int argc, char ** argv)
{
QGuiApplication app(argc, argv);
+ QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
qmlRegisterType<Timer>("QmlTime", 1, 0, "Timer");