aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--src/3rdparty/masm/assembler/LinkBuffer.h13
-rw-r--r--src/3rdparty/masm/stubs/ExecutableAllocator.h1
-rw-r--r--src/3rdparty/masm/yarr/YarrJIT.cpp40
-rw-r--r--src/3rdparty/masm/yarr/YarrJIT.h25
-rw-r--r--src/3rdparty/masm/yarr/YarrPattern.h1
-rw-r--r--src/imports/builtins/builtins.qmltypes4
-rw-r--r--src/imports/folderlistmodel/plugins.qmltypes4
-rw-r--r--src/imports/layouts/plugins.qmltypes4
-rw-r--r--src/imports/layouts/qquickstacklayout.cpp4
-rw-r--r--src/imports/layouts/qquickstacklayout_p.h4
-rw-r--r--src/imports/localstorage/plugin.cpp27
-rw-r--r--src/imports/localstorage/plugins.qmltypes2
-rw-r--r--src/imports/models/plugins.qmltypes2
-rw-r--r--src/imports/particles/plugins.qmltypes4
-rw-r--r--src/imports/qtqml/plugins.qmltypes2
-rw-r--r--src/imports/qtquick2/plugins.qmltypes33
-rw-r--r--src/imports/settings/plugins.qmltypes1
-rw-r--r--src/imports/settings/qqmlsettings.cpp19
-rw-r--r--src/imports/settings/qqmlsettings_p.h1
-rw-r--r--src/imports/shapes/plugins.qmltypes4
-rw-r--r--src/imports/sharedimage/plugins.qmltypes2
-rw-r--r--src/imports/statemachine/plugins.qmltypes2
-rw-r--r--src/imports/testlib/TestCase.qml106
-rw-r--r--src/imports/testlib/main.cpp1
-rw-r--r--src/imports/testlib/plugins.qmltypes23
-rw-r--r--src/imports/testlib/toucheventsequence.qdoc6
-rw-r--r--src/imports/wavefrontmesh/plugins.qmltypes4
-rw-r--r--src/imports/window/plugins.qmltypes13
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvghelpers.cpp8
-rw-r--r--src/qml/animations/qanimationgroupjob_p.h2
-rw-r--r--src/qml/animations/qsequentialanimationgroupjob.cpp9
-rw-r--r--src/qml/animations/qsequentialanimationgroupjob_p.h1
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp11
-rw-r--r--src/qml/compiler/qqmlirbuilder_p.h65
-rw-r--r--src/qml/compiler/qqmlpropertyvalidator.cpp80
-rw-r--r--src/qml/compiler/qv4bytecodegenerator.cpp4
-rw-r--r--src/qml/compiler/qv4bytecodegenerator_p.h70
-rw-r--r--src/qml/compiler/qv4bytecodehandler.cpp455
-rw-r--r--src/qml/compiler/qv4bytecodehandler_p.h10
-rw-r--r--src/qml/compiler/qv4codegen.cpp140
-rw-r--r--src/qml/compiler/qv4compileddata.cpp7
-rw-r--r--src/qml/compiler/qv4compileddata_p.h21
-rw-r--r--src/qml/compiler/qv4compiler.cpp15
-rw-r--r--src/qml/compiler/qv4compilercontext.cpp24
-rw-r--r--src/qml/compiler/qv4compilercontext_p.h4
-rw-r--r--src/qml/compiler/qv4instr_moth.cpp75
-rw-r--r--src/qml/compiler/qv4instr_moth_p.h73
-rw-r--r--src/qml/configure.json9
-rw-r--r--src/qml/debugger/qqmldebug.cpp8
-rw-r--r--src/qml/doc/snippets/qml/integrating-javascript/includejs/app.qml2
-rw-r--r--src/qml/doc/snippets/qml/integrating-javascript/includejs/factorial.mjs (renamed from src/qml/doc/snippets/qml/integrating-javascript/includejs/factorial.js)4
-rw-r--r--src/qml/doc/snippets/qml/integrating-javascript/includejs/script.mjs (renamed from src/qml/doc/snippets/qml/integrating-javascript/includejs/script.js)2
-rw-r--r--src/qml/doc/src/cppintegration/data.qdoc3
-rw-r--r--src/qml/doc/src/javascript/imports.qdoc65
-rw-r--r--src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc52
-rw-r--r--src/qml/doc/src/statemachine.qdoc4
-rw-r--r--src/qml/jit/qv4assemblercommon.cpp66
-rw-r--r--src/qml/jit/qv4assemblercommon_p.h6
-rw-r--r--src/qml/jit/qv4baselineassembler.cpp26
-rw-r--r--src/qml/jit/qv4baselineassembler_p.h15
-rw-r--r--src/qml/jit/qv4baselinejit.cpp92
-rw-r--r--src/qml/jit/qv4baselinejit_p.h65
-rw-r--r--src/qml/jsruntime/jsruntime.pri20
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp6
-rw-r--r--src/qml/jsruntime/qv4engine.cpp41
-rw-r--r--src/qml/jsruntime/qv4executableallocator.cpp10
-rw-r--r--src/qml/jsruntime/qv4executableallocator_p.h1
-rw-r--r--src/qml/jsruntime/qv4function.cpp67
-rw-r--r--src/qml/jsruntime/qv4function_p.h52
-rw-r--r--src/qml/jsruntime/qv4functiontable_noop.cpp65
-rw-r--r--src/qml/jsruntime/qv4functiontable_p.h75
-rw-r--r--src/qml/jsruntime/qv4functiontable_unix.cpp99
-rw-r--r--src/qml/jsruntime/qv4functiontable_win64.cpp153
-rw-r--r--src/qml/jsruntime/qv4global_p.h14
-rw-r--r--src/qml/jsruntime/qv4math_p.h27
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp50
-rw-r--r--src/qml/jsruntime/qv4runtimeapi_p.h2
-rw-r--r--src/qml/jsruntime/qv4variantobject.cpp13
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp153
-rw-r--r--src/qml/parser/parser.pri3
-rw-r--r--src/qml/parser/qqmljs.g8
-rw-r--r--src/qml/parser/qqmljsast.cpp4
-rw-r--r--src/qml/parser/qqmljsast_p.h4
-rw-r--r--src/qml/parser/qqmljsastfwd_p.h26
-rw-r--r--src/qml/parser/qqmljsastvisitor.cpp4
-rw-r--r--src/qml/parser/qqmljsastvisitor_p.h4
-rw-r--r--src/qml/parser/qqmljsengine_p.cpp4
-rw-r--r--src/qml/parser/qqmljsengine_p.h8
-rw-r--r--src/qml/parser/qqmljsglobal_p.h4
-rw-r--r--src/qml/parser/qqmljskeywords_p.h4
-rw-r--r--src/qml/parser/qqmljslexer_p.h4
-rw-r--r--src/qml/parser/qqmljsmemorypool_p.h81
-rw-r--r--src/qml/parser/qqmljssourcelocation_p.h87
-rw-r--r--src/qml/qml.pro1
-rw-r--r--src/qml/qml/qml.pri4
-rw-r--r--src/qml/qml/qqml.h3
-rw-r--r--src/qml/qml/qqmlabstracturlinterceptor.h4
-rw-r--r--src/qml/qml/qqmlapplicationengine_p.h1
-rw-r--r--src/qml/qml/qqmlbinding.cpp2
-rw-r--r--src/qml/qml/qqmlengine.cpp4
-rw-r--r--src/qml/qml/qqmlengine_p.h2
-rw-r--r--src/qml/qml/qqmlexpression.cpp1
-rw-r--r--src/qml/qml/qqmlextensioninterface.h4
-rw-r--r--src/qml/qml/qqmlfile.cpp17
-rw-r--r--src/qml/qml/qqmlglobal_p.h10
-rw-r--r--src/qml/qml/qqmlmetatype.cpp20
-rw-r--r--src/qml/qml/qqmlmetatype_p.h2
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp89
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp108
-rw-r--r--src/qml/qml/qqmltypeloader.cpp14
-rw-r--r--src/qml/qml/qqmlvaluetype.cpp5
-rw-r--r--src/qml/qml/qqmlvaluetype_p.h1
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp12
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp23
-rw-r--r--src/qml/qmldirparser/qmldirparser.pri11
-rw-r--r--src/qml/qmldirparser/qqmldirparser.cpp (renamed from src/qml/qml/qqmldirparser.cpp)2
-rw-r--r--src/qml/qmldirparser/qqmldirparser_p.h (renamed from src/qml/qml/qqmldirparser_p.h)4
-rw-r--r--src/qml/qmldirparser/qqmlerror.cpp (renamed from src/qml/qml/qqmlerror.cpp)16
-rw-r--r--src/qml/qmldirparser/qqmlerror.h (renamed from src/qml/qml/qqmlerror.h)4
-rw-r--r--src/qml/qmldirparser/qqmlsourcecoordinate_p.h72
-rw-r--r--src/qml/qtqmlglobal.h1
-rw-r--r--src/qml/types/qqmllistmodel.cpp2
-rw-r--r--src/qml/types/qquickworkerscript.cpp2
-rw-r--r--src/qmldebug/qmldebug.pro13
-rw-r--r--src/qmldebug/qqmlenginedebugclient.cpp (renamed from tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp)190
-rw-r--r--src/qmldebug/qqmlenginedebugclient_p.h168
-rw-r--r--src/qmldebug/qqmlenginedebugclient_p_p.h76
-rw-r--r--src/qmldebug/qqmlinspectorclient.cpp (renamed from tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp)72
-rw-r--r--src/qmldebug/qqmlinspectorclient_p.h85
-rw-r--r--src/qmldebug/qqmlinspectorclient_p_p.h69
-rw-r--r--src/qmldebug/qv4debugclient.cpp578
-rw-r--r--src/qmldebug/qv4debugclient_p.h121
-rw-r--r--src/qmldebug/qv4debugclient_p_p.h80
-rw-r--r--src/qmldevtools/qmldevtools.pro1
-rw-r--r--src/qmltest/doc/qtqmltest.qdocconf22
-rw-r--r--src/qmltest/doc/snippets/src_qmltest_qquicktest.cpp81
-rw-r--r--src/qmltest/doc/src/qtquicktest-cppapi.qdoc59
-rw-r--r--src/qmltest/doc/src/qtquicktest-index.qdoc48
-rw-r--r--src/qmltest/doc/src/qtquicktest-qmltypes.qdoc46
-rw-r--r--src/qmltest/doc/src/qtquicktest.qdoc79
-rw-r--r--src/qmltest/qmltest.pro2
-rw-r--r--src/qmltest/quicktest.cpp59
-rw-r--r--src/qmltest/quicktest.h13
-rw-r--r--src/qmltest/quicktestresult.cpp16
-rw-r--r--src/qmltest/quicktestresult_p.h3
-rw-r--r--src/quick/accessible/qaccessiblequickview.cpp2
-rw-r--r--src/quick/designer/qquickdesignersupportitems.cpp10
-rw-r--r--src/quick/doc/snippets/pointerHandlers/dragHandlerNullTarget.qml2
-rw-r--r--src/quick/doc/src/qmltypereference.qdoc16
-rw-r--r--src/quick/handlers/handlers.pri1
-rw-r--r--src/quick/handlers/qquickdragaxis.cpp3
-rw-r--r--src/quick/handlers/qquickdragaxis_p.h11
-rw-r--r--src/quick/handlers/qquickdraghandler_p.h2
-rw-r--r--src/quick/handlers/qquickhoverhandler_p.h2
-rw-r--r--src/quick/handlers/qquickmultipointhandler_p.h2
-rw-r--r--src/quick/handlers/qquickpinchhandler_p.h2
-rw-r--r--src/quick/handlers/qquickpointerdevicehandler_p.h2
-rw-r--r--src/quick/handlers/qquickpointerdevicehandler_p_p.h2
-rw-r--r--src/quick/handlers/qquickpointhandler_p.h2
-rw-r--r--src/quick/handlers/qquicksinglepointhandler.cpp62
-rw-r--r--src/quick/handlers/qquicksinglepointhandler_p.h15
-rw-r--r--src/quick/handlers/qquicksinglepointhandler_p_p.h79
-rw-r--r--src/quick/handlers/qquicktaphandler.cpp3
-rw-r--r--src/quick/handlers/qquicktaphandler_p.h2
-rw-r--r--src/quick/items/context2d/qquickcanvasitem.cpp2
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp6
-rw-r--r--src/quick/items/qquickclipnode.cpp3
-rw-r--r--src/quick/items/qquickclipnode_p.h4
-rw-r--r--src/quick/items/qquickflickable_p.h2
-rw-r--r--src/quick/items/qquickgridview.cpp13
-rw-r--r--src/quick/items/qquickimage.cpp53
-rw-r--r--src/quick/items/qquickimage_p_p.h18
-rw-r--r--src/quick/items/qquickitem.cpp2
-rw-r--r--src/quick/items/qquickitemsmodule.cpp4
-rw-r--r--src/quick/items/qquickitemview.cpp7
-rw-r--r--src/quick/items/qquickitemview_p.h1
-rw-r--r--src/quick/items/qquickitemviewfxitem.cpp2
-rw-r--r--src/quick/items/qquickitemviewfxitem_p_p.h8
-rw-r--r--src/quick/items/qquicklistview.cpp14
-rw-r--r--src/quick/items/qquickopenglshadereffect.cpp17
-rw-r--r--src/quick/items/qquickpathview.cpp27
-rw-r--r--src/quick/items/qquickpathview_p.h1
-rw-r--r--src/quick/items/qquickrectangle_p_p.h2
-rw-r--r--src/quick/items/qquicktableview.cpp920
-rw-r--r--src/quick/items/qquicktableview_p.h9
-rw-r--r--src/quick/items/qquicktableview_p_p.h133
-rw-r--r--src/quick/items/qquicktext.cpp7
-rw-r--r--src/quick/items/qquicktextcontrol.cpp2
-rw-r--r--src/quick/items/qquicktextedit.cpp9
-rw-r--r--src/quick/items/qquicktextinput.cpp4
-rw-r--r--src/quick/items/qquicktextnodeengine.cpp6
-rw-r--r--src/quick/items/qquickwindow.cpp64
-rw-r--r--src/quick/items/qquickwindowmodule.cpp6
-rw-r--r--src/quick/quick.pro1
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp3
-rw-r--r--src/quick/scenegraph/coreapi/qsgnode.h2
-rw-r--r--src/quick/scenegraph/qsgdefaultcontext.cpp10
-rw-r--r--src/quick/scenegraph/util/qsgimagenode.h2
-rw-r--r--src/quick/scenegraph/util/qsgninepatchnode.h2
-rw-r--r--src/quick/scenegraph/util/qsgrectanglenode.h2
-rw-r--r--src/quick/scenegraph/util/qsgtexture.cpp79
-rw-r--r--src/quick/scenegraph/util/qsgtexturematerial_p.h2
-rw-r--r--src/quick/util/qquickbehavior.cpp24
-rw-r--r--src/quick/util/qquickbehavior_p.h4
-rw-r--r--src/quick/util/qquickfontmetrics.cpp2
-rw-r--r--src/quick/util/qquickpixmapcache.cpp15
-rw-r--r--src/quick/util/qquickpropertychanges.cpp3
-rw-r--r--src/quick/util/qquickstyledtext.cpp2
-rw-r--r--src/quick/util/qquicktextmetrics.cpp2
-rw-r--r--src/quick/util/qquickutilmodule.cpp2
-rw-r--r--tests/auto/particles/shared/particlestestsshared.h11
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro3
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp902
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro2
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp30
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro1
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp157
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro1
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp2
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp19
-rw-r--r--tests/auto/qml/debugger/shared/qqmldebugprocess.cpp2
-rw-r--r--tests/auto/qml/debugger/shared/qqmlenginedebugclient.h233
-rw-r--r--tests/auto/qml/debugger/shared/qqmlenginedebugclient.pri3
-rw-r--r--tests/auto/qml/debugger/shared/qqmlinspectorclient.pri3
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp26
-rw-r--r--tests/auto/qml/qjsvalue/tst_qjsvalue.cpp2
-rw-r--r--tests/auto/qml/qml.pro4
-rw-r--r--tests/auto/qml/qmlcachegen/data/Retain.qml2
-rw-r--r--tests/auto/qml/qmlcachegen/qmlcachegen.pro5
-rw-r--r--tests/auto/qml/qmlcachegen/retain.qrc5
-rw-r--r--tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp8
-rw-r--r--tests/auto/qml/qqmlconsole/data/logging.qml2
-rw-r--r--tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp15
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qmlVarNullBinding.qml7
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.h2
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp15
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignComponentToWrongType.errors.txt1
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignComponentToWrongType.qml9
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp2
-rw-r--r--tests/auto/qml/qqmlparser/tst_qqmlparser.cpp10
-rw-r--r--tests/auto/qml/qqmlpropertycache/data/foreignEnums.qml6
-rw-r--r--tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp26
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/changeVersion.qml67
-rw-r--r--tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp17
-rw-r--r--tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp43
-rw-r--r--tests/auto/qml/qv4assembler/data/crash.qml53
-rw-r--r--tests/auto/qml/qv4assembler/qv4assembler.pro5
-rw-r--r--tests/auto/qml/qv4assembler/tst_qv4assembler.cpp54
-rw-r--r--tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp4
-rw-r--r--tests/auto/qml/v4traced/tst_v4traced.cpp325
-rw-r--r--tests/auto/qml/v4traced/v4traced.pro5
-rw-r--r--tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp2
-rw-r--r--tests/auto/quick/qquickanimatedsprite/qquickanimatedsprite.pro2
-rw-r--r--tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp5
-rw-r--r--tests/auto/quick/qquickanimations/tst_qquickanimations.cpp2
-rw-r--r--tests/auto/quick/qquickbehaviors/data/ItemWithInnerBehavior.qml1
-rw-r--r--tests/auto/quick/qquickbehaviors/data/aliased.qml1
-rw-r--r--tests/auto/quick/qquickbehaviors/data/oneway.qml20
-rw-r--r--tests/auto/quick/qquickbehaviors/qquickbehaviors.pro2
-rw-r--r--tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp49
-rw-r--r--tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp117
-rw-r--r--tests/auto/quick/qquickfontmetrics/tst_quickfontmetrics.cpp2
-rw-r--r--tests/auto/quick/qquickgridview/qquickgridview.pro2
-rw-r--r--tests/auto/quick/qquickgridview/tst_qquickgridview.cpp123
-rw-r--r--tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp13
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-itematindex.qml15
-rw-r--r--tests/auto/quick/qquicklistview/qquicklistview.pro3
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp266
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp10
-rw-r--r--tests/auto/quick/qquickpathview/qquickpathview.pro2
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp7
-rw-r--r--tests/auto/quick/qquickpositioners/qquickpositioners.pro2
-rw-r--r--tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp11
-rw-r--r--tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp2
-rw-r--r--tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp16
-rw-r--r--tests/auto/quick/qquicktableview/data/hiderowsandcolumns.qml85
-rw-r--r--tests/auto/quick/qquicktableview/data/usefaultyrowcolumnprovider.qml6
-rw-r--r--tests/auto/quick/qquicktableview/data/userowcolumnprovider.qml14
-rw-r--r--tests/auto/quick/qquicktableview/qquicktableview.pro1
-rw-r--r--tests/auto/quick/qquicktableview/tst_qquicktableview.cpp349
-rw-r--r--tests/auto/quick/qquicktext/qquicktext.pro2
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp157
-rw-r--r--tests/auto/quick/qquicktextedit/data/keys_shortcutoverride.qml34
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp60
-rw-r--r--tests/auto/quick/shared/viewtestutil.cpp3
-rw-r--r--tests/auto/quick/shared/viewtestutil.h4
-rw-r--r--tests/auto/quick/shared/visualtestutil.h3
-rw-r--r--tests/auto/quicktest/polish-qml/data/tst_polish.qml (renamed from tests/auto/qml/debugger/shared/qqmlinspectorclient.h)51
-rw-r--r--tests/auto/quicktest/polish-qml/polish-qml.pro12
-rw-r--r--tests/auto/quicktest/polish-qml/tst_polish-qml.cpp84
-rw-r--r--tests/auto/quicktest/polish/data/polish.qml32
-rw-r--r--tests/auto/quicktest/polish/polish.pro12
-rw-r--r--tests/auto/quicktest/polish/tst_polish.cpp88
-rw-r--r--tests/auto/quicktest/quicktest.pro1
-rw-r--r--tests/manual/scenegraph_lancelot/data/text/text_wrap_elide_maxlines.qml133
-rw-r--r--tools/qml/main.cpp79
-rw-r--r--tools/qmlcachegen/generateloader.cpp20
-rw-r--r--tools/qmlcachegen/qmlcachegen.cpp18
-rw-r--r--tools/qmlcachegen/qtquickcompiler.prf23
-rw-r--r--tools/qmleasing/mainwindow.cpp2
-rw-r--r--tools/qmleasing/segmentproperties.cpp2
-rw-r--r--tools/qmleasing/splineeditor.cpp2
-rw-r--r--tools/qmlimportscanner/main.cpp21
-rw-r--r--tools/qmlplugindump/main.cpp7
-rw-r--r--tools/qmlpreview/qmlpreviewapplication.cpp28
-rw-r--r--tools/qmlpreview/qmlpreviewapplication.h4
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.cpp62
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.h4
-rw-r--r--tools/qmlscene/main.cpp4
-rw-r--r--tools/tools.pro10
311 files changed, 7448 insertions, 3718 deletions
diff --git a/.qmake.conf b/.qmake.conf
index a3c853d760..7b49e2c3f9 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1,4 +1,4 @@
load(qt_build_config)
CONFIG += warning_clean
-MODULE_VERSION = 5.12.3
+MODULE_VERSION = 5.13.0
diff --git a/src/3rdparty/masm/assembler/LinkBuffer.h b/src/3rdparty/masm/assembler/LinkBuffer.h
index c79b0663c8..4dfd051797 100644
--- a/src/3rdparty/masm/assembler/LinkBuffer.h
+++ b/src/3rdparty/masm/assembler/LinkBuffer.h
@@ -228,6 +228,8 @@ public:
return m_size;
}
+ inline void makeExecutable();
+
private:
template <typename T> T applyOffset(T src)
{
@@ -353,6 +355,11 @@ inline void LinkBufferBase<MacroAssembler, ExecutableOffsetCalculator>::performF
ASSERT(m_size <= INT_MAX);
MacroAssembler::cacheFlush(code(), m_size);
+}
+
+template <typename MacroAssembler, template <typename T> class ExecutableOffsetCalculator>
+inline void LinkBufferBase<MacroAssembler, ExecutableOffsetCalculator>::makeExecutable()
+{
ExecutableAllocator::makeExecutable(code(), static_cast<int>(m_size));
}
@@ -389,6 +396,7 @@ public:
}
inline void performFinalization();
+ inline void makeExecutable();
inline void linkCode(void* ownerUID, JITCompilationEffort);
@@ -421,6 +429,11 @@ inline void BranchCompactingLinkBuffer<MacroAssembler>::performFinalization()
#endif
MacroAssembler::cacheFlush(code(), m_size);
+}
+
+template <typename MacroAssembler>
+inline void BranchCompactingLinkBuffer<MacroAssembler>::makeExecutable()
+{
ExecutableAllocator::makeExecutable(code(), m_initialSize);
}
diff --git a/src/3rdparty/masm/stubs/ExecutableAllocator.h b/src/3rdparty/masm/stubs/ExecutableAllocator.h
index 156b24b4e8..a439c53827 100644
--- a/src/3rdparty/masm/stubs/ExecutableAllocator.h
+++ b/src/3rdparty/masm/stubs/ExecutableAllocator.h
@@ -82,6 +82,7 @@ struct ExecutableMemoryHandle : public RefCounted<ExecutableMemoryHandle> {
inline bool isManaged() const { return true; }
+ void *exceptionHandler() { return m_allocation->exceptionHandler(); }
void *start() { return m_allocation->start(); }
size_t sizeInBytes() { return m_size; }
diff --git a/src/3rdparty/masm/yarr/YarrJIT.cpp b/src/3rdparty/masm/yarr/YarrJIT.cpp
index dee2ade407..da65b772f7 100644
--- a/src/3rdparty/masm/yarr/YarrJIT.cpp
+++ b/src/3rdparty/masm/yarr/YarrJIT.cpp
@@ -33,6 +33,8 @@
#include "Yarr.h"
#include "YarrCanonicalize.h"
+#include <private/qv4functiontable_p.h>
+
#if ENABLE(YARR_JIT)
using namespace WTF;
@@ -3529,17 +3531,30 @@ public:
m_backtrackingState.linkDataLabels(linkBuffer);
+ CodeRef codeRef;
if (compileMode == MatchOnly) {
- if (m_charSize == Char8)
- codeBlock.set8BitCodeMatchOnly(FINALIZE_CODE(linkBuffer, "YarrJIT", "Match-only 8-bit regular expression"));
- else
- codeBlock.set16BitCodeMatchOnly(FINALIZE_CODE(linkBuffer, "YarrJIT", "Match-only 16-bit regular expression"));
+ if (m_charSize == Char8) {
+ codeRef = FINALIZE_CODE(linkBuffer, "YarrJIT",
+ "Match-only 8-bit regular expression");
+ codeBlock.set8BitCodeMatchOnly(codeRef);
+ } else {
+ codeRef = FINALIZE_CODE(linkBuffer, "YarrJIT",
+ "Match-only 16-bit regular expression");
+ codeBlock.set16BitCodeMatchOnly(codeRef);
+ }
} else {
- if (m_charSize == Char8)
- codeBlock.set8BitCode(FINALIZE_CODE(linkBuffer, "YarrJIT", "8-bit regular expression"));
- else
- codeBlock.set16BitCode(FINALIZE_CODE(linkBuffer, "YarrJIT", "16-bit regular expression"));
+ if (m_charSize == Char8) {
+ codeRef = FINALIZE_CODE(linkBuffer, "YarrJIT", "8-bit regular expression");
+ codeBlock.set8BitCode(codeRef);
+ } else {
+ codeRef = FINALIZE_CODE(linkBuffer, "YarrJIT", "16-bit regular expression");
+ codeBlock.set16BitCode(codeRef);
+ }
}
+ QV4::generateFunctionTable(nullptr, &codeRef);
+
+ linkBuffer.makeExecutable();
+
if (m_failureReason)
codeBlock.setFallBackWithFailureReason(*m_failureReason);
}
@@ -3587,6 +3602,15 @@ private:
BacktrackingState m_backtrackingState;
};
+void YarrCodeBlock::replaceCodeRef(MacroAssemblerCodeRef &target,
+ const MacroAssemblerCodeRef &source)
+{
+ if (!!target && target.code().executableAddress() != source.code().executableAddress())
+ QV4::destroyFunctionTable(nullptr, &target);
+
+ target = source;
+}
+
static void dumpCompileFailure(JITFailureReason failure)
{
switch (failure) {
diff --git a/src/3rdparty/masm/yarr/YarrJIT.h b/src/3rdparty/masm/yarr/YarrJIT.h
index 8b6b3a7577..35a0690f6e 100644
--- a/src/3rdparty/masm/yarr/YarrJIT.h
+++ b/src/3rdparty/masm/yarr/YarrJIT.h
@@ -82,19 +82,28 @@ class YarrCodeBlock {
public:
YarrCodeBlock() = default;
+ ~YarrCodeBlock() { clear(); }
+
+ static void replaceCodeRef(MacroAssemblerCodeRef &target, const MacroAssemblerCodeRef &source);
void setFallBackWithFailureReason(JITFailureReason failureReason) { m_failureReason = failureReason; }
std::optional<JITFailureReason> failureReason() { return m_failureReason; }
bool has8BitCode() { return m_ref8.size(); }
bool has16BitCode() { return m_ref16.size(); }
- void set8BitCode(MacroAssemblerCodeRef ref) { m_ref8 = ref; }
- void set16BitCode(MacroAssemblerCodeRef ref) { m_ref16 = ref; }
+ void set8BitCode(MacroAssemblerCodeRef ref) { replaceCodeRef(m_ref8, ref); }
+ void set16BitCode(MacroAssemblerCodeRef ref) { replaceCodeRef(m_ref16, ref); }
bool has8BitCodeMatchOnly() { return m_matchOnly8.size(); }
bool has16BitCodeMatchOnly() { return m_matchOnly16.size(); }
- void set8BitCodeMatchOnly(MacroAssemblerCodeRef matchOnly) { m_matchOnly8 = matchOnly; }
- void set16BitCodeMatchOnly(MacroAssemblerCodeRef matchOnly) { m_matchOnly16 = matchOnly; }
+ void set8BitCodeMatchOnly(MacroAssemblerCodeRef matchOnly)
+ {
+ replaceCodeRef(m_matchOnly8, matchOnly);
+ }
+ void set16BitCodeMatchOnly(MacroAssemblerCodeRef matchOnly)
+ {
+ replaceCodeRef(m_matchOnly16, matchOnly);
+ }
#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
bool usesPatternContextBuffer() { return m_usesPatternContextBuffer; }
@@ -190,10 +199,10 @@ public:
void clear()
{
- m_ref8 = MacroAssemblerCodeRef();
- m_ref16 = MacroAssemblerCodeRef();
- m_matchOnly8 = MacroAssemblerCodeRef();
- m_matchOnly16 = MacroAssemblerCodeRef();
+ replaceCodeRef(m_ref8, MacroAssemblerCodeRef());
+ replaceCodeRef(m_ref16, MacroAssemblerCodeRef());
+ replaceCodeRef(m_matchOnly8, MacroAssemblerCodeRef());
+ replaceCodeRef(m_matchOnly16, MacroAssemblerCodeRef());
m_failureReason = std::nullopt;
}
diff --git a/src/3rdparty/masm/yarr/YarrPattern.h b/src/3rdparty/masm/yarr/YarrPattern.h
index 59decbac46..f7ddf861ba 100644
--- a/src/3rdparty/masm/yarr/YarrPattern.h
+++ b/src/3rdparty/masm/yarr/YarrPattern.h
@@ -31,6 +31,7 @@
#include "YarrUnicodeProperties.h"
#include <wtf/CheckedArithmetic.h>
#include <wtf/HashMap.h>
+#include <wtf/Optional.h>
#include <wtf/PrintStream.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
diff --git a/src/imports/builtins/builtins.qmltypes b/src/imports/builtins/builtins.qmltypes
index f2179aaf7a..4ad103f8de 100644
--- a/src/imports/builtins/builtins.qmltypes
+++ b/src/imports/builtins/builtins.qmltypes
@@ -1493,10 +1493,10 @@ Module {
"WhatsThisRole": 5,
"FontRole": 6,
"TextAlignmentRole": 7,
- "BackgroundColorRole": 8,
"BackgroundRole": 8,
- "TextColorRole": 9,
"ForegroundRole": 9,
+ "BackgroundColorRole": 8,
+ "TextColorRole": 9,
"CheckStateRole": 10,
"AccessibleTextRole": 11,
"AccessibleDescriptionRole": 12,
diff --git a/src/imports/folderlistmodel/plugins.qmltypes b/src/imports/folderlistmodel/plugins.qmltypes
index fd92ab9960..6f5466dbda 100644
--- a/src/imports/folderlistmodel/plugins.qmltypes
+++ b/src/imports/folderlistmodel/plugins.qmltypes
@@ -4,10 +4,10 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable Qt.labs.folderlistmodel 2.12'
+// 'qmlplugindump -nonrelocatable Qt.labs.folderlistmodel 2.13'
Module {
- dependencies: ["QtQuick 2.12"]
+ dependencies: ["QtQuick 2.0"]
Component {
name: "QQuickFolderListModel"
prototype: "QAbstractListModel"
diff --git a/src/imports/layouts/plugins.qmltypes b/src/imports/layouts/plugins.qmltypes
index f8d7b9acfe..22e8d79ece 100644
--- a/src/imports/layouts/plugins.qmltypes
+++ b/src/imports/layouts/plugins.qmltypes
@@ -4,10 +4,10 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtQuick.Layouts 1.12'
+// 'qmlplugindump -nonrelocatable QtQuick.Layouts 1.13'
Module {
- dependencies: ["QtQuick 2.12"]
+ dependencies: ["QtQuick 2.0"]
Component {
name: "QQuickColumnLayout"
defaultProperty: "data"
diff --git a/src/imports/layouts/qquickstacklayout.cpp b/src/imports/layouts/qquickstacklayout.cpp
index 0b51d79bef..116e162aa9 100644
--- a/src/imports/layouts/qquickstacklayout.cpp
+++ b/src/imports/layouts/qquickstacklayout.cpp
@@ -97,6 +97,8 @@
\sa StackView
*/
+QT_BEGIN_NAMESPACE
+
QQuickStackLayout::QQuickStackLayout(QQuickItem *parent) :
QQuickLayout(*new QQuickStackLayoutPrivate, parent)
{
@@ -345,4 +347,6 @@ bool QQuickStackLayout::shouldIgnoreItem(QQuickItem *item) const
return ignored;
}
+QT_END_NAMESPACE
+
#include "moc_qquickstacklayout_p.cpp"
diff --git a/src/imports/layouts/qquickstacklayout_p.h b/src/imports/layouts/qquickstacklayout_p.h
index 8ba41720aa..46181c6f50 100644
--- a/src/imports/layouts/qquickstacklayout_p.h
+++ b/src/imports/layouts/qquickstacklayout_p.h
@@ -42,6 +42,8 @@
#include <qquicklayout_p.h>
+QT_BEGIN_NAMESPACE
+
class QQuickStackLayoutPrivate;
class QQuickStackLayout : public QQuickLayout
@@ -105,4 +107,6 @@ private:
bool explicitCurrentIndex;
};
+QT_END_NAMESPACE
+
#endif // QQUICKSTACKLAYOUT_H
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
index e7e8d130bb..3c34d8e45a 100644
--- a/src/imports/localstorage/plugin.cpp
+++ b/src/imports/localstorage/plugin.cpp
@@ -399,23 +399,23 @@ static ReturnedValue qmlsqldatabase_changeVersion(const FunctionObject *b, const
if (from_version != *r->d()->version)
V4THROW_SQL(SQLEXCEPTION_VERSION_ERR, QQmlEngine::tr("Version mismatch: expected %1, found %2").arg(from_version).arg(*r->d()->version));
- Scoped<QQmlSqlDatabaseWrapper> w(scope, QQmlSqlDatabaseWrapper::create(scope.engine));
- ScopedObject p(scope, databaseData(scope.engine)->queryProto.value());
- w->setPrototypeUnchecked(p.getPointer());
- w->d()->type = Heap::QQmlSqlDatabaseWrapper::Query;
- *w->d()->database = db;
- *w->d()->version = *r->d()->version;
-
bool ok = true;
if (!!callback) {
+ Scoped<QQmlSqlDatabaseWrapper> query(scope, QQmlSqlDatabaseWrapper::create(scope.engine));
+ ScopedObject p(scope, databaseData(scope.engine)->queryProto.value());
+ query->setPrototypeUnchecked(p.getPointer());
+ query->d()->type = Heap::QQmlSqlDatabaseWrapper::Query;
+ *query->d()->database = db;
+ *query->d()->version = *r->d()->version;
+
ok = false;
db.transaction();
JSCallData jsCall(scope, 1);
*jsCall->thisObject = scope.engine->globalObject;
- jsCall->args[0] = w;
+ jsCall->args[0] = query;
- TransactionRollback rollbackOnException(&db, &w->d()->inTransaction);
+ TransactionRollback rollbackOnException(&db, &query->d()->inTransaction);
callback->call(jsCall);
rollbackOnException.clear();
if (!db.commit()) {
@@ -427,12 +427,18 @@ static ReturnedValue qmlsqldatabase_changeVersion(const FunctionObject *b, const
}
if (ok) {
+ Scoped<QQmlSqlDatabaseWrapper> w(scope, QQmlSqlDatabaseWrapper::create(scope.engine));
+ ScopedObject p(scope, databaseData(scope.engine)->databaseProto.value());
+ w->setPrototypeUnchecked(p.getPointer());
+ w->d()->type = Heap::QQmlSqlDatabaseWrapper::Database;
+ *w->d()->database = db;
*w->d()->version = to_version;
#if QT_CONFIG(settings)
const QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(scope.engine->qmlEngine());
QSettings ini(enginePrivate->offlineStorageDatabaseDirectory() + db.connectionName() + QLatin1String(".ini"), QSettings::IniFormat);
ini.setValue(QLatin1String("Version"), to_version);
#endif
+ RETURN_RESULT(w.asReturnedValue());
}
RETURN_UNDEFINED();
@@ -599,7 +605,8 @@ This data can be used by application tools.
\section3 db.changeVersion(from, to, callback(tx))
-This method allows you to perform a \e{Scheme Upgrade}.
+This method allows you to perform a \e{Scheme Upgrade}. If it succeeds it returns a new
+database object of version \e to. Otherwise it returns \e undefined.
If the current version of \e db is not \e from, then an exception is thrown.
diff --git a/src/imports/localstorage/plugins.qmltypes b/src/imports/localstorage/plugins.qmltypes
index 59944328d6..3c8c1404f2 100644
--- a/src/imports/localstorage/plugins.qmltypes
+++ b/src/imports/localstorage/plugins.qmltypes
@@ -4,7 +4,7 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtQuick.LocalStorage 2.12'
+// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtQuick.LocalStorage 2.13'
Module {
dependencies: []
diff --git a/src/imports/models/plugins.qmltypes b/src/imports/models/plugins.qmltypes
index 87ec0fee76..6e112c41b6 100644
--- a/src/imports/models/plugins.qmltypes
+++ b/src/imports/models/plugins.qmltypes
@@ -4,7 +4,7 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtQml.Models 2.12'
+// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtQml.Models 2.13'
Module {
dependencies: []
diff --git a/src/imports/particles/plugins.qmltypes b/src/imports/particles/plugins.qmltypes
index b68be6c5da..b6db00e683 100644
--- a/src/imports/particles/plugins.qmltypes
+++ b/src/imports/particles/plugins.qmltypes
@@ -4,10 +4,10 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtQuick.Particles 2.12'
+// 'qmlplugindump -nonrelocatable QtQuick.Particles 2.13'
Module {
- dependencies: ["QtQuick 2.12"]
+ dependencies: ["QtQuick 2.0"]
Component {
name: "QQuickAgeAffector"
defaultProperty: "data"
diff --git a/src/imports/qtqml/plugins.qmltypes b/src/imports/qtqml/plugins.qmltypes
index 1ffe4a78ca..d548a78dd0 100644
--- a/src/imports/qtqml/plugins.qmltypes
+++ b/src/imports/qtqml/plugins.qmltypes
@@ -4,7 +4,7 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable -noforceqtquick QtQml 2.12'
+// 'qmlplugindump -nonrelocatable -noforceqtquick QtQml 2.13'
Module {
dependencies: []
diff --git a/src/imports/qtquick2/plugins.qmltypes b/src/imports/qtquick2/plugins.qmltypes
index 035c13a4d3..f006c874da 100644
--- a/src/imports/qtquick2/plugins.qmltypes
+++ b/src/imports/qtquick2/plugins.qmltypes
@@ -4,7 +4,7 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtQuick 2.12'
+// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtQuick 2.13'
Module {
dependencies: []
@@ -1234,10 +1234,11 @@ Module {
name: "QQuickBehavior"
defaultProperty: "animation"
prototype: "QObject"
- exports: ["QtQuick/Behavior 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: ["QtQuick/Behavior 2.0", "QtQuick/Behavior 2.13"]
+ exportMetaObjectRevisions: [0, 13]
Property { name: "animation"; type: "QQuickAbstractAnimation"; isPointer: true }
Property { name: "enabled"; type: "bool" }
+ Property { name: "targetValue"; revision: 13; type: "QVariant"; isReadonly: true }
}
Component {
name: "QQuickBorderImage"
@@ -2083,9 +2084,10 @@ Module {
exports: [
"QtQuick/GridView 2.0",
"QtQuick/GridView 2.1",
+ "QtQuick/GridView 2.13",
"QtQuick/GridView 2.7"
]
- exportMetaObjectRevisions: [0, 1, 7]
+ exportMetaObjectRevisions: [0, 1, 13, 7]
attachedType: "QQuickGridViewAttached"
Enum {
name: "Flow"
@@ -2495,11 +2497,12 @@ Module {
prototype: "QQuickFlickable"
exports: [
"QtQuick/ItemView 2.1",
+ "QtQuick/ItemView 2.13",
"QtQuick/ItemView 2.3",
"QtQuick/ItemView 2.7"
]
isCreatable: false
- exportMetaObjectRevisions: [1, 2, 7]
+ exportMetaObjectRevisions: [1, 13, 2, 7]
Enum {
name: "LayoutDirection"
values: {
@@ -2593,6 +2596,12 @@ Module {
Parameter { name: "x"; type: "double" }
Parameter { name: "y"; type: "double" }
}
+ Method {
+ name: "itemAtIndex"
+ revision: 13
+ type: "QQuickItem*"
+ Parameter { name: "index"; type: "int" }
+ }
Method { name: "positionViewAtBeginning" }
Method { name: "positionViewAtEnd" }
Method { name: "forceLayout"; revision: 1 }
@@ -3340,8 +3349,12 @@ Module {
name: "QQuickPathView"
defaultProperty: "data"
prototype: "QQuickItem"
- exports: ["QtQuick/PathView 2.0", "QtQuick/PathView 2.7"]
- exportMetaObjectRevisions: [0, 7]
+ exports: [
+ "QtQuick/PathView 2.0",
+ "QtQuick/PathView 2.13",
+ "QtQuick/PathView 2.7"
+ ]
+ exportMetaObjectRevisions: [0, 13, 7]
attachedType: "QQuickPathViewAttached"
Enum {
name: "HighlightRangeMode"
@@ -3428,6 +3441,12 @@ Module {
Parameter { name: "x"; type: "double" }
Parameter { name: "y"; type: "double" }
}
+ Method {
+ name: "itemAtIndex"
+ revision: 13
+ type: "QQuickItem*"
+ Parameter { name: "index"; type: "int" }
+ }
}
Component {
name: "QQuickPathViewAttached"
diff --git a/src/imports/settings/plugins.qmltypes b/src/imports/settings/plugins.qmltypes
index d6cd1c6635..bbc5c1cf8f 100644
--- a/src/imports/settings/plugins.qmltypes
+++ b/src/imports/settings/plugins.qmltypes
@@ -31,5 +31,6 @@ Module {
Parameter { name: "key"; type: "string" }
Parameter { name: "value"; type: "QVariant" }
}
+ Method { name: "sync" }
}
}
diff --git a/src/imports/settings/qqmlsettings.cpp b/src/imports/settings/qqmlsettings.cpp
index f7a7d8b055..287a70363a 100644
--- a/src/imports/settings/qqmlsettings.cpp
+++ b/src/imports/settings/qqmlsettings.cpp
@@ -487,6 +487,25 @@ void QQmlSettings::setValue(const QString &key, const QVariant &value)
qCDebug(lcSettings) << "QQmlSettings: setValue" << key << ":" << value;
}
+/*!
+ \qmlmethod Settings::sync()
+
+ Writes any unsaved changes to permanent storage, and reloads any
+ settings that have been changed in the meantime by another
+ application.
+
+ This function is called automatically from QSettings's destructor and
+ by the event loop at regular intervals, so you normally don't need to
+ call it yourself.
+
+ \sa QSettings::sync
+*/
+void QQmlSettings::sync()
+{
+ Q_D(QQmlSettings);
+ d->instance()->sync();
+}
+
void QQmlSettings::classBegin()
{
}
diff --git a/src/imports/settings/qqmlsettings_p.h b/src/imports/settings/qqmlsettings_p.h
index f9122a58f7..a86c8b4751 100644
--- a/src/imports/settings/qqmlsettings_p.h
+++ b/src/imports/settings/qqmlsettings_p.h
@@ -79,6 +79,7 @@ public:
Q_INVOKABLE QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const;
Q_INVOKABLE void setValue(const QString &key, const QVariant &value);
+ Q_INVOKABLE void sync();
protected:
void timerEvent(QTimerEvent *event) override;
diff --git a/src/imports/shapes/plugins.qmltypes b/src/imports/shapes/plugins.qmltypes
index a851b20ed2..b78c5a1130 100644
--- a/src/imports/shapes/plugins.qmltypes
+++ b/src/imports/shapes/plugins.qmltypes
@@ -4,10 +4,10 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtQuick.Shapes 1.12'
+// 'qmlplugindump -nonrelocatable QtQuick.Shapes 1.13'
Module {
- dependencies: ["QtQuick 2.12"]
+ dependencies: ["QtQuick 2.0"]
Component {
name: "QQuickShape"
defaultProperty: "data"
diff --git a/src/imports/sharedimage/plugins.qmltypes b/src/imports/sharedimage/plugins.qmltypes
index 504186936b..29639e7697 100644
--- a/src/imports/sharedimage/plugins.qmltypes
+++ b/src/imports/sharedimage/plugins.qmltypes
@@ -7,5 +7,5 @@ import QtQuick.tooling 1.2
// 'qmlplugindump -nonrelocatable Qt.labs.sharedimage 1.0'
Module {
- dependencies: ["QtQuick 2.12"]
+ dependencies: ["QtQuick 2.0"]
}
diff --git a/src/imports/statemachine/plugins.qmltypes b/src/imports/statemachine/plugins.qmltypes
index 001efd3847..f92aeaa080 100644
--- a/src/imports/statemachine/plugins.qmltypes
+++ b/src/imports/statemachine/plugins.qmltypes
@@ -4,7 +4,7 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtQml.StateMachine 1.12'
+// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtQml.StateMachine 1.13'
Module {
dependencies: []
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml
index 1e06f604d5..e7669fd03d 100644
--- a/src/imports/testlib/TestCase.qml
+++ b/src/imports/testlib/TestCase.qml
@@ -521,6 +521,75 @@ Item {
}
/*!
+ \since 5.13
+ \qmlmethod bool TestCase::isPolishScheduled(object item)
+
+ Returns \c true if \l {QQuickItem::}{updatePolish()} has not been called
+ on \a item since the last call to \l {QQuickItem::}{polish()},
+ otherwise returns \c false.
+
+ When assigning values to properties in QML, any layouting the item
+ must do as a result of the assignment might not take effect immediately,
+ but can instead be postponed until the item is polished. For these cases,
+ you can use this function to ensure that the item has been polished
+ before the execution of the test continues. For example:
+
+ \code
+ verify(isPolishScheduled(item))
+ verify(waitForItemPolished(item))
+ \endcode
+
+ Without the call to \c isPolishScheduled() above, the
+ call to \c waitForItemPolished() might see that no polish
+ was scheduled and therefore pass instantly, assuming that
+ the item had already been polished. This function
+ makes it obvious why an item wasn't polished and allows tests to
+ fail early under such circumstances.
+
+ \sa waitForItemPolished(), QQuickItem::polish(), QQuickItem::updatePolish()
+ */
+ function isPolishScheduled(item) {
+ if (!item || typeof item !== "object") {
+ qtest_results.fail("Argument must be a valid Item; actual type is " + typeof item,
+ util.callerFile(), util.callerLine())
+ throw new Error("QtQuickTest::fail")
+ }
+
+ return qtest_results.isPolishScheduled(item)
+ }
+
+ /*!
+ \since 5.13
+ \qmlmethod bool waitForItemPolished(object item, int timeout = 5000)
+
+ Waits for \a timeout milliseconds or until
+ \l {QQuickItem::}{updatePolish()} has been called on \a item.
+
+ Returns \c true if \c updatePolish() was called on \a item within
+ \a timeout milliseconds, otherwise returns \c false.
+
+ \sa isPolishScheduled(), QQuickItem::polish(), QQuickItem::updatePolish()
+ */
+ function waitForItemPolished(item, timeout) {
+ if (!item || typeof item !== "object") {
+ qtest_results.fail("First argument must be a valid Item; actual type is " + typeof item,
+ util.callerFile(), util.callerLine())
+ throw new Error("QtQuickTest::fail")
+ }
+
+ if (timeout !== undefined && typeof(timeout) != "number") {
+ qtest_results.fail("Second argument must be a number; actual type is " + typeof timeout,
+ util.callerFile(), util.callerLine())
+ throw new Error("QtQuickTest::fail")
+ }
+
+ if (!timeout)
+ timeout = 5000
+
+ return qtest_results.waitForItemPolished(item, timeout)
+ }
+
+ /*!
\since 5.9
\qmlmethod object TestCase::createTemporaryQmlObject(string qml, object parent, string filePath)
@@ -850,12 +919,12 @@ Item {
Additionally, the returned image object has the following methods:
\list
- \li red(x, y) Returns the red channel value of the pixel at \a x, \a y position
- \li green(x, y) Returns the green channel value of the pixel at \a x, \a y position
- \li blue(x, y) Returns the blue channel value of the pixel at \a x, \a y position
- \li alpha(x, y) Returns the alpha channel value of the pixel at \a x, \a y position
- \li pixel(x, y) Returns the color value of the pixel at \a x, \a y position
- \li equals(image) Returns \c true if this image is identical to \a image -
+ \li \c {red(x, y)} Returns the red channel value of the pixel at \e x, \e y position
+ \li \c {green(x, y)} Returns the green channel value of the pixel at \e x, \e y position
+ \li \c {blue(x, y)} Returns the blue channel value of the pixel at \e x, \e y position
+ \li \c {alpha(x, y)} Returns the alpha channel value of the pixel at \e x, \e y position
+ \li \c {pixel(x, y)} Returns the color value of the pixel at \e x, \e y position
+ \li \c {equals(image)} Returns \c true if this image is identical to \e image -
see \l QImage::operator== (since 5.6)
For example:
@@ -869,7 +938,8 @@ Item {
var newImage = grabImage(rect);
verify(!newImage.equals(image));
\endcode
- \li save(path) Saves the image to the given \a path. If the image cannot
+
+ \li \c {save(path)} Saves the image to the given \e path. If the image cannot
be saved, an exception will be thrown. (since 5.10)
This can be useful to perform postmortem analysis on failing tests, for
@@ -886,8 +956,6 @@ Item {
\endcode
\endlist
-
- \sa
*/
function grabImage(item) {
return qtest_results.grabImage(item);
@@ -1152,7 +1220,7 @@ Item {
/*!
\qmlmethod TestCase::keyPress(key, modifiers = Qt.NoModifier, delay = -1)
- Simulates pressing a \a key with an optional \a modifier on the currently
+ Simulates pressing a \a key with optional \a modifiers on the currently
focused item. If \a delay is larger than 0, the test will wait for
\a delay milliseconds.
@@ -1180,7 +1248,7 @@ Item {
/*!
\qmlmethod TestCase::keyRelease(key, modifiers = Qt.NoModifier, delay = -1)
- Simulates releasing a \a key with an optional \a modifier on the currently
+ Simulates releasing a \a key with optional \a modifiers on the currently
focused item. If \a delay is larger than 0, the test will wait for
\a delay milliseconds.
@@ -1206,7 +1274,7 @@ Item {
/*!
\qmlmethod TestCase::keyClick(key, modifiers = Qt.NoModifier, delay = -1)
- Simulates clicking of \a key with an optional \a modifier on the currently
+ Simulates clicking of \a key with optional \a modifiers on the currently
focused item. If \a delay is larger than 0, the test will wait for
\a delay milliseconds.
@@ -1252,7 +1320,7 @@ Item {
/*!
\qmlmethod TestCase::mousePress(item, x = item.width / 2, y = item.height / 2, button = Qt.LeftButton, modifiers = Qt.NoModifier, delay = -1)
- Simulates pressing a mouse \a button with an optional \a modifier
+ Simulates pressing a mouse \a button with optional \a modifiers
on an \a item. The position is defined by \a x and \a y.
If \a x or \a y are not defined the position will be the center of \a item.
If \a delay is specified, the test will wait for the specified amount of
@@ -1286,7 +1354,7 @@ Item {
/*!
\qmlmethod TestCase::mouseRelease(item, x = item.width / 2, y = item.height / 2, button = Qt.LeftButton, modifiers = Qt.NoModifier, delay = -1)
- Simulates releasing a mouse \a button with an optional \a modifier
+ Simulates releasing a mouse \a button with optional \a modifiers
on an \a item. The position of the release is defined by \a x and \a y.
If \a x or \a y are not defined the position will be the center of \a item.
If \a delay is specified, the test will wait for the specified amount of
@@ -1320,7 +1388,7 @@ Item {
/*!
\qmlmethod TestCase::mouseDrag(item, x, y, dx, dy, button = Qt.LeftButton, modifiers = Qt.NoModifier, delay = -1)
- Simulates dragging the mouse on an \a item with \a button pressed and an optional \a modifier.
+ Simulates dragging the mouse on an \a item with \a button pressed and optional \a modifiers
The initial drag position is defined by \a x and \a y,
and drag distance is defined by \a dx and \a dy. If \a delay is specified,
the test will wait for the specified amount of milliseconds before releasing the button.
@@ -1370,7 +1438,7 @@ Item {
/*!
\qmlmethod TestCase::mouseClick(item, x = item.width / 2, y = item.height / 2, button = Qt.LeftButton, modifiers = Qt.NoModifier, delay = -1)
- Simulates clicking a mouse \a button with an optional \a modifier
+ Simulates clicking a mouse \a button with optional \a modifiers
on an \a item. The position of the click is defined by \a x and \a y.
If \a x and \a y are not defined the position will be the center of \a item.
If \a delay is specified, the test will wait for the specified amount of
@@ -1404,7 +1472,7 @@ Item {
/*!
\qmlmethod TestCase::mouseDoubleClick(item, x = item.width / 2, y = item.height / 2, button = Qt.LeftButton, modifiers = Qt.NoModifier, delay = -1)
- Simulates double-clicking a mouse \a button with an optional \a modifier
+ Simulates double-clicking a mouse \a button with optional \a modifiers
on an \a item. The position of the click is defined by \a x and \a y.
If \a x and \a y are not defined the position will be the center of \a item.
If \a delay is specified, the test will wait for the specified amount of
@@ -1439,7 +1507,7 @@ Item {
\qmlmethod TestCase::mouseDoubleClickSequence(item, x = item.width / 2, y = item.height / 2, button = Qt.LeftButton, modifiers = Qt.NoModifier, delay = -1)
Simulates the full sequence of events generated by double-clicking a mouse
- \a button with an optional \a modifier on an \a item.
+ \a button with optional \a modifiers on an \a item.
This method reproduces the sequence of mouse events generated when a user makes
a double click: Press-Release-Press-DoubleClick-Release.
@@ -1505,7 +1573,7 @@ Item {
/*!
\qmlmethod TestCase::mouseWheel(item, x, y, xDelta, yDelta, button = Qt.LeftButton, modifiers = Qt.NoModifier, delay = -1)
- Simulates rotating the mouse wheel on an \a item with \a button pressed and an optional \a modifier.
+ Simulates rotating the mouse wheel on an \a item with \a button pressed and optional \a modifiers.
The position of the wheel event is defined by \a x and \a y.
If \a delay is specified, the test will wait for the specified amount of milliseconds before releasing the button.
diff --git a/src/imports/testlib/main.cpp b/src/imports/testlib/main.cpp
index af15a44012..c625c87db7 100644
--- a/src/imports/testlib/main.cpp
+++ b/src/imports/testlib/main.cpp
@@ -149,6 +149,7 @@ public:
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtTest"));
qmlRegisterType<QuickTestResult, 0>(uri,1,0,"TestResult");
qmlRegisterType<QuickTestResult, 1>(uri,1,1,"TestResult");
+ qmlRegisterType<QuickTestResult, 13>(uri,1,13,"TestResult");
qmlRegisterType<QuickTestEvent>(uri,1,0,"TestEvent");
qmlRegisterType<QuickTestEvent>(uri,1,2,"TestEvent");
qmlRegisterType<QuickTestUtil>(uri,1,0,"TestUtil");
diff --git a/src/imports/testlib/plugins.qmltypes b/src/imports/testlib/plugins.qmltypes
index e51371d176..1e081d82ff 100644
--- a/src/imports/testlib/plugins.qmltypes
+++ b/src/imports/testlib/plugins.qmltypes
@@ -4,7 +4,7 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtTest 1.12'
+// 'qmlplugindump -nonrelocatable QtTest 1.13'
Module {
dependencies: ["QtQuick 2.0", "QtQuick.Window 2.0"]
@@ -177,8 +177,12 @@ Module {
Component {
name: "QuickTestResult"
prototype: "QObject"
- exports: ["QtTest/TestResult 1.0", "QtTest/TestResult 1.1"]
- exportMetaObjectRevisions: [0, 1]
+ exports: [
+ "QtTest/TestResult 1.0",
+ "QtTest/TestResult 1.1",
+ "QtTest/TestResult 1.13"
+ ]
+ exportMetaObjectRevisions: [0, 1, 13]
Enum {
name: "RunMode"
values: {
@@ -316,6 +320,19 @@ Module {
Parameter { name: "parent"; type: "QObject"; isPointer: true }
Parameter { name: "objectName"; type: "string" }
}
+ Method {
+ name: "isPolishScheduled"
+ revision: 13
+ type: "bool"
+ Parameter { name: "item"; type: "QQuickItem"; isPointer: true }
+ }
+ Method {
+ name: "waitForItemPolished"
+ revision: 13
+ type: "bool"
+ Parameter { name: "item"; type: "QQuickItem"; isPointer: true }
+ Parameter { name: "timeout"; type: "int" }
+ }
}
Component {
name: "QuickTestUtil"
diff --git a/src/imports/testlib/toucheventsequence.qdoc b/src/imports/testlib/toucheventsequence.qdoc
index 92c5836d49..bd3551a669 100644
--- a/src/imports/testlib/toucheventsequence.qdoc
+++ b/src/imports/testlib/toucheventsequence.qdoc
@@ -57,7 +57,7 @@
/*!
\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.
+ Creates a new point identified as \a touchId, at the point indicated by \e x and \e 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().
@@ -67,7 +67,7 @@
/*!
\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.
+ Moves \a touchId to the point indicated by \e x and \e y relative to \a item.
Item defaults to the value provided via touchEvent().
X and y default to the midpoint of the item.
@@ -76,7 +76,7 @@
/*!
\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.
+ Removes \a touchId at the point indicated by \e x and \e y relative to \a item.
Item defaults to the value provided via touchEvent().
X and y default to the midpoint of the item.
diff --git a/src/imports/wavefrontmesh/plugins.qmltypes b/src/imports/wavefrontmesh/plugins.qmltypes
index a0c4e22271..b9dd9e4c46 100644
--- a/src/imports/wavefrontmesh/plugins.qmltypes
+++ b/src/imports/wavefrontmesh/plugins.qmltypes
@@ -4,10 +4,10 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable Qt.labs.wavefrontmesh 1.12'
+// 'qmlplugindump -nonrelocatable Qt.labs.wavefrontmesh 1.13'
Module {
- dependencies: ["QtQuick 2.12"]
+ dependencies: ["QtQuick 2.0"]
Component {
name: "QWavefrontMesh"
prototype: "QQuickShaderEffectMesh"
diff --git a/src/imports/window/plugins.qmltypes b/src/imports/window/plugins.qmltypes
index 79fa40dbb2..b5786ed5a6 100644
--- a/src/imports/window/plugins.qmltypes
+++ b/src/imports/window/plugins.qmltypes
@@ -4,10 +4,10 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtQuick.Window 2.12'
+// 'qmlplugindump -nonrelocatable QtQuick.Window 2.13'
Module {
- dependencies: ["QtQuick 2.12"]
+ dependencies: ["QtQuick 2.0"]
Component {
name: "QQuickRootItem"
defaultProperty: "data"
@@ -160,10 +160,11 @@ Module {
prototype: "QQuickWindow"
exports: [
"QtQuick.Window/Window 2.1",
+ "QtQuick.Window/Window 2.13",
"QtQuick.Window/Window 2.2",
"QtQuick.Window/Window 2.3"
]
- exportMetaObjectRevisions: [0, 1, 2]
+ exportMetaObjectRevisions: [0, 13, 1, 2]
attachedType: "QQuickWindowAttached"
Property { name: "visible"; type: "bool" }
Property { name: "visibility"; type: "Visibility" }
@@ -215,6 +216,7 @@ Module {
Property { name: "visibility"; revision: 1; type: "Visibility" }
Property { name: "contentOrientation"; type: "Qt::ScreenOrientation" }
Property { name: "opacity"; revision: 1; type: "double" }
+ Property { name: "transientParent"; revision: 13; type: "QWindow"; isPointer: true }
Signal {
name: "screenChanged"
Parameter { name: "screen"; type: "QScreen"; isPointer: true }
@@ -287,6 +289,11 @@ Module {
revision: 1
Parameter { name: "opacity"; type: "double" }
}
+ Signal {
+ name: "transientParentChanged"
+ revision: 13
+ Parameter { name: "transientParent"; type: "QWindow"; isPointer: true }
+ }
Method { name: "requestActivate"; revision: 1 }
Method {
name: "setVisible"
diff --git a/src/plugins/scenegraph/openvg/qsgopenvghelpers.cpp b/src/plugins/scenegraph/openvg/qsgopenvghelpers.cpp
index 6bc99d32a1..ab5cfb48b8 100644
--- a/src/plugins/scenegraph/openvg/qsgopenvghelpers.cpp
+++ b/src/plugins/scenegraph/openvg/qsgopenvghelpers.cpp
@@ -220,10 +220,10 @@ void qDrawTiled(VGImage image, const QSize imageSize, const QRectF &targetRect,
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));
+ QMarginsF margins(qMax(innerTargetRect.left() - targetRect.left(), qreal(0.0)),
+ qMax(innerTargetRect.top() - targetRect.top(), qreal(0.0)),
+ qMax(targetRect.right() - innerTargetRect.right(), qreal(0.0)),
+ qMax(targetRect.bottom() - innerTargetRect.bottom(), qreal(0.0)));
QRectF sourceRect(0, 0, textureSize.width(), textureSize.height());
diff --git a/src/qml/animations/qanimationgroupjob_p.h b/src/qml/animations/qanimationgroupjob_p.h
index b01b2f3b36..a27c9195dd 100644
--- a/src/qml/animations/qanimationgroupjob_p.h
+++ b/src/qml/animations/qanimationgroupjob_p.h
@@ -72,7 +72,7 @@ public:
QAbstractAnimationJob *firstChild() const { return m_firstChild; }
QAbstractAnimationJob *lastChild() const { return m_lastChild; }
- void clear();
+ virtual void clear();
//called by QAbstractAnimationJob
virtual void uncontrolledAnimationFinished(QAbstractAnimationJob *animation);
diff --git a/src/qml/animations/qsequentialanimationgroupjob.cpp b/src/qml/animations/qsequentialanimationgroupjob.cpp
index 22e20d9268..d98546122f 100644
--- a/src/qml/animations/qsequentialanimationgroupjob.cpp
+++ b/src/qml/animations/qsequentialanimationgroupjob.cpp
@@ -204,6 +204,15 @@ int QSequentialAnimationGroupJob::duration() const
return ret;
}
+void QSequentialAnimationGroupJob::clear()
+{
+ m_previousLoop = 0;
+ QAnimationGroupJob::clear();
+
+ // clear() should call removeAnimation(), which will clear m_currentAnimation, eventually.
+ Q_ASSERT(m_currentAnimation == nullptr);
+}
+
void QSequentialAnimationGroupJob::updateCurrentTime(int currentTime)
{
if (!m_currentAnimation)
diff --git a/src/qml/animations/qsequentialanimationgroupjob_p.h b/src/qml/animations/qsequentialanimationgroupjob_p.h
index 13f9806be1..34e8fe1e08 100644
--- a/src/qml/animations/qsequentialanimationgroupjob_p.h
+++ b/src/qml/animations/qsequentialanimationgroupjob_p.h
@@ -68,6 +68,7 @@ public:
int duration() const override;
QAbstractAnimationJob *currentAnimation() const { return m_currentAnimation; }
+ void clear() override;
protected:
void updateCurrentTime(int) override;
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index 868f600a10..6e077ec44c 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -1082,6 +1082,9 @@ void IRBuilder::setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST
binding->type = QV4::CompiledData::Binding::Type_Number;
binding->value.constantValueIndex = jsGenerator->registerConstant(QV4::Encode(-lit->value));
}
+ } else if (QQmlJS::AST::cast<QQmlJS::AST::NullExpression *>(expr)) {
+ binding->type = QV4::CompiledData::Binding::Type_Null;
+ binding->value.nullMarker = 0;
}
}
@@ -1627,7 +1630,7 @@ void QmlUnitGenerator::generate(Document &output, const QV4::CompiledData::Depen
uint nextOffset = objectOffset + objectOffsetTableSize;
for (Object *o : qAsConst(output.objects)) {
objectOffsets.insert(o, nextOffset);
- nextOffset += QV4::CompiledData::Object::calculateSizeExcludingSignalsAndEnums(o->functionCount(), o->propertyCount(), o->aliasCount(), o->enumCount(), o->signalCount(), o->bindingCount(), o->namedObjectsInComponent.count);
+ nextOffset += QV4::CompiledData::Object::calculateSizeExcludingSignalsAndEnums(o->functionCount(), o->propertyCount(), o->aliasCount(), o->enumCount(), o->signalCount(), o->bindingCount(), o->namedObjectsInComponent.size());
int signalTableSize = 0;
for (const Signal *s = o->firstSignal(); s; s = s->next)
@@ -1702,7 +1705,7 @@ void QmlUnitGenerator::generate(Document &output, const QV4::CompiledData::Depen
objectToWrite->offsetToBindings = nextOffset;
nextOffset += objectToWrite->nBindings * sizeof(QV4::CompiledData::Binding);
- objectToWrite->nNamedObjectsInComponent = o->namedObjectsInComponent.count;
+ objectToWrite->nNamedObjectsInComponent = o->namedObjectsInComponent.size();
objectToWrite->offsetToNamedObjectsInComponent = nextOffset;
nextOffset += objectToWrite->nNamedObjectsInComponent * sizeof(quint32);
@@ -1774,7 +1777,7 @@ void QmlUnitGenerator::generate(Document &output, const QV4::CompiledData::Depen
}
quint32_le *namedObjectInComponentPtr = reinterpret_cast<quint32_le *>(objectPtr + objectToWrite->offsetToNamedObjectsInComponent);
- for (int i = 0; i < o->namedObjectsInComponent.count; ++i) {
+ for (int i = 0; i < o->namedObjectsInComponent.size(); ++i) {
*namedObjectInComponentPtr++ = o->namedObjectsInComponent.at(i);
}
}
@@ -2105,8 +2108,6 @@ QmlIR::Object *IRLoader::loadObject(const QV4::CompiledData::Object *serializedO
f->location = compiledFunction->location;
f->nameIndex = compiledFunction->nameIndex;
- const QString name = unit->stringAtInternal(compiledFunction->nameIndex);
-
f->formals.allocate(pool, int(compiledFunction->nFormals));
const quint32_le *formalNameIdx = compiledFunction->formalsTable();
for (uint i = 0; i < compiledFunction->nFormals; ++i, ++formalNameIdx)
diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h
index 56724bcda5..22bc2d2953 100644
--- a/src/qml/compiler/qqmlirbuilder_p.h
+++ b/src/qml/compiler/qqmlirbuilder_p.h
@@ -198,69 +198,6 @@ struct PoolList
Iterator end() { return Iterator(nullptr); }
};
-template <typename T>
-class FixedPoolArray
-{
- T *data;
-public:
- int count = 0;
-
- FixedPoolArray()
- : data(nullptr)
-
- {}
-
- void allocate(QQmlJS::MemoryPool *pool, int size)
- {
- count = size;
- data = reinterpret_cast<T*>(pool->allocate(count * sizeof(T)));
- }
-
- void allocate(QQmlJS::MemoryPool *pool, const QVector<T> &vector)
- {
- count = vector.count();
- data = reinterpret_cast<T*>(pool->allocate(count * sizeof(T)));
-
- if (QTypeInfo<T>::isComplex) {
- for (int i = 0; i < count; ++i)
- new (data + i) T(vector.at(i));
- } else {
- memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
- }
- }
-
- template <typename Container>
- void allocate(QQmlJS::MemoryPool *pool, const Container &container)
- {
- count = container.count();
- data = reinterpret_cast<T*>(pool->allocate(count * sizeof(T)));
- typename Container::ConstIterator it = container.constBegin();
- for (int i = 0; i < count; ++i)
- new (data + i) T(*it++);
- }
-
- const T &at(int index) const {
- Q_ASSERT(index >= 0 && index < count);
- return data[index];
- }
-
- T &operator[](int index) {
- Q_ASSERT(index >= 0 && index < count);
- return data[index];
- }
-
-
- int indexOf(const T &value) const {
- for (int i = 0; i < count; ++i)
- if (data[i] == value)
- return i;
- return -1;
- }
-
- const T *begin() const { return data; }
- const T *end() const { return data + count; }
-};
-
struct Object;
struct EnumValue : public QV4::CompiledData::EnumValue
@@ -410,7 +347,7 @@ public:
FixedPoolArray<int> runtimeFunctionIndices;
FixedPoolArray<quint32> namedObjectsInComponent;
- int namedObjectsInComponentCount() const { return namedObjectsInComponent.count; }
+ int namedObjectsInComponentCount() const { return namedObjectsInComponent.size(); }
const quint32 *namedObjectsInComponentTable() const { return namedObjectsInComponent.begin(); }
private:
diff --git a/src/qml/compiler/qqmlpropertyvalidator.cpp b/src/qml/compiler/qqmlpropertyvalidator.cpp
index 5e821518a4..1beaac8095 100644
--- a/src/qml/compiler/qqmlpropertyvalidator.cpp
+++ b/src/qml/compiler/qqmlpropertyvalidator.cpp
@@ -352,30 +352,45 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
return noError;
}
+ auto warnOrError = [&](const QString &error) {
+ if (binding->type == QV4::CompiledData::Binding::Type_Null) {
+ QQmlError warning;
+ warning.setUrl(compilationUnit->url());
+ warning.setLine(binding->valueLocation.line);
+ warning.setColumn(binding->valueLocation.column);
+ warning.setDescription(error + tr(" - Assigning null to incompatible properties in QML "
+ "is deprecated. This will become a compile error in "
+ "future versions of Qt."));
+ enginePrivate->warning(warning);
+ return noError;
+ }
+ return QQmlCompileError(binding->valueLocation, error);
+ };
+
switch (property->propType()) {
case QMetaType::QVariant:
break;
case QVariant::String: {
if (!binding->evaluatesToString()) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: string expected"));
+ return warnOrError(tr("Invalid property assignment: string expected"));
}
}
break;
case QVariant::StringList: {
if (!binding->evaluatesToString()) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: string or string list expected"));
+ return warnOrError(tr("Invalid property assignment: string or string list expected"));
}
}
break;
case QVariant::ByteArray: {
if (binding->type != QV4::CompiledData::Binding::Type_String) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: byte array expected"));
+ return warnOrError(tr("Invalid property assignment: byte array expected"));
}
}
break;
case QVariant::Url: {
if (binding->type != QV4::CompiledData::Binding::Type_String) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: url expected"));
+ return warnOrError(tr("Invalid property assignment: url expected"));
}
}
break;
@@ -385,7 +400,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
if (double(uint(d)) == d)
return noError;
}
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: unsigned int expected"));
+ return warnOrError(tr("Invalid property assignment: unsigned int expected"));
}
break;
case QVariant::Int: {
@@ -394,18 +409,18 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
if (double(int(d)) == d)
return noError;
}
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: int expected"));
+ return warnOrError(tr("Invalid property assignment: int expected"));
}
break;
case QMetaType::Float: {
if (binding->type != QV4::CompiledData::Binding::Type_Number) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: number expected"));
+ return warnOrError(tr("Invalid property assignment: number expected"));
}
}
break;
case QVariant::Double: {
if (binding->type != QV4::CompiledData::Binding::Type_Number) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: number expected"));
+ return warnOrError(tr("Invalid property assignment: number expected"));
}
}
break;
@@ -413,7 +428,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
bool ok = false;
QQmlStringConverters::rgbaFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: color expected"));
+ return warnOrError(tr("Invalid property assignment: color expected"));
}
}
break;
@@ -422,7 +437,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
bool ok = false;
QQmlStringConverters::dateFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: date expected"));
+ return warnOrError(tr("Invalid property assignment: date expected"));
}
}
break;
@@ -430,7 +445,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
bool ok = false;
QQmlStringConverters::timeFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: time expected"));
+ return warnOrError(tr("Invalid property assignment: time expected"));
}
}
break;
@@ -438,7 +453,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
bool ok = false;
QQmlStringConverters::dateTimeFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: datetime expected"));
+ return warnOrError(tr("Invalid property assignment: datetime expected"));
}
}
break;
@@ -447,7 +462,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
bool ok = false;
QQmlStringConverters::pointFFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: point expected"));
+ return warnOrError(tr("Invalid property assignment: point expected"));
}
}
break;
@@ -455,7 +470,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
bool ok = false;
QQmlStringConverters::pointFFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: point expected"));
+ return warnOrError(tr("Invalid property assignment: point expected"));
}
}
break;
@@ -463,7 +478,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
bool ok = false;
QQmlStringConverters::sizeFFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: size expected"));
+ return warnOrError(tr("Invalid property assignment: size expected"));
}
}
break;
@@ -471,7 +486,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
bool ok = false;
QQmlStringConverters::sizeFFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: size expected"));
+ return warnOrError(tr("Invalid property assignment: size expected"));
}
}
break;
@@ -479,7 +494,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
bool ok = false;
QQmlStringConverters::rectFFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: rect expected"));
+ return warnOrError(tr("Invalid property assignment: rect expected"));
}
}
break;
@@ -487,13 +502,13 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
bool ok = false;
QQmlStringConverters::rectFFromString(binding->valueAsString(compilationUnit.data()), &ok);
if (!ok) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: point expected"));
+ return warnOrError(tr("Invalid property assignment: point expected"));
}
}
break;
case QVariant::Bool: {
if (binding->type != QV4::CompiledData::Binding::Type_Boolean) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: boolean expected"));
+ return warnOrError(tr("Invalid property assignment: boolean expected"));
}
}
break;
@@ -503,7 +518,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
float yp;
} vec;
if (!QQmlStringConverters::createFromString(QMetaType::QVector2D, binding->valueAsString(compilationUnit.data()), &vec, sizeof(vec))) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: 2D vector expected"));
+ return warnOrError(tr("Invalid property assignment: 2D vector expected"));
}
}
break;
@@ -514,7 +529,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
float zy;
} vec;
if (!QQmlStringConverters::createFromString(QMetaType::QVector3D, binding->valueAsString(compilationUnit.data()), &vec, sizeof(vec))) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: 3D vector expected"));
+ return warnOrError(tr("Invalid property assignment: 3D vector expected"));
}
}
break;
@@ -526,7 +541,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
float wp;
} vec;
if (!QQmlStringConverters::createFromString(QMetaType::QVector4D, binding->valueAsString(compilationUnit.data()), &vec, sizeof(vec))) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: 4D vector expected"));
+ return warnOrError(tr("Invalid property assignment: 4D vector expected"));
}
}
break;
@@ -538,17 +553,17 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
float zp;
} vec;
if (!QQmlStringConverters::createFromString(QMetaType::QQuaternion, binding->valueAsString(compilationUnit.data()), &vec, sizeof(vec))) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: quaternion expected"));
+ return warnOrError(tr("Invalid property assignment: quaternion expected"));
}
}
break;
case QVariant::RegExp:
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: regular expression expected; use /pattern/ syntax"));
+ return warnOrError(tr("Invalid property assignment: regular expression expected; use /pattern/ syntax"));
default: {
// generate single literal value assignment to a list property if required
if (property->propType() == qMetaTypeId<QList<qreal> >()) {
if (binding->type != QV4::CompiledData::Binding::Type_Number) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: number or array of numbers expected"));
+ return warnOrError(tr("Invalid property assignment: number or array of numbers expected"));
}
break;
} else if (property->propType() == qMetaTypeId<QList<int> >()) {
@@ -559,33 +574,36 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache
ok = false;
}
if (!ok)
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: int or array of ints expected"));
+ return warnOrError(tr("Invalid property assignment: int or array of ints expected"));
break;
} else if (property->propType() == qMetaTypeId<QList<bool> >()) {
if (binding->type != QV4::CompiledData::Binding::Type_Boolean) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: bool or array of bools expected"));
+ return warnOrError(tr("Invalid property assignment: bool or array of bools expected"));
}
break;
} else if (property->propType() == qMetaTypeId<QList<QUrl> >()) {
if (binding->type != QV4::CompiledData::Binding::Type_String) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: url or array of urls expected"));
+ return warnOrError(tr("Invalid property assignment: url or array of urls expected"));
}
break;
} else if (property->propType() == qMetaTypeId<QList<QString> >()) {
if (!binding->evaluatesToString()) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: string or array of strings expected"));
+ return warnOrError(tr("Invalid property assignment: string or array of strings expected"));
}
break;
} else if (property->propType() == qMetaTypeId<QJSValue>()) {
break;
} else if (property->propType() == qMetaTypeId<QQmlScriptString>()) {
break;
+ } else if (property->isQObject()
+ && binding->type == QV4::CompiledData::Binding::Type_Null) {
+ break;
}
// otherwise, try a custom type assignment
QQmlMetaType::StringConverter converter = QQmlMetaType::customStringConverter(property->propType());
if (!converter) {
- return QQmlCompileError(binding->valueLocation, tr("Invalid property assignment: unsupported type \"%1\"").arg(QString::fromLatin1(QMetaType::typeName(property->propType()))));
+ return warnOrError(tr("Invalid property assignment: unsupported type \"%1\"").arg(QString::fromLatin1(QMetaType::typeName(property->propType()))));
}
}
break;
@@ -671,8 +689,6 @@ QQmlCompileError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *
}
}
return noError;
- } else if (compilationUnit->objectAt(binding->value.objectIndex)->flags & QV4::CompiledData::Object::IsComponent) {
- return noError;
} else if (binding->flags & QV4::CompiledData::Binding::IsSignalHandlerObject && property->isFunction()) {
return noError;
} else if (QQmlValueTypeFactory::isValueType(property->propType())) {
diff --git a/src/qml/compiler/qv4bytecodegenerator.cpp b/src/qml/compiler/qv4bytecodegenerator.cpp
index d0bca69b56..ea252a6013 100644
--- a/src/qml/compiler/qv4bytecodegenerator.cpp
+++ b/src/qml/compiler/qv4bytecodegenerator.cpp
@@ -180,6 +180,10 @@ void BytecodeGenerator::finalize(Compiler::Context *context)
context->code = code;
context->lineNumberMapping = lineNumbers;
+
+ for (const auto &li : _labelInfos) {
+ context->labelInfo.push_back(instructions.at(labels.at(li.labelIndex)).position);
+ }
}
int BytecodeGenerator::addInstructionHelper(Instr::Type type, const Instr &i, int offsetOfOffset) {
diff --git a/src/qml/compiler/qv4bytecodegenerator_p.h b/src/qml/compiler/qv4bytecodegenerator_p.h
index 4f3dc27acc..1d0a57c536 100644
--- a/src/qml/compiler/qv4bytecodegenerator_p.h
+++ b/src/qml/compiler/qv4bytecodegenerator_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
#include <private/qv4instr_moth_p.h>
+#include <private/qv4compileddata_p.h>
QT_BEGIN_NAMESPACE
@@ -65,6 +66,8 @@ namespace Moth {
class BytecodeGenerator {
public:
+ typedef CompiledData::Function::TraceInfoCount TraceInfoCount;
+
BytecodeGenerator(int line, bool debug)
: startLine(line), debugMode(debug) {}
@@ -161,6 +164,15 @@ public:
addInstructionHelper(Moth::Instr::Type(InstrT), genericInstr);
}
+ // Same as addInstruction, but also add a trace slot. Move only, because the instruction cannot
+ // be reused afterwards.
+ template<int InstrT>
+ void addTracingInstruction(InstrData<InstrT> data)
+ {
+ data.traceSlot = nextTraceInfo();
+ addInstruction(data);
+ }
+
Q_REQUIRED_RESULT Jump jump()
{
QT_WARNING_PUSH
@@ -172,14 +184,12 @@ QT_WARNING_POP
Q_REQUIRED_RESULT Jump jumpTrue()
{
- Instruction::JumpTrue data;
- return addJumpInstruction(data);
+ return addTracingJumpInstruction(Instruction::JumpTrue());
}
Q_REQUIRED_RESULT Jump jumpFalse()
{
- Instruction::JumpFalse data;
- return addJumpInstruction(data);
+ return addTracingJumpInstruction(Instruction::JumpFalse());
}
Q_REQUIRED_RESULT Jump jumpNotUndefined()
@@ -198,16 +208,16 @@ QT_WARNING_POP
{
Instruction::CmpStrictEqual cmp;
cmp.lhs = lhs;
- addInstruction(cmp);
- addJumpInstruction(Instruction::JumpTrue()).link(target);
+ addInstruction(std::move(cmp));
+ addTracingJumpInstruction(Instruction::JumpTrue()).link(target);
}
void jumpStrictNotEqual(const StackSlot &lhs, const Label &target)
{
Instruction::CmpStrictNotEqual cmp;
cmp.lhs = lhs;
- addInstruction(cmp);
- addJumpInstruction(Instruction::JumpTrue()).link(target);
+ addInstruction(std::move(cmp));
+ addTracingJumpInstruction(Instruction::JumpTrue()).link(target);
}
void setUnwindHandler(ExceptionHandler *handler)
@@ -248,6 +258,13 @@ QT_WARNING_POP
void finalize(Compiler::Context *context);
template<int InstrT>
+ Jump addTracingJumpInstruction(InstrData<InstrT> &&data)
+ {
+ data.traceSlot = nextTraceInfo();
+ return addJumpInstruction(data);
+ }
+
+ template<int InstrT>
Jump addJumpInstruction(const InstrData<InstrT> &data)
{
Instr genericInstr;
@@ -258,9 +275,9 @@ QT_WARNING_POP
void addCJumpInstruction(bool jumpOnFalse, const Label *trueLabel, const Label *falseLabel)
{
if (jumpOnFalse)
- addJumpInstruction(Instruction::JumpFalse()).link(*falseLabel);
+ addTracingJumpInstruction(Instruction::JumpFalse()).link(*falseLabel);
else
- addJumpInstruction(Instruction::JumpTrue()).link(*trueLabel);
+ addTracingJumpInstruction(Instruction::JumpTrue()).link(*trueLabel);
}
void clearLastInstruction()
@@ -268,6 +285,32 @@ QT_WARNING_POP
lastInstrType = -1;
}
+ TraceInfoCount nextTraceInfo()
+ {
+ // If tracing is disabled, use slot 0 to unconditionally store all trace info
+ if (nTraceInfos == CompiledData::Function::NoTracing())
+ return TraceInfoCount(0);
+ return nTraceInfos++;
+ }
+
+ void setTracing(bool onoff, int argumentCount)
+ {
+ if (onoff)
+ nTraceInfos = argumentCount;
+ else
+ nTraceInfos = CompiledData::Function::NoTracing();
+ }
+
+ TraceInfoCount traceInfoCount() const
+ {
+ return nTraceInfos;
+ }
+
+ void addLoopStart(const Label &start)
+ {
+ _labelInfos.push_back({ start.index });
+ }
+
private:
friend struct Jump;
friend struct Label;
@@ -302,6 +345,13 @@ private:
int lastInstrType = -1;
Moth::Instr lastInstr;
+
+ TraceInfoCount nTraceInfos = TraceInfoCount(0);
+
+ struct LabelInfo {
+ int labelIndex;
+ };
+ std::vector<LabelInfo> _labelInfos;
};
}
diff --git a/src/qml/compiler/qv4bytecodehandler.cpp b/src/qml/compiler/qv4bytecodehandler.cpp
index e1fc0c6ee3..92b112c2fa 100644
--- a/src/qml/compiler/qv4bytecodehandler.cpp
+++ b/src/qml/compiler/qv4bytecodehandler.cpp
@@ -79,458 +79,3 @@ void ByteCodeHandler::decode(const char *code, uint len)
#undef DECODE_AND_DISPATCH
#undef DISPATCH_INSTRUCTION
-
-#define MOTH_UNUSED_ARGS0()
-#define MOTH_UNUSED_ARGS1(arg) \
- Q_UNUSED(arg);
-#define MOTH_UNUSED_ARGS2(arg1, arg2) \
- Q_UNUSED(arg1); \
- Q_UNUSED(arg2);
-#define MOTH_UNUSED_ARGS3(arg1, arg2, arg3) \
- Q_UNUSED(arg1); \
- Q_UNUSED(arg2); \
- Q_UNUSED(arg3);
-#define MOTH_UNUSED_ARGS4(arg1, arg2, arg3, arg4) \
- Q_UNUSED(arg1); \
- Q_UNUSED(arg2); \
- Q_UNUSED(arg3); \
- Q_UNUSED(arg4);
-
-#define MOTH_MARK_ARGS_UNUSED_PLEASE(nargs, ...) \
- MOTH_EXPAND_FOR_MSVC(MOTH_UNUSED_ARGS##nargs(__VA_ARGS__))
-
-#define MOTH_MARK_ARGS_UNUSED_INSTRUCTION(name, nargs, ...) \
- MOTH_MARK_ARGS_UNUSED_PLEASE(nargs, __VA_ARGS__)
-
-#define COLLECTOR_BEGIN_INSTR(instr) \
- { \
- INSTR_##instr(MOTH_DECODE_WITH_BASE) \
- INSTR_##instr(MOTH_MARK_ARGS_UNUSED) \
- Q_UNUSED(base_ptr);
-
-#define COLLECTOR_END_INSTR(instr) \
- continue; \
- }
-
-std::vector<int> ByteCodeHandler::collectLabelsInBytecode(const char *code, uint len)
-{
- MOTH_JUMP_TABLE;
-
- std::vector<int> labels;
-
- const auto addLabel = [&labels,len](int offset) {
- Q_ASSERT(offset >= 0 && offset < static_cast<int>(len));
- labels.push_back(offset);
- };
-
- const char *start = code;
- const char *end = code + len;
- while (code < end) {
- MOTH_DISPATCH()
- Q_UNREACHABLE();
-
- COLLECTOR_BEGIN_INSTR(LoadReg)
- COLLECTOR_END_INSTR(LoadReg)
-
- COLLECTOR_BEGIN_INSTR(StoreReg)
- COLLECTOR_END_INSTR(StoreReg)
-
- COLLECTOR_BEGIN_INSTR(MoveReg)
- COLLECTOR_END_INSTR(MoveReg)
-
- COLLECTOR_BEGIN_INSTR(LoadConst)
- COLLECTOR_END_INSTR(LoadConst)
-
- COLLECTOR_BEGIN_INSTR(LoadNull)
- COLLECTOR_END_INSTR(LoadNull)
-
- COLLECTOR_BEGIN_INSTR(LoadZero)
- COLLECTOR_END_INSTR(LoadZero)
-
- COLLECTOR_BEGIN_INSTR(LoadTrue)
- COLLECTOR_END_INSTR(LoadTrue)
-
- COLLECTOR_BEGIN_INSTR(LoadFalse)
- COLLECTOR_END_INSTR(LoadFalse)
-
- COLLECTOR_BEGIN_INSTR(LoadUndefined)
- COLLECTOR_END_INSTR(LoadUndefined)
-
- COLLECTOR_BEGIN_INSTR(LoadInt)
- COLLECTOR_END_INSTR(LoadInt)
-
- COLLECTOR_BEGIN_INSTR(MoveConst)
- COLLECTOR_END_INSTR(MoveConst)
-
- COLLECTOR_BEGIN_INSTR(LoadImport)
- COLLECTOR_END_INSTR(LoadImport)
-
- COLLECTOR_BEGIN_INSTR(LoadLocal)
- COLLECTOR_END_INSTR(LoadLocal)
-
- COLLECTOR_BEGIN_INSTR(StoreLocal)
- COLLECTOR_END_INSTR(StoreLocal)
-
- COLLECTOR_BEGIN_INSTR(LoadScopedLocal)
- COLLECTOR_END_INSTR(LoadScopedLocal)
-
- COLLECTOR_BEGIN_INSTR(StoreScopedLocal)
- COLLECTOR_END_INSTR(StoreScopedLocal)
-
- COLLECTOR_BEGIN_INSTR(LoadRuntimeString)
- COLLECTOR_END_INSTR(LoadRuntimeString)
-
- COLLECTOR_BEGIN_INSTR(MoveRegExp)
- COLLECTOR_END_INSTR(MoveRegExp)
-
- COLLECTOR_BEGIN_INSTR(LoadClosure)
- COLLECTOR_END_INSTR(LoadClosure)
-
- COLLECTOR_BEGIN_INSTR(LoadName)
- COLLECTOR_END_INSTR(LoadName)
-
- COLLECTOR_BEGIN_INSTR(LoadGlobalLookup)
- COLLECTOR_END_INSTR(LoadGlobalLookup)
-
- COLLECTOR_BEGIN_INSTR(LoadQmlContextPropertyLookup)
- COLLECTOR_END_INSTR(LoadQmlContextPropertyLookup)
-
- COLLECTOR_BEGIN_INSTR(StoreNameSloppy)
- COLLECTOR_END_INSTR(StoreNameSloppy)
-
- COLLECTOR_BEGIN_INSTR(StoreNameStrict)
- COLLECTOR_END_INSTR(StoreNameStrict)
-
- COLLECTOR_BEGIN_INSTR(LoadElement)
- COLLECTOR_END_INSTR(LoadElement)
-
- COLLECTOR_BEGIN_INSTR(StoreElement)
- COLLECTOR_END_INSTR(StoreElement)
-
- COLLECTOR_BEGIN_INSTR(LoadProperty)
- COLLECTOR_END_INSTR(LoadProperty)
-
- COLLECTOR_BEGIN_INSTR(GetLookup)
- COLLECTOR_END_INSTR(GetLookup)
-
- COLLECTOR_BEGIN_INSTR(StoreProperty)
- COLLECTOR_END_INSTR(StoreProperty)
-
- COLLECTOR_BEGIN_INSTR(SetLookup)
- COLLECTOR_END_INSTR(SetLookup)
-
- COLLECTOR_BEGIN_INSTR(LoadSuperProperty)
- COLLECTOR_END_INSTR(LoadSuperProperty)
-
- COLLECTOR_BEGIN_INSTR(StoreSuperProperty)
- COLLECTOR_END_INSTR(StoreSuperProperty)
-
- COLLECTOR_BEGIN_INSTR(Yield)
- COLLECTOR_END_INSTR(Yield)
-
- COLLECTOR_BEGIN_INSTR(YieldStar)
- COLLECTOR_END_INSTR(YieldStar)
-
- COLLECTOR_BEGIN_INSTR(Resume)
- COLLECTOR_END_INSTR(Resume)
-
- COLLECTOR_BEGIN_INSTR(CallValue)
- COLLECTOR_END_INSTR(CallValue)
-
- COLLECTOR_BEGIN_INSTR(CallWithReceiver)
- COLLECTOR_END_INSTR(CallWithReceiver)
-
- COLLECTOR_BEGIN_INSTR(CallProperty)
- COLLECTOR_END_INSTR(CallProperty)
-
- COLLECTOR_BEGIN_INSTR(CallPropertyLookup)
- COLLECTOR_END_INSTR(CallPropertyLookup)
-
- COLLECTOR_BEGIN_INSTR(CallElement)
- COLLECTOR_END_INSTR(CallElement)
-
- COLLECTOR_BEGIN_INSTR(CallName)
- COLLECTOR_END_INSTR(CallName)
-
- COLLECTOR_BEGIN_INSTR(CallPossiblyDirectEval)
- COLLECTOR_END_INSTR(CallPossiblyDirectEval)
-
- COLLECTOR_BEGIN_INSTR(CallGlobalLookup)
- COLLECTOR_END_INSTR(CallGlobalLookup)
-
- COLLECTOR_BEGIN_INSTR(CallQmlContextPropertyLookup)
- COLLECTOR_END_INSTR(CallQmlContextPropertyLookup)
-
- COLLECTOR_BEGIN_INSTR(CallWithSpread)
- COLLECTOR_END_INSTR(CallWithSpread)
-
- COLLECTOR_BEGIN_INSTR(Construct)
- COLLECTOR_END_INSTR(Construct)
-
- COLLECTOR_BEGIN_INSTR(ConstructWithSpread)
- COLLECTOR_END_INSTR(ConstructWithSpread)
-
- COLLECTOR_BEGIN_INSTR(SetUnwindHandler)
- addLabel(code - start + offset);
- COLLECTOR_END_INSTR(SetUnwindHandler)
-
- COLLECTOR_BEGIN_INSTR(UnwindDispatch)
- COLLECTOR_END_INSTR(UnwindDispatch)
-
- COLLECTOR_BEGIN_INSTR(UnwindToLabel)
- addLabel(code - start + offset);
- COLLECTOR_END_INSTR(UnwindToLabel)
-
- COLLECTOR_BEGIN_INSTR(DeadTemporalZoneCheck)
- COLLECTOR_END_INSTR(DeadTemporalZoneCheck)
-
- COLLECTOR_BEGIN_INSTR(ThrowException)
- COLLECTOR_END_INSTR(ThrowException)
-
- COLLECTOR_BEGIN_INSTR(GetException)
- COLLECTOR_END_INSTR(HasException)
-
- COLLECTOR_BEGIN_INSTR(SetException)
- COLLECTOR_END_INSTR(SetExceptionFlag)
-
- COLLECTOR_BEGIN_INSTR(CreateCallContext)
- COLLECTOR_END_INSTR(CreateCallContext)
-
- COLLECTOR_BEGIN_INSTR(PushCatchContext)
- COLLECTOR_END_INSTR(PushCatchContext)
-
- COLLECTOR_BEGIN_INSTR(PushWithContext)
- COLLECTOR_END_INSTR(PushWithContext)
-
- COLLECTOR_BEGIN_INSTR(PushBlockContext)
- COLLECTOR_END_INSTR(PushBlockContext)
-
- COLLECTOR_BEGIN_INSTR(CloneBlockContext)
- COLLECTOR_END_INSTR(CloneBlockContext)
-
- COLLECTOR_BEGIN_INSTR(PushScriptContext)
- COLLECTOR_END_INSTR(PushScriptContext)
-
- COLLECTOR_BEGIN_INSTR(PopScriptContext)
- COLLECTOR_END_INSTR(PopScriptContext)
-
- COLLECTOR_BEGIN_INSTR(PopContext)
- COLLECTOR_END_INSTR(PopContext)
-
- COLLECTOR_BEGIN_INSTR(GetIterator)
- COLLECTOR_END_INSTR(GetIterator)
-
- COLLECTOR_BEGIN_INSTR(IteratorNext)
- COLLECTOR_END_INSTR(IteratorNext)
-
- COLLECTOR_BEGIN_INSTR(IteratorNextForYieldStar)
- COLLECTOR_END_INSTR(IteratorNextForYieldStar)
-
- COLLECTOR_BEGIN_INSTR(IteratorClose)
- COLLECTOR_END_INSTR(IteratorClose)
-
- COLLECTOR_BEGIN_INSTR(DestructureRestElement)
- COLLECTOR_END_INSTR(DestructureRestElement)
-
- COLLECTOR_BEGIN_INSTR(DeleteProperty)
- COLLECTOR_END_INSTR(DeleteProperty)
-
- COLLECTOR_BEGIN_INSTR(DeleteName)
- COLLECTOR_END_INSTR(DeleteName)
-
- COLLECTOR_BEGIN_INSTR(TypeofName)
- COLLECTOR_END_INSTR(TypeofName)
-
- COLLECTOR_BEGIN_INSTR(TypeofValue)
- COLLECTOR_END_INSTR(TypeofValue)
-
- COLLECTOR_BEGIN_INSTR(DeclareVar)
- COLLECTOR_END_INSTR(DeclareVar)
-
- COLLECTOR_BEGIN_INSTR(DefineArray)
- COLLECTOR_END_INSTR(DefineArray)
-
- COLLECTOR_BEGIN_INSTR(DefineObjectLiteral)
- COLLECTOR_END_INSTR(DefineObjectLiteral)
-
- COLLECTOR_BEGIN_INSTR(CreateClass)
- COLLECTOR_END_INSTR(CreateClass)
-
- COLLECTOR_BEGIN_INSTR(CreateMappedArgumentsObject)
- COLLECTOR_END_INSTR(CreateMappedArgumentsObject)
-
- COLLECTOR_BEGIN_INSTR(CreateUnmappedArgumentsObject)
- COLLECTOR_END_INSTR(CreateUnmappedArgumentsObject)
-
- COLLECTOR_BEGIN_INSTR(CreateRestParameter)
- COLLECTOR_END_INSTR(CreateRestParameter)
-
- COLLECTOR_BEGIN_INSTR(ConvertThisToObject)
- COLLECTOR_END_INSTR(ConvertThisToObject)
-
- COLLECTOR_BEGIN_INSTR(LoadSuperConstructor)
- COLLECTOR_END_INSTR(LoadSuperConstructor)
-
- COLLECTOR_BEGIN_INSTR(ToObject)
- COLLECTOR_END_INSTR(ToObject)
-
- COLLECTOR_BEGIN_INSTR(Jump)
- addLabel(code - start + offset);
- COLLECTOR_END_INSTR(Jump)
-
- COLLECTOR_BEGIN_INSTR(JumpTrue)
- addLabel(code - start + offset);
- COLLECTOR_END_INSTR(JumpTrue)
-
- COLLECTOR_BEGIN_INSTR(JumpFalse)
- addLabel(code - start + offset);
- COLLECTOR_END_INSTR(JumpFalse)
-
- COLLECTOR_BEGIN_INSTR(JumpNoException)
- addLabel(code - start + offset);
- COLLECTOR_END_INSTR(JumpNoException)
-
- COLLECTOR_BEGIN_INSTR(JumpNotUndefined)
- addLabel(code - start + offset);
- COLLECTOR_END_INSTR(JumpNotUndefined)
-
- COLLECTOR_BEGIN_INSTR(CmpEqNull)
- COLLECTOR_END_INSTR(CmpEqNull)
-
- COLLECTOR_BEGIN_INSTR(CmpNeNull)
- COLLECTOR_END_INSTR(CmpNeNull)
-
- COLLECTOR_BEGIN_INSTR(CmpEqInt)
- COLLECTOR_END_INSTR(CmpEq)
-
- COLLECTOR_BEGIN_INSTR(CmpNeInt)
- COLLECTOR_END_INSTR(CmpNeInt)
-
- COLLECTOR_BEGIN_INSTR(CmpEq)
- COLLECTOR_END_INSTR(CmpEq)
-
- COLLECTOR_BEGIN_INSTR(CmpNe)
- COLLECTOR_END_INSTR(CmpNe)
-
- COLLECTOR_BEGIN_INSTR(CmpGt)
- COLLECTOR_END_INSTR(CmpGt)
-
- COLLECTOR_BEGIN_INSTR(CmpGe)
- COLLECTOR_END_INSTR(CmpGe)
-
- COLLECTOR_BEGIN_INSTR(CmpLt)
- COLLECTOR_END_INSTR(CmpLt)
-
- COLLECTOR_BEGIN_INSTR(CmpLe)
- COLLECTOR_END_INSTR(CmpLe)
-
- COLLECTOR_BEGIN_INSTR(CmpStrictEqual)
- COLLECTOR_END_INSTR(CmpStrictEqual)
-
- COLLECTOR_BEGIN_INSTR(CmpStrictNotEqual)
- COLLECTOR_END_INSTR(CmpStrictNotEqual)
-
- COLLECTOR_BEGIN_INSTR(CmpIn)
- COLLECTOR_END_INSTR(CmpIn)
-
- COLLECTOR_BEGIN_INSTR(CmpInstanceOf)
- COLLECTOR_END_INSTR(CmpInstanceOf)
-
- COLLECTOR_BEGIN_INSTR(UNot)
- COLLECTOR_END_INSTR(UNot)
-
- COLLECTOR_BEGIN_INSTR(UPlus)
- COLLECTOR_END_INSTR(UPlus)
-
- COLLECTOR_BEGIN_INSTR(UMinus)
- COLLECTOR_END_INSTR(UMinus)
-
- COLLECTOR_BEGIN_INSTR(UCompl)
- COLLECTOR_END_INSTR(UCompl)
-
- COLLECTOR_BEGIN_INSTR(Increment)
- COLLECTOR_END_INSTR(PreIncrement)
-
- COLLECTOR_BEGIN_INSTR(Decrement)
- COLLECTOR_END_INSTR(PreDecrement)
-
- COLLECTOR_BEGIN_INSTR(Add)
- COLLECTOR_END_INSTR(Add)
-
- COLLECTOR_BEGIN_INSTR(BitAnd)
- COLLECTOR_END_INSTR(BitAnd)
-
- COLLECTOR_BEGIN_INSTR(BitOr)
- COLLECTOR_END_INSTR(BitOr)
-
- COLLECTOR_BEGIN_INSTR(BitXor)
- COLLECTOR_END_INSTR(BitXor)
-
- COLLECTOR_BEGIN_INSTR(UShr)
- COLLECTOR_END_INSTR(UShr)
-
- COLLECTOR_BEGIN_INSTR(Shr)
- COLLECTOR_END_INSTR(Shr)
-
- COLLECTOR_BEGIN_INSTR(Shl)
- COLLECTOR_END_INSTR(Shl)
-
- COLLECTOR_BEGIN_INSTR(BitAndConst)
- COLLECTOR_END_INSTR(BitAndConst)
-
- COLLECTOR_BEGIN_INSTR(BitOrConst)
- COLLECTOR_END_INSTR(BitOr)
-
- COLLECTOR_BEGIN_INSTR(BitXorConst)
- COLLECTOR_END_INSTR(BitXor)
-
- COLLECTOR_BEGIN_INSTR(UShrConst)
- COLLECTOR_END_INSTR(UShrConst)
-
- COLLECTOR_BEGIN_INSTR(ShrConst)
- COLLECTOR_END_INSTR(ShrConst)
-
- COLLECTOR_BEGIN_INSTR(ShlConst)
- COLLECTOR_END_INSTR(ShlConst)
-
- COLLECTOR_BEGIN_INSTR(Exp)
- COLLECTOR_END_INSTR(Exp)
-
- COLLECTOR_BEGIN_INSTR(Mul)
- COLLECTOR_END_INSTR(Mul)
-
- COLLECTOR_BEGIN_INSTR(Div)
- COLLECTOR_END_INSTR(Div)
-
- COLLECTOR_BEGIN_INSTR(Mod)
- COLLECTOR_END_INSTR(Mod)
-
- COLLECTOR_BEGIN_INSTR(Sub)
- COLLECTOR_END_INSTR(Sub)
-
- COLLECTOR_BEGIN_INSTR(Ret)
- COLLECTOR_END_INSTR(Ret)
-
-#ifndef QT_NO_QML_DEBUGGER
- COLLECTOR_BEGIN_INSTR(Debug)
- COLLECTOR_END_INSTR(Debug)
-#endif // QT_NO_QML_DEBUGGER
-
- COLLECTOR_BEGIN_INSTR(InitializeBlockDeadTemporalZone)
- COLLECTOR_END_INSTR(InitializeBlockDeadTemporalZone)
-
- COLLECTOR_BEGIN_INSTR(ThrowOnNullOrUndefined)
- COLLECTOR_END_INSTR(ThrowOnNullOrUndefined)
-
- COLLECTOR_BEGIN_INSTR(GetTemplateObject)
- COLLECTOR_END_INSTR(GetTemplateObject)
-
- COLLECTOR_BEGIN_INSTR(TailCall)
- COLLECTOR_END_INSTR(TailCall)
- }
-
- return labels;
-}
-
-#undef COLLECTOR_BEGIN_INSTR
-#undef COLLECTOR_END_INSTR
diff --git a/src/qml/compiler/qv4bytecodehandler_p.h b/src/qml/compiler/qv4bytecodehandler_p.h
index ca6abf3dc3..797d25b8d0 100644
--- a/src/qml/compiler/qv4bytecodehandler_p.h
+++ b/src/qml/compiler/qv4bytecodehandler_p.h
@@ -75,6 +75,12 @@ namespace Moth {
int arg2, \
int arg3, \
int arg4
+#define BYTECODE_HANDLER_DEFINE_ARGS5(arg1, arg2, arg3, arg4, arg5) \
+ int arg1, \
+ int arg2, \
+ int arg3, \
+ int arg4, \
+ int arg5
#define BYTECODE_HANDLER_DEFINE_VIRTUAL_BYTECODE_HANDLER_INSTRUCTION(name, nargs, ...) \
virtual void generate_##name( \
@@ -93,8 +99,8 @@ public:
int currentInstructionOffset() const { return _currentOffset; }
int nextInstructionOffset() const { return _nextOffset; }
-
- static std::vector<int> collectLabelsInBytecode(const char *code, uint len);
+ int absoluteOffset(int relativeOffset) const
+ { return nextInstructionOffset() + relativeOffset; }
protected:
FOR_EACH_MOTH_INSTR(BYTECODE_HANDLER_DEFINE_VIRTUAL_BYTECODE_HANDLER)
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 3fdba08f20..e0d259bd0c 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -288,8 +288,8 @@ Codegen::Reference Codegen::unop(UnaryOperation op, const Reference &expr)
switch (op) {
case UMinus: {
expr.loadInAccumulator();
- Instruction::UMinus uminus;
- bytecodeGenerator->addInstruction(uminus);
+ Instruction::UMinus uminus = {};
+ bytecodeGenerator->addTracingInstruction(uminus);
return Reference::fromAccumulator(this);
}
case UPlus: {
@@ -317,8 +317,8 @@ Codegen::Reference Codegen::unop(UnaryOperation op, const Reference &expr)
Instruction::UPlus uplus;
bytecodeGenerator->addInstruction(uplus);
Reference originalValue = Reference::fromStackSlot(this).storeRetainAccumulator();
- Instruction::Increment inc;
- bytecodeGenerator->addInstruction(inc);
+ Instruction::Increment inc = {};
+ bytecodeGenerator->addTracingInstruction(inc);
e.storeConsumeAccumulator();
return originalValue;
} else {
@@ -329,8 +329,8 @@ Codegen::Reference Codegen::unop(UnaryOperation op, const Reference &expr)
case PreIncrement: {
Reference e = expr.asLValue();
e.loadInAccumulator();
- Instruction::Increment inc;
- bytecodeGenerator->addInstruction(inc);
+ Instruction::Increment inc = {};
+ bytecodeGenerator->addTracingInstruction(inc);
if (exprAccept(nx))
return e.storeConsumeAccumulator();
else
@@ -343,8 +343,8 @@ Codegen::Reference Codegen::unop(UnaryOperation op, const Reference &expr)
Instruction::UPlus uplus;
bytecodeGenerator->addInstruction(uplus);
Reference originalValue = Reference::fromStackSlot(this).storeRetainAccumulator();
- Instruction::Decrement dec;
- bytecodeGenerator->addInstruction(dec);
+ Instruction::Decrement dec = {};
+ bytecodeGenerator->addTracingInstruction(dec);
e.storeConsumeAccumulator();
return originalValue;
} else {
@@ -355,8 +355,8 @@ Codegen::Reference Codegen::unop(UnaryOperation op, const Reference &expr)
case PreDecrement: {
Reference e = expr.asLValue();
e.loadInAccumulator();
- Instruction::Decrement dec;
- bytecodeGenerator->addInstruction(dec);
+ Instruction::Decrement dec = {};
+ bytecodeGenerator->addTracingInstruction(dec);
if (exprAccept(nx))
return e.storeConsumeAccumulator();
else
@@ -1138,8 +1138,8 @@ bool Codegen::visit(ArrayPattern *ast)
slot.storeConsumeAccumulator();
index.loadInAccumulator();
- Instruction::Increment inc;
- bytecodeGenerator->addInstruction(inc);
+ Instruction::Increment inc = {};
+ bytecodeGenerator->addTracingInstruction(inc);
index.storeConsumeAccumulator();
};
@@ -1195,7 +1195,7 @@ bool Codegen::visit(ArrayPattern *ast)
next.value = lhsValue.stackSlot();
next.done = iteratorDone.stackSlot();
bytecodeGenerator->addInstruction(next);
- bytecodeGenerator->addJumpInstruction(Instruction::JumpTrue()).link(end);
+ bytecodeGenerator->addTracingJumpInstruction(Instruction::JumpTrue()).link(end);
lhsValue.loadInAccumulator();
pushAccumulator();
@@ -1482,24 +1482,24 @@ Codegen::Reference Codegen::binopHelper(QSOperator::Op oper, Reference &left, Re
{
switch (oper) {
case QSOperator::Add: {
- //### Todo: when we add type hints, we can generate an Increment when both the lhs is a number and the rhs == 1
left = left.storeOnStack();
right.loadInAccumulator();
Instruction::Add add;
add.lhs = left.stackSlot();
- bytecodeGenerator->addInstruction(add);
+ bytecodeGenerator->addTracingInstruction(add);
break;
}
case QSOperator::Sub: {
if (right.isConstant() && right.constant == Encode(int(1))) {
left.loadInAccumulator();
- bytecodeGenerator->addInstruction(Instruction::Decrement());
+ Instruction::Decrement dec = {};
+ bytecodeGenerator->addTracingInstruction(dec);
} else {
left = left.storeOnStack();
right.loadInAccumulator();
Instruction::Sub sub;
sub.lhs = left.stackSlot();
- bytecodeGenerator->addInstruction(sub);
+ bytecodeGenerator->addTracingInstruction(sub);
}
break;
}
@@ -1516,7 +1516,7 @@ Codegen::Reference Codegen::binopHelper(QSOperator::Op oper, Reference &left, Re
right.loadInAccumulator();
Instruction::Mul mul;
mul.lhs = left.stackSlot();
- bytecodeGenerator->addInstruction(mul);
+ bytecodeGenerator->addTracingInstruction(mul);
break;
}
case QSOperator::Div: {
@@ -1532,7 +1532,7 @@ Codegen::Reference Codegen::binopHelper(QSOperator::Op oper, Reference &left, Re
right.loadInAccumulator();
Instruction::Mod mod;
mod.lhs = left.stackSlot();
- bytecodeGenerator->addInstruction(mod);
+ bytecodeGenerator->addTracingInstruction(mod);
break;
}
case QSOperator::BitAnd:
@@ -1901,7 +1901,7 @@ bool Codegen::visit(CallExpression *ast)
call.thisObject = baseObject.stackSlot();
call.argc = calldata.argc;
call.argv = calldata.argv;
- bytecodeGenerator->addInstruction(call);
+ bytecodeGenerator->addTracingInstruction(call);
} else {
Instruction::TailCall call;
call.func = base.stackSlot();
@@ -1930,14 +1930,14 @@ void Codegen::handleCall(Reference &base, Arguments calldata, int slotForFunctio
call.lookupIndex = registerGetterLookup(base.propertyNameIndex);
call.argc = calldata.argc;
call.argv = calldata.argv;
- bytecodeGenerator->addInstruction(call);
+ bytecodeGenerator->addTracingInstruction(call);
} else {
Instruction::CallProperty call;
call.base = base.propertyBase.stackSlot();
call.name = base.propertyNameIndex;
call.argc = calldata.argc;
call.argv = calldata.argv;
- bytecodeGenerator->addInstruction(call);
+ bytecodeGenerator->addTracingInstruction(call);
}
} else if (base.type == Reference::Subscript) {
Instruction::CallElement call;
@@ -1945,33 +1945,33 @@ void Codegen::handleCall(Reference &base, Arguments calldata, int slotForFunctio
call.index = base.elementSubscript.stackSlot();
call.argc = calldata.argc;
call.argv = calldata.argv;
- bytecodeGenerator->addInstruction(call);
+ bytecodeGenerator->addTracingInstruction(call);
} else if (base.type == Reference::Name) {
if (base.name == QStringLiteral("eval")) {
Instruction::CallPossiblyDirectEval call;
call.argc = calldata.argc;
call.argv = calldata.argv;
- bytecodeGenerator->addInstruction(call);
+ bytecodeGenerator->addTracingInstruction(call);
} else if (!disable_lookups && useFastLookups && base.global) {
if (base.qmlGlobal) {
Instruction::CallQmlContextPropertyLookup call;
call.index = registerQmlContextPropertyGetterLookup(base.nameAsIndex());
call.argc = calldata.argc;
call.argv = calldata.argv;
- bytecodeGenerator->addInstruction(call);
+ bytecodeGenerator->addTracingInstruction(call);
} else {
Instruction::CallGlobalLookup call;
call.index = registerGlobalGetterLookup(base.nameAsIndex());
call.argc = calldata.argc;
call.argv = calldata.argv;
- bytecodeGenerator->addInstruction(call);
+ bytecodeGenerator->addTracingInstruction(call);
}
} else {
Instruction::CallName call;
call.name = base.nameAsIndex();
call.argc = calldata.argc;
call.argv = calldata.argv;
- bytecodeGenerator->addInstruction(call);
+ bytecodeGenerator->addTracingInstruction(call);
}
} else if (base.type == Reference::SuperProperty) {
Reference receiver = base.baseObject();
@@ -1988,14 +1988,14 @@ void Codegen::handleCall(Reference &base, Arguments calldata, int slotForFunctio
call.thisObject = receiver.stackSlot();
call.argc = calldata.argc;
call.argv = calldata.argv;
- bytecodeGenerator->addInstruction(call);
+ bytecodeGenerator->addTracingInstruction(call);
} else {
Q_ASSERT(base.isStackSlot());
Instruction::CallValue call;
call.name = base.stackSlot();
call.argc = calldata.argc;
call.argv = calldata.argv;
- bytecodeGenerator->addInstruction(call);
+ bytecodeGenerator->addTracingInstruction(call);
}
setExprResult(Reference::fromAccumulator(this));
@@ -2490,9 +2490,6 @@ bool Codegen::visit(ObjectPattern *ast)
TailCallBlocker blockTailCalls(this);
- QVector<QPair<Reference, ObjectPropertyValue>> computedProperties;
- QMap<QString, ObjectPropertyValue> valueMap;
-
RegisterScope scope(this);
QStringList members;
@@ -2734,14 +2731,14 @@ bool Codegen::visit(TemplateLiteral *ast)
Instruction::Add instr;
instr.lhs = temp2;
- bytecodeGenerator->addInstruction(instr);
+ bytecodeGenerator->addTracingInstruction(instr);
} else {
expr.loadInAccumulator();
}
Instruction::Add instr;
instr.lhs = temp;
- bytecodeGenerator->addInstruction(instr);
+ bytecodeGenerator->addTracingInstruction(instr);
}
auto r = Reference::fromAccumulator(this);
@@ -2999,6 +2996,7 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast,
bool savedFunctionEndsWithReturn = functionEndsWithReturn;
functionEndsWithReturn = endsWithReturn(_module, body);
+ bytecodeGenerator->setTracing(_functionContext->canUseTracingJit(), _context->arguments.size());
// reserve the js stack frame (Context & js Function & accumulator)
bytecodeGenerator->newRegisterArray(sizeof(CallData)/sizeof(Value) - 1 + _context->arguments.size());
@@ -3085,6 +3083,7 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast,
Q_ASSERT(_context == _functionContext);
bytecodeGenerator->finalize(_context);
_context->registerCountInFunction = bytecodeGenerator->registerCount();
+ _context->nTraceInfos = bytecodeGenerator->traceInfoCount();
static const bool showCode = qEnvironmentVariableIsSet("QV4_SHOW_BYTECODE");
if (showCode) {
qDebug() << "=== Bytecode for" << _context->name << "strict mode" << _context->isStrict
@@ -3185,25 +3184,28 @@ bool Codegen::visit(DoWhileStatement *ast)
RegisterScope scope(this);
- BytecodeGenerator::Label body = bytecodeGenerator->label();
+ BytecodeGenerator::Label body = bytecodeGenerator->newLabel();
BytecodeGenerator::Label cond = bytecodeGenerator->newLabel();
BytecodeGenerator::Label end = bytecodeGenerator->newLabel();
ControlFlowLoop flow(this, &end, &cond);
-
- statement(ast->statement);
- setJumpOutLocation(bytecodeGenerator, ast->statement, ast->semicolonToken);
+ bytecodeGenerator->jump().link(body);
cond.link();
+ bytecodeGenerator->addLoopStart(cond);
- TailCallBlocker blockTailCalls(this);
- if (!AST::cast<FalseLiteral *>(ast->expression)) {
- if (AST::cast<TrueLiteral *>(ast->expression))
- bytecodeGenerator->jump().link(body);
- else
- condition(ast->expression, &body, &end, false);
+ if (!AST::cast<TrueLiteral *>(ast->expression)) {
+ TailCallBlocker blockTailCalls(this);
+ condition(ast->expression, &body, &end, true);
}
+ body.link();
+ statement(ast->statement);
+ setJumpOutLocation(bytecodeGenerator, ast->statement, ast->semicolonToken);
+
+ if (!AST::cast<FalseLiteral *>(ast->expression))
+ bytecodeGenerator->jump().link(cond);
+
end.link();
return false;
@@ -3274,9 +3276,14 @@ bool Codegen::visit(ForEachStatement *ast)
}
};
ControlFlowLoop flow(this, &end, &in, cleanup);
- bytecodeGenerator->jump().link(in);
-
- BytecodeGenerator::Label body = bytecodeGenerator->label();
+ bytecodeGenerator->addLoopStart(in);
+ in.link();
+ iterator.loadInAccumulator();
+ Instruction::IteratorNext next;
+ next.value = lhsValue.stackSlot();
+ next.done = iteratorDone.stackSlot();
+ bytecodeGenerator->addInstruction(next);
+ bytecodeGenerator->addTracingJumpInstruction(Instruction::JumpTrue()).link(end);
// each iteration gets it's own context, as per spec
{
@@ -3307,20 +3314,16 @@ bool Codegen::visit(ForEachStatement *ast)
Q_UNREACHABLE();
}
+ blockTailCalls.unblock();
statement(ast->statement);
setJumpOutLocation(bytecodeGenerator, ast->statement, ast->forToken);
-
}
+ bytecodeGenerator->jump().link(in);
+
error:
- in.link();
- iterator.loadInAccumulator();
- Instruction::IteratorNext next;
- next.value = lhsValue.stackSlot();
- next.done = iteratorDone.stackSlot();
- bytecodeGenerator->addInstruction(next);
- bytecodeGenerator->addJumpInstruction(Instruction::JumpFalse()).link(body);
end.link();
+
// all execution paths need to end up here (normal loop exit, break, and exceptions) in
// order to reset the unwind handler, and to close the iterator in calse of an for-of loop.
}
@@ -3349,7 +3352,7 @@ bool Codegen::visit(ForStatement *ast)
BytecodeGenerator::Label end = bytecodeGenerator->newLabel();
ControlFlowLoop flow(this, &end, &step);
-
+ bytecodeGenerator->addLoopStart(cond);
condition(ast->condition, &body, &end, true);
body.link();
@@ -3639,16 +3642,17 @@ bool Codegen::visit(WhileStatement *ast)
return false;
RegisterScope scope(this);
- TailCallBlocker blockTailCalls(this);
BytecodeGenerator::Label start = bytecodeGenerator->newLabel();
BytecodeGenerator::Label end = bytecodeGenerator->newLabel();
BytecodeGenerator::Label cond = bytecodeGenerator->label();
ControlFlowLoop flow(this, &end, &cond);
+ bytecodeGenerator->addLoopStart(cond);
- if (!AST::cast<TrueLiteral *>(ast->expression))
+ if (!AST::cast<TrueLiteral *>(ast->expression)) {
+ TailCallBlocker blockTailCalls(this);
condition(ast->expression, &start, &end, true);
- blockTailCalls.unblock();
+ }
start.link();
statement(ast->statement);
@@ -4216,7 +4220,7 @@ void Codegen::Reference::storeAccumulator() const
Instruction::StoreElement store;
store.base = elementBase;
store.index = elementSubscript.stackSlot();
- codegen->bytecodeGenerator->addInstruction(store);
+ codegen->bytecodeGenerator->addTracingInstruction(store);
} return;
case Invalid:
case Accumulator:
@@ -4306,12 +4310,12 @@ QT_WARNING_POP
if (!scope) {
Instruction::LoadLocal load;
load.index = index;
- codegen->bytecodeGenerator->addInstruction(load);
+ codegen->bytecodeGenerator->addTracingInstruction(load);
} else {
Instruction::LoadScopedLocal load;
load.index = index;
load.scope = scope;
- codegen->bytecodeGenerator->addInstruction(load);
+ codegen->bytecodeGenerator->addTracingInstruction(load);
}
tdzCheck(requiresTDZCheck);
return;
@@ -4335,16 +4339,16 @@ QT_WARNING_POP
if (qmlGlobal) {
Instruction::LoadQmlContextPropertyLookup load;
load.index = codegen->registerQmlContextPropertyGetterLookup(nameAsIndex());
- codegen->bytecodeGenerator->addInstruction(load);
+ codegen->bytecodeGenerator->addTracingInstruction(load);
} else {
Instruction::LoadGlobalLookup load;
load.index = codegen->registerGlobalGetterLookup(nameAsIndex());
- codegen->bytecodeGenerator->addInstruction(load);
+ codegen->bytecodeGenerator->addTracingInstruction(load);
}
} else {
Instruction::LoadName load;
load.name = nameAsIndex();
- codegen->bytecodeGenerator->addInstruction(load);
+ codegen->bytecodeGenerator->addTracingInstruction(load);
}
return;
case Member:
@@ -4353,11 +4357,11 @@ QT_WARNING_POP
if (!disable_lookups && codegen->useFastLookups) {
Instruction::GetLookup load;
load.index = codegen->registerGetterLookup(propertyNameIndex);
- codegen->bytecodeGenerator->addInstruction(load);
+ codegen->bytecodeGenerator->addTracingInstruction(load);
} else {
Instruction::LoadProperty load;
load.name = propertyNameIndex;
- codegen->bytecodeGenerator->addInstruction(load);
+ codegen->bytecodeGenerator->addTracingInstruction(load);
}
return;
case Import: {
@@ -4372,7 +4376,7 @@ QT_WARNING_POP
tdzCheck(subscriptRequiresTDZCheck);
Instruction::LoadElement load;
load.base = elementBase;
- codegen->bytecodeGenerator->addInstruction(load);
+ codegen->bytecodeGenerator->addTracingInstruction(load);
} return;
case Invalid:
break;
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp
index 9ffcb81fa2..dc5466371d 100644
--- a/src/qml/compiler/qv4compileddata.cpp
+++ b/src/qml/compiler/qv4compileddata.cpp
@@ -200,7 +200,7 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine)
runtimeFunctions.resize(data->functionTableSize);
for (int i = 0 ;i < runtimeFunctions.size(); ++i) {
const QV4::CompiledData::Function *compiledFunction = data->functionAt(i);
- runtimeFunctions[i] = new QV4::Function(engine, this, compiledFunction);
+ runtimeFunctions[i] = QV4::Function::create(engine, this, compiledFunction);
}
Scope scope(engine);
@@ -317,7 +317,8 @@ void CompilationUnit::unlink()
runtimeRegularExpressions = nullptr;
free(runtimeClasses);
runtimeClasses = nullptr;
- qDeleteAll(runtimeFunctions);
+ for (QV4::Function *f : qAsConst(runtimeFunctions))
+ f->destroy();
runtimeFunctions.clear();
}
@@ -775,6 +776,8 @@ QString Binding::valueAsString(const CompilationUnit *unit) const
case Type_Script:
case Type_String:
return unit->stringAt(stringIndex);
+ case Type_Null:
+ return QStringLiteral("null");
case Type_Boolean:
return value.b ? QStringLiteral("true") : QStringLiteral("false");
case Type_Number:
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h
index 3fd9fdf74b..23e33247a8 100644
--- a/src/qml/compiler/qv4compileddata_p.h
+++ b/src/qml/compiler/qv4compileddata_p.h
@@ -73,7 +73,7 @@
QT_BEGIN_NAMESPACE
// Bump this whenever the compiler data structures change in an incompatible way.
-#define QV4_DATA_STRUCTURE_VERSION 0x20
+#define QV4_DATA_STRUCTURE_VERSION 0x21
class QIODevice;
class QQmlPropertyCache;
@@ -288,10 +288,16 @@ struct Function
quint16_le nRegisters;
Location location;
+ quint32_le nLabelInfos;
+ size_t labelInfosOffset() const { return lineNumberOffset() + nLineNumbers * sizeof(CodeOffsetToLine); }
+
+ typedef quint16_le TraceInfoCount;
+ TraceInfoCount nTraceInfos;
+ static constexpr TraceInfoCount NoTracing() { return TraceInfoCount::max(); }
+
// Keep all unaligned data at the end
quint8 flags;
quint8 padding1;
- quint16 padding2;
// quint32 formalsIndex[nFormals]
// quint32 localsIndex[nLocals]
@@ -305,10 +311,13 @@ struct Function
const quint32_le *formalsEnd() const { return formalsTable() + nFormals; }
// ---
+ const quint32_le *labelInfoTable() const { return reinterpret_cast<const quint32_le *>(reinterpret_cast<const char *>(this) + labelInfosOffset()); }
+
const char *code() const { return reinterpret_cast<const char *>(this) + codeOffset; }
- static int calculateSize(int nFormals, int nLocals, int nLines, int nInnerfunctions, int codeSize) {
- int trailingData = (nFormals + nLocals + nInnerfunctions)*sizeof (quint32) + nLines*sizeof(CodeOffsetToLine);
+ static int calculateSize(int nFormals, int nLocals, int nLines, int nInnerfunctions, int labelInfoSize, int codeSize) {
+ int trailingData = (nFormals + nLocals + nInnerfunctions + labelInfoSize)*sizeof (quint32)
+ + nLines*sizeof(CodeOffsetToLine);
size_t size = align(align(sizeof(Function)) + size_t(trailingData)) + align(codeSize);
Q_ASSERT(size < INT_MAX);
return int(size);
@@ -318,7 +327,7 @@ struct Function
return (a + 7) & ~size_t(7);
}
};
-static_assert(sizeof(Function) == 48, "Function structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
+static_assert(sizeof(Function) == 52, "Function structure needs to have the expected size to be binary compatible on disk when generated by host compiler and loaded by target");
struct Method {
enum Type {
@@ -424,6 +433,7 @@ struct Q_QML_PRIVATE_EXPORT Binding
Type_Boolean,
Type_Number,
Type_String,
+ Type_Null,
Type_Translation,
Type_TranslationById,
Type_Script,
@@ -455,6 +465,7 @@ struct Q_QML_PRIVATE_EXPORT Binding
quint32_le compiledScriptIndex; // used when Type_Script
quint32_le objectIndex;
quint32_le translationDataIndex; // used when Type_Translation
+ quint32 nullMarker;
} value;
quint32_le stringIndex; // Set for Type_String and Type_Script (the latter because of script strings)
diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp
index 4d85f25d4b..01c033cb2a 100644
--- a/src/qml/compiler/qv4compiler.cpp
+++ b/src/qml/compiler/qv4compiler.cpp
@@ -424,9 +424,15 @@ void QV4::Compiler::JSUnitGenerator::writeFunction(char *f, QV4::Compiler::Conte
Q_ASSERT(function->lineNumberOffset() == currentOffset);
currentOffset += function->nLineNumbers * sizeof(CompiledData::CodeOffsetToLine);
-
+ function->nTraceInfos = irFunction->nTraceInfos;
function->nRegisters = irFunction->registerCountInFunction;
+ if (!irFunction->labelInfo.empty()) {
+ function->nLabelInfos = quint32(irFunction->labelInfo.size());
+ Q_ASSERT(function->labelInfosOffset() == currentOffset);
+ currentOffset += function->nLabelInfos * sizeof(quint32);
+ }
+
function->location.line = irFunction->line;
function->location.column = irFunction->column;
@@ -446,6 +452,11 @@ void QV4::Compiler::JSUnitGenerator::writeFunction(char *f, QV4::Compiler::Conte
// write line numbers
memcpy(f + function->lineNumberOffset(), irFunction->lineNumberMapping.constData(), irFunction->lineNumberMapping.size()*sizeof(CompiledData::CodeOffsetToLine));
+ quint32_le *labels = (quint32_le *)(f + function->labelInfosOffset());
+ for (unsigned u : irFunction->labelInfo) {
+ *labels++ = u;
+ }
+
// write byte code
memcpy(f + function->codeOffset, irFunction->code.constData(), irFunction->code.size());
}
@@ -643,7 +654,7 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp
blockAndFunctionOffsets[i] = nextOffset;
quint32 size = QV4::CompiledData::Function::calculateSize(f->arguments.size(), f->locals.size(), f->lineNumberMapping.size(), f->nestedContexts.size(),
- f->code.size());
+ int(f->labelInfo.size()), f->code.size());
functionSize += size - f->code.size();
nextOffset += size;
}
diff --git a/src/qml/compiler/qv4compilercontext.cpp b/src/qml/compiler/qv4compilercontext.cpp
index d1a5fee92b..b9ab4e5173 100644
--- a/src/qml/compiler/qv4compilercontext.cpp
+++ b/src/qml/compiler/qv4compilercontext.cpp
@@ -410,4 +410,28 @@ void Context::setupFunctionIndices(Moth::BytecodeGenerator *bytecodeGenerator)
nRegisters = bytecodeGenerator->currentRegister() - registerOffset;
}
+bool Context::canUseTracingJit() const
+{
+#if QT_CONFIG(qml_tracing)
+ static bool forceTracing = !qEnvironmentVariableIsEmpty("QV4_FORCE_TRACING");
+ if (forceTracing) //### we can probably remove this when tracing is turned on by default
+ return true; // to be used by unittests
+
+ static bool disableTracing = !qEnvironmentVariableIsEmpty("QV4_DISABLE_TRACING");
+ if (disableTracing)
+ return false;
+
+ static QStringList onlyTrace =
+ qEnvironmentVariable("QV4_ONLY_TRACE").split(QLatin1Char(','), QString::SkipEmptyParts);
+ if (!onlyTrace.isEmpty())
+ return onlyTrace.contains(name);
+
+ //### the next condition should be refined and have the IR distinguish between escaping and
+ // non-escaping locals
+ return !hasTry && !requiresExecutionContext && !hasNestedFunctions;
+#else
+ return false;
+#endif
+}
+
QT_END_NAMESPACE
diff --git a/src/qml/compiler/qv4compilercontext_p.h b/src/qml/compiler/qv4compilercontext_p.h
index 8f3b60e395..cb20ea9d57 100644
--- a/src/qml/compiler/qv4compilercontext_p.h
+++ b/src/qml/compiler/qv4compilercontext_p.h
@@ -162,6 +162,7 @@ struct Context {
int line = 0;
int column = 0;
int registerCountInFunction = 0;
+ uint nTraceInfos = 0;
int functionIndex = -1;
int blockIndex = -1;
@@ -200,6 +201,7 @@ struct Context {
ControlFlow *controlFlow = nullptr;
QByteArray code;
QVector<CompiledData::CodeOffsetToLine> lineNumberMapping;
+ std::vector<unsigned> labelInfo;
int nRegisters = 0;
int registerOffset = -1;
@@ -362,6 +364,8 @@ struct Context {
return parent->canHaveTailCalls();
return false;
}
+
+ bool canUseTracingJit() const;
};
diff --git a/src/qml/compiler/qv4instr_moth.cpp b/src/qml/compiler/qv4instr_moth.cpp
index c6c8caffba..345f03ae8a 100644
--- a/src/qml/compiler/qv4instr_moth.cpp
+++ b/src/qml/compiler/qv4instr_moth.cpp
@@ -156,7 +156,7 @@ QString dumpRegister(int reg, int nFormals)
return QStringLiteral("(this)");
else if (reg == CallData::Argc)
return QStringLiteral("(argc)");
- reg -= CallData::OffsetCount;
+ reg -= CallData::HeaderSize();
if (reg < nFormals)
return QStringLiteral("a%1").arg(reg);
reg -= nFormals;
@@ -171,6 +171,7 @@ QString dumpArguments(int argc, int argv, int nFormals)
return QStringLiteral("(") + dumpRegister(argv, nFormals) + QStringLiteral(", ") + QString::number(argc) + QStringLiteral(")");
}
+#define TRACE_SLOT QStringLiteral(" {%1}").arg(traceSlot)
void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*startLine*/, const QVector<CompiledData::CodeOffsetToLine> &lineNumberMapping)
{
@@ -240,9 +241,9 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
MOTH_BEGIN_INSTR(LoadLocal)
if (index < nLocals)
- d << "l" << index;
+ d << "l" << index << TRACE_SLOT;
else
- d << "a" << (index - nLocals);
+ d << "a" << (index - nLocals) << TRACE_SLOT;
MOTH_END_INSTR(LoadLocal)
MOTH_BEGIN_INSTR(StoreLocal)
@@ -254,9 +255,9 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
MOTH_BEGIN_INSTR(LoadScopedLocal)
if (index < nLocals)
- d << "l" << index << "@" << scope;
+ d << "l" << index << "@" << scope << TRACE_SLOT;
else
- d << "a" << (index - nLocals) << "@" << scope;
+ d << "a" << (index - nLocals) << "@" << scope << TRACE_SLOT;
MOTH_END_INSTR(LoadScopedLocal)
MOTH_BEGIN_INSTR(StoreScopedLocal)
@@ -279,15 +280,15 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
MOTH_END_INSTR(LoadClosure)
MOTH_BEGIN_INSTR(LoadName)
- d << name;
+ d << name << TRACE_SLOT;
MOTH_END_INSTR(LoadName)
MOTH_BEGIN_INSTR(LoadGlobalLookup)
- d << index;
+ d << index << TRACE_SLOT;
MOTH_END_INSTR(LoadGlobalLookup)
MOTH_BEGIN_INSTR(LoadQmlContextPropertyLookup)
- d << index;
+ d << index << TRACE_SLOT;
MOTH_END_INSTR(LoadQmlContextPropertyLookup)
MOTH_BEGIN_INSTR(StoreNameSloppy)
@@ -299,19 +300,20 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
MOTH_END_INSTR(StoreNameStrict)
MOTH_BEGIN_INSTR(LoadElement)
- d << dumpRegister(base, nFormals) << "[acc]";
+ d << dumpRegister(base, nFormals) << "[acc]" << TRACE_SLOT;
MOTH_END_INSTR(LoadElement)
MOTH_BEGIN_INSTR(StoreElement)
- d << dumpRegister(base, nFormals) << "[" << dumpRegister(index, nFormals) << "]";
+ d << dumpRegister(base, nFormals) << "[" << dumpRegister(index, nFormals) << "]"
+ << TRACE_SLOT;
MOTH_END_INSTR(StoreElement)
MOTH_BEGIN_INSTR(LoadProperty)
- d << "acc[" << name << "]";
+ d << "acc[" << name << "]" << TRACE_SLOT;
MOTH_END_INSTR(LoadProperty)
MOTH_BEGIN_INSTR(GetLookup)
- d << "acc(" << index << ")";
+ d << "acc(" << index << ")" << TRACE_SLOT;
MOTH_END_INSTR(GetLookup)
MOTH_BEGIN_INSTR(StoreProperty)
@@ -341,51 +343,57 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
MOTH_END_INSTR(Resume)
MOTH_BEGIN_INSTR(CallValue)
- d << dumpRegister(name, nFormals) << dumpArguments(argc, argv, nFormals);
+ d << dumpRegister(name, nFormals) << dumpArguments(argc, argv, nFormals) << TRACE_SLOT;
MOTH_END_INSTR(CallValue)
MOTH_BEGIN_INSTR(CallWithReceiver)
- d << dumpRegister(name, nFormals) << dumpRegister(thisObject, nFormals) << dumpArguments(argc, argv, nFormals);
+ d << dumpRegister(name, nFormals) << dumpRegister(thisObject, nFormals)
+ << dumpArguments(argc, argv, nFormals) << TRACE_SLOT;
MOTH_END_INSTR(CallWithReceiver)
MOTH_BEGIN_INSTR(CallProperty)
- d << dumpRegister(base, nFormals) << "." << name << dumpArguments(argc, argv, nFormals);
+ d << dumpRegister(base, nFormals) << "." << name << dumpArguments(argc, argv, nFormals)
+ << TRACE_SLOT;
MOTH_END_INSTR(CallProperty)
MOTH_BEGIN_INSTR(CallPropertyLookup)
- d << dumpRegister(base, nFormals) << "." << lookupIndex << dumpArguments(argc, argv, nFormals);
+ d << dumpRegister(base, nFormals) << "." << lookupIndex
+ << dumpArguments(argc, argv, nFormals) << TRACE_SLOT;
MOTH_END_INSTR(CallPropertyLookup)
MOTH_BEGIN_INSTR(CallElement)
- d << dumpRegister(base, nFormals) << "[" << dumpRegister(index, nFormals) << "]" << dumpArguments(argc, argv, nFormals);
+ d << dumpRegister(base, nFormals) << "[" << dumpRegister(index, nFormals) << "]"
+ << dumpArguments(argc, argv, nFormals) << TRACE_SLOT;
MOTH_END_INSTR(CallElement)
MOTH_BEGIN_INSTR(CallName)
- d << name << dumpArguments(argc, argv, nFormals);
+ d << name << dumpArguments(argc, argv, nFormals) << TRACE_SLOT;
MOTH_END_INSTR(CallName)
MOTH_BEGIN_INSTR(CallPossiblyDirectEval)
- d << dumpArguments(argc, argv, nFormals);
+ d << dumpArguments(argc, argv, nFormals) << TRACE_SLOT;
MOTH_END_INSTR(CallPossiblyDirectEval)
MOTH_BEGIN_INSTR(CallGlobalLookup)
- d << index << dumpArguments(argc, argv, nFormals);
+ d << index << dumpArguments(argc, argv, nFormals) << TRACE_SLOT;
MOTH_END_INSTR(CallGlobalLookup)
MOTH_BEGIN_INSTR(CallQmlContextPropertyLookup)
- d << index << dumpArguments(argc, argv, nFormals);
+ d << index << dumpArguments(argc, argv, nFormals) << TRACE_SLOT;
MOTH_END_INSTR(CallQmlContextPropertyLookup)
MOTH_BEGIN_INSTR(CallWithSpread)
- d << "new" << dumpRegister(func, nFormals) << dumpRegister(thisObject, nFormals) << dumpArguments(argc, argv, nFormals);
+ d << "new " << dumpRegister(func, nFormals) << dumpRegister(thisObject, nFormals)
+ << dumpArguments(argc, argv, nFormals)
+ << TRACE_SLOT;
MOTH_END_INSTR(CallWithSpread)
MOTH_BEGIN_INSTR(Construct)
- d << "new" << dumpRegister(func, nFormals) << dumpArguments(argc, argv, nFormals);
+ d << "new " << dumpRegister(func, nFormals) << dumpArguments(argc, argv, nFormals);
MOTH_END_INSTR(Construct)
MOTH_BEGIN_INSTR(ConstructWithSpread)
- d << "new" << dumpRegister(func, nFormals) << dumpArguments(argc, argv, nFormals);
+ d << "new " << dumpRegister(func, nFormals) << dumpArguments(argc, argv, nFormals);
MOTH_END_INSTR(ConstructWithSpread)
MOTH_BEGIN_INSTR(SetUnwindHandler)
@@ -520,11 +528,11 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
MOTH_END_INSTR(Jump)
MOTH_BEGIN_INSTR(JumpTrue)
- d << ABSOLUTE_OFFSET();
+ d << ABSOLUTE_OFFSET() << TRACE_SLOT;
MOTH_END_INSTR(JumpTrue)
MOTH_BEGIN_INSTR(JumpFalse)
- d << ABSOLUTE_OFFSET();
+ d << ABSOLUTE_OFFSET() << TRACE_SLOT;
MOTH_END_INSTR(JumpFalse)
MOTH_BEGIN_INSTR(JumpNotUndefined)
@@ -588,19 +596,22 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
MOTH_END_INSTR(UPlus)
MOTH_BEGIN_INSTR(UMinus)
+ d << TRACE_SLOT;
MOTH_END_INSTR(UMinus)
MOTH_BEGIN_INSTR(UCompl)
MOTH_END_INSTR(UCompl)
MOTH_BEGIN_INSTR(Increment)
- MOTH_END_INSTR(PreIncrement)
+ d << TRACE_SLOT;
+ MOTH_END_INSTR(Increment)
MOTH_BEGIN_INSTR(Decrement)
- MOTH_END_INSTR(PreDecrement)
+ d << TRACE_SLOT;
+ MOTH_END_INSTR(Decrement)
MOTH_BEGIN_INSTR(Add)
- d << dumpRegister(lhs, nFormals) << ", acc";
+ d << dumpRegister(lhs, nFormals) << ", acc" << TRACE_SLOT;
MOTH_END_INSTR(Add)
MOTH_BEGIN_INSTR(BitAnd)
@@ -656,7 +667,7 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
MOTH_END_INSTR(Exp)
MOTH_BEGIN_INSTR(Mul)
- d << dumpRegister(lhs, nFormals) << ", acc";
+ d << dumpRegister(lhs, nFormals) << ", acc" << TRACE_SLOT;
MOTH_END_INSTR(Mul)
MOTH_BEGIN_INSTR(Div)
@@ -664,11 +675,11 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st
MOTH_END_INSTR(Div)
MOTH_BEGIN_INSTR(Mod)
- d << dumpRegister(lhs, nFormals) << ", acc";
+ d << dumpRegister(lhs, nFormals) << ", acc" << TRACE_SLOT;
MOTH_END_INSTR(Mod)
MOTH_BEGIN_INSTR(Sub)
- d << dumpRegister(lhs, nFormals) << ", acc";
+ d << dumpRegister(lhs, nFormals) << ", acc" << TRACE_SLOT;
MOTH_END_INSTR(Sub)
MOTH_BEGIN_INSTR(CmpIn)
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h
index 25fca3c0b0..26901c297c 100644
--- a/src/qml/compiler/qv4instr_moth_p.h
+++ b/src/qml/compiler/qv4instr_moth_p.h
@@ -77,20 +77,20 @@ QT_BEGIN_NAMESPACE
#define INSTR_StoreReg(op) INSTRUCTION(op, StoreReg, 1, reg)
#define INSTR_MoveReg(op) INSTRUCTION(op, MoveReg, 2, srcReg, destReg)
#define INSTR_LoadImport(op) INSTRUCTION(op, LoadImport, 1, index)
-#define INSTR_LoadLocal(op) INSTRUCTION(op, LoadLocal, 1, index)
+#define INSTR_LoadLocal(op) INSTRUCTION(op, LoadLocal, 2, index, traceSlot)
#define INSTR_StoreLocal(op) INSTRUCTION(op, StoreLocal, 1, index)
-#define INSTR_LoadScopedLocal(op) INSTRUCTION(op, LoadScopedLocal, 2, scope, index)
+#define INSTR_LoadScopedLocal(op) INSTRUCTION(op, LoadScopedLocal, 3, scope, index, traceSlot)
#define INSTR_StoreScopedLocal(op) INSTRUCTION(op, StoreScopedLocal, 2, scope, index)
#define INSTR_LoadRuntimeString(op) INSTRUCTION(op, LoadRuntimeString, 1, stringId)
#define INSTR_MoveRegExp(op) INSTRUCTION(op, MoveRegExp, 2, regExpId, destReg)
#define INSTR_LoadClosure(op) INSTRUCTION(op, LoadClosure, 1, value)
-#define INSTR_LoadName(op) INSTRUCTION(op, LoadName, 1, name)
-#define INSTR_LoadGlobalLookup(op) INSTRUCTION(op, LoadGlobalLookup, 1, index)
-#define INSTR_LoadQmlContextPropertyLookup(op) INSTRUCTION(op, LoadQmlContextPropertyLookup, 1, index)
+#define INSTR_LoadName(op) INSTRUCTION(op, LoadName, 2, name, traceSlot)
+#define INSTR_LoadGlobalLookup(op) INSTRUCTION(op, LoadGlobalLookup, 2, index, traceSlot)
+#define INSTR_LoadQmlContextPropertyLookup(op) INSTRUCTION(op, LoadQmlContextPropertyLookup, 2, index, traceSlot)
#define INSTR_StoreNameSloppy(op) INSTRUCTION(op, StoreNameSloppy, 1, name)
#define INSTR_StoreNameStrict(op) INSTRUCTION(op, StoreNameStrict, 1, name)
-#define INSTR_LoadProperty(op) INSTRUCTION(op, LoadProperty, 1, name)
-#define INSTR_GetLookup(op) INSTRUCTION(op, GetLookup, 1, index)
+#define INSTR_LoadProperty(op) INSTRUCTION(op, LoadProperty, 2, name, traceSlot)
+#define INSTR_GetLookup(op) INSTRUCTION(op, GetLookup, 2, index, traceSlot)
#define INSTR_LoadIdObject(op) INSTRUCTION(op, LoadIdObject, 2, index, base)
#define INSTR_Yield(op) INSTRUCTION(op, Yield, 0)
#define INSTR_YieldStar(op) INSTRUCTION(op, YieldStar, 0)
@@ -100,18 +100,18 @@ QT_BEGIN_NAMESPACE
#define INSTR_SetLookup(op) INSTRUCTION(op, SetLookup, 2, index, base)
#define INSTR_LoadSuperProperty(op) INSTRUCTION(op, LoadSuperProperty, 1, property)
#define INSTR_StoreSuperProperty(op) INSTRUCTION(op, StoreSuperProperty, 1, property)
-#define INSTR_LoadElement(op) INSTRUCTION(op, LoadElement, 1, base)
-#define INSTR_StoreElement(op) INSTRUCTION(op, StoreElement, 2, base, index)
-#define INSTR_CallValue(op) INSTRUCTION(op, CallValue, 3, name, argc, argv)
-#define INSTR_CallWithReceiver(op) INSTRUCTION(op, CallWithReceiver, 4, name, thisObject, argc, argv)
-#define INSTR_CallProperty(op) INSTRUCTION(op, CallProperty, 4, name, base, argc, argv)
-#define INSTR_CallPropertyLookup(op) INSTRUCTION(op, CallPropertyLookup, 4, lookupIndex, base, argc, argv)
-#define INSTR_CallElement(op) INSTRUCTION(op, CallElement, 4, base, index, argc, argv)
-#define INSTR_CallName(op) INSTRUCTION(op, CallName, 3, name, argc, argv)
-#define INSTR_CallPossiblyDirectEval(op) INSTRUCTION(op, CallPossiblyDirectEval, 2, argc, argv)
-#define INSTR_CallGlobalLookup(op) INSTRUCTION(op, CallGlobalLookup, 3, index, argc, argv)
-#define INSTR_CallQmlContextPropertyLookup(op) INSTRUCTION(op, CallQmlContextPropertyLookup, 3, index, argc, argv)
-#define INSTR_CallWithSpread(op) INSTRUCTION(op, CallWithSpread, 4, func, thisObject, argc, argv)
+#define INSTR_LoadElement(op) INSTRUCTION(op, LoadElement, 2, base, traceSlot)
+#define INSTR_StoreElement(op) INSTRUCTION(op, StoreElement, 3, base, index, traceSlot)
+#define INSTR_CallValue(op) INSTRUCTION(op, CallValue, 4, name, argc, argv, traceSlot)
+#define INSTR_CallWithReceiver(op) INSTRUCTION(op, CallWithReceiver, 5, name, thisObject, argc, argv, traceSlot)
+#define INSTR_CallProperty(op) INSTRUCTION(op, CallProperty, 5, name, base, argc, argv, traceSlot)
+#define INSTR_CallPropertyLookup(op) INSTRUCTION(op, CallPropertyLookup, 5, lookupIndex, base, argc, argv, traceSlot)
+#define INSTR_CallElement(op) INSTRUCTION(op, CallElement, 5, base, index, argc, argv, traceSlot)
+#define INSTR_CallName(op) INSTRUCTION(op, CallName, 4, name, argc, argv, traceSlot)
+#define INSTR_CallPossiblyDirectEval(op) INSTRUCTION(op, CallPossiblyDirectEval, 3, argc, argv, traceSlot)
+#define INSTR_CallGlobalLookup(op) INSTRUCTION(op, CallGlobalLookup, 4, index, argc, argv, traceSlot)
+#define INSTR_CallQmlContextPropertyLookup(op) INSTRUCTION(op, CallQmlContextPropertyLookup, 4, index, argc, argv, traceSlot)
+#define INSTR_CallWithSpread(op) INSTRUCTION(op, CallWithSpread, 5, func, thisObject, argc, argv, traceSlot)
#define INSTR_Construct(op) INSTRUCTION(op, Construct, 3, func, argc, argv)
#define INSTR_ConstructWithSpread(op) INSTRUCTION(op, ConstructWithSpread, 3, func, argc, argv)
#define INSTR_SetUnwindHandler(op) INSTRUCTION(op, SetUnwindHandler, 1, offset)
@@ -148,8 +148,8 @@ QT_BEGIN_NAMESPACE
#define INSTR_LoadSuperConstructor(op) INSTRUCTION(op, LoadSuperConstructor, 0)
#define INSTR_ToObject(op) INSTRUCTION(op, ToObject, 0)
#define INSTR_Jump(op) INSTRUCTION(op, Jump, 1, offset)
-#define INSTR_JumpTrue(op) INSTRUCTION(op, JumpTrue, 1, offset)
-#define INSTR_JumpFalse(op) INSTRUCTION(op, JumpFalse, 1, offset)
+#define INSTR_JumpTrue(op) INSTRUCTION(op, JumpTrue, 2, traceSlot, offset)
+#define INSTR_JumpFalse(op) INSTRUCTION(op, JumpFalse, 2, traceSlot, offset)
#define INSTR_JumpNotUndefined(op) INSTRUCTION(op, JumpNotUndefined, 1, offset)
#define INSTR_JumpNoException(op) INSTRUCTION(op, JumpNoException, 1, offset)
#define INSTR_CmpEqNull(op) INSTRUCTION(op, CmpEqNull, 0)
@@ -168,11 +168,11 @@ QT_BEGIN_NAMESPACE
#define INSTR_CmpInstanceOf(op) INSTRUCTION(op, CmpInstanceOf, 1, lhs)
#define INSTR_UNot(op) INSTRUCTION(op, UNot, 0)
#define INSTR_UPlus(op) INSTRUCTION(op, UPlus, 0)
-#define INSTR_UMinus(op) INSTRUCTION(op, UMinus, 0)
+#define INSTR_UMinus(op) INSTRUCTION(op, UMinus, 1, traceSlot)
#define INSTR_UCompl(op) INSTRUCTION(op, UCompl, 0)
-#define INSTR_Increment(op) INSTRUCTION(op, Increment, 0)
-#define INSTR_Decrement(op) INSTRUCTION(op, Decrement, 0)
-#define INSTR_Add(op) INSTRUCTION(op, Add, 1, lhs)
+#define INSTR_Increment(op) INSTRUCTION(op, Increment, 1, traceSlot)
+#define INSTR_Decrement(op) INSTRUCTION(op, Decrement, 1, traceSlot)
+#define INSTR_Add(op) INSTRUCTION(op, Add, 2, lhs, traceSlot)
#define INSTR_BitAnd(op) INSTRUCTION(op, BitAnd, 1, lhs)
#define INSTR_BitOr(op) INSTRUCTION(op, BitOr, 1, lhs)
#define INSTR_BitXor(op) INSTRUCTION(op, BitXor, 1, lhs)
@@ -186,10 +186,10 @@ QT_BEGIN_NAMESPACE
#define INSTR_ShrConst(op) INSTRUCTION(op, ShrConst, 1, rhs)
#define INSTR_ShlConst(op) INSTRUCTION(op, ShlConst, 1, rhs)
#define INSTR_Exp(op) INSTRUCTION(op, Exp, 1, lhs)
-#define INSTR_Mul(op) INSTRUCTION(op, Mul, 1, lhs)
+#define INSTR_Mul(op) INSTRUCTION(op, Mul, 2, lhs, traceSlot)
#define INSTR_Div(op) INSTRUCTION(op, Div, 1, lhs)
-#define INSTR_Mod(op) INSTRUCTION(op, Mod, 1, lhs)
-#define INSTR_Sub(op) INSTRUCTION(op, Sub, 1, lhs)
+#define INSTR_Mod(op) INSTRUCTION(op, Mod, 2, lhs, traceSlot)
+#define INSTR_Sub(op) INSTRUCTION(op, Sub, 2, lhs, traceSlot)
#define INSTR_LoadQmlImportedScripts(op) INSTRUCTION(op, LoadQmlImportedScripts, 1, result)
#define INSTR_InitializeBlockDeadTemporalZone(op) INSTRUCTION(op, InitializeBlockDeadTemporalZone, 2, firstReg, count)
#define INSTR_ThrowOnNullOrUndefined(op) INSTRUCTION(op, ThrowOnNullOrUndefined, 0)
@@ -334,12 +334,18 @@ QT_BEGIN_NAMESPACE
#define MOTH_NUM_INSTRUCTIONS() (static_cast<int>(Moth::Instr::Type::Debug_Wide) + 1)
-#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL)
+#if defined(Q_CC_GNU)
+#if defined(Q_CC_INTEL)
// icc before version 1200 doesn't support computed goto, and at least up to version 18.0.0 the
// current use results in an internal compiler error. We could enable this if/when it gets fixed
// in a later version.
+# elif defined(Q_OS_WASM) && !defined(__asmjs)
+// Upstream llvm does not support computed goto for the wasm target, unlike the 'fastcomp' llvm fork
+// shipped with the emscripten SDK. Disable computed goto usage for non-fastcomp llvm on Wasm.
+#else
# define MOTH_COMPUTED_GOTO
#endif
+#endif
#define MOTH_INSTR_ALIGN_MASK (Q_ALIGNOF(QV4::Moth::Instr) - 1)
@@ -365,6 +371,12 @@ QT_BEGIN_NAMESPACE
int arg2; \
int arg3; \
int arg4;
+#define MOTH_DEFINE_ARGS5(arg1, arg2, arg3, arg4, arg5) \
+ int arg1; \
+ int arg2; \
+ int arg3; \
+ int arg4; \
+ int arg5;
#define MOTH_COLLECT_ENUMS(instr) \
INSTR_##instr(MOTH_GET_ENUM)
@@ -435,6 +447,9 @@ QT_BEGIN_NAMESPACE
#define MOTH_DECODE_ARGS4(name, type, nargs, arg1, arg2, arg3, arg4) \
MOTH_DECODE_ARGS3(name, type, nargs, arg1, arg2, arg3); \
MOTH_DECODE_ARG(arg4, type, nargs, 3);
+#define MOTH_DECODE_ARGS5(name, type, nargs, arg1, arg2, arg3, arg4, arg5) \
+ MOTH_DECODE_ARGS4(name, type, nargs, arg1, arg2, arg3, arg4); \
+ MOTH_DECODE_ARG(arg5, type, nargs, 4);
#ifdef MOTH_COMPUTED_GOTO
/* collect jump labels */
diff --git a/src/qml/configure.json b/src/qml/configure.json
index 17d1f800ac..c35f5be06b 100644
--- a/src/qml/configure.json
+++ b/src/qml/configure.json
@@ -8,6 +8,7 @@
"commandline": {
"options": {
"qml-network": "boolean",
+ "qml-tracing": "boolean",
"qml-debug": "boolean"
}
},
@@ -39,6 +40,13 @@
"condition": "features.network",
"output": [ "publicFeature" ]
},
+ "qml-tracing": {
+ "label": "QML tracing JIT support",
+ "purpose": "Provides a JIT that uses trace information generated by the interpreter.",
+ "section": "QML",
+ "output": [ "privateFeature" ],
+ "autoDetect": false
+ },
"qml-debug": {
"label": "QML debugging and profiling support",
"purpose": "Provides infrastructure and plugins for debugging and profiling.",
@@ -132,6 +140,7 @@
"entries": [
"qml-network",
"qml-debug",
+ "qml-tracing",
"qml-sequence-object",
"qml-list-model",
"qml-xml-http-request",
diff --git a/src/qml/debugger/qqmldebug.cpp b/src/qml/debugger/qqmldebug.cpp
index 6246fb4207..6532576e03 100644
--- a/src/qml/debugger/qqmldebug.cpp
+++ b/src/qml/debugger/qqmldebug.cpp
@@ -44,16 +44,16 @@
#include <private/qqmlengine_p.h>
#include <private/qv4compileddata_p.h>
+#include <cstdio>
+
QT_REQUIRE_CONFIG(qml_debug);
QT_BEGIN_NAMESPACE
QQmlDebuggingEnabler::QQmlDebuggingEnabler(bool printWarning)
{
- if (!QQmlEnginePrivate::qml_debugging_enabled
- && printWarning) {
- qDebug("QML debugging is enabled. Only use this in a safe environment.");
- }
+ if (!QQmlEnginePrivate::qml_debugging_enabled && printWarning)
+ fprintf(stderr, "QML debugging is enabled. Only use this in a safe environment.\n");
QQmlEnginePrivate::qml_debugging_enabled = true;
}
diff --git a/src/qml/doc/snippets/qml/integrating-javascript/includejs/app.qml b/src/qml/doc/snippets/qml/integrating-javascript/includejs/app.qml
index 5339fcddce..e2104f8740 100644
--- a/src/qml/doc/snippets/qml/integrating-javascript/includejs/app.qml
+++ b/src/qml/doc/snippets/qml/integrating-javascript/includejs/app.qml
@@ -49,7 +49,7 @@
****************************************************************************/
//![0]
import QtQuick 2.0
-import "script.js" as MyScript
+import "script.mjs" as MyScript
Item {
width: 100; height: 100
diff --git a/src/qml/doc/snippets/qml/integrating-javascript/includejs/factorial.js b/src/qml/doc/snippets/qml/integrating-javascript/includejs/factorial.mjs
index f2e31265e3..d0a09b68ad 100644
--- a/src/qml/doc/snippets/qml/integrating-javascript/includejs/factorial.js
+++ b/src/qml/doc/snippets/qml/integrating-javascript/includejs/factorial.mjs
@@ -48,8 +48,8 @@
**
****************************************************************************/
//![0]
-// factorial.js
-function factorial(a) {
+// factorial.mjs
+export function factorial(a) {
a = parseInt(a);
if (a <= 0)
return 1;
diff --git a/src/qml/doc/snippets/qml/integrating-javascript/includejs/script.js b/src/qml/doc/snippets/qml/integrating-javascript/includejs/script.mjs
index c44b39abda..ef7688693d 100644
--- a/src/qml/doc/snippets/qml/integrating-javascript/includejs/script.js
+++ b/src/qml/doc/snippets/qml/integrating-javascript/includejs/script.mjs
@@ -49,7 +49,7 @@
****************************************************************************/
//![0]
// script.js
-Qt.include("factorial.js")
+import { factorial } from "factorial.mjs"
function showCalculations(value) {
console.log(
diff --git a/src/qml/doc/src/cppintegration/data.qdoc b/src/qml/doc/src/cppintegration/data.qdoc
index 8ebbd28737..171b2b6a11 100644
--- a/src/qml/doc/src/cppintegration/data.qdoc
+++ b/src/qml/doc/src/cppintegration/data.qdoc
@@ -284,6 +284,9 @@ In particular, QML currently supports:
\li \c {std::vector<bool>}
\endlist
+and all registered QList, QVector, QQueue, QStack, QSet, QLinkedList, std::list,
+std::vector that contain a type marked with \l Q_DECLARE_METATYPE.
+
These sequence types are implemented directly in terms of the underlying C++
sequence. There are two ways in which such sequences can be exposed to QML:
as a Q_PROPERTY of the given sequence type; or as the return type of a
diff --git a/src/qml/doc/src/javascript/imports.qdoc b/src/qml/doc/src/javascript/imports.qdoc
index 7da2cd22fe..974f2e154f 100644
--- a/src/qml/doc/src/javascript/imports.qdoc
+++ b/src/qml/doc/src/javascript/imports.qdoc
@@ -99,9 +99,44 @@ A JavaScript resource may import another in the following fashion:
\endcode
For example:
\code
-.import "factorial.js" as MathFunctions
+import * as MathFunctions from "factorial.mjs";
\endcode
+The latter is standard ECMAScript syntax for importing ECMAScript modules, and
+only works from within ECMAScript modules as denoted by the \c mjs file
+extension. The former is an extension to JavaScript provided by the \c QML
+engine and will work also with non-modules.
+
+When a JavaScript file is imported this way, it is imported with a qualifier.
+The functions in that file are then accessible from the importing script via the
+qualifier (that is, as \tt{Qualifier.functionName(params)}).
+
+Sometimes it is desirable to have the functions made available in the importing
+context without needing to qualify them. In this case ECMAScript modules and the
+JavaScript \c import statement should be used without the \c as qualifier.
+
+For example, the QML code below left calls \c showCalculations() in \c script.mjs,
+which in turn can call \c factorial() in \c factorial.mjs, as it has included
+\c factorial.mjs using \c import.
+
+\table
+\row
+\li {1,2} \snippet qml/integrating-javascript/includejs/app.qml 0
+\li \snippet qml/integrating-javascript/includejs/script.mjs 0
+\row
+\li \snippet qml/integrating-javascript/includejs/factorial.mjs 0
+\endtable
+
+The \l{QtQml::Qt::include()} {Qt.include()} function includes one JavaScript
+file from another without using ECMAScript modules and without qualifying the
+import. It makes all functions and variables from the other file available in
+the current file's namespace, but ignores all pragmas and imports defined in
+that file. This is not a good idea as a function call should never modify the
+caller's context.
+
+\l{QtQml::Qt::include()} {Qt.include()} is deprecated and should be avoided. It
+will be removed in a future version of Qt.
+
\section2 Importing a QML Module from a JavaScript Resource
A JavaScript resource may import a QML module in the following fashion:
@@ -119,32 +154,4 @@ via a singleton type; see qmlRegisterSingletonType() for more information.
\note The .import syntax doesn't work for scripts used in the \l {WorkerScript}
-\section1 Including a JavaScript Resource from Another JavaScript Resource
-
-When a JavaScript file is imported, it must be imported with a qualifier. The
-functions in that file are then accessible from the importing script via the
-qualifier (that is, as \tt{Qualifier.functionName(params)}). Sometimes it is
-desirable to have the functions made available in the importing context without
-needing to qualify them, and in this circumstance the \l{QtQml::Qt::include()}
-{Qt.include()} function may be used to include one JavaScript file from another.
-This copies all functions from the other file into the current file's
-namespace, but ignores all pragmas and imports defined in that file.
-
-For example, the QML code below left calls \c showCalculations() in \c script.js,
-which in turn can call \c factorial() in \c factorial.js, as it has included
-\c factorial.js using \l {QtQml::Qt::include()}{Qt.include()}.
-
-\table
-\row
-\li {1,2} \snippet qml/integrating-javascript/includejs/app.qml 0
-\li \snippet qml/integrating-javascript/includejs/script.js 0
-\row
-\li \snippet qml/integrating-javascript/includejs/factorial.js 0
-\endtable
-
-Notice that calling \l {QtQml::Qt::include()}{Qt.include()} copies all functions
-from \c factorial.js into the \c MyScript namespace, which means the QML
-component can also access \c factorial() directly as \c MyScript.factorial().
-
-
*/
diff --git a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc
index 2bb1fcac61..15e8e4c52c 100644
--- a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc
+++ b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc
@@ -540,6 +540,58 @@ Internally, however, the rectangle can correctly set its \c color
property and refer to the actual defined property rather than the alias.
+\section4 Property Aliases and Types
+
+Property aliases cannot have explicit type specifications. The type of a
+property alias is the \e declared type of the property or object it refers to.
+Therefore, if you create an alias to an object referenced via id with extra
+properties declared inline, the extra properties won't be accessible through
+the alias:
+
+\code
+// MyItem.qml
+Item {
+ property alias inner: innerItem
+
+ Item {
+ id: innerItem
+ property int extraProperty
+ }
+}
+\code
+
+You cannot initialize \a inner.extraProperty from outside of this component, as
+inner is only an \a Item:
+
+\code
+// main.qml
+MyItem {
+ inner.extraProperty: 5 // fails
+}
+\code
+
+However, if you extract the inner object into a separate component with a
+dedicated .qml file, you can instantiate that component instead and have all
+its properties available through the alias:
+
+\code
+// MainItem.qml
+Item {
+ // Now you can access inner.extraProperty, as inner is now an ExtraItem
+ property alias inner: innerItem
+
+ ExtraItem {
+ id: innerItem
+ }
+}
+
+// ExtraItem.qml
+Item {
+ property int extraProperty
+}
+\code
+
+
\section3 Default Properties
An object definition can have a single \e default property. A default property
diff --git a/src/qml/doc/src/statemachine.qdoc b/src/qml/doc/src/statemachine.qdoc
index 6986f1baa0..231b85af76 100644
--- a/src/qml/doc/src/statemachine.qdoc
+++ b/src/qml/doc/src/statemachine.qdoc
@@ -27,7 +27,7 @@
/*!
\qmlmodule QtQml.StateMachine 1.\QtMinorVersion
- \title Declarative State Machine QML Types
+ \title Qt QML State Machine QML Types
\brief Provides QML types to create and execute state graphs.
The following is a list of QML types provided by the module:
@@ -322,7 +322,7 @@
\section1 Related Information
\list
- \li \l{Declarative State Machine QML Types}
+ \li \l{Qt QML State Machine QML Types}
\li \l{The State Machine Framework}
\endlist
*/
diff --git a/src/qml/jit/qv4assemblercommon.cpp b/src/qml/jit/qv4assemblercommon.cpp
index 831496a628..dd810d9d70 100644
--- a/src/qml/jit/qv4assemblercommon.cpp
+++ b/src/qml/jit/qv4assemblercommon.cpp
@@ -39,10 +39,12 @@
#include <QBuffer>
#include <QFile>
+#include <QLoggingCategory>
#include "qv4engine_p.h"
#include "qv4assemblercommon_p.h"
#include <private/qv4function_p.h>
+#include <private/qv4functiontable_p.h>
#include <private/qv4runtime_p.h>
#include <assembler/MacroAssemblerCodeRef.h>
@@ -57,6 +59,8 @@ QT_BEGIN_NAMESPACE
namespace QV4 {
namespace JIT {
+Q_LOGGING_CATEGORY(lcAsm, "qt.v4.asm")
+
namespace {
class QIODevicePrintStream: public FilePrintStream
{
@@ -109,18 +113,9 @@ static void printDisassembledOutputWithCalls(QByteArray processedOutput,
}
}
- qDebug("%s", processedOutput.constData());
-}
-
-static QByteArray functionName(Function *function)
-{
- QByteArray name = function->name()->toQString().toUtf8();
- if (name.isEmpty()) {
- name = QByteArray::number(reinterpret_cast<quintptr>(function), 16);
- name.prepend("QV4::Function(0x");
- name.append(')');
- }
- return name;
+ auto lines = processedOutput.split('\n');
+ for (const auto &line : lines)
+ qCDebug(lcAsm, "%s", line.constData());
}
JIT::PlatformAssemblerCommon::~PlatformAssemblerCommon()
@@ -141,13 +136,15 @@ void PlatformAssemblerCommon::link(Function *function, const char *jitKind)
JSC::MacroAssemblerCodeRef codeRef;
- static const bool showCode = qEnvironmentVariableIsSet("QV4_SHOW_ASM");
+ static const bool showCode = lcAsm().isDebugEnabled();
if (showCode) {
QBuffer buf;
buf.open(QIODevice::WriteOnly);
WTF::setDataFile(new QIODevicePrintStream(&buf));
- QByteArray name = functionName(function);
+ // We use debugAddress here because it's actually for debugging and hidden behind an
+ // environment variable.
+ const QByteArray name = Function::prettyName(function, linkBuffer.debugAddress()).toUtf8();
codeRef = linkBuffer.finalizeCodeWithDisassembly(jitKind, "function %s", name.constData());
WTF::setDataFile(stderr);
@@ -159,31 +156,9 @@ void PlatformAssemblerCommon::link(Function *function, const char *jitKind)
function->codeRef = new JSC::MacroAssemblerCodeRef(codeRef);
function->jittedCode = reinterpret_cast<Function::JittedCode>(function->codeRef->code().executableAddress());
- // This implements writing of JIT'd addresses so that perf can find the
- // symbol names.
- //
- // Perf expects the mapping to be in a certain place and have certain
- // content, for more information, see:
- // https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/jit-interface.txt
- static bool doProfile = !qEnvironmentVariableIsEmpty("QV4_PROFILE_WRITE_PERF_MAP");
- if (Q_UNLIKELY(doProfile)) {
- static QFile perfMapFile(QString::fromLatin1("/tmp/perf-%1.map")
- .arg(QCoreApplication::applicationPid()));
- static const bool isOpen = perfMapFile.open(QIODevice::WriteOnly);
- if (!isOpen) {
- qWarning("QV4::JIT::Assembler: Cannot write perf map file.");
- doProfile = false;
- } else {
- perfMapFile.write(QByteArray::number(reinterpret_cast<quintptr>(
- codeRef.code().executableAddress()), 16));
- perfMapFile.putChar(' ');
- perfMapFile.write(QByteArray::number(static_cast<qsizetype>(codeRef.size()), 16));
- perfMapFile.putChar(' ');
- perfMapFile.write(functionName(function));
- perfMapFile.putChar('\n');
- perfMapFile.flush();
- }
- }
+ generateFunctionTable(function, &codeRef);
+
+ linkBuffer.makeExecutable();
}
void PlatformAssemblerCommon::prepareCallWithArgCount(int argc)
@@ -316,6 +291,19 @@ void PlatformAssemblerCommon::passInt32AsArg(int value, int arg)
store32(TrustedImm32(value), argStackAddress(arg));
}
+void JIT::PlatformAssemblerCommon::passPointerAsArg(void *ptr, int arg)
+{
+#ifndef QT_NO_DEBUG
+ Q_ASSERT(arg < remainingArgcForCall);
+ --remainingArgcForCall;
+#endif
+
+ if (arg < ArgInRegCount)
+ move(TrustedImmPtr(ptr), registerForArg(arg));
+ else
+ storePtr(TrustedImmPtr(ptr), argStackAddress(arg));
+}
+
void PlatformAssemblerCommon::callRuntime(const char *functionName, const void *funcPtr)
{
#ifndef QT_NO_DEBUG
diff --git a/src/qml/jit/qv4assemblercommon_p.h b/src/qml/jit/qv4assemblercommon_p.h
index 729d0fc53d..d3d7eedae2 100644
--- a/src/qml/jit/qv4assemblercommon_p.h
+++ b/src/qml/jit/qv4assemblercommon_p.h
@@ -587,7 +587,7 @@ public:
Address loadCompilationUnitPtr(RegisterID target)
{
Address addr = loadFunctionPtr(target);
- addr.offset = offsetof(QV4::Function, compilationUnit);
+ addr.offset = offsetof(QV4::FunctionData, compilationUnit);
loadPtr(addr, target);
return Address(target);
}
@@ -670,7 +670,8 @@ public:
void addLabelForOffset(int offset)
{
- labelForOffset.insert(offset, label());
+ if (!labelForOffset.contains(offset))
+ labelForOffset.insert(offset, label());
}
void addJumpToOffset(const Jump &jump, int offset)
@@ -699,6 +700,7 @@ public:
void passAddressAsArg(Address addr, int arg);
void passCppFrameAsArg(int arg);
void passInt32AsArg(int value, int arg);
+ void passPointerAsArg(void *ptr, int arg);
void callRuntime(const char *functionName, const void *funcPtr);
void callRuntimeUnchecked(const char *functionName, const void *funcPtr);
void tailCallRuntime(const char *functionName, const void *funcPtr);
diff --git a/src/qml/jit/qv4baselineassembler.cpp b/src/qml/jit/qv4baselineassembler.cpp
index b13f646360..25c74e74e8 100644
--- a/src/qml/jit/qv4baselineassembler.cpp
+++ b/src/qml/jit/qv4baselineassembler.cpp
@@ -1382,28 +1382,31 @@ void BaselineAssembler::cmpStrictNotEqual(int lhs)
pasm()->setAccumulatorTag(QV4::Value::ValueTypeInternal::Boolean);
}
-void BaselineAssembler::jump(int offset)
+int BaselineAssembler::jump(int offset)
{
pasm()->addJumpToOffset(pasm()->jump(), offset);
+ return offset;
}
-void BaselineAssembler::jumpTrue(int offset)
+int BaselineAssembler::jumpTrue(int offset)
{
pasm()->toBoolean([this, offset](PlatformAssembler::RegisterID resultReg) {
auto jump = pasm()->branch32(PlatformAssembler::NotEqual, TrustedImm32(0), resultReg);
pasm()->addJumpToOffset(jump, offset);
});
+ return offset;
}
-void BaselineAssembler::jumpFalse(int offset)
+int BaselineAssembler::jumpFalse(int offset)
{
pasm()->toBoolean([this, offset](PlatformAssembler::RegisterID resultReg) {
auto jump = pasm()->branch32(PlatformAssembler::Equal, TrustedImm32(0), resultReg);
pasm()->addJumpToOffset(jump, offset);
});
+ return offset;
}
-void BaselineAssembler::jumpNoException(int offset)
+int BaselineAssembler::jumpNoException(int offset)
{
auto jump = pasm()->branch32(
PlatformAssembler::Equal,
@@ -1411,11 +1414,13 @@ void BaselineAssembler::jumpNoException(int offset)
offsetof(EngineBase, hasException)),
TrustedImm32(0));
pasm()->addJumpToOffset(jump, offset);
+ return offset;
}
-void BaselineAssembler::jumpNotUndefined(int offset)
+int BaselineAssembler::jumpNotUndefined(int offset)
{
pasm()->jumpNotUndefined(offset);
+ return offset;
}
void BaselineAssembler::prepareCallWithArgCount(int argc)
@@ -1458,6 +1463,11 @@ void BaselineAssembler::passInt32AsArg(int value, int arg)
pasm()->passInt32AsArg(value, arg);
}
+void BaselineAssembler::passPointerAsArg(void *ptr, int arg)
+{
+ pasm()->passPointerAsArg(ptr, arg);
+}
+
void BaselineAssembler::callRuntime(const char *functionName, const void *funcPtr, CallResultDestination dest)
{
pasm()->callRuntime(functionName, funcPtr, dest);
@@ -1534,10 +1544,11 @@ void BaselineAssembler::setException()
noException.link(pasm());
}
-void BaselineAssembler::setUnwindHandler(int offset)
+int BaselineAssembler::setUnwindHandler(int offset)
{
auto l = pasm()->storePtrWithPatch(TrustedImmPtr(nullptr), pasm()->exceptionHandlerAddress());
pasm()->addEHTarget(l, offset);
+ return offset;
}
@@ -1563,12 +1574,13 @@ void JIT::BaselineAssembler::unwindDispatch()
noUnwind.link(pasm());
}
-void JIT::BaselineAssembler::unwindToLabel(int level, int offset)
+int JIT::BaselineAssembler::unwindToLabel(int level, int offset)
{
auto l = pasm()->storePtrWithPatch(TrustedImmPtr(nullptr), Address(PlatformAssembler::CppStackFrameRegister, offsetof(CppStackFrame, unwindLabel)));
pasm()->addEHTarget(l, offset);
pasm()->store32(TrustedImm32(level), Address(PlatformAssembler::CppStackFrameRegister, offsetof(CppStackFrame, unwindLevel)));
gotoCatchException();
+ return offset;
}
void BaselineAssembler::pushCatchContext(int index, int name)
diff --git a/src/qml/jit/qv4baselineassembler_p.h b/src/qml/jit/qv4baselineassembler_p.h
index 0aa508ae71..c39d002bf9 100644
--- a/src/qml/jit/qv4baselineassembler_p.h
+++ b/src/qml/jit/qv4baselineassembler_p.h
@@ -135,11 +135,11 @@ public:
void cmpStrictNotEqual(int lhs);
// jumps
- void jump(int offset);
- void jumpTrue(int offset);
- void jumpFalse(int offset);
- void jumpNoException(int offset);
- void jumpNotUndefined(int offset);
+ Q_REQUIRED_RESULT int jump(int offset);
+ Q_REQUIRED_RESULT int jumpTrue(int offset);
+ Q_REQUIRED_RESULT int jumpFalse(int offset);
+ Q_REQUIRED_RESULT int jumpNoException(int offset);
+ Q_REQUIRED_RESULT int jumpNotUndefined(int offset);
// stuff for runtime calls
void prepareCallWithArgCount(int argc);
@@ -150,6 +150,7 @@ public:
void passJSSlotAsArg(int reg, int arg);
void passCppFrameAsArg(int arg);
void passInt32AsArg(int value, int arg);
+ void passPointerAsArg(void *ptr, int arg);
void callRuntime(const char *functionName, const void *funcPtr, CallResultDestination dest);
void saveAccumulatorInFrame();
void jsTailCall(int func, int thisObject, int argc, int argv);
@@ -159,10 +160,10 @@ public:
void gotoCatchException();
void getException();
void setException();
- void setUnwindHandler(int offset);
+ Q_REQUIRED_RESULT int setUnwindHandler(int offset);
void clearUnwindHandler();
void unwindDispatch();
- void unwindToLabel(int level, int offset);
+ Q_REQUIRED_RESULT int unwindToLabel(int level, int offset);
void pushCatchContext(int index, int name);
void popContext();
void deadTemporalZoneCheck(int offsetForSavedIP, int variableName);
diff --git a/src/qml/jit/qv4baselinejit.cpp b/src/qml/jit/qv4baselinejit.cpp
index 1e4288e3c9..e518fc5a0e 100644
--- a/src/qml/jit/qv4baselinejit.cpp
+++ b/src/qml/jit/qv4baselinejit.cpp
@@ -63,7 +63,9 @@ void BaselineJIT::generate()
// qDebug()<<"jitting" << function->name()->toQString();
const char *code = function->codeData;
uint len = function->compiledFunction->codeSize;
- labels = collectLabelsInBytecode(code, len);
+
+ for (unsigned i = 0, ei = function->compiledFunction->nLabelInfos; i != ei; ++i)
+ labels.insert(int(function->compiledFunction->labelInfoTable()[i]));
as->generatePrologue();
decode(code, len);
@@ -149,7 +151,7 @@ void BaselineJIT::generate_LoadImport(int index)
as->loadImport(index);
}
-void BaselineJIT::generate_LoadLocal(int index)
+void BaselineJIT::generate_LoadLocal(int index, int /*traceSlot*/)
{
as->loadLocal(index);
}
@@ -160,7 +162,7 @@ void BaselineJIT::generate_StoreLocal(int index)
as->storeLocal(index);
}
-void BaselineJIT::generate_LoadScopedLocal(int scope, int index)
+void BaselineJIT::generate_LoadScopedLocal(int scope, int index, int /*traceSlot*/)
{
as->loadLocal(index, scope);
}
@@ -193,7 +195,7 @@ void BaselineJIT::generate_LoadClosure(int value)
BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_closure, CallResultDestination::InAccumulator);
}
-void BaselineJIT::generate_LoadName(int name)
+void BaselineJIT::generate_LoadName(int name, int /*traceSlot*/)
{
STORE_IP();
as->prepareCallWithArgCount(2);
@@ -203,7 +205,7 @@ void BaselineJIT::generate_LoadName(int name)
as->checkException();
}
-void BaselineJIT::generate_LoadGlobalLookup(int index)
+void BaselineJIT::generate_LoadGlobalLookup(int index, int /*traceSlot*/)
{
as->prepareCallWithArgCount(3);
as->passInt32AsArg(index, 2);
@@ -213,7 +215,7 @@ void BaselineJIT::generate_LoadGlobalLookup(int index)
as->checkException();
}
-void BaselineJIT::generate_LoadQmlContextPropertyLookup(int index)
+void BaselineJIT::generate_LoadQmlContextPropertyLookup(int index, int /*traceSlot*/)
{
as->prepareCallWithArgCount(3);
as->passInt32AsArg(index, 2);
@@ -247,7 +249,7 @@ void BaselineJIT::generate_StoreNameStrict(int name)
as->checkException();
}
-void BaselineJIT::generate_LoadElement(int base)
+void BaselineJIT::generate_LoadElement(int base, int /*traceSlot*/)
{
STORE_IP();
STORE_ACC();
@@ -259,7 +261,7 @@ void BaselineJIT::generate_LoadElement(int base)
as->checkException();
}
-void BaselineJIT::generate_StoreElement(int base, int index)
+void BaselineJIT::generate_StoreElement(int base, int index, int /*traceSlot*/)
{
STORE_IP();
STORE_ACC();
@@ -272,7 +274,7 @@ void BaselineJIT::generate_StoreElement(int base, int index)
as->checkException();
}
-void BaselineJIT::generate_LoadProperty(int name)
+void BaselineJIT::generate_LoadProperty(int name, int /*traceSlot*/)
{
STORE_IP();
STORE_ACC();
@@ -284,7 +286,7 @@ void BaselineJIT::generate_LoadProperty(int name)
as->checkException();
}
-void BaselineJIT::generate_GetLookup(int index)
+void BaselineJIT::generate_GetLookup(int index, int /*traceSlot*/)
{
STORE_IP();
STORE_ACC();
@@ -365,7 +367,7 @@ void BaselineJIT::generate_Resume(int)
Q_UNREACHABLE();
}
-void BaselineJIT::generate_CallValue(int name, int argc, int argv)
+void BaselineJIT::generate_CallValue(int name, int argc, int argv, int /*traceSlot*/)
{
STORE_IP();
as->prepareCallWithArgCount(4);
@@ -377,7 +379,7 @@ void BaselineJIT::generate_CallValue(int name, int argc, int argv)
as->checkException();
}
-void BaselineJIT::generate_CallWithReceiver(int name, int thisObject, int argc, int argv)
+void BaselineJIT::generate_CallWithReceiver(int name, int thisObject, int argc, int argv, int /*traceSlot*/)
{
STORE_IP();
as->prepareCallWithArgCount(5);
@@ -390,7 +392,7 @@ void BaselineJIT::generate_CallWithReceiver(int name, int thisObject, int argc,
as->checkException();
}
-void BaselineJIT::generate_CallProperty(int name, int base, int argc, int argv)
+void BaselineJIT::generate_CallProperty(int name, int base, int argc, int argv, int /*traceSlot*/)
{
STORE_IP();
as->prepareCallWithArgCount(5);
@@ -403,7 +405,7 @@ void BaselineJIT::generate_CallProperty(int name, int base, int argc, int argv)
as->checkException();
}
-void BaselineJIT::generate_CallPropertyLookup(int lookupIndex, int base, int argc, int argv)
+void BaselineJIT::generate_CallPropertyLookup(int lookupIndex, int base, int argc, int argv, int /*traceSlot*/)
{
STORE_IP();
as->prepareCallWithArgCount(5);
@@ -416,7 +418,7 @@ void BaselineJIT::generate_CallPropertyLookup(int lookupIndex, int base, int arg
as->checkException();
}
-void BaselineJIT::generate_CallElement(int base, int index, int argc, int argv)
+void BaselineJIT::generate_CallElement(int base, int index, int argc, int argv, int /*traceSlot*/)
{
STORE_IP();
as->prepareCallWithArgCount(5);
@@ -429,7 +431,7 @@ void BaselineJIT::generate_CallElement(int base, int index, int argc, int argv)
as->checkException();
}
-void BaselineJIT::generate_CallName(int name, int argc, int argv)
+void BaselineJIT::generate_CallName(int name, int argc, int argv, int /*traceSlot*/)
{
STORE_IP();
as->prepareCallWithArgCount(4);
@@ -441,7 +443,7 @@ void BaselineJIT::generate_CallName(int name, int argc, int argv)
as->checkException();
}
-void BaselineJIT::generate_CallPossiblyDirectEval(int argc, int argv)
+void BaselineJIT::generate_CallPossiblyDirectEval(int argc, int argv, int /*traceSlot*/)
{
STORE_IP();
as->prepareCallWithArgCount(3);
@@ -452,7 +454,7 @@ void BaselineJIT::generate_CallPossiblyDirectEval(int argc, int argv)
as->checkException();
}
-void BaselineJIT::generate_CallGlobalLookup(int index, int argc, int argv)
+void BaselineJIT::generate_CallGlobalLookup(int index, int argc, int argv, int /*traceSlot*/)
{
STORE_IP();
as->prepareCallWithArgCount(4);
@@ -464,7 +466,8 @@ void BaselineJIT::generate_CallGlobalLookup(int index, int argc, int argv)
as->checkException();
}
-void BaselineJIT::generate_CallQmlContextPropertyLookup(int index, int argc, int argv)
+void BaselineJIT::generate_CallQmlContextPropertyLookup(int index, int argc, int argv,
+ int /*traceSlot*/)
{
STORE_IP();
as->prepareCallWithArgCount(4);
@@ -476,7 +479,7 @@ void BaselineJIT::generate_CallQmlContextPropertyLookup(int index, int argc, int
as->checkException();
}
-void BaselineJIT::generate_CallWithSpread(int func, int thisObject, int argc, int argv)
+void BaselineJIT::generate_CallWithSpread(int func, int thisObject, int argc, int argv, int /*traceSlot*/)
{
STORE_IP();
as->prepareCallWithArgCount(5);
@@ -526,7 +529,7 @@ void BaselineJIT::generate_ConstructWithSpread(int func, int argc, int argv)
void BaselineJIT::generate_SetUnwindHandler(int offset)
{
if (offset)
- as->setUnwindHandler(absoluteOffsetForJump(offset));
+ labels.insert(as->setUnwindHandler(absoluteOffset(offset)));
else
as->clearUnwindHandler();
}
@@ -538,7 +541,7 @@ void BaselineJIT::generate_UnwindDispatch()
void BaselineJIT::generate_UnwindToLabel(int level, int offset)
{
- as->unwindToLabel(level, absoluteOffsetForJump(offset));
+ labels.insert(as->unwindToLabel(level, absoluteOffset(offset)));
}
void BaselineJIT::generate_DeadTemporalZoneCheck(int name)
@@ -805,11 +808,30 @@ void BaselineJIT::generate_ToObject()
}
-void BaselineJIT::generate_Jump(int offset) { as->jump(absoluteOffsetForJump(offset)); }
-void BaselineJIT::generate_JumpTrue(int offset) { as->jumpTrue(absoluteOffsetForJump(offset)); }
-void BaselineJIT::generate_JumpFalse(int offset) { as->jumpFalse(absoluteOffsetForJump(offset)); }
-void BaselineJIT::generate_JumpNoException(int offset) { as->jumpNoException(absoluteOffsetForJump(offset)); }
-void BaselineJIT::generate_JumpNotUndefined(int offset) { as->jumpNotUndefined(absoluteOffsetForJump(offset)); }
+void BaselineJIT::generate_Jump(int offset)
+{
+ labels.insert(as->jump(absoluteOffset(offset)));
+}
+
+void BaselineJIT::generate_JumpTrue(int /*traceSlot*/, int offset)
+{
+ labels.insert(as->jumpTrue(absoluteOffset(offset)));
+}
+
+void BaselineJIT::generate_JumpFalse(int /*traceSlot*/, int offset)
+{
+ labels.insert(as->jumpFalse(absoluteOffset(offset)));
+}
+
+void BaselineJIT::generate_JumpNoException(int offset)
+{
+ labels.insert(as->jumpNoException(absoluteOffset(offset)));
+}
+
+void BaselineJIT::generate_JumpNotUndefined(int offset)
+{
+ labels.insert(as->jumpNotUndefined(absoluteOffset(offset)));
+}
void BaselineJIT::generate_CmpEqNull() { as->cmpeqNull(); }
void BaselineJIT::generate_CmpNeNull() { as->cmpneNull(); }
@@ -848,11 +870,11 @@ void BaselineJIT::generate_CmpInstanceOf(int lhs)
void BaselineJIT::generate_UNot() { as->unot(); }
void BaselineJIT::generate_UPlus() { as->toNumber(); }
-void BaselineJIT::generate_UMinus() { as->uminus(); }
+void BaselineJIT::generate_UMinus(int /*traceSlot*/) { as->uminus(); }
void BaselineJIT::generate_UCompl() { as->ucompl(); }
-void BaselineJIT::generate_Increment() { as->inc(); }
-void BaselineJIT::generate_Decrement() { as->dec(); }
-void BaselineJIT::generate_Add(int lhs) { as->add(lhs); }
+void BaselineJIT::generate_Increment(int /*traceSlot*/) { as->inc(); }
+void BaselineJIT::generate_Decrement(int /*traceSlot*/) { as->dec(); }
+void BaselineJIT::generate_Add(int lhs, int /*traceSlot*/) { as->add(lhs); }
void BaselineJIT::generate_BitAnd(int lhs) { as->bitAnd(lhs); }
void BaselineJIT::generate_BitOr(int lhs) { as->bitOr(lhs); }
@@ -877,10 +899,10 @@ void BaselineJIT::generate_Exp(int lhs) {
BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::exp, CallResultDestination::InAccumulator);
as->checkException();
}
-void BaselineJIT::generate_Mul(int lhs) { as->mul(lhs); }
+void BaselineJIT::generate_Mul(int lhs, int /*traceSlot*/) { as->mul(lhs); }
void BaselineJIT::generate_Div(int lhs) { as->div(lhs); }
-void BaselineJIT::generate_Mod(int lhs) { as->mod(lhs); }
-void BaselineJIT::generate_Sub(int lhs) { as->sub(lhs); }
+void BaselineJIT::generate_Mod(int lhs, int /*traceSlot*/) { as->mod(lhs); }
+void BaselineJIT::generate_Sub(int lhs, int /*traceSlot*/) { as->sub(lhs); }
//void BaselineJIT::generate_BinopContext(int alu, int lhs)
//{
@@ -923,7 +945,7 @@ void BaselineJIT::generate_GetTemplateObject(int index)
void BaselineJIT::startInstruction(Instr::Type /*instr*/)
{
- if (hasLabel())
+ if (labels.contains(currentInstructionOffset()))
as->addLabel(currentInstructionOffset());
}
diff --git a/src/qml/jit/qv4baselinejit_p.h b/src/qml/jit/qv4baselinejit_p.h
index 6646eb713e..10c89bc74b 100644
--- a/src/qml/jit/qv4baselinejit_p.h
+++ b/src/qml/jit/qv4baselinejit_p.h
@@ -88,22 +88,22 @@ public:
void generate_StoreReg(int reg) override;
void generate_MoveReg(int srcReg, int destReg) override;
void generate_LoadImport(int index) override;
- void generate_LoadLocal(int index) override;
+ void generate_LoadLocal(int index, int traceSlot) override;
void generate_StoreLocal(int index) override;
- void generate_LoadScopedLocal(int scope, int index) override;
+ void generate_LoadScopedLocal(int scope, int index, int traceSlot) override;
void generate_StoreScopedLocal(int scope, int index) override;
void generate_LoadRuntimeString(int stringId) override;
void generate_MoveRegExp(int regExpId, int destReg) override;
void generate_LoadClosure(int value) override;
- void generate_LoadName(int name) override;
- void generate_LoadGlobalLookup(int index) override;
- void generate_LoadQmlContextPropertyLookup(int index) override;
+ void generate_LoadName(int name, int traceSlot) override;
+ void generate_LoadGlobalLookup(int index, int traceSlot) override;
+ void generate_LoadQmlContextPropertyLookup(int index, int traceSlot) override;
void generate_StoreNameSloppy(int name) override;
void generate_StoreNameStrict(int name) override;
- void generate_LoadElement(int base) override;
- void generate_StoreElement(int base, int index) override;
- void generate_LoadProperty(int name) override;
- void generate_GetLookup(int index) override;
+ void generate_LoadElement(int base, int traceSlot) override;
+ void generate_StoreElement(int base, int index, int traceSlot) override;
+ void generate_LoadProperty(int name, int traceSlot) override;
+ void generate_GetLookup(int index, int traceSlot) override;
void generate_StoreProperty(int name, int base) override;
void generate_SetLookup(int index, int base) override;
void generate_LoadSuperProperty(int property) override;
@@ -112,16 +112,16 @@ public:
void generate_YieldStar() override;
void generate_Resume(int) override;
- void generate_CallValue(int name, int argc, int argv) override;
- void generate_CallWithReceiver(int name, int thisObject, int argc, int argv) override;
- void generate_CallProperty(int name, int base, int argc, int argv) override;
- void generate_CallPropertyLookup(int lookupIndex, int base, int argc, int argv) override;
- void generate_CallElement(int base, int index, int argc, int argv) override;
- void generate_CallName(int name, int argc, int argv) override;
- void generate_CallPossiblyDirectEval(int argc, int argv) override;
- void generate_CallGlobalLookup(int index, int argc, int argv) override;
- void generate_CallQmlContextPropertyLookup(int index, int argc, int argv) override;
- void generate_CallWithSpread(int func, int thisObject, int argc, int argv) override;
+ void generate_CallValue(int name, int argc, int argv, int traceSlot) override;
+ void generate_CallWithReceiver(int name, int thisObject, int argc, int argv, int traceSlot) override;
+ void generate_CallProperty(int name, int base, int argc, int argv, int traceSlot) override;
+ void generate_CallPropertyLookup(int lookupIndex, int base, int argc, int argv, int traceSlot) override;
+ void generate_CallElement(int base, int index, int argc, int argv, int traceSlot) override;
+ void generate_CallName(int name, int argc, int argv, int traceSlot) override;
+ void generate_CallPossiblyDirectEval(int argc, int argv, int traceSlot) override;
+ void generate_CallGlobalLookup(int index, int argc, int argv, int traceSlot) override;
+ void generate_CallQmlContextPropertyLookup(int index, int argc, int argv, int traceSlot) override;
+ void generate_CallWithSpread(int func, int thisObject, int argc, int argv, int traceSlot) override;
void generate_TailCall(int func, int thisObject, int argc, int argv) override;
void generate_Construct(int func, int argc, int argv) override;
void generate_ConstructWithSpread(int func, int argc, int argv) override;
@@ -160,8 +160,8 @@ public:
void generate_LoadSuperConstructor() override;
void generate_ToObject() override;
void generate_Jump(int offset) override;
- void generate_JumpTrue(int offset) override;
- void generate_JumpFalse(int offset) override;
+ void generate_JumpTrue(int traceSlot, int offset) override;
+ void generate_JumpFalse(int traceSlot, int offset) override;
void generate_JumpNoException(int offset) override;
void generate_JumpNotUndefined(int offset) override;
void generate_CmpEqNull() override;
@@ -180,11 +180,11 @@ public:
void generate_CmpInstanceOf(int lhs) override;
void generate_UNot() override;
void generate_UPlus() override;
- void generate_UMinus() override;
+ void generate_UMinus(int traceSlot) override;
void generate_UCompl() override;
- void generate_Increment() override;
- void generate_Decrement() override;
- void generate_Add(int lhs) override;
+ void generate_Increment(int traceSlot) override;
+ void generate_Decrement(int traceSlot) override;
+ void generate_Add(int lhs, int traceSlot) override;
void generate_BitAnd(int lhs) override;
void generate_BitOr(int lhs) override;
void generate_BitXor(int lhs) override;
@@ -198,10 +198,10 @@ public:
void generate_ShrConst(int rhs) override;
void generate_ShlConst(int rhs) override;
void generate_Exp(int lhs) override;
- void generate_Mul(int lhs) override;
+ void generate_Mul(int lhs, int traceSlot) override;
void generate_Div(int lhs) override;
- void generate_Mod(int lhs) override;
- void generate_Sub(int lhs) override;
+ void generate_Mod(int lhs, int traceSlot) override;
+ void generate_Sub(int lhs, int traceSlot) override;
void generate_InitializeBlockDeadTemporalZone(int firstReg, int count) override;
void generate_ThrowOnNullOrUndefined() override;
void generate_GetTemplateObject(int index) override;
@@ -209,17 +209,10 @@ public:
void startInstruction(Moth::Instr::Type instr) override;
void endInstruction(Moth::Instr::Type instr) override;
-protected:
- bool hasLabel() const
- { return std::find(labels.cbegin(), labels.cend(), currentInstructionOffset()) != labels.cend(); }
-
- int absoluteOffsetForJump(int relativeOffset) const
- { return nextInstructionOffset() + relativeOffset; }
-
private:
QV4::Function *function;
QScopedPointer<BaselineAssembler> as;
- std::vector<int> labels;
+ QSet<int> labels;
};
#endif // V4_ENABLE_JIT
diff --git a/src/qml/jsruntime/jsruntime.pri b/src/qml/jsruntime/jsruntime.pri
index 5ec55b960b..a24ee0a188 100644
--- a/src/qml/jsruntime/jsruntime.pri
+++ b/src/qml/jsruntime/jsruntime.pri
@@ -147,7 +147,8 @@ HEADERS += \
$$PWD/qv4value_p.h \
$$PWD/qv4string_p.h \
$$PWD/qv4util_p.h \
- $$PWD/qv4value_p.h
+ $$PWD/qv4value_p.h \
+ $$PWD/qv4functiontable_p.h
SOURCES += \
$$PWD/qv4engine.cpp \
@@ -156,6 +157,23 @@ SOURCES += \
$$PWD/qv4value.cpp \
$$PWD/qv4executableallocator.cpp
+qmldevtools_build {
+ SOURCES += \
+ $$PWD/qv4functiontable_noop.cpp
+} else:win32 {
+ !winrt:equals(QT_ARCH, x86_64) {
+ SOURCES += \
+ $$PWD/qv4functiontable_win64.cpp
+ } else {
+ SOURCES += \
+ $$PWD/qv4functiontable_noop.cpp
+ }
+} else {
+ SOURCES += \
+ $$PWD/qv4functiontable_unix.cpp
+}
+
+
valgrind {
DEFINES += V4_USE_VALGRIND
}
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index a13fb37a52..21c6a5d06b 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -670,17 +670,17 @@ static inline QString ToTimeString(double t)
static inline QString ToLocaleString(double t)
{
- return ToDateTime(t, Qt::LocalTime).toString(Qt::LocaleDate);
+ return ToDateTime(t, Qt::LocalTime).toString(Qt::DefaultLocaleShortDate);
}
static inline QString ToLocaleDateString(double t)
{
- return ToDateTime(t, Qt::LocalTime).date().toString(Qt::LocaleDate);
+ return ToDateTime(t, Qt::LocalTime).date().toString(Qt::DefaultLocaleShortDate);
}
static inline QString ToLocaleTimeString(double t)
{
- return ToDateTime(t, Qt::LocalTime).time().toString(Qt::LocaleDate);
+ return ToDateTime(t, Qt::LocalTime).time().toString(Qt::DefaultLocaleShortDate);
}
static double getLocalTZA()
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index bcd577c24d..f506e4015e 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -50,6 +50,7 @@
#include <QDateTime>
#include <QDir>
#include <QFileInfo>
+#include <QLoggingCategory>
#ifndef V4_BOOTSTRAP
@@ -134,6 +135,8 @@
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcTracingAll, "qt.v4.tracing.all")
+
using namespace QV4;
#ifndef V4_BOOTSTRAP
@@ -652,6 +655,13 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine)
ExecutionEngine::~ExecutionEngine()
{
+ if (Q_UNLIKELY(lcTracingAll().isDebugEnabled())) {
+ for (auto cu : compilationUnits) {
+ for (auto f : qAsConst(cu->runtimeFunctions))
+ qCDebug(lcTracingAll).noquote().nospace() << f->traceInfoToString();
+ }
+ }
+
modules.clear();
delete m_multiplyWrappedQObjects;
m_multiplyWrappedQObjects = nullptr;
@@ -1616,6 +1626,22 @@ static QV4::ReturnedValue variantListToJS(QV4::ExecutionEngine *v4, const QVaria
return a.asReturnedValue();
}
+// Converts a QSequentialIterable to JS.
+// The result is a new Array object with length equal to the length
+// of the QSequentialIterable, and the elements being the QSequentialIterable's
+// elements converted to JS, recursively.
+static QV4::ReturnedValue sequentialIterableToJS(QV4::ExecutionEngine *v4, const QSequentialIterable &lst)
+{
+ QV4::Scope scope(v4);
+ QV4::ScopedArrayObject a(scope, v4->newArrayObject());
+ a->arrayReserve(lst.size());
+ QV4::ScopedValue v(scope);
+ for (int i = 0; i < lst.size(); i++)
+ a->arrayPut(i, (v = variantToJS(v4, lst.at(i))));
+ a->setArrayLengthUnchecked(lst.size());
+ return a.asReturnedValue();
+}
+
// Converts a QVariantMap to JS.
// The result is a new Object object with property names being
// the keys of the QVariantMap, and values being the values of
@@ -1720,9 +1746,18 @@ QV4::ReturnedValue ExecutionEngine::metaTypeToJS(int type, const void *data)
return QV4::Encode::null();
}
QMetaType mt(type);
- if (mt.flags() & QMetaType::IsGadget) {
- Q_ASSERT(mt.metaObject());
- return QV4::QQmlValueTypeWrapper::create(this, QVariant(type, data), mt.metaObject(), type);
+ if (auto metaObject = mt.metaObject()) {
+ auto flags = mt.flags();
+ if (flags & QMetaType::IsGadget) {
+ return QV4::QQmlValueTypeWrapper::create(this, QVariant(type, data), metaObject, type);
+ } else if (flags & QMetaType::PointerToQObject) {
+ return QV4::QObjectWrapper::wrap(this, *reinterpret_cast<QObject* const *>(data));
+ }
+ }
+ if (QMetaType::hasRegisteredConverterFunction(type, qMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>())) {
+ auto v = QVariant(type, data);
+ QSequentialIterable lst = v.value<QSequentialIterable>();
+ return sequentialIterableToJS(this, lst);
}
// Fall back to wrapping in a QVariant.
return QV4::Encode(newVariantObject(QVariant(type, data)));
diff --git a/src/qml/jsruntime/qv4executableallocator.cpp b/src/qml/jsruntime/qv4executableallocator.cpp
index 6f04a712e6..c836d121e3 100644
--- a/src/qml/jsruntime/qv4executableallocator.cpp
+++ b/src/qml/jsruntime/qv4executableallocator.cpp
@@ -38,17 +38,23 @@
****************************************************************************/
#include "qv4executableallocator_p.h"
+#include "qv4functiontable_p.h"
#include <wtf/StdLibExtras.h>
#include <wtf/PageAllocation.h>
using namespace QV4;
-void *ExecutableAllocator::Allocation::start() const
+void *ExecutableAllocator::Allocation::exceptionHandler() const
{
return reinterpret_cast<void*>(addr);
}
+void *ExecutableAllocator::Allocation::start() const
+{
+ return reinterpret_cast<void*>(addr + exceptionHandlerSize());
+}
+
void ExecutableAllocator::Allocation::deallocate(ExecutableAllocator *allocator)
{
if (isValid())
@@ -162,7 +168,7 @@ ExecutableAllocator::Allocation *ExecutableAllocator::allocate(size_t size)
Allocation *allocation = nullptr;
// Code is best aligned to 16-byte boundaries.
- size = WTF::roundUpToMultipleOf(16, size);
+ size = WTF::roundUpToMultipleOf(16, size + exceptionHandlerSize());
QMultiMap<size_t, Allocation*>::Iterator it = freeAllocations.lowerBound(size);
if (it != freeAllocations.end()) {
diff --git a/src/qml/jsruntime/qv4executableallocator_p.h b/src/qml/jsruntime/qv4executableallocator_p.h
index 375c9a365f..013c6d7120 100644
--- a/src/qml/jsruntime/qv4executableallocator_p.h
+++ b/src/qml/jsruntime/qv4executableallocator_p.h
@@ -86,6 +86,7 @@ public:
, free(true)
{}
+ void *exceptionHandler() const;
void *start() const;
void invalidate() { addr = 0; }
bool isValid() const { return addr != 0; }
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp
index 51a9b92967..1bd4329fe8 100644
--- a/src/qml/jsruntime/qv4function.cpp
+++ b/src/qml/jsruntime/qv4function.cpp
@@ -46,6 +46,7 @@
#include "qv4lookup_p.h"
#include <private/qv4mm_p.h>
#include <private/qv4identifiertable_p.h>
+#include <private/qv4functiontable_p.h>
#include <assembler/MacroAssemblerCodeRef.h>
#include <private/qv4vme_moth_p.h>
#include <private/qqmlglobal_p.h>
@@ -72,12 +73,29 @@ ReturnedValue Function::call(const Value *thisObject, const Value *argv, int arg
return result;
}
+Function *Function::create(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function)
+{
+ quint16 traceSlotCount = 0;
+#if QT_CONFIG(qml_tracing)
+ traceSlotCount = function->nTraceInfos == CompiledData::Function::NoTracing()
+ ? 1
+ : function->nTraceInfos;
+#endif
+ quint8 *storage = new quint8[sizeof(Function) + traceSlotCount];
+ return new(storage) Function(engine, unit, function);
+}
+
+void Function::destroy()
+{
+ delete[] reinterpret_cast<quint8 *>(this);
+}
+
Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function)
- : compiledFunction(function)
- , compilationUnit(unit)
+ : FunctionData(unit)
+ , compiledFunction(function)
, codeData(function->code())
- , jittedCode(nullptr)
- , codeRef(nullptr)
+ , jittedCode(nullptr)
+ , codeRef(nullptr)
{
Scope scope(engine);
Scoped<InternalClass> ic(scope, engine->internalClasses(EngineBase::Class_CallContext));
@@ -93,11 +111,21 @@ Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit,
internalClass = ic->d();
nFormals = compiledFunction->nFormals;
+
+#if QT_CONFIG(qml_tracing)
+ if (tracingEnabled()) {
+ for (uint i = 0; i < function->nTraceInfos; ++i)
+ *traceInfo(i) = 0;
+ }
+#endif
}
Function::~Function()
{
- delete codeRef;
+ if (codeRef) {
+ destroyFunctionTable(this, codeRef);
+ delete codeRef;
+ }
}
void Function::updateInternalClass(ExecutionEngine *engine, const QList<QByteArray> &parameters)
@@ -144,9 +172,38 @@ void Function::updateInternalClass(ExecutionEngine *engine, const QList<QByteArr
nFormals = parameters.size();
}
+QString Function::prettyName(const Function *function, const void *code)
+{
+ QString prettyName = function ? function->name()->toQString() : QString();
+ if (prettyName.isEmpty()) {
+ prettyName = QString::number(reinterpret_cast<quintptr>(code), 16);
+ prettyName.prepend(QLatin1String("QV4::Function(0x"));
+ prettyName.append(QLatin1Char(')'));
+ }
+ return prettyName;
+}
+
QQmlSourceLocation Function::sourceLocation() const
{
return QQmlSourceLocation(sourceFile(), compiledFunction->location.line, compiledFunction->location.column);
}
+QString Function::traceInfoToString()
+{
+ QString info = QLatin1String("=== Trace information for ") + name()->toQString() + QLatin1Char(':');
+ if (!tracingEnabled())
+ return info + QStringLiteral(" disabled. Interpreter call count: %1\n").arg(interpreterCallCount);
+ if (compiledFunction->nTraceInfos == 0)
+ return info + QLatin1String(" none.\n");
+
+ info += QLatin1Char('\n');
+ for (uint i = 0, ei = compiledFunction->nTraceInfos; i < ei; ++i) {
+ auto bits = QString::number(*traceInfo(i), 2);
+ if (bits.size() < 8)
+ bits.prepend(QString(8 - bits.size(), '0'));
+ info += QStringLiteral(" %1: %2\n").arg(QString::number(i), bits);
+ }
+ return info;
+}
+
QT_END_NAMESPACE
diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h
index 62c5d24fc4..f8125a58f8 100644
--- a/src/qml/jsruntime/qv4function_p.h
+++ b/src/qml/jsruntime/qv4function_p.h
@@ -64,10 +64,24 @@ struct QQmlSourceLocation;
namespace QV4 {
-struct Q_QML_EXPORT Function {
- const CompiledData::Function *compiledFunction;
+struct Q_QML_EXPORT FunctionData {
CompiledData::CompilationUnit *compilationUnit;
+ FunctionData(CompiledData::CompilationUnit *compilationUnit)
+ : compilationUnit(compilationUnit)
+ {}
+};
+// Make sure this class can be accessed through offsetof (done by the assemblers):
+Q_STATIC_ASSERT(std::is_standard_layout< FunctionData >::value);
+
+struct Q_QML_EXPORT Function : public FunctionData {
+private:
+ Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function);
+ ~Function();
+
+public:
+ const CompiledData::Function *compiledFunction;
+
ReturnedValue call(const Value *thisObject, const Value *argv, int argc, const ExecutionContext *context);
const char *codeData;
@@ -82,15 +96,18 @@ struct Q_QML_EXPORT Function {
int interpreterCallCount = 0;
bool isEval = false;
- Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function);
- ~Function();
+ static Function *create(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function);
+ void destroy();
// used when dynamically assigning signal handlers (QQmlConnection)
void updateInternalClass(ExecutionEngine *engine, const QList<QByteArray> &parameters);
- inline Heap::String *name() {
+ inline Heap::String *name() const {
return compilationUnit->runtimeStrings[compiledFunction->nameIndex];
}
+
+ static QString prettyName(const Function *function, const void *address);
+
inline QString sourceFile() const { return compilationUnit->fileName(); }
inline QUrl finalUrl() const { return compilationUnit->finalUrl(); }
@@ -106,6 +123,31 @@ struct Q_QML_EXPORT Function {
return nullptr;
return compilationUnit->runtimeFunctions[compiledFunction->nestedFunctionIndex];
}
+
+ Q_NEVER_INLINE QString traceInfoToString();
+
+ quint8 *traceInfo(uint i)
+ {
+#if QT_CONFIG(qml_tracing)
+ Q_ASSERT((tracingEnabled() && i < traceInfoCount()) || (i == 0));
+ return reinterpret_cast<quint8 *>(this) + sizeof(Function) + i;
+#else
+ Q_UNUSED(i);
+ return nullptr;
+#endif
+ }
+
+ quint32 traceInfoCount() const
+ { return compiledFunction->nTraceInfos; }
+
+ bool tracingEnabled() const
+ {
+#if QT_CONFIG(qml_tracing)
+ return traceInfoCount() != CompiledData::Function::NoTracing();
+#else
+ return false;
+#endif
+ }
};
}
diff --git a/src/qml/jsruntime/qv4functiontable_noop.cpp b/src/qml/jsruntime/qv4functiontable_noop.cpp
new file mode 100644
index 0000000000..31c198eb00
--- /dev/null
+++ b/src/qml/jsruntime/qv4functiontable_noop.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 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 "qv4functiontable_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+
+void generateFunctionTable(Function *function, JSC::MacroAssemblerCodeRef *codeRef)
+{
+ Q_UNUSED(function);
+ Q_UNUSED(codeRef);
+}
+
+void destroyFunctionTable(Function *function, JSC::MacroAssemblerCodeRef *codeRef)
+{
+ Q_UNUSED(function);
+ Q_UNUSED(codeRef);
+}
+
+size_t exceptionHandlerSize()
+{
+ return 0;
+}
+
+} // QV4
+
+QT_END_NAMESPACE
diff --git a/src/qml/jsruntime/qv4functiontable_p.h b/src/qml/jsruntime/qv4functiontable_p.h
new file mode 100644
index 0000000000..69e3d2bdd5
--- /dev/null
+++ b/src/qml/jsruntime/qv4functiontable_p.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 QV4FUNCTIONTABLE_P_H
+#define QV4FUNCTIONTABLE_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.
+//
+
+#include "qv4global_p.h"
+
+namespace JSC {
+class MacroAssemblerCodeRef;
+}
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+
+struct Function;
+
+void generateFunctionTable(Function *function, JSC::MacroAssemblerCodeRef *codeRef);
+void destroyFunctionTable(Function *function, JSC::MacroAssemblerCodeRef *codeRef);
+
+size_t exceptionHandlerSize();
+
+}
+
+QT_END_NAMESPACE
+
+#endif // QV4FUNCTIONTABLE_P_H
diff --git a/src/qml/jsruntime/qv4functiontable_unix.cpp b/src/qml/jsruntime/qv4functiontable_unix.cpp
new file mode 100644
index 0000000000..25b5c27161
--- /dev/null
+++ b/src/qml/jsruntime/qv4functiontable_unix.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 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 "qv4functiontable_p.h"
+#include "qv4function_p.h"
+
+#include <assembler/MacroAssemblerCodeRef.h>
+
+#include <QtCore/qfile.h>
+#include <QtCore/qcoreapplication.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+
+void generateFunctionTable(Function *function, JSC::MacroAssemblerCodeRef *codeRef)
+{
+ // This implements writing of JIT'd addresses so that perf can find the
+ // symbol names.
+ //
+ // Perf expects the mapping to be in a certain place and have certain
+ // content, for more information, see:
+ // https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/jit-interface.txt
+ static bool doProfile = !qEnvironmentVariableIsEmpty("QV4_PROFILE_WRITE_PERF_MAP");
+ if (Q_UNLIKELY(doProfile)) {
+ static QFile perfMapFile(QString::fromLatin1("/tmp/perf-%1.map")
+ .arg(QCoreApplication::applicationPid()));
+ static const bool isOpen = perfMapFile.open(QIODevice::WriteOnly);
+ if (!isOpen) {
+ qWarning("QV4::JIT::Assembler: Cannot write perf map file.");
+ doProfile = false;
+ } else {
+ const void *address = codeRef->code().executableAddress();
+ perfMapFile.write(QByteArray::number(reinterpret_cast<quintptr>(address), 16));
+ perfMapFile.putChar(' ');
+ perfMapFile.write(QByteArray::number(static_cast<qsizetype>(codeRef->size()), 16));
+ perfMapFile.putChar(' ');
+ perfMapFile.write(Function::prettyName(function, address).toUtf8());
+ perfMapFile.putChar('\n');
+ perfMapFile.flush();
+ }
+ }
+}
+
+void destroyFunctionTable(Function *function, JSC::MacroAssemblerCodeRef *codeRef)
+{
+ Q_UNUSED(function);
+ Q_UNUSED(codeRef);
+
+ // It's not advisable to remove things from the perf map file, as it's primarily used to analyze
+ // a trace after the application has terminated. We want to know about all functions that were
+ // ever jitted then. If the memory ranges overlap, we will have a problem when analyzing the
+ // trace. The JIT should try to avoid this.
+}
+
+size_t exceptionHandlerSize()
+{
+ return 0;
+}
+
+} // QV4
+
+QT_END_NAMESPACE
diff --git a/src/qml/jsruntime/qv4functiontable_win64.cpp b/src/qml/jsruntime/qv4functiontable_win64.cpp
new file mode 100644
index 0000000000..fc13dc2602
--- /dev/null
+++ b/src/qml/jsruntime/qv4functiontable_win64.cpp
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 "qv4functiontable_p.h"
+
+#include <assembler/MacroAssemblerCodeRef.h>
+
+#include <QtCore/qdebug.h>
+
+#include <windows.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+
+enum UnwindOpcode: UINT8
+{
+ UWOP_PUSH_NONVOL = 0, /* info == register number */
+ UWOP_ALLOC_LARGE, /* no info, alloc size in next 2 slots */
+ UWOP_ALLOC_SMALL, /* info == size of allocation / 8 - 1 */
+ UWOP_SET_FPREG, /* no info, FP = RSP + UNWIND_INFO.FPRegOffset*16 */
+ UWOP_SAVE_NONVOL, /* info == register number, offset in next slot */
+ UWOP_SAVE_NONVOL_FAR, /* info == register number, offset in next 2 slots */
+ UWOP_SAVE_XMM128 = 8, /* info == XMM reg number, offset in next slot */
+ UWOP_SAVE_XMM128_FAR, /* info == XMM reg number, offset in next 2 slots */
+ UWOP_PUSH_MACHFRAME /* info == 0: no error-code, 1: error-code */
+};
+
+enum Register : UINT8
+{
+ RAX = 0,
+ RCX,
+ RDX,
+ RBX,
+ RSP,
+ RBP,
+ RSI,
+ RDI,
+ NONE = 15
+};
+
+struct UnwindCode
+{
+ UnwindCode(UINT8 offset, UnwindOpcode operation, Register info)
+ : offset(offset), operation(operation), info(info)
+ {}
+
+ UINT8 offset;
+ UINT8 operation: 4;
+ UINT8 info: 4;
+};
+
+struct UnwindInfo
+{
+ UINT8 Version : 3;
+ UINT8 Flags : 5;
+ UINT8 SizeOfProlog;
+ UINT8 CountOfUnwindCodes;
+ UINT8 FrameRegister : 4;
+ UINT8 FrameRegisterOffset : 4;
+ UnwindCode UnwindCodes[2];
+};
+
+struct ExceptionHandlerRecord
+{
+ RUNTIME_FUNCTION handler;
+ UnwindInfo info;
+};
+
+void generateFunctionTable(Function *, JSC::MacroAssemblerCodeRef *codeRef)
+{
+ ExceptionHandlerRecord *record = reinterpret_cast<ExceptionHandlerRecord *>(
+ codeRef->executableMemory()->exceptionHandler());
+
+ record->info.Version = 1;
+ record->info.Flags = 0;
+ record->info.SizeOfProlog = 4;
+ record->info.CountOfUnwindCodes = 2;
+ record->info.FrameRegister = RBP;
+ record->info.FrameRegisterOffset = 0;
+
+ // Push frame pointer
+ record->info.UnwindCodes[1] = UnwindCode(1, UWOP_PUSH_NONVOL, RBP);
+ // Set frame pointer from stack pointer
+ record->info.UnwindCodes[0] = UnwindCode(4, UWOP_SET_FPREG, NONE);
+
+ const quintptr codeStart = quintptr(codeRef->code().executableAddress());
+ const quintptr codeSize = codeRef->size();
+
+ record->handler.BeginAddress = DWORD(codeStart - quintptr(record));
+ record->handler.EndAddress = DWORD(codeStart + codeSize - quintptr(record));
+ record->handler.UnwindData = offsetof(ExceptionHandlerRecord, info);
+
+ if (!RtlAddFunctionTable(&record->handler, 1, DWORD64(record))) {
+ const unsigned int errorCode = GetLastError();
+ qWarning() << "Failed to install win64 unwind hook. Error code:" << errorCode;
+ }
+}
+
+void destroyFunctionTable(Function *, JSC::MacroAssemblerCodeRef *codeRef)
+{
+ ExceptionHandlerRecord *record = reinterpret_cast<ExceptionHandlerRecord *>(
+ codeRef->executableMemory()->exceptionHandler());
+ if (!RtlDeleteFunctionTable(&record->handler)) {
+ const unsigned int errorCode = GetLastError();
+ qWarning() << "Failed to remove win64 unwind hook. Error code:" << errorCode;
+ }
+}
+
+size_t exceptionHandlerSize()
+{
+ return sizeof(ExceptionHandlerRecord);
+}
+
+} // QV4
+
+QT_END_NAMESPACE
diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h
index 162fb66cba..44adac26cd 100644
--- a/src/qml/jsruntime/qv4global_p.h
+++ b/src/qml/jsruntime/qv4global_p.h
@@ -279,6 +279,20 @@ struct IdentifierTable;
class RegExpCache;
class MultiplyWrappedQObjectMap;
+enum class ObservedTraceValues : quint8 {
+ Integer = 1 << 0,
+ Boolean = 1 << 1,
+ Double = 1 << 2,
+ Other = 1 << 3,
+ TypeMask = Integer | Boolean | Double | Other,
+
+ TruePathTaken = 1 << 0,
+ FalsePathTaken = 1 << 1,
+
+ ArrayWasAccessed = 1 << 7,
+ ArrayAccessNeededFallback = 1 << 6,
+};
+
enum PropertyFlag {
Attr_Data = 0,
Attr_Accessor = 0x1,
diff --git a/src/qml/jsruntime/qv4math_p.h b/src/qml/jsruntime/qv4math_p.h
index 90246c4229..a60a49a811 100644
--- a/src/qml/jsruntime/qv4math_p.h
+++ b/src/qml/jsruntime/qv4math_p.h
@@ -66,27 +66,42 @@ QT_BEGIN_NAMESPACE
namespace QV4 {
-static inline QMLJS_READONLY ReturnedValue add_int32(int a, int b)
+static inline QMLJS_READONLY ReturnedValue add_int32(int a, int b, quint8 *traceInfo = nullptr)
{
int result;
- if (Q_UNLIKELY(add_overflow(a, b, &result)))
+ if (Q_UNLIKELY(add_overflow(a, b, &result))) {
+ if (traceInfo)
+ *traceInfo |= quint8(QV4::ObservedTraceValues::Double);
return Value::fromDouble(static_cast<double>(a) + b).asReturnedValue();
+ }
+ if (traceInfo)
+ *traceInfo |= quint8(QV4::ObservedTraceValues::Integer);
return Value::fromInt32(result).asReturnedValue();
}
-static inline QMLJS_READONLY ReturnedValue sub_int32(int a, int b)
+static inline QMLJS_READONLY ReturnedValue sub_int32(int a, int b, quint8 *traceInfo = nullptr)
{
int result;
- if (Q_UNLIKELY(sub_overflow(a, b, &result)))
+ if (Q_UNLIKELY(sub_overflow(a, b, &result))) {
+ if (traceInfo)
+ *traceInfo |= quint8(QV4::ObservedTraceValues::Double);
return Value::fromDouble(static_cast<double>(a) - b).asReturnedValue();
+ }
+ if (traceInfo)
+ *traceInfo |= quint8(QV4::ObservedTraceValues::Integer);
return Value::fromInt32(result).asReturnedValue();
}
-static inline QMLJS_READONLY ReturnedValue mul_int32(int a, int b)
+static inline QMLJS_READONLY ReturnedValue mul_int32(int a, int b, quint8 *traceInfo = nullptr)
{
int result;
- if (Q_UNLIKELY(mul_overflow(a, b, &result)))
+ if (Q_UNLIKELY(mul_overflow(a, b, &result))) {
+ if (traceInfo)
+ *traceInfo |= quint8(QV4::ObservedTraceValues::Double);
return Value::fromDouble(static_cast<double>(a) * b).asReturnedValue();
+ }
+ if (traceInfo)
+ *traceInfo |= quint8(QV4::ObservedTraceValues::Integer);
return Value::fromInt32(result).asReturnedValue();
}
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 6a242ba5f6..f7c339dc26 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -704,6 +704,30 @@ ReturnedValue Runtime::method_loadElement(ExecutionEngine *engine, const Value &
return getElementFallback(engine, object, index);
}
+ReturnedValue Runtime::method_loadElement_traced(ExecutionEngine *engine, const Value &object, const Value &index, quint8 *traceSlot)
+{
+ *traceSlot |= quint8(ObservedTraceValues::ArrayWasAccessed);
+ if (index.isPositiveInt()) {
+ uint idx = static_cast<uint>(index.int_32());
+ if (Heap::Base *b = object.heapObject()) {
+ if (b->internalClass->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->values.size)
+ if (!s->data(idx).isEmpty())
+ return s->data(idx).asReturnedValue();
+ }
+ }
+ }
+ *traceSlot |= quint8(ObservedTraceValues::ArrayAccessNeededFallback);
+ return getElementIntFallback(engine, object, idx);
+ }
+
+ *traceSlot |= quint8(ObservedTraceValues::ArrayAccessNeededFallback);
+ return getElementFallback(engine, object, index);
+}
+
static Q_NEVER_INLINE bool setElementFallback(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value)
{
Scope scope(engine);
@@ -759,6 +783,30 @@ void Runtime::method_storeElement(ExecutionEngine *engine, const Value &object,
engine->throwTypeError();
}
+void Runtime::method_storeElement_traced(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value, quint8 *traceSlot)
+{
+ *traceSlot |= quint8(ObservedTraceValues::ArrayWasAccessed);
+ if (index.isPositiveInt()) {
+ uint idx = static_cast<uint>(index.int_32());
+ if (Heap::Base *b = object.heapObject()) {
+ if (b->internalClass->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->values.size) {
+ s->setData(engine, idx, value);
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ *traceSlot |= quint8(ObservedTraceValues::ArrayAccessNeededFallback);
+ if (!setElementFallback(engine, object, index, value) && engine->currentStackFrame->v4Function->isStrict())
+ engine->throwTypeError();
+}
+
ReturnedValue Runtime::method_getIterator(ExecutionEngine *engine, const Value &in, int iterator)
{
Scope scope(engine);
@@ -1405,7 +1453,7 @@ ReturnedValue Runtime::method_callProperty(ExecutionEngine *engine, Value *base,
if (!f) {
QString error = QStringLiteral("Property '%1' of object %2 is not a function")
- .arg(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]->toQString(),
+ .arg(name->toQString(),
base->toQStringNoThrow());
return engine->throwTypeError(error);
}
diff --git a/src/qml/jsruntime/qv4runtimeapi_p.h b/src/qml/jsruntime/qv4runtimeapi_p.h
index 4b3905c56f..ceec13a3bb 100644
--- a/src/qml/jsruntime/qv4runtimeapi_p.h
+++ b/src/qml/jsruntime/qv4runtimeapi_p.h
@@ -113,9 +113,11 @@ struct ExceptionCheck<void (*)(QV4::NoThrowEngine *, A, B, C)> {
F(void, storeNameSloppy, (ExecutionEngine *engine, int nameIndex, const Value &value)) \
F(void, storeProperty, (ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value)) \
F(void, storeElement, (ExecutionEngine *engine, const Value &object, const Value &index, const Value &value)) \
+ F(void, storeElement_traced, (ExecutionEngine *engine, const Value &object, const Value &index, const Value &value, quint8 *traceSlot)) \
F(ReturnedValue, loadProperty, (ExecutionEngine *engine, const Value &object, int nameIndex)) \
F(ReturnedValue, loadName, (ExecutionEngine *engine, int nameIndex)) \
F(ReturnedValue, loadElement, (ExecutionEngine *engine, const Value &object, const Value &index)) \
+ F(ReturnedValue, loadElement_traced, (ExecutionEngine *engine, const Value &object, const Value &index, quint8 *traceSlot)) \
F(ReturnedValue, loadSuperProperty, (ExecutionEngine *engine, const Value &property)) \
F(void, storeSuperProperty, (ExecutionEngine *engine, const Value &property, const Value &value)) \
F(ReturnedValue, loadSuperConstructor, (ExecutionEngine *engine, const Value &t)) \
diff --git a/src/qml/jsruntime/qv4variantobject.cpp b/src/qml/jsruntime/qv4variantobject.cpp
index ef0877dbd0..e4d8bcaafc 100644
--- a/src/qml/jsruntime/qv4variantobject.cpp
+++ b/src/qml/jsruntime/qv4variantobject.cpp
@@ -138,11 +138,14 @@ ReturnedValue VariantPrototype::method_toString(const FunctionObject *b, const V
const VariantObject *o = thisObject->as<QV4::VariantObject>();
if (!o)
RETURN_UNDEFINED();
- QString result = o->d()->data().toString();
- if (result.isEmpty() && !o->d()->data().canConvert(QVariant::String)) {
- result = QLatin1String("QVariant(")
- + QLatin1String(o->d()->data().typeName())
- + QLatin1Char(')');
+ const QVariant variant = o->d()->data();
+ QString result = variant.toString();
+ if (result.isEmpty() && !variant.canConvert(QVariant::String)) {
+ QDebug dbg(&result);
+ dbg << variant;
+ // QDebug appends a space, we're not interested in continuing the stream so we chop it off.
+ // Can't use nospace() because it would affect the debug-stream operator of the variant.
+ result.chop(1);
}
return Encode(v4->newString(result));
}
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index ea2217499f..dd712a15d6 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -346,6 +346,70 @@ static struct InstrCount {
if (engine->hasException) \
goto handleUnwind
+static inline void traceJumpTakesTruePath(bool truePathTaken, Function *f, int slot)
+{
+#if QT_CONFIG(qml_tracing)
+ quint8 *traceInfo = f->traceInfo(slot);
+ Q_ASSERT(traceInfo);
+ *traceInfo |= truePathTaken ? quint8(ObservedTraceValues::TruePathTaken)
+ : quint8(ObservedTraceValues::FalsePathTaken);
+#else
+ Q_UNUSED(truePathTaken);
+ Q_UNUSED(f);
+ Q_UNUSED(slot);
+#endif
+}
+
+static inline void traceValue(ReturnedValue acc, Function *f, int slot)
+{
+#if QT_CONFIG(qml_tracing)
+ quint8 *traceInfo = f->traceInfo(slot);
+ Q_ASSERT(traceInfo);
+ switch (Primitive::fromReturnedValue(acc).type()) {
+ case QV4::Value::Integer_Type:
+ *traceInfo |= quint8(ObservedTraceValues::Integer);
+ break;
+ case QV4::Value::Boolean_Type:
+ *traceInfo |= quint8(ObservedTraceValues::Boolean);
+ break;
+ case QV4::Value::Double_Type:
+ *traceInfo |= quint8(ObservedTraceValues::Double);
+ break;
+ default:
+ *traceInfo |= quint8(ObservedTraceValues::Other);
+ break;
+ }
+#else
+ Q_UNUSED(acc);
+ Q_UNUSED(f);
+ Q_UNUSED(slot);
+#endif
+}
+
+static inline void traceDoubleValue(Function *f, int slot)
+{
+#if QT_CONFIG(qml_tracing)
+ quint8 *traceInfo = f->traceInfo(slot);
+ Q_ASSERT(traceInfo);
+ *traceInfo |= quint8(ObservedTraceValues::Double);
+#else
+ Q_UNUSED(f);
+ Q_UNUSED(slot);
+#endif
+}
+
+static inline void traceOtherValue(Function *f, int slot)
+{
+#if QT_CONFIG(qml_tracing)
+ quint8 *traceInfo = f->traceInfo(slot);
+ Q_ASSERT(traceInfo);
+ *traceInfo |= quint8(ObservedTraceValues::Other);
+#else
+ Q_UNUSED(f);
+ Q_UNUSED(slot);
+#endif
+}
+
static inline Heap::CallContext *getScope(QV4::Value *stack, int level)
{
Heap::ExecutionContext *scope = static_cast<ExecutionContext &>(stack[CallData::Context]).d();
@@ -453,6 +517,11 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
QV4::ReturnedValue acc = accumulator.asReturnedValue();
Value *stack = reinterpret_cast<Value *>(frame->jsFrame);
+ if (function->tracingEnabled()) {
+ for (int i = 0; i < int(function->nFormals); ++i)
+ traceValue(frame->jsFrame->argument(i), function, i);
+ }
+
MOTH_JUMP_TABLE;
for (;;) {
@@ -511,6 +580,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
auto cc = static_cast<Heap::CallContext *>(stack[CallData::Context].m());
Q_ASSERT(cc->type != QV4::Heap::CallContext::Type_GlobalContext);
acc = cc->locals[index].asReturnedValue();
+ traceValue(acc, function, traceSlot);
MOTH_END_INSTR(LoadLocal)
MOTH_BEGIN_INSTR(StoreLocal)
@@ -523,6 +593,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
MOTH_BEGIN_INSTR(LoadScopedLocal)
auto cc = getScope(stack, scope);
acc = cc->locals[index].asReturnedValue();
+ traceValue(acc, function, traceSlot);
MOTH_END_INSTR(LoadScopedLocal)
MOTH_BEGIN_INSTR(StoreScopedLocal)
@@ -547,6 +618,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
STORE_IP();
acc = Runtime::method_loadName(engine, name);
CHECK_EXCEPTION;
+ traceValue(acc, function, traceSlot);
MOTH_END_INSTR(LoadName)
MOTH_BEGIN_INSTR(LoadGlobalLookup)
@@ -554,6 +626,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
QV4::Lookup *l = function->compilationUnit->runtimeLookups + index;
acc = l->globalGetter(l, engine);
CHECK_EXCEPTION;
+ traceValue(acc, function, traceSlot);
MOTH_END_INSTR(LoadGlobalLookup)
MOTH_BEGIN_INSTR(LoadQmlContextPropertyLookup)
@@ -561,6 +634,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
QV4::Lookup *l = function->compilationUnit->runtimeLookups + index;
acc = l->qmlContextPropertyGetter(l, engine, nullptr);
CHECK_EXCEPTION;
+ traceValue(acc, function, traceSlot);
MOTH_END_INSTR(LoadQmlContextPropertyLookup)
MOTH_BEGIN_INSTR(StoreNameStrict)
@@ -580,14 +654,25 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
MOTH_BEGIN_INSTR(LoadElement)
STORE_IP();
STORE_ACC();
+#if QT_CONFIG(qml_tracing)
+ acc = Runtime::method_loadElement_traced(engine, STACK_VALUE(base), accumulator, function->traceInfo(traceSlot));
+ traceValue(acc, function, traceSlot);
+#else
+ Q_UNUSED(traceSlot);
acc = Runtime::method_loadElement(engine, STACK_VALUE(base), accumulator);
+#endif
CHECK_EXCEPTION;
MOTH_END_INSTR(LoadElement)
MOTH_BEGIN_INSTR(StoreElement)
STORE_IP();
STORE_ACC();
+#if QT_CONFIG(qml_tracing)
+ Runtime::method_storeElement_traced(engine, STACK_VALUE(base), STACK_VALUE(index), accumulator, function->traceInfo(traceSlot));
+#else
+ Q_UNUSED(traceSlot);
Runtime::method_storeElement(engine, STACK_VALUE(base), STACK_VALUE(index), accumulator);
+#endif
CHECK_EXCEPTION;
MOTH_END_INSTR(StoreElement)
@@ -596,6 +681,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
STORE_ACC();
acc = Runtime::method_loadProperty(engine, accumulator, name);
CHECK_EXCEPTION;
+ traceValue(acc, function, traceSlot);
MOTH_END_INSTR(LoadProperty)
MOTH_BEGIN_INSTR(GetLookup)
@@ -614,6 +700,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
acc = l->getter(l, engine, accumulator);
CHECK_EXCEPTION;
+ traceValue(acc, function, traceSlot);
MOTH_END_INSTR(GetLookup)
MOTH_BEGIN_INSTR(StoreProperty)
@@ -687,6 +774,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
Value undef = Value::undefinedValue();
acc = static_cast<const FunctionObject &>(func).call(&undef, stack + argv, argc);
CHECK_EXCEPTION;
+ traceValue(acc, function, traceSlot);
MOTH_END_INSTR(CallValue)
MOTH_BEGIN_INSTR(CallWithReceiver)
@@ -698,12 +786,14 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
}
acc = static_cast<const FunctionObject &>(func).call(stack + thisObject, stack + argv, argc);
CHECK_EXCEPTION;
+ traceValue(acc, function, traceSlot);
MOTH_END_INSTR(CallWithReceiver)
MOTH_BEGIN_INSTR(CallProperty)
STORE_IP();
acc = Runtime::method_callProperty(engine, stack + base, name, stack + argv, argc);
CHECK_EXCEPTION;
+ traceValue(acc, function, traceSlot);
MOTH_END_INSTR(CallProperty)
MOTH_BEGIN_INSTR(CallPropertyLookup)
@@ -731,42 +821,49 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
acc = static_cast<FunctionObject &>(f).call(stack + base, stack + argv, argc);
CHECK_EXCEPTION;
+ traceValue(acc, function, traceSlot);
MOTH_END_INSTR(CallPropertyLookup)
MOTH_BEGIN_INSTR(CallElement)
STORE_IP();
acc = Runtime::method_callElement(engine, stack + base, STACK_VALUE(index), stack + argv, argc);
CHECK_EXCEPTION;
+ traceValue(acc, function, traceSlot);
MOTH_END_INSTR(CallElement)
MOTH_BEGIN_INSTR(CallName)
STORE_IP();
acc = Runtime::method_callName(engine, name, stack + argv, argc);
CHECK_EXCEPTION;
+ traceValue(acc, function, traceSlot);
MOTH_END_INSTR(CallName)
MOTH_BEGIN_INSTR(CallPossiblyDirectEval)
STORE_IP();
acc = Runtime::method_callPossiblyDirectEval(engine, stack + argv, argc);
CHECK_EXCEPTION;
+ traceValue(acc, function, traceSlot);
MOTH_END_INSTR(CallPossiblyDirectEval)
MOTH_BEGIN_INSTR(CallGlobalLookup)
STORE_IP();
acc = Runtime::method_callGlobalLookup(engine, index, stack + argv, argc);
CHECK_EXCEPTION;
+ traceValue(acc, function, traceSlot);
MOTH_END_INSTR(CallGlobalLookup)
MOTH_BEGIN_INSTR(CallQmlContextPropertyLookup)
STORE_IP();
acc = Runtime::method_callQmlContextPropertyLookup(engine, index, stack + argv, argc);
CHECK_EXCEPTION;
+ traceValue(acc, function, traceSlot);
MOTH_END_INSTR(CallQmlContextPropertyLookup)
MOTH_BEGIN_INSTR(CallWithSpread)
STORE_IP();
acc = Runtime::method_callWithSpread(engine, STACK_VALUE(func), STACK_VALUE(thisObject), stack + argv, argc);
CHECK_EXCEPTION;
+ traceValue(acc, function, traceSlot);
MOTH_END_INSTR(CallWithSpread)
MOTH_BEGIN_INSTR(TailCall)
@@ -1004,23 +1101,25 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
MOTH_END_INSTR(Jump)
MOTH_BEGIN_INSTR(JumpTrue)
- if (Q_LIKELY(ACC.integerCompatible())) {
- if (ACC.int_32())
- code += offset;
- } else {
- if (ACC.toBoolean())
- code += offset;
- }
+ bool takeJump;
+ if (Q_LIKELY(ACC.integerCompatible()))
+ takeJump = ACC.int_32();
+ else
+ takeJump = ACC.toBoolean();
+ traceJumpTakesTruePath(takeJump, function, traceSlot);
+ if (takeJump)
+ code += offset;
MOTH_END_INSTR(JumpTrue)
MOTH_BEGIN_INSTR(JumpFalse)
- if (Q_LIKELY(ACC.integerCompatible())) {
- if (!ACC.int_32())
- code += offset;
- } else {
- if (!ACC.toBoolean())
- code += offset;
- }
+ bool takeJump;
+ if (Q_LIKELY(ACC.integerCompatible()))
+ takeJump = !ACC.int_32();
+ else
+ takeJump = !ACC.toBoolean();
+ traceJumpTakesTruePath(!takeJump, function, traceSlot);
+ if (takeJump)
+ code += offset;
MOTH_END_INSTR(JumpFalse)
MOTH_BEGIN_INSTR(JumpNoException)
@@ -1189,14 +1288,17 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
int a = ACC.int_32();
if (a == 0 || a == std::numeric_limits<int>::min()) {
acc = Encode(-static_cast<double>(a));
+ traceDoubleValue(function, traceSlot);
} else {
- acc = sub_int32(0, ACC.int_32());
+ acc = sub_int32(0, ACC.int_32(), function->traceInfo(traceSlot));
}
} else if (ACC.isDouble()) {
acc ^= (1ull << 63); // simply flip sign bit
+ traceDoubleValue(function, traceSlot);
} else {
acc = Encode(-ACC.toNumberImpl());
CHECK_EXCEPTION;
+ traceOtherValue(function, traceSlot);
}
MOTH_END_INSTR(UMinus)
@@ -1207,49 +1309,57 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
MOTH_BEGIN_INSTR(Increment)
if (Q_LIKELY(ACC.integerCompatible())) {
- acc = add_int32(ACC.int_32(), 1);
+ acc = add_int32(ACC.int_32(), 1, function->traceInfo(traceSlot));
} else if (ACC.isDouble()) {
acc = QV4::Encode(ACC.doubleValue() + 1.);
+ traceDoubleValue(function, traceSlot);
} else {
acc = Encode(ACC.toNumberImpl() + 1.);
CHECK_EXCEPTION;
+ traceDoubleValue(function, traceSlot);
}
MOTH_END_INSTR(Increment)
MOTH_BEGIN_INSTR(Decrement)
if (Q_LIKELY(ACC.integerCompatible())) {
- acc = sub_int32(ACC.int_32(), 1);
+ acc = sub_int32(ACC.int_32(), 1, function->traceInfo(traceSlot));
} else if (ACC.isDouble()) {
acc = QV4::Encode(ACC.doubleValue() - 1.);
+ traceDoubleValue(function, traceSlot);
} else {
acc = Encode(ACC.toNumberImpl() - 1.);
CHECK_EXCEPTION;
+ traceDoubleValue(function, traceSlot);
}
MOTH_END_INSTR(Decrement)
MOTH_BEGIN_INSTR(Add)
const Value left = STACK_VALUE(lhs);
if (Q_LIKELY(Value::integerCompatible(left, ACC))) {
- acc = add_int32(left.int_32(), ACC.int_32());
+ acc = add_int32(left.int_32(), ACC.int_32(), function->traceInfo(traceSlot));
} else if (left.isNumber() && ACC.isNumber()) {
acc = Encode(left.asDouble() + ACC.asDouble());
+ traceDoubleValue(function, traceSlot);
} else {
STORE_ACC();
acc = Runtime::method_add(engine, left, accumulator);
CHECK_EXCEPTION;
+ traceOtherValue(function, traceSlot);
}
MOTH_END_INSTR(Add)
MOTH_BEGIN_INSTR(Sub)
const Value left = STACK_VALUE(lhs);
if (Q_LIKELY(Value::integerCompatible(left, ACC))) {
- acc = sub_int32(left.int_32(), ACC.int_32());
+ acc = sub_int32(left.int_32(), ACC.int_32(), function->traceInfo(traceSlot));
} else if (left.isNumber() && ACC.isNumber()) {
acc = Encode(left.asDouble() - ACC.asDouble());
+ traceDoubleValue(function, traceSlot);
} else {
STORE_ACC();
acc = Runtime::method_sub(left, accumulator);
CHECK_EXCEPTION;
+ traceOtherValue(function, traceSlot);
}
MOTH_END_INSTR(Sub)
@@ -1266,13 +1376,15 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
MOTH_BEGIN_INSTR(Mul)
const Value left = STACK_VALUE(lhs);
if (Q_LIKELY(Value::integerCompatible(left, ACC))) {
- acc = mul_int32(left.int_32(), ACC.int_32());
+ acc = mul_int32(left.int_32(), ACC.int_32(), function->traceInfo(traceSlot));
} else if (left.isNumber() && ACC.isNumber()) {
acc = Encode(left.asDouble() * ACC.asDouble());
+ traceDoubleValue(function, traceSlot);
} else {
STORE_ACC();
acc = Runtime::method_mul(left, accumulator);
CHECK_EXCEPTION;
+ traceOtherValue(function, traceSlot);
}
MOTH_END_INSTR(Mul)
@@ -1286,6 +1398,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
STORE_ACC();
acc = Runtime::method_mod(STACK_VALUE(lhs), accumulator);
CHECK_EXCEPTION;
+ traceValue(acc, function, traceSlot);
MOTH_END_INSTR(Mod)
MOTH_BEGIN_INSTR(BitAnd)
diff --git a/src/qml/parser/parser.pri b/src/qml/parser/parser.pri
index adab4ef9a2..2c0175c94b 100644
--- a/src/qml/parser/parser.pri
+++ b/src/qml/parser/parser.pri
@@ -8,7 +8,8 @@ HEADERS += \
$$PWD/qqmljsglobal_p.h \
$$PWD/qqmljskeywords_p.h \
$$PWD/qqmljsengine_p.h \
- $$PWD/qqmljsglobal_p.h
+ $$PWD/qqmljsglobal_p.h \
+ $$PWD/qqmljssourcelocation_p.h
SOURCES += \
$$PWD/qqmljsast.cpp \
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g
index 8ae51a795f..0c947b541b 100644
--- a/src/qml/parser/qqmljs.g
+++ b/src/qml/parser/qqmljs.g
@@ -249,7 +249,7 @@
#include <QtCore/qlist.h>
#include <QtCore/qstring.h>
-QT_QML_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
namespace QQmlJS {
@@ -486,7 +486,7 @@ protected:
using namespace QQmlJS;
-QT_QML_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
void Parser::reallocateStack()
{
@@ -4476,12 +4476,12 @@ ExportSpecifier: IdentifierName T_AS IdentifierName;
return false;
}
-QT_QML_END_NAMESPACE
+QT_END_NAMESPACE
./
/:
-QT_QML_END_NAMESPACE
+QT_END_NAMESPACE
diff --git a/src/qml/parser/qqmljsast.cpp b/src/qml/parser/qqmljsast.cpp
index 54a1200493..e5817ab763 100644
--- a/src/qml/parser/qqmljsast.cpp
+++ b/src/qml/parser/qqmljsast.cpp
@@ -41,7 +41,7 @@
#include "qqmljsastvisitor_p.h"
-QT_QML_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
namespace QQmlJS { namespace AST {
@@ -1474,6 +1474,6 @@ LeftHandSideExpression *LeftHandSideExpression::leftHandSideExpressionCast()
} } // namespace QQmlJS::AST
-QT_QML_END_NAMESPACE
+QT_END_NAMESPACE
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index e84c62af2f..b81553776d 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -57,7 +57,7 @@
#include <QtCore/qstring.h>
-QT_QML_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
#define QQMLJS_DECLARE_AST_NODE(name) \
enum { K = Kind_##name };
@@ -3395,6 +3395,6 @@ public:
-QT_QML_END_NAMESPACE
+QT_END_NAMESPACE
#endif
diff --git a/src/qml/parser/qqmljsastfwd_p.h b/src/qml/parser/qqmljsastfwd_p.h
index 996264db59..e9caa918d5 100644
--- a/src/qml/parser/qqmljsastfwd_p.h
+++ b/src/qml/parser/qqmljsastfwd_p.h
@@ -41,6 +41,7 @@
#define QQMLJSAST_FWD_P_H
#include "qqmljsglobal_p.h"
+#include "qqmljssourcelocation_p.h"
#include <QtCore/qglobal.h>
@@ -55,31 +56,10 @@
// We mean it.
//
-QT_QML_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
namespace QQmlJS { namespace AST {
-class SourceLocation
-{
-public:
- explicit SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0)
- : offset(offset), length(length),
- startLine(line), startColumn(column)
- { }
-
- bool isValid() const { return length != 0; }
-
- quint32 begin() const { return offset; }
- quint32 end() const { return offset + length; }
-
-// attributes
- // ### encode
- quint32 offset;
- quint32 length;
- quint32 startLine;
- quint32 startColumn;
-};
-
class Visitor;
class Node;
class ExpressionNode;
@@ -201,6 +181,6 @@ class UiEnumMemberList;
} } // namespace AST
-QT_QML_END_NAMESPACE
+QT_END_NAMESPACE
#endif
diff --git a/src/qml/parser/qqmljsastvisitor.cpp b/src/qml/parser/qqmljsastvisitor.cpp
index 666623eecc..5ecac36423 100644
--- a/src/qml/parser/qqmljsastvisitor.cpp
+++ b/src/qml/parser/qqmljsastvisitor.cpp
@@ -39,7 +39,7 @@
#include "qqmljsastvisitor_p.h"
-QT_QML_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
namespace QQmlJS { namespace AST {
@@ -53,4 +53,4 @@ Visitor::~Visitor()
} } // namespace QQmlJS::AST
-QT_QML_END_NAMESPACE
+QT_END_NAMESPACE
diff --git a/src/qml/parser/qqmljsastvisitor_p.h b/src/qml/parser/qqmljsastvisitor_p.h
index 9c69f88e0c..9115449a46 100644
--- a/src/qml/parser/qqmljsastvisitor_p.h
+++ b/src/qml/parser/qqmljsastvisitor_p.h
@@ -54,7 +54,7 @@
#include "qqmljsastfwd_p.h"
#include "qqmljsglobal_p.h"
-QT_QML_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
namespace QQmlJS { namespace AST {
@@ -412,6 +412,6 @@ protected:
} } // namespace AST
-QT_QML_END_NAMESPACE
+QT_END_NAMESPACE
#endif // QQMLJSASTVISITOR_P_H
diff --git a/src/qml/parser/qqmljsengine_p.cpp b/src/qml/parser/qqmljsengine_p.cpp
index 97ce6ebea3..bb27f3992e 100644
--- a/src/qml/parser/qqmljsengine_p.cpp
+++ b/src/qml/parser/qqmljsengine_p.cpp
@@ -44,7 +44,7 @@
#include <QtCore/qhash.h>
#include <QtCore/qdebug.h>
-QT_QML_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
namespace QQmlJS {
@@ -155,4 +155,4 @@ QStringRef Engine::newStringRef(const QChar *chars, int size)
} // end of namespace QQmlJS
-QT_QML_END_NAMESPACE
+QT_END_NAMESPACE
diff --git a/src/qml/parser/qqmljsengine_p.h b/src/qml/parser/qqmljsengine_p.h
index 1de907d296..b7f7da9478 100644
--- a/src/qml/parser/qqmljsengine_p.h
+++ b/src/qml/parser/qqmljsengine_p.h
@@ -52,13 +52,13 @@
//
#include "qqmljsglobal_p.h"
-#include "qqmljsastfwd_p.h"
#include "qqmljsmemorypool_p.h"
+#include "qqmljssourcelocation_p.h"
#include <QtCore/qstring.h>
#include <QtCore/qset.h>
-QT_QML_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
namespace QQmlJS {
@@ -95,7 +95,7 @@ public:
class QML_PARSER_EXPORT DiagnosticMessage
{
public:
- enum Kind { Warning, Error };
+ enum Kind { Hint, Warning, Error };
DiagnosticMessage() {}
@@ -150,6 +150,6 @@ double integerFromString(const char *buf, int size, int radix);
} // end of namespace QQmlJS
-QT_QML_END_NAMESPACE
+QT_END_NAMESPACE
#endif // QQMLJSENGINE_P_H
diff --git a/src/qml/parser/qqmljsglobal_p.h b/src/qml/parser/qqmljsglobal_p.h
index 0e195994b4..bf8155c6ec 100644
--- a/src/qml/parser/qqmljsglobal_p.h
+++ b/src/qml/parser/qqmljsglobal_p.h
@@ -53,8 +53,6 @@
#include <QtCore/qglobal.h>
#ifdef QT_CREATOR
-# define QT_QML_BEGIN_NAMESPACE
-# define QT_QML_END_NAMESPACE
# ifdef QDECLARATIVEJS_BUILD_DIR
# define QML_PARSER_EXPORT Q_DECL_EXPORT
@@ -65,8 +63,6 @@
# endif // QQMLJS_BUILD_DIR
#else // !QT_CREATOR
-# define QT_QML_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
-# define QT_QML_END_NAMESPACE QT_END_NAMESPACE
# ifndef QT_STATIC
# if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB)
// QmlDevTools is a static library
diff --git a/src/qml/parser/qqmljskeywords_p.h b/src/qml/parser/qqmljskeywords_p.h
index b0a4951ece..96b3709162 100644
--- a/src/qml/parser/qqmljskeywords_p.h
+++ b/src/qml/parser/qqmljskeywords_p.h
@@ -53,7 +53,7 @@
#include "qqmljslexer_p.h"
-QT_QML_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
namespace QQmlJS {
@@ -918,6 +918,6 @@ int Lexer::classify(const QChar *s, int n, int parseModeFlags) {
} // namespace QQmlJS
-QT_QML_END_NAMESPACE
+QT_END_NAMESPACE
#endif // QQMLJSKEYWORDS_P_H
diff --git a/src/qml/parser/qqmljslexer_p.h b/src/qml/parser/qqmljslexer_p.h
index 03f33f6e06..51152bfd6e 100644
--- a/src/qml/parser/qqmljslexer_p.h
+++ b/src/qml/parser/qqmljslexer_p.h
@@ -57,7 +57,7 @@
#include <QtCore/qstring.h>
#include <QtCore/qstack.h>
-QT_QML_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
namespace QQmlJS {
@@ -257,6 +257,6 @@ private:
} // end of namespace QQmlJS
-QT_QML_END_NAMESPACE
+QT_END_NAMESPACE
#endif // LEXER_H
diff --git a/src/qml/parser/qqmljsmemorypool_p.h b/src/qml/parser/qqmljsmemorypool_p.h
index afd0f809da..e7b1f46414 100644
--- a/src/qml/parser/qqmljsmemorypool_p.h
+++ b/src/qml/parser/qqmljsmemorypool_p.h
@@ -59,7 +59,7 @@
#include <cstring>
-QT_QML_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
namespace QQmlJS {
@@ -104,6 +104,8 @@ public:
}
template <typename Tp> Tp *New() { return new (this->allocate(sizeof(Tp))) Tp(); }
+ template <typename Tp, typename... Ta> Tp *New(Ta... args)
+ { return new (this->allocate(sizeof(Tp))) Tp(args...); }
QStringRef newString(const QString &string) {
strings.append(new QString(string));
@@ -172,8 +174,83 @@ public:
void operator delete(void *, MemoryPool *) {}
};
+template <typename T>
+class FixedPoolArray
+{
+ T *data;
+ int count = 0;
+
+public:
+ FixedPoolArray()
+ : data(nullptr)
+ {}
+
+ FixedPoolArray(MemoryPool *pool, int size)
+ { allocate(pool, size); }
+
+ void allocate(MemoryPool *pool, int size)
+ {
+ count = size;
+ data = reinterpret_cast<T*>(pool->allocate(count * sizeof(T)));
+ }
+
+ void allocate(MemoryPool *pool, const QVector<T> &vector)
+ {
+ count = vector.count();
+ data = reinterpret_cast<T*>(pool->allocate(count * sizeof(T)));
+
+ if (QTypeInfo<T>::isComplex) {
+ for (int i = 0; i < count; ++i)
+ new (data + i) T(vector.at(i));
+ } else {
+ memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+ }
+ }
+
+ template <typename Container>
+ void allocate(MemoryPool *pool, const Container &container)
+ {
+ count = container.count();
+ data = reinterpret_cast<T*>(pool->allocate(count * sizeof(T)));
+ typename Container::ConstIterator it = container.constBegin();
+ for (int i = 0; i < count; ++i)
+ new (data + i) T(*it++);
+ }
+
+ int size() const
+ { return count; }
+
+ const T &at(int index) const {
+ Q_ASSERT(index >= 0 && index < count);
+ return data[index];
+ }
+
+ T &at(int index) {
+ Q_ASSERT(index >= 0 && index < count);
+ return data[index];
+ }
+
+ T &operator[](int index) {
+ return at(index);
+ }
+
+
+ int indexOf(const T &value) const {
+ for (int i = 0; i < count; ++i)
+ if (data[i] == value)
+ return i;
+ return -1;
+ }
+
+ const T *begin() const { return data; }
+ const T *end() const { return data + count; }
+
+ T *begin() { return data; }
+ T *end() { return data + count; }
+};
+
} // namespace QQmlJS
-QT_QML_END_NAMESPACE
+QT_END_NAMESPACE
#endif
diff --git a/src/qml/parser/qqmljssourcelocation_p.h b/src/qml/parser/qqmljssourcelocation_p.h
new file mode 100644
index 0000000000..d76e701d49
--- /dev/null
+++ b/src/qml/parser/qqmljssourcelocation_p.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 QQMLJSSOURCELOCATION_P_H
+#define QQMLJSSOURCELOCATION_P_H
+
+#include "qqmljsglobal_p.h"
+
+#include <QtCore/qglobal.h>
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+namespace QQmlJS { namespace AST {
+
+class SourceLocation
+{
+public:
+ explicit SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0)
+ : offset(offset), length(length),
+ startLine(line), startColumn(column)
+ { }
+
+ bool isValid() const { return length != 0; }
+
+ quint32 begin() const { return offset; }
+ quint32 end() const { return offset + length; }
+
+// attributes
+ // ### encode
+ quint32 offset;
+ quint32 length;
+ quint32 startLine;
+ quint32 startColumn;
+};
+
+} } // namespace AST
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/qml/qml.pro b/src/qml/qml.pro
index db59140f06..94717a8f43 100644
--- a/src/qml/qml.pro
+++ b/src/qml/qml.pro
@@ -73,6 +73,7 @@ include(jsruntime/jsruntime.pri)
include(jit/jit.pri)
include(qml/qml.pri)
include(debugger/debugger.pri)
+include(qmldirparser/qmldirparser.pri)
qtConfig(qml-animation) {
include(animations/animations.pri)
}
diff --git a/src/qml/qml/qml.pri b/src/qml/qml/qml.pri
index 6d69294c17..ca13ce9211 100644
--- a/src/qml/qml/qml.pri
+++ b/src/qml/qml/qml.pri
@@ -18,7 +18,6 @@ SOURCES += \
$$PWD/qqmlparserstatus.cpp \
$$PWD/qqmltypeloader.cpp \
$$PWD/qqmlinfo.cpp \
- $$PWD/qqmlerror.cpp \
$$PWD/qqmlvaluetype.cpp \
$$PWD/qqmlcleanup.cpp \
$$PWD/qqmlpropertycache.cpp \
@@ -44,7 +43,6 @@ SOURCES += \
$$PWD/qqmltypewrapper.cpp \
$$PWD/qqmlfileselector.cpp \
$$PWD/qqmlobjectcreator.cpp \
- $$PWD/qqmldirparser.cpp \
$$PWD/qqmldelayedcallqueue.cpp \
$$PWD/qqmlloggingcategory.cpp
@@ -81,7 +79,6 @@ HEADERS += \
$$PWD/qqmllist.h \
$$PWD/qqmllist_p.h \
$$PWD/qqmldata_p.h \
- $$PWD/qqmlerror.h \
$$PWD/qqmlvaluetype_p.h \
$$PWD/qqmlcleanup_p.h \
$$PWD/qqmlpropertycache_p.h \
@@ -112,7 +109,6 @@ HEADERS += \
$$PWD/qqmlfileselector_p.h \
$$PWD/qqmlfileselector.h \
$$PWD/qqmlobjectcreator_p.h \
- $$PWD/qqmldirparser_p.h \
$$PWD/qqmldelayedcallqueue_p.h \
$$PWD/qqmlloggingcategory_p.h
diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h
index 05a9f70247..bf9330856d 100644
--- a/src/qml/qml/qqml.h
+++ b/src/qml/qml/qqml.h
@@ -584,7 +584,6 @@ namespace QtQml {
const QMetaObject *, bool create);
#ifndef Q_QDOC
}
-#endif
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wheader-hygiene")
@@ -594,6 +593,8 @@ using namespace QtQml;
QT_WARNING_POP
+#endif // Q_QDOC
+
//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);
diff --git a/src/qml/qml/qqmlabstracturlinterceptor.h b/src/qml/qml/qqmlabstracturlinterceptor.h
index 665b37fb3a..af231f51b2 100644
--- a/src/qml/qml/qqmlabstracturlinterceptor.h
+++ b/src/qml/qml/qqmlabstracturlinterceptor.h
@@ -55,8 +55,8 @@ public:
UrlString = 0x1000
};
- QQmlAbstractUrlInterceptor() {}
- virtual ~QQmlAbstractUrlInterceptor() {}
+ QQmlAbstractUrlInterceptor() = default;
+ virtual ~QQmlAbstractUrlInterceptor() = default;
virtual QUrl intercept(const QUrl &path, DataType type) = 0;
};
diff --git a/src/qml/qml/qqmlapplicationengine_p.h b/src/qml/qml/qqmlapplicationengine_p.h
index 4795170bed..6cf6828832 100644
--- a/src/qml/qml/qqmlapplicationengine_p.h
+++ b/src/qml/qml/qqmlapplicationengine_p.h
@@ -74,7 +74,6 @@ public:
void loadTranslations(const QUrl &rootFile);
void finishLoad(QQmlComponent *component);
QList<QObject *> objects;
- QObject *appObj;
#if QT_CONFIG(translation)
QList<QTranslator *> translators;
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index 7f0442d034..b164517011 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -314,7 +314,7 @@ protected:
break;
default:
if (const QV4::QQmlValueTypeWrapper *vtw = result.as<const QV4::QQmlValueTypeWrapper>()) {
- if (vtw->d()->valueType->typeId == pd->propType()) {
+ if (vtw->d()->valueType->metaType.id() == pd->propType()) {
return vtw->write(m_target.data(), pd->coreIndex());
}
}
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 5841a480fc..0a26ed89cc 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -661,6 +661,10 @@ The following functions are also on the Qt object.
/*!
\qmlmethod object Qt::include(string url, jsobject callback)
+\deprecated
+
+This method should not be used. Use ECMAScript modules instead and the native
+JavaScript \c import and \c export statements instead.
Includes another JavaScript file. This method can only be used from within JavaScript files,
and not regular QML files.
diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h
index 8a9581fb35..d05c945ae4 100644
--- a/src/qml/qml/qqmlengine_p.h
+++ b/src/qml/qml/qqmlengine_p.h
@@ -64,7 +64,6 @@
#include "qqmlproperty_p.h"
#include "qqmlpropertycache_p.h"
#include "qqmlmetatype_p.h"
-#include "qqmldirparser_p.h"
#include <private/qintrusivelist_p.h>
#include <private/qrecyclepool_p.h>
#include <private/qfieldlist_p.h>
@@ -80,6 +79,7 @@
#include <private/qv8engine_p.h>
#include <private/qjsengine_p.h>
+#include <private/qqmldirparser_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp
index 0c1ffbf3a0..ac2629979f 100644
--- a/src/qml/qml/qqmlexpression.cpp
+++ b/src/qml/qml/qqmlexpression.cpp
@@ -46,6 +46,7 @@
#include "qqmlscriptstring_p.h"
#include "qqmlbinding_p.h"
#include <private/qv8engine_p.h>
+#include <private/qqmlsourcecoordinate_p.h>
#include <QtCore/qdebug.h>
diff --git a/src/qml/qml/qqmlextensioninterface.h b/src/qml/qml/qqmlextensioninterface.h
index c2d20ef0a3..d2eb79c5c9 100644
--- a/src/qml/qml/qqmlextensioninterface.h
+++ b/src/qml/qml/qqmlextensioninterface.h
@@ -51,14 +51,14 @@ class QQmlEngine;
class Q_QML_EXPORT QQmlTypesExtensionInterface
{
public:
- virtual ~QQmlTypesExtensionInterface() {}
+ virtual ~QQmlTypesExtensionInterface() = default;
virtual void registerTypes(const char *uri) = 0;
};
class Q_QML_EXPORT QQmlExtensionInterface : public QQmlTypesExtensionInterface
{
public:
- ~QQmlExtensionInterface() override {}
+ ~QQmlExtensionInterface() override = default;
virtual void initializeEngine(QQmlEngine *engine, const char *uri) = 0;
};
diff --git a/src/qml/qml/qqmlfile.cpp b/src/qml/qml/qqmlfile.cpp
index 99031e1e74..465a342129 100644
--- a/src/qml/qml/qqmlfile.cpp
+++ b/src/qml/qml/qqmlfile.cpp
@@ -64,6 +64,7 @@ static char file_string[] = "file";
#if defined(Q_OS_ANDROID)
static char assets_string[] = "assets";
+static char content_string[] = "content";
#endif
class QQmlFilePrivate;
@@ -452,6 +453,8 @@ bool QQmlFile::isSynchronous(const QUrl &url)
#if defined(Q_OS_ANDROID)
} else if (scheme.length() == 6 && 0 == scheme.compare(QLatin1String(assets_string), Qt::CaseInsensitive)) {
return true;
+ } else if (scheme.length() == 7 && 0 == scheme.compare(QLatin1String(content_string), Qt::CaseInsensitive)) {
+ return true;
#endif
} else {
@@ -492,7 +495,10 @@ bool QQmlFile::isSynchronous(const QString &url)
return url.length() >= 8 /* assets:/ */ &&
url.startsWith(QLatin1String(assets_string), Qt::CaseInsensitive) &&
url[6] == QLatin1Char(':') && url[7] == QLatin1Char('/');
-
+ } else if (f == QLatin1Char('c') || f == QLatin1Char('C')) {
+ return url.length() >= 9 /* content:/ */ &&
+ url.startsWith(QLatin1String(content_string), Qt::CaseInsensitive) &&
+ url[7] == QLatin1Char(':') && url[8] == QLatin1Char('/');
}
#endif
@@ -556,7 +562,10 @@ bool QQmlFile::isLocalFile(const QString &url)
return url.length() >= 8 /* assets:/ */ &&
url.startsWith(QLatin1String(assets_string), Qt::CaseInsensitive) &&
url[6] == QLatin1Char(':') && url[7] == QLatin1Char('/');
-
+ } else if (f == QLatin1Char('c') || f == QLatin1Char('C')) {
+ return url.length() >= 9 /* content:/ */ &&
+ url.startsWith(QLatin1String(content_string), Qt::CaseInsensitive) &&
+ url[7] == QLatin1Char(':') && url[8] == QLatin1Char('/');
}
#endif
@@ -580,6 +589,8 @@ QString QQmlFile::urlToLocalFileOrQrc(const QUrl& url)
if (url.authority().isEmpty())
return url.toString();
return QString();
+ } else if (url.scheme().compare(QLatin1String("content"), Qt::CaseInsensitive) == 0) {
+ return url.toString();
}
#endif
@@ -618,6 +629,8 @@ QString QQmlFile::urlToLocalFileOrQrc(const QString& url)
#if defined(Q_OS_ANDROID)
else if (url.startsWith(QLatin1String("assets:"), Qt::CaseInsensitive)) {
return url;
+ } else if (url.startsWith(QLatin1String("content:"), Qt::CaseInsensitive)) {
+ return url;
}
#endif
diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h
index 302fdd56c4..818537560c 100644
--- a/src/qml/qml/qqmlglobal_p.h
+++ b/src/qml/qml/qqmlglobal_p.h
@@ -174,16 +174,6 @@ T qmlobject_cast(QObject *object)
return 0;
}
-inline quint16 qmlSourceCoordinate(int n)
-{
- return (n > 0 && n <= static_cast<int>(USHRT_MAX)) ? static_cast<quint16>(n) : 0;
-}
-
-inline int qmlSourceCoordinate(quint16 n)
-{
- return (n == 0) ? -1 : static_cast<int>(n);
-}
-
#define IS_SIGNAL_CONNECTED(Sender, SenderType, Name, Arguments) \
do { \
QObject *sender = (Sender); \
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index f801e9aeba..a8ec5d18f8 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -1102,13 +1102,6 @@ QString QQmlType::noCreationReason() const
return d->extraData.cd->noCreationReason;
}
-int QQmlType::createSize() const
-{
- if (!d || d->regType != CppType)
- return 0;
- return d->extraData.cd->allocationSize;
-}
-
bool QQmlType::isCreatable() const
{
return d && d->regType == CppType && d->extraData.cd->newFunc;
@@ -2172,11 +2165,14 @@ int QQmlMetaType::attachedPropertiesFuncId(QQmlEnginePrivate *engine, const QMet
QMutexLocker lock(metaTypeDataLock());
QQmlMetaTypeData *data = metaTypeData();
- QQmlType type(data->metaObjectToType.value(mo));
- if (type.attachedPropertiesFunction(engine))
- return type.attachedPropertiesId(engine);
- else
- return -1;
+ for (auto it = data->metaObjectToType.constFind(mo), end = data->metaObjectToType.constEnd();
+ it != end && it.key() == mo; ++it) {
+ const QQmlType type(it.value());
+ if (type.attachedPropertiesFunction(engine))
+ return type.attachedPropertiesId(engine);
+ }
+
+ return -1;
}
QQmlAttachedPropertiesFunc QQmlMetaType::attachedPropertiesFuncById(QQmlEnginePrivate *engine, int id)
diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h
index 8256212207..3ad2de7bb3 100644
--- a/src/qml/qml/qqmlmetatype_p.h
+++ b/src/qml/qml/qqmlmetatype_p.h
@@ -196,8 +196,6 @@ public:
typedef void (*CreateFunc)(void *);
CreateFunc createFunction() const;
- int createSize() const;
-
QQmlCustomParser *customParser() const;
bool isCreatable() const;
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 5af658194f..c36b3ed386 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -379,6 +379,28 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
}
}
+ auto assertOrNull = [&](bool ok)
+ {
+ Q_ASSERT(ok || binding->type == QV4::CompiledData::Binding::Type_Null);
+ Q_UNUSED(ok);
+ };
+
+ auto assertType = [&](QV4::CompiledData::Binding::ValueType type)
+ {
+ Q_ASSERT(binding->type == type || binding->type == QV4::CompiledData::Binding::Type_Null);
+ Q_UNUSED(type);
+ };
+
+ if (property->isQObject()) {
+ if (binding->type == QV4::CompiledData::Binding::Type_Null) {
+ QObject *value = nullptr;
+ const bool ok = property->writeProperty(_qobject, &value, propertyWriteFlags);
+ Q_ASSERT(ok);
+ Q_UNUSED(ok);
+ return;
+ }
+ }
+
switch (propertyType) {
case QMetaType::QVariant: {
if (binding->type == QV4::CompiledData::Binding::Type_Number) {
@@ -406,6 +428,13 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
QVariant value(binding->valueAsBoolean());
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
+ } else if (binding->type == QV4::CompiledData::Binding::Type_Null) {
+ if (property->isVarProperty()) {
+ _vmeMetaObject->setVMEProperty(property->coreIndex(), QV4::Value::nullValue());
+ } else {
+ QVariant nullValue = QVariant::fromValue(nullptr);
+ property->writeProperty(_qobject, &nullValue, propertyWriteFlags);
+ }
} else {
QString stringValue = binding->valueAsString(compilationUnit.data());
if (property->isVarProperty()) {
@@ -419,25 +448,25 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
}
break;
case QVariant::String: {
- Q_ASSERT(binding->evaluatesToString());
+ assertOrNull(binding->evaluatesToString());
QString value = binding->valueAsString(compilationUnit.data());
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::StringList: {
- Q_ASSERT(binding->evaluatesToString());
+ assertOrNull(binding->evaluatesToString());
QStringList value(binding->valueAsString(compilationUnit.data()));
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::ByteArray: {
- Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_String);
+ assertType(QV4::CompiledData::Binding::Type_String);
QByteArray value(binding->valueAsString(compilationUnit.data()).toUtf8());
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::Url: {
- Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_String);
+ assertType(QV4::CompiledData::Binding::Type_String);
QString string = binding->valueAsString(compilationUnit.data());
// Encoded dir-separators defeat QUrl processing - decode them first
string.replace(QLatin1String("%2f"), QLatin1String("/"), Qt::CaseInsensitive);
@@ -449,7 +478,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
}
break;
case QVariant::UInt: {
- Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Number);
+ assertType(QV4::CompiledData::Binding::Type_Number);
double d = binding->valueAsNumber(compilationUnit->constants);
uint value = uint(d);
property->writeProperty(_qobject, &value, propertyWriteFlags);
@@ -457,7 +486,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
}
break;
case QVariant::Int: {
- Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Number);
+ assertType(QV4::CompiledData::Binding::Type_Number);
double d = binding->valueAsNumber(compilationUnit->constants);
int value = int(d);
property->writeProperty(_qobject, &value, propertyWriteFlags);
@@ -465,13 +494,13 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
}
break;
case QMetaType::Float: {
- Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Number);
+ assertType(QV4::CompiledData::Binding::Type_Number);
float value = float(binding->valueAsNumber(compilationUnit->constants));
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::Double: {
- Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Number);
+ assertType(QV4::CompiledData::Binding::Type_Number);
double value = binding->valueAsNumber(compilationUnit->constants);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
@@ -479,7 +508,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
case QVariant::Color: {
bool ok = false;
uint colorValue = QQmlStringConverters::rgbaFromString(binding->valueAsString(compilationUnit.data()), &ok);
- Q_ASSERT(ok);
+ assertOrNull(ok);
struct { void *data[4]; } buffer;
if (QQml_valueTypeProvider()->storeValueType(property->propType(), &colorValue, &buffer, sizeof(buffer))) {
property->writeProperty(_qobject, &buffer, propertyWriteFlags);
@@ -490,14 +519,14 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
case QVariant::Date: {
bool ok = false;
QDate value = QQmlStringConverters::dateFromString(binding->valueAsString(compilationUnit.data()), &ok);
- Q_ASSERT(ok);
+ assertOrNull(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::Time: {
bool ok = false;
QTime value = QQmlStringConverters::timeFromString(binding->valueAsString(compilationUnit.data()), &ok);
- Q_ASSERT(ok);
+ assertOrNull(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
@@ -510,7 +539,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
const int msecsSinceStartOfDay = value.time().msecsSinceStartOfDay();
value = QDateTime(QDate::fromJulianDay(date), QTime::fromMSecsSinceStartOfDay(msecsSinceStartOfDay));
}
- Q_ASSERT(ok);
+ assertOrNull(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
@@ -518,47 +547,47 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
case QVariant::Point: {
bool ok = false;
QPoint value = QQmlStringConverters::pointFFromString(binding->valueAsString(compilationUnit.data()), &ok).toPoint();
- Q_ASSERT(ok);
+ assertOrNull(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::PointF: {
bool ok = false;
QPointF value = QQmlStringConverters::pointFFromString(binding->valueAsString(compilationUnit.data()), &ok);
- Q_ASSERT(ok);
+ assertOrNull(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::Size: {
bool ok = false;
QSize value = QQmlStringConverters::sizeFFromString(binding->valueAsString(compilationUnit.data()), &ok).toSize();
- Q_ASSERT(ok);
+ assertOrNull(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::SizeF: {
bool ok = false;
QSizeF value = QQmlStringConverters::sizeFFromString(binding->valueAsString(compilationUnit.data()), &ok);
- Q_ASSERT(ok);
+ assertOrNull(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::Rect: {
bool ok = false;
QRect value = QQmlStringConverters::rectFFromString(binding->valueAsString(compilationUnit.data()), &ok).toRect();
- Q_ASSERT(ok);
+ assertOrNull(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::RectF: {
bool ok = false;
QRectF value = QQmlStringConverters::rectFFromString(binding->valueAsString(compilationUnit.data()), &ok);
- Q_ASSERT(ok);
+ assertOrNull(ok);
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
case QVariant::Bool: {
- Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Boolean);
+ assertType(QV4::CompiledData::Binding::Type_Boolean);
bool value = binding->valueAsBoolean();
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
@@ -569,7 +598,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
float yp;
} vec;
bool ok = QQmlStringConverters::createFromString(QMetaType::QVector2D, binding->valueAsString(compilationUnit.data()), &vec, sizeof(vec));
- Q_ASSERT(ok);
+ assertOrNull(ok);
Q_UNUSED(ok);
property->writeProperty(_qobject, &vec, propertyWriteFlags);
}
@@ -581,7 +610,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
float zy;
} vec;
bool ok = QQmlStringConverters::createFromString(QMetaType::QVector3D, binding->valueAsString(compilationUnit.data()), &vec, sizeof(vec));
- Q_ASSERT(ok);
+ assertOrNull(ok);
Q_UNUSED(ok);
property->writeProperty(_qobject, &vec, propertyWriteFlags);
}
@@ -594,7 +623,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
float wp;
} vec;
bool ok = QQmlStringConverters::createFromString(QMetaType::QVector4D, binding->valueAsString(compilationUnit.data()), &vec, sizeof(vec));
- Q_ASSERT(ok);
+ assertOrNull(ok);
Q_UNUSED(ok);
property->writeProperty(_qobject, &vec, propertyWriteFlags);
}
@@ -607,37 +636,37 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
float zp;
} vec;
bool ok = QQmlStringConverters::createFromString(QMetaType::QQuaternion, binding->valueAsString(compilationUnit.data()), &vec, sizeof(vec));
- Q_ASSERT(ok);
+ assertOrNull(ok);
Q_UNUSED(ok);
property->writeProperty(_qobject, &vec, propertyWriteFlags);
}
break;
case QVariant::RegExp:
- Q_ASSERT(!"not possible");
+ assertOrNull(!"not possible");
break;
default: {
// generate single literal value assignment to a list property if required
if (property->propType() == qMetaTypeId<QList<qreal> >()) {
- Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Number);
+ assertType(QV4::CompiledData::Binding::Type_Number);
QList<qreal> value;
value.append(binding->valueAsNumber(compilationUnit->constants));
property->writeProperty(_qobject, &value, propertyWriteFlags);
break;
} else if (property->propType() == qMetaTypeId<QList<int> >()) {
- Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Number);
+ assertType(QV4::CompiledData::Binding::Type_Number);
double n = binding->valueAsNumber(compilationUnit->constants);
QList<int> value;
value.append(int(n));
property->writeProperty(_qobject, &value, propertyWriteFlags);
break;
} else if (property->propType() == qMetaTypeId<QList<bool> >()) {
- Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Boolean);
+ assertType(QV4::CompiledData::Binding::Type_Boolean);
QList<bool> value;
value.append(binding->valueAsBoolean());
property->writeProperty(_qobject, &value, propertyWriteFlags);
break;
} else if (property->propType() == qMetaTypeId<QList<QUrl> >()) {
- Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_String);
+ assertType(QV4::CompiledData::Binding::Type_String);
QString urlString = binding->valueAsString(compilationUnit.data());
QUrl u = urlString.isEmpty() ? QUrl()
: compilationUnit->finalUrl().resolved(QUrl(urlString));
@@ -646,7 +675,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
property->writeProperty(_qobject, &value, propertyWriteFlags);
break;
} else if (property->propType() == qMetaTypeId<QList<QString> >()) {
- Q_ASSERT(binding->evaluatesToString());
+ assertOrNull(binding->evaluatesToString());
QList<QString> value;
value.append(binding->valueAsString(compilationUnit.data()));
property->writeProperty(_qobject, &value, propertyWriteFlags);
@@ -661,6 +690,8 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
value = QJSValue(int(n));
} else
value = QJSValue(n);
+ } else if (binding->type == QV4::CompiledData::Binding::Type_Null) {
+ value = QJSValue::NullValue;
} else {
value = QJSValue(binding->valueAsString(compilationUnit.data()));
}
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index 20d5c76029..73bfd7bbaa 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -898,6 +898,17 @@ struct StaticQtMetaObject : public QObject
{ return &staticQtMetaObject; }
};
+static bool isNamedEnumeratorInScope(const QMetaObject *resolvedMetaObject, const QByteArray &scope,
+ const QByteArray &name)
+{
+ for (int i = resolvedMetaObject->enumeratorCount() - 1; i >= 0; --i) {
+ QMetaEnum m = resolvedMetaObject->enumerator(i);
+ if ((m.name() == name) && (scope.isEmpty() || (m.scope() == scope)))
+ return true;
+ }
+ return false;
+}
+
static bool isNamedEnumerator(const QMetaObject *metaObj, const QByteArray &scopedName)
{
QByteArray scope;
@@ -909,52 +920,21 @@ static bool isNamedEnumerator(const QMetaObject *metaObj, const QByteArray &scop
} else {
name = scopedName;
}
- const QMetaObject *meta;
- if (scope == "Qt")
- meta = StaticQtMetaObject::get();
- else
- meta = metaObj;
- for (int i = meta->enumeratorCount() - 1; i >= 0; --i) {
- QMetaEnum m = meta->enumerator(i);
- if ((m.name() == name) && (scope.isEmpty() || (m.scope() == scope)))
- return true;
- }
- return false;
-}
-
-static bool passTypeAsInt(int type)
-{
- // We should not encounter the unknown type here.
- // In order to check that we need extra information.
- Q_ASSERT(type != QMetaType::UnknownType);
- const QMetaType::TypeFlags flags = QMetaType::typeFlags(type);
+ if (scope == "Qt")
+ return isNamedEnumeratorInScope(StaticQtMetaObject::get(), scope, name);
- // Cast enumerations to int.
- if (flags & QMetaType::IsEnumeration)
+ if (isNamedEnumeratorInScope(metaObj, scope, name))
return true;
- // Qt builtins can be handled as they are.
- if (type < int(QMetaType::User))
- return false;
-
- // Pointers to QObjects and QGadgets, and QGadgets themselves can be handled as they are.
- if (flags & (QMetaType::PointerToQObject | QMetaType::PointerToGadget | QMetaType::IsGadget))
- return false;
-
- // If it wasn't declared as metatype, better don't touch it.
- if (!(flags & QMetaType::WasDeclaredAsMetaType))
- return false;
-
- // If it needs construction or destruction (that is, it is a structured type),
- // pass as original type.
- if (flags & (QMetaType::NeedsConstruction | QMetaType::NeedsDestruction))
- return false;
+ if (metaObj->d.relatedMetaObjects && !scope.isEmpty()) {
+ for (auto related = metaObj->d.relatedMetaObjects; *related; ++related) {
+ if (isNamedEnumeratorInScope(*related, scope, name))
+ return true;
+ }
+ }
- // A single value that's not a pointer to a QObject or QGadget, not a builtin type, was declared
- // as meta type, but we don't know it as an enumeration (although it probably is one).
- // Pass as int if it fits into an int.
- return QMetaType::sizeOf(type) <= int(sizeof(int));
+ return false;
}
QQmlPropertyCacheMethodArguments *QQmlPropertyCache::createArgumentsObject(int argc, const QList<QByteArray> &names)
@@ -1658,14 +1638,18 @@ int QQmlMetaObject::methodReturnType(const QQmlPropertyData &data, QByteArray *u
propTypeName = m.typeName();
}
- if (type == QMetaType::UnknownType) {
+ if (QMetaType::sizeOf(type) <= int(sizeof(int))) {
+ if (QMetaType::typeFlags(type) & QMetaType::IsEnumeration)
+ return QMetaType::Int;
+
if (isNamedEnumerator(metaObject(), propTypeName))
- type = QVariant::Int;
- else if (unknownTypeError)
- *unknownTypeError = propTypeName;
- } else if (passTypeAsInt(type)) {
- type = QVariant::Int;
- }
+ return QMetaType::Int;
+
+ if (type == QMetaType::UnknownType) {
+ if (unknownTypeError)
+ *unknownTypeError = propTypeName;
+ }
+ } // else we know that it's a known type, as sizeOf(UnknownType) == 0
return type;
}
@@ -1704,18 +1688,23 @@ int *QQmlMetaObject::methodParameterTypes(int index, ArgTypeStorage *argStorage,
for (int ii = 0; ii < argc; ++ii) {
int type = m.parameterType(ii);
- if (type == QMetaType::UnknownType) {
+
+ if (QMetaType::sizeOf(type) > int(sizeof(int))) {
+ // Cannot be passed as int
+ // We know that it's a known type, as sizeOf(UnknownType) == 0
+ } else if (QMetaType::typeFlags(type) & QMetaType::IsEnumeration) {
+ type = QMetaType::Int;
+ } else {
if (argTypeNames.isEmpty())
argTypeNames = m.parameterTypes();
if (isNamedEnumerator(metaObject, argTypeNames.at(ii))) {
- type = QVariant::Int;
- } else {
+ type = QMetaType::Int;
+ } else if (type == QMetaType::UnknownType){
if (unknownTypeError)
*unknownTypeError = argTypeNames.at(ii);
return nullptr;
}
- } else if (passTypeAsInt(type)) {
- type = QVariant::Int;
+
}
args->arguments[ii + 1] = type;
}
@@ -1741,18 +1730,21 @@ int *QQmlMetaObject::methodParameterTypes(const QMetaMethod &m, ArgTypeStorage *
for (int ii = 0; ii < argc; ++ii) {
int type = m.parameterType(ii);
- if (type == QMetaType::UnknownType) {
+ if (QMetaType::sizeOf(type) > int(sizeof(int))) {
+ // Cannot be passed as int
+ // We know that it's a known type, as sizeOf(UnknownType) == 0
+ } else if (QMetaType::typeFlags(type) & QMetaType::IsEnumeration) {
+ type = QMetaType::Int;
+ } else {
if (argTypeNames.isEmpty())
argTypeNames = m.parameterTypes();
if (isNamedEnumerator(_m.asT2(), argTypeNames.at(ii))) {
- type = QVariant::Int;
- } else {
+ type = QMetaType::Int;
+ } else if (type == QMetaType::UnknownType) {
if (unknownTypeError)
*unknownTypeError = argTypeNames.at(ii);
return nullptr;
}
- } else if (passTypeAsInt(type)) {
- type = QVariant::Int;
}
argStorage->operator[](ii + 1) = type;
}
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index df6a8f1500..457558fb56 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -1821,6 +1821,11 @@ QString QQmlTypeLoader::absoluteFilePath(const QString &path)
// assets resource url
QFileInfo fileInfo(QQmlFile::urlToLocalFileOrQrc(path));
return fileInfo.isFile() ? fileInfo.absoluteFilePath() : QString();
+ } else if (path.count() > 8 && path.at(7) == QLatin1Char(':') && path.at(8) == QLatin1Char('/') &&
+ path.startsWith(QLatin1String("content"), Qt::CaseInsensitive)) {
+ // content url
+ QFileInfo fileInfo(QQmlFile::urlToLocalFileOrQrc(path));
+ return fileInfo.isFile() ? fileInfo.absoluteFilePath() : QString();
}
#endif
@@ -1878,6 +1883,11 @@ bool QQmlTypeLoader::fileExists(const QString &path, const QString &file)
// assets resource url
QFileInfo fileInfo(QQmlFile::urlToLocalFileOrQrc(path + file));
return fileInfo.isFile();
+ } else if (path.count() > 8 && path.at(7) == QLatin1Char(':') && path.at(8) == QLatin1Char('/') &&
+ path.startsWith(QLatin1String("content"), Qt::CaseInsensitive)) {
+ // content url
+ QFileInfo fileInfo(QQmlFile::urlToLocalFileOrQrc(path + file));
+ return fileInfo.isFile();
}
#endif
@@ -1891,8 +1901,6 @@ bool QQmlTypeLoader::fileExists(const QString &path, const QString &file)
if (!fileSet)
return false;
- QString absoluteFilePath;
-
bool *value = fileSet->object(file);
if (value) {
return *value;
@@ -1915,7 +1923,7 @@ bool QQmlTypeLoader::directoryExists(const QString &path)
bool isResource = path.at(0) == QLatin1Char(':');
#if defined(Q_OS_ANDROID)
- isResource = isResource || path.startsWith(QLatin1String("assets:/"));
+ isResource = isResource || path.startsWith(QLatin1String("assets:/")) || path.startsWith(QLatin1String("content:/"));
#endif
if (isResource) {
diff --git a/src/qml/qml/qqmlvaluetype.cpp b/src/qml/qml/qqmlvaluetype.cpp
index 2b21591017..e92488f9f6 100644
--- a/src/qml/qml/qqmlvaluetype.cpp
+++ b/src/qml/qml/qqmlvaluetype.cpp
@@ -191,7 +191,6 @@ void QQmlValueTypeFactory::registerValueTypes(const char *uri, int versionMajor,
QQmlValueType::QQmlValueType(int typeId, const QMetaObject *gadgetMetaObject)
: gadgetPtr(QMetaType::create(typeId))
- , typeId(typeId)
, metaType(typeId)
{
QObjectPrivate *op = QObjectPrivate::get(this);
@@ -230,12 +229,12 @@ void QQmlValueType::write(QObject *obj, int idx, QQmlPropertyData::WriteFlags fl
QVariant QQmlValueType::value()
{
Q_ASSERT(gadgetPtr);
- return QVariant(typeId, gadgetPtr);
+ return QVariant(metaType.id(), gadgetPtr);
}
void QQmlValueType::setValue(const QVariant &value)
{
- Q_ASSERT(typeId == value.userType());
+ Q_ASSERT(metaType.id() == value.userType());
metaType.destruct(gadgetPtr);
metaType.construct(gadgetPtr, value.constData());
}
diff --git a/src/qml/qml/qqmlvaluetype_p.h b/src/qml/qml/qqmlvaluetype_p.h
index 4ea71e8955..89f1b71d61 100644
--- a/src/qml/qml/qqmlvaluetype_p.h
+++ b/src/qml/qml/qqmlvaluetype_p.h
@@ -84,7 +84,6 @@ private:
void *gadgetPtr;
public:
- int typeId;
QMetaType metaType;
};
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index b22d1530e2..7df5757b95 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -107,7 +107,7 @@ void Heap::QQmlValueTypeWrapper::destroy()
void Heap::QQmlValueTypeWrapper::setValue(const QVariant &value) const
{
- Q_ASSERT(valueType->typeId == value.userType());
+ Q_ASSERT(valueType->metaType.id() == value.userType());
if (gadgetPtr)
valueType->metaType.destruct(gadgetPtr);
if (!gadgetPtr)
@@ -118,7 +118,7 @@ void Heap::QQmlValueTypeWrapper::setValue(const QVariant &value) const
QVariant Heap::QQmlValueTypeWrapper::toVariant() const
{
Q_ASSERT(gadgetPtr);
- return QVariant(valueType->typeId, gadgetPtr);
+ return QVariant(valueType->metaType.id(), gadgetPtr);
}
@@ -223,7 +223,7 @@ bool QQmlValueTypeWrapper::toGadget(void *data) const
if (const QQmlValueTypeReference *ref = as<const QQmlValueTypeReference>())
if (!ref->readReferenceValue())
return false;
- const int typeId = d()->valueType->typeId;
+ const int typeId = d()->valueType->metaType.id();
QMetaType::destruct(typeId, data);
QMetaType::construct(typeId, data, d()->gadgetPtr);
return true;
@@ -307,7 +307,7 @@ bool QQmlValueTypeWrapper::isEqual(const QVariant& value) const
int QQmlValueTypeWrapper::typeId() const
{
- return d()->valueType->typeId;
+ return d()->valueType->metaType.id();
}
bool QQmlValueTypeWrapper::write(QObject *target, int propertyIndex) const
@@ -354,10 +354,10 @@ ReturnedValue QQmlValueTypeWrapper::method_toString(const FunctionObject *b, con
// Prepare a buffer to pass to QMetaType::convert()
QString convertResult;
convertResult.~QString();
- if (QMetaType::convert(w->d()->gadgetPtr, w->d()->valueType->typeId, &convertResult, QMetaType::QString)) {
+ if (QMetaType::convert(w->d()->gadgetPtr, w->d()->valueType->metaType.id(), &convertResult, QMetaType::QString)) {
result = convertResult;
} else {
- result += QString::fromUtf8(QMetaType::typeName(w->d()->valueType->typeId))
+ result += QString::fromUtf8(QMetaType::typeName(w->d()->valueType->metaType.id()))
+ QLatin1Char('(');
const QMetaObject *mo = w->d()->propertyCache()->metaObject();
const int propCount = mo->propertyCount();
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index f713efb289..64dc581a56 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -1527,6 +1527,27 @@ static QString jsStack(QV4::ExecutionEngine *engine) {
return stack;
}
+static QString serializeArray(Object *array, ExecutionEngine *v4) {
+ Scope scope(v4);
+ ScopedValue val(scope);
+ QString result;
+
+ result += QLatin1Char('[');
+ const uint length = array->getLength();
+ for (uint i = 0; i < length; ++i) {
+ if (i != 0)
+ result += QLatin1Char(',');
+ val = array->get(i);
+ if (val->isManaged() && val->managed()->isArrayLike())
+ result += serializeArray(val->objectValue(), v4);
+ else
+ result += val->toQStringNoThrow();
+ }
+ result += QLatin1Char(']');
+
+ return result;
+};
+
static ReturnedValue writeToConsole(const FunctionObject *b, const Value *, const Value *argv, int argc,
ConsoleLogTypes logType, bool printStack = false)
{
@@ -1554,7 +1575,7 @@ static ReturnedValue writeToConsole(const FunctionObject *b, const Value *, cons
result.append(QLatin1Char(' '));
if (argv[i].isManaged() && argv[i].managed()->isArrayLike())
- result += QLatin1Char('[') + argv[i].toQStringNoThrow() + QLatin1Char(']');
+ result.append(serializeArray(argv[i].objectValue(), v4));
else
result.append(argv[i].toQStringNoThrow());
}
diff --git a/src/qml/qmldirparser/qmldirparser.pri b/src/qml/qmldirparser/qmldirparser.pri
new file mode 100644
index 0000000000..660e7b395a
--- /dev/null
+++ b/src/qml/qmldirparser/qmldirparser.pri
@@ -0,0 +1,11 @@
+INCLUDEPATH += $$PWD
+INCLUDEPATH += $$OUT_PWD
+
+HEADERS += \
+ $$PWD/qqmldirparser_p.h \
+ $$PWD/qqmlerror.h \
+ $$PWD/qqmlsourcecoordinate_p.h
+
+SOURCES += \
+ $$PWD/qqmldirparser.cpp \
+ $$PWD/qqmlerror.cpp
diff --git a/src/qml/qml/qqmldirparser.cpp b/src/qml/qmldirparser/qqmldirparser.cpp
index d87bf433b8..e944b52e47 100644
--- a/src/qml/qml/qqmldirparser.cpp
+++ b/src/qml/qmldirparser/qqmldirparser.cpp
@@ -367,12 +367,10 @@ QList<QQmlDirParser::Script> QQmlDirParser::scripts() const
return _scripts;
}
-#ifdef QT_CREATOR
QList<QQmlDirParser::TypeInfo> QQmlDirParser::typeInfos() const
{
return _typeInfos;
}
-#endif
bool QQmlDirParser::designerSupported() const
{
diff --git a/src/qml/qml/qqmldirparser_p.h b/src/qml/qmldirparser/qqmldirparser_p.h
index d7e29813d1..cff9cb11a4 100644
--- a/src/qml/qml/qqmldirparser_p.h
+++ b/src/qml/qmldirparser/qqmldirparser_p.h
@@ -122,7 +122,6 @@ public:
QList<Plugin> plugins() const;
bool designerSupported() const;
-#ifdef QT_CREATOR
struct TypeInfo
{
TypeInfo() {}
@@ -133,7 +132,6 @@ public:
};
QList<TypeInfo> typeInfos() const;
-#endif
QString className() const;
@@ -149,9 +147,7 @@ private:
QList<Script> _scripts;
QList<Plugin> _plugins;
bool _designerSupported;
-#ifdef QT_CREATOR
QList<TypeInfo> _typeInfos;
-#endif
QString _className;
};
diff --git a/src/qml/qml/qqmlerror.cpp b/src/qml/qmldirparser/qqmlerror.cpp
index 61e9a3f37e..5e181f7e27 100644
--- a/src/qml/qml/qqmlerror.cpp
+++ b/src/qml/qmldirparser/qqmlerror.cpp
@@ -38,15 +38,17 @@
****************************************************************************/
#include "qqmlerror.h"
-#include "qqmlglobal_p.h"
+#include "qqmlsourcecoordinate_p.h"
#include <QtCore/qdebug.h>
#include <QtCore/qfile.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qvector.h>
-#include <QtCore/qpointer.h>
-#include <private/qv4errorobject_p.h>
+#ifndef QT_NO_QOBJECT
+#include <QtCore/qobject.h>
+#include <QtCore/qpointer.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -85,11 +87,13 @@ public:
quint16 line;
quint16 column;
QtMsgType messageType;
+#ifndef QT_NO_QOBJECT
QPointer<QObject> object;
+#endif
};
QQmlErrorPrivate::QQmlErrorPrivate()
-: line(0), column(0), messageType(QtMsgType::QtWarningMsg), object()
+: line(0), column(0), messageType(QtMsgType::QtWarningMsg)
{
}
@@ -125,7 +129,9 @@ QQmlError &QQmlError::operator=(const QQmlError &other)
d->description = other.d->description;
d->line = other.d->line;
d->column = other.d->column;
+#ifndef QT_NO_QOBJECT
d->object = other.d->object;
+#endif
d->messageType = other.d->messageType;
}
return *this;
@@ -227,6 +233,7 @@ void QQmlError::setColumn(int column)
d->column = qmlSourceCoordinate(column);
}
+#ifndef QT_NO_QOBJECT
/*!
Returns the nearest object where this error occurred.
Exceptions in bound property expressions set this to the object
@@ -249,6 +256,7 @@ void QQmlError::setObject(QObject *object)
d = new QQmlErrorPrivate;
d->object = object;
}
+#endif // QT_NO_QOBJECT
/*!
\since 5.9
diff --git a/src/qml/qml/qqmlerror.h b/src/qml/qmldirparser/qqmlerror.h
index ef529e3828..f4221358e9 100644
--- a/src/qml/qml/qqmlerror.h
+++ b/src/qml/qmldirparser/qqmlerror.h
@@ -68,8 +68,12 @@ public:
void setLine(int);
int column() const;
void setColumn(int);
+
+#ifndef QT_NO_QOBJECT
QObject *object() const;
void setObject(QObject *);
+#endif
+
QtMsgType messageType() const;
void setMessageType(QtMsgType messageType);
diff --git a/src/qml/qmldirparser/qqmlsourcecoordinate_p.h b/src/qml/qmldirparser/qqmlsourcecoordinate_p.h
new file mode 100644
index 0000000000..76ac741ae8
--- /dev/null
+++ b/src/qml/qmldirparser/qqmlsourcecoordinate_p.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 QQMLSOURCECOORDINATE_P_H
+#define QQMLSOURCECOORDINATE_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.
+//
+
+#include <QtCore/qglobal.h>
+
+#include <climits>
+
+QT_BEGIN_NAMESPACE
+
+inline quint16 qmlSourceCoordinate(int n)
+{
+ return (n > 0 && n <= static_cast<int>(USHRT_MAX)) ? static_cast<quint16>(n) : 0;
+}
+
+inline int qmlSourceCoordinate(quint16 n)
+{
+ return (n == 0) ? -1 : static_cast<int>(n);
+}
+
+QT_END_NAMESPACE
+
+#endif // QQMLSOURCECOORDINATE_P_H
diff --git a/src/qml/qtqmlglobal.h b/src/qml/qtqmlglobal.h
index e02dfa5ed4..090b830b3c 100644
--- a/src/qml/qtqmlglobal.h
+++ b/src/qml/qtqmlglobal.h
@@ -53,6 +53,7 @@
#else
# define QT_FEATURE_qml_debug -1
# define QT_FEATURE_qml_sequence_object 1
+# define QT_FEATURE_qml_tracing -1
#endif
QT_BEGIN_NAMESPACE
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp
index 69b7876cf6..565e60b3c1 100644
--- a/src/qml/types/qqmllistmodel.cpp
+++ b/src/qml/types/qqmllistmodel.cpp
@@ -2764,6 +2764,8 @@ bool QQmlListModelParser::applyProperty(const QQmlRefPointer<QV4::CompiledData::
value = binding->valueAsNumber(compilationUnit->constants);
} else if (binding->type == QV4::CompiledData::Binding::Type_Boolean) {
value = binding->valueAsBoolean();
+ } else if (binding->type == QV4::CompiledData::Binding::Type_Null) {
+ value = QVariant::fromValue(nullptr);
} else if (binding->type == QV4::CompiledData::Binding::Type_Script) {
QString scriptStr = binding->valueAsScriptString(compilationUnit.data());
if (definesEmptyList(scriptStr)) {
diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp
index fe51f8ec47..edb112276c 100644
--- a/src/qml/types/qquickworkerscript.cpp
+++ b/src/qml/types/qquickworkerscript.cpp
@@ -481,7 +481,7 @@ void QQuickWorkerScriptEngine::run()
\qmltype WorkerScript
\instantiates QQuickWorkerScript
\ingroup qtquick-threading
- \inqmlmodule QtQuick
+ \inqmlmodule QtQml
\brief Enables the use of threads in a Qt Quick application.
Use WorkerScript to run operations in a new thread.
diff --git a/src/qmldebug/qmldebug.pro b/src/qmldebug/qmldebug.pro
index 0807482d23..94d300b765 100644
--- a/src/qmldebug/qmldebug.pro
+++ b/src/qmldebug/qmldebug.pro
@@ -9,20 +9,27 @@ SOURCES += \
qqmldebugconnection.cpp \
qqmldebugmessageclient.cpp \
qqmlenginecontrolclient.cpp \
+ qqmlenginedebugclient.cpp \
+ qqmlinspectorclient.cpp \
qqmlpreviewclient.cpp \
qqmlprofilerclient.cpp \
qqmlprofilerevent.cpp \
qqmlprofilereventlocation.cpp \
qqmlprofilereventtype.cpp \
- qqmlprofilertypedevent.cpp
+ qqmlprofilertypedevent.cpp \
+ qv4debugclient.cpp
HEADERS += \
qqmldebugclient_p.h \
qqmldebugclient_p_p.h \
qqmldebugconnection_p.h \
qqmldebugmessageclient_p.h \
+ qqmlenginedebugclient_p.h \
+ qqmlenginedebugclient_p_p.h \
qqmlenginecontrolclient_p.h \
qqmlenginecontrolclient_p_p.h \
+ qqmlinspectorclient_p.h \
+ qqmlinspectorclient_p_p.h \
qqmlpreviewclient_p.h \
qqmlpreviewclient_p_p.h \
qqmlprofilerclient_p.h \
@@ -32,4 +39,6 @@ HEADERS += \
qqmlprofilereventreceiver_p.h \
qqmlprofilereventtype_p.h \
qqmlprofilertypedevent_p.h \
- qqmlprofilerclientdefinitions_p.h
+ qqmlprofilerclientdefinitions_p.h \
+ qv4debugclient_p.h \
+ qv4debugclient_p_p.h
diff --git a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp b/src/qmldebug/qqmlenginedebugclient.cpp
index 7e736ec400..ec45ec33bc 100644
--- a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp
+++ b/src/qmldebug/qqmlenginedebugclient.cpp
@@ -26,22 +26,24 @@
**
****************************************************************************/
-#include "qqmlenginedebugclient.h"
+#include "qqmlenginedebugclient_p_p.h"
#include <private/qqmldebugconnection_p.h>
-struct QmlObjectData {
+QT_BEGIN_NAMESPACE
+
+struct QQmlObjectData {
QUrl url;
- int lineNumber;
- int columnNumber;
+ int lineNumber = -1;
+ int columnNumber = -1;
QString idString;
QString objectName;
QString objectType;
- int objectId;
- int contextId;
- int parentId;
+ int objectId = -1;
+ int contextId = -1;
+ int parentId = -1;
};
-QPacket &operator>>(QPacket &ds, QmlObjectData &data)
+QPacket &operator>>(QPacket &ds, QQmlObjectData &data)
{
ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString
>> data.objectName >> data.objectType >> data.objectId >> data.contextId
@@ -49,35 +51,38 @@ QPacket &operator>>(QPacket &ds, QmlObjectData &data)
return ds;
}
-struct QmlObjectProperty {
+struct QQmlObjectProperty {
enum Type { Unknown, Basic, Object, List, SignalProperty };
- Type type;
+ Type type = Unknown;
QString name;
QVariant value;
QString valueTypeName;
QString binding;
- bool hasNotifySignal;
+ bool hasNotifySignal = false;
};
-QPacket &operator>>(QPacket &ds, QmlObjectProperty &data)
+QPacket &operator>>(QPacket &ds, QQmlObjectProperty &data)
{
int type;
ds >> type >> data.name >> data.value >> data.valueTypeName
>> data.binding >> data.hasNotifySignal;
- data.type = (QmlObjectProperty::Type)type;
+ data.type = (QQmlObjectProperty::Type)type;
return ds;
}
-QQmlEngineDebugClient::QQmlEngineDebugClient(
- QQmlDebugConnection *connection)
- : QQmlDebugClient(QLatin1String("QmlDebugger"), connection),
- m_nextId(0),
- m_valid(false)
+QQmlEngineDebugClient::QQmlEngineDebugClient(QQmlDebugConnection *connection) :
+ QQmlDebugClient(*new QQmlEngineDebugClientPrivate(connection))
+{
+}
+
+QQmlEngineDebugClientPrivate::QQmlEngineDebugClientPrivate(QQmlDebugConnection *connection) :
+ QQmlDebugClientPrivate (QLatin1String("QmlDebugger"), connection)
{
}
+
quint32 QQmlEngineDebugClient::addWatch(
- const QmlDebugPropertyReference &property, bool *success)
+ const QQmlEngineDebugPropertyReference &property, bool *success)
{
quint32 id = -1;
*success = false;
@@ -93,7 +98,7 @@ quint32 QQmlEngineDebugClient::addWatch(
}
quint32 QQmlEngineDebugClient::addWatch(
- const QmlDebugContextReference &, const QString &, bool *success)
+ const QQmlEngineDebugContextReference &, const QString &, bool *success)
{
*success = false;
qWarning("QQmlEngineDebugClient::addWatch(): Not implemented");
@@ -101,7 +106,7 @@ quint32 QQmlEngineDebugClient::addWatch(
}
quint32 QQmlEngineDebugClient::addWatch(
- const QmlDebugObjectReference &object, const QString &expr,
+ const QQmlEngineDebugObjectReference &object, const QString &expr,
bool *success)
{
quint32 id = -1;
@@ -117,7 +122,7 @@ quint32 QQmlEngineDebugClient::addWatch(
}
quint32 QQmlEngineDebugClient::addWatch(
- const QmlDebugObjectReference &object, bool *success)
+ const QQmlEngineDebugObjectReference &object, bool *success)
{
quint32 id = -1;
*success = false;
@@ -132,7 +137,7 @@ quint32 QQmlEngineDebugClient::addWatch(
}
quint32 QQmlEngineDebugClient::addWatch(
- const QmlDebugFileReference &, bool *success)
+ const QQmlEngineDebugFileReference &, bool *success)
{
*success = false;
qWarning("QQmlEngineDebugClient::addWatch(): Not implemented");
@@ -152,7 +157,8 @@ void QQmlEngineDebugClient::removeWatch(quint32 id, bool *success)
quint32 QQmlEngineDebugClient::queryAvailableEngines(bool *success)
{
- m_engines.clear();
+ Q_D(QQmlEngineDebugClient);
+ d->engines.clear();
quint32 id = -1;
*success = false;
if (state() == QQmlDebugClient::Enabled) {
@@ -166,9 +172,10 @@ quint32 QQmlEngineDebugClient::queryAvailableEngines(bool *success)
}
quint32 QQmlEngineDebugClient::queryRootContexts(
- const QmlDebugEngineReference &engine, bool *success)
+ const QQmlEngineDebugEngineReference &engine, bool *success)
{
- m_rootContext = QmlDebugContextReference();
+ Q_D(QQmlEngineDebugClient);
+ d->rootContext = QQmlEngineDebugContextReference();
quint32 id = -1;
*success = false;
if (state() == QQmlDebugClient::Enabled && engine.debugId != -1) {
@@ -182,9 +189,10 @@ quint32 QQmlEngineDebugClient::queryRootContexts(
}
quint32 QQmlEngineDebugClient::queryObject(
- const QmlDebugObjectReference &object, bool *success)
+ const QQmlEngineDebugObjectReference &object, bool *success)
{
- m_object = QmlDebugObjectReference();
+ Q_D(QQmlEngineDebugClient);
+ d->object = QQmlEngineDebugObjectReference();
quint32 id = -1;
*success = false;
if (state() == QQmlDebugClient::Enabled && object.debugId != -1) {
@@ -200,7 +208,8 @@ quint32 QQmlEngineDebugClient::queryObject(
quint32 QQmlEngineDebugClient::queryObjectsForLocation(
const QString &file, int lineNumber, int columnNumber, bool *success)
{
- m_objects.clear();
+ Q_D(QQmlEngineDebugClient);
+ d->objects.clear();
quint32 id = -1;
*success = false;
if (state() == QQmlDebugClient::Enabled) {
@@ -215,9 +224,10 @@ quint32 QQmlEngineDebugClient::queryObjectsForLocation(
}
quint32 QQmlEngineDebugClient::queryObjectRecursive(
- const QmlDebugObjectReference &object, bool *success)
+ const QQmlEngineDebugObjectReference &object, bool *success)
{
- m_object = QmlDebugObjectReference();
+ Q_D(QQmlEngineDebugClient);
+ d->object = QQmlEngineDebugObjectReference();
quint32 id = -1;
*success = false;
if (state() == QQmlDebugClient::Enabled && object.debugId != -1) {
@@ -233,7 +243,8 @@ quint32 QQmlEngineDebugClient::queryObjectRecursive(
quint32 QQmlEngineDebugClient::queryObjectsForLocationRecursive(const QString &file,
int lineNumber, int columnNumber, bool *success)
{
- m_objects.clear();
+ Q_D(QQmlEngineDebugClient);
+ d->objects.clear();
quint32 id = -1;
*success = false;
if (state() == QQmlDebugClient::Enabled) {
@@ -250,7 +261,8 @@ quint32 QQmlEngineDebugClient::queryObjectsForLocationRecursive(const QString &f
quint32 QQmlEngineDebugClient::queryExpressionResult(
int objectDebugId, const QString &expr, bool *success)
{
- m_exprResult = QVariant();
+ Q_D(QQmlEngineDebugClient);
+ d->exprResult = QVariant();
quint32 id = -1;
*success = false;
if (state() == QQmlDebugClient::Enabled) {
@@ -267,7 +279,8 @@ quint32 QQmlEngineDebugClient::queryExpressionResult(
quint32 QQmlEngineDebugClient::queryExpressionResultBC(
int objectDebugId, const QString &expr, bool *success)
{
- m_exprResult = QVariant();
+ Q_D(QQmlEngineDebugClient);
+ d->exprResult = QVariant();
quint32 id = -1;
*success = false;
if (state() == QQmlDebugClient::Enabled) {
@@ -285,7 +298,7 @@ quint32 QQmlEngineDebugClient::setBindingForObject(
const QString &propertyName,
const QVariant &bindingExpression,
bool isLiteralValue,
- QString source, int line,
+ const QString &source, int line,
bool *success)
{
quint32 id = -1;
@@ -336,10 +349,10 @@ quint32 QQmlEngineDebugClient::setMethodBody(
}
void QQmlEngineDebugClient::decode(QPacket &ds,
- QmlDebugObjectReference &o,
+ QQmlEngineDebugObjectReference &o,
bool simple)
{
- QmlObjectData data;
+ QQmlObjectData data;
ds >> data;
o.debugId = data.objectId;
o.className = data.objectType;
@@ -358,7 +371,7 @@ void QQmlEngineDebugClient::decode(QPacket &ds,
ds >> childCount >> recur;
for (int ii = 0; ii < childCount; ++ii) {
- o.children.append(QmlDebugObjectReference());
+ o.children.append(QQmlEngineDebugObjectReference());
decode(ds, o.children.last(), !recur);
}
@@ -366,31 +379,31 @@ void QQmlEngineDebugClient::decode(QPacket &ds,
ds >> propCount;
for (int ii = 0; ii < propCount; ++ii) {
- QmlObjectProperty data;
+ QQmlObjectProperty data;
ds >> data;
- QmlDebugPropertyReference prop;
+ QQmlEngineDebugPropertyReference prop;
prop.objectDebugId = o.debugId;
prop.name = data.name;
prop.binding = data.binding;
prop.hasNotifySignal = data.hasNotifySignal;
prop.valueTypeName = data.valueTypeName;
switch (data.type) {
- case QmlObjectProperty::Basic:
- case QmlObjectProperty::List:
- case QmlObjectProperty::SignalProperty:
+ case QQmlObjectProperty::Basic:
+ case QQmlObjectProperty::List:
+ case QQmlObjectProperty::SignalProperty:
{
prop.value = data.value;
break;
}
- case QmlObjectProperty::Object:
+ case QQmlObjectProperty::Object:
{
- QmlDebugObjectReference obj;
+ QQmlEngineDebugObjectReference obj;
obj.name = data.value.toString();
obj.className = prop.valueTypeName;
prop.value = qVariantFromValue(obj);
break;
}
- case QmlObjectProperty::Unknown:
+ case QQmlObjectProperty::Unknown:
break;
}
o.properties << prop;
@@ -398,20 +411,56 @@ void QQmlEngineDebugClient::decode(QPacket &ds,
}
void QQmlEngineDebugClient::decode(QPacket &ds,
- QList<QmlDebugObjectReference> &o,
+ QList<QQmlEngineDebugObjectReference> &o,
bool simple)
{
int count;
ds >> count;
for (int i = 0; i < count; i++) {
- QmlDebugObjectReference obj;
+ QQmlEngineDebugObjectReference obj;
decode(ds, obj, simple);
o << obj;
}
}
+QList<QQmlEngineDebugEngineReference> QQmlEngineDebugClient::engines() const
+{
+ Q_D(const QQmlEngineDebugClient);
+ return d->engines;
+}
+
+QQmlEngineDebugContextReference QQmlEngineDebugClient::rootContext() const
+{
+ Q_D(const QQmlEngineDebugClient);
+ return d->rootContext;
+}
+
+QQmlEngineDebugObjectReference QQmlEngineDebugClient::object() const
+{
+ Q_D(const QQmlEngineDebugClient);
+ return d->object;
+}
+
+QList<QQmlEngineDebugObjectReference> QQmlEngineDebugClient::objects() const
+{
+ Q_D(const QQmlEngineDebugClient);
+ return d->objects;
+}
+
+QVariant QQmlEngineDebugClient::resultExpr() const
+{
+ Q_D(const QQmlEngineDebugClient);
+ return d->exprResult;
+}
+
+bool QQmlEngineDebugClient::valid() const
+{
+ Q_D(const QQmlEngineDebugClient);
+ return d->valid;
+}
+
void QQmlEngineDebugClient::decode(QPacket &ds,
- QmlDebugContextReference &c)
+ QQmlEngineDebugContextReference &c)
{
ds >> c.name >> c.debugId;
@@ -419,7 +468,7 @@ void QQmlEngineDebugClient::decode(QPacket &ds,
ds >> contextCount;
for (int ii = 0; ii < contextCount; ++ii) {
- c.contexts.append(QmlDebugContextReference());
+ c.contexts.append(QQmlEngineDebugContextReference());
decode(ds, c.contexts.last());
}
@@ -427,7 +476,7 @@ void QQmlEngineDebugClient::decode(QPacket &ds,
ds >> objectCount;
for (int ii = 0; ii < objectCount; ++ii) {
- QmlDebugObjectReference obj;
+ QQmlEngineDebugObjectReference obj;
decode(ds, obj, true);
obj.contextDebugId = c.debugId;
@@ -437,7 +486,8 @@ void QQmlEngineDebugClient::decode(QPacket &ds,
void QQmlEngineDebugClient::messageReceived(const QByteArray &data)
{
- m_valid = false;
+ Q_D(QQmlEngineDebugClient);
+ d->valid = false;
QPacket ds(connection()->currentDataStreamVersion(), data);
int queryId;
@@ -450,36 +500,36 @@ void QQmlEngineDebugClient::messageReceived(const QByteArray &data)
int count;
ds >> count;
- m_engines.clear();
+ d->engines.clear();
for (int ii = 0; ii < count; ++ii) {
- QmlDebugEngineReference eng;
+ QQmlEngineDebugEngineReference eng;
ds >> eng.name;
ds >> eng.debugId;
- m_engines << eng;
+ d->engines << eng;
}
} else if (type == "LIST_OBJECTS_R") {
if (!ds.atEnd())
- decode(ds, m_rootContext);
+ decode(ds, d->rootContext);
} else if (type == "FETCH_OBJECT_R") {
if (!ds.atEnd())
- decode(ds, m_object, false);
+ decode(ds, d->object, false);
} else if (type == "FETCH_OBJECTS_FOR_LOCATION_R") {
if (!ds.atEnd())
- decode(ds, m_objects, false);
+ decode(ds, d->objects, false);
} else if (type == "EVAL_EXPRESSION_R") {;
- ds >> m_exprResult;
+ ds >> d->exprResult;
} else if (type == "WATCH_PROPERTY_R") {
- ds >> m_valid;
+ ds >> d->valid;
} else if (type == "WATCH_OBJECT_R") {
- ds >> m_valid;
+ ds >> d->valid;
} else if (type == "WATCH_EXPR_OBJECT_R") {
- ds >> m_valid;
+ ds >> d->valid;
} else if (type == "UPDATE_WATCH") {
int debugId;
@@ -495,14 +545,22 @@ void QQmlEngineDebugClient::messageReceived(const QByteArray &data)
emit newObject(objectId);
return;
} else if (type == "SET_BINDING_R") {
- ds >> m_valid;
+ ds >> d->valid;
} else if (type == "RESET_BINDING_R") {
- ds >> m_valid;
+ ds >> d->valid;
} else if (type == "SET_METHOD_BODY_R") {
- ds >> m_valid;
+ ds >> d->valid;
} else if (type == "NO_WATCH_R") {
- ds >> m_valid;
+ ds >> d->valid;
}
emit result();
}
+
+quint32 QQmlEngineDebugClient::getId()
+{
+ Q_D(QQmlEngineDebugClient);
+ return d->nextId++;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qmldebug/qqmlenginedebugclient_p.h b/src/qmldebug/qqmlenginedebugclient_p.h
new file mode 100644
index 0000000000..4a9cc3a020
--- /dev/null
+++ b/src/qmldebug/qqmlenginedebugclient_p.h
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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: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$
+**
+****************************************************************************/
+
+#ifndef QQMLENGINEDEBUGCLIENT_H
+#define QQMLENGINEDEBUGCLIENT_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qqmldebugclient_p.h>
+#include <private/qpacket_p.h>
+
+#include <QtCore/qurl.h>
+#include <QtCore/qvariant.h>
+
+QT_BEGIN_NAMESPACE
+
+struct QQmlEngineDebugPropertyReference
+{
+ int objectDebugId = -1;
+ QString name;
+ QVariant value;
+ QString valueTypeName;
+ QString binding;
+ bool hasNotifySignal = false;
+};
+
+struct QQmlEngineDebugFileReference
+{
+ QUrl url;
+ int lineNumber = -1;
+ int columnNumber = -1;
+};
+
+struct QQmlEngineDebugObjectReference
+{
+ int debugId = -1;
+ QString className;
+ QString idString;
+ QString name;
+ QQmlEngineDebugFileReference source;
+ int contextDebugId = -1;
+ QList<QQmlEngineDebugPropertyReference> properties;
+ QList<QQmlEngineDebugObjectReference> children;
+};
+
+struct QQmlEngineDebugContextReference
+{
+ int debugId = -1;
+ QString name;
+ QList<QQmlEngineDebugObjectReference> objects;
+ QList<QQmlEngineDebugContextReference> contexts;
+};
+
+struct QQmlEngineDebugEngineReference
+{
+ int debugId = -1;
+ QString name;
+};
+
+class QQmlEngineDebugClientPrivate;
+class QQmlEngineDebugClient : public QQmlDebugClient
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQmlEngineDebugClient)
+
+public:
+ explicit QQmlEngineDebugClient(QQmlDebugConnection *conn);
+
+ quint32 addWatch(const QQmlEngineDebugPropertyReference &,
+ bool *success);
+ quint32 addWatch(const QQmlEngineDebugContextReference &, const QString &,
+ bool *success);
+ quint32 addWatch(const QQmlEngineDebugObjectReference &, const QString &,
+ bool *success);
+ quint32 addWatch(const QQmlEngineDebugObjectReference &,
+ bool *success);
+ quint32 addWatch(const QQmlEngineDebugFileReference &,
+ bool *success);
+
+ void removeWatch(quint32 watch, bool *success);
+
+ quint32 queryAvailableEngines(bool *success);
+ quint32 queryRootContexts(const QQmlEngineDebugEngineReference &,
+ bool *success);
+ quint32 queryObject(const QQmlEngineDebugObjectReference &,
+ bool *success);
+ quint32 queryObjectsForLocation(const QString &file,
+ int lineNumber, int columnNumber, bool *success);
+ quint32 queryObjectRecursive(const QQmlEngineDebugObjectReference &,
+ bool *success);
+ quint32 queryObjectsForLocationRecursive(const QString &file,
+ int lineNumber, int columnNumber, bool *success);
+ quint32 queryExpressionResult(int objectDebugId,
+ const QString &expr,
+ bool *success);
+ quint32 queryExpressionResultBC(int objectDebugId,
+ const QString &expr,
+ bool *success);
+ quint32 setBindingForObject(int objectDebugId, const QString &propertyName,
+ const QVariant &bindingExpression,
+ bool isLiteralValue,
+ const QString &source, int line, bool *success);
+ quint32 resetBindingForObject(int objectDebugId,
+ const QString &propertyName, bool *success);
+ quint32 setMethodBody(int objectDebugId, const QString &methodName,
+ const QString &methodBody, bool *success);
+
+ quint32 getId();
+
+ void decode(QPacket &ds, QQmlEngineDebugContextReference &);
+ void decode(QPacket &ds, QQmlEngineDebugObjectReference &, bool simple);
+ void decode(QPacket &ds, QList<QQmlEngineDebugObjectReference> &o, bool simple);
+
+ QList<QQmlEngineDebugEngineReference> engines() const;
+ QQmlEngineDebugContextReference rootContext() const;
+ QQmlEngineDebugObjectReference object() const;
+ QList<QQmlEngineDebugObjectReference> objects() const;
+ QVariant resultExpr() const;
+ bool valid() const;
+
+signals:
+ void newObject(int objectId);
+ void valueChanged(QByteArray,QVariant);
+ void result();
+
+protected:
+ void messageReceived(const QByteArray &) override;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QQmlEngineDebugObjectReference)
+
+#endif // QQMLENGINEDEBUGCLIENT_H
diff --git a/src/qmldebug/qqmlenginedebugclient_p_p.h b/src/qmldebug/qqmlenginedebugclient_p_p.h
new file mode 100644
index 0000000000..7c992ad3ab
--- /dev/null
+++ b/src/qmldebug/qqmlenginedebugclient_p_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 QQMLENGINEDEBUGCLIENT_P_P_H
+#define QQMLENGINEDEBUGCLIENT_P_P_H
+
+#include "qqmlenginedebugclient_p.h"
+#include "qqmldebugclient_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.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QQmlEngineDebugClientPrivate : public QQmlDebugClientPrivate
+{
+ Q_DECLARE_PUBLIC(QQmlEngineDebugClient)
+public:
+ QQmlEngineDebugClientPrivate(QQmlDebugConnection *connection);
+
+ quint32 nextId = 0;
+ bool valid = false;
+ QList<QQmlEngineDebugEngineReference> engines;
+ QQmlEngineDebugContextReference rootContext;
+ QQmlEngineDebugObjectReference object;
+ QList<QQmlEngineDebugObjectReference> objects;
+ QVariant exprResult;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLENGINEDEBUGCLIENT_P_P_H
diff --git a/tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp b/src/qmldebug/qqmlinspectorclient.cpp
index 20faef177e..1de52bd0c1 100644
--- a/tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp
+++ b/src/qmldebug/qqmlinspectorclient.cpp
@@ -1,11 +1,11 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the test suite of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** $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
@@ -14,96 +14,120 @@
** 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 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** 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-3.0.html.
+** 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 "qqmlinspectorclient.h"
+#include "qqmlinspectorclient_p_p.h"
#include <private/qpacket_p.h>
#include <private/qqmldebugconnection_p.h>
#include <QtCore/qdebug.h>
+QT_BEGIN_NAMESPACE
+
QQmlInspectorClient::QQmlInspectorClient(QQmlDebugConnection *connection) :
- QQmlDebugClient(QLatin1String("QmlInspector"), connection),
- m_lastRequestId(-1)
+ QQmlDebugClient(*new QQmlInspectorClientPrivate(connection))
+{
+}
+
+QQmlInspectorClientPrivate::QQmlInspectorClientPrivate(QQmlDebugConnection *connection) :
+ QQmlDebugClientPrivate(QLatin1String("QmlInspector"), connection)
{
}
int QQmlInspectorClient::setInspectToolEnabled(bool enabled)
{
+ Q_D(QQmlInspectorClient);
QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("request") << ++m_lastRequestId
+ ds << QByteArray("request") << ++(d->m_lastRequestId)
<< QByteArray(enabled ? "enable" : "disable");
sendMessage(ds.data());
- return m_lastRequestId;
+ return d->m_lastRequestId;
}
int QQmlInspectorClient::setShowAppOnTop(bool showOnTop)
{
+ Q_D(QQmlInspectorClient);
QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("request") << ++m_lastRequestId
+ ds << QByteArray("request") << ++(d->m_lastRequestId)
<< QByteArray("showAppOnTop") << showOnTop;
sendMessage(ds.data());
- return m_lastRequestId;
+ return d->m_lastRequestId;
}
int QQmlInspectorClient::setAnimationSpeed(qreal speed)
{
+ Q_D(QQmlInspectorClient);
QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("request") << ++m_lastRequestId
+ ds << QByteArray("request") << ++(d->m_lastRequestId)
<< QByteArray("setAnimationSpeed") << speed;
sendMessage(ds.data());
- return m_lastRequestId;
+ return d->m_lastRequestId;
}
int QQmlInspectorClient::select(const QList<int> &objectIds)
{
+ Q_D(QQmlInspectorClient);
QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("request") << ++m_lastRequestId
+ ds << QByteArray("request") << ++(d->m_lastRequestId)
<< QByteArray("select") << objectIds;
sendMessage(ds.data());
- return m_lastRequestId;
+ return d->m_lastRequestId;
}
int QQmlInspectorClient::createObject(const QString &qml, int parentId, const QStringList &imports,
const QString &filename)
{
+ Q_D(QQmlInspectorClient);
QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("request") << ++m_lastRequestId
+ ds << QByteArray("request") << ++(d->m_lastRequestId)
<< QByteArray("createObject") << qml << parentId << imports << filename;
sendMessage(ds.data());
- return m_lastRequestId;
+ return d->m_lastRequestId;
}
int QQmlInspectorClient::moveObject(int childId, int newParentId)
{
+ Q_D(QQmlInspectorClient);
QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("request") << ++m_lastRequestId
+ ds << QByteArray("request") << ++(d->m_lastRequestId)
<< QByteArray("moveObject") << childId << newParentId;
sendMessage(ds.data());
- return m_lastRequestId;
+ return d->m_lastRequestId;
}
int QQmlInspectorClient::destroyObject(int objectId)
{
+ Q_D(QQmlInspectorClient);
QPacket ds(connection()->currentDataStreamVersion());
- ds << QByteArray("request") << ++m_lastRequestId
+ ds << QByteArray("request") << ++(d->m_lastRequestId)
<< QByteArray("destroyObject") << objectId;
sendMessage(ds.data());
- return m_lastRequestId;
+ return d->m_lastRequestId;
}
void QQmlInspectorClient::messageReceived(const QByteArray &message)
@@ -122,3 +146,5 @@ void QQmlInspectorClient::messageReceived(const QByteArray &message)
ds >> responseId >> result;
emit responseReceived(responseId, result);
}
+
+QT_END_NAMESPACE
diff --git a/src/qmldebug/qqmlinspectorclient_p.h b/src/qmldebug/qqmlinspectorclient_p.h
new file mode 100644
index 0000000000..d4ab136c9a
--- /dev/null
+++ b/src/qmldebug/qqmlinspectorclient_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 QQMLINSPECTORCLIENT_P_H
+#define QQMLINSPECTORCLIENT_P_H
+
+#include <private/qqmldebugclient_p.h>
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QQmlInspectorClientPrivate;
+class QQmlInspectorClient : public QQmlDebugClient
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQmlInspectorClient)
+
+public:
+ QQmlInspectorClient(QQmlDebugConnection *connection);
+
+ int setInspectToolEnabled(bool enabled);
+ int setShowAppOnTop(bool showOnTop);
+ int setAnimationSpeed(qreal speed);
+ int select(const QList<int> &objectIds);
+ int createObject(const QString &qml, int parentId, const QStringList &imports,
+ const QString &filename);
+ int moveObject(int childId, int newParentId);
+ int destroyObject(int objectId);
+
+signals:
+ void responseReceived(int requestId, bool result);
+
+protected:
+ void messageReceived(const QByteArray &message) override;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLINSPECTORCLIENT_P_H
diff --git a/src/qmldebug/qqmlinspectorclient_p_p.h b/src/qmldebug/qqmlinspectorclient_p_p.h
new file mode 100644
index 0000000000..91537dd994
--- /dev/null
+++ b/src/qmldebug/qqmlinspectorclient_p_p.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 QQMLINSPECTORCLIENT_P_P_H
+#define QQMLINSPECTORCLIENT_P_P_H
+
+#include "qqmlinspectorclient_p.h"
+#include "qqmldebugclient_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.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QQmlInspectorClientPrivate : public QQmlDebugClientPrivate
+{
+ Q_DECLARE_PUBLIC(QQmlInspectorClient)
+public:
+ QQmlInspectorClientPrivate(QQmlDebugConnection *connection);
+ int m_lastRequestId = -1;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLINSPECTORCLIENT_P_P_H
diff --git a/src/qmldebug/qv4debugclient.cpp b/src/qmldebug/qv4debugclient.cpp
new file mode 100644
index 0000000000..76c2f1ebea
--- /dev/null
+++ b/src/qmldebug/qv4debugclient.cpp
@@ -0,0 +1,578 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 "qv4debugclient_p.h"
+#include "qv4debugclient_p_p.h"
+#include "qqmldebugconnection_p.h"
+
+#include <private/qpacket_p.h>
+
+#include <QJsonDocument>
+#include <QJsonObject>
+#include <QJsonValue>
+#include <QJsonArray>
+
+QT_BEGIN_NAMESPACE
+
+const char *V8REQUEST = "v8request";
+const char *V8MESSAGE = "v8message";
+const char *SEQ = "seq";
+const char *TYPE = "type";
+const char *COMMAND = "command";
+const char *ARGUMENTS = "arguments";
+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";
+const char *INCLUDESOURCE = "includeSource";
+const char *FROMFRAME = "fromFrame";
+const char *TOFRAME = "toFrame";
+const char *BOTTOM = "bottom";
+const char *NUMBER = "number";
+const char *FRAMENUMBER = "frameNumber";
+const char *TYPES = "types";
+const char *IDS = "ids";
+const char *FILTER = "filter";
+const char *FROMLINE = "fromLine";
+const char *TOLINE = "toLine";
+const char *TARGET = "target";
+const char *LINE = "line";
+const char *COLUMN = "column";
+const char *ENABLED = "enabled";
+const char *CONDITION = "condition";
+const char *IGNORECOUNT = "ignoreCount";
+const char *BREAKPOINT = "breakpoint";
+const char *FLAGS = "flags";
+
+const char *CONTINEDEBUGGING = "continue";
+const char *EVALUATE = "evaluate";
+const char *LOOKUP = "lookup";
+const char *BACKTRACE = "backtrace";
+const char *SCOPE = "scope";
+const char *SCOPES = "scopes";
+const char *SCRIPTS = "scripts";
+const char *SOURCE = "source";
+const char *SETBREAKPOINT = "setbreakpoint";
+const char *CLEARBREAKPOINT = "clearbreakpoint";
+const char *CHANGEBREAKPOINT = "changebreakpoint";
+const char *SETEXCEPTIONBREAK = "setexceptionbreak";
+const char *VERSION = "version";
+const char *DISCONNECT = "disconnect";
+const char *GARBAGECOLLECTOR = "gc";
+
+const char *CONNECT = "connect";
+const char *INTERRUPT = "interrupt";
+
+const char *REQUEST = "request";
+const char *IN = "in";
+const char *NEXT = "next";
+const char *OUT = "out";
+
+const char *SCRIPT = "script";
+const char *SCRIPTREGEXP = "scriptRegExp";
+const char *EVENT = "event";
+
+const char *ALL = "all";
+const char *UNCAUGHT = "uncaught";
+
+#define VARIANTMAPINIT \
+ Q_D(QV4DebugClient); \
+ QJsonObject jsonVal; \
+ jsonVal.insert(QLatin1String(SEQ), d->seq++); \
+ jsonVal.insert(QLatin1String(TYPE), QLatin1String(REQUEST));
+
+QV4DebugClient::QV4DebugClient(QQmlDebugConnection *connection)
+ : QQmlDebugClient(*new QV4DebugClientPrivate(connection))
+{
+ QObject::connect(this, &QQmlDebugClient::stateChanged,
+ this, [this](State state) { d_func()->onStateChanged(state); });
+}
+
+QV4DebugClientPrivate::QV4DebugClientPrivate(QQmlDebugConnection *connection) :
+ QQmlDebugClientPrivate(QLatin1String("V8Debugger"), connection)
+{
+}
+
+void QV4DebugClient::connect()
+{
+ Q_D(QV4DebugClient);
+ d->sendMessage(CONNECT);
+}
+
+void QV4DebugClient::interrupt()
+{
+ Q_D(QV4DebugClient);
+ d->sendMessage(INTERRUPT);
+}
+
+void QV4DebugClient::continueDebugging(StepAction action)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "continue",
+ // "arguments" : { "stepaction" : <"in", "next" or "out">,
+ // "stepcount" : <number of steps (default 1)>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.insert(QLatin1String(COMMAND), QLatin1String(CONTINEDEBUGGING));
+
+ if (action != Continue) {
+ QJsonObject args;
+ switch (action) {
+ case In:
+ args.insert(QLatin1String(STEPACTION), QLatin1String(IN));
+ break;
+ case Out:
+ args.insert(QLatin1String(STEPACTION), QLatin1String(OUT));
+ break;
+ case Next:
+ args.insert(QLatin1String(STEPACTION), QLatin1String(NEXT));
+ break;
+ default:
+ break;
+ }
+ jsonVal.insert(QLatin1String(ARGUMENTS), args);
+ }
+
+ d->sendMessage(V8REQUEST, jsonVal);
+}
+
+void QV4DebugClient::evaluate(const QString &expr, int frame, int context)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "evaluate",
+ // "arguments" : { "expression" : <expression to evaluate>,
+ // "frame" : <number>,
+ // "context" : <object ID>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.insert(QLatin1String(COMMAND), QLatin1String(EVALUATE));
+
+ QJsonObject args;
+ args.insert(QLatin1String(EXPRESSION), expr);
+
+ if (frame != -1)
+ args.insert(QLatin1String(FRAME), frame);
+
+ if (context != -1)
+ args.insert(QLatin1String(CONTEXT), context);
+
+ jsonVal.insert(QLatin1String(ARGUMENTS), args);
+
+ d->sendMessage(V8REQUEST, jsonVal);
+}
+
+void QV4DebugClient::lookup(const QList<int> &handles, bool includeSource)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "lookup",
+ // "arguments" : { "handles" : <array of handles>,
+ // "includeSource" : <boolean indicating whether the source will be included when script objects are returned>,
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.insert(QLatin1String(COMMAND),(QLatin1String(LOOKUP)));
+
+ QJsonObject args;
+ QJsonArray array;
+
+ for (int handle : handles)
+ array.append(handle);
+
+ args.insert(QLatin1String(HANDLES), array);
+
+ if (includeSource)
+ args.insert(QLatin1String(INCLUDESOURCE), includeSource);
+
+ jsonVal.insert(QLatin1String(ARGUMENTS), args);
+
+ d->sendMessage(V8REQUEST, jsonVal);
+}
+
+void QV4DebugClient::backtrace(int fromFrame, int toFrame, bool bottom)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "backtrace",
+ // "arguments" : { "fromFrame" : <number>
+ // "toFrame" : <number>
+ // "bottom" : <boolean, set to true if the bottom of the stack is requested>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.insert(QLatin1String(COMMAND), QLatin1String(BACKTRACE));
+
+ QJsonObject args;
+
+ if (fromFrame != -1)
+ args.insert(QLatin1String(FROMFRAME), fromFrame);
+
+ if (toFrame != -1)
+ args.insert(QLatin1String(TOFRAME), toFrame);
+
+ if (bottom)
+ args.insert(QLatin1String(BOTTOM), bottom);
+
+ jsonVal.insert(QLatin1String(ARGUMENTS), args);
+ d->sendMessage(V8REQUEST, jsonVal);
+}
+
+void QV4DebugClient::frame(int number)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "frame",
+ // "arguments" : { "number" : <frame number>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.insert(QLatin1String(COMMAND), QLatin1String(FRAME));
+
+ if (number != -1) {
+ QJsonObject args;
+ args.insert(QLatin1String(NUMBER), number);
+ jsonVal.insert(QLatin1String(ARGUMENTS), args);
+ }
+
+ d->sendMessage(V8REQUEST, jsonVal);
+}
+
+void QV4DebugClient::scope(int number, int frameNumber)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "scope",
+ // "arguments" : { "number" : <scope number>
+ // "frameNumber" : <frame number, optional uses selected frame if missing>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.insert(QLatin1String(COMMAND), QLatin1String(SCOPE));
+
+ if (number != -1) {
+ QJsonObject args;
+ args.insert(QLatin1String(NUMBER), number);
+
+ if (frameNumber != -1)
+ args.insert(QLatin1String(FRAMENUMBER), frameNumber);
+
+ jsonVal.insert(QLatin1String(ARGUMENTS), args);
+ }
+
+ d->sendMessage(V8REQUEST, jsonVal);
+}
+
+void QV4DebugClient::scripts(int types, const QList<int> &ids, bool includeSource)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "scripts",
+ // "arguments" : { "types" : <types of scripts to retrieve
+ // set bit 0 for native scripts
+ // set bit 1 for extension scripts
+ // set bit 2 for normal scripts
+ // (default is 4 for normal scripts)>
+ // "ids" : <array of id's of scripts to return. If this is not specified all scripts are requrned>
+ // "includeSource" : <boolean indicating whether the source code should be included for the scripts returned>
+ // "filter" : <string or number: filter string or script id.
+ // If a number is specified, then only the script with the same number as its script id will be retrieved.
+ // If a string is specified, then only scripts whose names contain the filter string will be retrieved.>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.insert(QLatin1String(COMMAND), QLatin1String(SCRIPTS));
+
+ QJsonObject args;
+ args.insert(QLatin1String(TYPES), types);
+
+ if (ids.count()) {
+ QJsonArray array;
+ for (int id : ids)
+ array.append(id);
+
+ args.insert(QLatin1String(IDS), array);
+ }
+
+ if (includeSource)
+ args.insert(QLatin1String(INCLUDESOURCE), includeSource);
+
+ jsonVal.insert(QLatin1String(ARGUMENTS), args);
+ d->sendMessage(V8REQUEST, jsonVal);
+}
+
+void QV4DebugClient::setBreakpoint(const QString &target, int line, int column, bool enabled,
+ const QString &condition, int ignoreCount)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "setbreakpoint",
+ // "arguments" : { "type" : "scriptRegExp"
+ // "target" : <function expression or script identification>
+ // "line" : <line in script or function>
+ // "column" : <character position within the line>
+ // "enabled" : <initial enabled state. True or false, default is true>
+ // "condition" : <string with break point condition>
+ // "ignoreCount" : <number specifying the number of break point hits to ignore, default value is 0>
+ // }
+ // }
+
+ VARIANTMAPINIT;
+ jsonVal.insert(QLatin1String(COMMAND), QLatin1String(SETBREAKPOINT));
+
+ QJsonObject args;
+
+ args.insert(QLatin1String(TYPE), QLatin1String(SCRIPTREGEXP));
+ args.insert(QLatin1String(TARGET), target);
+
+ if (line != -1)
+ args.insert(QLatin1String(LINE), line);
+
+ if (column != -1)
+ args.insert(QLatin1String(COLUMN), column);
+
+ args.insert(QLatin1String(ENABLED), enabled);
+
+ if (!condition.isEmpty())
+ args.insert(QLatin1String(CONDITION), condition);
+
+ if (ignoreCount != -1)
+ args.insert(QLatin1String(IGNORECOUNT), ignoreCount);
+
+ jsonVal.insert(QLatin1String(ARGUMENTS),args);
+ d->sendMessage(V8REQUEST, jsonVal);
+}
+
+void QV4DebugClient::clearBreakpoint(int breakpoint)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "clearbreakpoint",
+ // "arguments" : { "breakpoint" : <number of the break point to clear>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.insert(QLatin1String(COMMAND), QLatin1String(CLEARBREAKPOINT));
+
+ QJsonObject args;
+ args.insert(QLatin1String(BREAKPOINT), breakpoint);
+ jsonVal.insert(QLatin1String(ARGUMENTS),args);
+
+ d->sendMessage(V8REQUEST, jsonVal);
+}
+
+void QV4DebugClient::changeBreakpoint(int breakpoint, bool enabled)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "changebreakpoint",
+ // "arguments" : { "breakpoint" : <number of the break point to change>
+ // "enabled" : <bool: enables the break type if true, disables if false>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.insert(QLatin1String(COMMAND), QLatin1String(CHANGEBREAKPOINT));
+
+ QJsonObject args;
+ args.insert(QLatin1String(BREAKPOINT), breakpoint);
+ args.insert(QLatin1String(ENABLED), enabled);
+
+ jsonVal.insert(QLatin1String(ARGUMENTS), args);
+ d->sendMessage(V8REQUEST, jsonVal);
+}
+
+void QV4DebugClient::setExceptionBreak(Exception type, bool enabled)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "setexceptionbreak",
+ // "arguments" : { "type" : <string: "all", or "uncaught">,
+ // "enabled" : <optional bool: enables the break type if true>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.insert(QLatin1String(COMMAND), QLatin1String(SETEXCEPTIONBREAK));
+
+ QJsonObject args;
+
+ if (type == All)
+ args.insert(QLatin1String(TYPE), QLatin1String(ALL));
+ else if (type == Uncaught)
+ args.insert(QLatin1String(TYPE), QLatin1String(UNCAUGHT));
+
+ if (enabled)
+ args.insert(QLatin1String(ENABLED), enabled);
+
+ jsonVal.insert(QLatin1String(ARGUMENTS), args);
+ d->sendMessage(V8REQUEST, jsonVal);
+}
+
+void QV4DebugClient::version()
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "version",
+ // }
+ VARIANTMAPINIT;
+ jsonVal.insert(QLatin1String(COMMAND), QLatin1String(VERSION));
+ d->sendMessage(V8REQUEST, jsonVal);
+}
+
+QV4DebugClient::Response QV4DebugClient::response() const
+{
+ Q_D(const QV4DebugClient);
+ const QJsonObject value = QJsonDocument::fromJson(d->response).object();
+ return {
+ value.value(QLatin1String(COMMAND)).toString(),
+ value.value(QLatin1String("body"))
+ };
+}
+
+void QV4DebugClient::disconnect()
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "disconnect",
+ // }
+ VARIANTMAPINIT;
+ jsonVal.insert(QLatin1String(COMMAND), QLatin1String(DISCONNECT));
+ d->sendMessage(DISCONNECT, jsonVal);
+}
+
+void QV4DebugClientPrivate::onStateChanged(QQmlDebugClient::State state)
+{
+ if (state == QQmlDebugClient::Enabled)
+ flushSendBuffer();
+}
+
+void QV4DebugClient::messageReceived(const QByteArray &data)
+{
+ Q_D(QV4DebugClient);
+ QPacket ds(connection()->currentDataStreamVersion(), data);
+ QByteArray command;
+ ds >> command;
+
+ if (command == "V8DEBUG") {
+ QByteArray type;
+ ds >> type >> d->response;
+
+ if (type == CONNECT) {
+ emit connected();
+
+ } else if (type == INTERRUPT) {
+ emit interrupted();
+
+ } else if (type == V8MESSAGE) {
+ const QJsonObject value = QJsonDocument::fromJson(d->response).object();
+ QString type = value.value(QLatin1String(TYPE)).toString();
+
+ if (type == QLatin1String("response")) {
+
+ if (!value.value(QLatin1String("success")).toBool()) {
+ emit failure();
+ qDebug() << "Received success == false response from application:"
+ << value.value(QLatin1String("message")).toString();
+ return;
+ }
+
+ QString debugCommand(value.value(QLatin1String(COMMAND)).toString());
+ if (debugCommand == QLatin1String(BACKTRACE) ||
+ debugCommand == QLatin1String(LOOKUP) ||
+ debugCommand == QLatin1String(SETBREAKPOINT) ||
+ debugCommand == QLatin1String(EVALUATE) ||
+ debugCommand == QLatin1String(VERSION) ||
+ debugCommand == QLatin1String(DISCONNECT) ||
+ debugCommand == QLatin1String(GARBAGECOLLECTOR) ||
+ debugCommand == QLatin1String(CHANGEBREAKPOINT) ||
+ debugCommand == QLatin1String(CLEARBREAKPOINT) ||
+ debugCommand == QLatin1String(FRAME) ||
+ debugCommand == QLatin1String(SCOPE) ||
+ debugCommand == QLatin1String(SCOPES) ||
+ debugCommand == QLatin1String(SCRIPTS) ||
+ debugCommand == QLatin1String(SOURCE) ||
+ debugCommand == QLatin1String(SETEXCEPTIONBREAK)) {
+ emit result();
+ } else {
+ // DO NOTHING
+ }
+
+ } else if (type == QLatin1String(EVENT)) {
+ QString event(value.value(QLatin1String(EVENT)).toString());
+
+ if (event == QLatin1String("break") || event == QLatin1String("exception"))
+ emit stopped();
+ }
+ }
+ }
+}
+
+void QV4DebugClientPrivate::sendMessage(const QByteArray &command, const QJsonObject &args)
+{
+ Q_Q(QV4DebugClient);
+ const QByteArray msg = packMessage(command, args);
+ if (q->state() == QQmlDebugClient::Enabled) {
+ q->sendMessage(msg);
+ } else {
+ sendBuffer.append(msg);
+ }
+}
+
+void QV4DebugClientPrivate::flushSendBuffer()
+{
+ foreach (const QByteArray &msg, sendBuffer)
+ sendMessage(msg);
+ sendBuffer.clear();
+}
+
+QByteArray QV4DebugClientPrivate::packMessage(const QByteArray &type, const QJsonObject &object)
+{
+ QPacket rs(connection->currentDataStreamVersion());
+ QByteArray cmd = "V8DEBUG";
+ rs << cmd << type << QJsonDocument(object).toJson(QJsonDocument::Compact);
+ return rs.data();
+}
+
+QT_END_NAMESPACE
diff --git a/src/qmldebug/qv4debugclient_p.h b/src/qmldebug/qv4debugclient_p.h
new file mode 100644
index 0000000000..fdcf4284c5
--- /dev/null
+++ b/src/qmldebug/qv4debugclient_p.h
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 QV4DEBUGCLIENT_P_H
+#define QV4DEBUGCLIENT_P_H
+
+#include <QtQmlDebug/private/qqmldebugclient_p.h>
+#include <QtCore/qjsonvalue.h>
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QV4DebugClientPrivate;
+class QV4DebugClient : public QQmlDebugClient
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QV4DebugClient)
+
+public:
+ enum StepAction
+ {
+ Continue,
+ In,
+ Out,
+ Next
+ };
+
+ enum Exception
+ {
+ All,
+ Uncaught
+ };
+
+ struct Response
+ {
+ QString command;
+ QJsonValue body;
+ };
+
+ QV4DebugClient(QQmlDebugConnection *connection);
+
+ void connect();
+ void disconnect();
+
+ void interrupt();
+ void continueDebugging(StepAction stepAction);
+ void evaluate(const QString &expr, int frame = -1, int context = -1);
+ void lookup(const QList<int> &handles, bool includeSource = false);
+ void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false);
+ void frame(int number = -1);
+ void scope(int number = -1, int frameNumber = -1);
+ void scripts(int types = 4, const QList<int> &ids = QList<int>(), bool includeSource = false);
+ void setBreakpoint(const QString &target, int line = -1, int column = -1, bool enabled = true,
+ const QString &condition = QString(), int ignoreCount = -1);
+ void clearBreakpoint(int breakpoint);
+ void changeBreakpoint(int breakpoint, bool enabled);
+ void setExceptionBreak(Exception type, bool enabled = false);
+ void version();
+
+ Response response() const;
+
+protected:
+ void messageReceived(const QByteArray &data) override;
+
+signals:
+ void connected();
+ void interrupted();
+ void result();
+ void failure();
+ void stopped();
+};
+
+QT_END_NAMESPACE
+
+#endif // QV4DEBUGCLIENT_P_H
diff --git a/src/qmldebug/qv4debugclient_p_p.h b/src/qmldebug/qv4debugclient_p_p.h
new file mode 100644
index 0000000000..993c281632
--- /dev/null
+++ b/src/qmldebug/qv4debugclient_p_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 QV4DEBUGCLIENT_P_P_H
+#define QV4DEBUGCLIENT_P_P_H
+
+#include "qv4debugclient_p.h"
+#include "qqmldebugclient_p_p.h"
+
+#include <QtCore/qjsonobject.h>
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QV4DebugClientPrivate : public QQmlDebugClientPrivate
+{
+ Q_DECLARE_PUBLIC(QV4DebugClient)
+
+public:
+ QV4DebugClientPrivate(QQmlDebugConnection *connection);
+
+ void sendMessage(const QByteArray &command, const QJsonObject &args = QJsonObject());
+ void flushSendBuffer();
+ QByteArray packMessage(const QByteArray &type, const QJsonObject &object);
+ void onStateChanged(QQmlDebugClient::State state);
+
+ int seq = 0;
+ QList<QByteArray> sendBuffer;
+ QByteArray response;
+};
+
+QT_END_NAMESPACE
+
+#endif // QV4DEBUGCLIENT_P_P_H
diff --git a/src/qmldevtools/qmldevtools.pro b/src/qmldevtools/qmldevtools.pro
index 05aa6f66f5..45029400b9 100644
--- a/src/qmldevtools/qmldevtools.pro
+++ b/src/qmldevtools/qmldevtools.pro
@@ -17,5 +17,6 @@ include(../qml/parser/parser.pri)
include(../qml/jsruntime/jsruntime.pri)
include(../qml/compiler/compiler.pri)
include(../qml/memory/memory.pri)
+include(../qml/qmldirparser/qmldirparser.pri)
load(qt_module)
diff --git a/src/qmltest/doc/qtqmltest.qdocconf b/src/qmltest/doc/qtqmltest.qdocconf
index a819546fba..9a3e16b64d 100644
--- a/src/qmltest/doc/qtqmltest.qdocconf
+++ b/src/qmltest/doc/qtqmltest.qdocconf
@@ -15,28 +15,28 @@ qhp.QtQmlTest.indexRoot =
qhp.QtQmlTest.filterAttributes = qtqmltest $QT_VERSION qtrefdoc
qhp.QtQmlTest.customFilters.Qt.name = QtQmlTest $QT_VERSION
qhp.QtQmlTest.customFilters.Qt.filterAttributes = qtqmltest $QT_VERSION
-qhp.QtQmlTest.subprojects = qmltypes classes examples
-qhp.QtQmlTest.subprojects.classes.title = C++ Classes
-qhp.QtQmlTest.subprojects.classes.indexTitle = Qt Quick Test C++ Classes
-qhp.QtQmlTest.subprojects.classes.selectors = class doc:headerfile
+
+qhp.QtQmlTest.subprojects = qmltypes classes
+qhp.QtQmlTest.subprojects.classes.title = C++ API
+qhp.QtQmlTest.subprojects.classes.indexTitle = Qt Quick Test C++ API
+qhp.QtQmlTest.subprojects.classes.selectors = class namespace doc:headerfile
qhp.QtQmlTest.subprojects.classes.sortPages = true
-qhp.QtQmlTest.subprojects.examples.title = Examples
-qhp.QtQmlTest.subprojects.examples.indexTitle = Qt Quick Test Examples
-qhp.QtQmlTest.subprojects.examples.selectors = doc:example
qhp.QtQmlTest.subprojects.qmltypes.title = QML Types
qhp.QtQmlTest.subprojects.qmltypes.indexTitle = Qt Quick Test QML Types
qhp.QtQmlTest.subprojects.qmltypes.selectors = qmlclass
qhp.QtQmlTest.subprojects.qmltypes.sortPages = true
-
-tagfile = ../../../doc/qtqmltest/qtqmltest.tags
+tagfile = qtqmltest.tags
depends += qtcore qtgui qttestlib qtqml qtquick qtdoc
headerdirs += ..
-sourcedirs += ..
+sourcedirs += .. \
+ ../../imports/testlib
+
+exampledirs += snippets
navigation.landingpage = "Qt Quick Test"
-navigation.cppclassespage = "Qt Quick Test C++ Classes"
+navigation.cppclassespage = "Qt Quick Test C++ API"
navigation.qmltypespage = "Qt Quick Test QML Types"
diff --git a/src/qmltest/doc/snippets/src_qmltest_qquicktest.cpp b/src/qmltest/doc/snippets/src_qmltest_qquicktest.cpp
new file mode 100644
index 0000000000..191f693a9a
--- /dev/null
+++ b/src/qmltest/doc/snippets/src_qmltest_qquicktest.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [1]
+//! [0]
+#include <QtQuickTest>
+//! [0]
+QUICK_TEST_MAIN(example)
+//! [1]
+
+//! [2]
+// tst_mytest.cpp
+#include <QtQuickTest>
+#include <QQmlEngine>
+#include <QQmlContext>
+
+class Setup : public QObject
+{
+ Q_OBJECT
+
+public:
+ Setup() {}
+
+public slots:
+ void qmlEngineAvailable(QQmlEngine *engine)
+ {
+ engine->rootContext()->setContextProperty("myContextProperty", QVariant(true));
+ }
+};
+
+QUICK_TEST_MAIN_WITH_SETUP(mytest, Setup)
+
+#include "tst_mytest.moc"
+//! [2]
diff --git a/src/qmltest/doc/src/qtquicktest-cppapi.qdoc b/src/qmltest/doc/src/qtquicktest-cppapi.qdoc
new file mode 100644
index 0000000000..0e5dab8887
--- /dev/null
+++ b/src/qmltest/doc/src/qtquicktest-cppapi.qdoc
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \module QtQuickTest
+ \keyword Qt Quick Test C++ API
+ \title Qt Quick Test C++ API
+ \ingroup modules
+
+ \brief Provides macros and functions for tests.
+
+ The C++ macros and functions can be included into your application using
+ the following include statement:
+
+ \snippet src_qmltest_qquicktest.cpp 0
+
+ There are two ways to link against the corresponding C++ library. If your
+ test project uses a QML \l TestCase, you should already have the following
+ line in your project file:
+
+ \badcode
+ CONFIG += qmltestcase
+ \endcode
+
+ This will cause the test to link to the C++ \QtQuickTest library.
+
+ If you have a C++-only test project, you can add the following line
+ to your project file:
+
+ \badcode
+ QT += qmltest
+ \endcode
+
+ \sa {Executing C++ Before QML Tests}
+*/
diff --git a/src/qmltest/doc/src/qtquicktest-index.qdoc b/src/qmltest/doc/src/qtquicktest-index.qdoc
index bee160f6e8..668d6c1417 100644
--- a/src/qmltest/doc/src/qtquicktest-index.qdoc
+++ b/src/qmltest/doc/src/qtquicktest-index.qdoc
@@ -30,6 +30,7 @@
\title Qt Quick Test
\brief Unit testing framework for QML.
+ \target Introduction to Qt Quick Test
\section1 Introduction
\l {Qt Quick Test QML Types}{Qt Quick Test} is a unit test framework for QML applications.
@@ -62,15 +63,13 @@
only guaranteed to work with the Qt version it was developed against.
However, source compatibility is guaranteed.
+ \target Running Qt Quick Tests
\section1 Running Tests
Test cases are launched by a C++ harness that consists of
the following code:
- \code
- #include <QtQuickTest/quicktest.h>
- QUICK_TEST_MAIN(example)
- \endcode
+ \snippet src_qmltest_qquicktest.cpp 1
Where "example" is the identifier to use to uniquely identify
this set of tests. Finally, add \c{CONFIG += qmltestcase} to the project
@@ -139,7 +138,7 @@
\section1 Executing C++ Before QML Tests
To execute C++ code before any of the QML tests are run, the
- \c QUICK_TEST_MAIN_WITH_SETUP macro can be used. This can be useful for
+ \l QUICK_TEST_MAIN_WITH_SETUP macro can be used. This can be useful for
setting context properties on the QML engine, amongst other things.
The macro is identical to \c QUICK_TEST_MAIN, except that it takes an
@@ -152,13 +151,13 @@
\li Purpose
\li Since
\row
- \li void applicationAvailable()
+ \li \c {void applicationAvailable()}
\li Called right after the QApplication object was instantiated.
Use this function to perform setup that does not require a
\l QQmlEngine instance.
\li Qt 5.12
\row
- \li void qmlEngineAvailable(QQmlEngine*)
+ \li \c {void qmlEngineAvailable(QQmlEngine *)}
\li Called when the QML engine is available.
Any \l {QQmlEngine::addImportPath}{import paths},
\l {QQmlEngine::addPluginPath}{plugin paths},
@@ -171,42 +170,20 @@
amongst other things.
\li Qt 5.11
\row
- \li void cleanupTestCase()
+ \li \c {void cleanupTestCase()}
\li Called right after the test execution has finished.
Use this function to clean up before everything will start to be destructed.
\li Qt 5.12
\endtable
- Each function will be called once for each \c tst_*.qml file, so any
+ Each function will be called once for each \c {tst_*.qml} file, so any
arguments are unique to that test. For example, this means that each QML
test file will have its own QML engine.
The following example demonstrates how the macro can be used to set context
properties on the QML engine:
- \code
- #include <QtQuickTest>
- #include <QQmlEngine>
- #include <QQmlContext>
-
- class Setup : public QObject
- {
- Q_OBJECT
-
- public:
- Setup() {}
-
- public slots:
- void qmlEngineAvailable(QQmlEngine *engine)
- {
- engine->rootContext()->setContextProperty("myContextProperty", QVariant(true));
- }
- };
-
- QUICK_TEST_MAIN_WITH_SETUP(mytest, Setup)
-
- #include "tst_mytest.moc"
- \endcode
+ \snippet src_qmltest_qquicktest.cpp 2
The \c .moc include is based on the file name of the \c .cpp file.
For example, in the example above, the \c .cpp file is named
@@ -217,6 +194,13 @@
#include "MyTest.moc"
\endcode
+ \section1 Reference
+
+ \list
+ \li \l{Qt Quick Test QML Types}{QML Types}
+ \li \l{Qt Quick Test C++ API}{C++ API}
+ \endlist
+
\section1 Licenses
Qt Quick Tests is available under commercial licenses from \l{The Qt Company}.
diff --git a/src/qmltest/doc/src/qtquicktest-qmltypes.qdoc b/src/qmltest/doc/src/qtquicktest-qmltypes.qdoc
new file mode 100644
index 0000000000..0ed8c6faa0
--- /dev/null
+++ b/src/qmltest/doc/src/qtquicktest-qmltypes.qdoc
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \qmlmodule QtTest 1.\QtMinorVersion
+ \title Qt Quick Test QML Types
+ \brief Provides QML types to unit test your QML application.
+ \ingroup qmlmodules
+
+ You can import this module using the following statement:
+
+ \qml \QtMinorVersion
+ import QtTest 1.\1
+ \endqml
+
+ \section1 QML Types
+ \generatelist {qmltypesbymodule QtTest}
+ \noautolist
+
+ For more information about how to use these types, see
+ \l{Qt Quick Test}.
+*/
diff --git a/src/qmltest/doc/src/qtquicktest.qdoc b/src/qmltest/doc/src/qtquicktest.qdoc
new file mode 100644
index 0000000000..31c097ed76
--- /dev/null
+++ b/src/qmltest/doc/src/qtquicktest.qdoc
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \namespace QQuickTest
+ \inmodule QtQuickTest
+
+ \brief The QQuickTest namespace contains all the functions and
+ macros related to Qt Quick Test.
+
+ See the \l{Introduction to Qt Quick Test} for information about how to write
+ Qt Quick unit tests.
+
+ To link to the Qt Quick Test C++ library, see \l {Qt Quick Test C++ API}.
+
+ \sa {Executing C++ Before QML Tests}
+*/
+
+/*!
+ \macro QUICK_TEST_MAIN(name)
+ \relates QQuickTest
+
+ \brief Sets up the entry point for a Qt Quick Test application.
+ The \a name argument uniquely identifies this set of tests.
+
+ \snippet src_qmltest_qquicktest.cpp 1
+
+ \note The macro assumes that your test sources are in the current
+ directory, unless the \c QUICK_TEST_SOURCE_DIR environment variable is set.
+
+ \sa QUICK_TEST_MAIN_WITH_SETUP(), {Running Qt Quick Tests}
+
+*/
+
+/*!
+ \macro QUICK_TEST_MAIN_WITH_SETUP(name, QuickTestSetupClass)
+ \relates QQuickTest
+
+ \brief Sets up the entry point for a Qt Quick Test application.
+ The \a name argument uniquely identifies this set of tests.
+
+ This macro is identical to QUICK_TEST_MAIN(), except that it takes an
+ additional argument \a QuickTestSetupClass, a pointer to a QObject-derived
+ class. With this class it is possible to define additional setup code to
+ execute before running the QML test.
+
+ \note The macro assumes that your test sources are in the current
+ directory, unless the \c QUICK_TEST_SOURCE_DIR environment variable is set.
+
+ The following snippet demonstrates the use of this macro:
+
+ \snippet src_qmltest_qquicktest.cpp 2
+
+ \sa QUICK_TEST_MAIN(), {Running Qt Quick Tests}
+*/
diff --git a/src/qmltest/qmltest.pro b/src/qmltest/qmltest.pro
index e2200e5abb..0bf05093be 100644
--- a/src/qmltest/qmltest.pro
+++ b/src/qmltest/qmltest.pro
@@ -4,7 +4,7 @@ QMAKE_DOCS = $$PWD/doc/qtqmltest.qdocconf
DEFINES += QT_NO_URL_CAST_FROM_STRING QT_NO_FOREACH
QT = core testlib-private
-QT_PRIVATE = quick qml-private gui core-private gui-private
+QT_PRIVATE = quick quick-private 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 22d329bb80..9cddf61543 100644
--- a/src/qmltest/quicktest.cpp
+++ b/src/qmltest/quicktest.cpp
@@ -44,10 +44,14 @@
#include <QtQml/qqml.h>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcontext.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickview.h>
#include <QtQml/qjsvalue.h>
#include <QtQml/qjsengine.h>
#include <QtQml/qqmlpropertymap.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuick/qquickitem.h>
#include <QtGui/qopengl.h>
#include <QtCore/qurl.h>
#include <QtCore/qfileinfo.h>
@@ -73,6 +77,61 @@
QT_BEGIN_NAMESPACE
+/*!
+ \since 5.13
+
+ Returns \c true if \l {QQuickItem::}{updatePolish()} has not been called
+ on \a item since the last call to \l {QQuickItem::}{polish()},
+ otherwise returns \c false.
+
+ When assigning values to properties in QML, any layouting the item
+ must do as a result of the assignment might not take effect immediately,
+ but can instead be postponed until the item is polished. For these cases,
+ you can use this function to ensure that the item has been polished
+ before the execution of the test continues. For example:
+
+ \code
+ QVERIFY(QQuickTest::qIsPolishScheduled(item));
+ QVERIFY(QQuickTest::qWaitForItemPolished(item));
+ \endcode
+
+ Without the call to \c qIsPolishScheduled() above, the
+ call to \c qWaitForItemPolished() might see that no polish
+ was scheduled and therefore pass instantly, assuming that
+ the item had already been polished. This function
+ makes it obvious why an item wasn't polished and allows tests to
+ fail early under such circumstances.
+
+ The QML equivalent of this function is
+ \l {TestCase::}{isPolishScheduled()}.
+
+ \sa QQuickItem::polish(), QQuickItem::updatePolish()
+*/
+bool QQuickTest::qIsPolishScheduled(const QQuickItem *item)
+{
+ return QQuickItemPrivate::get(item)->polishScheduled;
+}
+
+/*!
+ \since 5.13
+
+ Waits for \a timeout milliseconds or until
+ \l {QQuickItem::}{updatePolish()} has been called on \a item.
+
+ Returns \c true if \c updatePolish() was called on \a item within
+ \a timeout milliseconds, otherwise returns \c false.
+
+ The QML equivalent of this function is
+ \l {TestCase::}{waitForItemPolished()}.
+
+ \sa QQuickItem::polish(), QQuickItem::updatePolish(),
+ QQuickTest::qIsPolishScheduled()
+*/
+bool QQuickTest::qWaitForItemPolished(const QQuickItem *item, int timeout)
+{
+ return QTest::qWaitFor([&]() { return !QQuickItemPrivate::get(item)->polishScheduled; }, timeout);
+}
+
class QTestRootObject : public QObject
{
Q_OBJECT
diff --git a/src/qmltest/quicktest.h b/src/qmltest/quicktest.h
index 62ed749722..8e3510c9a5 100644
--- a/src/qmltest/quicktest.h
+++ b/src/qmltest/quicktest.h
@@ -45,7 +45,7 @@
QT_BEGIN_NAMESPACE
-QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS
+class QQuickItem;
Q_QUICK_TEST_EXPORT int quick_test_main(int argc, char **argv, const char *name, const char *sourceDir);
Q_QUICK_TEST_EXPORT int quick_test_main_with_setup(int argc, char **argv, const char *name, const char *sourceDir, QObject *setup);
@@ -55,7 +55,6 @@ Q_QUICK_TEST_EXPORT int quick_test_main_with_setup(int argc, char **argv, const
#define QUICK_TEST_MAIN(name) \
int main(int argc, char **argv) \
{ \
- QTEST_ADD_GPU_BLACKLIST_SUPPORT \
QTEST_SET_MAIN_SOURCE_PATH \
return quick_test_main(argc, argv, #name, QUICK_TEST_SOURCE_DIR); \
}
@@ -63,7 +62,6 @@ Q_QUICK_TEST_EXPORT int quick_test_main_with_setup(int argc, char **argv, const
#define QUICK_TEST_OPENGL_MAIN(name) \
int main(int argc, char **argv) \
{ \
- QTEST_ADD_GPU_BLACKLIST_SUPPORT \
QTEST_SET_MAIN_SOURCE_PATH \
return quick_test_main(argc, argv, #name, QUICK_TEST_SOURCE_DIR); \
}
@@ -71,7 +69,6 @@ Q_QUICK_TEST_EXPORT int quick_test_main_with_setup(int argc, char **argv, const
#define QUICK_TEST_MAIN_WITH_SETUP(name, QuickTestSetupClass) \
int main(int argc, char **argv) \
{ \
- QTEST_ADD_GPU_BLACKLIST_SUPPORT \
QTEST_SET_MAIN_SOURCE_PATH \
QuickTestSetupClass setup; \
return quick_test_main_with_setup(argc, argv, #name, QUICK_TEST_SOURCE_DIR, &setup); \
@@ -82,7 +79,6 @@ Q_QUICK_TEST_EXPORT int quick_test_main_with_setup(int argc, char **argv, const
#define QUICK_TEST_MAIN(name) \
int main(int argc, char **argv) \
{ \
- QTEST_ADD_GPU_BLACKLIST_SUPPORT \
QTEST_SET_MAIN_SOURCE_PATH \
return quick_test_main(argc, argv, #name, nullptr); \
}
@@ -90,7 +86,6 @@ Q_QUICK_TEST_EXPORT int quick_test_main_with_setup(int argc, char **argv, const
#define QUICK_TEST_OPENGL_MAIN(name) \
int main(int argc, char **argv) \
{ \
- QTEST_ADD_GPU_BLACKLIST_SUPPORT \
QTEST_SET_MAIN_SOURCE_PATH \
return quick_test_main(argc, argv, #name, nullptr); \
}
@@ -98,7 +93,6 @@ Q_QUICK_TEST_EXPORT int quick_test_main_with_setup(int argc, char **argv, const
#define QUICK_TEST_MAIN_WITH_SETUP(name, QuickTestSetupClass) \
int main(int argc, char **argv) \
{ \
- QTEST_ADD_GPU_BLACKLIST_SUPPORT \
QTEST_SET_MAIN_SOURCE_PATH \
QuickTestSetupClass setup; \
return quick_test_main_with_setup(argc, argv, #name, nullptr, &setup); \
@@ -106,6 +100,11 @@ Q_QUICK_TEST_EXPORT int quick_test_main_with_setup(int argc, char **argv, const
#endif
+namespace QQuickTest {
+Q_QUICK_TEST_EXPORT bool qIsPolishScheduled(const QQuickItem *item);
+Q_QUICK_TEST_EXPORT bool qWaitForItemPolished(const QQuickItem *item, int timeout = 5000);
+}
+
QT_END_NAMESPACE
#endif
diff --git a/src/qmltest/quicktestresult.cpp b/src/qmltest/quicktestresult.cpp
index 3225dc95cd..4dbec585c4 100644
--- a/src/qmltest/quicktestresult.cpp
+++ b/src/qmltest/quicktestresult.cpp
@@ -39,6 +39,7 @@
****************************************************************************/
#include "quicktestresult_p.h"
+#include "quicktest.h"
#include <QtTest/qtestcase.h>
#include <QtTest/qtestsystem.h>
#include <QtTest/private/qtestblacklist_p.h>
@@ -787,6 +788,16 @@ QObject *QuickTestResult::findChild(QObject *parent, const QString &objectName)
return parent ? parent->findChild<QObject*>(objectName) : 0;
}
+bool QuickTestResult::isPolishScheduled(QQuickItem *item) const
+{
+ return QQuickTest::qIsPolishScheduled(item);
+}
+
+bool QuickTestResult::waitForItemPolished(QQuickItem *item, int timeout)
+{
+ return QQuickTest::qWaitForItemPolished(item, timeout);
+}
+
namespace QTest {
void qtest_qParseArgs(int argc, char *argv[], bool qml);
};
@@ -802,7 +813,6 @@ void QuickTestResult::setProgramName(const char *name)
{
if (name) {
QTestPrivate::parseBlackList();
- QTestPrivate::parseGpuBlackList();
QTestResult::reset();
} else if (!name && loggingStarted) {
QTestResult::setCurrentTestObject(globalProgramName);
@@ -829,7 +839,7 @@ int QuickTestResult::exitCode()
#endif
}
+QT_END_NAMESPACE
+
#include "quicktestresult.moc"
#include "moc_quicktestresult_p.cpp"
-
-QT_END_NAMESPACE
diff --git a/src/qmltest/quicktestresult_p.h b/src/qmltest/quicktestresult_p.h
index b2eeefdfff..3643826e5d 100644
--- a/src/qmltest/quicktestresult_p.h
+++ b/src/qmltest/quicktestresult_p.h
@@ -160,6 +160,9 @@ public Q_SLOTS:
Q_REVISION(1) QObject *findChild(QObject *parent, const QString &objectName);
+ Q_REVISION(13) bool isPolishScheduled(QQuickItem *item) const;
+ Q_REVISION(13) bool waitForItemPolished(QQuickItem *item, int timeout);
+
public:
// Helper functions for the C++ main() shell.
static void parseArgs(int argc, char *argv[]);
diff --git a/src/quick/accessible/qaccessiblequickview.cpp b/src/quick/accessible/qaccessiblequickview.cpp
index 3bb40546be..41a02fc09c 100644
--- a/src/quick/accessible/qaccessiblequickview.cpp
+++ b/src/quick/accessible/qaccessiblequickview.cpp
@@ -91,7 +91,7 @@ QAccessibleInterface *QAccessibleQuickWindow::focusChild() const
QAccessible::Role QAccessibleQuickWindow::role() const
{
- return QAccessible::Window; // FIXME
+ return QAccessible::Window;
}
QAccessible::State QAccessibleQuickWindow::state() const
diff --git a/src/quick/designer/qquickdesignersupportitems.cpp b/src/quick/designer/qquickdesignersupportitems.cpp
index 1c338fa79d..ed5fdf3a4a 100644
--- a/src/quick/designer/qquickdesignersupportitems.cpp
+++ b/src/quick/designer/qquickdesignersupportitems.cpp
@@ -192,19 +192,19 @@ static bool isCrashingType(const QQmlType &type)
{
QString name = type.qmlTypeName();
- if (type.qmlTypeName() == QLatin1String("QtMultimedia/MediaPlayer"))
+ if (name == QLatin1String("QtMultimedia/MediaPlayer"))
return true;
- if (type.qmlTypeName() == QLatin1String("QtMultimedia/Audio"))
+ if (name == QLatin1String("QtMultimedia/Audio"))
return true;
- if (type.qmlTypeName() == QLatin1String("QtQuick.Controls/MenuItem"))
+ if (name == QLatin1String("QtQuick.Controls/MenuItem"))
return true;
- if (type.qmlTypeName() == QLatin1String("QtQuick.Controls/Menu"))
+ if (name == QLatin1String("QtQuick.Controls/Menu"))
return true;
- if (type.qmlTypeName() == QLatin1String("QtQuick/Timer"))
+ if (name == QLatin1String("QtQuick/Timer"))
return true;
return false;
diff --git a/src/quick/doc/snippets/pointerHandlers/dragHandlerNullTarget.qml b/src/quick/doc/snippets/pointerHandlers/dragHandlerNullTarget.qml
index c33f2b2782..dcdd28da80 100644
--- a/src/quick/doc/snippets/pointerHandlers/dragHandlerNullTarget.qml
+++ b/src/quick/doc/snippets/pointerHandlers/dragHandlerNullTarget.qml
@@ -61,7 +61,7 @@ Item {
Text {
color: handler.active ? "darkgreen" : "black"
- text: handler.centroid.centroid.x.toFixed(1) + "," + handler.centroid.position.y.toFixed(1)
+ text: handler.centroid.position.x.toFixed(1) + "," + handler.centroid.position.y.toFixed(1)
x: handler.centroid.position.x - width / 2
y: handler.centroid.position.y - height
}
diff --git a/src/quick/doc/src/qmltypereference.qdoc b/src/quick/doc/src/qmltypereference.qdoc
index 04682c9f33..418475f100 100644
--- a/src/quick/doc/src/qmltypereference.qdoc
+++ b/src/quick/doc/src/qmltypereference.qdoc
@@ -887,19 +887,3 @@ console.log(c + " " + d); // false true
\sa {QML Basic Types}
*/
-
-/*!
-\qmlmodule QtTest 1.\QtMinorVersion
-\title Qt Quick Test QML Types
-\brief This module provides QML types to unit test your QML application
-\ingroup qmlmodules
-
-You can import this module using the following statement:
-
-\qml \QtMinorVersion
-import QtTest 1.\1
-\endqml
-
-For more information about how to use these types, see
-\l{Qt Quick Test}.
-*/
diff --git a/src/quick/handlers/handlers.pri b/src/quick/handlers/handlers.pri
index 1258822f40..226cca22cb 100644
--- a/src/quick/handlers/handlers.pri
+++ b/src/quick/handlers/handlers.pri
@@ -10,6 +10,7 @@ HEADERS += \
$$PWD/qquickpointerhandler_p_p.h \
$$PWD/qquickpointhandler_p.h \
$$PWD/qquicksinglepointhandler_p.h \
+ $$PWD/qquicksinglepointhandler_p_p.h \
$$PWD/qquicktaphandler_p.h \
$$PWD/qquickdragaxis_p.h
diff --git a/src/quick/handlers/qquickdragaxis.cpp b/src/quick/handlers/qquickdragaxis.cpp
index 5efe19b2fe..88470c8a7d 100644
--- a/src/quick/handlers/qquickdragaxis.cpp
+++ b/src/quick/handlers/qquickdragaxis.cpp
@@ -39,6 +39,8 @@
#include "qquickdragaxis_p.h"
#include <limits>
+QT_BEGIN_NAMESPACE
+
QQuickDragAxis::QQuickDragAxis()
: m_minimum(-std::numeric_limits<qreal>::max())
, m_maximum(std::numeric_limits<qreal>::max())
@@ -73,3 +75,4 @@ void QQuickDragAxis::setEnabled(bool enabled)
emit enabledChanged();
}
+QT_END_NAMESPACE
diff --git a/src/quick/handlers/qquickdragaxis_p.h b/src/quick/handlers/qquickdragaxis_p.h
index 2c2e0a426d..a4649d5eb9 100644
--- a/src/quick/handlers/qquickdragaxis_p.h
+++ b/src/quick/handlers/qquickdragaxis_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQuick module of the Qt Toolkit.
@@ -51,10 +51,11 @@
// We mean it.
//
-#include <QtCore/qobject.h>
-#include <QtCore/qglobal.h>
+#include <private/qtquickglobal_p.h>
-class Q_AUTOTEST_EXPORT QQuickDragAxis : public QObject
+QT_BEGIN_NAMESPACE
+
+class Q_QUICK_PRIVATE_EXPORT QQuickDragAxis : public QObject
{
Q_OBJECT
Q_PROPERTY(qreal minimum READ minimum WRITE setMinimum NOTIFY minimumChanged)
@@ -84,4 +85,6 @@ private:
bool m_enabled;
};
+QT_END_NAMESPACE
+
#endif // QQUICKDRAGAXIS_P_H
diff --git a/src/quick/handlers/qquickdraghandler_p.h b/src/quick/handlers/qquickdraghandler_p.h
index 387a81eb43..748026488a 100644
--- a/src/quick/handlers/qquickdraghandler_p.h
+++ b/src/quick/handlers/qquickdraghandler_p.h
@@ -56,7 +56,7 @@
QT_BEGIN_NAMESPACE
-class Q_AUTOTEST_EXPORT QQuickDragHandler : public QQuickMultiPointHandler
+class Q_QUICK_PRIVATE_EXPORT QQuickDragHandler : public QQuickMultiPointHandler
{
Q_OBJECT
Q_PROPERTY(QQuickDragAxis * xAxis READ xAxis CONSTANT)
diff --git a/src/quick/handlers/qquickhoverhandler_p.h b/src/quick/handlers/qquickhoverhandler_p.h
index 1ee2aeb7e6..d8e5fc00a1 100644
--- a/src/quick/handlers/qquickhoverhandler_p.h
+++ b/src/quick/handlers/qquickhoverhandler_p.h
@@ -58,7 +58,7 @@
QT_BEGIN_NAMESPACE
-class Q_AUTOTEST_EXPORT QQuickHoverHandler : public QQuickSinglePointHandler
+class Q_QUICK_PRIVATE_EXPORT QQuickHoverHandler : public QQuickSinglePointHandler
{
Q_OBJECT
Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged)
diff --git a/src/quick/handlers/qquickmultipointhandler_p.h b/src/quick/handlers/qquickmultipointhandler_p.h
index 94142013cc..06f170154b 100644
--- a/src/quick/handlers/qquickmultipointhandler_p.h
+++ b/src/quick/handlers/qquickmultipointhandler_p.h
@@ -58,7 +58,7 @@
QT_BEGIN_NAMESPACE
-class Q_AUTOTEST_EXPORT QQuickMultiPointHandler : public QQuickPointerDeviceHandler
+class Q_QUICK_PRIVATE_EXPORT QQuickMultiPointHandler : public QQuickPointerDeviceHandler
{
Q_OBJECT
Q_PROPERTY(int minimumPointCount READ minimumPointCount WRITE setMinimumPointCount NOTIFY minimumPointCountChanged)
diff --git a/src/quick/handlers/qquickpinchhandler_p.h b/src/quick/handlers/qquickpinchhandler_p.h
index 1afc028758..766d57f892 100644
--- a/src/quick/handlers/qquickpinchhandler_p.h
+++ b/src/quick/handlers/qquickpinchhandler_p.h
@@ -59,7 +59,7 @@
QT_BEGIN_NAMESPACE
-class Q_AUTOTEST_EXPORT QQuickPinchHandler : public QQuickMultiPointHandler
+class Q_QUICK_PRIVATE_EXPORT QQuickPinchHandler : public QQuickMultiPointHandler
{
Q_OBJECT
Q_PROPERTY(qreal minimumScale READ minimumScale WRITE setMinimumScale NOTIFY minimumScaleChanged)
diff --git a/src/quick/handlers/qquickpointerdevicehandler_p.h b/src/quick/handlers/qquickpointerdevicehandler_p.h
index 82b24369d3..bb15142824 100644
--- a/src/quick/handlers/qquickpointerdevicehandler_p.h
+++ b/src/quick/handlers/qquickpointerdevicehandler_p.h
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
class QQuickPointerDeviceHandlerPrivate;
-class Q_AUTOTEST_EXPORT QQuickPointerDeviceHandler : public QQuickPointerHandler
+class Q_QUICK_PRIVATE_EXPORT QQuickPointerDeviceHandler : public QQuickPointerHandler
{
Q_OBJECT
Q_PROPERTY(QQuickPointerDevice::DeviceTypes acceptedDevices READ acceptedDevices WRITE setAcceptedDevices NOTIFY acceptedDevicesChanged)
diff --git a/src/quick/handlers/qquickpointerdevicehandler_p_p.h b/src/quick/handlers/qquickpointerdevicehandler_p_p.h
index 6a950590f3..03272d9f69 100644
--- a/src/quick/handlers/qquickpointerdevicehandler_p_p.h
+++ b/src/quick/handlers/qquickpointerdevicehandler_p_p.h
@@ -56,7 +56,7 @@
QT_BEGIN_NAMESPACE
-class Q_AUTOTEST_EXPORT QQuickPointerDeviceHandlerPrivate : public QQuickPointerHandlerPrivate
+class Q_QUICK_PRIVATE_EXPORT QQuickPointerDeviceHandlerPrivate : public QQuickPointerHandlerPrivate
{
Q_DECLARE_PUBLIC(QQuickPointerDeviceHandler)
diff --git a/src/quick/handlers/qquickpointhandler_p.h b/src/quick/handlers/qquickpointhandler_p.h
index 380ce1f90f..c197cb4f20 100644
--- a/src/quick/handlers/qquickpointhandler_p.h
+++ b/src/quick/handlers/qquickpointhandler_p.h
@@ -55,7 +55,7 @@
QT_BEGIN_NAMESPACE
-class Q_AUTOTEST_EXPORT QQuickPointHandler : public QQuickSinglePointHandler
+class Q_QUICK_PRIVATE_EXPORT QQuickPointHandler : public QQuickSinglePointHandler
{
Q_OBJECT
Q_PROPERTY(QVector2D translation READ translation NOTIFY translationChanged)
diff --git a/src/quick/handlers/qquicksinglepointhandler.cpp b/src/quick/handlers/qquicksinglepointhandler.cpp
index ae162bed87..c0fa39fad3 100644
--- a/src/quick/handlers/qquicksinglepointhandler.cpp
+++ b/src/quick/handlers/qquicksinglepointhandler.cpp
@@ -38,6 +38,7 @@
****************************************************************************/
#include "qquicksinglepointhandler_p.h"
+#include "qquicksinglepointhandler_p_p.h"
QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(DBG_TOUCH_TARGET)
@@ -59,19 +60,25 @@ Q_DECLARE_LOGGING_CATEGORY(DBG_TOUCH_TARGET)
*/
QQuickSinglePointHandler::QQuickSinglePointHandler(QQuickItem *parent)
- : QQuickPointerDeviceHandler(parent)
+ : QQuickPointerDeviceHandler(*(new QQuickSinglePointHandlerPrivate), parent)
+{
+}
+
+QQuickSinglePointHandler::QQuickSinglePointHandler(QQuickSinglePointHandlerPrivate &dd, QQuickItem *parent)
+ : QQuickPointerDeviceHandler(dd, parent)
{
}
bool QQuickSinglePointHandler::wantsPointerEvent(QQuickPointerEvent *event)
{
+ Q_D(QQuickSinglePointHandler);
if (!QQuickPointerDeviceHandler::wantsPointerEvent(event))
return false;
if (event->device()->pointerType() != QQuickPointerDevice::Finger &&
(event->buttons() & acceptedButtons()) == 0 && (event->button() & acceptedButtons()) == 0)
return false;
- if (m_pointInfo.m_id) {
+ if (d->pointInfo.id()) {
// We already know which one we want, so check whether it's there.
// It's expected to be an update or a release.
// If we no longer want it, cancel the grab.
@@ -81,7 +88,7 @@ bool QQuickSinglePointHandler::wantsPointerEvent(QQuickPointerEvent *event)
int c = event->pointCount();
for (int i = 0; i < c; ++i) {
QQuickEventPoint *p = event->point(i);
- const bool found = (p->pointId() == m_pointInfo.m_id);
+ const bool found = (p->pointId() == d->pointInfo.id());
if (found)
missing = false;
if (wantsEventPoint(p)) {
@@ -91,10 +98,10 @@ bool QQuickSinglePointHandler::wantsPointerEvent(QQuickPointerEvent *event)
}
}
if (missing)
- qCWarning(DBG_TOUCH_TARGET) << this << "pointId" << hex << m_pointInfo.m_id
+ qCWarning(DBG_TOUCH_TARGET) << this << "pointId" << hex << d->pointInfo.id()
<< "is missing from current event, but was neither canceled nor released";
if (point) {
- if (candidatePointCount == 1 || (candidatePointCount > 1 && m_ignoreAdditionalPoints)) {
+ if (candidatePointCount == 1 || (candidatePointCount > 1 && d->ignoreAdditionalPoints)) {
point->setAccepted();
return true;
} else {
@@ -121,35 +128,37 @@ bool QQuickSinglePointHandler::wantsPointerEvent(QQuickPointerEvent *event)
chosen->setAccepted();
}
}
- return m_pointInfo.m_id;
+ return d->pointInfo.id();
}
void QQuickSinglePointHandler::handlePointerEventImpl(QQuickPointerEvent *event)
{
+ Q_D(QQuickSinglePointHandler);
QQuickPointerDeviceHandler::handlePointerEventImpl(event);
- QQuickEventPoint *currentPoint = event->pointById(m_pointInfo.m_id);
+ QQuickEventPoint *currentPoint = event->pointById(d->pointInfo.id());
Q_ASSERT(currentPoint);
- m_pointInfo.reset(currentPoint);
+ d->pointInfo.reset(currentPoint);
handleEventPoint(currentPoint);
if (currentPoint->state() == QQuickEventPoint::Released && (event->buttons() & acceptedButtons()) == Qt::NoButton) {
setExclusiveGrab(currentPoint, false);
- reset();
+ d->reset();
}
emit pointChanged();
}
void QQuickSinglePointHandler::onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point)
{
+ Q_D(QQuickSinglePointHandler);
if (grabber != this)
return;
switch (transition) {
case QQuickEventPoint::GrabExclusive:
- m_pointInfo.m_sceneGrabPosition = point->sceneGrabPosition();
+ d->pointInfo.m_sceneGrabPosition = point->sceneGrabPosition();
setActive(true);
QQuickPointerHandler::onGrabChanged(grabber, transition, point);
break;
case QQuickEventPoint::GrabPassive:
- m_pointInfo.m_sceneGrabPosition = point->sceneGrabPosition();
+ d->pointInfo.m_sceneGrabPosition = point->sceneGrabPosition();
QQuickPointerHandler::onGrabChanged(grabber, transition, point);
break;
case QQuickEventPoint::OverrideGrabPassive:
@@ -160,32 +169,35 @@ void QQuickSinglePointHandler::onGrabChanged(QQuickPointerHandler *grabber, QQui
case QQuickEventPoint::CancelGrabExclusive:
// the grab is lost or relinquished, so the point is no longer relevant
QQuickPointerHandler::onGrabChanged(grabber, transition, point);
- reset();
+ d->reset();
break;
}
}
void QQuickSinglePointHandler::setIgnoreAdditionalPoints(bool v)
{
- m_ignoreAdditionalPoints = v;
+ Q_D(QQuickSinglePointHandler);
+ d->ignoreAdditionalPoints = v;
}
void QQuickSinglePointHandler::moveTarget(QPointF pos, QQuickEventPoint *point)
{
+ Q_D(QQuickSinglePointHandler);
target()->setPosition(pos);
- m_pointInfo.m_scenePosition = point->scenePosition();
- m_pointInfo.m_position = target()->mapFromScene(m_pointInfo.m_scenePosition);
+ d->pointInfo.m_scenePosition = point->scenePosition();
+ d->pointInfo.m_position = target()->mapFromScene(d->pointInfo.m_scenePosition);
}
void QQuickSinglePointHandler::setPointId(int id)
{
- m_pointInfo.m_id = id;
+ Q_D(QQuickSinglePointHandler);
+ d->pointInfo.m_id = id;
}
-void QQuickSinglePointHandler::reset()
+QQuickHandlerPoint QQuickSinglePointHandler::point() const
{
- setActive(false);
- m_pointInfo.reset();
+ Q_D(const QQuickSinglePointHandler);
+ return d->pointInfo;
}
/*!
@@ -196,4 +208,16 @@ void QQuickSinglePointHandler::reset()
handled, this object is reset to default values (all coordinates are 0).
*/
+QQuickSinglePointHandlerPrivate::QQuickSinglePointHandlerPrivate()
+ : QQuickPointerDeviceHandlerPrivate()
+{
+}
+
+void QQuickSinglePointHandlerPrivate::reset()
+{
+ Q_Q(QQuickSinglePointHandler);
+ q->setActive(false);
+ pointInfo.reset();
+}
+
QT_END_NAMESPACE
diff --git a/src/quick/handlers/qquicksinglepointhandler_p.h b/src/quick/handlers/qquicksinglepointhandler_p.h
index 7bf8eff999..edc55aaaf6 100644
--- a/src/quick/handlers/qquicksinglepointhandler_p.h
+++ b/src/quick/handlers/qquicksinglepointhandler_p.h
@@ -56,24 +56,29 @@
QT_BEGIN_NAMESPACE
+class QQuickSinglePointHandlerPrivate;
+
class Q_QUICK_PRIVATE_EXPORT QQuickSinglePointHandler : public QQuickPointerDeviceHandler
{
Q_OBJECT
Q_PROPERTY(QQuickHandlerPoint point READ point NOTIFY pointChanged)
+
public:
explicit QQuickSinglePointHandler(QQuickItem *parent = nullptr);
- QQuickHandlerPoint point() const { return m_pointInfo; }
+ QQuickHandlerPoint point() const;
Q_SIGNALS:
void pointChanged();
protected:
+ QQuickSinglePointHandler(QQuickSinglePointHandlerPrivate &dd, QQuickItem *parent);
+
bool wantsPointerEvent(QQuickPointerEvent *event) override;
void handlePointerEventImpl(QQuickPointerEvent *event) override;
virtual void handleEventPoint(QQuickEventPoint *point) = 0;
- QQuickEventPoint *currentPoint(QQuickPointerEvent *ev) { return ev->pointById(m_pointInfo.m_id); }
+ QQuickEventPoint *currentPoint(QQuickPointerEvent *ev);
void onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point) override;
void setIgnoreAdditionalPoints(bool v = true);
@@ -82,11 +87,7 @@ protected:
void setPointId(int id);
- void reset();
-
-private:
- QQuickHandlerPoint m_pointInfo;
- bool m_ignoreAdditionalPoints = false;
+ Q_DECLARE_PRIVATE(QQuickSinglePointHandler)
};
QT_END_NAMESPACE
diff --git a/src/quick/handlers/qquicksinglepointhandler_p_p.h b/src/quick/handlers/qquicksinglepointhandler_p_p.h
new file mode 100644
index 0000000000..1e66c25e14
--- /dev/null
+++ b/src/quick/handlers/qquicksinglepointhandler_p_p.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 QQUICKPOINTERSINGLEHANDLER_P_H
+#define QQUICKPOINTERSINGLEHANDLER_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.
+//
+
+#include "qquickhandlerpoint_p.h"
+#include "qquickpointerdevicehandler_p_p.h"
+#include "qquicksinglepointhandler_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class Q_QUICK_PRIVATE_EXPORT QQuickSinglePointHandlerPrivate : public QQuickPointerDeviceHandlerPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickSinglePointHandler)
+
+public:
+ static QQuickSinglePointHandlerPrivate* get(QQuickSinglePointHandler *q) { return q->d_func(); }
+ static const QQuickSinglePointHandlerPrivate* get(const QQuickSinglePointHandler *q) { return q->d_func(); }
+
+ QQuickSinglePointHandlerPrivate();
+
+ void reset();
+
+ QQuickHandlerPoint pointInfo;
+ bool ignoreAdditionalPoints = false;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKPOINTERSINGLEHANDLER_P_H
+
diff --git a/src/quick/handlers/qquicktaphandler.cpp b/src/quick/handlers/qquicktaphandler.cpp
index 41ac294df3..081645da71 100644
--- a/src/quick/handlers/qquicktaphandler.cpp
+++ b/src/quick/handlers/qquicktaphandler.cpp
@@ -38,6 +38,7 @@
****************************************************************************/
#include "qquicktaphandler_p.h"
+#include "qquicksinglepointhandler_p_p.h"
#include <qpa/qplatformtheme.h>
#include <private/qguiapplication_p.h>
#include <QtGui/qstylehints.h>
@@ -317,7 +318,7 @@ void QQuickTapHandler::setPressed(bool press, bool cancel, QQuickEventPoint *poi
setExclusiveGrab(point, false);
// In case there is a filtering parent (Flickable), we should not give up the passive grab,
// so that it can continue to filter future events.
- reset();
+ d_func()->reset();
emit pointChanged();
}
}
diff --git a/src/quick/handlers/qquicktaphandler_p.h b/src/quick/handlers/qquicktaphandler_p.h
index 6ec5d55227..56e08590b2 100644
--- a/src/quick/handlers/qquicktaphandler_p.h
+++ b/src/quick/handlers/qquicktaphandler_p.h
@@ -58,7 +58,7 @@
QT_BEGIN_NAMESPACE
-class Q_AUTOTEST_EXPORT QQuickTapHandler : public QQuickSinglePointHandler
+class Q_QUICK_PRIVATE_EXPORT QQuickTapHandler : public QQuickSinglePointHandler
{
Q_OBJECT
Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged)
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp
index 06dddabb65..14443a2f2f 100644
--- a/src/quick/items/context2d/qquickcanvasitem.cpp
+++ b/src/quick/items/context2d/qquickcanvasitem.cpp
@@ -735,7 +735,7 @@ void QQuickCanvasItem::updatePolish()
for (auto it = animationCallbacks.cbegin(), end = animationCallbacks.cend(); it != end; ++it) {
function = it.value().value();
- jsCall->args[0] = QV4::Value::fromUInt32(QDateTime::currentMSecsSinceEpoch() / 1000);
+ jsCall->args[0] = QV4::Value::fromUInt32(QDateTime::currentMSecsSinceEpoch());
function->call(jsCall);
}
}
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index 57e697bdd1..546f3011ec 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -3004,7 +3004,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_measureText(const QV4::Fun
if (argc >= 1) {
QFontMetrics fm(r->d()->context()->state.font);
- uint width = fm.width(argv[0].toQStringNoThrow());
+ uint width = fm.horizontalAdvance(argv[0].toQStringNoThrow());
QV4::ScopedObject tm(scope, scope.engine->newObject());
tm->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("width"))).getPointer(),
QV4::ScopedValue(scope, QV4::Value::fromDouble(width)));
@@ -4084,10 +4084,10 @@ static int textAlignOffset(QQuickContext2D::TextAlignType value, const QFontMetr
value = QGuiApplication::layoutDirection() == Qt::LeftToRight ? QQuickContext2D::Right: QQuickContext2D::Left;
switch (value) {
case QQuickContext2D::Center:
- offset = metrics.width(text)/2;
+ offset = metrics.horizontalAdvance(text) / 2;
break;
case QQuickContext2D::Right:
- offset = metrics.width(text);
+ offset = metrics.horizontalAdvance(text);
case QQuickContext2D::Left:
default:
break;
diff --git a/src/quick/items/qquickclipnode.cpp b/src/quick/items/qquickclipnode.cpp
index 747e844172..d90b1f1540 100644
--- a/src/quick/items/qquickclipnode.cpp
+++ b/src/quick/items/qquickclipnode.cpp
@@ -43,6 +43,8 @@
#include <QtGui/qvector2d.h>
#include <QtCore/qmath.h>
+QT_BEGIN_NAMESPACE
+
QQuickDefaultClipNode::QQuickDefaultClipNode(const QRectF &rect)
: m_rect(rect)
, m_radius(0)
@@ -117,3 +119,4 @@ void QQuickDefaultClipNode::updateGeometry()
markDirty(DirtyGeometry);
}
+QT_END_NAMESPACE
diff --git a/src/quick/items/qquickclipnode_p.h b/src/quick/items/qquickclipnode_p.h
index ed9e1ae4d8..00914deae8 100644
--- a/src/quick/items/qquickclipnode_p.h
+++ b/src/quick/items/qquickclipnode_p.h
@@ -54,6 +54,8 @@
#include <private/qtquickglobal_p.h>
#include <QtQuick/qsgnode.h>
+QT_BEGIN_NAMESPACE
+
class Q_QUICK_PRIVATE_EXPORT QQuickDefaultClipNode : public QSGClipNode
{
public:
@@ -78,4 +80,6 @@ private:
QSGGeometry m_geometry;
};
+QT_END_NAMESPACE
+
#endif // QQUICKCLIPNODE_P_H
diff --git a/src/quick/items/qquickflickable_p.h b/src/quick/items/qquickflickable_p.h
index f21fe94177..c54ed5ce71 100644
--- a/src/quick/items/qquickflickable_p.h
+++ b/src/quick/items/qquickflickable_p.h
@@ -117,7 +117,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickFlickable : public QQuickItem
public:
QQuickFlickable(QQuickItem *parent=nullptr);
- ~QQuickFlickable();
+ ~QQuickFlickable() override;
QQmlListProperty<QObject> flickableData();
QQmlListProperty<QQuickItem> flickableChildren();
diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp
index 272d4a4df5..6638fbd3e8 100644
--- a/src/quick/items/qquickgridview.cpp
+++ b/src/quick/items/qquickgridview.cpp
@@ -2636,6 +2636,19 @@ bool QQuickGridViewPrivate::needsRefillForAddedOrRemovedIndex(int modelIndex) co
\b Note: methods should only be called after the Component has completed.
*/
+/*!
+ \qmlmethod Item QtQuick::GridView::itemAtIndex(int index)
+
+ Returns the item for \a index. If there is no item for that index, for example
+ because it has not been created yet, or because it has been panned out of
+ the visible area and removed from the cache, null is returned.
+
+ \b Note: this method should only be called after the Component has completed.
+ The returned value should also not be stored since it can turn to null
+ as soon as control goes out of the calling scope, if the view releases that item.
+
+ \since 5.13
+*/
/*!
\qmlmethod QtQuick::GridView::forceLayout()
diff --git a/src/quick/items/qquickimage.cpp b/src/quick/items/qquickimage.cpp
index 49e5b7b1fa..4a0936b4d5 100644
--- a/src/quick/items/qquickimage.cpp
+++ b/src/quick/items/qquickimage.cpp
@@ -52,42 +52,28 @@
QT_BEGIN_NAMESPACE
-class QQuickImageTextureProvider : public QSGTextureProvider
+QQuickImageTextureProvider::QQuickImageTextureProvider()
+ : m_texture(nullptr)
+ , m_smooth(false)
{
- Q_OBJECT
-public:
- QQuickImageTextureProvider()
- : m_texture(nullptr)
- , m_smooth(false)
- {
- }
+}
- void updateTexture(QSGTexture *texture) {
- if (m_texture == texture)
- return;
- m_texture = texture;
- emit textureChanged();
- }
+void QQuickImageTextureProvider::updateTexture(QSGTexture *texture) {
+ if (m_texture == texture)
+ return;
+ m_texture = texture;
+ emit textureChanged();
+}
- QSGTexture *texture() const override {
- if (m_texture) {
- m_texture->setFiltering(m_smooth ? QSGTexture::Linear : QSGTexture::Nearest);
- m_texture->setMipmapFiltering(m_mipmap ? QSGTexture::Linear : QSGTexture::None);
- m_texture->setHorizontalWrapMode(QSGTexture::ClampToEdge);
- m_texture->setVerticalWrapMode(QSGTexture::ClampToEdge);
- }
- return m_texture;
+QSGTexture *QQuickImageTextureProvider::texture() const {
+ if (m_texture) {
+ m_texture->setFiltering(m_smooth ? QSGTexture::Linear : QSGTexture::Nearest);
+ m_texture->setMipmapFiltering(m_mipmap ? QSGTexture::Linear : QSGTexture::None);
+ m_texture->setHorizontalWrapMode(QSGTexture::ClampToEdge);
+ m_texture->setVerticalWrapMode(QSGTexture::ClampToEdge);
}
-
- friend class QQuickImage;
-
- QSGTexture *m_texture;
- bool m_smooth;
- bool m_mipmap;
-};
-
-#include "qquickimage.moc"
-#include "moc_qquickimage_p.cpp"
+ return m_texture;
+}
QQuickImagePrivate::QQuickImagePrivate()
: fillMode(QQuickImage::Stretch)
@@ -146,6 +132,7 @@ QQuickImagePrivate::QQuickImagePrivate()
\list
\li \c PKM (since Qt 5.10)
\li \c KTX (since Qt 5.11)
+ \li \c ASTC (since Qt 5.13)
\endlist
\note Semi-transparent original images require alpha pre-multiplication
@@ -153,7 +140,7 @@ QQuickImagePrivate::QQuickImagePrivate()
Quick. This can be done with the following ImageMagick command
line:
\badcode
- convert MYORIGIMAGE \( +clone -alpha Extract \) -channel RGB -compose Multiply -composite MYPMIMAGE
+ convert foo.png \( +clone -alpha Extract \) -channel RGB -compose Multiply -composite foo_pm.png
\endcode
\section1 Automatic Detection of File Extension
diff --git a/src/quick/items/qquickimage_p_p.h b/src/quick/items/qquickimage_p_p.h
index afc33def0f..e2c467c311 100644
--- a/src/quick/items/qquickimage_p_p.h
+++ b/src/quick/items/qquickimage_p_p.h
@@ -53,10 +53,26 @@
#include "qquickimagebase_p_p.h"
#include "qquickimage_p.h"
+#include <QtQuick/qsgtextureprovider.h>
QT_BEGIN_NAMESPACE
-class QQuickImageTextureProvider;
+class Q_QUICK_PRIVATE_EXPORT QQuickImageTextureProvider : public QSGTextureProvider
+{
+ Q_OBJECT
+public:
+ QQuickImageTextureProvider();
+
+ void updateTexture(QSGTexture *texture);
+
+ QSGTexture *texture() const override ;
+
+ friend class QQuickImage;
+
+ QSGTexture *m_texture;
+ bool m_smooth;
+ bool m_mipmap;
+};
class Q_QUICK_PRIVATE_EXPORT QQuickImagePrivate : public QQuickImageBasePrivate
{
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 9e32ccfee9..ec6bf5a1b8 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -4444,6 +4444,8 @@ void QQuickItem::update()
When the scene graph processes the request, it will call updatePolish()
on this item.
+
+ \sa updatePolish(), QQuickTest::qIsPolishScheduled()
*/
void QQuickItem::polish()
{
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp
index b2fcfb4307..ddd438e56d 100644
--- a/src/quick/items/qquickitemsmodule.cpp
+++ b/src/quick/items/qquickitemsmodule.cpp
@@ -472,6 +472,10 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
#if QT_CONFIG(quick_tableview)
qmlRegisterType<QQuickTableView>(uri, 2, 12, "TableView");
#endif
+
+ qmlRegisterUncreatableType<QQuickItemView, 13>(uri, 2, 13, itemViewName, itemViewMessage);
+ qmlRegisterType<QQuickPathView, 13>(uri, 2, 13, "PathView");
+ qmlRegisterType<QQuickGridView, 13>(uri, 2, 13, "GridView");
}
static void initResources()
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index 8dafc16cf4..1f8a0de72b 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -951,6 +951,13 @@ QQuickItem *QQuickItemView::itemAt(qreal x, qreal y) const
return item ? item->item : nullptr;
}
+QQuickItem *QQuickItemView::itemAtIndex(int index) const
+{
+ Q_D(const QQuickItemView);
+ const FxViewItem *item = d->visibleItem(index);
+ return item ? item->item : nullptr;
+}
+
void QQuickItemView::forceLayout()
{
Q_D(QQuickItemView);
diff --git a/src/quick/items/qquickitemview_p.h b/src/quick/items/qquickitemview_p.h
index 483fc1a09f..0a0da587b4 100644
--- a/src/quick/items/qquickitemview_p.h
+++ b/src/quick/items/qquickitemview_p.h
@@ -228,6 +228,7 @@ public:
Q_INVOKABLE void positionViewAtIndex(int index, int mode);
Q_INVOKABLE int indexAt(qreal x, qreal y) const;
Q_INVOKABLE QQuickItem *itemAt(qreal x, qreal y) const;
+ Q_REVISION(13) Q_INVOKABLE QQuickItem *itemAtIndex(int index) const;
Q_INVOKABLE void positionViewAtBeginning();
Q_INVOKABLE void positionViewAtEnd();
Q_REVISION(1) Q_INVOKABLE void forceLayout();
diff --git a/src/quick/items/qquickitemviewfxitem.cpp b/src/quick/items/qquickitemviewfxitem.cpp
index f9c65967ea..60e9d7b115 100644
--- a/src/quick/items/qquickitemviewfxitem.cpp
+++ b/src/quick/items/qquickitemviewfxitem.cpp
@@ -45,9 +45,9 @@ QT_BEGIN_NAMESPACE
QQuickItemViewFxItem::QQuickItemViewFxItem(QQuickItem *item, bool ownItem, QQuickItemChangeListener* changeListener)
: item(item)
- , ownItem(ownItem)
, changeListener(changeListener)
, transitionableItem(nullptr)
+ , ownItem(ownItem)
, releaseAfterTransition(false)
, trackGeom(false)
{
diff --git a/src/quick/items/qquickitemviewfxitem_p_p.h b/src/quick/items/qquickitemviewfxitem_p_p.h
index 48ffe248bc..3bc5ba440c 100644
--- a/src/quick/items/qquickitemviewfxitem_p_p.h
+++ b/src/quick/items/qquickitemviewfxitem_p_p.h
@@ -94,13 +94,13 @@ public:
virtual bool contains(qreal x, qreal y) const = 0;
- int index = -1;
QPointer<QQuickItem> item;
- bool ownItem;
QQuickItemChangeListener *changeListener;
QQuickItemViewTransitionableItem *transitionableItem;
- bool releaseAfterTransition;
- bool trackGeom;
+ int index = -1;
+ bool ownItem : 1;
+ bool releaseAfterTransition : 1;
+ bool trackGeom : 1;
};
QT_END_NAMESPACE
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index 75a24c7d76..81d019a26d 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -3518,6 +3518,20 @@ void QQuickListViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex
*/
/*!
+ \qmlmethod Item QtQuick::ListView::itemAtIndex(int index)
+
+ Returns the item for \a index. If there is no item for that index, for example
+ because it has not been created yet, or because it has been panned out of
+ the visible area and removed from the cache, null is returned.
+
+ \b Note: this method should only be called after the Component has completed.
+ The returned value should also not be stored since it can turn to null
+ as soon as control goes out of the calling scope, if the view releases that item.
+
+ \since 5.13
+*/
+
+/*!
\qmlmethod QtQuick::ListView::forceLayout()
Responding to changes in the model is usually batched to happen only once
diff --git a/src/quick/items/qquickopenglshadereffect.cpp b/src/quick/items/qquickopenglshadereffect.cpp
index cad598d2c0..3aa00340b2 100644
--- a/src/quick/items/qquickopenglshadereffect.cpp
+++ b/src/quick/items/qquickopenglshadereffect.cpp
@@ -245,7 +245,11 @@ void QQuickOpenGLShaderEffectCommon::connectPropertySignals(QQuickItem *item,
const QMetaObject *itemMetaObject,
Key::ShaderType shaderType)
{
- QQmlPropertyCache *propCache = QQmlData::ensurePropertyCache(qmlEngine(item), item);
+ auto engine = qmlEngine(item);
+ if (!engine)
+ return;
+
+ QQmlPropertyCache *propCache = QQmlData::ensurePropertyCache(engine, item);
for (int i = 0; i < uniformData[shaderType].size(); ++i) {
if (signalMappers[shaderType].at(i) == 0)
continue;
@@ -317,7 +321,8 @@ void QQuickOpenGLShaderEffectCommon::lookThroughShaderCode(QQuickItem *item,
Key::ShaderType shaderType,
const QByteArray &code)
{
- QQmlPropertyCache *propCache = QQmlData::ensurePropertyCache(qmlEngine(item), item);
+ auto engine = qmlEngine(item);
+ QQmlPropertyCache *propCache = (engine) ? QQmlData::ensurePropertyCache(engine, item) : nullptr;
int index = 0;
int typeIndex = -1;
int typeLength = 0;
@@ -350,9 +355,11 @@ void QQuickOpenGLShaderEffectCommon::lookThroughShaderCode(QQuickItem *item,
} else if (nameLength > srLen && qstrncmp("qt_SubRect_", s + nameIndex, srLen) == 0) {
d.specialType = UniformData::SubRect;
} else {
- if (QQmlPropertyData *pd = propCache->property(QString::fromUtf8(d.name), nullptr, nullptr)) {
- if (!pd->isFunction())
- d.propertyIndex = pd->coreIndex();
+ if (propCache) {
+ if (QQmlPropertyData *pd = propCache->property(QString::fromUtf8(d.name), nullptr, nullptr)) {
+ if (!pd->isFunction())
+ d.propertyIndex = pd->coreIndex();
+ }
}
const int mappedId = uniformData[shaderType].size() | (shaderType << 16);
mapper = new QtPrivate::MappedSlotObject([this, mappedId](){
diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp
index fd5814d2b2..e4480b335a 100644
--- a/src/quick/items/qquickpathview.cpp
+++ b/src/quick/items/qquickpathview.cpp
@@ -1550,6 +1550,33 @@ QQuickItem *QQuickPathView::itemAt(qreal x, qreal y) const
return nullptr;
}
+/*!
+ \qmlmethod Item QtQuick::QQuickPathView::itemAtIndex(int index)
+
+ Returns the item for \a index. If there is no item for that index, for example
+ because it has not been created yet, or because it has been panned out of
+ the visible area and removed from the cache, null is returned.
+
+ \b Note: this method should only be called after the Component has completed.
+ The returned value should also not be stored since it can turn to null
+ as soon as control goes out of the calling scope, if the view releases that item.
+
+ \since 5.13
+*/
+QQuickItem *QQuickPathView::itemAtIndex(int index) const
+{
+ Q_D(const QQuickPathView);
+ if (!d->isValid())
+ return nullptr;
+
+ for (QQuickItem *item : d->items) {
+ if (index == d->model->indexOf(item, nullptr))
+ return item;
+ }
+
+ return nullptr;
+}
+
QPointF QQuickPathViewPrivate::pointNear(const QPointF &point, qreal *nearPercent) const
{
const auto pathLength = path->path().length();
diff --git a/src/quick/items/qquickpathview_p.h b/src/quick/items/qquickpathview_p.h
index 0e237b7b74..66be7fa6ff 100644
--- a/src/quick/items/qquickpathview_p.h
+++ b/src/quick/items/qquickpathview_p.h
@@ -180,6 +180,7 @@ public:
Q_INVOKABLE void positionViewAtIndex(int index, int mode);
Q_INVOKABLE int indexAt(qreal x, qreal y) const;
Q_INVOKABLE QQuickItem *itemAt(qreal x, qreal y) const;
+ Q_REVISION(13) Q_INVOKABLE QQuickItem *itemAtIndex(int index) const;
static QQuickPathViewAttached *qmlAttachedProperties(QObject *);
diff --git a/src/quick/items/qquickrectangle_p_p.h b/src/quick/items/qquickrectangle_p_p.h
index c7c5293f9b..f40e5adada 100644
--- a/src/quick/items/qquickrectangle_p_p.h
+++ b/src/quick/items/qquickrectangle_p_p.h
@@ -64,7 +64,7 @@ class QQuickRectanglePrivate : public QQuickItemPrivate
public:
QQuickRectanglePrivate() :
- color(Qt::white), gradient(0), pen(0), radius(0)
+ color(Qt::white), gradient(QJSValue::UndefinedValue), pen(0), radius(0)
{
}
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
index 9cd407b0fd..ac3397d2a9 100644
--- a/src/quick/items/qquicktableview.cpp
+++ b/src/quick/items/qquicktableview.cpp
@@ -150,6 +150,11 @@
must call \l forceLayout. This informs TableView that it needs to use the
provider functions again to recalculate and update the layout.
+ Since Qt 5.13, if you want to hide a specific column, you can return \c 0 from the
+ \l columnWidthProvider for that column. Likewise, you can return 0 from the
+ \l rowHeightProvider to hide a row. If you return a negative number, TableView
+ will fall back to calculate the size based on the delegate items.
+
\note The size of a row or column should be a whole number to avoid
sub-pixel alignment of items.
@@ -217,7 +222,9 @@
know the height of a specific row. The function takes one argument, \c row,
for which the TableView needs to know the height.
- \note The height of a row must always be greater than \c 0.
+ Since Qt 5.13, if you want to hide a specific row, you can return \c 0 height for
+ that row. If you return a negative number, TableView will fall back to
+ calculate the height based on the delegate items.
\sa columnWidthProvider, {Row heights and column widths}
*/
@@ -230,7 +237,9 @@
to know the width of a specific column. The function takes one argument,
\c column, for which the TableView needs to know the width.
- \note The width of a column must always be greater than \c 0.
+ Since Qt 5.13, if you want to hide a specific column, you can return \c 0 width for
+ that column. If you return a negative number, TableView will fall back to
+ calculate the width based on the delegate items.
\sa rowHeightProvider, {Row heights and column widths}
*/
@@ -377,42 +386,41 @@ Q_LOGGING_CATEGORY(lcTableViewDelegateLifecycle, "qt.quick.tableview.lifecycle")
#define Q_TABLEVIEW_ASSERT(cond, output) Q_ASSERT((cond) || [&](){ dumpTable(); qWarning() << "output:" << output; return false;}())
static const Qt::Edge allTableEdges[] = { Qt::LeftEdge, Qt::RightEdge, Qt::TopEdge, Qt::BottomEdge };
-
-static QLine rectangleEdge(const QRect &rect, Qt::Edge tableEdge)
-{
- switch (tableEdge) {
- case Qt::LeftEdge:
- return QLine(rect.topLeft(), rect.bottomLeft());
- case Qt::RightEdge:
- return QLine(rect.topRight(), rect.bottomRight());
- case Qt::TopEdge:
- return QLine(rect.topLeft(), rect.topRight());
- case Qt::BottomEdge:
- return QLine(rect.bottomLeft(), rect.bottomRight());
- }
- return QLine();
-}
-
-static QRect expandedRect(const QRect &rect, Qt::Edge edge, int increment)
-{
- switch (edge) {
- case Qt::LeftEdge:
- return rect.adjusted(-increment, 0, 0, 0);
- case Qt::RightEdge:
- return rect.adjusted(0, 0, increment, 0);
- case Qt::TopEdge:
- return rect.adjusted(0, -increment, 0, 0);
- case Qt::BottomEdge:
- return rect.adjusted(0, 0, 0, increment);
- }
- return QRect();
-}
+static const int kEdgeIndexNotSet = -2;
+static const int kEdgeIndexAtEnd = -3;
const QPoint QQuickTableViewPrivate::kLeft = QPoint(-1, 0);
const QPoint QQuickTableViewPrivate::kRight = QPoint(1, 0);
const QPoint QQuickTableViewPrivate::kUp = QPoint(0, -1);
const QPoint QQuickTableViewPrivate::kDown = QPoint(0, 1);
+QQuickTableViewPrivate::EdgeRange::EdgeRange()
+ : startIndex(kEdgeIndexNotSet)
+ , endIndex(kEdgeIndexNotSet)
+ , size(0)
+{}
+
+bool QQuickTableViewPrivate::EdgeRange::containsIndex(Qt::Edge edge, int index)
+{
+ if (startIndex == kEdgeIndexNotSet)
+ return false;
+
+ if (endIndex == kEdgeIndexAtEnd) {
+ switch (edge) {
+ case Qt::LeftEdge:
+ case Qt::TopEdge:
+ return index <= startIndex;
+ case Qt::RightEdge:
+ case Qt::BottomEdge:
+ return index >= startIndex;
+ }
+ }
+
+ const int s = std::min(startIndex, endIndex);
+ const int e = std::max(startIndex, endIndex);
+ return index >= s && index <= e;
+}
+
QQuickTableViewPrivate::QQuickTableViewPrivate()
: QQuickFlickablePrivate()
{
@@ -428,8 +436,8 @@ QQuickTableViewPrivate::~QQuickTableViewPrivate()
QString QQuickTableViewPrivate::tableLayoutToString() const
{
return QString(QLatin1String("table cells: (%1,%2) -> (%3,%4), item count: %5, table rect: %6,%7 x %8,%9"))
- .arg(loadedTable.topLeft().x()).arg(loadedTable.topLeft().y())
- .arg(loadedTable.bottomRight().x()).arg(loadedTable.bottomRight().y())
+ .arg(leftColumn()).arg(topRow())
+ .arg(rightColumn()).arg(bottomRow())
.arg(loadedItems.count())
.arg(loadedTableOuterRect.x())
.arg(loadedTableOuterRect.y())
@@ -479,6 +487,118 @@ QPoint QQuickTableViewPrivate::cellAtModelIndex(int modelIndex) const
return QPoint(column, row);
}
+int QQuickTableViewPrivate::edgeToArrayIndex(Qt::Edge edge)
+{
+ return int(log2(float(edge)));
+}
+
+void QQuickTableViewPrivate::clearEdgeSizeCache()
+{
+ cachedColumnWidth.startIndex = kEdgeIndexNotSet;
+ cachedRowHeight.startIndex = kEdgeIndexNotSet;
+
+ for (Qt::Edge edge : allTableEdges)
+ cachedNextVisibleEdgeIndex[edgeToArrayIndex(edge)].startIndex = kEdgeIndexNotSet;
+}
+
+int QQuickTableViewPrivate::nextVisibleEdgeIndexAroundLoadedTable(Qt::Edge edge)
+{
+ // Find the next column (or row) around the loaded table that is
+ // visible, and should be loaded next if the content item moves.
+ int startIndex = -1;
+ switch (edge) {
+ case Qt::LeftEdge: startIndex = loadedColumns.firstKey() - 1; break;
+ case Qt::RightEdge: startIndex = loadedColumns.lastKey() + 1; break;
+ case Qt::TopEdge: startIndex = loadedRows.firstKey() - 1; break;
+ case Qt::BottomEdge: startIndex = loadedRows.lastKey() + 1; break;
+ }
+
+ return nextVisibleEdgeIndex(edge, startIndex);
+}
+
+int QQuickTableViewPrivate::nextVisibleEdgeIndex(Qt::Edge edge, int startIndex)
+{
+ // First check if we have already searched for the first visible index
+ // after the given startIndex recently, and if so, return the cached result.
+ // The cached result is valid if startIndex is inside the range between the
+ // startIndex and the first visible index found after it.
+ auto &cachedResult = cachedNextVisibleEdgeIndex[edgeToArrayIndex(edge)];
+ if (cachedResult.containsIndex(edge, startIndex))
+ return cachedResult.endIndex;
+
+ // Search for the first column (or row) in the direction of edge that is
+ // visible, starting from the given column (startIndex).
+ int foundIndex = kEdgeIndexNotSet;
+ int testIndex = startIndex;
+
+ switch (edge) {
+ case Qt::LeftEdge: {
+ forever {
+ if (testIndex < 0) {
+ foundIndex = kEdgeIndexAtEnd;
+ break;
+ }
+
+ if (!isColumnHidden(testIndex)) {
+ foundIndex = testIndex;
+ break;
+ }
+
+ --testIndex;
+ }
+ break; }
+ case Qt::RightEdge: {
+ forever {
+ if (testIndex > tableSize.width() - 1) {
+ foundIndex = kEdgeIndexAtEnd;
+ break;
+ }
+
+ if (!isColumnHidden(testIndex)) {
+ foundIndex = testIndex;
+ break;
+ }
+
+ ++testIndex;
+ }
+ break; }
+ case Qt::TopEdge: {
+ forever {
+ if (testIndex < 0) {
+ foundIndex = kEdgeIndexAtEnd;
+ break;
+ }
+
+ if (!isRowHidden(testIndex)) {
+ foundIndex = testIndex;
+ break;
+ }
+
+ --testIndex;
+ }
+ break; }
+ case Qt::BottomEdge: {
+ forever {
+ if (testIndex > tableSize.height() - 1) {
+ foundIndex = kEdgeIndexAtEnd;
+ break;
+ }
+
+ if (!isRowHidden(testIndex)) {
+ foundIndex = testIndex;
+ break;
+ }
+
+ ++testIndex;
+ }
+ break; }
+ }
+
+ cachedResult.startIndex = startIndex;
+ cachedResult.endIndex = foundIndex;
+ return foundIndex;
+}
+
void QQuickTableViewPrivate::updateContentWidth()
{
Q_Q(QQuickTableView);
@@ -489,31 +609,13 @@ void QQuickTableViewPrivate::updateContentWidth()
return;
}
- const qreal thresholdBeforeAdjust = 0.1;
- int currentRightColumn = loadedTable.right();
-
- if (currentRightColumn > contentSizeBenchMarkPoint.x()) {
- contentSizeBenchMarkPoint.setX(currentRightColumn);
-
- const qreal spacing = currentRightColumn * cellSpacing.width();
- qreal currentWidth = loadedTableOuterRect.right();
- const qreal averageCellWidth = (currentWidth - spacing) / (currentRightColumn + 1);
- qreal estimatedWidth = (tableSize.width() * (averageCellWidth + cellSpacing.width())) - cellSpacing.width();
-
- if (currentRightColumn >= tableSize.width() - 1) {
- // We are at the last column, and can set the exact width
- if (!qFuzzyCompare(currentWidth, q->implicitWidth()))
- q->QQuickFlickable::setContentWidth(currentWidth);
- } else if (currentWidth >= q->implicitWidth()) {
- // We are at the estimated width, but there are still more columns
- q->QQuickFlickable::setContentWidth(estimatedWidth);
- } else {
- // Only set a new width if the new estimate is substantially different
- qreal diff = 1 - (estimatedWidth / q->implicitWidth());
- if (qAbs(diff) > thresholdBeforeAdjust)
- q->QQuickFlickable::setContentWidth(estimatedWidth);
- }
- }
+ const int nextColumn = nextVisibleEdgeIndexAroundLoadedTable(Qt::RightEdge);
+ const int columnsRemaining = nextColumn == kEdgeIndexAtEnd ? 0 : tableSize.width() - nextColumn;
+ const qreal remainingColumnWidths = columnsRemaining * averageEdgeSize.width();
+ const qreal remainingSpacing = columnsRemaining * cellSpacing.width();
+ const qreal estimatedRemainingWidth = remainingColumnWidths + remainingSpacing;
+ const qreal estimatedWidth = loadedTableOuterRect.right() + estimatedRemainingWidth;
+ q->QQuickFlickable::setContentWidth(estimatedWidth);
}
void QQuickTableViewPrivate::updateContentHeight()
@@ -526,31 +628,13 @@ void QQuickTableViewPrivate::updateContentHeight()
return;
}
- const qreal thresholdBeforeAdjust = 0.1;
- int currentBottomRow = loadedTable.bottom();
-
- if (currentBottomRow > contentSizeBenchMarkPoint.y()) {
- contentSizeBenchMarkPoint.setY(currentBottomRow);
-
- const qreal spacing = currentBottomRow * cellSpacing.height();
- qreal currentHeight = loadedTableOuterRect.bottom();
- const qreal averageCellHeight = (currentHeight - spacing) / (currentBottomRow + 1);
- qreal estimatedHeight = (tableSize.height() * (averageCellHeight + cellSpacing.height())) - cellSpacing.height();
-
- if (currentBottomRow >= tableSize.height() - 1) {
- // We are at the last row, and can set the exact height
- if (!qFuzzyCompare(currentHeight, q->implicitHeight()))
- q->QQuickFlickable::setContentHeight(currentHeight);
- } else if (currentHeight >= q->implicitHeight()) {
- // We are at the estimated height, but there are still more rows
- q->QQuickFlickable::setContentHeight(estimatedHeight);
- } else {
- // Only set a new height if the new estimate is substantially different
- qreal diff = 1 - (estimatedHeight / q->implicitHeight());
- if (qAbs(diff) > thresholdBeforeAdjust)
- q->QQuickFlickable::setContentHeight(estimatedHeight);
- }
- }
+ const int nextRow = nextVisibleEdgeIndexAroundLoadedTable(Qt::BottomEdge);
+ const int rowsRemaining = nextRow == kEdgeIndexAtEnd ? 0 : tableSize.height() - nextRow;
+ const qreal remainingRowHeights = rowsRemaining * averageEdgeSize.height();
+ const qreal remainingSpacing = rowsRemaining * cellSpacing.height();
+ const qreal estimatedRemainingHeight = remainingRowHeights + remainingSpacing;
+ const qreal estimatedHeight = loadedTableOuterRect.bottom() + estimatedRemainingHeight;
+ q->QQuickFlickable::setContentHeight(estimatedHeight);
}
void QQuickTableViewPrivate::enforceTableAtOrigin()
@@ -562,24 +646,36 @@ void QQuickTableViewPrivate::enforceTableAtOrigin()
bool layoutNeeded = false;
const qreal flickMargin = 50;
- if (loadedTable.x() == 0 && loadedTableOuterRect.x() > 0) {
- // The table is at the beginning, but not at the edge of the
- // content view. So move the table to origin.
- loadedTableOuterRect.moveLeft(0);
- layoutNeeded = true;
- } else if (loadedTableOuterRect.x() < 0) {
- // The table is outside the beginning of the content view. Move
- // the whole table inside, and make some room for flicking.
- loadedTableOuterRect.moveLeft(loadedTable.x() == 0 ? 0 : flickMargin);
- layoutNeeded = true;
+ const bool noMoreColumns = nextVisibleEdgeIndexAroundLoadedTable(Qt::LeftEdge) == kEdgeIndexAtEnd;
+ const bool noMoreRows = nextVisibleEdgeIndexAroundLoadedTable(Qt::TopEdge) == kEdgeIndexAtEnd;
+
+ if (noMoreColumns) {
+ if (!qFuzzyIsNull(loadedTableOuterRect.left())) {
+ // There are no more columns, but the table rect
+ // is not at origin. So we move it there.
+ loadedTableOuterRect.moveLeft(0);
+ layoutNeeded = true;
+ }
+ } else {
+ if (loadedTableOuterRect.left() <= 0) {
+ // The table rect is at origin, or outside. But we still have
+ // more visible columns to the left. So we need to make some
+ // space so that they can be flicked in.
+ loadedTableOuterRect.moveLeft(flickMargin);
+ layoutNeeded = true;
+ }
}
- if (loadedTable.y() == 0 && loadedTableOuterRect.y() > 0) {
- loadedTableOuterRect.moveTop(0);
- layoutNeeded = true;
- } else if (loadedTableOuterRect.y() < 0) {
- loadedTableOuterRect.moveTop(loadedTable.y() == 0 ? 0 : flickMargin);
- layoutNeeded = true;
+ if (noMoreRows) {
+ if (!qFuzzyIsNull(loadedTableOuterRect.top())) {
+ loadedTableOuterRect.moveTop(0);
+ layoutNeeded = true;
+ }
+ } else {
+ if (loadedTableOuterRect.top() <= 0) {
+ loadedTableOuterRect.moveTop(flickMargin);
+ layoutNeeded = true;
+ }
}
if (layoutNeeded) {
@@ -590,47 +686,100 @@ void QQuickTableViewPrivate::enforceTableAtOrigin()
void QQuickTableViewPrivate::updateAverageEdgeSize()
{
- int bottomCell = loadedTable.bottom();
- int rightCell = loadedTable.right();
- qreal accRowSpacing = bottomCell * cellSpacing.height();
- qreal accColumnSpacing = rightCell * cellSpacing.width();
- averageEdgeSize.setHeight((loadedTableOuterRect.bottom() - accRowSpacing) / (bottomCell + 1));
- averageEdgeSize.setWidth((loadedTableOuterRect.right() - accColumnSpacing) / (rightCell + 1));
+ const int loadedRowCount = loadedRows.count();
+ const int loadedColumnCount = loadedColumns.count();
+ const qreal accRowSpacing = (loadedRowCount - 1) * cellSpacing.height();
+ const qreal accColumnSpacing = (loadedColumnCount - 1) * cellSpacing.width();
+ averageEdgeSize.setHeight((loadedTableOuterRect.height() - accRowSpacing) / loadedRowCount);
+ averageEdgeSize.setWidth((loadedTableOuterRect.width() - accColumnSpacing) / loadedColumnCount);
}
void QQuickTableViewPrivate::syncLoadedTableRectFromLoadedTable()
{
- QRectF topLeftRect = loadedTableItem(loadedTable.topLeft())->geometry();
- QRectF bottomRightRect = loadedTableItem(loadedTable.bottomRight())->geometry();
- loadedTableOuterRect = topLeftRect.united(bottomRightRect);
+ const QPoint topLeft = QPoint(leftColumn(), topRow());
+ const QPoint bottomRight = QPoint(rightColumn(), bottomRow());
+ QRectF topLeftRect = loadedTableItem(topLeft)->geometry();
+ QRectF bottomRightRect = loadedTableItem(bottomRight)->geometry();
+ loadedTableOuterRect = QRectF(topLeftRect.topLeft(), bottomRightRect.bottomRight());
loadedTableInnerRect = QRectF(topLeftRect.bottomRight(), bottomRightRect.topLeft());
}
+void QQuickTableViewPrivate::forceLayout()
+{
+ columnRowPositionsInvalid = true;
+ clearEdgeSizeCache();
+ RebuildOptions rebuildOptions = RebuildOption::None;
+
+ // Go through all columns from first to last, find the columns that used
+ // to be hidden and not loaded, and check if they should become visible
+ // (and vice versa). If there is a change, we need to rebuild.
+ for (int column = leftColumn(); column <= rightColumn(); ++column) {
+ const bool wasVisibleFromBefore = loadedColumns.contains(column);
+ const bool isVisibleNow = !qFuzzyIsNull(getColumnWidth(column));
+ if (wasVisibleFromBefore == isVisibleNow)
+ continue;
+
+ // A column changed visibility. This means that it should
+ // either be loaded or unloaded. So we need a rebuild.
+ qCDebug(lcTableViewDelegateLifecycle) << "Column" << column << "changed visibility to" << isVisibleNow;
+ rebuildOptions.setFlag(RebuildOption::ViewportOnly);
+ if (column == leftColumn()) {
+ // The first loaded column should now be hidden. This means that we
+ // need to calculate which column should now be first instead.
+ rebuildOptions.setFlag(RebuildOption::CalculateNewTopLeftColumn);
+ }
+ break;
+ }
+
+ // Go through all rows from first to last, and do the same as above
+ for (int row = topRow(); row <= bottomRow(); ++row) {
+ const bool wasVisibleFromBefore = loadedRows.contains(row);
+ const bool isVisibleNow = !qFuzzyIsNull(getRowHeight(row));
+ if (wasVisibleFromBefore == isVisibleNow)
+ continue;
+
+ // A row changed visibility. This means that it should
+ // either be loaded or unloaded. So we need a rebuild.
+ qCDebug(lcTableViewDelegateLifecycle) << "Row" << row << "changed visibility to" << isVisibleNow;
+ rebuildOptions.setFlag(RebuildOption::ViewportOnly);
+ if (row == topRow())
+ rebuildOptions.setFlag(RebuildOption::CalculateNewTopLeftRow);
+ break;
+ }
+
+ if (rebuildOptions)
+ scheduleRebuildTable(rebuildOptions);
+
+ if (polishing) {
+ qWarning() << "TableView::forceLayout(): Cannot do an immediate re-layout during an ongoing layout!";
+ q_func()->polish();
+ return;
+ }
+
+ updatePolish();
+}
+
void QQuickTableViewPrivate::syncLoadedTableFromLoadRequest()
{
if (loadRequest.edge() == Qt::Edge(0)) {
// No edge means we're loading the top-left item
- loadedTable = QRect(loadRequest.firstCell(), loadRequest.lastCell());
+ loadedColumns.insert(loadRequest.column(), 0);
+ loadedRows.insert(loadRequest.row(), 0);
return;
}
switch (loadRequest.edge()) {
case Qt::LeftEdge:
- case Qt::TopEdge:
- loadedTable.setTopLeft(loadRequest.firstCell());
- break;
case Qt::RightEdge:
+ loadedColumns.insert(loadRequest.column(), 0);
+ break;
+ case Qt::TopEdge:
case Qt::BottomEdge:
- loadedTable.setBottomRight(loadRequest.lastCell());
+ loadedRows.insert(loadRequest.row(), 0);
break;
}
}
-FxTableItem *QQuickTableViewPrivate::itemNextTo(const FxTableItem *fxTableItem, const QPoint &direction) const
-{
- return loadedTableItem(fxTableItem->cell + direction);
-}
-
FxTableItem *QQuickTableViewPrivate::loadedTableItem(const QPoint &cell) const
{
const int modelIndex = modelIndexAtCell(cell);
@@ -762,39 +911,16 @@ void QQuickTableViewPrivate::unloadItem(const QPoint &cell)
releaseItem(loadedItems.take(modelIndex), reusableFlag);
}
-void QQuickTableViewPrivate::unloadItems(const QLine &items)
-{
- qCDebug(lcTableViewDelegateLifecycle) << items;
-
- if (items.dx()) {
- int y = items.p1().y();
- for (int x = items.p1().x(); x <= items.p2().x(); ++x)
- unloadItem(QPoint(x, y));
- } else {
- int x = items.p1().x();
- for (int y = items.p1().y(); y <= items.p2().y(); ++y)
- unloadItem(QPoint(x, y));
- }
-}
-
bool QQuickTableViewPrivate::canLoadTableEdge(Qt::Edge tableEdge, const QRectF fillRect) const
{
switch (tableEdge) {
case Qt::LeftEdge:
- if (loadedTable.topLeft().x() == 0)
- return false;
return loadedTableOuterRect.left() > fillRect.left() + cellSpacing.width();
case Qt::RightEdge:
- if (loadedTable.bottomRight().x() >= tableSize.width() - 1)
- return false;
return loadedTableOuterRect.right() < fillRect.right() - cellSpacing.width();
case Qt::TopEdge:
- if (loadedTable.topLeft().y() == 0)
- return false;
return loadedTableOuterRect.top() > fillRect.top() + cellSpacing.height();
case Qt::BottomEdge:
- if (loadedTable.bottomRight().y() >= tableSize.height() - 1)
- return false;
return loadedTableOuterRect.bottom() < fillRect.bottom() - cellSpacing.height();
}
@@ -807,19 +933,19 @@ bool QQuickTableViewPrivate::canUnloadTableEdge(Qt::Edge tableEdge, const QRectF
// they are needed as anchor point for further layouting.
switch (tableEdge) {
case Qt::LeftEdge:
- if (loadedTable.width() <= 1)
+ if (loadedColumns.count() <= 1)
return false;
return loadedTableInnerRect.left() <= fillRect.left();
case Qt::RightEdge:
- if (loadedTable.width() <= 1)
+ if (loadedColumns.count() <= 1)
return false;
return loadedTableInnerRect.right() >= fillRect.right();
case Qt::TopEdge:
- if (loadedTable.height() <= 1)
+ if (loadedRows.count() <= 1)
return false;
return loadedTableInnerRect.top() <= fillRect.top();
case Qt::BottomEdge:
- if (loadedTable.height() <= 1)
+ if (loadedRows.count() <= 1)
return false;
return loadedTableInnerRect.bottom() >= fillRect.bottom();
}
@@ -830,9 +956,14 @@ bool QQuickTableViewPrivate::canUnloadTableEdge(Qt::Edge tableEdge, const QRectF
Qt::Edge QQuickTableViewPrivate::nextEdgeToLoad(const QRectF rect)
{
for (Qt::Edge edge : allTableEdges) {
- if (canLoadTableEdge(edge, rect))
- return edge;
+ if (!canLoadTableEdge(edge, rect))
+ continue;
+ const int nextIndex = nextVisibleEdgeIndexAroundLoadedTable(edge);
+ if (nextIndex == kEdgeIndexAtEnd)
+ continue;
+ return edge;
}
+
return Qt::Edge(0);
}
@@ -865,8 +996,10 @@ qreal QQuickTableViewPrivate::sizeHintForColumn(int column)
{
// Find the widest cell in the column, and return its width
qreal columnWidth = 0;
- for (int row = loadedTable.top(); row <= loadedTable.bottom(); ++row)
+ for (auto r = loadedRows.cbegin(); r != loadedRows.cend(); ++r) {
+ const int row = r.key();
columnWidth = qMax(columnWidth, cellWidth(QPoint(column, row)));
+ }
return columnWidth;
}
@@ -875,8 +1008,10 @@ qreal QQuickTableViewPrivate::sizeHintForRow(int row)
{
// Find the highest cell in the row, and return its height
qreal rowHeight = 0;
- for (int column = loadedTable.left(); column <= loadedTable.right(); ++column)
+ for (auto c = loadedColumns.cbegin(); c != loadedColumns.cend(); ++c) {
+ const int column = c.key();
rowHeight = qMax(rowHeight, cellHeight(QPoint(column, row)));
+ }
return rowHeight;
}
@@ -901,102 +1036,152 @@ void QQuickTableViewPrivate::calculateTableSize()
emit q->rowsChanged();
}
-qreal QQuickTableViewPrivate::resolveColumnWidth(int column)
-{
- Q_TABLEVIEW_ASSERT(column >= loadedTable.left() && column <= loadedTable.right(), column);
- qreal columnWidth = -1;
+qreal QQuickTableViewPrivate::getColumnLayoutWidth(int column)
+{
+ // Return the column width specified by the application, or go
+ // through the loaded items and calculate it as a fallback. For
+ // layouting, the width can never be zero (or negative), as this
+ // can lead us to be stuck in an infinite loop trying to load and
+ // fill out the empty viewport space with empty columns.
+ const qreal explicitColumnWidth = getColumnWidth(column);
+ if (explicitColumnWidth >= 0)
+ return explicitColumnWidth;
+
+ // Iterate over the currently visible items in the column. The downside
+ // of doing that, is that the column width will then only be based on the implicit
+ // width of the currently loaded items (which can be different depending on which
+ // row you're at when the column is flicked in). The upshot is that you don't have to
+ // bother setting columnWidthProvider for small tables, or if the implicit width doesn't vary.
+ qreal columnWidth = sizeHintForColumn(column);
+
+ if (qIsNaN(columnWidth) || columnWidth <= 0) {
+ if (!layoutWarningIssued) {
+ layoutWarningIssued = true;
+ qmlWarning(q_func()) << "the delegate's implicitHeight needs to be greater than zero";
+ }
+ columnWidth = kDefaultRowHeight;
+ }
- if (!columnWidthProvider.isUndefined()) {
- if (columnWidthProvider.isCallable()) {
- auto const columnAsArgument = QJSValueList() << QJSValue(column);
- columnWidth = columnWidthProvider.call(columnAsArgument).toNumber();
- if (qIsNaN(columnWidth) || columnWidth <= 0) {
- // The column width needs to be greater than 0, otherwise we never reach the edge
- // while loading/refilling columns. This would cause the application to hang.
- if (!layoutWarningIssued) {
- layoutWarningIssued = true;
- qmlWarning(q_func()) << "columnWidthProvider did not return a valid width for column: " << column;
- }
- columnWidth = kDefaultColumnWidth;
- }
- } else {
- if (!layoutWarningIssued) {
- layoutWarningIssued = true;
- qmlWarning(q_func()) << "columnWidthProvider doesn't contain a function";
- }
- columnWidth = kDefaultColumnWidth;
+ return columnWidth;
+}
+
+qreal QQuickTableViewPrivate::getRowLayoutHeight(int row)
+{
+ // Return the row height specified by the application, or go
+ // through the loaded items and calculate it as a fallback. For
+ // layouting, the height can never be zero (or negative), as this
+ // can lead us to be stuck in an infinite loop trying to load and
+ // fill out the empty viewport space with empty rows.
+ const qreal explicitRowHeight = getRowHeight(row);
+ if (explicitRowHeight >= 0)
+ return explicitRowHeight;
+
+ // Iterate over the currently visible items in the row. The downside
+ // of doing that, is that the row height will then only be based on the implicit
+ // height of the currently loaded items (which can be different depending on which
+ // column you're at when the row is flicked in). The upshot is that you don't have to
+ // bother setting rowHeightProvider for small tables, or if the implicit height doesn't vary.
+ qreal rowHeight = sizeHintForRow(row);
+
+ if (qIsNaN(rowHeight) || rowHeight <= 0) {
+ if (!layoutWarningIssued) {
+ layoutWarningIssued = true;
+ qmlWarning(q_func()) << "the delegate's implicitHeight needs to be greater than zero";
}
+ rowHeight = kDefaultRowHeight;
+ }
+
+ return rowHeight;
+}
+
+qreal QQuickTableViewPrivate::getColumnWidth(int column)
+{
+ // Return the width of the given column, if explicitly set. Return 0 if the column
+ // is hidden, and -1 if the width is not set (which means that the width should
+ // instead be calculated from the implicit size of the delegate items. This function
+ // can be overridden by e.g HeaderView to provide the column widths by other means.
+ const int noExplicitColumnWidth = -1;
+
+ if (cachedColumnWidth.startIndex == column)
+ return cachedColumnWidth.size;
+
+ if (columnWidthProvider.isUndefined())
+ return noExplicitColumnWidth;
+
+ qreal columnWidth = noExplicitColumnWidth;
+
+ if (columnWidthProvider.isCallable()) {
+ auto const columnAsArgument = QJSValueList() << QJSValue(column);
+ columnWidth = columnWidthProvider.call(columnAsArgument).toNumber();
+ if (qIsNaN(columnWidth) || columnWidth < 0)
+ columnWidth = noExplicitColumnWidth;
} else {
- // If columnWidthProvider is left unspecified, we just iterate over the currently visible items in
- // the column. The downside of doing that, is that the column width will then only be based
- // on the implicit width of the currently loaded items (which can be different depending on
- // which row you're at when the column is flicked in). The upshot is that you don't have to
- // bother setting columnWidthProvider for small tables, or if the implicit width doesn't vary.
- columnWidth = sizeHintForColumn(column);
- if (qIsNaN(columnWidth) || columnWidth <= 0) {
- // The column width needs to be greater than 0, otherwise we never reach the edge
- // while loading/refilling columns. This would cause the application to hang.
- if (!layoutWarningIssued) {
- layoutWarningIssued = true;
- qmlWarning(q_func()) << "the delegate's implicitWidth needs to be greater than zero";
- }
- columnWidth = kDefaultColumnWidth;
+ if (!layoutWarningIssued) {
+ layoutWarningIssued = true;
+ qmlWarning(q_func()) << "columnWidthProvider doesn't contain a function";
}
+ columnWidth = noExplicitColumnWidth;
}
+ cachedColumnWidth.startIndex = column;
+ cachedColumnWidth.size = columnWidth;
return columnWidth;
}
-qreal QQuickTableViewPrivate::resolveRowHeight(int row)
+qreal QQuickTableViewPrivate::getRowHeight(int row)
{
- Q_TABLEVIEW_ASSERT(row >= loadedTable.top() && row <= loadedTable.bottom(), row);
- qreal rowHeight = -1;
+ // Return the height of the given row, if explicitly set. Return 0 if the row
+ // is hidden, and -1 if the height is not set (which means that the height should
+ // instead be calculated from the implicit size of the delegate items. This function
+ // can be overridden by e.g HeaderView to provide the row heights by other means.
+ const int noExplicitRowHeight = -1;
- if (!rowHeightProvider.isUndefined()) {
- if (rowHeightProvider.isCallable()) {
- auto const rowAsArgument = QJSValueList() << QJSValue(row);
- rowHeight = rowHeightProvider.call(rowAsArgument).toNumber();
- if (qIsNaN(rowHeight) || rowHeight <= 0) {
- // The row height needs to be greater than 0, otherwise we never reach the edge
- // while loading/refilling rows. This would cause the application to hang.
- if (!layoutWarningIssued) {
- layoutWarningIssued = true;
- qmlWarning(q_func()) << "rowHeightProvider did not return a valid height for row: " << row;
- }
- rowHeight = kDefaultRowHeight;
- }
- } else {
- if (!layoutWarningIssued) {
- layoutWarningIssued = true;
- qmlWarning(q_func()) << "rowHeightProvider doesn't contain a function";
- }
- rowHeight = kDefaultRowHeight;
- }
+ if (cachedRowHeight.startIndex == row)
+ return cachedRowHeight.size;
+
+ if (rowHeightProvider.isUndefined())
+ return noExplicitRowHeight;
+
+ qreal rowHeight = noExplicitRowHeight;
+
+ if (rowHeightProvider.isCallable()) {
+ auto const rowAsArgument = QJSValueList() << QJSValue(row);
+ rowHeight = rowHeightProvider.call(rowAsArgument).toNumber();
+ if (qIsNaN(rowHeight) || rowHeight < 0)
+ rowHeight = noExplicitRowHeight;
} else {
- // If rowHeightProvider is left unspecified, we just iterate over the currently visible items in
- // the row. The downside of doing that, is that the row height will then only be based
- // on the implicit height of the currently loaded items (which can be different depending on
- // which column you're at when the row is flicked in). The upshot is that you don't have to
- // bother setting rowHeightProvider for small tables, or if the implicit height doesn't vary.
- rowHeight = sizeHintForRow(row);
- if (qIsNaN(rowHeight) || rowHeight <= 0) {
- if (!layoutWarningIssued) {
- layoutWarningIssued = true;
- qmlWarning(q_func()) << "the delegate's implicitHeight needs to be greater than zero";
- }
- rowHeight = kDefaultRowHeight;
+ if (!layoutWarningIssued) {
+ layoutWarningIssued = true;
+ qmlWarning(q_func()) << "rowHeightProvider doesn't contain a function";
}
+ rowHeight = noExplicitRowHeight;
}
+ cachedRowHeight.startIndex = row;
+ cachedRowHeight.size = rowHeight;
return rowHeight;
}
+bool QQuickTableViewPrivate::isColumnHidden(int column)
+{
+ // A column is hidden if the width is explicit set to zero (either by
+ // using a columnWidthProvider, or by overriding getColumnWidth()).
+ return qFuzzyIsNull(getColumnWidth(column));
+}
+
+bool QQuickTableViewPrivate::isRowHidden(int row)
+{
+ // A row is hidden if the height is explicit set to zero (either by
+ // using a rowHeightProvider, or by overriding getRowHeight()).
+ return qFuzzyIsNull(getRowHeight(row));
+}
+
void QQuickTableViewPrivate::relayoutTable()
{
+ clearEdgeSizeCache();
relayoutTableItems();
syncLoadedTableRectFromLoadedTable();
enforceTableAtOrigin();
- contentSizeBenchMarkPoint = QPoint(-1, -1);
updateContentWidth();
updateContentHeight();
// Return back to updatePolish to loadAndUnloadVisibleEdges()
@@ -1012,11 +1197,13 @@ void QQuickTableViewPrivate::relayoutTableItems()
qreal nextColumnX = loadedTableOuterRect.x();
qreal nextRowY = loadedTableOuterRect.y();
- for (int column = loadedTable.left(); column <= loadedTable.right(); ++column) {
+ for (auto c = loadedColumns.cbegin(); c != loadedColumns.cend(); ++c) {
+ const int column = c.key();
// Adjust the geometry of all cells in the current column
- const qreal width = resolveColumnWidth(column);
+ const qreal width = getColumnLayoutWidth(column);
- for (int row = loadedTable.top(); row <= loadedTable.bottom(); ++row) {
+ for (auto r = loadedRows.cbegin(); r != loadedRows.cend(); ++r) {
+ const int row = r.key();
auto item = loadedTableItem(QPoint(column, row));
QRectF geometry = item->geometry();
geometry.moveLeft(nextColumnX);
@@ -1024,14 +1211,17 @@ void QQuickTableViewPrivate::relayoutTableItems()
item->setGeometry(geometry);
}
- nextColumnX += width + cellSpacing.width();
+ if (width > 0)
+ nextColumnX += width + cellSpacing.width();
}
- for (int row = loadedTable.top(); row <= loadedTable.bottom(); ++row) {
+ for (auto r = loadedRows.cbegin(); r != loadedRows.cend(); ++r) {
+ const int row = r.key();
// Adjust the geometry of all cells in the current row
- const qreal height = resolveRowHeight(row);
+ const qreal height = getRowLayoutHeight(row);
- for (int column = loadedTable.left(); column <= loadedTable.right(); ++column) {
+ for (auto c = loadedColumns.cbegin(); c != loadedColumns.cend(); ++c) {
+ const int column = c.key();
auto item = loadedTableItem(QPoint(column, row));
QRectF geometry = item->geometry();
geometry.moveTop(nextRowY);
@@ -1039,12 +1229,15 @@ void QQuickTableViewPrivate::relayoutTableItems()
item->setGeometry(geometry);
}
- nextRowY += height + cellSpacing.height();
+ if (height > 0)
+ nextRowY += height + cellSpacing.height();
}
if (Q_UNLIKELY(lcTableViewDelegateLifecycle().isDebugEnabled())) {
- for (int column = loadedTable.left(); column <= loadedTable.right(); ++column) {
- for (int row = loadedTable.top(); row <= loadedTable.bottom(); ++row) {
+ for (auto c = loadedColumns.cbegin(); c != loadedColumns.cend(); ++c) {
+ const int column = c.key();
+ for (auto r = loadedRows.cbegin(); r != loadedRows.cend(); ++r) {
+ const int row = r.key();
QPoint cell = QPoint(column, row);
qCDebug(lcTableViewDelegateLifecycle()) << "relayout item:" << cell << loadedTableItem(cell)->geometry();
}
@@ -1054,66 +1247,82 @@ void QQuickTableViewPrivate::relayoutTableItems()
void QQuickTableViewPrivate::layoutVerticalEdge(Qt::Edge tableEdge)
{
- int column = (tableEdge == Qt::LeftEdge) ? loadedTable.left() : loadedTable.right();
- QPoint neighbourDirection = (tableEdge == Qt::LeftEdge) ? kRight : kLeft;
- qreal width = resolveColumnWidth(column);
-
- for (int row = loadedTable.top(); row <= loadedTable.bottom(); ++row) {
- auto fxTableItem = loadedTableItem(QPoint(column, row));
- auto const neighbourItem = itemNextTo(fxTableItem, neighbourDirection);
-
- QRectF geometry = fxTableItem->geometry();
- geometry.setWidth(width);
- geometry.setHeight(neighbourItem->geometry().height());
- qreal left = tableEdge == Qt::LeftEdge ?
- neighbourItem->geometry().left() - cellSpacing.width() - geometry.width() :
- neighbourItem->geometry().right() + cellSpacing.width();
+ int columnThatNeedsLayout;
+ int neighbourColumn;
+ qreal columnX;
+ qreal columnWidth;
+
+ if (tableEdge == Qt::LeftEdge) {
+ columnThatNeedsLayout = leftColumn();
+ neighbourColumn = loadedColumns.keys().value(1);
+ columnWidth = getColumnLayoutWidth(columnThatNeedsLayout);
+ const auto neighbourItem = loadedTableItem(QPoint(neighbourColumn, topRow()));
+ columnX = neighbourItem->geometry().left() - cellSpacing.width() - columnWidth;
+ } else {
+ columnThatNeedsLayout = rightColumn();
+ neighbourColumn = loadedColumns.keys().value(loadedColumns.count() - 2);
+ columnWidth = getColumnLayoutWidth(columnThatNeedsLayout);
+ const auto neighbourItem = loadedTableItem(QPoint(neighbourColumn, topRow()));
+ columnX = neighbourItem->geometry().right() + cellSpacing.width();
+ }
- geometry.moveLeft(left);
- geometry.moveTop(neighbourItem->geometry().top());
+ for (auto r = loadedRows.cbegin(); r != loadedRows.cend(); ++r) {
+ const int row = r.key();
+ auto fxTableItem = loadedTableItem(QPoint(columnThatNeedsLayout, row));
+ auto const neighbourItem = loadedTableItem(QPoint(neighbourColumn, row));
+ const qreal rowY = neighbourItem->geometry().y();
+ const qreal rowHeight = neighbourItem->geometry().height();
- fxTableItem->setGeometry(geometry);
+ fxTableItem->setGeometry(QRectF(columnX, rowY, columnWidth, rowHeight));
fxTableItem->setVisible(true);
- qCDebug(lcTableViewDelegateLifecycle()) << "layout item:" << QPoint(column, row) << fxTableItem->geometry();
+ qCDebug(lcTableViewDelegateLifecycle()) << "layout item:" << QPoint(columnThatNeedsLayout, row) << fxTableItem->geometry();
}
}
void QQuickTableViewPrivate::layoutHorizontalEdge(Qt::Edge tableEdge)
{
- int row = (tableEdge == Qt::TopEdge) ? loadedTable.top() : loadedTable.bottom();
- QPoint neighbourDirection = (tableEdge == Qt::TopEdge) ? kDown : kUp;
- qreal height = resolveRowHeight(row);
-
- for (int column = loadedTable.left(); column <= loadedTable.right(); ++column) {
- auto fxTableItem = loadedTableItem(QPoint(column, row));
- auto const neighbourItem = itemNextTo(fxTableItem, neighbourDirection);
-
- QRectF geometry = fxTableItem->geometry();
- geometry.setWidth(neighbourItem->geometry().width());
- geometry.setHeight(height);
- qreal top = tableEdge == Qt::TopEdge ?
- neighbourItem->geometry().top() - cellSpacing.height() - geometry.height() :
- neighbourItem->geometry().bottom() + cellSpacing.height();
+ int rowThatNeedsLayout;
+ int neighbourRow;
+ qreal rowY;
+ qreal rowHeight;
+
+ if (tableEdge == Qt::TopEdge) {
+ rowThatNeedsLayout = topRow();
+ neighbourRow = loadedRows.keys().value(1);
+ rowHeight = getRowLayoutHeight(rowThatNeedsLayout);
+ const auto neighbourItem = loadedTableItem(QPoint(leftColumn(), neighbourRow));
+ rowY = neighbourItem->geometry().top() - cellSpacing.height() - rowHeight;
+ } else {
+ rowThatNeedsLayout = bottomRow();
+ neighbourRow = loadedRows.keys().value(loadedRows.count() - 2);
+ rowHeight = getRowLayoutHeight(rowThatNeedsLayout);
+ const auto neighbourItem = loadedTableItem(QPoint(leftColumn(), neighbourRow));
+ rowY = neighbourItem->geometry().bottom() + cellSpacing.height();
+ }
- geometry.moveTop(top);
- geometry.moveLeft(neighbourItem->geometry().left());
+ for (auto c = loadedColumns.cbegin(); c != loadedColumns.cend(); ++c) {
+ const int column = c.key();
+ auto fxTableItem = loadedTableItem(QPoint(column, rowThatNeedsLayout));
+ auto const neighbourItem = loadedTableItem(QPoint(column, neighbourRow));
+ const qreal columnX = neighbourItem->geometry().x();
+ const qreal columnWidth = neighbourItem->geometry().width();
- fxTableItem->setGeometry(geometry);
+ fxTableItem->setGeometry(QRectF(columnX, rowY, columnWidth, rowHeight));
fxTableItem->setVisible(true);
- qCDebug(lcTableViewDelegateLifecycle()) << "layout item:" << QPoint(column, row) << fxTableItem->geometry();
+ qCDebug(lcTableViewDelegateLifecycle()) << "layout item:" << QPoint(column, rowThatNeedsLayout) << fxTableItem->geometry();
}
}
void QQuickTableViewPrivate::layoutTopLeftItem()
{
- const QPoint cell = loadRequest.firstCell();
+ const QPoint cell(loadRequest.column(), loadRequest.row());
auto topLeftItem = loadedTableItem(cell);
auto item = topLeftItem->item;
item->setPosition(loadRequest.startPosition());
- item->setSize(QSizeF(resolveColumnWidth(cell.x()), resolveRowHeight(cell.y())));
+ item->setSize(QSizeF(getColumnLayoutWidth(cell.x()), getRowLayoutHeight(cell.y())));
topLeftItem->setVisible(true);
qCDebug(lcTableViewDelegateLifecycle) << "geometry:" << topLeftItem->geometry();
}
@@ -1138,29 +1347,6 @@ void QQuickTableViewPrivate::layoutTableEdgeFromLoadRequest()
}
}
-void QQuickTableViewPrivate::cancelLoadRequest()
-{
- loadRequest.markAsDone();
- model->cancel(modelIndexAtCell(loadRequest.currentCell()));
-
- if (rebuildScheduled) {
- // No reason to rollback already loaded edge items
- // since we anyway are about to reload all items.
- return;
- }
-
- if (loadRequest.atBeginning()) {
- // No items have yet been loaded, so nothing to unload
- return;
- }
-
- QLine rollbackItems;
- rollbackItems.setP1(loadRequest.firstCell());
- rollbackItems.setP2(loadRequest.previousCell());
- qCDebug(lcTableViewDelegateLifecycle()) << "rollback:" << rollbackItems << tableLayoutToString();
- unloadItems(rollbackItems);
-}
-
void QQuickTableViewPrivate::processLoadRequest()
{
Q_TABLEVIEW_ASSERT(loadRequest.isActive(), "");
@@ -1186,9 +1372,22 @@ void QQuickTableViewPrivate::processLoadRequest()
syncLoadedTableRectFromLoadedTable();
if (rebuildState == RebuildState::Done) {
- enforceTableAtOrigin();
- updateContentWidth();
- updateContentHeight();
+ // Loading of this edge was not done as a part of a rebuild, but
+ // instead as an incremental build after e.g a flick.
+ switch (loadRequest.edge()) {
+ case Qt::LeftEdge:
+ case Qt::TopEdge:
+ enforceTableAtOrigin();
+ break;
+ case Qt::RightEdge:
+ updateAverageEdgeSize();
+ updateContentWidth();
+ break;
+ case Qt::BottomEdge:
+ updateAverageEdgeSize();
+ updateContentHeight();
+ break;
+ }
drainReusePoolAfterLoadRequest();
}
@@ -1209,7 +1408,7 @@ void QQuickTableViewPrivate::processRebuildTable()
if (rebuildState == RebuildState::VerifyTable) {
if (loadedItems.isEmpty()) {
- qCDebug(lcTableViewDelegateLifecycle()) << "no items loaded, meaning empty model or no delegate";
+ qCDebug(lcTableViewDelegateLifecycle()) << "no items loaded, meaning empty model, all rows or columns hidden, or no delegate";
rebuildState = RebuildState::Done;
return;
}
@@ -1233,14 +1432,14 @@ void QQuickTableViewPrivate::processRebuildTable()
&& reusableFlag == QQmlTableInstanceModel::Reusable);
if (rebuildState == RebuildState::PreloadColumns) {
- if (preload && loadedTable.right() < tableSize.width() - 1)
+ if (preload && nextVisibleEdgeIndexAroundLoadedTable(Qt::RightEdge) != kEdgeIndexAtEnd)
loadEdge(Qt::RightEdge, QQmlIncubator::AsynchronousIfNested);
if (!moveToNextRebuildState())
return;
}
if (rebuildState == RebuildState::PreloadRows) {
- if (preload && loadedTable.bottom() < tableSize.height() - 1)
+ if (preload && nextVisibleEdgeIndexAroundLoadedTable(Qt::BottomEdge) != kEdgeIndexAtEnd)
loadEdge(Qt::BottomEdge, QQmlIncubator::AsynchronousIfNested);
if (!moveToNextRebuildState())
return;
@@ -1268,19 +1467,26 @@ bool QQuickTableViewPrivate::moveToNextRebuildState()
return true;
}
-void QQuickTableViewPrivate::beginRebuildTable()
+QPoint QQuickTableViewPrivate::calculateNewTopLeft()
{
- if (loadRequest.isActive())
- cancelLoadRequest();
+ const int firstVisibleLeft = nextVisibleEdgeIndex(Qt::RightEdge, 0);
+ const int firstVisibleTop = nextVisibleEdgeIndex(Qt::BottomEdge, 0);
- calculateTableSize();
+ return QPoint(firstVisibleLeft, firstVisibleTop);
+}
- QPoint topLeft;
- QPointF topLeftPos;
+void QQuickTableViewPrivate::calculateTopLeft(QPoint &topLeft, QPointF &topLeftPos)
+{
+ if (tableSize.isEmpty()) {
+ releaseLoadedItems(QQmlTableInstanceModel::NotReusable);
+ topLeft = QPoint(kEdgeIndexAtEnd, kEdgeIndexAtEnd);
+ return;
+ }
if (rebuildOptions & RebuildOption::All) {
qCDebug(lcTableViewDelegateLifecycle()) << "RebuildOption::All";
releaseLoadedItems(QQmlTableInstanceModel::NotReusable);
+ topLeft = calculateNewTopLeft();
} else if (rebuildOptions & RebuildOption::ViewportOnly) {
qCDebug(lcTableViewDelegateLifecycle()) << "RebuildOption::ViewportOnly";
releaseLoadedItems(reusableFlag);
@@ -1290,7 +1496,7 @@ void QQuickTableViewPrivate::beginRebuildTable()
topLeft.ry() = qBound(0, newRow, tableSize.height() - 1);
topLeftPos.ry() = topLeft.y() * (averageEdgeSize.height() + cellSpacing.height());
} else {
- topLeft.ry() = qBound(0, loadedTable.topLeft().y(), tableSize.height() - 1);
+ topLeft.ry() = qBound(0, topRow(), tableSize.height() - 1);
topLeftPos.ry() = loadedTableOuterRect.topLeft().y();
}
if (rebuildOptions & RebuildOption::CalculateNewTopLeftColumn) {
@@ -1298,18 +1504,33 @@ void QQuickTableViewPrivate::beginRebuildTable()
topLeft.rx() = qBound(0, newColumn, tableSize.width() - 1);
topLeftPos.rx() = topLeft.x() * (averageEdgeSize.width() + cellSpacing.width());
} else {
- topLeft.rx() = qBound(0, loadedTable.topLeft().x(), tableSize.width() - 1);
+ topLeft.rx() = qBound(0, leftColumn(), tableSize.width() - 1);
topLeftPos.rx() = loadedTableOuterRect.topLeft().x();
}
} else {
Q_TABLEVIEW_UNREACHABLE(rebuildOptions);
}
+}
- loadedTable = QRect();
+void QQuickTableViewPrivate::beginRebuildTable()
+{
+ calculateTableSize();
+
+ QPoint topLeft;
+ QPointF topLeftPos;
+ calculateTopLeft(topLeft, topLeftPos);
+
+ loadedColumns.clear();
+ loadedRows.clear();
loadedTableOuterRect = QRect();
loadedTableInnerRect = QRect();
- contentSizeBenchMarkPoint = QPoint(-1, -1);
columnRowPositionsInvalid = false;
+ clearEdgeSizeCache();
+
+ if (topLeft.x() == kEdgeIndexAtEnd || topLeft.y() == kEdgeIndexAtEnd) {
+ // No visible columns or rows, so nothing to load
+ return;
+ }
loadInitialTopLeftItem(topLeft, topLeftPos);
loadAndUnloadVisibleEdges();
@@ -1335,12 +1556,6 @@ void QQuickTableViewPrivate::loadInitialTopLeftItem(const QPoint &cell, const QP
{
Q_TABLEVIEW_ASSERT(loadedItems.isEmpty(), "");
- if (tableSize.isEmpty())
- return;
-
- if (model->count() == 0)
- return;
-
if (tableModel && !tableModel->delegate())
return;
@@ -1352,16 +1567,42 @@ void QQuickTableViewPrivate::loadInitialTopLeftItem(const QPoint &cell, const QP
void QQuickTableViewPrivate::unloadEdge(Qt::Edge edge)
{
- unloadItems(rectangleEdge(loadedTable, edge));
- loadedTable = expandedRect(loadedTable, edge, -1);
- syncLoadedTableRectFromLoadedTable();
+ qCDebug(lcTableViewDelegateLifecycle) << edge;
+
+ switch (edge) {
+ case Qt::LeftEdge:
+ case Qt::RightEdge: {
+ const int column = edge == Qt::LeftEdge ? leftColumn() : rightColumn();
+ for (auto r = loadedRows.cbegin(); r != loadedRows.cend(); ++r)
+ unloadItem(QPoint(column, r.key()));
+ loadedColumns.remove(column);
+ syncLoadedTableRectFromLoadedTable();
+ updateAverageEdgeSize();
+ updateContentWidth();
+ break; }
+ case Qt::TopEdge:
+ case Qt::BottomEdge: {
+ const int row = edge == Qt::TopEdge ? topRow() : bottomRow();
+ for (auto c = loadedColumns.cbegin(); c != loadedColumns.cend(); ++c)
+ unloadItem(QPoint(c.key(), row));
+ loadedRows.remove(row);
+ syncLoadedTableRectFromLoadedTable();
+ updateAverageEdgeSize();
+ updateContentHeight();
+ break; }
+ }
+
qCDebug(lcTableViewDelegateLifecycle) << tableLayoutToString();
}
void QQuickTableViewPrivate::loadEdge(Qt::Edge edge, QQmlIncubator::IncubationMode incubationMode)
{
- QLine cellsToLoad = rectangleEdge(expandedRect(loadedTable, edge, 1), edge);
- loadRequest.begin(cellsToLoad, edge, incubationMode);
+ const int edgeIndex = nextVisibleEdgeIndexAroundLoadedTable(edge);
+ qCDebug(lcTableViewDelegateLifecycle) << edge << edgeIndex;
+
+ const QList<int> visibleCells = edge & (Qt::LeftEdge | Qt::RightEdge)
+ ? loadedRows.keys() : loadedColumns.keys();
+ loadRequest.begin(edge, edgeIndex, visibleCells, incubationMode);
processLoadRequest();
}
@@ -1447,8 +1688,8 @@ void QQuickTableViewPrivate::drainReusePoolAfterLoadRequest()
// in with varying sizes, causing some items not to be resued immediately), we multiply the
// value by 2. Note that we also add an extra +1 to the column count, because the number of
// visible columns will fluctuate between +1/-1 while flicking.
- const int w = loadedTable.width();
- const int h = loadedTable.height();
+ const int w = loadedColumns.count();
+ const int h = loadedRows.count();
const int minTime = int(std::ceil(w > h ? qreal(w + 1) / h : qreal(h + 1) / w));
const int maxTime = minTime * 2;
tableModel->drainReusableItemsPool(maxTime);
@@ -1502,8 +1743,12 @@ void QQuickTableViewPrivate::updatePolish()
if (loadedItems.isEmpty())
return;
- if (columnRowPositionsInvalid)
+ if (columnRowPositionsInvalid) {
relayoutTable();
+ updateAverageEdgeSize();
+ updateContentWidth();
+ updateContentHeight();
+ }
loadAndUnloadVisibleEdges();
}
@@ -1609,6 +1854,12 @@ void QQuickTableViewPrivate::syncRebuildOptions()
rebuildOptions = scheduledRebuildOptions;
scheduledRebuildOptions = RebuildOption::None;
rebuildScheduled = false;
+
+ if (loadedItems.isEmpty()) {
+ // If we have no items from before, we cannot just rebuild the viewport, but need
+ // to rebuild everything, since we have no top-left loaded item to start from.
+ rebuildOptions.setFlag(RebuildOption::All);
+ }
}
void QQuickTableViewPrivate::syncDelegate()
@@ -1787,6 +2038,16 @@ QQuickTableView::QQuickTableView(QQuickItem *parent)
setFlag(QQuickItem::ItemIsFocusScope);
}
+QQuickTableView::~QQuickTableView()
+{
+}
+
+QQuickTableView::QQuickTableView(QQuickTableViewPrivate &dd, QQuickItem *parent)
+ : QQuickFlickable(dd, parent)
+{
+ setFlag(QQuickItem::ItemIsFocusScope);
+}
+
int QQuickTableView::rows() const
{
return d_func()->tableSize.height();
@@ -1936,16 +2197,7 @@ void QQuickTableView::setContentHeight(qreal height)
void QQuickTableView::forceLayout()
{
- Q_D(QQuickTableView);
- d->columnRowPositionsInvalid = true;
-
- if (d->polishing) {
- qWarning() << "TableView::forceLayout(): Cannot do an immediate re-layout during an ongoing layout!";
- polish();
- return;
- }
-
- d->updatePolish();
+ d_func()->forceLayout();
}
QQuickTableViewAttached *QQuickTableView::qmlAttachedProperties(QObject *obj)
diff --git a/src/quick/items/qquicktableview_p.h b/src/quick/items/qquicktableview_p.h
index 86ee843c22..f32c71b983 100644
--- a/src/quick/items/qquicktableview_p.h
+++ b/src/quick/items/qquicktableview_p.h
@@ -82,7 +82,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTableView : public QQuickFlickable
public:
QQuickTableView(QQuickItem *parent = nullptr);
-
+ ~QQuickTableView() override;
int rows() const;
int columns() const;
@@ -98,8 +98,8 @@ public:
QJSValue columnWidthProvider() const;
void setColumnWidthProvider(QJSValue provider);
- QVariant model() const;
- void setModel(const QVariant &newModel);
+ virtual QVariant model() const;
+ virtual void setModel(const QVariant &newModel);
QQmlComponent *delegate() const;
void setDelegate(QQmlComponent *);
@@ -130,6 +130,9 @@ protected:
void viewportMoved(Qt::Orientations orientation) override;
void componentComplete() override;
+protected:
+ QQuickTableView(QQuickTableViewPrivate &dd, QQuickItem *parent);
+
private:
Q_DISABLE_COPY(QQuickTableView)
Q_DECLARE_PRIVATE(QQuickTableView)
diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h
index 8a02d23694..f2fef0d774 100644
--- a/src/quick/items/qquicktableview_p_p.h
+++ b/src/quick/items/qquicktableview_p_p.h
@@ -88,54 +88,52 @@ public:
public:
void begin(const QPoint &cell, const QPointF &pos, QQmlIncubator::IncubationMode incubationMode)
{
- Q_ASSERT(!active);
- active = true;
- tableEdge = Qt::Edge(0);
- tableCells = QLine(cell, cell);
- mode = incubationMode;
- cellCount = 1;
- currentIndex = 0;
- startPos = pos;
+ Q_ASSERT(!m_active);
+ m_active = true;
+ m_edge = Qt::Edge(0);
+ m_mode = incubationMode;
+ m_edgeIndex = cell.x();
+ m_visibleCellsInEdge.clear();
+ m_visibleCellsInEdge.append(cell.y());
+ m_currentIndex = 0;
+ m_startPos = pos;
qCDebug(lcTableViewDelegateLifecycle()) << "begin top-left:" << toString();
}
- void begin(const QLine cellsToLoad, Qt::Edge edgeToLoad, QQmlIncubator::IncubationMode incubationMode)
+ void begin(Qt::Edge edgeToLoad, int edgeIndex, const QList<int> visibleCellsInEdge, QQmlIncubator::IncubationMode incubationMode)
{
- Q_ASSERT(!active);
- active = true;
- tableEdge = edgeToLoad;
- tableCells = cellsToLoad;
- mode = incubationMode;
- cellCount = tableCells.x2() - tableCells.x1() + tableCells.y2() - tableCells.y1() + 1;
- currentIndex = 0;
+ Q_ASSERT(!m_active);
+ m_active = true;
+ m_edge = edgeToLoad;
+ m_edgeIndex = edgeIndex;
+ m_visibleCellsInEdge = visibleCellsInEdge;
+ m_mode = incubationMode;
+ m_currentIndex = 0;
qCDebug(lcTableViewDelegateLifecycle()) << "begin:" << toString();
}
- inline void markAsDone() { active = false; }
- inline bool isActive() { return active; }
+ inline void markAsDone() { m_active = false; }
+ inline bool isActive() { return m_active; }
- inline QPoint firstCell() { return tableCells.p1(); }
- inline QPoint lastCell() { return tableCells.p2(); }
- inline QPoint currentCell() { return cellAt(currentIndex); }
- inline QPoint previousCell() { return cellAt(currentIndex - 1); }
+ inline QPoint currentCell() { return cellAt(m_currentIndex); }
+ inline bool hasCurrentCell() { return m_currentIndex < m_visibleCellsInEdge.count(); }
+ inline void moveToNextCell() { ++m_currentIndex; }
- inline bool atBeginning() { return currentIndex == 0; }
- inline bool hasCurrentCell() { return currentIndex < cellCount; }
- inline void moveToNextCell() { ++currentIndex; }
+ inline Qt::Edge edge() { return m_edge; }
+ inline int row() { return cellAt(0).y(); }
+ inline int column() { return cellAt(0).x(); }
+ inline QQmlIncubator::IncubationMode incubationMode() { return m_mode; }
- inline Qt::Edge edge() { return tableEdge; }
- inline QQmlIncubator::IncubationMode incubationMode() { return mode; }
-
- inline QPointF startPosition() { return startPos; }
+ inline QPointF startPosition() { return m_startPos; }
QString toString()
{
QString str;
QDebug dbg(&str);
dbg.nospace() << "TableSectionLoadRequest(" << "edge:"
- << tableEdge << " cells:" << tableCells << " incubation:";
+ << m_edge << ", edgeIndex:" << m_edgeIndex << ", incubation:";
- switch (mode) {
+ switch (m_mode) {
case QQmlIncubator::Asynchronous:
dbg << "Asynchronous";
break;
@@ -151,22 +149,31 @@ public:
}
private:
- Qt::Edge tableEdge = Qt::Edge(0);
- QLine tableCells;
- int currentIndex = 0;
- int cellCount = 0;
- bool active = false;
- QQmlIncubator::IncubationMode mode = QQmlIncubator::AsynchronousIfNested;
- QPointF startPos;
-
- QPoint cellAt(int index)
- {
- int x = tableCells.p1().x() + (tableCells.dx() ? index : 0);
- int y = tableCells.p1().y() + (tableCells.dy() ? index : 0);
- return QPoint(x, y);
+ Qt::Edge m_edge = Qt::Edge(0);
+ QList<int> m_visibleCellsInEdge;
+ int m_edgeIndex = 0;
+ int m_currentIndex = 0;
+ bool m_active = false;
+ QQmlIncubator::IncubationMode m_mode = QQmlIncubator::AsynchronousIfNested;
+ QPointF m_startPos;
+
+ inline QPoint cellAt(int index) {
+ return !m_edge || (m_edge & (Qt::LeftEdge | Qt::RightEdge))
+ ? QPoint(m_edgeIndex, m_visibleCellsInEdge[index])
+ : QPoint(m_visibleCellsInEdge[index], m_edgeIndex);
}
};
+ class EdgeRange {
+ public:
+ EdgeRange();
+ bool containsIndex(Qt::Edge edge, int index);
+
+ int startIndex;
+ int endIndex;
+ qreal size;
+ };
+
enum class RebuildState {
Begin = 0,
LoadInitalTable,
@@ -213,13 +220,14 @@ public:
QVariant assignedModel = QVariant(int(0));
QQmlComponent *assignedDelegate = nullptr;
- // loadedTable describes the table cells that are currently loaded (from top left
+ // loadedRows/Columns describes the rows and columns that are currently loaded (from top left
// row/column to bottom right row/column). loadedTableOuterRect describes the actual
- // pixels that those cells cover, and is matched agains the viewport to determine when
+ // pixels that all the loaded delegate items cover, and is matched agains the viewport to determine when
// we need to fill up with more rows/columns. loadedTableInnerRect describes the pixels
// that the loaded table covers if you remove one row/column on each side of the table, and
// is used to determine rows/columns that are no longer visible and can be unloaded.
- QRect loadedTable;
+ QMap<int, int> loadedColumns;
+ QMap<int, int> loadedRows;
QRectF loadedTableOuterRect;
QRectF loadedTableInnerRect;
@@ -233,7 +241,6 @@ public:
TableEdgeLoadRequest loadRequest;
- QPoint contentSizeBenchMarkPoint = QPoint(-1, -1);
QSizeF cellSpacing = QSizeF(0, 0);
QQmlTableInstanceModel::ReusableFlag reusableFlag = QQmlTableInstanceModel::Reusable;
@@ -247,6 +254,10 @@ public:
QJSValue rowHeightProvider;
QJSValue columnWidthProvider;
+ EdgeRange cachedNextVisibleEdgeIndex[4];
+ EdgeRange cachedColumnWidth;
+ EdgeRange cachedRowHeight;
+
// TableView uses contentWidth/height to report the size of the table (this
// will e.g make scrollbars written for Flickable work out of the box). This
// value is continuously calculated, and will change/improve as more columns
@@ -280,8 +291,18 @@ public:
qreal sizeHintForRow(int row);
void calculateTableSize();
- qreal resolveColumnWidth(int column);
- qreal resolveRowHeight(int row);
+ inline bool isColumnHidden(int column);
+ inline bool isRowHidden(int row);
+
+ qreal getColumnLayoutWidth(int column);
+ qreal getRowLayoutHeight(int row);
+ qreal getColumnWidth(int column);
+ qreal getRowHeight(int row);
+
+ inline int topRow() const { return loadedRows.firstKey(); }
+ inline int bottomRow() const { return loadedRows.lastKey(); }
+ inline int leftColumn() const { return loadedColumns.firstKey(); }
+ inline int rightColumn() const { return loadedColumns.lastKey(); }
void relayoutTable();
void relayoutTableItems();
@@ -294,11 +315,17 @@ public:
void updateContentWidth();
void updateContentHeight();
void updateAverageEdgeSize();
+ void forceLayout();
void enforceTableAtOrigin();
void syncLoadedTableRectFromLoadedTable();
void syncLoadedTableFromLoadRequest();
+ int nextVisibleEdgeIndex(Qt::Edge edge, int startIndex);
+ int nextVisibleEdgeIndexAroundLoadedTable(Qt::Edge edge);
+ inline int edgeToArrayIndex(Qt::Edge edge);
+ void clearEdgeSizeCache();
+
bool canLoadTableEdge(Qt::Edge tableEdge, const QRectF fillRect) const;
bool canUnloadTableEdge(Qt::Edge tableEdge, const QRectF fillRect) const;
Qt::Edge nextEdgeToLoad(const QRectF rect);
@@ -308,7 +335,6 @@ public:
qreal cellHeight(const QPoint &cell);
FxTableItem *loadedTableItem(const QPoint &cell) const;
- FxTableItem *itemNextTo(const FxTableItem *fxTableItem, const QPoint &direction) const;
FxTableItem *createFxTableItem(const QPoint &cell, QQmlIncubator::IncubationMode incubationMode);
FxTableItem *loadFxTableItem(const QPoint &cell, QQmlIncubator::IncubationMode incubationMode);
@@ -316,18 +342,17 @@ public:
void releaseLoadedItems(QQmlTableInstanceModel::ReusableFlag reusableFlag);
void unloadItem(const QPoint &cell);
- void unloadItems(const QLine &items);
-
void loadInitialTopLeftItem(const QPoint &cell, const QPointF &pos);
void loadEdge(Qt::Edge edge, QQmlIncubator::IncubationMode incubationMode);
void unloadEdge(Qt::Edge edge);
void loadAndUnloadVisibleEdges();
void drainReusePoolAfterLoadRequest();
- void cancelLoadRequest();
void processLoadRequest();
void processRebuildTable();
bool moveToNextRebuildState();
+ QPoint calculateNewTopLeft();
+ void calculateTopLeft(QPoint &topLeft, QPointF &topLeftPos);
void beginRebuildTable();
void layoutAfterLoadingInitialTable();
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index 97cc33b95f..6d343a91ce 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -643,7 +643,7 @@ QString QQuickTextPrivate::elidedText(qreal lineWidth, const QTextLine &line, QT
// Appending the elide character may push the line over the maximum width
// in which case the elided text will need to be elided.
QFontMetricsF metrics(layout.font());
- if (metrics.width(elideChar) + line.naturalTextWidth() >= lineWidth)
+ if (metrics.horizontalAdvance(elideChar) + line.naturalTextWidth() >= lineWidth)
elideText = metrics.elidedText(elideText, Qt::TextElideMode(elideMode), lineWidth);
}
return elideText;
@@ -754,6 +754,7 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline)
bool once = true;
int elideStart = 0;
int elideEnd = 0;
+ bool noBreakLastLine = multilineElide && (wrapMode == QQuickText::Wrap || wrapMode == QQuickText::WordWrap);
int eos = multilengthEos;
@@ -786,11 +787,15 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline)
QRectF unelidedRect;
QTextLine line = layout.createLine();
for (visibleCount = 1; ; ++visibleCount) {
+ if (noBreakLastLine && visibleCount == maxLineCount)
+ layout.engine()->option.setWrapMode(QTextOption::WrapAnywhere);
if (customLayout) {
setupCustomLineGeometry(line, naturalHeight);
} else {
setLineGeometry(line, lineWidth, naturalHeight);
}
+ if (noBreakLastLine && visibleCount == maxLineCount)
+ layout.engine()->option.setWrapMode(QTextOption::WrapMode(wrapMode));
unelidedRect = br.united(line.naturalTextRect());
diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp
index 38ca7283b4..a7a90c9134 100644
--- a/src/quick/items/qquicktextcontrol.cpp
+++ b/src/quick/items/qquicktextcontrol.cpp
@@ -998,7 +998,7 @@ QRectF QQuickTextControlPrivate::rectForPosition(int position) const
if (relativePos < line.textLength() - line.textStart())
w = line.cursorToX(relativePos + 1) - x;
else
- w = QFontMetrics(block.layout()->font()).width(QLatin1Char(' ')); // in sync with QTextLine::draw()
+ w = QFontMetrics(block.layout()->font()).horizontalAdvance(QLatin1Char(' ')); // in sync with QTextLine::draw()
}
r = QRectF(layoutPos.x() + x, layoutPos.y() + line.y(), textCursorWidth + w, line.height());
} else {
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index 06a0fc396b..6b4b118eb7 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -1641,7 +1641,8 @@ bool QQuickTextEdit::event(QEvent *event)
Q_D(QQuickTextEdit);
if (event->type() == QEvent::ShortcutOverride) {
d->control->processEvent(event, QPointF(-d->xoff, -d->yoff));
- return event->isAccepted();
+ if (event->isAccepted())
+ return true;
}
return QQuickImplicitSizeItem::event(event);
}
@@ -2688,6 +2689,12 @@ void QQuickTextEditPrivate::handleFocusEvent(QFocusEvent *event)
q->disconnect(QGuiApplication::inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)),
q, SLOT(q_updateAlignment()));
#endif
+ if (event->reason() != Qt::ActiveWindowFocusReason
+ && event->reason() != Qt::PopupFocusReason
+ && control->textCursor().hasSelection()
+ && !persistentSelection)
+ q->deselect();
+
emit q->editingFinished();
}
}
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index aac7137ff3..5f6fd8f50f 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -877,7 +877,7 @@ QRectF QQuickTextInput::cursorRectangle() const
if (c < text().length())
w = l.cursorToX(c + 1) - x;
else
- w = QFontMetrics(font()).width(QLatin1Char(' ')); // in sync with QTextLine::draw()
+ w = QFontMetrics(font()).horizontalAdvance(QLatin1Char(' ')); // in sync with QTextLine::draw()
}
return QRectF(x, y, w, l.height());
}
@@ -1383,7 +1383,7 @@ QRectF QQuickTextInput::positionToRectangle(int pos) const
if (pos < text().length())
w = l.cursorToX(pos + 1) - x;
else
- w = QFontMetrics(font()).width(QLatin1Char(' ')); // in sync with QTextLine::draw()
+ w = QFontMetrics(font()).horizontalAdvance(QLatin1Char(' ')); // in sync with QTextLine::draw()
}
return QRectF(x, y, w, l.height());
}
diff --git a/src/quick/items/qquicktextnodeengine.cpp b/src/quick/items/qquicktextnodeengine.cpp
index 36fc168ec2..a1b5eb1faf 100644
--- a/src/quick/items/qquicktextnodeengine.cpp
+++ b/src/quick/items/qquicktextnodeengine.cpp
@@ -1011,8 +1011,8 @@ void QQuickTextNodeEngine::addTextBlock(QTextDocument *textDocument, const QText
break;
};
- QSizeF size(fontMetrics.width(listItemBullet), fontMetrics.height());
- qreal xoff = fontMetrics.width(QLatin1Char(' '));
+ QSizeF size(fontMetrics.horizontalAdvance(listItemBullet), fontMetrics.height());
+ qreal xoff = fontMetrics.horizontalAdvance(QLatin1Char(' '));
if (block.textDirection() == Qt::LeftToRight)
xoff = -xoff - size.width();
setPosition(pos + QPointF(xoff, 0));
@@ -1055,7 +1055,7 @@ void QQuickTextNodeEngine::addTextBlock(QTextDocument *textDocument, const QText
if (text.contains(QChar::ObjectReplacementCharacter)) {
QTextFrame *frame = qobject_cast<QTextFrame *>(textDocument->objectForFormat(charFormat));
- if (frame && frame->frameFormat().position() == QTextFrameFormat::InFlow) {
+ if (!frame || frame->frameFormat().position() == QTextFrameFormat::InFlow) {
int blockRelativePosition = textPos - block.position();
QTextLine line = block.layout()->lineForTextPosition(blockRelativePosition);
if (!currentLine().isValid()
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index c6bfcaa647..88d419e2b3 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -1643,6 +1643,14 @@ bool QQuickWindow::event(QEvent *e)
emit closing(&qev);
e->setAccepted(qev.isAccepted());
} break;
+ case QEvent::PlatformSurface:
+ if ((static_cast<QPlatformSurfaceEvent *>(e))->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed) {
+ // Ensure that the rendering thread is notified before
+ // the QPlatformWindow is destroyed.
+ if (d->windowManager)
+ d->windowManager->hide(this);
+ }
+ break;
case QEvent::FocusAboutToChange:
#if QT_CONFIG(im)
if (d->activeFocusItem)
@@ -4614,6 +4622,62 @@ void QQuickWindow::resetOpenGLState()
*/
/*!
+ \qmlproperty QWindow Window::transientParent
+ \since 5.13
+
+ The window for which this window is a transient pop-up.
+
+ This is a hint to the window manager that this window is a dialog or pop-up
+ on behalf of the transient parent. It usually means that the transient
+ window will be centered over its transient parent when it is initially
+ shown, that minimizing the parent window will also minimize the transient
+ window, and so on; however results vary somewhat from platform to platform.
+
+ Normally if you declare a Window inside an Item or inside another Window,
+ this relationship is deduced automatically. In that case, if you declare
+ this window's \l visible property \c true, it will not actually be shown
+ until the \c transientParent window is shown.
+
+ However if you set this property, then Qt Quick will no longer wait until
+ the \c transientParent window is shown before showing this window. If you
+ want to to be able to show a transient window independently of the "parent"
+ Item or Window within which it was declared, you can remove that
+ relationship by setting \c transientParent to \c null:
+
+ \qml
+ import QtQuick.Window 2.13
+
+ Window {
+ // visible is false by default
+ Window {
+ transientParent: null
+ visible: true
+ }
+ }
+ \endqml
+
+ In order to cause the window to be centered above its transient parent by
+ default, depending on the window manager, it may also be necessary to set
+ the \l Window::flags property with a suitable \l Qt::WindowType (such as
+ \c Qt::Dialog).
+*/
+
+/*!
+ \property QQuickWindow::transientParent
+ \brief The window for which this window is a transient pop-up.
+ \since 5.13
+
+ This is a hint to the window manager that this window is a dialog or pop-up
+ on behalf of the transient parent, which may be any kind of \l QWindow.
+
+ In order to cause the window to be centered above its transient parent by
+ default, depending on the window manager, it may also be necessary to set
+ the \l flags property with a suitable \l Qt::WindowType (such as \c Qt::Dialog).
+
+ \sa parent()
+ */
+
+/*!
\qmlproperty Item Window::activeFocusItem
\since 5.1
diff --git a/src/quick/items/qquickwindowmodule.cpp b/src/quick/items/qquickwindowmodule.cpp
index ab3f49d5b6..2b109c0897 100644
--- a/src/quick/items/qquickwindowmodule.cpp
+++ b/src/quick/items/qquickwindowmodule.cpp
@@ -124,7 +124,8 @@ void QQuickWindowQmlImpl::componentComplete()
Q_D(QQuickWindowQmlImpl);
d->complete = true;
QQuickItem *itemParent = qmlobject_cast<QQuickItem *>(QObject::parent());
- if (itemParent && !itemParent->window()) {
+ const bool transientParentAlreadySet = QQuickWindowPrivate::get(this)->transientParentPropertySet;
+ if (!transientParentAlreadySet && itemParent && !itemParent->window()) {
qCDebug(lcTransient) << "window" << title() << "has invisible Item parent" << itemParent << "transientParent"
<< transientParent() << "declared visibility" << d->visibility << "; delaying show";
connect(itemParent, &QQuickItem::windowChanged, this,
@@ -210,6 +211,9 @@ void QQuickWindowModule::defineModule()
qmlRegisterUncreatableType<QQuickScreen,1>(uri, 2, 3, "Screen", QStringLiteral("Screen can only be used via the attached property."));
qmlRegisterUncreatableType<QQuickScreenInfo,2>(uri, 2, 3, "ScreenInfo", QStringLiteral("ScreenInfo can only be used via the attached property."));
qmlRegisterUncreatableType<QQuickScreenInfo,10>(uri, 2, 10, "ScreenInfo", QStringLiteral("ScreenInfo can only be used via the attached property."));
+ qmlRegisterRevision<QWindow,13>(uri, 2, 13);
+ qmlRegisterRevision<QQuickWindow,13>(uri, 2, 13);
+ qmlRegisterType<QQuickWindowQmlImpl,13>(uri, 2, 13, "Window");
}
QT_END_NAMESPACE
diff --git a/src/quick/quick.pro b/src/quick/quick.pro
index 0f5f5abca3..37d2ad1172 100644
--- a/src/quick/quick.pro
+++ b/src/quick/quick.pro
@@ -21,7 +21,6 @@ QMAKE_DOCS = $$PWD/doc/qtquick.qdocconf
ANDROID_LIB_DEPENDENCIES = \
lib/libQt5QuickParticles.so
MODULE_PLUGIN_TYPES += \
- accessible/libqtaccessiblequick.so \
scenegraph
ANDROID_BUNDLED_FILES += \
qml \
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp
index 405e2ab100..da5d39db20 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp
@@ -473,8 +473,7 @@ void QSGSoftwareInternalImageNode::paint(QPainter *painter)
painter->save();
qreal sx = m_targetRect.width()/(m_subSourceRect.width()*pm.width());
qreal sy = m_targetRect.height()/(m_subSourceRect.height()*pm.height());
- QMatrix transform(sx, 0, 0, sy, 0, 0);
- painter->setMatrix(transform, true);
+ painter->setTransform(QTransform::fromScale(sx, sy), true);
painter->drawTiledPixmap(QRectF(m_targetRect.x()/sx, m_targetRect.y()/sy, m_targetRect.width()/sx, m_targetRect.height()/sy),
pm,
QPointF(m_subSourceRect.left()*pm.width(), m_subSourceRect.top()*pm.height()));
diff --git a/src/quick/scenegraph/coreapi/qsgnode.h b/src/quick/scenegraph/coreapi/qsgnode.h
index 854e284c9e..cb677de030 100644
--- a/src/quick/scenegraph/coreapi/qsgnode.h
+++ b/src/quick/scenegraph/coreapi/qsgnode.h
@@ -96,7 +96,7 @@ public:
// Uppermost 8 bits are reserved for internal use.
IsVisitableNode = 0x01000000
#ifdef Q_CLANG_QDOC
- InternalReserved = 0x01000000
+ , InternalReserved = 0x01000000
#endif
};
Q_DECLARE_FLAGS(Flags, Flag)
diff --git a/src/quick/scenegraph/qsgdefaultcontext.cpp b/src/quick/scenegraph/qsgdefaultcontext.cpp
index 5813844cd2..70b74b8877 100644
--- a/src/quick/scenegraph/qsgdefaultcontext.cpp
+++ b/src/quick/scenegraph/qsgdefaultcontext.cpp
@@ -221,8 +221,14 @@ QSurfaceFormat QSGDefaultContext::defaultSurfaceFormat() const
static bool useDepth = qEnvironmentVariableIsEmpty("QSG_NO_DEPTH_BUFFER");
static bool useStencil = qEnvironmentVariableIsEmpty("QSG_NO_STENCIL_BUFFER");
static bool enableDebug = qEnvironmentVariableIsSet("QSG_OPENGL_DEBUG");
- format.setDepthBufferSize(useDepth ? 24 : 0);
- format.setStencilBufferSize(useStencil ? 8 : 0);
+ if (useDepth && format.depthBufferSize() == -1)
+ format.setDepthBufferSize(24);
+ else if (!useDepth)
+ format.setDepthBufferSize(0);
+ if (useStencil && format.stencilBufferSize() == -1)
+ format.setStencilBufferSize(8);
+ else if (!useStencil)
+ format.setStencilBufferSize(0);
if (enableDebug)
format.setOption(QSurfaceFormat::DebugContext);
if (QQuickWindow::hasDefaultAlphaBuffer())
diff --git a/src/quick/scenegraph/util/qsgimagenode.h b/src/quick/scenegraph/util/qsgimagenode.h
index 526f52b7e5..3b78f78a0e 100644
--- a/src/quick/scenegraph/util/qsgimagenode.h
+++ b/src/quick/scenegraph/util/qsgimagenode.h
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
class Q_QUICK_EXPORT QSGImageNode : public QSGGeometryNode
{
public:
- ~QSGImageNode() override { }
+ ~QSGImageNode() override = default;
virtual void setRect(const QRectF &rect) = 0;
inline void setRect(qreal x, qreal y, qreal w, qreal h) { setRect(QRectF(x, y, w, h)); }
diff --git a/src/quick/scenegraph/util/qsgninepatchnode.h b/src/quick/scenegraph/util/qsgninepatchnode.h
index e76afd3c4a..b690a50e9d 100644
--- a/src/quick/scenegraph/util/qsgninepatchnode.h
+++ b/src/quick/scenegraph/util/qsgninepatchnode.h
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
class Q_QUICK_EXPORT QSGNinePatchNode : public QSGGeometryNode
{
public:
- ~QSGNinePatchNode() override { }
+ ~QSGNinePatchNode() override = default;
virtual void setTexture(QSGTexture *texture) = 0;
virtual void setBounds(const QRectF &bounds) = 0;
diff --git a/src/quick/scenegraph/util/qsgrectanglenode.h b/src/quick/scenegraph/util/qsgrectanglenode.h
index ba52b65b07..c435dc790f 100644
--- a/src/quick/scenegraph/util/qsgrectanglenode.h
+++ b/src/quick/scenegraph/util/qsgrectanglenode.h
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
class Q_QUICK_EXPORT QSGRectangleNode : public QSGGeometryNode
{
public:
- ~QSGRectangleNode() override { }
+ ~QSGRectangleNode() override = default;
virtual void setRect(const QRectF &rect) = 0;
inline void setRect(qreal x, qreal y, qreal w, qreal h) { setRect(QRectF(x, y, w, h)); }
diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp
index d33bdffe74..042eee19f5 100644
--- a/src/quick/scenegraph/util/qsgtexture.cpp
+++ b/src/quick/scenegraph/util/qsgtexture.cpp
@@ -49,6 +49,7 @@
# include <qopenglfunctions.h>
# include <QtGui/qopenglcontext.h>
# include <QtGui/qopenglfunctions.h>
+# include <QtGui/private/qopengltextureuploader_p.h>
# include <private/qsgdefaultrendercontext_p.h>
#endif
#include <private/qsgmaterialshader_p.h>
@@ -89,7 +90,7 @@ static const bool qsg_leak_check = !qEnvironmentVariableIsEmpty("QML_LEAK_CHECK"
QT_BEGIN_NAMESPACE
-#if QT_CONFIG(opengl)
+#if QT_CONFIG(opengl) && !defined(QT_NO_DEBUG)
inline static bool isPowerOfTwo(int x)
{
// Assumption: x >= 1
@@ -755,9 +756,7 @@ void QSGPlainTexture::bind()
// ### TODO: check for out-of-memory situations...
- QImage tmp = (m_image.format() == QImage::Format_RGB32 || m_image.format() == QImage::Format_ARGB32_Premultiplied)
- ? m_image
- : m_image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
+ QOpenGLTextureUploader::BindOptions options = QOpenGLTextureUploader::PremultipliedAlphaBindOption;
// Downscale the texture to fit inside the max texture limit if it is too big.
// It would be better if the image was already downscaled to the right size,
@@ -771,75 +770,19 @@ void QSGPlainTexture::bind()
max = rc->maxTextureSize();
else
funcs->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max);
- if (tmp.width() > max || tmp.height() > max) {
- tmp = tmp.scaled(qMin(max, tmp.width()), qMin(max, tmp.height()), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- m_texture_size = tmp.size();
- }
+
+ m_texture_size = m_texture_size.boundedTo(QSize(max, max));
// Scale to a power of two size if mipmapping is requested and the
// texture is npot and npot textures are not properly supported.
if (mipmapFiltering() != QSGTexture::None
- && (!isPowerOfTwo(m_texture_size.width()) || !isPowerOfTwo(m_texture_size.height()))
&& !funcs->hasOpenGLFeature(QOpenGLFunctions::NPOTTextures)) {
- tmp = tmp.scaled(qNextPowerOfTwo(m_texture_size.width()), qNextPowerOfTwo(m_texture_size.height()),
- Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- m_texture_size = tmp.size();
+ options |= QOpenGLTextureUploader::PowerOfTwoBindOption;
}
- if (tmp.width() * 4 != tmp.bytesPerLine())
- tmp = tmp.copy();
-
- qint64 convertTime = 0;
- if (profileFrames)
- convertTime = qsg_renderer_timer.nsecsElapsed();
- Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare,
- QQuickProfiler::SceneGraphTexturePrepareConvert);
-
updateBindOptions(m_dirty_bind_options);
- GLenum externalFormat = GL_RGBA;
- GLenum internalFormat = GL_RGBA;
-
-#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED)
- QString *deviceName =
- static_cast<QString *>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("AndroidDeviceName"));
- static bool wrongfullyReportsBgra8888Support = deviceName != 0
- && (deviceName->compare(QLatin1String("samsung SM-T211"), Qt::CaseInsensitive) == 0
- || deviceName->compare(QLatin1String("samsung SM-T210"), Qt::CaseInsensitive) == 0
- || deviceName->compare(QLatin1String("samsung SM-T215"), Qt::CaseInsensitive) == 0);
-#else
- static bool wrongfullyReportsBgra8888Support = false;
-#endif
-
- if (context->hasExtension(QByteArrayLiteral("GL_EXT_bgra"))) {
- externalFormat = GL_BGRA;
-#ifdef QT_OPENGL_ES
- internalFormat = GL_BGRA;
-#else
- if (context->isOpenGLES())
- internalFormat = GL_BGRA;
-#endif // QT_OPENGL_ES
- } else if (!wrongfullyReportsBgra8888Support
- && (context->hasExtension(QByteArrayLiteral("GL_EXT_texture_format_BGRA8888"))
- || context->hasExtension(QByteArrayLiteral("GL_IMG_texture_format_BGRA8888")))) {
- externalFormat = GL_BGRA;
- internalFormat = GL_BGRA;
-#if defined(Q_OS_DARWIN) && !defined(Q_OS_OSX)
- } else if (context->hasExtension(QByteArrayLiteral("GL_APPLE_texture_format_BGRA8888"))) {
- externalFormat = GL_BGRA;
- internalFormat = GL_RGBA;
-#endif
- } else {
- tmp = std::move(tmp).convertToFormat(QImage::Format_RGBA8888_Premultiplied);
- }
-
- qint64 swizzleTime = 0;
- if (profileFrames)
- swizzleTime = qsg_renderer_timer.nsecsElapsed();
- 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());
+ QOpenGLTextureUploader::textureImage(GL_TEXTURE_2D, m_image, options, QSize(max, max));
qint64 uploadTime = 0;
if (profileFrames)
@@ -856,15 +799,11 @@ void QSGPlainTexture::bind()
if (profileFrames) {
mipmapTime = qsg_renderer_timer.nsecsElapsed();
qCDebug(QSG_LOG_TIME_TEXTURE,
- "plain texture uploaded in: %dms (%dx%d), bind=%d, convert=%d, swizzle=%d (%s->%s), upload=%d, mipmap=%d%s",
+ "plain texture uploaded in: %dms (%dx%d), bind=%d, upload=%d, mipmap=%d%s",
int(mipmapTime / 1000000),
m_texture_size.width(), m_texture_size.height(),
int(bindTime / 1000000),
- int((convertTime - bindTime)/1000000),
- int((swizzleTime - convertTime)/1000000),
- (externalFormat == GL_BGRA ? "BGRA" : "RGBA"),
- (internalFormat == GL_BGRA ? "BGRA" : "RGBA"),
- int((uploadTime - swizzleTime)/1000000),
+ int((uploadTime - bindTime)/1000000),
int((mipmapTime - uploadTime)/1000000),
m_texture_size != m_image.size() ? " (scaled to GL_MAX_TEXTURE_SIZE)" : "");
}
diff --git a/src/quick/scenegraph/util/qsgtexturematerial_p.h b/src/quick/scenegraph/util/qsgtexturematerial_p.h
index 093d820801..a99e872580 100644
--- a/src/quick/scenegraph/util/qsgtexturematerial_p.h
+++ b/src/quick/scenegraph/util/qsgtexturematerial_p.h
@@ -72,7 +72,7 @@ protected:
int m_matrix_id;
};
-class QSGTextureMaterialShader : public QSGOpaqueTextureMaterialShader
+class Q_QUICK_PRIVATE_EXPORT QSGTextureMaterialShader : public QSGOpaqueTextureMaterialShader
{
public:
QSGTextureMaterialShader();
diff --git a/src/quick/util/qquickbehavior.cpp b/src/quick/util/qquickbehavior.cpp
index d024c0099b..76d464e7f8 100644
--- a/src/quick/util/qquickbehavior.cpp
+++ b/src/quick/util/qquickbehavior.cpp
@@ -171,9 +171,28 @@ void QQuickBehavior::setEnabled(bool enabled)
emit enabledChanged();
}
+/*!
+ \qmlproperty Variant QtQuick::Behavior::targetValue
+
+ This property holds the target value of the property being controlled by the Behavior.
+ This value is set by the Behavior before the animation is started.
+
+ \since QtQuick 2.13
+*/
+QVariant QQuickBehavior::targetValue() const
+{
+ Q_D(const QQuickBehavior);
+ return d->targetValue;
+}
+
void QQuickBehavior::write(const QVariant &value)
{
Q_D(QQuickBehavior);
+ const bool targetValueHasChanged = d->targetValue != value;
+ if (targetValueHasChanged) {
+ d->targetValue = value;
+ emit targetValueChanged(); // emitting the signal here should allow
+ } // d->enabled to change if scripted by the user.
bool bypass = !d->enabled || !d->finalized || QQmlEnginePrivate::designerMode();
if (!bypass)
qmlExecuteDeferred(this);
@@ -181,16 +200,13 @@ void QQuickBehavior::write(const QVariant &value)
if (d->animationInstance)
d->animationInstance->stop();
QQmlPropertyPrivate::write(d->property, value, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding);
- d->targetValue = value;
return;
}
bool behaviorActive = d->animation->isRunning();
- if (behaviorActive && value == d->targetValue)
+ if (behaviorActive && !targetValueHasChanged)
return;
- d->targetValue = value;
-
if (d->animationInstance
&& (d->animationInstance->duration() != -1
|| d->animationInstance->isRenderThreadProxy())
diff --git a/src/quick/util/qquickbehavior_p.h b/src/quick/util/qquickbehavior_p.h
index f939597d15..80a51d77af 100644
--- a/src/quick/util/qquickbehavior_p.h
+++ b/src/quick/util/qquickbehavior_p.h
@@ -69,6 +69,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickBehavior : public QObject, public QQmlPropert
Q_CLASSINFO("DefaultProperty", "animation")
Q_PROPERTY(QQuickAbstractAnimation *animation READ animation WRITE setAnimation)
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
+ Q_PROPERTY(QVariant targetValue READ targetValue NOTIFY targetValueChanged REVISION 13)
Q_CLASSINFO("DeferredPropertyNames", "animation")
public:
@@ -84,8 +85,11 @@ public:
bool enabled() const;
void setEnabled(bool enabled);
+ QVariant targetValue() const;
+
Q_SIGNALS:
void enabledChanged();
+ void targetValueChanged();
private Q_SLOTS:
void componentFinalized();
diff --git a/src/quick/util/qquickfontmetrics.cpp b/src/quick/util/qquickfontmetrics.cpp
index f1278c366f..42b3038c48 100644
--- a/src/quick/util/qquickfontmetrics.cpp
+++ b/src/quick/util/qquickfontmetrics.cpp
@@ -287,7 +287,7 @@ qreal QQuickFontMetrics::lineWidth() const
*/
qreal QQuickFontMetrics::advanceWidth(const QString &text) const
{
- return m_metrics.width(text);
+ return m_metrics.horizontalAdvance(text);
}
/*!
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
index dc8bed8125..ced0acd9ab 100644
--- a/src/quick/util/qquickpixmapcache.cpp
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -61,9 +61,7 @@
#include <QThread>
#include <QMutex>
#include <QMutexLocker>
-#include <QWaitCondition>
#include <QBuffer>
-#include <QWaitCondition>
#include <QtCore/qdebug.h>
#include <private/qobject_p.h>
#include <QQmlFile>
@@ -222,7 +220,6 @@ private:
QMutex mutex;
QQuickPixmapReaderThreadObject *threadObject;
- QWaitCondition waitCondition;
#if QT_CONFIG(qml_network)
QNetworkAccessManager *networkAccessManager();
@@ -372,15 +369,27 @@ static void maybeRemoveAlpha(QImage *image)
switch (image->format()) {
case QImage::Format_RGBA8888:
case QImage::Format_RGBA8888_Premultiplied:
+ if (image->data_ptr()->convertInPlace(QImage::Format_RGBX8888, Qt::AutoColor))
+ break;
+
*image = image->convertToFormat(QImage::Format_RGBX8888);
break;
case QImage::Format_A2BGR30_Premultiplied:
+ if (image->data_ptr()->convertInPlace(QImage::Format_BGR30, Qt::AutoColor))
+ break;
+
*image = image->convertToFormat(QImage::Format_BGR30);
break;
case QImage::Format_A2RGB30_Premultiplied:
+ if (image->data_ptr()->convertInPlace(QImage::Format_RGB30, Qt::AutoColor))
+ break;
+
*image = image->convertToFormat(QImage::Format_RGB30);
break;
default:
+ if (image->data_ptr()->convertInPlace(QImage::Format_RGB32, Qt::AutoColor))
+ break;
+
*image = image->convertToFormat(QImage::Format_RGB32);
break;
}
diff --git a/src/quick/util/qquickpropertychanges.cpp b/src/quick/util/qquickpropertychanges.cpp
index 8e2ac32ace..d739c8a017 100644
--- a/src/quick/util/qquickpropertychanges.cpp
+++ b/src/quick/util/qquickpropertychanges.cpp
@@ -336,6 +336,9 @@ void QQuickPropertyChangesPrivate::decodeBinding(const QString &propertyPrefix,
case QV4::CompiledData::Binding::Type_Boolean:
var = binding->valueAsBoolean();
break;
+ case QV4::CompiledData::Binding::Type_Null:
+ var = QVariant::fromValue(nullptr);
+ break;
default:
break;
}
diff --git a/src/quick/util/qquickstyledtext.cpp b/src/quick/util/qquickstyledtext.cpp
index 5e1aaf121e..7d545cdb2f 100644
--- a/src/quick/util/qquickstyledtext.cpp
+++ b/src/quick/util/qquickstyledtext.cpp
@@ -675,7 +675,7 @@ void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QStri
{
qreal imgWidth = 0.0;
QFontMetricsF fm(layout.font());
- const qreal spaceWidth = fm.width(QChar::Nbsp);
+ const qreal spaceWidth = fm.horizontalAdvance(QChar::Nbsp);
const bool trailingSpace = textOut.endsWith(space);
if (!updateImagePositions) {
diff --git a/src/quick/util/qquicktextmetrics.cpp b/src/quick/util/qquicktextmetrics.cpp
index 81088b5cd6..959980b267 100644
--- a/src/quick/util/qquicktextmetrics.cpp
+++ b/src/quick/util/qquicktextmetrics.cpp
@@ -186,7 +186,7 @@ void QQuickTextMetrics::setElideWidth(qreal elideWidth)
*/
qreal QQuickTextMetrics::advanceWidth() const
{
- return m_metrics.width(m_text);
+ return m_metrics.horizontalAdvance(m_text);
}
/*!
diff --git a/src/quick/util/qquickutilmodule.cpp b/src/quick/util/qquickutilmodule.cpp
index 31d4d4c437..5147ebc6f6 100644
--- a/src/quick/util/qquickutilmodule.cpp
+++ b/src/quick/util/qquickutilmodule.cpp
@@ -135,4 +135,6 @@ void QQuickUtilModule::defineModule()
qmlRegisterUncreatableType<QQuickAbstractAnimation, 12>("QtQuick", 2, 12, "Animation",
QQuickAbstractAnimation::tr("Animation is an abstract class"));
+ // 5.13
+ qmlRegisterType<QQuickBehavior, 13>("QtQuick", 2, 13, "Behavior");
}
diff --git a/tests/auto/particles/shared/particlestestsshared.h b/tests/auto/particles/shared/particlestestsshared.h
index 5ef1d2cabb..e1fc6f4ccd 100644
--- a/tests/auto/particles/shared/particlestestsshared.h
+++ b/tests/auto/particles/shared/particlestestsshared.h
@@ -31,6 +31,8 @@
#include <QtQuick/QQuickView>
#include <QtTest>
#include <QAbstractAnimation>
+#include <QScopedPointer>
+
const qreal EPSILON = 0.0001;
bool extremelyFuzzyCompare(qreal a, qreal b, qreal e)//For cases which can have larger variances
@@ -55,17 +57,18 @@ bool myFuzzyGEQ(qreal a, qreal b)
QQuickView* createView(const QUrl &filename, int additionalWait=0)
{
- QQuickView *view = new QQuickView(0);
+ QScopedPointer<QQuickView> view(new QQuickView(nullptr));
view->setSource(filename);
if (view->status() != QQuickView::Ready)
- return 0;
+ return nullptr;
view->show();
- QTest::qWaitForWindowExposed(view);
+ if (!QTest::qWaitForWindowExposed(view.data()))
+ return nullptr;
if (additionalWait)
QTest::qWait(additionalWait);
- return view;
+ return view.take();
}
void ensureAnimTime(int requiredTime, QAbstractAnimation* anim)//With consistentTiming, who knows how long an animation really takes...
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro
index 8fef435d98..acd5546a02 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro
+++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro
@@ -1,13 +1,12 @@
CONFIG += testcase
TARGET = tst_qqmldebugjs
-QT += qml testlib gui-private core-private
+QT += testlib gui-private core-private
macos:CONFIG -= app_bundle
SOURCES += tst_qqmldebugjs.cpp
INCLUDEPATH += ../shared
include(../shared/debugutil.pri)
-include(../shared/qqmlenginedebugclient.pri)
TESTDATA = data/*
diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
index 1202cddc05..1ac28c473b 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
+++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
@@ -28,10 +28,10 @@
#include "debugutil_p.h"
#include "qqmldebugprocess_p.h"
-#include "../shared/qqmlenginedebugclient.h"
#include "../../../shared/util.h"
-#include <private/qqmldebugclient_p.h>
+#include <private/qqmlenginedebugclient_p.h>
+#include <private/qv4debugclient_p.h>
#include <private/qqmldebugconnection_p.h>
#include <private/qpacket_p.h>
@@ -43,72 +43,8 @@
#include <QtCore/qdir.h>
#include <QtCore/qmutex.h>
#include <QtCore/qlibraryinfo.h>
-#include <QtQml/qjsengine.h>
-
-const char *V8REQUEST = "v8request";
-const char *V8MESSAGE = "v8message";
-const char *SEQ = "seq";
-const char *TYPE = "type";
-const char *COMMAND = "command";
-const char *ARGUMENTS = "arguments";
-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";
-const char *INCLUDESOURCE = "includeSource";
-const char *FROMFRAME = "fromFrame";
-const char *TOFRAME = "toFrame";
-const char *BOTTOM = "bottom";
-const char *NUMBER = "number";
-const char *FRAMENUMBER = "frameNumber";
-const char *TYPES = "types";
-const char *IDS = "ids";
-const char *FILTER = "filter";
-const char *FROMLINE = "fromLine";
-const char *TOLINE = "toLine";
-const char *TARGET = "target";
-const char *LINE = "line";
-const char *COLUMN = "column";
-const char *ENABLED = "enabled";
-const char *CONDITION = "condition";
-const char *IGNORECOUNT = "ignoreCount";
-const char *BREAKPOINT = "breakpoint";
-const char *FLAGS = "flags";
-
-const char *CONTINEDEBUGGING = "continue";
-const char *EVALUATE = "evaluate";
-const char *LOOKUP = "lookup";
-const char *BACKTRACE = "backtrace";
-const char *SCOPE = "scope";
-const char *SCOPES = "scopes";
-const char *SCRIPTS = "scripts";
-const char *SOURCE = "source";
-const char *SETBREAKPOINT = "setbreakpoint";
-const char *CLEARBREAKPOINT = "clearbreakpoint";
-const char *CHANGEBREAKPOINT = "changebreakpoint";
-const char *SETEXCEPTIONBREAK = "setexceptionbreak";
-const char *VERSION = "version";
-const char *DISCONNECT = "disconnect";
-const char *GARBAGECOLLECTOR = "gc";
-
-const char *CONNECT = "connect";
-const char *INTERRUPT = "interrupt";
-
-const char *REQUEST = "request";
-const char *IN = "in";
-const char *NEXT = "next";
-const char *OUT = "out";
-
-const char *SCRIPT = "script";
-const char *SCRIPTREGEXP = "scriptRegExp";
-const char *EVENT = "event";
-
-const char *ALL = "all";
-const char *UNCAUGHT = "uncaught";
+#include <QtCore/qjsonobject.h>
+#include <QtCore/qjsonarray.h>
const char *BLOCKMODE = "-qmljsdebugger=port:3771,3800,block";
const char *NORMALMODE = "-qmljsdebugger=port:3771,3800";
@@ -129,13 +65,6 @@ const char *BREAKPOINTRELOCATION_QMLFILE = "breakpointRelocation.qml";
const char *ENCODEQMLSCOPE_QMLFILE = "encodeQmlScope.qml";
const char *BREAKONANCHOR_QMLFILE = "breakOnAnchor.qml";
-#define VARIANTMAPINIT \
- QString obj("{}"); \
- QJSValue jsonVal = parser.call(QJSValueList() << obj); \
- jsonVal.setProperty(SEQ,QJSValue(seq++)); \
- jsonVal.setProperty(TYPE,REQUEST);
-
-
#undef QVERIFY
#define QVERIFY(statement) \
do {\
@@ -146,9 +75,6 @@ do {\
}\
} while (0)
-
-class QJSDebugClient;
-
class tst_QQmlDebugJS : public QQmlDebugTest
{
Q_OBJECT
@@ -231,7 +157,7 @@ private:
ConnectResult init(bool qmlscene, const QString &qmlFile = QString(TEST_QMLFILE),
bool blockMode = true, bool restrictServices = false);
QList<QQmlDebugClient *> createClients() override;
- QPointer<QJSDebugClient> m_client;
+ QPointer<QV4DebugClient> m_client;
void targetData();
bool waitForClientSignal(const char *signal, int timeout = 30000);
@@ -240,555 +166,7 @@ private:
QTime t;
};
-class QJSDebugClient : public QQmlDebugClient
-{
- Q_OBJECT
-public:
- enum StepAction
- {
- Continue,
- In,
- Out,
- Next
- };
-
- enum Exception
- {
- All,
- Uncaught
- };
-
- QJSDebugClient(QQmlDebugConnection *connection)
- : QQmlDebugClient(QLatin1String("V8Debugger"), connection),
- seq(0)
- {
- parser = jsEngine.evaluate(QLatin1String("JSON.parse"));
- stringify = jsEngine.evaluate(QLatin1String("JSON.stringify"));
- QObject::connect(this, &QQmlDebugClient::stateChanged,
- this, &QJSDebugClient::onStateChanged);
- }
-
- void connect();
- void interrupt();
-
- void continueDebugging(StepAction stepAction);
- 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);
- void scope(int number = -1, int frameNumber = -1);
- void scripts(int types = 4, QList<int> ids = QList<int>(), bool includeSource = false, QVariant filter = QVariant());
- void setBreakpoint(QString target, int line = -1, int column = -1, bool enabled = true,
- QString condition = QString(), int ignoreCount = -1);
- void clearBreakpoint(int breakpoint);
- void changeBreakpoint(int breakpoint, bool enabled);
- void setExceptionBreak(Exception type, bool enabled = false);
- void version();
- void disconnect();
-
-protected:
- //inherited from QQmlDebugClient
- void onStateChanged(State state);
- void messageReceived(const QByteArray &data);
-
-signals:
- void connected();
- void interruptRequested();
- void result();
- void failure();
- void stopped();
-
-private:
- void sendMessage(const QByteArray &);
- void flushSendBuffer();
- QByteArray packMessage(const QByteArray &type, const QByteArray &message = QByteArray());
-
-private:
- QJSEngine jsEngine;
- int seq;
-
- QList<QByteArray> sendBuffer;
-public:
- QJSValue parser;
- QJSValue stringify;
- QByteArray response;
-
-};
-
-void QJSDebugClient::connect()
-{
- const QJSValue jsonVal = parser.call(QJSValueList() << QLatin1String("{}"));
- sendMessage(packMessage(CONNECT,
- stringify.call(QJSValueList() << jsonVal).toString().toUtf8()));
-}
-
-void QJSDebugClient::interrupt()
-{
- sendMessage(packMessage(INTERRUPT));
-}
-
-void QJSDebugClient::continueDebugging(StepAction action)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "continue",
- // "arguments" : { "stepaction" : <"in", "next" or "out">,
- // "stepcount" : <number of steps (default 1)>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CONTINEDEBUGGING)));
-
- if (action != Continue) {
- QJSValue args = parser.call(QJSValueList() << obj);
- switch (action) {
- case In: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(IN)));
- break;
- case Out: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(OUT)));
- break;
- case Next: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(NEXT)));
- break;
- default:break;
- }
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
- }
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::evaluate(QString expr, int frame, int context)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "evaluate",
- // "arguments" : { "expression" : <expression to evaluate>,
- // "frame" : <number>,
- // "context" : <object ID>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(EVALUATE)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(EXPRESSION),QJSValue(expr));
-
- 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);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::lookup(QList<int> handles, bool includeSource)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "lookup",
- // "arguments" : { "handles" : <array of handles>,
- // "includeSource" : <boolean indicating whether the source will be included when script objects are returned>,
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(LOOKUP)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- QString arr("[]");
- QJSValue array = parser.call(QJSValueList() << arr);
- int index = 0;
- foreach (int handle, handles) {
- array.setProperty(index++,QJSValue(handle));
- }
- args.setProperty(QLatin1String(HANDLES),array);
-
- if (includeSource)
- args.setProperty(QLatin1String(INCLUDESOURCE),QJSValue(includeSource));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::backtrace(int fromFrame, int toFrame, bool bottom)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "backtrace",
- // "arguments" : { "fromFrame" : <number>
- // "toFrame" : <number>
- // "bottom" : <boolean, set to true if the bottom of the stack is requested>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(BACKTRACE)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- if (fromFrame != -1)
- args.setProperty(QLatin1String(FROMFRAME),QJSValue(fromFrame));
-
- if (toFrame != -1)
- args.setProperty(QLatin1String(TOFRAME),QJSValue(toFrame));
-
- if (bottom)
- args.setProperty(QLatin1String(BOTTOM),QJSValue(bottom));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::frame(int number)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "frame",
- // "arguments" : { "number" : <frame number>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(FRAME)));
-
- if (number != -1) {
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(NUMBER),QJSValue(number));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::scope(int number, int frameNumber)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "scope",
- // "arguments" : { "number" : <scope number>
- // "frameNumber" : <frame number, optional uses selected frame if missing>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCOPE)));
-
- if (number != -1) {
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(NUMBER),QJSValue(number));
-
- if (frameNumber != -1)
- args.setProperty(QLatin1String(FRAMENUMBER),QJSValue(frameNumber));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::scripts(int types, QList<int> ids, bool includeSource, QVariant /*filter*/)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "scripts",
- // "arguments" : { "types" : <types of scripts to retrieve
- // set bit 0 for native scripts
- // set bit 1 for extension scripts
- // set bit 2 for normal scripts
- // (default is 4 for normal scripts)>
- // "ids" : <array of id's of scripts to return. If this is not specified all scripts are requrned>
- // "includeSource" : <boolean indicating whether the source code should be included for the scripts returned>
- // "filter" : <string or number: filter string or script id.
- // If a number is specified, then only the script with the same number as its script id will be retrieved.
- // If a string is specified, then only scripts whose names contain the filter string will be retrieved.>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCRIPTS)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(TYPES),QJSValue(types));
-
- if (ids.count()) {
- QString arr("[]");
- QJSValue array = parser.call(QJSValueList() << arr);
- int index = 0;
- foreach (int id, ids) {
- array.setProperty(index++,QJSValue(id));
- }
- args.setProperty(QLatin1String(IDS),array);
- }
-
- if (includeSource)
- args.setProperty(QLatin1String(INCLUDESOURCE),QJSValue(includeSource));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::setBreakpoint(QString target, int line, int column, bool enabled,
- QString condition, int ignoreCount)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "setbreakpoint",
- // "arguments" : { "type" : "scriptRegExp"
- // "target" : <function expression or script identification>
- // "line" : <line in script or function>
- // "column" : <character position within the line>
- // "enabled" : <initial enabled state. True or false, default is true>
- // "condition" : <string with break point condition>
- // "ignoreCount" : <number specifying the number of break point hits to ignore, default value is 0>
- // }
- // }
-
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SETBREAKPOINT)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(SCRIPTREGEXP)));
- args.setProperty(QLatin1String(TARGET),QJSValue(target));
-
- if (line != -1)
- args.setProperty(QLatin1String(LINE),QJSValue(line));
-
- if (column != -1)
- args.setProperty(QLatin1String(COLUMN),QJSValue(column));
-
- args.setProperty(QLatin1String(ENABLED),QJSValue(enabled));
-
- if (!condition.isEmpty())
- args.setProperty(QLatin1String(CONDITION),QJSValue(condition));
-
- if (ignoreCount != -1)
- args.setProperty(QLatin1String(IGNORECOUNT),QJSValue(ignoreCount));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::clearBreakpoint(int breakpoint)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "clearbreakpoint",
- // "arguments" : { "breakpoint" : <number of the break point to clear>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CLEARBREAKPOINT)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- args.setProperty(QLatin1String(BREAKPOINT),QJSValue(breakpoint));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::changeBreakpoint(int breakpoint, bool enabled)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "changebreakpoint",
- // "arguments" : { "breakpoint" : <number of the break point to change>
- // "enabled" : <bool: enables the break type if true, disables if false>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND), QLatin1String(CHANGEBREAKPOINT));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- args.setProperty(QLatin1String(BREAKPOINT), breakpoint);
- args.setProperty(QLatin1String(ENABLED), enabled);
- jsonVal.setProperty(QLatin1String(ARGUMENTS), args);
-
- const QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::setExceptionBreak(Exception type, bool enabled)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "setexceptionbreak",
- // "arguments" : { "type" : <string: "all", or "uncaught">,
- // "enabled" : <optional bool: enables the break type if true>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SETEXCEPTIONBREAK)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- if (type == All)
- args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(ALL)));
- else if (type == Uncaught)
- args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(UNCAUGHT)));
-
- if (enabled)
- args.setProperty(QLatin1String(ENABLED),QJSValue(enabled));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::version()
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "version",
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(VERSION)));
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::disconnect()
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "disconnect",
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(DISCONNECT)));
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(DISCONNECT, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::onStateChanged(State state)
-{
- if (state == Enabled)
- flushSendBuffer();
-}
-
-void QJSDebugClient::messageReceived(const QByteArray &data)
-{
- QPacket ds(connection()->currentDataStreamVersion(), data);
- QByteArray command;
- ds >> command;
-
- if (command == "V8DEBUG") {
- QByteArray type;
- ds >> type >> response;
-
- if (type == CONNECT) {
- emit connected();
-
- } else if (type == INTERRUPT) {
- emit interruptRequested();
-
- } else if (type == V8MESSAGE) {
- QString jsonString(response);
- QVariantMap value = parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
- QString type = value.value("type").toString();
-
- if (type == "response") {
-
- if (!value.value("success").toBool()) {
- emit failure();
- qDebug() << "Received success == false response from application:"
- << value.value("message").toString();
- return;
- }
-
- QString debugCommand(value.value("command").toString());
- if (debugCommand == "backtrace" ||
- debugCommand == "lookup" ||
- debugCommand == "setbreakpoint" ||
- debugCommand == "evaluate" ||
- debugCommand == "version" ||
- debugCommand == "disconnect" ||
- debugCommand == "gc" ||
- debugCommand == "changebreakpoint" ||
- debugCommand == "clearbreakpoint" ||
- debugCommand == "frame" ||
- debugCommand == "scope" ||
- debugCommand == "scopes" ||
- debugCommand == "scripts" ||
- debugCommand == "source" ||
- debugCommand == "setexceptionbreak" /*||
- debugCommand == "profile"*/) {
- emit result();
- } else {
- // DO NOTHING
- }
-
- } else if (type == QLatin1String(EVENT)) {
- QString event(value.value(QLatin1String(EVENT)).toString());
-
- if (event == "break" ||
- event == "exception")
- emit stopped();
- }
-
- }
- }
-}
-
-void QJSDebugClient::sendMessage(const QByteArray &msg)
-{
- if (state() == Enabled) {
- QQmlDebugClient::sendMessage(msg);
- } else {
- sendBuffer.append(msg);
- }
-}
-
-void QJSDebugClient::flushSendBuffer()
-{
- foreach (const QByteArray &msg, sendBuffer)
- QQmlDebugClient::sendMessage(msg);
- sendBuffer.clear();
-}
-
-QByteArray QJSDebugClient::packMessage(const QByteArray &type, const QByteArray &message)
-{
- QPacket rs(connection()->currentDataStreamVersion());
- QByteArray cmd = "V8DEBUG";
- rs << cmd << type << message;
- return rs.data();
-}
void tst_QQmlDebugJS::initTestCase()
{
@@ -842,7 +220,7 @@ void tst_QQmlDebugJS::interrupt()
m_client->connect();
m_client->interrupt();
- QVERIFY(waitForClientSignal(SIGNAL(interruptRequested())));
+ QVERIFY(waitForClientSignal(SIGNAL(interrupted())));
}
void tst_QQmlDebugJS::getVersion()
@@ -896,13 +274,11 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnCompleted()
m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(ONCOMPLETED_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(),
+ QLatin1String(ONCOMPLETED_QMLFILE));
}
void tst_QQmlDebugJS::setBreakpointInScriptOnComponentCreated()
@@ -917,13 +293,11 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComponentCreated()
m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(ONCOMPLETED_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(),
+ QLatin1String(ONCOMPLETED_QMLFILE));
}
void tst_QQmlDebugJS::setBreakpointInScriptOnTimerCallback()
@@ -939,13 +313,11 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnTimerCallback()
m_client->setBreakpoint(QLatin1String(TIMER_QMLFILE), sourceLine, -1, true);
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TIMER_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(),
+ QLatin1String(TIMER_QMLFILE));
}
void tst_QQmlDebugJS::setBreakpointInScriptInDifferentFile()
@@ -960,13 +332,11 @@ void tst_QQmlDebugJS::setBreakpointInScriptInDifferentFile()
m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TEST_JSFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(),
+ QLatin1String(TEST_JSFILE));
}
void tst_QQmlDebugJS::setBreakpointInScriptOnComment()
@@ -983,13 +353,11 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComment()
QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort);
QVERIFY(waitForClientSignal(SIGNAL(stopped()), 1));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
QCOMPARE(body.value("sourceLine").toInt(), actualLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(),
+ QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
}
void tst_QQmlDebugJS::setBreakpointInScriptOnEmptyLine()
@@ -1006,13 +374,11 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnEmptyLine()
QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort);
QVERIFY(waitForClientSignal(SIGNAL(stopped()), 1));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
QCOMPARE(body.value("sourceLine").toInt(), actualLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(),
+ QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
}
void tst_QQmlDebugJS::setBreakpointInScriptOnOptimizedBinding()
@@ -1027,13 +393,11 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnOptimizedBinding()
m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(),
+ QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
}
void tst_QQmlDebugJS::setBreakpointInScriptWithCondition()
@@ -1050,11 +414,8 @@ void tst_QQmlDebugJS::setBreakpointInScriptWithCondition()
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
//Get the frame index
- QString jsonString = m_client->response;
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
{
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
int frameIndex = body.value("index").toInt();
//Verify the value of 'result'
@@ -1062,13 +423,10 @@ void tst_QQmlDebugJS::setBreakpointInScriptWithCondition()
QVERIFY(waitForClientSignal(SIGNAL(result())));
}
- jsonString = m_client->response;
- QJSValue val = m_client->parser.call(QJSValueList() << QJSValue(jsonString));
- QVERIFY(val.isObject());
- QJSValue body = val.property(QStringLiteral("body"));
- QVERIFY(body.isObject());
- val = body.property("value");
- QVERIFY(val.isNumber());
+ const QJsonObject body = m_client->response().body.toObject();
+ QVERIFY(!body.isEmpty());
+ QJsonValue val = body.value("value");
+ QVERIFY(val.isDouble());
const int a = val.toInt();
QVERIFY(a > out);
@@ -1086,15 +444,12 @@ void tst_QQmlDebugJS::setBreakpointInScriptThatQuits()
m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(QUIT_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(), QLatin1String(QUIT_QMLFILE));
- m_client->continueDebugging(QJSDebugClient::Continue);
+ m_client->continueDebugging(QV4DebugClient::Continue);
QVERIFY(m_process->waitForFinished());
QCOMPARE(m_process->exitStatus(), QProcess::NormalExit);
}
@@ -1134,34 +489,32 @@ void tst_QQmlDebugJS::clearBreakpoint()
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- //Will hit 1st brakpoint, change this breakpoint enable = false
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+ {
+ //Will hit 1st brakpoint, change this breakpoint enable = false
+ const QJsonObject body = m_client->response().body.toObject();
+ const QJsonArray breakpointsHit = body.value("breakpoints").toArray();
- QVariantMap body = value.value("body").toMap();
- QList<QVariant> breakpointsHit = body.value("breakpoints").toList();
+ int breakpoint = breakpointsHit.at(0).toInt();
+ m_client->clearBreakpoint(breakpoint);
- int breakpoint = breakpointsHit.at(0).toInt();
- m_client->clearBreakpoint(breakpoint);
+ QVERIFY(waitForClientSignal(SIGNAL(result())));
- QVERIFY(waitForClientSignal(SIGNAL(result())));
+ //Continue with debugging
+ m_client->continueDebugging(QV4DebugClient::Continue);
+ //Hit 2nd breakpoint
+ QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- //Continue with debugging
- m_client->continueDebugging(QJSDebugClient::Continue);
- //Hit 2nd breakpoint
- QVERIFY(waitForClientSignal(SIGNAL(stopped())));
+ //Continue with debugging
+ m_client->continueDebugging(QV4DebugClient::Continue);
+ }
- //Continue with debugging
- m_client->continueDebugging(QJSDebugClient::Continue);
//Should stop at 2nd breakpoint
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- jsonString = m_client->response;
- value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
+ {
+ const QJsonObject body = m_client->response().body.toObject();
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
+ }
}
void tst_QQmlDebugJS::changeBreakpoint()
@@ -1174,23 +527,21 @@ void tst_QQmlDebugJS::changeBreakpoint()
QCOMPARE(init(qmlscene, CHANGEBREAKPOINT_QMLFILE), ConnectSuccess);
bool isStopped = false;
- QObject::connect(m_client.data(), &QJSDebugClient::stopped, this, [&]() { isStopped = true; });
+ QObject::connect(m_client.data(), &QV4DebugClient::stopped, this, [&]() { isStopped = true; });
auto continueDebugging = [&]() {
- m_client->continueDebugging(QJSDebugClient::Continue);
+ m_client->continueDebugging(QV4DebugClient::Continue);
isStopped = false;
};
m_client->connect();
auto extractBody = [&]() {
- const QVariantMap value = m_client->parser.call(
- QJSValueList() << QJSValue(QString(m_client->response))).toVariant().toMap();
- return value.value("body").toMap();
+ return m_client->response().body.toObject();
};
- auto extractBreakPointId = [&](const QVariantMap &body) {
- const QList<QVariant> breakpointsHit = body.value("breakpoints").toList();
+ auto extractBreakPointId = [&](const QJsonObject &body) {
+ const QJsonArray breakpointsHit = body.value("breakpoints").toArray();
if (breakpointsHit.size() != 1)
return -1;
return breakpointsHit[0].toInt();
@@ -1198,7 +549,7 @@ void tst_QQmlDebugJS::changeBreakpoint()
auto setBreakPoint = [&](int sourceLine, bool enabled) {
int id = -1;
- auto connection = QObject::connect(m_client.data(), &QJSDebugClient::result, [&]() {
+ auto connection = QObject::connect(m_client.data(), &QV4DebugClient::result, [&]() {
id = extractBody().value("breakpoint").toInt();
});
@@ -1221,7 +572,7 @@ void tst_QQmlDebugJS::changeBreakpoint()
auto verifyBreakpoint = [&](int sourceLine, int breakpointId) {
QTRY_VERIFY_WITH_TIMEOUT(isStopped, 30000);
- const QVariantMap body = extractBody();
+ const QJsonObject body = extractBody();
QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
QCOMPARE(extractBreakPointId(body), breakpointId);
};
@@ -1261,7 +612,7 @@ void tst_QQmlDebugJS::setExceptionBreak()
QFETCH(bool, qmlscene);
QCOMPARE(init(qmlscene, EXCEPTION_QMLFILE), ConnectSuccess);
- m_client->setExceptionBreak(QJSDebugClient::All,true);
+ m_client->setExceptionBreak(QV4DebugClient::All,true);
m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
}
@@ -1278,24 +629,19 @@ void tst_QQmlDebugJS::stepNext()
m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- m_client->continueDebugging(QJSDebugClient::Next);
+ m_client->continueDebugging(QV4DebugClient::Next);
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = m_client->response().body.toObject();
QCOMPARE(body.value("sourceLine").toInt(), sourceLine + 1);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(),
+ QLatin1String(STEPACTION_QMLFILE));
}
-static QVariantMap responseBody(QJSDebugClient *client)
+static QJsonObject responseBody(QV4DebugClient *client)
{
- const QString jsonString(client->response);
- const QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString))
- .toVariant().toMap();
- return value.value("body").toMap();
+ return client->response().body.toObject();
}
void tst_QQmlDebugJS::stepIn()
@@ -1312,12 +658,12 @@ void tst_QQmlDebugJS::stepIn()
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
QCOMPARE(responseBody(m_client).value("sourceLine").toInt(), sourceLine);
- m_client->continueDebugging(QJSDebugClient::In);
+ m_client->continueDebugging(QV4DebugClient::In);
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- const QVariantMap body = responseBody(m_client);
+ const QJsonObject body = responseBody(m_client);
QCOMPARE(body.value("sourceLine").toInt(), actualLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
}
void tst_QQmlDebugJS::stepOut()
@@ -1334,12 +680,12 @@ void tst_QQmlDebugJS::stepOut()
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
QCOMPARE(responseBody(m_client).value("sourceLine").toInt(), sourceLine);
- m_client->continueDebugging(QJSDebugClient::Out);
+ m_client->continueDebugging(QV4DebugClient::Out);
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- const QVariantMap body = responseBody(m_client);
+ const QJsonObject body = responseBody(m_client);
QCOMPARE(body.value("sourceLine").toInt(), actualLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
}
void tst_QQmlDebugJS::continueDebugging()
@@ -1356,16 +702,14 @@ void tst_QQmlDebugJS::continueDebugging()
m_client->connect();
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- m_client->continueDebugging(QJSDebugClient::Continue);
+ m_client->continueDebugging(QV4DebugClient::Continue);
QVERIFY(waitForClientSignal(SIGNAL(stopped())));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
+ const QJsonObject body = responseBody(m_client);
QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(),
+ QLatin1String(STEPACTION_QMLFILE));
}
void tst_QQmlDebugJS::backtrace()
@@ -1449,32 +793,27 @@ void tst_QQmlDebugJS::evaluateInLocalScope()
m_client->frame();
QVERIFY(waitForClientSignal(SIGNAL(result())));
- //Get the frame index
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- int frameIndex = body.value("index").toInt();
-
- m_client->evaluate(QLatin1String("root.a"), frameIndex);
- QVERIFY(waitForClientSignal(SIGNAL(result())));
-
- //Verify the value of 'timer.interval'
- jsonString = m_client->response;
- value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- body = value.value("body").toMap();
+ {
+ //Get the frame index
+ const QJsonObject body = responseBody(m_client);
+ int frameIndex = body.value("index").toInt();
+ m_client->evaluate(QLatin1String("root.a"), frameIndex);
+ QVERIFY(waitForClientSignal(SIGNAL(result())));
+ }
- QCOMPARE(body.value("value").toInt(),10);
+ {
+ //Verify the value of 'timer.interval'
+ const QJsonObject body = responseBody(m_client);
+ QCOMPARE(body.value("value").toInt(),10);
+ }
}
void tst_QQmlDebugJS::evaluateInContext()
{
m_connection = new QQmlDebugConnection();
- m_process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath)
- + "/qmlscene", this);
- m_client = new QJSDebugClient(m_connection);
+ m_process = new QQmlDebugProcess(
+ QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this);
+ m_client = new QV4DebugClient(m_connection);
QScopedPointer<QQmlEngineDebugClient> engineClient(new QQmlEngineDebugClient(m_connection));
m_process->start(QStringList() << QLatin1String(BLOCKMODE) << testFile(ONCOMPLETED_QMLFILE));
@@ -1497,7 +836,7 @@ void tst_QQmlDebugJS::evaluateInContext()
QVERIFY(QQmlDebugTest::waitForSignal(engineClient.data(), SIGNAL(result())));
QVERIFY(engineClient->engines().count());
- engineClient->queryRootContexts(engineClient->engines()[0].debugId, &success);
+ engineClient->queryRootContexts(engineClient->engines()[0], &success);
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(engineClient.data(), SIGNAL(result())));
@@ -1530,14 +869,12 @@ void tst_QQmlDebugJS::getScripts()
m_client->scripts();
QVERIFY(waitForClientSignal(SIGNAL(result())));
- QString jsonString(m_client->response);
- QVariantMap value = m_client->parser.call(QJSValueList()
- << QJSValue(jsonString)).toVariant().toMap();
- QList<QVariant> scripts = value.value("body").toList();
+ const QJsonArray scripts = m_client->response().body.toArray();
QCOMPARE(scripts.count(), 1);
- QVERIFY(scripts.first().toMap()[QStringLiteral("name")].toString().endsWith(QStringLiteral("data/test.qml")));
+ QVERIFY(scripts.first().toObject()[QStringLiteral("name")].toString()
+ .endsWith(QStringLiteral("data/test.qml")));
}
void tst_QQmlDebugJS::encodeQmlScope()
@@ -1551,42 +888,38 @@ void tst_QQmlDebugJS::encodeQmlScope()
bool isStopped = false;
bool scopesFailed = false;
- QObject::connect(m_client.data(), &QJSDebugClient::failure, this, [&]() {
- qWarning() << "received failure" << m_client->response;
+ QObject::connect(m_client.data(), &QV4DebugClient::failure, this, [&]() {
+ qWarning() << "received failure" << m_client->response().body;
scopesFailed = true;
m_process->stop();
numFrames = 2;
isStopped = false;
});
- QObject::connect(m_client.data(), &QJSDebugClient::stopped, this, [&]() {
+ QObject::connect(m_client.data(), &QV4DebugClient::stopped, this, [&]() {
m_client->frame();
isStopped = true;
});
- QObject::connect(m_client.data(), &QJSDebugClient::result, this, [&]() {
- const QVariantMap value = m_client->parser.call(
- QJSValueList() << QJSValue(QString(m_client->response))).toVariant().toMap();
-
- const QMap<QString, QVariant> body = value.value("body").toMap();
- const QString command = value.value("command").toString();
+ QObject::connect(m_client.data(), &QV4DebugClient::result, this, [&]() {
+ const QV4DebugClient::Response value = m_client->response();
- if (command == QString("scope")) {
+ if (value.command == QString("scope")) {
// If the scope commands fail we get a failure() signal above.
if (++numReceivedScopes == numExpectedScopes) {
- m_client->continueDebugging(QJSDebugClient::Continue);
+ m_client->continueDebugging(QV4DebugClient::Continue);
isStopped = false;
}
- } else if (command == QString("frame")) {
+ } else if (value.command == QString("frame")) {
// We want at least a global scope and some kind of local scope here.
- const QList<QVariant> scopes = body.value("scopes").toList();
- if (scopes.length() < 2)
+ const QJsonArray scopes = value.body.toObject().value("scopes").toArray();
+ if (scopes.count() < 2)
scopesFailed = true;
- for (const QVariant &scope : scopes) {
+ for (const QJsonValue &scope : scopes) {
++numExpectedScopes;
- m_client->scope(scope.toMap().value("index").toInt());
+ m_client->scope(scope.toObject().value("index").toInt());
}
++numFrames;
@@ -1611,21 +944,21 @@ void tst_QQmlDebugJS::breakOnAnchor()
int breaks = 0;
bool stopped = false;
- QObject::connect(m_client.data(), &QJSDebugClient::stopped, this, [&]() {
+ QObject::connect(m_client.data(), &QV4DebugClient::stopped, this, [&]() {
stopped = true;
++breaks;
m_client->evaluate("this", 0, -1);
});
- QObject::connect(m_client.data(), &QJSDebugClient::result, this, [&]() {
+ QObject::connect(m_client.data(), &QV4DebugClient::result, this, [&]() {
if (stopped) {
- m_client->continueDebugging(QJSDebugClient::Continue);
+ m_client->continueDebugging(QV4DebugClient::Continue);
stopped = false;
}
});
- QObject::connect(m_client.data(), &QJSDebugClient::failure, this, [&]() {
- qWarning() << "received failure" << m_client->response;
+ QObject::connect(m_client.data(), &QV4DebugClient::failure, this, [&]() {
+ qWarning() << "received failure" << m_client->response().body;
});
m_client->setBreakpoint(file, 34);
@@ -1643,7 +976,7 @@ void tst_QQmlDebugJS::breakOnAnchor()
QList<QQmlDebugClient *> tst_QQmlDebugJS::createClients()
{
- m_client = new QJSDebugClient(m_connection);
+ m_client = new QV4DebugClient(m_connection);
return QList<QQmlDebugClient *>({m_client});
}
@@ -1661,10 +994,9 @@ bool tst_QQmlDebugJS::waitForClientSignal(const char *signal, int timeout)
void tst_QQmlDebugJS::checkVersionParameters()
{
- const QVariantMap value = m_client->parser.call(
- QJSValueList() << QJSValue(QString(m_client->response))).toVariant().toMap();
- QCOMPARE(value.value("command").toString(), QString("version"));
- const QVariantMap body = value.value("body").toMap();
+ const QV4DebugClient::Response value = m_client->response();
+ QCOMPARE(value.command, QString("version"));
+ const QJsonObject body = value.body.toObject();
QCOMPARE(body.value("UnpausedEvaluate").toBool(), true);
QCOMPARE(body.value("ContextEvaluate").toBool(), true);
QCOMPARE(body.value("ChangeBreakpoint").toBool(), true);
diff --git a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro
index 54244c6d16..454a1e3ab0 100644
--- a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro
+++ b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro
@@ -6,8 +6,6 @@ osx:CONFIG -= app_bundle
SOURCES += tst_qqmlenginedebuginspectorintegration.cpp
-include(../shared/qqmlinspectorclient.pri)
-include(../shared/qqmlenginedebugclient.pri)
include(../shared/debugutil.pri)
TESTDATA = data/*
diff --git a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp
index 249416a3b9..980e2be1f1 100644
--- a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp
+++ b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp
@@ -26,12 +26,12 @@
**
****************************************************************************/
-#include "qqmlinspectorclient.h"
-#include "qqmlenginedebugclient.h"
#include "../shared/debugutil_p.h"
#include "../../../shared/util.h"
#include <private/qqmldebugconnection_p.h>
+#include <private/qqmlenginedebugclient_p.h>
+#include <private/qqmlinspectorclient_p.h>
#include <QtTest/qtest.h>
#include <QtTest/qsignalspy.h>
@@ -49,7 +49,7 @@ private:
ConnectResult init(bool restrictServices);
QList<QQmlDebugClient *> createClients() override;
- QmlDebugObjectReference findRootObject();
+ QQmlEngineDebugObjectReference findRootObject();
QPointer<QQmlInspectorClient> m_inspectorClient;
QPointer<QQmlEngineDebugClient> m_engineDebugClient;
@@ -65,23 +65,23 @@ private slots:
void destroyObject();
};
-QmlDebugObjectReference tst_QQmlEngineDebugInspectorIntegration::findRootObject()
+QQmlEngineDebugObjectReference tst_QQmlEngineDebugInspectorIntegration::findRootObject()
{
bool success = false;
m_engineDebugClient->queryAvailableEngines(&success);
if (!QQmlDebugTest::waitForSignal(m_engineDebugClient, SIGNAL(result())))
- return QmlDebugObjectReference();
+ return QQmlEngineDebugObjectReference();
- m_engineDebugClient->queryRootContexts(m_engineDebugClient->engines()[0].debugId, &success);
+ m_engineDebugClient->queryRootContexts(m_engineDebugClient->engines()[0], &success);
if (!QQmlDebugTest::waitForSignal(m_engineDebugClient, SIGNAL(result())))
- return QmlDebugObjectReference();
+ return QQmlEngineDebugObjectReference();
int count = m_engineDebugClient->rootContext().contexts.count();
m_engineDebugClient->queryObject(
m_engineDebugClient->rootContext().contexts[count - 1].objects[0], &success);
if (!QQmlDebugTest::waitForSignal(m_engineDebugClient, SIGNAL(result())))
- return QmlDebugObjectReference();
+ return QQmlEngineDebugObjectReference();
return m_engineDebugClient->object();
}
@@ -121,7 +121,7 @@ void tst_QQmlEngineDebugInspectorIntegration::objectLocationLookup()
QCOMPARE(init(true), ConnectSuccess);
bool success = false;
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(rootObject.debugId != -1);
const QString fileName = QFileInfo(rootObject.source.url.toString()).fileName();
int lineNumber = rootObject.source.lineNumber;
@@ -131,7 +131,7 @@ void tst_QQmlEngineDebugInspectorIntegration::objectLocationLookup()
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_engineDebugClient, SIGNAL(result())));
- foreach (QmlDebugObjectReference child, rootObject.children) {
+ foreach (QQmlEngineDebugObjectReference child, rootObject.children) {
success = false;
lineNumber = child.source.lineNumber;
columnNumber = child.source.columnNumber;
@@ -146,10 +146,10 @@ void tst_QQmlEngineDebugInspectorIntegration::select()
{
QCOMPARE(init(true), ConnectSuccess);
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QList<int> childIds;
int requestId = 0;
- foreach (const QmlDebugObjectReference &child, rootObject.children) {
+ foreach (const QQmlEngineDebugObjectReference &child, rootObject.children) {
requestId = m_inspectorClient->select(QList<int>() << child.debugId);
QTRY_COMPARE(m_recipient->lastResponseId, requestId);
QVERIFY(m_recipient->lastResult);
@@ -171,7 +171,7 @@ void tst_QQmlEngineDebugInspectorIntegration::createObject()
" color: \"blue\"\n"
"}");
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(rootObject.debugId != -1);
QCOMPARE(rootObject.children.length(), 2);
@@ -192,7 +192,7 @@ void tst_QQmlEngineDebugInspectorIntegration::moveObject()
QCOMPARE(init(true), ConnectSuccess);
QCOMPARE(m_inspectorClient->state(), QQmlDebugClient::Enabled);
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(rootObject.debugId != -1);
QCOMPARE(rootObject.children.length(), 2);
@@ -217,7 +217,7 @@ void tst_QQmlEngineDebugInspectorIntegration::destroyObject()
QCOMPARE(init(true), ConnectSuccess);
QCOMPARE(m_inspectorClient->state(), QQmlDebugClient::Enabled);
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(rootObject.debugId != -1);
QCOMPARE(rootObject.children.length(), 2);
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro
index ed4224446e..5ff65ba276 100644
--- a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro
+++ b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro
@@ -5,7 +5,6 @@ osx:CONFIG -= app_bundle
SOURCES += \
tst_qqmlenginedebugservice.cpp
-include(../shared/qqmlenginedebugclient.pri)
include(../shared/debugutil.pri)
DEFINES += QT_QML_DEBUG_NO_WARNING
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
index c613d88b2b..99c90c142f 100644
--- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
+++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
@@ -26,7 +26,6 @@
**
****************************************************************************/
-#include "qqmlenginedebugclient.h"
#include "debugutil_p.h"
#include "../../../shared/util.h"
@@ -36,6 +35,7 @@
#include <private/qqmlmetatype_p.h>
#include <private/qqmlproperty_p.h>
#include <private/qqmldebugconnection_p.h>
+#include <private/qqmlenginedebugclient_p.h>
#include <QtTest/qtest.h>
#include <QtTest/qsignalspy.h>
@@ -60,7 +60,7 @@
#define QVERIFYOBJECT(statement) \
do {\
if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__)) {\
- return QmlDebugObjectReference();\
+ return QQmlEngineDebugObjectReference();\
}\
} while (0)
@@ -126,14 +126,14 @@ public:
tst_QQmlEngineDebugService() : m_conn(nullptr), m_dbg(nullptr), m_engine(nullptr), m_rootItem(nullptr) {}
private:
- QmlDebugObjectReference findRootObject(int context = 0,
+ QQmlEngineDebugObjectReference findRootObject(int context = 0,
bool recursive = false);
- QmlDebugPropertyReference findProperty(
- const QList<QmlDebugPropertyReference> &props,
+ QQmlEngineDebugPropertyReference findProperty(
+ const QList<QQmlEngineDebugPropertyReference> &props,
const QString &name) const;
void recursiveObjectTest(QObject *o,
- const QmlDebugObjectReference &oref,
+ const QQmlEngineDebugObjectReference &oref,
bool recursive) const;
void getContexts();
@@ -182,7 +182,7 @@ private slots:
void createObjectOnDestruction();
};
-QmlDebugObjectReference tst_QQmlEngineDebugService::findRootObject(
+QQmlEngineDebugObjectReference tst_QQmlEngineDebugService::findRootObject(
int context, bool recursive)
{
bool success = false;
@@ -191,7 +191,7 @@ QmlDebugObjectReference tst_QQmlEngineDebugService::findRootObject(
QVERIFYOBJECT(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
QVERIFYOBJECT(m_dbg->engines().count());
- m_dbg->queryRootContexts(m_dbg->engines()[0].debugId, &success);
+ m_dbg->queryRootContexts(m_dbg->engines()[0], &success);
QVERIFYOBJECT(success);
QVERIFYOBJECT(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
@@ -207,18 +207,18 @@ QmlDebugObjectReference tst_QQmlEngineDebugService::findRootObject(
return m_dbg->object();
}
-QmlDebugPropertyReference tst_QQmlEngineDebugService::findProperty(
- const QList<QmlDebugPropertyReference> &props, const QString &name) const
+QQmlEngineDebugPropertyReference tst_QQmlEngineDebugService::findProperty(
+ const QList<QQmlEngineDebugPropertyReference> &props, const QString &name) const
{
- foreach (const QmlDebugPropertyReference &p, props) {
+ foreach (const QQmlEngineDebugPropertyReference &p, props) {
if (p.name == name)
return p;
}
- return QmlDebugPropertyReference();
+ return QQmlEngineDebugPropertyReference();
}
void tst_QQmlEngineDebugService::recursiveObjectTest(
- QObject *o, const QmlDebugObjectReference &oref, bool recursive) const
+ QObject *o, const QQmlEngineDebugObjectReference &oref, bool recursive) const
{
const QMetaObject *meta = o->metaObject();
@@ -236,8 +236,8 @@ void tst_QQmlEngineDebugService::recursiveObjectTest(
int debugId = QQmlDebugService::idForObject(child);
QVERIFY(debugId >= 0);
- QmlDebugObjectReference cref;
- foreach (const QmlDebugObjectReference &ref, oref.children) {
+ QQmlEngineDebugObjectReference cref;
+ foreach (const QQmlEngineDebugObjectReference &ref, oref.children) {
QVERIFY(!ref.className.isEmpty());
if (ref.debugId == debugId) {
cref = ref;
@@ -250,7 +250,7 @@ void tst_QQmlEngineDebugService::recursiveObjectTest(
recursiveObjectTest(child, cref, true);
}
- foreach (const QmlDebugPropertyReference &p, oref.properties) {
+ foreach (const QQmlEngineDebugPropertyReference &p, oref.properties) {
QCOMPARE(p.objectDebugId, QQmlDebugService::idForObject(o));
// signal properties are fake - they are generated from QQmlAbstractBoundSignal children
@@ -269,7 +269,8 @@ void tst_QQmlEngineDebugService::recursiveObjectTest(
QCOMPARE(p.name, QString::fromUtf8(pmeta.name()));
if (pmeta.userType() == QMetaType::QObjectStar) {
- const QmlDebugObjectReference ref = qvariant_cast<QmlDebugObjectReference>(p.value);
+ const QQmlEngineDebugObjectReference ref
+ = qvariant_cast<QQmlEngineDebugObjectReference>(p.value);
QObject *pobj = qvariant_cast<QObject *>(pmeta.read(o));
if (pobj) {
if (pobj->objectName().isEmpty())
@@ -312,9 +313,9 @@ void tst_QQmlEngineDebugService::getContexts()
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
- QList<QmlDebugEngineReference> engines = m_dbg->engines();
+ QList<QQmlEngineDebugEngineReference> engines = m_dbg->engines();
QCOMPARE(engines.count(), 1);
- m_dbg->queryRootContexts(engines.first().debugId, &success);
+ m_dbg->queryRootContexts(engines.first(), &success);
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
@@ -441,7 +442,7 @@ void tst_QQmlEngineDebugService::cleanupTestCase()
void tst_QQmlEngineDebugService::setMethodBody()
{
bool success;
- QmlDebugObjectReference obj = findRootObject(2);
+ QQmlEngineDebugObjectReference obj = findRootObject(2);
QVERIFY(!obj.className.isEmpty());
QObject *root = m_components.at(2);
@@ -483,9 +484,9 @@ void tst_QQmlEngineDebugService::setMethodBody()
void tst_QQmlEngineDebugService::watch_property()
{
- QmlDebugObjectReference obj = findRootObject();
+ QQmlEngineDebugObjectReference obj = findRootObject();
QVERIFY(!obj.className.isEmpty());
- QmlDebugPropertyReference prop = findProperty(obj.properties, "width");
+ QQmlEngineDebugPropertyReference prop = findProperty(obj.properties, "width");
bool success;
@@ -494,7 +495,7 @@ void tst_QQmlEngineDebugService::watch_property()
QVERIFY(!success);
delete unconnected;
- m_dbg->addWatch(QmlDebugPropertyReference(), &success);
+ m_dbg->addWatch(QQmlEngineDebugPropertyReference(), &success);
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
QCOMPARE(m_dbg->valid(), false);
@@ -528,7 +529,7 @@ void tst_QQmlEngineDebugService::watch_property()
void tst_QQmlEngineDebugService::watch_object()
{
- QmlDebugObjectReference obj = findRootObject();
+ QQmlEngineDebugObjectReference obj = findRootObject();
QVERIFY(!obj.className.isEmpty());
bool success;
@@ -538,7 +539,7 @@ void tst_QQmlEngineDebugService::watch_object()
QVERIFY(!success);
delete unconnected;
- m_dbg->addWatch(QmlDebugObjectReference(), &success);
+ m_dbg->addWatch(QQmlEngineDebugObjectReference(), &success);
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
QCOMPARE(m_dbg->valid(), false);
@@ -594,7 +595,7 @@ void tst_QQmlEngineDebugService::watch_expression()
int origWidth = m_rootItem->property("width").toInt();
- QmlDebugObjectReference obj = findRootObject();
+ QQmlEngineDebugObjectReference obj = findRootObject();
QVERIFY(!obj.className.isEmpty());
bool success;
@@ -604,7 +605,7 @@ void tst_QQmlEngineDebugService::watch_expression()
QVERIFY(!success);
delete unconnected;
- m_dbg->addWatch(QmlDebugObjectReference(), expr, &success);
+ m_dbg->addWatch(QQmlEngineDebugObjectReference(), expr, &success);
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
QCOMPARE(m_dbg->valid(), false);
@@ -654,7 +655,7 @@ void tst_QQmlEngineDebugService::watch_expression_data()
void tst_QQmlEngineDebugService::watch_context()
{
- QmlDebugContextReference c;
+ QQmlEngineDebugContextReference c;
QTest::ignoreMessage(QtWarningMsg, "QQmlEngineDebugClient::addWatch(): Not implemented");
bool success;
m_dbg->addWatch(c, QString(), &success);
@@ -663,7 +664,7 @@ void tst_QQmlEngineDebugService::watch_context()
void tst_QQmlEngineDebugService::watch_file()
{
- QmlDebugFileReference f;
+ QQmlEngineDebugFileReference f;
QTest::ignoreMessage(QtWarningMsg, "QQmlEngineDebugClient::addWatch(): Not implemented");
bool success;
m_dbg->addWatch(f, &success);
@@ -684,10 +685,10 @@ void tst_QQmlEngineDebugService::queryAvailableEngines()
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
// TODO test multiple engines
- QList<QmlDebugEngineReference> engines = m_dbg->engines();
+ QList<QQmlEngineDebugEngineReference> engines = m_dbg->engines();
QCOMPARE(engines.count(), 1);
- foreach (const QmlDebugEngineReference &e, engines) {
+ foreach (const QQmlEngineDebugEngineReference &e, engines) {
QCOMPARE(e.debugId, QQmlDebugService::idForObject(m_engine));
QCOMPARE(e.name, m_engine->objectName());
}
@@ -700,19 +701,19 @@ void tst_QQmlEngineDebugService::queryRootContexts()
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
QVERIFY(m_dbg->engines().count());
- int engineId = m_dbg->engines()[0].debugId;
+ const QQmlEngineDebugEngineReference engine = m_dbg->engines()[0];
QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(nullptr);
- unconnected->queryRootContexts(engineId, &success);
+ unconnected->queryRootContexts(engine, &success);
QVERIFY(!success);
delete unconnected;
- m_dbg->queryRootContexts(engineId, &success);
+ m_dbg->queryRootContexts(engine, &success);
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
QQmlContext *actualContext = m_engine->rootContext();
- QmlDebugContextReference context = m_dbg->rootContext();
+ QQmlEngineDebugContextReference context = m_dbg->rootContext();
QCOMPARE(context.debugId, QQmlDebugService::idForObject(actualContext));
QCOMPARE(context.name, actualContext->objectName());
@@ -730,7 +731,7 @@ void tst_QQmlEngineDebugService::queryObject()
bool success;
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(!rootObject.className.isEmpty());
QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(nullptr);
@@ -742,11 +743,11 @@ void tst_QQmlEngineDebugService::queryObject()
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
- QmlDebugObjectReference obj = m_dbg->object();
+ QQmlEngineDebugObjectReference obj = m_dbg->object();
QVERIFY(!obj.className.isEmpty());
// check source as defined in main()
- QmlDebugFileReference source = obj.source;
+ QQmlEngineDebugFileReference source = obj.source;
QCOMPARE(source.url, QUrl::fromLocalFile(""));
QCOMPARE(source.lineNumber, 3);
QCOMPARE(source.columnNumber, 1);
@@ -755,14 +756,14 @@ void tst_QQmlEngineDebugService::queryObject()
recursiveObjectTest(m_rootItem, obj, recursive);
if (recursive) {
- foreach (const QmlDebugObjectReference &child, obj.children) {
+ foreach (const QQmlEngineDebugObjectReference &child, obj.children) {
QVERIFY(!child.className.isEmpty());
QVERIFY(child.properties.count() > 0);
}
- QmlDebugObjectReference rect;
- QmlDebugObjectReference text;
- foreach (const QmlDebugObjectReference &child, obj.children) {
+ QQmlEngineDebugObjectReference rect;
+ QQmlEngineDebugObjectReference text;
+ foreach (const QQmlEngineDebugObjectReference &child, obj.children) {
QVERIFY(!child.className.isEmpty());
if (child.className == "Rectangle")
rect = child;
@@ -777,7 +778,7 @@ void tst_QQmlEngineDebugService::queryObject()
QCOMPARE(findProperty(text.properties, "color").value, qVariantFromValue(QColor("blue")));
} else {
- foreach (const QmlDebugObjectReference &child, obj.children) {
+ foreach (const QQmlEngineDebugObjectReference &child, obj.children) {
QVERIFY(!child.className.isEmpty());
QCOMPARE(child.properties.count(), 0);
}
@@ -798,7 +799,7 @@ void tst_QQmlEngineDebugService::queryObjectsForLocation()
bool success;
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(!rootObject.className.isEmpty());
const QString fileName = QFileInfo(rootObject.source.url.toString()).fileName();
@@ -821,11 +822,11 @@ void tst_QQmlEngineDebugService::queryObjectsForLocation()
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
QCOMPARE(m_dbg->objects().count(), 1);
- QmlDebugObjectReference obj = m_dbg->objects().first();
+ QQmlEngineDebugObjectReference obj = m_dbg->objects().first();
QVERIFY(!obj.className.isEmpty());
// check source as defined in main()
- QmlDebugFileReference source = obj.source;
+ QQmlEngineDebugFileReference source = obj.source;
QCOMPARE(source.url, QUrl(fileName));
QCOMPARE(source.lineNumber, lineNumber);
QCOMPARE(source.columnNumber, columnNumber);
@@ -834,14 +835,14 @@ void tst_QQmlEngineDebugService::queryObjectsForLocation()
recursiveObjectTest(m_rootItem, obj, recursive);
if (recursive) {
- foreach (const QmlDebugObjectReference &child, obj.children) {
+ foreach (const QQmlEngineDebugObjectReference &child, obj.children) {
QVERIFY(!child.className.isEmpty());
QVERIFY(child.properties.count() > 0);
}
- QmlDebugObjectReference rect;
- QmlDebugObjectReference text;
- foreach (const QmlDebugObjectReference &child, obj.children) {
+ QQmlEngineDebugObjectReference rect;
+ QQmlEngineDebugObjectReference text;
+ foreach (const QQmlEngineDebugObjectReference &child, obj.children) {
QVERIFY(!child.className.isEmpty());
if (child.className == "Rectangle")
rect = child;
@@ -856,7 +857,7 @@ void tst_QQmlEngineDebugService::queryObjectsForLocation()
QCOMPARE(findProperty(text.properties, "color").value, qVariantFromValue(QColor("blue")));
} else {
- foreach (const QmlDebugObjectReference &child, obj.children) {
+ foreach (const QQmlEngineDebugObjectReference &child, obj.children) {
QVERIFY(!child.className.isEmpty());
QCOMPARE(child.properties.count(), 0);
}
@@ -873,7 +874,7 @@ void tst_QQmlEngineDebugService::queryObjectsForLocation_data()
void tst_QQmlEngineDebugService::regression_QTCREATORBUG_7451()
{
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(!rootObject.className.isEmpty());
int contextId = rootObject.contextDebugId;
QQmlContext *context = qobject_cast<QQmlContext *>(QQmlDebugService::objectForId(contextId));
@@ -900,7 +901,7 @@ void tst_QQmlEngineDebugService::regression_QTCREATORBUG_7451()
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
- foreach (QmlDebugObjectReference child, rootObject.children) {
+ foreach (QQmlEngineDebugObjectReference child, rootObject.children) {
QVERIFY(!child.className.isEmpty());
success = false;
lineNumber = child.source.lineNumber;
@@ -923,7 +924,7 @@ void tst_QQmlEngineDebugService::regression_QTCREATORBUG_7451()
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
- foreach (QmlDebugObjectReference child, rootObject.children) {
+ foreach (QQmlEngineDebugObjectReference child, rootObject.children) {
QVERIFY(!child.className.isEmpty());
success = false;
lineNumber = child.source.lineNumber;
@@ -939,7 +940,7 @@ void tst_QQmlEngineDebugService::queryObjectWithNonStreamableTypes()
{
bool success;
- QmlDebugObjectReference rootObject = findRootObject(4, true);
+ QQmlEngineDebugObjectReference rootObject = findRootObject(4, true);
QVERIFY(!rootObject.className.isEmpty());
QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(nullptr);
@@ -951,7 +952,7 @@ void tst_QQmlEngineDebugService::queryObjectWithNonStreamableTypes()
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
- QmlDebugObjectReference obj = m_dbg->object();
+ QQmlEngineDebugObjectReference obj = m_dbg->object();
QVERIFY(!obj.className.isEmpty());
QCOMPARE(findProperty(obj.properties, "modelIndex").value,
@@ -962,14 +963,14 @@ void tst_QQmlEngineDebugService::jsonData()
{
bool success;
- QmlDebugObjectReference rootObject = findRootObject(5, true);
+ QQmlEngineDebugObjectReference rootObject = findRootObject(5, true);
QVERIFY(!rootObject.className.isEmpty());
m_dbg->queryObject(rootObject, &success);
QVERIFY(success);
QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
- QmlDebugObjectReference obj = m_dbg->object();
+ QQmlEngineDebugObjectReference obj = m_dbg->object();
QVERIFY(!obj.className.isEmpty());
QCOMPARE(findProperty(obj.properties, "data").value,
@@ -1064,10 +1065,10 @@ void tst_QQmlEngineDebugService::queryExpressionResultBC_data()
void tst_QQmlEngineDebugService::setBindingForObject()
{
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(!rootObject.className.isEmpty());
QVERIFY(rootObject.debugId != -1);
- QmlDebugPropertyReference widthPropertyRef = findProperty(rootObject.properties, "width");
+ QQmlEngineDebugPropertyReference widthPropertyRef = findProperty(rootObject.properties, "width");
QCOMPARE(widthPropertyRef.value, QVariant(10));
QCOMPARE(widthPropertyRef.binding, QString());
@@ -1112,7 +1113,7 @@ void tst_QQmlEngineDebugService::setBindingForObject()
rootObject = findRootObject();
QVERIFY(!rootObject.className.isEmpty());
QCOMPARE(rootObject.children.size(), 5); // Rectangle, Text, MouseArea, Component.onCompleted, NonScriptPropertyElement
- QmlDebugObjectReference mouseAreaObject = rootObject.children.at(2);
+ QQmlEngineDebugObjectReference mouseAreaObject = rootObject.children.at(2);
QVERIFY(!mouseAreaObject.className.isEmpty());
m_dbg->queryObjectRecursive(mouseAreaObject, &success);
QVERIFY(success);
@@ -1120,7 +1121,7 @@ void tst_QQmlEngineDebugService::setBindingForObject()
mouseAreaObject = m_dbg->object();
QCOMPARE(mouseAreaObject.className, QString("MouseArea"));
- QmlDebugPropertyReference onEnteredRef = findProperty(mouseAreaObject.properties, "onEntered");
+ QQmlEngineDebugPropertyReference onEnteredRef = findProperty(mouseAreaObject.properties, "onEntered");
QCOMPARE(onEnteredRef.name, QString("onEntered"));
// Sorry, can't do that anymore: QCOMPARE(onEnteredRef.value, QVariant("{ console.log('hello') }"));
@@ -1149,10 +1150,10 @@ void tst_QQmlEngineDebugService::setBindingForObject()
void tst_QQmlEngineDebugService::resetBindingForObject()
{
- QmlDebugObjectReference rootObject = findRootObject();
+ QQmlEngineDebugObjectReference rootObject = findRootObject();
QVERIFY(!rootObject.className.isEmpty());
QVERIFY(rootObject.debugId != -1);
- QmlDebugPropertyReference widthPropertyRef = findProperty(rootObject.properties, "width");
+ QQmlEngineDebugPropertyReference widthPropertyRef = findProperty(rootObject.properties, "width");
bool success = false;
@@ -1188,7 +1189,7 @@ void tst_QQmlEngineDebugService::resetBindingForObject()
rootObject = findRootObject();
QVERIFY(!rootObject.className.isEmpty());
- QmlDebugPropertyReference boldPropertyRef = findProperty(rootObject.properties, "font.bold");
+ QQmlEngineDebugPropertyReference boldPropertyRef = findProperty(rootObject.properties, "font.bold");
QCOMPARE(boldPropertyRef.value.toBool(), false);
QCOMPARE(boldPropertyRef.binding, QString());
@@ -1200,7 +1201,7 @@ void tst_QQmlEngineDebugService::setBindingInStates()
const int sourceIndex = 3;
- QmlDebugObjectReference obj = findRootObject(sourceIndex);
+ QQmlEngineDebugObjectReference obj = findRootObject(sourceIndex);
QVERIFY(!obj.className.isEmpty());
QVERIFY(obj.debugId != -1);
QVERIFY(obj.children.count() >= 2);
@@ -1233,11 +1234,11 @@ void tst_QQmlEngineDebugService::setBindingInStates()
// change the binding
- QmlDebugObjectReference state = obj.children[1];
+ QQmlEngineDebugObjectReference state = obj.children[1];
QCOMPARE(state.className, QString("State"));
QVERIFY(state.children.count() > 0);
- QmlDebugObjectReference propertyChange = state.children[0];
+ QQmlEngineDebugObjectReference propertyChange = state.children[0];
QVERIFY(!propertyChange.className.isEmpty());
QVERIFY(propertyChange.debugId != -1);
@@ -1316,43 +1317,43 @@ void tst_QQmlEngineDebugService::queryObjectTree()
{
const int sourceIndex = 3;
- QmlDebugObjectReference obj = findRootObject(sourceIndex, true);
+ QQmlEngineDebugObjectReference obj = findRootObject(sourceIndex, true);
QVERIFY(!obj.className.isEmpty());
QVERIFY(obj.debugId != -1);
QVERIFY(obj.children.count() >= 2);
// check state
- QmlDebugObjectReference state = obj.children[1];
+ QQmlEngineDebugObjectReference state = obj.children[1];
QCOMPARE(state.className, QString("State"));
QVERIFY(state.children.count() > 0);
- QmlDebugObjectReference propertyChange = state.children[0];
+ QQmlEngineDebugObjectReference propertyChange = state.children[0];
QVERIFY(!propertyChange.className.isEmpty());
QVERIFY(propertyChange.debugId != -1);
- QmlDebugPropertyReference propertyChangeTarget = findProperty(propertyChange.properties,"target");
+ QQmlEngineDebugPropertyReference propertyChangeTarget = findProperty(propertyChange.properties,"target");
QCOMPARE(propertyChangeTarget.objectDebugId, propertyChange.debugId);
- QmlDebugObjectReference targetReference = qvariant_cast<QmlDebugObjectReference>(propertyChangeTarget.value);
+ QQmlEngineDebugObjectReference targetReference = qvariant_cast<QQmlEngineDebugObjectReference>(propertyChangeTarget.value);
QVERIFY(!targetReference.className.isEmpty());
QCOMPARE(targetReference.debugId, -1);
QCOMPARE(targetReference.name, QString("<unnamed object>"));
// check transition
- QmlDebugObjectReference transition = obj.children[0];
+ QQmlEngineDebugObjectReference transition = obj.children[0];
QCOMPARE(transition.className, QString("Transition"));
QCOMPARE(findProperty(transition.properties,"from").value.toString(), QString("*"));
QCOMPARE(findProperty(transition.properties,"to").value, findProperty(state.properties,"name").value);
QVERIFY(transition.children.count() > 0);
- QmlDebugObjectReference animation = transition.children[0];
+ QQmlEngineDebugObjectReference animation = transition.children[0];
QVERIFY(!animation.className.isEmpty());
QVERIFY(animation.debugId != -1);
- QmlDebugPropertyReference animationTarget = findProperty(animation.properties,"target");
+ QQmlEngineDebugPropertyReference animationTarget = findProperty(animation.properties,"target");
QCOMPARE(animationTarget.objectDebugId, animation.debugId);
- targetReference = qvariant_cast<QmlDebugObjectReference>(animationTarget.value);
+ targetReference = qvariant_cast<QQmlEngineDebugObjectReference>(animationTarget.value);
QVERIFY(!targetReference.className.isEmpty());
QCOMPARE(targetReference.debugId, -1);
QCOMPARE(targetReference.name, QString("<unnamed object>"));
@@ -1362,7 +1363,7 @@ void tst_QQmlEngineDebugService::queryObjectTree()
}
void tst_QQmlEngineDebugService::asynchronousCreate() {
- QmlDebugObjectReference object;
+ QQmlEngineDebugObjectReference object;
auto connection = connect(m_dbg, &QQmlEngineDebugClient::newObject, this, [&](int objectId) {
object.debugId = objectId;
});
diff --git a/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro b/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro
index 3d4473c693..0d42030b52 100644
--- a/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro
+++ b/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro
@@ -6,7 +6,6 @@ osx:CONFIG -= app_bundle
SOURCES += tst_qqmlinspector.cpp
-include(../shared/qqmlinspectorclient.pri)
include(../shared/debugutil.pri)
TESTDATA = data/*
diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
index 5c9506eb21..6685558bb5 100644
--- a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
+++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
@@ -26,12 +26,12 @@
**
****************************************************************************/
-#include "qqmlinspectorclient.h"
#include "../shared/debugutil_p.h"
#include "../shared/qqmldebugprocess_p.h"
#include "../../../shared/util.h"
#include <private/qqmldebugconnection_p.h>
+#include <private/qqmlinspectorclient_p.h>
#include <QtTest/qtest.h>
#include <QtTest/qsignalspy.h>
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
index e0bd5413fe..085eb7b87a 100644
--- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
@@ -201,7 +201,7 @@ private:
CheckType = CheckMessageType | CheckDetailType | CheckLine | CheckColumn | CheckFileEndsWith
};
- ConnectResult connect(bool block, const QString &testFile, bool recordFromStart = true,
+ ConnectResult connect(bool block, const QString &file, bool recordFromStart = true,
uint flushInterval = 0, bool restrictServices = true,
const QString &executable
= QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene");
@@ -209,8 +209,8 @@ private:
void checkTraceReceived();
void checkJsHeap();
bool verify(MessageListType type, int expectedPosition,
- const QQmlProfilerEventType &expectedType, quint32 checks,
- const QVector<qint64> &numbers);
+ const QQmlProfilerEventType &expected, quint32 checks,
+ const QVector<qint64> &expectedNumbers);
QList<QQmlDebugClient *> createClients() override;
QScopedPointer<QQmlProfilerTestClient> m_client;
@@ -235,7 +235,7 @@ private slots:
private:
bool m_recordFromStart = true;
- bool m_flushInterval = 0;
+ bool m_flushInterval = false;
bool m_isComplete = false;
// Don't use ({...}) here as MSVC will interpret that as the "QVector(int size)" ctor.
@@ -305,7 +305,7 @@ void tst_QQmlProfilerService::checkJsHeap()
qint64 used = 0;
qint64 lastTimestamp = -1;
foreach (const QQmlProfilerEvent &message, m_client->jsHeapMessages) {
- const qint64 amount = message.number<qint64>(0);
+ const auto amount = message.number<qint64>(0);
const QQmlProfilerEventType &type = m_client->types.at(message.typeIndex());
switch (type.detailType()) {
case HeapPage:
@@ -328,10 +328,11 @@ void tst_QQmlProfilerService::checkJsHeap()
if (lastTimestamp == -1) {
lastTimestamp = message.timestamp();
continue;
- } else if (message.timestamp() == lastTimestamp) {
- continue;
}
+ if (message.timestamp() == lastTimestamp)
+ continue;
+
lastTimestamp = message.timestamp();
QVERIFY2(used >= 0, QString::fromLatin1("Negative memory usage seen: %1")
@@ -759,7 +760,7 @@ void tst_QQmlProfilerService::memory()
QVERIFY(m_client);
int smallItems = 0;
- for (auto message : m_client->jsHeapMessages) {
+ for (const auto& message : m_client->jsHeapMessages) {
const QQmlProfilerEventType &type = m_client->types[message.typeIndex()];
if (type.detailType() == SmallItem)
++smallItems;
@@ -793,7 +794,7 @@ void tst_QQmlProfilerService::compile()
checkJsHeap();
Message rangeStage = MaximumMessage;
- for (auto message : m_client->qmlMessages) {
+ for (const auto& message : m_client->qmlMessages) {
const QQmlProfilerEventType &type = m_client->types[message.typeIndex()];
if (type.rangeType() == Compiling) {
switch (rangeStage) {
diff --git a/tests/auto/qml/debugger/shared/qqmldebugprocess.cpp b/tests/auto/qml/debugger/shared/qqmldebugprocess.cpp
index 6f74edf863..956e97e7ba 100644
--- a/tests/auto/qml/debugger/shared/qqmldebugprocess.cpp
+++ b/tests/auto/qml/debugger/shared/qqmldebugprocess.cpp
@@ -46,7 +46,7 @@ QQmlDebugProcess::QQmlDebugProcess(const QString &executable, QObject *parent)
this, &QQmlDebugProcess::processAppOutput);
connect(&m_process, &QProcess::errorOccurred,
this, &QQmlDebugProcess::processError);
- connect(&m_process, QOverload<int>::of(&QProcess::finished),
+ connect(&m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
this, [this]() {
m_timer.stop();
m_eventLoop.quit();
diff --git a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.h b/tests/auto/qml/debugger/shared/qqmlenginedebugclient.h
deleted file mode 100644
index 5d74f2d43c..0000000000
--- a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.h
+++ /dev/null
@@ -1,233 +0,0 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
-
-#ifndef QQMLENGINEDEBUGCLIENT_H
-#define QQMLENGINEDEBUGCLIENT_H
-
-#include <private/qqmldebugclient_p.h>
-#include <private/qpacket_p.h>
-
-#include <QtCore/qurl.h>
-#include <QtCore/qvariant.h>
-
-struct QmlDebugPropertyReference
-{
- QmlDebugPropertyReference()
- : objectDebugId(-1), hasNotifySignal(false)
- {
- }
-
- QmlDebugPropertyReference &operator=(
- const QmlDebugPropertyReference &o)
- {
- objectDebugId = o.objectDebugId; name = o.name; value = o.value;
- valueTypeName = o.valueTypeName; binding = o.binding;
- hasNotifySignal = o.hasNotifySignal;
- return *this;
- }
-
- int objectDebugId;
- QString name;
- QVariant value;
- QString valueTypeName;
- QString binding;
- bool hasNotifySignal;
-};
-
-struct QmlDebugFileReference
-{
- QmlDebugFileReference()
- : lineNumber(-1), columnNumber(-1)
- {
- }
-
- QmlDebugFileReference &operator=(
- const QmlDebugFileReference &o)
- {
- url = o.url; lineNumber = o.lineNumber; columnNumber = o.columnNumber;
- return *this;
- }
-
- QUrl url;
- int lineNumber;
- int columnNumber;
-};
-
-struct QmlDebugObjectReference
-{
- QmlDebugObjectReference()
- : debugId(-1), contextDebugId(-1)
- {
- }
-
- QmlDebugObjectReference(int id)
- : debugId(id), contextDebugId(-1)
- {
- }
-
- QmlDebugObjectReference &operator=(
- const QmlDebugObjectReference &o)
- {
- debugId = o.debugId; className = o.className; idString = o.idString;
- name = o.name; source = o.source; contextDebugId = o.contextDebugId;
- properties = o.properties; children = o.children;
- return *this;
- }
- int debugId;
- QString className;
- QString idString;
- QString name;
- QmlDebugFileReference source;
- int contextDebugId;
- QList<QmlDebugPropertyReference> properties;
- QList<QmlDebugObjectReference> children;
-};
-
-Q_DECLARE_METATYPE(QmlDebugObjectReference)
-
-struct QmlDebugContextReference
-{
- QmlDebugContextReference()
- : debugId(-1)
- {
- }
-
- QmlDebugContextReference &operator=(
- const QmlDebugContextReference &o)
- {
- debugId = o.debugId; name = o.name; objects = o.objects;
- contexts = o.contexts;
- return *this;
- }
-
- int debugId;
- QString name;
- QList<QmlDebugObjectReference> objects;
- QList<QmlDebugContextReference> contexts;
-};
-
-struct QmlDebugEngineReference
-{
- QmlDebugEngineReference()
- : debugId(-1)
- {
- }
-
- QmlDebugEngineReference(int id)
- : debugId(id)
- {
- }
-
- QmlDebugEngineReference &operator=(
- const QmlDebugEngineReference &o)
- {
- debugId = o.debugId; name = o.name;
- return *this;
- }
-
- int debugId;
- QString name;
-};
-
-class QQmlEngineDebugClient : public QQmlDebugClient
-{
- Q_OBJECT
-public:
- explicit QQmlEngineDebugClient(QQmlDebugConnection *conn);
-
- quint32 addWatch(const QmlDebugPropertyReference &,
- bool *success);
- quint32 addWatch(const QmlDebugContextReference &, const QString &,
- bool *success);
- quint32 addWatch(const QmlDebugObjectReference &, const QString &,
- bool *success);
- quint32 addWatch(const QmlDebugObjectReference &,
- bool *success);
- quint32 addWatch(const QmlDebugFileReference &,
- bool *success);
-
- void removeWatch(quint32 watch, bool *success);
-
- quint32 queryAvailableEngines(bool *success);
- quint32 queryRootContexts(const QmlDebugEngineReference &,
- bool *success);
- quint32 queryObject(const QmlDebugObjectReference &,
- bool *success);
- quint32 queryObjectsForLocation(const QString &file,
- int lineNumber, int columnNumber, bool *success);
- quint32 queryObjectRecursive(const QmlDebugObjectReference &,
- bool *success);
- quint32 queryObjectsForLocationRecursive(const QString &file,
- int lineNumber, int columnNumber, bool *success);
- quint32 queryExpressionResult(int objectDebugId,
- const QString &expr,
- bool *success);
- quint32 queryExpressionResultBC(int objectDebugId,
- const QString &expr,
- bool *success);
- quint32 setBindingForObject(int objectDebugId, const QString &propertyName,
- const QVariant &bindingExpression,
- bool isLiteralValue,
- QString source, int line, bool *success);
- quint32 resetBindingForObject(int objectDebugId,
- const QString &propertyName, bool *success);
- quint32 setMethodBody(int objectDebugId, const QString &methodName,
- const QString &methodBody, bool *success);
-
- quint32 getId() { return m_nextId++; }
-
- void decode(QPacket &ds, QmlDebugContextReference &);
- void decode(QPacket &ds, QmlDebugObjectReference &, bool simple);
- void decode(QPacket &ds, QList<QmlDebugObjectReference> &o, bool simple);
-
- QList<QmlDebugEngineReference> engines() { return m_engines; }
- QmlDebugContextReference rootContext() { return m_rootContext; }
- QmlDebugObjectReference object() { return m_object; }
- QList<QmlDebugObjectReference> objects() { return m_objects; }
- QVariant resultExpr() { return m_exprResult; }
- bool valid() { return m_valid; }
-
-signals:
- void newObject(int objectId);
- void valueChanged(QByteArray,QVariant);
- void result();
-
-protected:
- void messageReceived(const QByteArray &);
-
-private:
- quint32 m_nextId;
- bool m_valid;
- QList<QmlDebugEngineReference> m_engines;
- QmlDebugContextReference m_rootContext;
- QmlDebugObjectReference m_object;
- QList<QmlDebugObjectReference> m_objects;
- QVariant m_exprResult;
-};
-
-#endif // QQMLENGINEDEBUGCLIENT_H
diff --git a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.pri b/tests/auto/qml/debugger/shared/qqmlenginedebugclient.pri
deleted file mode 100644
index a969b4f153..0000000000
--- a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.pri
+++ /dev/null
@@ -1,3 +0,0 @@
-HEADERS += $$PWD/qqmlenginedebugclient.h
-
-SOURCES += $$PWD/qqmlenginedebugclient.cpp
diff --git a/tests/auto/qml/debugger/shared/qqmlinspectorclient.pri b/tests/auto/qml/debugger/shared/qqmlinspectorclient.pri
deleted file mode 100644
index c136e1313a..0000000000
--- a/tests/auto/qml/debugger/shared/qqmlinspectorclient.pri
+++ /dev/null
@@ -1,3 +0,0 @@
-HEADERS += $$PWD/qqmlinspectorclient.h
-
-SOURCES += $$PWD/qqmlinspectorclient.cpp
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 0b1f1e0bca..620e31e01a 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -505,7 +505,7 @@ void tst_QJSEngine::newVariant_valueOfToString()
QJSValue value = object.property("valueOf").callWithInstance(object);
QVERIFY(value.isObject());
QVERIFY(value.strictlyEquals(object));
- QCOMPARE(object.toString(), QString::fromLatin1("QVariant(QPoint)"));
+ QCOMPARE(object.toString(), QString::fromLatin1("QVariant(QPoint, QPoint(10,20))"));
}
}
@@ -3157,7 +3157,7 @@ void tst_QJSEngine::dateRoundtripJSQtJS()
#ifdef Q_OS_WIN
QSKIP("This test fails on Windows due to a bug in QDateTime.");
#endif
- uint secs = QDateTime(QDate(2009, 1, 1)).toUTC().toTime_t();
+ qint64 secs = QDateTime(QDate(2009, 1, 1)).toUTC().toSecsSinceEpoch();
QJSEngine eng;
for (int i = 0; i < 8000; ++i) {
QJSValue jsDate = eng.evaluate(QString::fromLatin1("new Date(%0)").arg(secs * 1000.0));
@@ -3190,7 +3190,7 @@ void tst_QJSEngine::dateConversionJSQt()
#ifdef Q_OS_WIN
QSKIP("This test fails on Windows due to a bug in QDateTime.");
#endif
- uint secs = QDateTime(QDate(2009, 1, 1)).toUTC().toTime_t();
+ qint64 secs = QDateTime(QDate(2009, 1, 1)).toUTC().toSecsSinceEpoch();
QJSEngine eng;
for (int i = 0; i < 8000; ++i) {
QJSValue jsDate = eng.evaluate(QString::fromLatin1("new Date(%0)").arg(secs * 1000.0));
@@ -3681,7 +3681,7 @@ void tst_QJSEngine::translateScript()
QJSEngine engine;
TranslationScope tranScope(":/translations/translatable_la");
- engine.installTranslatorFunctions();
+ engine.installExtensions(QJSEngine::TranslationExtension);
QCOMPARE(engine.evaluate(expression, fileName).toString(), expectedTranslation);
}
@@ -3690,7 +3690,7 @@ void tst_QJSEngine::translateScript_crossScript()
{
QJSEngine engine;
TranslationScope tranScope(":/translations/translatable_la");
- engine.installTranslatorFunctions();
+ engine.installExtensions(QJSEngine::TranslationExtension);
QString fileName = QString::fromLatin1("translatable.js");
QString fileName2 = QString::fromLatin1("translatable2.js");
@@ -3712,7 +3712,7 @@ void tst_QJSEngine::translateScript_trNoOp()
{
QJSEngine engine;
TranslationScope tranScope(":/translations/translatable_la");
- engine.installTranslatorFunctions();
+ engine.installExtensions(QJSEngine::TranslationExtension);
QVERIFY(engine.evaluate("QT_TR_NOOP()").isUndefined());
QCOMPARE(engine.evaluate("QT_TR_NOOP('One')").toString(), QString::fromLatin1("One"));
@@ -3726,7 +3726,7 @@ void tst_QJSEngine::translateScript_callQsTrFromCpp()
{
QJSEngine engine;
TranslationScope tranScope(":/translations/translatable_la");
- engine.installTranslatorFunctions();
+ engine.installExtensions(QJSEngine::TranslationExtension);
// There is no context, but it shouldn't crash
QCOMPARE(engine.globalObject().property("qsTr").call(QJSValueList() << "One").toString(), QString::fromLatin1("One"));
@@ -3759,7 +3759,7 @@ void tst_QJSEngine::translateWithInvalidArgs()
QFETCH(QString, expression);
QFETCH(QString, expectedError);
QJSEngine engine;
- engine.installTranslatorFunctions();
+ engine.installExtensions(QJSEngine::TranslationExtension);
QJSValue result = engine.evaluate(expression);
QVERIFY(result.isError());
QCOMPARE(result.toString(), expectedError);
@@ -3795,7 +3795,7 @@ void tst_QJSEngine::translationContext()
TranslationScope tranScope(":/translations/translatable_la");
QJSEngine engine;
- engine.installTranslatorFunctions();
+ engine.installExtensions(QJSEngine::TranslationExtension);
QFETCH(QString, path);
QFETCH(QString, text);
@@ -3810,7 +3810,7 @@ void tst_QJSEngine::translateScriptIdBased()
QJSEngine engine;
TranslationScope tranScope(":/translations/idtranslatable_la");
- engine.installTranslatorFunctions();
+ engine.installExtensions(QJSEngine::TranslationExtension);
QString fileName = QString::fromLatin1("idtranslatable.js");
@@ -3892,7 +3892,7 @@ void tst_QJSEngine::translateScriptUnicode()
QJSEngine engine;
TranslationScope tranScope(":/translations/translatable-unicode");
- engine.installTranslatorFunctions();
+ engine.installExtensions(QJSEngine::TranslationExtension);
QCOMPARE(engine.evaluate(expression, fileName).toString(), expectedTranslation);
}
@@ -3922,7 +3922,7 @@ void tst_QJSEngine::translateScriptUnicodeIdBased()
QJSEngine engine;
TranslationScope tranScope(":/translations/idtranslatable-unicode");
- engine.installTranslatorFunctions();
+ engine.installExtensions(QJSEngine::TranslationExtension);
QCOMPARE(engine.evaluate(expression).toString(), expectedTranslation);
}
@@ -3930,7 +3930,7 @@ void tst_QJSEngine::translateScriptUnicodeIdBased()
void tst_QJSEngine::translateFromBuiltinCallback()
{
QJSEngine eng;
- eng.installTranslatorFunctions();
+ eng.installExtensions(QJSEngine::TranslationExtension);
// Callback has no translation context.
eng.evaluate("function foo() { qsTr('foo'); }");
diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
index f9718e3699..b58cd98d1e 100644
--- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
+++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
@@ -405,7 +405,7 @@ void tst_QJSValue::toString()
// then fall back to "QVariant(typename)"
QJSValue variant = eng.toScriptValue(QPoint(10, 20));
QVERIFY(variant.isVariant());
- QCOMPARE(variant.toString(), QString::fromLatin1("QVariant(QPoint)"));
+ QCOMPARE(variant.toString(), QString::fromLatin1("QVariant(QPoint, QPoint(10,20))"));
variant = eng.toScriptValue(QUrl());
QVERIFY(variant.isVariant());
QVERIFY(variant.toString().isEmpty());
diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro
index 7cfddf0eaf..5448088ee5 100644
--- a/tests/auto/qml/qml.pro
+++ b/tests/auto/qml/qml.pro
@@ -104,3 +104,7 @@ qtConfig(private_tests): \
qtNomakeTools( \
qmlplugindump \
)
+
+QtConfig(qml_tracing) {
+ PRIVATETESTS += v4traced
+}
diff --git a/tests/auto/qml/qmlcachegen/data/Retain.qml b/tests/auto/qml/qmlcachegen/data/Retain.qml
new file mode 100644
index 0000000000..0e69012662
--- /dev/null
+++ b/tests/auto/qml/qmlcachegen/data/Retain.qml
@@ -0,0 +1,2 @@
+import QtQml 2.0
+QtObject {}
diff --git a/tests/auto/qml/qmlcachegen/qmlcachegen.pro b/tests/auto/qml/qmlcachegen/qmlcachegen.pro
index 7f8e93d101..7bd4414302 100644
--- a/tests/auto/qml/qmlcachegen/qmlcachegen.pro
+++ b/tests/auto/qml/qmlcachegen/qmlcachegen.pro
@@ -24,9 +24,12 @@ workerscripts_test.prefix = /workerscripts
RESOURCES += \
workerscripts_test \
- trickypaths.qrc
+ trickypaths.qrc \
+ retain.qrc
# QTBUG-46375
!win32: RESOURCES += trickypaths_umlaut.qrc
+QTQUICK_COMPILER_RETAINED_RESOURCES += retain.qrc
+
QT += core-private qml-private testlib
diff --git a/tests/auto/qml/qmlcachegen/retain.qrc b/tests/auto/qml/qmlcachegen/retain.qrc
new file mode 100644
index 0000000000..e5eed9b12f
--- /dev/null
+++ b/tests/auto/qml/qmlcachegen/retain.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file alias="Retain.qml">data/Retain.qml</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
index e290f21986..5462e6c8ae 100644
--- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
+++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
@@ -54,6 +54,7 @@ private slots:
void aheadOfTimeCompilation();
void functionExpressions();
void versionChecksForAheadOfTimeUnits();
+ void retainedResources();
void workerScripts();
@@ -401,6 +402,13 @@ void tst_qmlcachegen::versionChecksForAheadOfTimeUnits()
QQmlMetaType::removeCachedUnitLookupFunction(testHandler);
}
+void tst_qmlcachegen::retainedResources()
+{
+ QFile file(":/Retain.qml");
+ QVERIFY(file.open(QIODevice::ReadOnly));
+ QVERIFY(file.readAll().startsWith("import QtQml 2.0"));
+}
+
void tst_qmlcachegen::workerScripts()
{
QVERIFY(QFile::exists(":/workerscripts/data/worker.js"));
diff --git a/tests/auto/qml/qqmlconsole/data/logging.qml b/tests/auto/qml/qqmlconsole/data/logging.qml
index 0764ad7545..1f929d311b 100644
--- a/tests/auto/qml/qqmlconsole/data/logging.qml
+++ b/tests/auto/qml/qqmlconsole/data/logging.qml
@@ -68,6 +68,8 @@ QtObject {
console.log(1, ["ping","pong"], new Object, 2);
console.log(contextStringListProperty);
+ console.log(customObject);
+ console.log([[1,2,3,[2,2,2,2],4],[5,6,7,8]]);
try {
console.log(exception);
diff --git a/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp
index 817ca0a257..b157314071 100644
--- a/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp
+++ b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp
@@ -51,6 +51,15 @@ private:
QQmlEngine engine;
};
+struct CustomObject {};
+
+QDebug operator<<(QDebug dbg, const CustomObject &)
+{
+ return dbg << "MY OBJECT";
+}
+
+Q_DECLARE_METATYPE(CustomObject)
+
void tst_qqmlconsole::logging()
{
QUrl testUrl = testFileUrl("logging.qml");
@@ -83,11 +92,17 @@ void tst_qqmlconsole::logging()
QTest::ignoreMessage(QtDebugMsg, "1 pong! [object Object]");
QTest::ignoreMessage(QtDebugMsg, "1 [ping,pong] [object Object] 2");
QTest::ignoreMessage(QtDebugMsg, "[Hello,World]");
+ QTest::ignoreMessage(QtDebugMsg, "QVariant(CustomObject, MY OBJECT)");
+ QTest::ignoreMessage(QtDebugMsg, "[[1,2,3,[2,2,2,2],4],[5,6,7,8]]");
QScopedPointer<QQmlContext> loggingContext(new QQmlContext(engine.rootContext()));
QStringList stringList; stringList << QStringLiteral("Hello") << QStringLiteral("World");
loggingContext->setContextProperty("contextStringListProperty", stringList);
+ CustomObject customObject;
+ QVERIFY(QMetaType::registerDebugStreamOperator<CustomObject>());
+ loggingContext->setContextProperty("customObject", QVariant::fromValue(customObject));
+
QQmlComponent component(&engine, testUrl);
QScopedPointer<QObject> object(component.create(loggingContext.data()));
QVERIFY(object != nullptr);
diff --git a/tests/auto/qml/qqmlecmascript/data/qmlVarNullBinding.qml b/tests/auto/qml/qqmlecmascript/data/qmlVarNullBinding.qml
new file mode 100644
index 0000000000..6666b85ffd
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/qmlVarNullBinding.qml
@@ -0,0 +1,7 @@
+import QtQml 2.2
+
+QtObject {
+ property var foo: null
+ property bool signalSeen: false
+ onFooChanged: signalSeen = true
+}
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h
index 8d89df31db..4547a74470 100644
--- a/tests/auto/qml/qqmlecmascript/testtypes.h
+++ b/tests/auto/qml/qqmlecmascript/testtypes.h
@@ -1502,7 +1502,7 @@ public:
}
break;
case Qt::OffsetFromUTC:
- m_offset = m_datetime.utcOffset() / 60;
+ m_offset = m_datetime.offsetFromUtc() / 60;
m_timespec = QString("%1%2:%3").arg(m_offset < 0 ? '-' : '+')
.arg(abs(m_offset) / 60)
.arg(abs(m_offset) % 60);
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 0e8844d23f..90ff6f24fa 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -523,22 +523,22 @@ void tst_qqmlecmascript::exportDate_data()
QTest::newRow("UTC late") << testFileUrl("exportDate.4.qml") << QDateTime(date, late, Qt::UTC);
{
QDateTime dt(date, early, Qt::OffsetFromUTC);
- dt.setUtcOffset(offset);
+ dt.setOffsetFromUtc(offset);
QTest::newRow("+11:30 early") << testFileUrl("exportDate.5.qml") << dt;
}
{
QDateTime dt(date, late, Qt::OffsetFromUTC);
- dt.setUtcOffset(offset);
+ dt.setOffsetFromUtc(offset);
QTest::newRow("+11:30 late") << testFileUrl("exportDate.6.qml") << dt;
}
{
QDateTime dt(date, early, Qt::OffsetFromUTC);
- dt.setUtcOffset(-offset);
+ dt.setOffsetFromUtc(-offset);
QTest::newRow("-11:30 early") << testFileUrl("exportDate.7.qml") << dt;
}
{
QDateTime dt(date, late, Qt::OffsetFromUTC);
- dt.setUtcOffset(-offset);
+ dt.setOffsetFromUtc(-offset);
QTest::newRow("-11:30 late") << testFileUrl("exportDate.8.qml") << dt;
}
}
@@ -5997,6 +5997,13 @@ void tst_qqmlecmascript::nullObjectInitializer()
QVERIFY(value.userType() == qMetaTypeId<QObject*>());
QVERIFY(!value.value<QObject*>());
}
+
+ {
+ QQmlComponent component(&engine, testFileUrl("qmlVarNullBinding.qml"));
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+ QVERIFY(!obj->property("signalSeen").toBool());
+ }
}
// Test that bindings don't evaluate once the engine has been destroyed
diff --git a/tests/auto/qml/qqmllanguage/data/assignComponentToWrongType.errors.txt b/tests/auto/qml/qqmllanguage/data/assignComponentToWrongType.errors.txt
new file mode 100644
index 0000000000..af103cf8bf
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/assignComponentToWrongType.errors.txt
@@ -0,0 +1 @@
+4:27:Cannot assign object of type "Component" to property of type "QQmlTimer*" as the former is neither the same as the latter nor a sub-class of it.
diff --git a/tests/auto/qml/qqmllanguage/data/assignComponentToWrongType.qml b/tests/auto/qml/qqmllanguage/data/assignComponentToWrongType.qml
new file mode 100644
index 0000000000..2159bf8116
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/assignComponentToWrongType.qml
@@ -0,0 +1,9 @@
+import QtQml 2.9
+
+QtObject {
+ property Timer stuff: Component {
+ QtObject {
+ objectName: "wrong"
+ }
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index dea7c6c7ee..22ea3a89c3 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -612,6 +612,8 @@ void tst_qqmllanguage::errors_data()
QTest::newRow("badCompositeRegistration.1") << "badCompositeRegistration.1.qml" << "badCompositeRegistration.1.errors.txt" << false;
QTest::newRow("badCompositeRegistration.2") << "badCompositeRegistration.2.qml" << "badCompositeRegistration.2.errors.txt" << false;
+
+ QTest::newRow("assignComponentToWrongType") << "assignComponentToWrongType.qml" << "assignComponentToWrongType.errors.txt" << false;
}
diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
index 71dd900073..fead8c4ebc 100644
--- a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
+++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
@@ -234,8 +234,8 @@ void tst_qqmlparser::stringLiteral()
auto *literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(expression);
QVERIFY(literal);
QCOMPARE(literal->value, "hello string");
- QCOMPARE(literal->firstSourceLocation().begin(), 0);
- QCOMPARE(literal->lastSourceLocation().end(), code.size());
+ QCOMPARE(literal->firstSourceLocation().begin(), 0u);
+ QCOMPARE(literal->lastSourceLocation().end(), quint32(code.size()));
}
void tst_qqmlparser::noSubstitutionTemplateLiteral()
@@ -255,8 +255,8 @@ void tst_qqmlparser::noSubstitutionTemplateLiteral()
QVERIFY(literal);
QCOMPARE(literal->value, "hello template");
- QCOMPARE(literal->firstSourceLocation().begin(), 0);
- QCOMPARE(literal->lastSourceLocation().end(), code.size());
+ QCOMPARE(literal->firstSourceLocation().begin(), 0u);
+ QCOMPARE(literal->lastSourceLocation().end(), quint32(code.size()));
}
void tst_qqmlparser::templateLiteral()
@@ -275,7 +275,7 @@ void tst_qqmlparser::templateLiteral()
auto *templateLiteral = QQmlJS::AST::cast<QQmlJS::AST::TemplateLiteral *>(expression);
QVERIFY(templateLiteral);
- QCOMPARE(templateLiteral->firstSourceLocation().begin(), 0);
+ QCOMPARE(templateLiteral->firstSourceLocation().begin(), 0u);
auto *e = templateLiteral->expression;
QVERIFY(e);
}
diff --git a/tests/auto/qml/qqmlpropertycache/data/foreignEnums.qml b/tests/auto/qml/qqmlpropertycache/data/foreignEnums.qml
index 7ceb231c8d..b7492e507e 100644
--- a/tests/auto/qml/qqmlpropertycache/data/foreignEnums.qml
+++ b/tests/auto/qml/qqmlpropertycache/data/foreignEnums.qml
@@ -7,5 +7,11 @@ QtObject {
mydata.opt1 = opt1;
mydata.setOpt1(opt1);
mydata.setOption1(opt1);
+
+ var opt2 = mydata.opt2;
+ opt2 = (opt2 === MyEnum.Short8 ? MyEnum.Short16 : MyEnum.Short0);
+ mydata.opt2 = opt2;
+ mydata.setOpt2(opt2);
+ mydata.setOption2(opt2);
}
}
diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
index 69c6ce2d35..02b5302a45 100644
--- a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
+++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
@@ -312,17 +312,27 @@ class MyEnum : public QObject
};
Q_DECLARE_FLAGS(Option1, Option1Flag)
Q_FLAG(Option1)
+
+ enum ShortEnum: quint16 {
+ Short0 = 0,
+ Short8 = 0xff,
+ Short16 = 0xffff
+ };
+ Q_ENUM(ShortEnum);
};
class MyData : public QObject
{
Q_OBJECT
Q_PROPERTY(MyEnum::Option1 opt1 READ opt1 WRITE setOpt1 NOTIFY opt1Changed)
+ Q_PROPERTY(MyEnum::ShortEnum opt2 READ opt2 WRITE setOpt2 NOTIFY opt2Changed)
public:
MyEnum::Option1 opt1() const { return m_opt1; }
+ MyEnum::ShortEnum opt2() const { return m_opt2; }
signals:
void opt1Changed(MyEnum::Option1 opt1);
+ void opt2Changed(MyEnum::ShortEnum opt2);
public slots:
void setOpt1(MyEnum::Option1 opt1)
@@ -334,10 +344,21 @@ public slots:
}
}
+ void setOpt2(MyEnum::ShortEnum opt2)
+ {
+ QCOMPARE(opt2, MyEnum::Short16);
+ if (opt2 != m_opt2) {
+ m_opt2 = opt2;
+ emit opt2Changed(opt2);
+ }
+ }
+
void setOption1(MyEnum::Option1 opt1) { setOpt1(opt1); }
+ void setOption2(MyEnum::ShortEnum opt2) { setOpt2(opt2); }
private:
MyEnum::Option1 m_opt1 = MyEnum::Option10;
+ MyEnum::ShortEnum m_opt2 = MyEnum::Short8;
};
void tst_qqmlpropertycache::passForeignEnums()
@@ -354,11 +375,14 @@ void tst_qqmlpropertycache::passForeignEnums()
QQmlComponent component(&engine, testFile("foreignEnums.qml"));
QVERIFY(component.isReady());
- QObject *obj = component.create(engine.rootContext());
+ QScopedPointer<QObject> obj(component.create(engine.rootContext()));
+ QVERIFY(!obj.isNull());
QCOMPARE(data.opt1(), MyEnum::Option1AD);
+ QCOMPARE(data.opt2(), MyEnum::Short16);
}
Q_DECLARE_METATYPE(MyEnum::Option1)
+Q_DECLARE_METATYPE(MyEnum::ShortEnum)
QT_BEGIN_NAMESPACE
class SimpleGadget
diff --git a/tests/auto/qml/qqmlsqldatabase/data/changeVersion.qml b/tests/auto/qml/qqmlsqldatabase/data/changeVersion.qml
new file mode 100644
index 0000000000..7d2683d869
--- /dev/null
+++ b/tests/auto/qml/qqmlsqldatabase/data/changeVersion.qml
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQml 2.2
+import QtQuick.LocalStorage 2.0
+
+QtObject {
+ property var db;
+ property string version;
+
+ function create() {
+ db = LocalStorage.openDatabaseSync("testdb", "2", "stuff for testing", 100000);
+ version = db.version;
+ }
+
+ function upgrade() {
+ db = db.changeVersion(db.version, "22", function(y) {});
+ version = db.version;
+ }
+}
diff --git a/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp b/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp
index f1dcefdab6..28f9c9a0c2 100644
--- a/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp
+++ b/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp
@@ -63,6 +63,7 @@ private slots:
void testQml_cleanopen_data();
void testQml_cleanopen();
void totalDatabases();
+ void upgradeDatabase();
void cleanupTestCase();
@@ -200,6 +201,22 @@ void tst_qqmlsqldatabase::totalDatabases()
QCOMPARE(QDir(dbDir()+"/Databases").entryInfoList(QDir::Files|QDir::NoDotAndDotDot).count(), total_databases_created_by_tests*2);
}
+void tst_qqmlsqldatabase::upgradeDatabase()
+{
+ QQmlComponent component(engine, testFile("changeVersion.qml"));
+ QVERIFY(component.isReady());
+
+ QObject *object = component.create();
+ QVERIFY(object);
+ QVERIFY(object->property("version").toString().isEmpty());
+
+ QVERIFY(QMetaObject::invokeMethod(object, "create"));
+ QCOMPARE(object->property("version").toString(), QLatin1String("2"));
+
+ QVERIFY(QMetaObject::invokeMethod(object, "upgrade"));
+ QCOMPARE(object->property("version").toString(), QLatin1String("22"));
+}
+
QTEST_MAIN(tst_qqmlsqldatabase)
#include "tst_qqmlsqldatabase.moc"
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
index 1ee4510e30..6ccfc77c25 100644
--- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
+++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
@@ -90,6 +90,7 @@ private slots:
void customValueTypeInQml();
void gadgetInheritance();
void gadgetTemplateInheritance();
+ void sequences();
void toStringConversion();
void enumerableProperties();
void enumProperties();
@@ -1590,6 +1591,7 @@ struct BaseGadget
Q_PROPERTY(int baseProperty READ baseProperty WRITE setBaseProperty)
public:
BaseGadget() : m_baseProperty(0) {}
+ BaseGadget(int initValue) : m_baseProperty(initValue) {}
int baseProperty() const { return m_baseProperty; }
void setBaseProperty(int value) { m_baseProperty = value; }
@@ -1686,6 +1688,47 @@ void tst_qqmlvaluetypes::gadgetTemplateInheritance()
QCOMPARE(value.property("baseProperty").toInt(), 42);
}
+void tst_qqmlvaluetypes::sequences()
+{
+ QJSEngine engine;
+ {
+ QList<BaseGadget> gadgetList{1, 4, 7, 8, 15};
+ QJSValue value = engine.toScriptValue(gadgetList);
+ QCOMPARE(value.property("length").toInt(), gadgetList.length());
+ for (int i = 0; i < gadgetList.length(); ++i)
+ QCOMPARE(value.property(i).property("baseProperty").toInt(), gadgetList.at(i).baseProperty());
+ }
+ {
+ std::vector<BaseGadget> container{1, 4, 7, 8, 15};
+ QJSValue value = engine.toScriptValue(container);
+ QCOMPARE(value.property("length").toInt(), int(container.size()));
+ for (size_t i = 0; i < container.size(); ++i)
+ QCOMPARE(value.property(i).property("baseProperty").toInt(), container.at(i).baseProperty());
+ }
+ {
+ QVector<QChar> qcharVector{1, 4, 42, 8, 15};
+ QJSValue value = engine.toScriptValue(qcharVector);
+ QCOMPARE(value.property("length").toInt(), qcharVector.length());
+ for (int i = 0; i < qcharVector.length(); ++i)
+ QCOMPARE(value.property(i).toInt(), qcharVector.at(i));
+ }
+ {
+ MyTypeObject a, b, c;
+ QSet<QObject*> objSet{&a, &b, &c};
+ QJSValue value = engine.toScriptValue(objSet);
+ QCOMPARE(value.property("length").toInt(), objSet.size());
+ for (int i = 0; i < objSet.size(); ++i)
+ QCOMPARE(value.property(i).property("point").property("x").toInt(), a.point().x());
+ }
+ {
+ MyTypeObject a, b, c;
+ QSet<MyTypeObject*> container{&a, &b, &c};
+ QJSValue value = engine.toScriptValue(container);
+ QCOMPARE(value.property("length").toInt(), container.size());
+ for (int i = 0; i < container.size(); ++i)
+ QCOMPARE(value.property(i).property("point").property("x").toInt(), a.point().x());
+ }
+}
struct StringLessGadget {
Q_GADGET
};
diff --git a/tests/auto/qml/qv4assembler/data/crash.qml b/tests/auto/qml/qv4assembler/data/crash.qml
new file mode 100644
index 0000000000..dfdb9ceba5
--- /dev/null
+++ b/tests/auto/qml/qv4assembler/data/crash.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 QtQml 2.2
+import Crash 1.0
+
+QtObject {
+ property Crash crash: Crash {
+ id: crash
+ }
+
+ // Recursion makes the crash more reliable
+ // With a single frame the unwinder might guess
+ // the next frame by chance.
+ function recurse(x) {
+ if (x > 32)
+ crash.crash();
+ else
+ recurse(x + 1);
+ }
+
+ property Timer timer: Timer {
+ interval: 10
+ running: true
+ onTriggered: recurse(0)
+ }
+}
+
diff --git a/tests/auto/qml/qv4assembler/qv4assembler.pro b/tests/auto/qml/qv4assembler/qv4assembler.pro
index afd7586ac7..895e241cc9 100644
--- a/tests/auto/qml/qv4assembler/qv4assembler.pro
+++ b/tests/auto/qml/qv4assembler/qv4assembler.pro
@@ -1,7 +1,12 @@
CONFIG += testcase
TARGET = tst_qv4assembler
+
+include (../../shared/util.pri)
+
macos:CONFIG -= app_bundle
+TESTDATA = data/*
+
SOURCES += tst_qv4assembler.cpp
QT += qml-private testlib
diff --git a/tests/auto/qml/qv4assembler/tst_qv4assembler.cpp b/tests/auto/qml/qv4assembler/tst_qv4assembler.cpp
index 9bd1afa256..4916cb4cc0 100644
--- a/tests/auto/qml/qv4assembler/tst_qv4assembler.cpp
+++ b/tests/auto/qml/qv4assembler/tst_qv4assembler.cpp
@@ -26,18 +26,34 @@
**
****************************************************************************/
+#include <util.h>
+
#include <QtTest/QtTest>
#include <QtCore/qprocess.h>
#include <QtCore/qtemporaryfile.h>
+#include <QtQml/qqml.h>
+#include <QtQml/qqmlapplicationengine.h>
+
+#ifdef Q_OS_WIN
+#include <windows.h>
+#endif
-class tst_QV4Assembler : public QObject
+class tst_QV4Assembler : public QQmlDataTest
{
Q_OBJECT
private slots:
+ void initTestCase() override;
void perfMapFile();
+ void functionTable();
};
+void tst_QV4Assembler::initTestCase()
+{
+ qputenv("QV4_JIT_CALL_THRESHOLD", "0");
+ QQmlDataTest::initTestCase();
+}
+
void tst_QV4Assembler::perfMapFile()
{
#if !defined(Q_OS_LINUX)
@@ -85,6 +101,42 @@ void tst_QV4Assembler::perfMapFile()
#endif
}
+#ifdef Q_OS_WIN
+class Crash : public QObject
+{
+ Q_OBJECT
+public:
+ explicit Crash(QObject *parent = nullptr) : QObject(parent) { }
+ Q_INVOKABLE static void crash();
+};
+
+static bool crashHandlerHit = false;
+
+static LONG WINAPI crashHandler(EXCEPTION_POINTERS*)
+{
+ crashHandlerHit = true;
+ return EXCEPTION_CONTINUE_EXECUTION;
+}
+
+void Crash::crash()
+{
+ SetUnhandledExceptionFilter(crashHandler);
+ RaiseException(EXCEPTION_ACCESS_VIOLATION, 0, 0, nullptr);
+}
+#endif
+
+void tst_QV4Assembler::functionTable()
+{
+#ifndef Q_OS_WIN
+ QSKIP("Function tables only exist on windows.");
+#else
+ QQmlApplicationEngine engine;
+ qmlRegisterType<Crash>("Crash", 1, 0, "Crash");
+ engine.load(testFileUrl("crash.qml"));
+ QTRY_VERIFY(crashHandlerHit);
+#endif
+}
+
QTEST_MAIN(tst_QV4Assembler)
#include "tst_qv4assembler.moc"
diff --git a/tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp b/tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp
index 095943cdc7..308fba9049 100644
--- a/tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp
+++ b/tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp
@@ -67,8 +67,8 @@ void tst_qv4identifiertable::sweepFirstEntryInBucket()
table.asPropertyKey(entry2);
table.asPropertyKey(entry3);
- QCOMPARE(table.size, 3);
- QCOMPARE(table.alloc, 5);
+ QCOMPARE(table.size, 3u);
+ QCOMPARE(table.alloc, 5u);
QCOMPARE(table.entriesByHash[0], entry1);
QCOMPARE(table.entriesByHash[1], entry2);
diff --git a/tests/auto/qml/v4traced/tst_v4traced.cpp b/tests/auto/qml/v4traced/tst_v4traced.cpp
new file mode 100644
index 0000000000..f82cc0ed5e
--- /dev/null
+++ b/tests/auto/qml/v4traced/tst_v4traced.cpp
@@ -0,0 +1,325 @@
+/****************************************************************************
+**
+** 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 <QtTest/QtTest>
+#include <QJSEngine>
+#include <private/qjsvalue_p.h>
+#include <private/qv4scopedvalue_p.h>
+#include <private/qv4script_p.h>
+
+class EnvVarSaver
+{
+public:
+ EnvVarSaver(const char *name, const QByteArray &newValue)
+ : _name(name)
+ {
+ _wasSet = qEnvironmentVariableIsSet(name);
+ if (_wasSet)
+ _oldValue = qgetenv(name);
+ qputenv(name, newValue);
+ }
+
+ ~EnvVarSaver()
+ {
+ if (_wasSet)
+ qputenv(_name, _oldValue);
+ else
+ qunsetenv(_name);
+ }
+
+private:
+ const char *_name;
+ bool _wasSet;
+ QByteArray _oldValue;
+};
+
+class tst_v4traced : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void collectTraces_data();
+ void collectTraces();
+
+ void binopI32deopt_data();
+ void binopI32deopt();
+
+ void calls_data();
+ void calls();
+
+ void setLookup();
+ void construct();
+};
+
+void tst_v4traced::collectTraces_data()
+{
+ QTest::addColumn<QString>("code");
+ QTest::addColumn<int>("tracePointCount");
+ QTest::addColumn<int>("interestingTracePoint");
+ QTest::addColumn<quint8>("expectedBits");
+
+ QTest::newRow("int+") << "var a = 4; a + 2" << 2 << 1 << quint8(QV4::ObservedTraceValues::Integer);
+ QTest::newRow("double+") << "var a = 4.1; a + 1.9" << 2 << 1 << quint8(QV4::ObservedTraceValues::Double);
+ QTest::newRow("object+") << "var a = '4'; a + '2'" << 2 << 1 << quint8(QV4::ObservedTraceValues::Other);
+}
+
+void tst_v4traced::collectTraces()
+{
+ QFETCH(QString, code);
+ QFETCH(int, tracePointCount);
+ QFETCH(int, interestingTracePoint);
+ QFETCH(quint8, expectedBits);
+
+ EnvVarSaver forceInterpreter("QV4_FORCE_INTERPRETER", "1");
+ EnvVarSaver forceTracing("QV4_FORCE_TRACING", "1");
+
+ QV4::ExecutionEngine vm;
+ QV4::Scope scope(&vm);
+ QV4::ScopedContext ctx(scope, vm.rootContext());
+ QV4::ScopedValue result(scope);
+ QScopedPointer<QV4::Script> script;
+ script.reset(new QV4::Script(ctx, QV4::Compiler::ContextType::Global, code, "collectTraces"));
+ script->parseAsBinding = false;
+
+ QVERIFY(!scope.engine->hasException);
+ script->parse();
+ QVERIFY(!scope.engine->hasException);
+
+ QVERIFY(script->function()->tracingEnabled());
+ result = script->run();
+ QVERIFY(!scope.engine->hasException);
+
+ QCOMPARE(int(script->function()->compiledFunction->nTraceInfos), tracePointCount);
+ QCOMPARE(*script->function()->traceInfo(interestingTracePoint), expectedBits);
+}
+
+void tst_v4traced::binopI32deopt_data()
+{
+ QTest::addColumn<QString>("operand");
+ QTest::addColumn<int>("int_arg1");
+ QTest::addColumn<int>("int_arg2");
+ QTest::addColumn<int>("int_result");
+ QTest::addColumn<QString>("other_arg1");
+ QTest::addColumn<QString>("other_arg2");
+ QTest::addColumn<double>("other_result");
+
+ QTest::newRow("+") << "+" << 1 << 2 << 3 << "1.1" << "1.9" << 3.0;
+ QTest::newRow("-") << "-" << 3 << 2 << 1 << "3.1" << "2.1" << 1.0;
+ QTest::newRow("*") << "*" << 2 << 3 << 6 << "2.1" << "1.9" << 3.99;
+ QTest::newRow("/") << "/" << 6 << 3 << 2 << "6.6" << "3.3" << 2.0;
+
+ QTest::newRow("&") << "&" << 6 << 3 << 2 << "'6'" << "'3'" << 2.0;
+ QTest::newRow("|") << "|" << 6 << 3 << 7 << "'6'" << "'3'" << 7.0;
+ QTest::newRow("^") << "^" << 6 << 3 << 5 << "'6'" << "'3'" << 5.0;
+
+ QTest::newRow("<<") << "<<" << 5 << 1 << 10 << "'5'" << "'1'" << 10.0;
+ QTest::newRow(">>") << ">>" << -1 << 1 << -1 << "'-1'" << "'1'" << -1.0;
+ QTest::newRow(">>>") << ">>>" << -1 << 1 << 0x7FFFFFFF << "'-1'" << "'1'" << 2147483647.0;
+
+ QTest::newRow("==") << "==" << 2 << 1 << 0 << "'2'" << "'1'" << 0.0;
+ QTest::newRow("!=") << "!=" << 2 << 1 << 1 << "'2'" << "'1'" << 1.0;
+ QTest::newRow("<" ) << "<" << 2 << 1 << 0 << "'2'" << "'1'" << 0.0;
+ QTest::newRow("<=") << "<=" << 2 << 1 << 0 << "'2'" << "'1'" << 0.0;
+ QTest::newRow(">" ) << ">" << 2 << 1 << 1 << "'2'" << "'1'" << 1.0;
+ QTest::newRow(">=") << ">=" << 2 << 1 << 1 << "'2'" << "'1'" << 1.0;
+}
+
+void tst_v4traced::binopI32deopt()
+{
+ QFETCH(QString, operand);
+ QFETCH(int, int_arg1);
+ QFETCH(int, int_arg2);
+ QFETCH(int, int_result);
+ QFETCH(QString, other_arg1);
+ QFETCH(QString, other_arg2);
+ QFETCH(double, other_result);
+
+ QString func = QStringLiteral("function binopI32(a, b) { return a %1 b }").arg(operand);
+ QString intCall = QStringLiteral("binopI32(%1, %2)").arg(int_arg1).arg(int_arg2);
+ QString otherCall = QStringLiteral("binopI32(%1, %2)").arg(other_arg1).arg(other_arg2);
+
+ QJSEngine engine;
+ engine.evaluate(func);
+
+ QCOMPARE(engine.evaluate(intCall).toInt(), int_result); // interpret + trace
+ QCOMPARE(engine.evaluate(intCall).toInt(), int_result); // jit
+ QCOMPARE(engine.evaluate(otherCall).toNumber(), other_result); // deopt
+ QCOMPARE(engine.evaluate(otherCall).toNumber(), other_result); // retrace
+ QCOMPARE(engine.evaluate(otherCall).toNumber(), other_result); // rejit
+}
+
+void tst_v4traced::calls_data()
+{
+ QTest::addColumn<QString>("call");
+
+ QTest::newRow("callGlobalLookup") << "globalLookup";
+ QTest::newRow("callPropertyLookup") << "obj.propertyLookup";
+}
+
+class Calls
+{
+public:
+ static int callCount;
+
+ static QV4::ReturnedValue doSomething(const QV4::FunctionObject */*o*/,
+ const QV4::Value */*thiz*/,
+ const QV4::Value *argv, int argc)
+ {
+ ++callCount;
+
+ if (argc == 0)
+ return QV4::Encode(42);
+
+ int prod = 1;
+ for (int i = 0; i < argc; ++i) {
+ Q_ASSERT(argv[i].isInteger());
+ prod *= argv[i].int_32();
+ }
+ return QV4::Encode(prod);
+ }
+};
+
+int Calls::callCount = 0;
+
+void tst_v4traced::calls()
+{
+ QFETCH(QString, call);
+
+ EnvVarSaver forceTracing("QV4_FORCE_TRACING", "1");
+ EnvVarSaver jitCallThreshold("QV4_JIT_CALL_THRESHOLD", "1");
+
+ QV4::ExecutionEngine vm;
+ QV4::Scope scope(&vm);
+ QV4::ScopedContext ctx(scope, vm.rootContext());
+ vm.globalObject->defineDefaultProperty(QLatin1String("globalLookup"),
+ Calls::doSomething);
+ QV4::ScopedObject obj(scope, vm.newObject());
+ vm.globalObject->defineDefaultProperty(QLatin1String("obj"), obj);
+ obj->defineDefaultProperty("propertyLookup", Calls::doSomething);
+
+ QString code = QStringLiteral(
+ "function doCalls() {\n"
+ " if (%1() != 42) return false\n"
+ " if (%1(21, 2) != 42) return false\n"
+ " if (%1(2, 3, 7) != 42) return false\n"
+ " return true\n"
+ "}\n"
+ "var result = true\n"
+ "for (var i = 0; i < 10; ++i) {\n"
+ " if (!doCalls()) { result = false; break }"
+ "}\n"
+ "result\n").arg(call);
+ QScopedPointer<QV4::Script> script;
+ script.reset(new QV4::Script(ctx, QV4::Compiler::ContextType::Global, code, "call"));
+ script->parseAsBinding = false;
+
+ QVERIFY(!scope.engine->hasException);
+ script->parse();
+ QVERIFY(!scope.engine->hasException);
+
+ Calls::callCount = 0;
+ QV4::ScopedValue result(scope, script->run());
+ QVERIFY(!scope.engine->hasException);
+
+ QVERIFY(result->isBoolean());
+ QVERIFY(result->booleanValue());
+ QCOMPARE(Calls::callCount, 30);
+}
+
+void tst_v4traced::setLookup()
+{
+ EnvVarSaver forceTracing("QV4_FORCE_TRACING", "1");
+ EnvVarSaver jitCallThreshold("QV4_JIT_CALL_THRESHOLD", "1");
+
+ QV4::ExecutionEngine vm;
+ QV4::Scope scope(&vm);
+ QV4::ScopedContext ctx(scope, vm.rootContext());
+ QV4::ScopedObject obj(scope, vm.newObject());
+ vm.globalObject->defineDefaultProperty(QLatin1String("oracle"), obj);
+ obj->defineDefaultProperty("answer", QV4::Primitive::fromInt32(32));
+
+ QString code = QStringLiteral(
+ "function doit() {\n"
+ " ++oracle.answer\n"
+ "}\n"
+ "for (var i = 0; i < 10; ++i) doit()\n"
+ "oracle.answer\n");
+ QScopedPointer<QV4::Script> script;
+ script.reset(new QV4::Script(ctx, QV4::Compiler::ContextType::Global, code, "setLookup"));
+ script->parseAsBinding = false;
+
+ QVERIFY(!scope.engine->hasException);
+ script->parse();
+ QVERIFY(!scope.engine->hasException);
+
+ QV4::ScopedValue result(scope, script->run());
+ QVERIFY(!scope.engine->hasException);
+
+ QVERIFY(result->isInteger());
+ QCOMPARE(result->int_32(), 42);
+}
+
+void tst_v4traced::construct()
+{
+ EnvVarSaver forceTracing("QV4_FORCE_TRACING", "1");
+ EnvVarSaver jitCallThreshold("QV4_JIT_CALL_THRESHOLD", "1");
+
+ QV4::ExecutionEngine vm;
+ QV4::Scope scope(&vm);
+ QV4::ScopedContext ctx(scope, vm.rootContext());
+ QV4::ScopedObject obj(scope, vm.newObject());
+ vm.globalObject->defineDefaultProperty(QLatin1String("oracle"), obj);
+ obj->defineDefaultProperty("answer", QV4::Primitive::fromInt32(32));
+
+ QString code = QStringLiteral(
+ "function doit() {\n"
+ " this.arr = new Array()\n"
+ " this.arr[0] = 0\n"
+ " this.arr[1] = 1\n"
+ " this.arr[2] = 2\n"
+ "}\n"
+ "var o\n"
+ "for (var i = 0; i < 10; ++i) o = new doit()\n"
+ "o.arr\n");
+ QScopedPointer<QV4::Script> script;
+ script.reset(new QV4::Script(ctx, QV4::Compiler::ContextType::Global, code, "setLookup"));
+ script->parseAsBinding = false;
+
+ QVERIFY(!scope.engine->hasException);
+ script->parse();
+ QVERIFY(!scope.engine->hasException);
+
+ QV4::ScopedValue result(scope, script->run());
+ QVERIFY(!scope.engine->hasException);
+
+ QVERIFY(result->as<QV4::ArrayObject>());
+}
+
+QTEST_MAIN(tst_v4traced)
+
+#include "tst_v4traced.moc"
diff --git a/tests/auto/qml/v4traced/v4traced.pro b/tests/auto/qml/v4traced/v4traced.pro
new file mode 100644
index 0000000000..cbc8f38046
--- /dev/null
+++ b/tests/auto/qml/v4traced/v4traced.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase
+TARGET = tst_v4traced
+macos:CONFIG -= app_bundle
+QT += core-private qml-private testlib
+SOURCES += tst_v4traced.cpp
diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp
index f141a2546c..575139f851 100644
--- a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp
@@ -252,7 +252,7 @@ void tst_HoverHandler::movingItemWithHoverHandler()
QTRY_COMPARE(window->isVisible(), false);
QCursor::setPos(paddlePos);
window->show();
- QTest::qWaitForWindowExposed(window);
+ QVERIFY(QTest::qWaitForWindowExposed(window));
QTRY_COMPARE(paddleHH->isHovered(), true);
diff --git a/tests/auto/quick/qquickanimatedsprite/qquickanimatedsprite.pro b/tests/auto/quick/qquickanimatedsprite/qquickanimatedsprite.pro
index 85f71bb605..a337473d99 100644
--- a/tests/auto/quick/qquickanimatedsprite/qquickanimatedsprite.pro
+++ b/tests/auto/quick/qquickanimatedsprite/qquickanimatedsprite.pro
@@ -8,7 +8,7 @@ macx:CONFIG -= app_bundle
TESTDATA = data/*
-QT += core-private gui-private qml-private quick-private network testlib
+QT += core-private gui-private qml-private quick-private network testlib qmltest
OTHER_FILES += \
$$files(data/*.qml)
diff --git a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
index 4ca31fd957..d2bbf9e6b1 100644
--- a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
+++ b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
@@ -28,6 +28,7 @@
#include <QtTest/QtTest>
#include "../../shared/util.h"
#include <QtQuick/qquickview.h>
+#include <QtQuickTest/QtQuickTest>
#include <private/qabstractanimation_p.h>
#include <private/qquickanimatedsprite_p.h>
#include <private/qquickitem_p.h>
@@ -290,8 +291,8 @@ void tst_qquickanimatedsprite::test_reparenting()
sprite->setParentItem(window.rootObject());
// don't crash (QTBUG-51162)
sprite->polish();
- QTRY_COMPARE(QQuickItemPrivate::get(sprite)->polishScheduled, true);
- QTRY_COMPARE(QQuickItemPrivate::get(sprite)->polishScheduled, false);
+ QVERIFY(QQuickTest::qIsPolishScheduled(sprite));
+ QVERIFY(QQuickTest::qWaitForItemPolished(sprite));
}
class KillerThread : public QThread
diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
index 0f095774e8..961506372a 100644
--- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
+++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
@@ -1207,7 +1207,7 @@ void tst_qquickanimations::easingProperties()
QVERIFY(animObject != nullptr);
QCOMPARE(animObject->easing().type(), QEasingCurve::BezierSpline);
- QList<QPointF> points = animObject->easing().cubicBezierSpline();
+ QVector<QPointF> points = animObject->easing().toCubicSpline();
QCOMPARE(points.count(), 3);
QCOMPARE(points.at(0), QPointF(0.5, 0.2));
QCOMPARE(points.at(1), QPointF(0.13, 0.65));
diff --git a/tests/auto/quick/qquickbehaviors/data/ItemWithInnerBehavior.qml b/tests/auto/quick/qquickbehaviors/data/ItemWithInnerBehavior.qml
index 09983645ef..0ac7f87c42 100644
--- a/tests/auto/quick/qquickbehaviors/data/ItemWithInnerBehavior.qml
+++ b/tests/auto/quick/qquickbehaviors/data/ItemWithInnerBehavior.qml
@@ -5,6 +5,7 @@ Item {
property bool someValue
Behavior on someValue {
+ objectName: "behavior"
ScriptAction { script: { parent.behaviorTriggered = true }}
}
}
diff --git a/tests/auto/quick/qquickbehaviors/data/aliased.qml b/tests/auto/quick/qquickbehaviors/data/aliased.qml
index e65e035d83..1840cdd22e 100644
--- a/tests/auto/quick/qquickbehaviors/data/aliased.qml
+++ b/tests/auto/quick/qquickbehaviors/data/aliased.qml
@@ -17,6 +17,7 @@ Rectangle {
anchors.fill: parent
value: accelerating ? 400 : 0
Behavior on value {
+ objectName: "behavior"
NumberAnimation {
duration: 500
}
diff --git a/tests/auto/quick/qquickbehaviors/data/oneway.qml b/tests/auto/quick/qquickbehaviors/data/oneway.qml
new file mode 100644
index 0000000000..0b438b80f6
--- /dev/null
+++ b/tests/auto/quick/qquickbehaviors/data/oneway.qml
@@ -0,0 +1,20 @@
+import QtQuick 2.0
+Rectangle {
+ width: 400
+ height: 400
+ Rectangle {
+ id: rect
+ objectName: "MyRectOneWay"
+ width: 100; height: 100; color: "green"
+ Behavior on x {
+ id: behavior
+ objectName: "MyBehaviorOneWay";
+ enabled: (behavior.targetValue === 0)
+ NumberAnimation {
+ id: ani
+ objectName: "MyAnimationOneWay";
+ duration: 200;
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro b/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro
index 51bc42c390..fd64eb1d40 100644
--- a/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro
+++ b/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro
@@ -7,5 +7,5 @@ include (../../shared/util.pri)
macx:CONFIG -= app_bundle
TESTDATA = data/*
-
+DISTFILES = $$files(data/*)
QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
index fa9eba095d..6367f327da 100644
--- a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
+++ b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
@@ -73,6 +73,7 @@ private slots:
void disabledWriteWhileRunning();
void aliasedProperty();
void innerBehaviorOverwritten();
+ void oneWay();
};
void tst_qquickbehaviors::simpleBehavior()
@@ -516,6 +517,7 @@ void tst_qquickbehaviors::disabledWriteWhileRunning()
myRect->setProperty("x", 200);
QCOMPARE(myAnimation->isRunning(), true);
QTRY_VERIFY(myRect->x() != qreal(0) && myRect->x() != qreal(200));
+ QCOMPARE(myBehavior->targetValue(), 200); // grabbed before starting the animation
// set disabled while animation is in progress
myBehavior->setProperty("enabled", false);
@@ -526,6 +528,7 @@ void tst_qquickbehaviors::disabledWriteWhileRunning()
myRect->setProperty("x", 100);
QCOMPARE(myAnimation->isRunning(), false);
QCOMPARE(myRect->x(), qreal(100));
+ QCOMPARE(myBehavior->targetValue(), 100);
QTest::qWait(200);
QCOMPARE(myRect->x(), qreal(100));
}
@@ -546,17 +549,20 @@ void tst_qquickbehaviors::disabledWriteWhileRunning()
// initial values
QCOMPARE(myBehavior->enabled(), true);
+ QCOMPARE(myBehavior->targetValue(), QVariant());
QCOMPARE(myAnimation->isRunning(), false);
QCOMPARE(myRect->x(), qreal(0));
// start animation
myRect->setProperty("x", 200);
QCOMPARE(myAnimation->isRunning(), true);
+ QCOMPARE(myBehavior->targetValue(), 200);
QTRY_VERIFY(myRect->x() != qreal(0) && myRect->x() != qreal(200));
//set second value
myRect->setProperty("x", 300);
QCOMPARE(myAnimation->isRunning(), true);
+ QCOMPARE(myBehavior->targetValue(), 300);
QTRY_VERIFY(myRect->x() != qreal(0) && myRect->x() != qreal(200));
// set disabled while animation is in progress
@@ -568,6 +574,7 @@ void tst_qquickbehaviors::disabledWriteWhileRunning()
myRect->setProperty("x", 100);
QCOMPARE(myAnimation->isRunning(), false);
QCOMPARE(myRect->x(), qreal(100));
+ QCOMPARE(myBehavior->targetValue(), 100);
QTest::qWait(200);
QCOMPARE(myRect->x(), qreal(100));
}
@@ -580,7 +587,12 @@ void tst_qquickbehaviors::aliasedProperty()
QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));
QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
+ QQuickBehavior* behavior =
+ qobject_cast<QQuickBehavior*>(rect->findChild<QQuickBehavior*>("behavior"));
+ QSignalSpy targetValueSpy(behavior, SIGNAL(targetValueChanged()));
QQuickItemPrivate::get(rect.data())->setState("moved");
+ QCOMPARE(behavior->targetValue(), 400);
+ QCOMPARE(targetValueSpy.count(), 1);
QScopedPointer<QQuickRectangle> acc(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("acc")));
QScopedPointer<QQuickRectangle> range(qobject_cast<QQuickRectangle*>(acc->findChild<QQuickRectangle*>("range")));
QTRY_VERIFY(acc->property("value").toDouble() > 0);
@@ -595,7 +607,44 @@ void tst_qquickbehaviors::innerBehaviorOverwritten()
QQmlEngine engine;
QQmlComponent c(&engine, testFileUrl("overwrittenbehavior.qml"));
QScopedPointer<QQuickItem> item(qobject_cast<QQuickItem*>(c.create()));
+ QQuickBehavior* behavior =
+ qobject_cast<QQuickBehavior*>(item->findChild<QQuickBehavior*>("behavior"));
QVERIFY(item->property("behaviorTriggered").toBool());
+ QCOMPARE(behavior->targetValue(), true);
+}
+
+void tst_qquickbehaviors::oneWay()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("oneway.qml"));
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));;
+ QVERIFY2(!rect.isNull(), qPrintable(c.errorString()));
+ QQuickBehavior* behavior =
+ qobject_cast<QQuickBehavior*>(rect->findChild<QQuickBehavior*>("MyBehaviorOneWay"));
+ QCOMPARE(behavior->enabled(), false);
+ QCOMPARE(behavior->targetValue(), QVariant());
+
+ QSignalSpy targetValueSpy(behavior, SIGNAL(targetValueChanged()));
+ QQuickRectangle *myRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRectOneWay"));
+ myRect->setProperty("x", 100);
+ QCOMPARE(behavior->targetValue(), 100);
+ QCOMPARE(targetValueSpy.count(), 1);
+ QCOMPARE(behavior->enabled(), false);
+ qreal x = myRect->x();
+ QCOMPARE(x, qreal(100)); //should change immediately
+ QQuickNumberAnimation *myAnimation =
+ qobject_cast<QQuickNumberAnimation*>(behavior->findChild<QQuickNumberAnimation*>("MyAnimationOneWay"));
+ QCOMPARE(myAnimation->isRunning(), false);
+
+ myRect->setProperty("x", 0);
+ QCOMPARE(behavior->targetValue(), 0);
+ QCOMPARE(targetValueSpy.count(), 2);
+ QCOMPARE(behavior->enabled(), true);
+ QCOMPARE(myAnimation->isRunning(), true);
+ QVERIFY(myRect->x() > 0.0);
+ QTRY_VERIFY(myRect->x() < 100.0);
+ QTRY_COMPARE(myRect->x(), qreal(0));
+ QCOMPARE(myAnimation->isRunning(), false);
}
QTEST_MAIN(tst_qquickbehaviors)
diff --git a/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp
index 3c7159782c..cf01cc927b 100644
--- a/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp
+++ b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp
@@ -188,14 +188,16 @@ void tst_QQuickDropArea::containsDrag_external()
const qreal dpr = window.devicePixelRatio();
const QPoint nativePos1 = QPoint(50, 50) * dpr;
const QPoint nativePos2 = QPoint(150, 50) * dpr;
- QWindowSystemInterface::handleDrag(&window, &data, nativePos1, Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, nativePos1, Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&alternateWindow, &data, nativePos1, Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&alternateWindow, &data, nativePos1, Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
@@ -203,13 +205,15 @@ void tst_QQuickDropArea::containsDrag_external()
evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&window, &data, nativePos2, Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, nativePos2, Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
- QWindowSystemInterface::handleDrag(&window, &data, nativePos1, Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, nativePos1, Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
@@ -217,13 +221,15 @@ void tst_QQuickDropArea::containsDrag_external()
evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&window, &data, nativePos2, Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, nativePos2, Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 1);
- QWindowSystemInterface::handleDrop(&window, &data, nativePos2, Qt::CopyAction);
+ QWindowSystemInterface::handleDrop(&window, &data, nativePos2, Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
}
void tst_QQuickDropArea::keys_internal()
@@ -358,80 +364,96 @@ void tst_QQuickDropArea::keys_external()
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
- QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
evaluate<void>(dropArea, "keys = \"text/x-blue\"");
QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-blue");
QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-blue");
evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
- QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
evaluate<void>(dropArea, "keys = \"text/x-red\"");
QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red");
QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red");
evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
- QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
evaluate<void>(dropArea, "keys = \"text/x-green\"");
QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-green");
QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-green");
evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
evaluate<void>(dropArea, "keys = [\"text/x-red\", \"text/x-green\"]");
QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red" << "text/x-green");
QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red" << "text/x-green");
evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
- QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
data.removeFormat("text/x-red");
data.removeFormat("text/x-blue");
evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
evaluate<void>(dropArea, "keys = []");
QCOMPARE(dropArea->property("keys").toStringList(), QStringList());
QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList());
evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList());
- QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
data.setData("text/x-red", "red");
data.setData("text/x-blue", "blue");
QCOMPARE(dropArea->property("keys").toStringList(), QStringList());
QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList());
evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
- QWindowSystemInterface::handleDrop(&window, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrop(&window, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
}
void tst_QQuickDropArea::source_internal()
@@ -587,7 +609,8 @@ void tst_QQuickDropArea::position_external()
QMimeData data;
const qreal dpr = window.devicePixelRatio();
- QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50) * dpr, Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50) * dpr, Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(50));
@@ -598,7 +621,8 @@ void tst_QQuickDropArea::position_external()
QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
- QWindowSystemInterface::handleDrag(&window, &data, QPoint(40, 50) * dpr, Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, QPoint(40, 50) * dpr, Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(40));
@@ -609,7 +633,8 @@ void tst_QQuickDropArea::position_external()
QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
- QWindowSystemInterface::handleDrag(&window, &data, QPoint(75, 25) * dpr, Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, QPoint(75, 25) * dpr, Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(75));
@@ -619,7 +644,8 @@ void tst_QQuickDropArea::position_external()
QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(75));
QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(25));
- QWindowSystemInterface::handleDrop(&window, &data, QPoint(75, 25) * dpr, Qt::CopyAction);
+ QWindowSystemInterface::handleDrop(&window, &data, QPoint(75, 25) * dpr, Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
}
void tst_QQuickDropArea::drop_internal()
@@ -930,7 +956,8 @@ void tst_QQuickDropArea::simultaneousDrags()
evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
//Same as in the first case, dropArea2 already contains a drag, dropArea1 will get the event
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
@@ -939,7 +966,8 @@ void tst_QQuickDropArea::simultaneousDrags()
QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
- QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
@@ -947,7 +975,8 @@ void tst_QQuickDropArea::simultaneousDrags()
QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
- QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 2);
QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
@@ -965,7 +994,8 @@ void tst_QQuickDropArea::simultaneousDrags()
evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
@@ -976,7 +1006,8 @@ void tst_QQuickDropArea::simultaneousDrags()
// external then internal.
evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
@@ -1010,7 +1041,8 @@ void tst_QQuickDropArea::simultaneousDrags()
QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
- QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 2);
QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
@@ -1106,7 +1138,8 @@ void tst_QQuickDropArea::simultaneousDrags()
evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
@@ -1116,7 +1149,8 @@ void tst_QQuickDropArea::simultaneousDrags()
evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
@@ -1126,7 +1160,8 @@ void tst_QQuickDropArea::simultaneousDrags()
evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
@@ -1146,7 +1181,8 @@ void tst_QQuickDropArea::simultaneousDrags()
evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
@@ -1154,7 +1190,8 @@ void tst_QQuickDropArea::simultaneousDrags()
QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
- QWindowSystemInterface::handleDrop(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrop(&alternateWindow, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
}
void tst_QQuickDropArea::dropStuff()
@@ -1179,8 +1216,10 @@ void tst_QQuickDropArea::dropStuff()
QCOMPARE(evaluate<QVariant>(dropArea, "array"), QVariant());
- QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction);
- QWindowSystemInterface::handleDrop(&window, &data, QPoint(50, 50), Qt::CopyAction);
+ QWindowSystemInterface::handleDrag(&window, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
+ QWindowSystemInterface::handleDrop(&window, &data, QPoint(50, 50), Qt::CopyAction,
+ Qt::MouseButtons(), Qt::KeyboardModifiers());
QCOMPARE(evaluate<int>(dropArea, "array.byteLength"), 3);
QCOMPARE(evaluate<QByteArray>(dropArea, "array"), QByteArray("red"));
}
diff --git a/tests/auto/quick/qquickfontmetrics/tst_quickfontmetrics.cpp b/tests/auto/quick/qquickfontmetrics/tst_quickfontmetrics.cpp
index 6e516f51e1..ef61c45225 100644
--- a/tests/auto/quick/qquickfontmetrics/tst_quickfontmetrics.cpp
+++ b/tests/auto/quick/qquickfontmetrics/tst_quickfontmetrics.cpp
@@ -127,7 +127,7 @@ void tst_QuickFontMetrics::functions()
QFontMetricsF expected = QFontMetricsF(QFont());
QCOMPARE(metrics.elidedText(text, mode, width, flags), expected.elidedText(text, mode, width, flags));
- QCOMPARE(metrics.advanceWidth(text), expected.width(text));
+ QCOMPARE(metrics.advanceWidth(text), expected.horizontalAdvance(text));
QCOMPARE(metrics.boundingRect(text), expected.boundingRect(text));
QCOMPARE(metrics.tightBoundingRect(text), expected.tightBoundingRect(text));
}
diff --git a/tests/auto/quick/qquickgridview/qquickgridview.pro b/tests/auto/quick/qquickgridview/qquickgridview.pro
index 3c33cc78fb..5051f8bc62 100644
--- a/tests/auto/quick/qquickgridview/qquickgridview.pro
+++ b/tests/auto/quick/qquickgridview/qquickgridview.pro
@@ -10,5 +10,5 @@ include (../shared/util.pri)
TESTDATA = data/*
-QT += core-private gui-private qml-private quick-private testlib
+QT += core-private gui-private qml-private quick-private testlib qmltest
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
index e346e25aaf..448096720c 100644
--- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
+++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
@@ -29,6 +29,7 @@
#include <QtTest/QtTest>
#include <QtCore/qstringlistmodel.h>
#include <QtQuick/qquickview.h>
+#include <QtQuickTest/QtQuickTest>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
#include <QtQml/qqmlcontext.h>
@@ -535,7 +536,7 @@ void tst_QQuickGridView::inserted_defaultLayout(QQuickGridView::Flow flow,
insertCount = insertCount_ttb;
}
if (setContentPos(gridview, contentYRowOffset))
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QList<QPair<QString, QString> > newData;
for (int i=0; i<insertCount; i++)
@@ -721,13 +722,13 @@ void tst_QQuickGridView::insertBeforeVisible()
QTRY_VERIFY(contentItem != nullptr);
gridview->setCacheBuffer(cacheBuffer);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
// trigger a refill (not just setting contentY) so that the visibleItems grid is updated
int firstVisibleIndex = 12; // move to an index where the top item is not visible
gridview->setContentY(firstVisibleIndex/3 * 60.0);
gridview->setCurrentIndex(firstVisibleIndex);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QTRY_COMPARE(gridview->currentIndex(), firstVisibleIndex);
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", firstVisibleIndex);
@@ -744,7 +745,7 @@ void tst_QQuickGridView::insertBeforeVisible()
// now, moving to the top of the view should position the inserted items correctly
int itemsOffsetAfterMove = (insertCount / 3) * -60.0;
gridview->setCurrentIndex(0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QTRY_COMPARE(gridview->currentIndex(), 0);
QTRY_COMPARE(gridview->contentY(), 0.0 + itemsOffsetAfterMove);
@@ -803,7 +804,7 @@ void tst_QQuickGridView::removed_basic()
QTRY_VERIFY(gridview != nullptr);
QQuickItem *contentItem = gridview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
model.removeItem(1);
QTRY_COMPARE(window->rootObject()->property("count").toInt(), model.count());
@@ -890,7 +891,7 @@ void tst_QQuickGridView::removed_basic()
QTRY_VERIFY(gridview->currentItem() != oldCurrent);
gridview->setContentY(0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
// Confirm items positioned correctly
itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
@@ -966,7 +967,7 @@ void tst_QQuickGridView::removed_defaultLayout(QQuickGridView::Flow flow,
firstVisible = firstVisible_ttb;
}
if (setContentPos(gridview, contentYRowOffset))
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
model.removeItems(removeIndex, removeCount);
gridview->forceLayout();
@@ -1182,7 +1183,7 @@ void tst_QQuickGridView::addOrRemoveBeforeVisible()
gridview->setCurrentIndex(0);
qApp->processEvents();
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
// scroll down until item 0 is no longer drawn
// (bug not triggered if we just move using content y, since that doesn't
@@ -1193,7 +1194,7 @@ void tst_QQuickGridView::addOrRemoveBeforeVisible()
QTRY_COMPARE(gridview->currentIndex(), 24);
QTRY_COMPARE(gridview->contentY(), 220.0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 0)); // 0 shouldn't be visible
if (doAdd) {
@@ -1254,7 +1255,7 @@ void tst_QQuickGridView::clear()
QVERIFY(gridview != nullptr);
QQuickItem *contentItem = gridview->contentItem();
QVERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
model.clear();
gridview->forceLayout();
@@ -1307,7 +1308,7 @@ void tst_QQuickGridView::moved_defaultLayout(QQuickGridView::Flow flow,
QTRY_VERIFY(gridview != nullptr);
QQuickItem *contentItem = gridview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QQuickItem *currentItem = gridview->currentItem();
QTRY_VERIFY(currentItem != nullptr);
@@ -1318,10 +1319,10 @@ void tst_QQuickGridView::moved_defaultLayout(QQuickGridView::Flow flow,
count = count_ttb;
}
if (setContentPos(gridview, contentYRowOffset))
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
model.moveItems(from, to, count);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
// Confirm items positioned correctly and indexes correct
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
@@ -1560,7 +1561,7 @@ void tst_QQuickGridView::multipleChanges(bool condensed)
QQuickGridView *gridview = findItem<QQuickGridView>(window->rootObject(), "grid");
QTRY_VERIFY(gridview != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
for (int i=0; i<changes.count(); i++) {
switch (changes[i].type) {
@@ -1588,10 +1589,10 @@ void tst_QQuickGridView::multipleChanges(bool condensed)
break;
}
if (condensed) {
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
}
}
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QCOMPARE(gridview->count(), newCount);
QCOMPARE(gridview->count(), model.count());
@@ -1834,7 +1835,7 @@ void tst_QQuickGridView::currentIndex()
QQuickGridView *gridview = findItem<QQuickGridView>(window->rootObject(), "grid");
QVERIFY(gridview != nullptr);
- QTRY_VERIFY(!QQuickItemPrivate::get(gridview)->polishScheduled);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QQuickItem *contentItem = gridview->contentItem();
QVERIFY(contentItem != nullptr);
@@ -1936,7 +1937,7 @@ void tst_QQuickGridView::noCurrentIndex()
QVERIFY(gridview != nullptr);
QQuickItem *contentItem = gridview->contentItem();
QVERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
// current index should be -1
QCOMPARE(gridview->currentIndex(), -1);
@@ -1981,7 +1982,7 @@ void tst_QQuickGridView::keyNavigation()
gridview->setFlow(flow);
gridview->setLayoutDirection(layoutDirection);
gridview->setVerticalLayoutDirection(verticalLayoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -2491,7 +2492,7 @@ void tst_QQuickGridView::positionViewAtBeginningEnd()
QTRY_VERIFY(gridview != nullptr);
QQuickItem *contentItem = gridview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
// positionViewAtBeginning
gridview->setContentY(150);
@@ -2578,10 +2579,10 @@ void tst_QQuickGridView::positionViewAtIndex()
QTRY_VERIFY(gridview != nullptr);
QQuickItem *contentItem = gridview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
window->rootObject()->setProperty("enforceRange", enforceRange);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
if (topToBottom)
gridview->setContentX(initContentPos);
@@ -2791,7 +2792,7 @@ void tst_QQuickGridView::resetModel()
QTRY_VERIFY(gridview != nullptr);
QQuickItem *contentItem = gridview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QTRY_COMPARE(gridview->count(), model.rowCount());
@@ -2840,7 +2841,7 @@ void tst_QQuickGridView::enforceRange()
QTRY_COMPARE(gridview->preferredHighlightBegin(), 100.0);
QTRY_COMPARE(gridview->preferredHighlightEnd(), 100.0);
QTRY_COMPARE(gridview->highlightRangeMode(), QQuickGridView::StrictlyEnforceRange);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QQuickItem *contentItem = gridview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
@@ -3023,7 +3024,7 @@ void tst_QQuickGridView::footer()
gridview->setFlow(flow);
gridview->setLayoutDirection(layoutDirection);
gridview->setVerticalLayoutDirection(verticalLayoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QQuickItem *contentItem = gridview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
@@ -3272,7 +3273,7 @@ void tst_QQuickGridView::header()
gridview->setFlow(flow);
gridview->setLayoutDirection(layoutDirection);
gridview->setVerticalLayoutDirection(verticalLayoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QQuickItem *contentItem = gridview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
@@ -3296,7 +3297,7 @@ void tst_QQuickGridView::header()
QCOMPARE(item->position(), firstDelegatePos);
model.clear();
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QCOMPARE(header->position(), initialHeaderPos); // header should stay where it is
if (flow == QQuickGridView::FlowLeftToRight)
QCOMPARE(gridview->contentHeight(), header->height());
@@ -3349,7 +3350,7 @@ void tst_QQuickGridView::header()
gridview->setFlow(flow);
gridview->setLayoutDirection(layoutDirection);
gridview->setVerticalLayoutDirection(verticalLayoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
gridview->setWidth(240);
gridview->setHeight(320);
@@ -3494,7 +3495,7 @@ void tst_QQuickGridView::extents()
gridview->setFlow(flow);
gridview->setLayoutDirection(layoutDirection);
gridview->setVerticalLayoutDirection(verticalLayoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QQuickItem *contentItem = gridview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
@@ -3655,7 +3656,7 @@ void tst_QQuickGridView::resizeViewAndRepaint()
QTRY_VERIFY(gridview != nullptr);
QQuickItem *contentItem = gridview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
// item at index 10 should not be currently visible
QVERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10));
@@ -3736,7 +3737,7 @@ void tst_QQuickGridView::resizeGrid()
// items are aligned correctly in right-to-left
window->rootObject()->setWidth(260);
window->rootObject()->setHeight(320);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QCOMPARE(gridview->contentX(), initialContentPos.x());
QCOMPARE(gridview->contentY(), initialContentPos.y());
@@ -3760,7 +3761,7 @@ void tst_QQuickGridView::resizeGrid()
// change from 3x5 grid to 4x7
window->rootObject()->setWidth(window->rootObject()->width() + 80);
window->rootObject()->setHeight(window->rootObject()->height() + 60*2);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
// other than in LeftToRight+RightToLeft layout, the first item should not move
// if view is resized
@@ -3865,7 +3866,7 @@ void tst_QQuickGridView::changeColumnCount()
QTRY_VERIFY(gridview != nullptr);
QQuickItem *contentItem = gridview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
// a single column of 6 items are visible
int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
@@ -3879,7 +3880,7 @@ void tst_QQuickGridView::changeColumnCount()
// now 6x3 grid is visible, plus 1 extra below for refill
gridview->setWidth(240);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
QCOMPARE(itemCount, 6*3 + 1);
for (int i = 0; i < model.count() && i < itemCount; ++i) {
@@ -3891,7 +3892,7 @@ void tst_QQuickGridView::changeColumnCount()
// back to single column
gridview->setWidth(100);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
QCOMPARE(itemCount, 6);
for (int i = 0; i < model.count() && i < itemCount; ++i) {
@@ -4139,7 +4140,7 @@ void tst_QQuickGridView::margins()
QTRY_VERIFY(gridview != nullptr);
QQuickItem *contentItem = gridview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QCOMPARE(gridview->contentX(), -30.);
QCOMPARE(gridview->originX(), 0.);
@@ -4217,7 +4218,7 @@ void tst_QQuickGridView::margins()
// remove item before visible and check that left margin is maintained
// and originX is updated
gridview->setContentX(-400);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
model.removeItems(0, 4);
gridview->forceLayout();
QTRY_COMPARE(model.count(), gridview->count());
@@ -4259,7 +4260,7 @@ void tst_QQuickGridView::margins()
QVERIFY(gridview != nullptr);
QQuickItem *contentItem = gridview->contentItem();
QVERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QCOMPARE(contentItem->x(), 200);
QCOMPARE(contentItem->y(), 20);
@@ -4341,7 +4342,7 @@ void tst_QQuickGridView::snapToRow()
gridview->setFlow(flow);
gridview->setLayoutDirection(layoutDirection);
gridview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QQuickItem *contentItem = gridview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
@@ -4461,7 +4462,7 @@ void tst_QQuickGridView::snapOneRow()
gridview->setFlow(flow);
gridview->setLayoutDirection(layoutDirection);
gridview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QQuickItem *contentItem = gridview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
@@ -4623,7 +4624,7 @@ void tst_QQuickGridView::populateTransitions()
QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), 0);
QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 18);
} else {
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QCOMPARE(gridview->property("countPopulateTransitions").toInt(), 0);
QCOMPARE(gridview->property("countAddTransitions").toInt(), 0);
}
@@ -4659,7 +4660,7 @@ void tst_QQuickGridView::populateTransitions()
for (int i = 0; i < 30; i++)
model.addItem("item" + QString::number(i), "");
window->rootContext()->setContextProperty("testModel", &model);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 18 : 0);
QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0);
@@ -4747,11 +4748,11 @@ void tst_QQuickGridView::addTransitions()
QTRY_VERIFY(gridview != nullptr);
QQuickItem *contentItem = gridview->contentItem();
QVERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
if (contentYRowOffset != 0) {
gridview->setContentY(contentYRowOffset * 60.0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
}
QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
@@ -4956,7 +4957,7 @@ void tst_QQuickGridView::moveTransitions()
if (contentYRowOffset != 0) {
gridview->setContentY(contentYRowOffset * 60.0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
}
QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
@@ -5197,11 +5198,11 @@ void tst_QQuickGridView::removeTransitions()
QTRY_VERIFY(gridview != nullptr);
QQuickItem *contentItem = gridview->contentItem();
QVERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
if (contentYRowOffset != 0) {
gridview->setContentY(contentYRowOffset * 60.0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
}
QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
@@ -5415,7 +5416,7 @@ void tst_QQuickGridView::displacedTransitions()
QTRY_VERIFY(gridview != nullptr);
QQuickItem *contentItem = gridview->contentItem();
QVERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
gridview->setProperty("displaceTransitionsDone", false);
@@ -5436,7 +5437,7 @@ void tst_QQuickGridView::displacedTransitions()
break;
case ListChange::Moved:
model.moveItems(change.index, change.to, change.count);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
break;
case ListChange::SetCurrent:
case ListChange::SetContentY:
@@ -5634,11 +5635,11 @@ void tst_QQuickGridView::multipleTransitions()
QTRY_VERIFY(gridview != nullptr);
QQuickItem *contentItem = gridview->contentItem();
QVERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
if (contentY != 0) {
gridview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
}
int timeBetweenActions = window->rootObject()->property("timeBetweenActions").toInt();
@@ -5675,7 +5676,7 @@ void tst_QQuickGridView::multipleTransitions()
case ListChange::Moved:
model.moveItems(changes[i].index, changes[i].to, changes[i].count);
gridview->forceLayout();
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
if (i == changes.count() - 1) {
QTRY_VERIFY(!gridview->property("runningMoveTargets").toBool());
QTRY_VERIFY(!gridview->property("runningMoveDisplaced").toBool());
@@ -5685,12 +5686,12 @@ void tst_QQuickGridView::multipleTransitions()
break;
case ListChange::SetCurrent:
gridview->setCurrentIndex(changes[i].index);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
gridview->forceLayout();
break;
case ListChange::SetContentY:
gridview->setContentY(changes[i].pos);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
gridview->forceLayout();
break;
case ListChange::Polish:
@@ -5804,7 +5805,7 @@ void tst_QQuickGridView::multipleDisplaced()
QTRY_VERIFY(gridview != nullptr);
QQuickItem *contentItem = gridview->contentItem();
QVERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
model.moveItems(12, 8, 1);
QTest::qWait(window->rootObject()->property("duration").toInt() / 2);
@@ -5854,7 +5855,7 @@ void tst_QQuickGridView::regression_QTBUG_57225()
QQuickGridView *gridview = findItem<QQuickGridView>(window->rootObject(), "grid");
QVERIFY(gridview != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(gridview));
model.removeItems(removeIndex, removeCount);
QTRY_VERIFY(gridview->property("animationDone").toBool());
@@ -6127,7 +6128,7 @@ void tst_QQuickGridView::unrequestedVisibility()
// move a non-visible item into view
model.moveItems(10, 9, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(leftview));
QTRY_VERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
QCOMPARE(delegateVisible(item), false);
@@ -6150,7 +6151,7 @@ void tst_QQuickGridView::unrequestedVisibility()
// move a visible item out of view
model.moveItems(5, 3, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(leftview));
QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
QCOMPARE(delegateVisible(item), false);
@@ -6163,7 +6164,7 @@ void tst_QQuickGridView::unrequestedVisibility()
// move a non-visible item into view
model.moveItems(3, 5, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(leftview));
QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
QCOMPARE(delegateVisible(item), false);
@@ -6176,7 +6177,7 @@ void tst_QQuickGridView::unrequestedVisibility()
// move a visible item out of view
model.moveItems(9, 10, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(leftview));
QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
QCOMPARE(delegateVisible(item), false);
@@ -6189,7 +6190,7 @@ void tst_QQuickGridView::unrequestedVisibility()
// move a non-visible item into view
model.moveItems(10, 9, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(leftview));
QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
QCOMPARE(delegateVisible(item), false);
diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
index 1a289a2087..2f90632841 100644
--- a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
+++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
@@ -51,9 +51,8 @@ public:
view.setSource(testFileUrl(fileName));
view.showNormal();
- QTest::qWaitForWindowExposed(&view);
-
- return view.grabWindow();
+ return QTest::qWaitForWindowExposed(&view)
+ ? view.grabWindow() : QImage();
}
private slots:
@@ -153,6 +152,7 @@ void tst_QQuickItemLayer::layerSmooth()
QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms");
QImage fb = runTest("Smooth.qml");
+ QVERIFY(!fb.size().isEmpty());
QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0, 0xff));
@@ -177,6 +177,7 @@ void tst_QQuickItemLayer::layerEnabled()
QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms");
QImage fb = runTest("Enabled.qml");
+ QVERIFY(!fb.size().isEmpty());
// Verify the banding
QCOMPARE(fb.pixel(0, 0), fb.pixel(0, 1));
// Verify the gradient
@@ -212,6 +213,7 @@ void tst_QQuickItemLayer::layerEffect()
QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms");
QImage fb = runTest("Effect.qml");
+ QVERIFY(!fb.size().isEmpty());
QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0));
}
@@ -229,6 +231,7 @@ void tst_QQuickItemLayer::layerSourceRect()
QSKIP("Only OpenGL Renderer supports GLSL ShaderEffects");
QImage fb = runTest("SourceRect.qml");
+ QVERIFY(!fb.size().isEmpty());
// Check that the edges are converted to blue
QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff));
@@ -253,6 +256,7 @@ void tst_QQuickItemLayer::layerIsTextureProvider()
QSKIP("Only OpenGL Renderer supports GLSL ShaderEffects");
QImage fb = runTest("TextureProvider.qml");
+ QVERIFY(!fb.size().isEmpty());
QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0));
}
@@ -448,6 +452,7 @@ void tst_QQuickItemLayer::changeSamplerName()
QSKIP("Only OpenGL Renderer supports GLSL ShaderEffects");
QImage fb = runTest("SamplerNameChange.qml");
+ QVERIFY(!fb.size().isEmpty());
QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff));
}
@@ -459,6 +464,7 @@ void tst_QQuickItemLayer::itemEffect()
QSKIP("Only OpenGL Renderer supports GLSL ShaderEffects");
QImage fb = runTest("ItemEffect.qml");
+ QVERIFY(!fb.size().isEmpty());
QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
QCOMPARE(fb.pixel(199, 0), qRgb(0xff, 0, 0));
QCOMPARE(fb.pixel(0, 199), qRgb(0, 0, 0xff));
@@ -472,6 +478,7 @@ void tst_QQuickItemLayer::rectangleEffect()
QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms");
QImage fb = runTest("RectangleEffect.qml");
+ QVERIFY(!fb.size().isEmpty());
QCOMPARE(fb.pixel(0, 0), qRgb(0, 0xff, 0));
QCOMPARE(fb.pixel(199, 0), qRgb(0, 0xff, 0));
QCOMPARE(fb.pixel(0, 199), qRgb(0, 0xff, 0));
diff --git a/tests/auto/quick/qquicklistview/data/listview-itematindex.qml b/tests/auto/quick/qquicklistview/data/listview-itematindex.qml
new file mode 100644
index 0000000000..fba8b11933
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/listview-itematindex.qml
@@ -0,0 +1,15 @@
+import QtQuick 2.0
+
+ListView {
+ width: 400
+ height: 400
+ focus: true
+ model: 3
+
+ delegate: Text {
+ width: parent.width
+ height: 10
+ property int idx: index
+ text: index
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/qquicklistview.pro b/tests/auto/quick/qquicklistview/qquicklistview.pro
index a95b6fdf33..fd96c269a2 100644
--- a/tests/auto/quick/qquicklistview/qquicklistview.pro
+++ b/tests/auto/quick/qquicklistview/qquicklistview.pro
@@ -16,6 +16,7 @@ include (../../shared/util.pri)
include (../shared/util.pri)
TESTDATA = data/*
+DISTFILES += data/*
-QT += core-private gui-private qml-private quick-private testlib
+QT += core-private gui-private qml-private quick-private testlib qmltest
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index fddba77f35..2ea8a477a8 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -31,6 +31,7 @@
#include <QtCore/QSortFilterProxyModel>
#include <QtGui/QStandardItemModel>
#include <QtQuick/qquickview.h>
+#include <QtQuickTest/QtQuickTest>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcontext.h>
#include <QtQml/qqmlexpression.h>
@@ -166,6 +167,7 @@ private slots:
void QTBUG_16037();
void indexAt_itemAt_data();
void indexAt_itemAt();
+ void itemAtIndex();
void incrementalModel();
void onAdd();
void onAdd_data();
@@ -473,8 +475,7 @@ void tst_QQuickListView::items(const QUrl &source)
// Force a layout, necessary if ListView is completed before DelegateModel.
listview->forceLayout();
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- QTRY_COMPARE(itemCount, 0);
+ QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").isEmpty());
QTRY_COMPARE(listview->highlightResizeVelocity(), 1000.0);
QTRY_COMPARE(listview->highlightMoveVelocity(), 100000.0);
@@ -650,7 +651,7 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v
if (verticalLayoutDirection == QQuickItemView::BottomToTop) {
listview->setVerticalLayoutDirection(verticalLayoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
contentY = -listview->height() - contentY;
}
listview->setContentY(contentY);
@@ -663,7 +664,7 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v
model.insertItems(insertIndex, newData);
//Wait for polish (updates list to the model changes)
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QTRY_COMPARE(listview->property("count").toInt(), model.count());
@@ -844,7 +845,7 @@ void tst_QQuickListView::insertBeforeVisible()
QTRY_VERIFY(contentItem != nullptr);
listview->setCacheBuffer(cacheBuffer);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// trigger a refill (not just setting contentY) so that the visibleItems grid is updated
int firstVisibleIndex = 20; // move to an index where the top item is not visible
@@ -852,7 +853,7 @@ void tst_QQuickListView::insertBeforeVisible()
listview->setCurrentIndex(firstVisibleIndex);
qApp->processEvents();
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QTRY_COMPARE(listview->currentIndex(), firstVisibleIndex);
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", firstVisibleIndex);
QVERIFY(item);
@@ -872,7 +873,7 @@ void tst_QQuickListView::insertBeforeVisible()
// now, moving to the top of the view should position the inserted items correctly
int itemsOffsetAfterMove = (removeCount - insertCount) * 20;
listview->setCurrentIndex(0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QTRY_COMPARE(listview->currentIndex(), 0);
QTRY_COMPARE(listview->contentY(), 0.0 + itemsOffsetAfterMove);
@@ -955,7 +956,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
QTRY_VERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
model.removeItem(1);
QTRY_COMPARE(window->rootObject()->property("count").toInt(), model.count());
@@ -1034,7 +1035,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
listview->setContentY(20); // That's the top now
// let transitions settle.
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// Confirm items positioned correctly
itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
@@ -1048,7 +1049,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
// remove current item beyond visible items.
listview->setCurrentIndex(20);
listview->setContentY(40);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
model.removeItem(20);
QTRY_COMPARE(listview->currentIndex(), 20);
@@ -1056,7 +1057,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
// remove item before current, but visible
listview->setCurrentIndex(8);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
oldCurrent = listview->currentItem();
model.removeItem(6);
@@ -1064,7 +1065,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
QTRY_COMPARE(listview->currentItem(), oldCurrent);
listview->setContentY(80);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// remove all visible items
model.removeItems(1, 18);
@@ -1142,14 +1143,14 @@ void tst_QQuickListView::removed_more(const QUrl &source, QQuickItemView::Vertic
if (verticalLayoutDirection == QQuickItemView::BottomToTop) {
listview->setVerticalLayoutDirection(verticalLayoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
contentY = -listview->height() - contentY;
}
listview->setContentY(contentY);
model.removeItems(removeIndex, removeCount);
//Wait for polish (updates list to the model changes)
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QTRY_COMPARE(listview->property("count").toInt(), model.count());
@@ -1323,7 +1324,7 @@ void tst_QQuickListView::clear(const QUrl &source, QQuickItemView::VerticalLayou
QTRY_VERIFY(contentItem != nullptr);
listview->setVerticalLayoutDirection(verticalLayoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
model.clear();
@@ -1381,20 +1382,20 @@ void tst_QQuickListView::moved(const QUrl &source, QQuickItemView::VerticalLayou
QTRY_VERIFY(contentItem != nullptr);
// always need to wait for view to be painted before the first move()
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
bool waitForPolish = (contentY != 0);
if (verticalLayoutDirection == QQuickItemView::BottomToTop) {
listview->setVerticalLayoutDirection(verticalLayoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
contentY = -listview->height() - contentY;
}
listview->setContentY(contentY);
if (waitForPolish)
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
model.moveItems(from, to, count);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
int firstVisibleIndex = -1;
@@ -1607,7 +1608,7 @@ void tst_QQuickListView::multipleChanges(bool condensed)
QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list");
QTRY_VERIFY(listview != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
for (int i=0; i<changes.count(); i++) {
switch (changes[i].type) {
@@ -1635,10 +1636,10 @@ void tst_QQuickListView::multipleChanges(bool condensed)
continue;
}
if (!condensed) {
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
}
}
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QCOMPARE(listview->count(), newCount);
QCOMPARE(listview->count(), model.count());
@@ -1855,7 +1856,7 @@ void tst_QQuickListView::swapWithFirstItem()
QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list");
QTRY_VERIFY(listview != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// ensure content position is stable
listview->setContentY(0);
@@ -1918,7 +1919,7 @@ void tst_QQuickListView::enforceRange()
QTRY_COMPARE(listview->preferredHighlightBegin(), 100.0);
QTRY_COMPARE(listview->preferredHighlightEnd(), 100.0);
QTRY_COMPARE(listview->highlightRangeMode(), QQuickListView::StrictlyEnforceRange);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
@@ -1973,7 +1974,7 @@ void tst_QQuickListView::enforceRange_withoutHighlight()
QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list");
QTRY_VERIFY(listview != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
qreal expectedPos = -100.0;
@@ -2017,7 +2018,7 @@ void tst_QQuickListView::spacing()
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// Confirm items positioned correctly
int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
@@ -2076,7 +2077,7 @@ void tst_QQuickListView::sections(const QUrl &source)
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// Confirm items positioned correctly
int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
@@ -2146,9 +2147,9 @@ void tst_QQuickListView::sections(const QUrl &source)
// check that headers change when item changes
listview->setContentY(0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
model.modifyItem(0, "changed", "2");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
item = findItem<QQuickItem>(contentItem, "wrapper", 1);
QTRY_VERIFY(item);
@@ -2176,7 +2177,7 @@ void tst_QQuickListView::sectionsDelegate()
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// Confirm items positioned correctly
int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
@@ -2200,7 +2201,7 @@ void tst_QQuickListView::sectionsDelegate()
model.modifyItem(2, "Three", "aaa");
model.modifyItem(3, "Four", "aaa");
model.modifyItem(4, "Five", "aaa");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
for (int i = 0; i < 3; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem,
@@ -2236,7 +2237,7 @@ void tst_QQuickListView::sectionsDelegate()
model.modifyItem(9, "Two", "aaa");
model.modifyItem(10, "Two", "aaa");
model.modifyItem(11, "Two", "aaa");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QTRY_COMPARE(findItems<QQuickItem>(contentItem, "sect_aaa").count(), 1);
window->rootObject()->setProperty("sectionProperty", "name");
// ensure view has settled.
@@ -2286,7 +2287,7 @@ void tst_QQuickListView::sectionsDragOutsideBounds()
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// QTBUG-17769
// Drag view up beyond bounds
@@ -2332,11 +2333,11 @@ void tst_QQuickListView::sectionsDelegate_headerVisibility()
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// ensure section header is maintained in view
listview->setCurrentIndex(20);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QTRY_VERIFY(qFuzzyCompare(listview->contentY(), 200.0));
QTRY_VERIFY(!listview->isMoving());
listview->setCurrentIndex(0);
@@ -2363,7 +2364,7 @@ void tst_QQuickListView::sectionsPositioning()
QTRY_VERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
for (int i = 0; i < 3; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "sect_" + QString::number(i));
@@ -2381,12 +2382,12 @@ void tst_QQuickListView::sectionsPositioning()
// move down a little and check that section header is at top
listview->setContentY(10);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QCOMPARE(topItem->y(), 0.);
// push the top header up
listview->setContentY(110);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
topItem = findVisibleChild(contentItem, "sect_0"); // section header
QVERIFY(topItem);
QCOMPARE(topItem->y(), 100.);
@@ -2401,13 +2402,13 @@ void tst_QQuickListView::sectionsPositioning()
// Move past section 0
listview->setContentY(120);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
topItem = findVisibleChild(contentItem, "sect_0"); // section header
QVERIFY(!topItem);
// Push section footer down
listview->setContentY(70);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
bottomItem = findVisibleChild(contentItem, "sect_4"); // section footer
QVERIFY(bottomItem);
QCOMPARE(bottomItem->y(), 380.);
@@ -2419,7 +2420,7 @@ void tst_QQuickListView::sectionsPositioning()
model.modifyItem(2, "Three", "aAa");
model.modifyItem(3, "Four", "aaA");
model.modifyItem(4, "Five", "Aaa");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QTRY_COMPARE(listview->currentSection(), QString("aaa"));
@@ -2435,7 +2436,7 @@ void tst_QQuickListView::sectionsPositioning()
// remove section boundary
listview->setContentY(120);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
model.removeItem(5);
listview->forceLayout();
QTRY_COMPARE(listview->count(), model.count());
@@ -2452,27 +2453,27 @@ void tst_QQuickListView::sectionsPositioning()
// Change the next section
listview->setContentY(0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
bottomItem = findVisibleChild(contentItem, "sect_3"); // section footer
QVERIFY(bottomItem);
QTRY_COMPARE(bottomItem->y(), 300.);
model.modifyItem(14, "New", "new");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QTRY_VERIFY(bottomItem = findVisibleChild(contentItem, "sect_new")); // section footer
QTRY_COMPARE(bottomItem->y(), 300.);
// delegate size increase should push section footer down
listview->setContentY(70);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QTRY_VERIFY(bottomItem = findVisibleChild(contentItem, "sect_3")); // section footer
QTRY_COMPARE(bottomItem->y(), 370.);
QQuickItem *inlineSection = findVisibleChild(contentItem, "sect_new");
item = findItem<QQuickItem>(contentItem, "wrapper", 13);
QVERIFY(item);
item->setHeight(40.);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QTRY_COMPARE(bottomItem->y(), 380.);
QCOMPARE(inlineSection->y(), 360.);
item->setHeight(20.);
@@ -2480,14 +2481,14 @@ void tst_QQuickListView::sectionsPositioning()
// Turn sticky footer off
listview->setContentY(20);
window->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart)));
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QTRY_VERIFY(item = findVisibleChild(contentItem, "sect_new")); // inline label restored
QCOMPARE(item->y(), 340.);
// Turn sticky header off
listview->setContentY(30);
window->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels)));
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QTRY_VERIFY(item = findVisibleChild(contentItem, "sect_aaa")); // inline label restored
QCOMPARE(item->y(), 0.);
@@ -2523,7 +2524,7 @@ void tst_QQuickListView::sectionPropertyChange()
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// Confirm items positioned correctly
for (int i = 0; i < 2; ++i) {
@@ -2533,7 +2534,7 @@ void tst_QQuickListView::sectionPropertyChange()
}
QMetaObject::invokeMethod(window->rootObject(), "switchGroups");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// Confirm items positioned correctly
for (int i = 0; i < 2; ++i) {
@@ -2543,7 +2544,7 @@ void tst_QQuickListView::sectionPropertyChange()
}
QMetaObject::invokeMethod(window->rootObject(), "switchGroups");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// Confirm items positioned correctly
for (int i = 0; i < 2; ++i) {
@@ -2553,7 +2554,7 @@ void tst_QQuickListView::sectionPropertyChange()
}
QMetaObject::invokeMethod(window->rootObject(), "switchGrouped");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// Confirm items positioned correctly
for (int i = 0; i < 2; ++i) {
@@ -2563,7 +2564,7 @@ void tst_QQuickListView::sectionPropertyChange()
}
QMetaObject::invokeMethod(window->rootObject(), "switchGrouped");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// Confirm items positioned correctly
for (int i = 0; i < 2; ++i) {
@@ -2587,7 +2588,7 @@ void tst_QQuickListView::sectionDelegateChange()
QQuickItem *contentItem = listview->contentItem();
QVERIFY(contentItem != nullptr);
- QQUICK_VERIFY_POLISH(listview);
+ QQuickTest::qWaitForItemPolished(listview);
QVERIFY(findItems<QQuickItem>(contentItem, "section1").count() > 0);
QCOMPARE(findItems<QQuickItem>(contentItem, "section2").count(), 0);
@@ -2599,7 +2600,7 @@ void tst_QQuickListView::sectionDelegateChange()
}
QMetaObject::invokeMethod(window->rootObject(), "switchDelegates");
- QQUICK_VERIFY_POLISH(listview);
+ QQuickTest::qWaitForItemPolished(listview);
QCOMPARE(findItems<QQuickItem>(contentItem, "section1").count(), 0);
QVERIFY(findItems<QQuickItem>(contentItem, "section2").count() > 0);
@@ -2631,7 +2632,7 @@ void tst_QQuickListView::sectionsItemInsertion()
QTRY_VERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
for (int i = 0; i < 3; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "sect_" + QString::number(i));
@@ -2647,7 +2648,7 @@ void tst_QQuickListView::sectionsItemInsertion()
for (int i = 0; i < 10; i++)
model.insertItem(i, "Item" + QString::number(i), QLatin1String("A"));
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
QVERIFY(itemCount > 10);
@@ -2785,7 +2786,7 @@ void tst_QQuickListView::currentIndex()
QTRY_VERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// currentIndex is initialized to 20
// currentItem should be in view
@@ -2888,7 +2889,7 @@ void tst_QQuickListView::noCurrentIndex()
QTRY_VERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// current index should be -1 at startup
// and we should not have a currentItem or highlightItem
@@ -2933,7 +2934,7 @@ void tst_QQuickListView::keyNavigation()
listview->setOrientation(orientation);
listview->setLayoutDirection(layoutDirection);
listview->setVerticalLayoutDirection(verticalLayoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -3248,7 +3249,7 @@ void tst_QQuickListView::positionViewAtBeginningEnd()
QTRY_VERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
listview->setContentY(100);
@@ -3308,10 +3309,10 @@ void tst_QQuickListView::positionViewAtIndex()
QTRY_VERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
window->rootObject()->setProperty("enforceRange", enforceRange);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
listview->setContentY(initContentY);
@@ -3388,7 +3389,7 @@ void tst_QQuickListView::resetModel()
QTRY_VERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QTRY_COMPARE(listview->count(), model.rowCount());
@@ -3659,7 +3660,7 @@ void tst_QQuickListView::QTBUG_11105()
QTRY_VERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// Confirm items positioned correctly
int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
@@ -3751,7 +3752,7 @@ void tst_QQuickListView::header()
listview->setOrientation(orientation);
listview->setLayoutDirection(layoutDirection);
listview->setVerticalLayoutDirection(verticalLayoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
@@ -3830,7 +3831,7 @@ void tst_QQuickListView::header()
listview->setOrientation(orientation);
listview->setLayoutDirection(layoutDirection);
listview->setVerticalLayoutDirection(verticalLayoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
listview->setWidth(240);
listview->setHeight(320);
@@ -3937,7 +3938,7 @@ void tst_QQuickListView::headerChangesViewport()
QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list");
QTRY_VERIFY(listview != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
@@ -3987,7 +3988,7 @@ void tst_QQuickListView::footer()
listview->setOrientation(orientation);
listview->setLayoutDirection(layoutDirection);
listview->setVerticalLayoutDirection(verticalLayoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
@@ -4176,7 +4177,7 @@ void tst_QQuickListView::extents()
listview->setOrientation(orientation);
listview->setLayoutDirection(layoutDirection);
listview->setVerticalLayoutDirection(verticalLayoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
@@ -4316,7 +4317,7 @@ void tst_QQuickListView::resizeView()
QTRY_VERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// Confirm items positioned correctly
int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
@@ -4332,7 +4333,7 @@ void tst_QQuickListView::resizeView()
QCOMPARE(heightRatio.toReal(), 0.4);
listview->setHeight(200);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QMetaObject::invokeMethod(window->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio));
QCOMPARE(heightRatio.toReal(), 0.25);
@@ -4393,7 +4394,7 @@ void tst_QQuickListView::resizeViewAndRepaint()
QTRY_VERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// item at index 10 should not be currently visible
QVERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10));
@@ -4428,7 +4429,7 @@ void tst_QQuickListView::sizeLessThan1()
QTRY_VERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// Confirm items positioned correctly
int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
@@ -4480,13 +4481,13 @@ void tst_QQuickListView::resizeDelegate()
QVERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QVERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QCOMPARE(listview->count(), model.rowCount());
listview->setCurrentIndex(25);
listview->setContentY(0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
for (int i = 0; i < 16; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
@@ -4498,7 +4499,7 @@ void tst_QQuickListView::resizeDelegate()
QTRY_COMPARE(listview->highlightItem()->y(), 500.0);
window->rootObject()->setProperty("delegateHeight", 30);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
for (int i = 0; i < 11; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
@@ -4512,7 +4513,7 @@ void tst_QQuickListView::resizeDelegate()
listview->setCurrentIndex(1);
listview->positionViewAtIndex(25, QQuickListView::Beginning);
listview->positionViewAtIndex(5, QQuickListView::Beginning);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
for (int i = 5; i < 16; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
@@ -4524,7 +4525,7 @@ void tst_QQuickListView::resizeDelegate()
QTRY_COMPARE(listview->highlightItem()->y(), 30.0);
window->rootObject()->setProperty("delegateHeight", 20);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
for (int i = 5; i < 11; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
@@ -4561,7 +4562,7 @@ void tst_QQuickListView::resizeFirstDelegate()
QVERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QVERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QQuickItem *item = nullptr;
for (int i = 0; i < model.count(); ++i) {
@@ -4600,7 +4601,7 @@ void tst_QQuickListView::resizeFirstDelegate()
listview->setCurrentIndex(19);
qApp->processEvents();
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// items 0-2 should have been deleted
for (int i=0; i<3; i++) {
@@ -4631,7 +4632,7 @@ void tst_QQuickListView::repositionResizedDelegate()
QQuickListView *listview = qobject_cast<QQuickListView*>(window->rootObject());
QTRY_VERIFY(listview != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QQuickItem *positioner = findItem<QQuickItem>(window->rootObject(), "positioner");
QVERIFY(positioner);
@@ -4646,7 +4647,7 @@ void tst_QQuickListView::repositionResizedDelegate()
listview->setContentX(contentPos_itemFirstHalfVisible.x());
listview->setContentY(contentPos_itemFirstHalfVisible.y());
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
prevSpyCount = spy.count();
QVERIFY(QMetaObject::invokeMethod(window->rootObject(), "incrementRepeater"));
QTRY_COMPARE(positioner->boundingRect().size(), resizedPositionerRect.size());
@@ -4663,7 +4664,7 @@ void tst_QQuickListView::repositionResizedDelegate()
listview->setContentX(contentPos_itemSecondHalfVisible.x());
listview->setContentY(contentPos_itemSecondHalfVisible.y());
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
prevSpyCount = spy.count();
QVERIFY(QMetaObject::invokeMethod(window->rootObject(), "incrementRepeater"));
@@ -4771,7 +4772,7 @@ void tst_QQuickListView::indexAt_itemAt()
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QQuickItem *item = nullptr;
if (index >= 0) {
@@ -4785,6 +4786,29 @@ void tst_QQuickListView::indexAt_itemAt()
delete testObject;
}
+void tst_QQuickListView::itemAtIndex()
+{
+ QScopedPointer<QQuickView> window(createView());
+ window->setSource(testFileUrl("listview-itematindex.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(window->rootObject());
+ QVERIFY(listview != nullptr);
+
+ QCOMPARE(listview->itemAtIndex(-1), nullptr);
+ QCOMPARE(listview->itemAtIndex(3), nullptr);
+ QQuickItem *item = listview->itemAtIndex(0);
+ QVERIFY(item);
+ QCOMPARE(item->property("idx"), 0);
+ item = listview->itemAtIndex(1);
+ QVERIFY(item);
+ QCOMPARE(item->property("idx"), 1);
+ item = listview->itemAtIndex(2);
+ QVERIFY(item);
+ QCOMPARE(item->property("idx"), 2);
+}
+
void tst_QQuickListView::incrementalModel()
{
QScopedPointer<QQuickView> window(createView());
@@ -4929,7 +4953,7 @@ void tst_QQuickListView::rightToLeft()
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QQmlObjectModel *model = window->rootObject()->findChild<QQmlObjectModel*>("itemModel");
QTRY_VERIFY(model != nullptr);
@@ -5042,7 +5066,7 @@ void tst_QQuickListView::margins()
QTRY_VERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QCOMPARE(listview->contentY(), -30.);
QCOMPARE(listview->originY(), 0.);
@@ -5051,7 +5075,7 @@ void tst_QQuickListView::margins()
listview->positionViewAtEnd();
qreal pos = listview->contentY();
listview->setContentY(pos + 80);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
listview->returnToBounds();
QTRY_COMPARE(listview->contentY(), pos + 50);
@@ -5062,7 +5086,7 @@ void tst_QQuickListView::margins()
listview->forceLayout();
QTRY_COMPARE(listview->count(), model.count());
listview->setContentY(-50);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
listview->returnToBounds();
QCOMPARE(listview->originY(), 20.);
QTRY_COMPARE(listview->contentY(), -10.);
@@ -5115,7 +5139,7 @@ void tst_QQuickListView::marginsResize()
listview->setOrientation(orientation);
listview->setLayoutDirection(layoutDirection);
listview->setVerticalLayoutDirection(verticalLayoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// view is resized after componentCompleted - top margin should still be visible
if (orientation == QQuickListView::Vertical)
@@ -5255,7 +5279,7 @@ void tst_QQuickListView::snapToItem()
listview->setLayoutDirection(layoutDirection);
listview->setVerticalLayoutDirection(verticalLayoutDirection);
listview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
@@ -5307,7 +5331,7 @@ void tst_QQuickListView::snapToItemWithSpacing_QTBUG_59852()
auto *listView = qobject_cast<QQuickListView*>(window->rootObject());
QVERIFY(listView);
- QTRY_COMPARE(QQuickItemPrivate::get(listView)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listView));
// each item in the list is 100 pixels tall, and the spacing is 100
@@ -5338,14 +5362,14 @@ void tst_QQuickListView::snapOneItemResize_QTBUG_43555()
QSignalSpy currentIndexSpy(listview, SIGNAL(currentIndexChanged()));
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QTRY_COMPARE(listview->currentIndex(), 5);
currentIndexSpy.clear();
window->resize(QSize(400, 320));
QTRY_COMPARE(int(listview->width()), 400);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QTRY_COMPARE(listview->currentIndex(), 5);
QCOMPARE(currentIndexSpy.count(), 0);
@@ -5655,7 +5679,7 @@ void tst_QQuickListView::snapOneItem()
listview->setLayoutDirection(layoutDirection);
listview->setVerticalLayoutDirection(verticalLayoutDirection);
listview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
@@ -5724,14 +5748,14 @@ void tst_QQuickListView::snapOneItemCurrentIndexRemoveAnimation()
QQuickListView *listview = qobject_cast<QQuickListView*>(window->rootObject());
QTRY_VERIFY(listview != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QTRY_COMPARE(listview->currentIndex(), 0);
QSignalSpy currentIndexSpy(listview, SIGNAL(currentIndexChanged()));
QMetaObject::invokeMethod(window->rootObject(), "removeItemZero");
QTRY_COMPARE(listview->property("transitionsRun").toInt(), 1);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QCOMPARE(listview->currentIndex(), 0);
QCOMPARE(currentIndexSpy.count(), 0);
@@ -5747,7 +5771,7 @@ void tst_QQuickListView::snapOneItemWrongDirection()
QQuickListView *listview = qobject_cast<QQuickListView*>(window->rootObject());
QTRY_VERIFY(listview != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QTRY_COMPARE(listview->currentIndex(), 0);
listview->flick(0,500);
@@ -5897,7 +5921,7 @@ void tst_QQuickListView::unrequestedVisibility()
QCOMPARE(delegateVisible(item), false);
model.moveItems(19, 1, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(leftview));
QTRY_VERIFY((item = findItem<QQuickItem>(leftContent, wrapperObjectName, 1)));
QCOMPARE(delegateVisible(item), false);
@@ -5926,7 +5950,7 @@ void tst_QQuickListView::unrequestedVisibility()
QCOMPARE(delegateVisible(item), false);
model.moveItems(3, 4, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(leftview));
item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4);
QVERIFY(item);
@@ -5942,7 +5966,7 @@ void tst_QQuickListView::unrequestedVisibility()
QCOMPARE(delegateVisible(item), false);
model.moveItems(4, 3, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(leftview));
item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4);
QVERIFY(item);
@@ -5958,7 +5982,7 @@ void tst_QQuickListView::unrequestedVisibility()
QCOMPARE(delegateVisible(item), false);
model.moveItems(16, 17, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(leftview));
item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4);
QVERIFY(item);
@@ -5974,7 +5998,7 @@ void tst_QQuickListView::unrequestedVisibility()
QCOMPARE(delegateVisible(item), false);
model.moveItems(17, 16, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(leftview));
item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4);
QVERIFY(item);
@@ -6034,7 +6058,7 @@ void tst_QQuickListView::populateTransitions()
QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), 0);
QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 16);
} else {
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QCOMPARE(listview->property("countPopulateTransitions").toInt(), 0);
QCOMPARE(listview->property("countAddTransitions").toInt(), 0);
}
@@ -6145,7 +6169,7 @@ void tst_QQuickListView::sizeTransitions()
QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list");
QTRY_VERIFY(listview != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// the following will start the transition
model.addItem(QLatin1String("Test"), "");
@@ -6210,11 +6234,11 @@ void tst_QQuickListView::addTransitions()
QTRY_VERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QVERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
if (contentY != 0) {
listview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
}
QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
@@ -6410,7 +6434,7 @@ void tst_QQuickListView::moveTransitions()
if (contentY != 0) {
listview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
}
QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
@@ -6609,11 +6633,11 @@ void tst_QQuickListView::removeTransitions()
QTRY_VERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QVERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
if (contentY != 0) {
listview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
}
QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
@@ -6821,7 +6845,7 @@ void tst_QQuickListView::displacedTransitions()
QTRY_VERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QVERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
listview->setProperty("displaceTransitionsDone", false);
@@ -6842,7 +6866,7 @@ void tst_QQuickListView::displacedTransitions()
break;
case ListChange::Moved:
model.moveItems(change.index, change.to, change.count);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
break;
case ListChange::SetCurrent:
case ListChange::SetContentY:
@@ -7041,11 +7065,11 @@ void tst_QQuickListView::multipleTransitions()
QTRY_VERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QVERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
if (contentY != 0) {
listview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
}
int timeBetweenActions = window->rootObject()->property("timeBetweenActions").toInt();
@@ -7079,7 +7103,7 @@ void tst_QQuickListView::multipleTransitions()
break;
case ListChange::Moved:
model.moveItems(changes[i].index, changes[i].to, changes[i].count);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
if (i == changes.count() - 1) {
QTRY_VERIFY(!listview->property("runningMoveTargets").toBool());
QTRY_VERIFY(!listview->property("runningMoveDisplaced").toBool());
@@ -7092,7 +7116,7 @@ void tst_QQuickListView::multipleTransitions()
break;
case ListChange::SetContentY:
listview->setContentY(changes[i].pos);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
break;
case ListChange::Polish:
break;
@@ -7198,7 +7222,7 @@ void tst_QQuickListView::multipleDisplaced()
QTRY_VERIFY(listview != nullptr);
QQuickItem *contentItem = listview->contentItem();
QVERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
model.moveItems(12, 8, 1);
QTest::qWait(window->rootObject()->property("duration").toInt() / 2);
@@ -7292,7 +7316,7 @@ void tst_QQuickListView::flickBeyondBounds()
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
// Flick view up beyond bounds
flick(window.data(), QPoint(10, 10), QPoint(10, -2000), 180);
@@ -7404,7 +7428,7 @@ void tst_QQuickListView::destroyItemOnCreation()
QQuickItem *contentItem = listview->contentItem();
QVERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QCOMPARE(window->rootObject()->property("createdIndex").toInt(), -1);
model.addItem("new item", "");
@@ -7428,7 +7452,7 @@ void tst_QQuickListView::parentBinding()
QQuickItem *contentItem = listview->contentItem();
QVERIFY(contentItem != nullptr);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
QVERIFY(item);
@@ -8832,7 +8856,7 @@ void tst_QQuickListView::QTBUG_34576_velocityZero()
QVERIFY(listview);
QQuickItem *contentItem = listview->contentItem();
QVERIFY(contentItem);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(listview));
QSignalSpy horizontalVelocitySpy(listview, SIGNAL(horizontalVelocityChanged()));
diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
index d4ad282701..cd66fc4ede 100644
--- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
+++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
@@ -1145,16 +1145,18 @@ void tst_QQuickMultiPointTouchArea::transformedTouchArea()
QQuickView *tst_QQuickMultiPointTouchArea::createAndShowView(const QString &file)
{
- QQuickView *window = new QQuickView(nullptr);
+ QScopedPointer<QQuickView> window(new QQuickView(nullptr));
window->setSource(testFileUrl(file));
+ if (window->status() != QQuickView::Ready)
+ return nullptr;
const QRect screenGeometry = window->screen()->availableGeometry();
const QSize size = window->size();
const QPoint offset = QPoint(size.width() / 2, size.height() / 2);
window->setFramePosition(screenGeometry.center() - offset);
window->show();
- QTest::qWaitForWindowExposed(window);
-
- return window;
+ if (!QTest::qWaitForWindowExposed(window.data()))
+ return nullptr;
+ return window.take();
}
void tst_QQuickMultiPointTouchArea::mouseInteraction_data()
diff --git a/tests/auto/quick/qquickpathview/qquickpathview.pro b/tests/auto/quick/qquickpathview/qquickpathview.pro
index 90c1eb0c67..f21fb64fa4 100644
--- a/tests/auto/quick/qquickpathview/qquickpathview.pro
+++ b/tests/auto/quick/qquickpathview/qquickpathview.pro
@@ -9,5 +9,5 @@ include (../shared/util.pri)
TESTDATA = data/*
-QT += core-private gui-private qml-private quick-private testlib
+QT += core-private gui-private qml-private quick-private testlib qmltest
qtHaveModule(widgets): QT += widgets
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index 7491df5087..1a5ce39318 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -38,6 +38,7 @@
#include <QtQuick/private/qquickpath_p.h>
#include <QtQuick/private/qquicktext_p.h>
#include <QtQuick/private/qquickrectangle_p.h>
+#include <QtQuickTest/QtQuickTest>
#include <QtQml/private/qqmllistmodel_p.h>
#include <QtQml/private/qqmlvaluetype_p.h>
#include <QtGui/qstandarditemmodel.h>
@@ -715,13 +716,13 @@ void tst_QQuickPathView::consecutiveModelChanges()
pathview->setCurrentIndex(changes[i].index);
break;
case ListChange::Polish:
- QQUICK_VERIFY_POLISH(pathview);
+ QQuickTest::qWaitForItemPolished(pathview);
break;
default:
continue;
}
}
- QQUICK_VERIFY_POLISH(pathview);
+ QQuickTest::qWaitForItemPolished(pathview);
QCOMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), count);
QCOMPARE(pathview->count(), count);
@@ -1394,7 +1395,7 @@ void tst_QQuickPathView::package()
QSKIP("QTBUG-27170 view does not reliably receive polish without a running animation");
#endif
- QQUICK_VERIFY_POLISH(pathView);
+ QQuickTest::qWaitForItemPolished(pathView);
QQuickItem *item = findItem<QQuickItem>(pathView, "pathItem");
QVERIFY(item);
QVERIFY(item->scale() != 1.0);
diff --git a/tests/auto/quick/qquickpositioners/qquickpositioners.pro b/tests/auto/quick/qquickpositioners/qquickpositioners.pro
index 6e85ba9db8..d1547df189 100644
--- a/tests/auto/quick/qquickpositioners/qquickpositioners.pro
+++ b/tests/auto/quick/qquickpositioners/qquickpositioners.pro
@@ -9,4 +9,4 @@ macx:CONFIG -= app_bundle
TESTDATA = data/*
-QT += testlib
+QT += testlib qmltest
diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
index 9881af690c..80be25d1b0 100644
--- a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
+++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
@@ -31,6 +31,7 @@
#include <QtQuick/private/qquickrectangle_p.h>
#include <QtQuick/private/qquickpositioners_p.h>
#include <QtQuick/private/qquicktransition_p.h>
+#include <QtQuickTest/QtQuickTest>
#include <private/qquickitem_p.h>
#include <qqmlexpression.h>
#include "../shared/viewtestutil.h"
@@ -1062,7 +1063,7 @@ void tst_qquickpositioners::populateTransitions(const QString &positionerObjectN
QTRY_COMPARE(window->rootObject()->property("populateTransitionsDone").toInt(), 0);
QTRY_COMPARE(window->rootObject()->property("addTransitionsDone").toInt(), model.count());
} else {
- QTRY_COMPARE(QQuickItemPrivate::get(positioner)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(positioner));
QTRY_COMPARE(window->rootObject()->property("populateTransitionsDone").toInt(), 0);
QTRY_COMPARE(window->rootObject()->property("addTransitionsDone").toInt(), 0);
}
@@ -1128,7 +1129,7 @@ void tst_qquickpositioners::addTransitions(const QString &positionerObjectName)
QQuickItem *positioner = window->rootObject()->findChild<QQuickItem*>(positionerObjectName);
QVERIFY(positioner);
positioner->findChild<QQuickItem*>("repeater")->setProperty("model", QVariant::fromValue(&model));
- QTRY_COMPARE(QQuickItemPrivate::get(positioner)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(positioner));
for (int i = 0; i < initialItemCount; i++)
model.addItem("Original item" + QString::number(i), "");
@@ -1253,7 +1254,7 @@ void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName)
QQuickItem *positioner = window->rootObject()->findChild<QQuickItem*>(positionerObjectName);
QVERIFY(positioner);
positioner->findChild<QQuickItem*>("repeater")->setProperty("model", QVariant::fromValue(&model));
- QTRY_COMPARE(QQuickItemPrivate::get(positioner)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(positioner));
switch (change.type) {
case ListChange::Removed:
@@ -1262,7 +1263,7 @@ void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName)
break;
case ListChange::Moved:
model.moveItems(change.index, change.to, change.count);
- QTRY_COMPARE(QQuickItemPrivate::get(positioner)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(positioner));
break;
case ListChange::Inserted:
case ListChange::SetCurrent:
@@ -3815,7 +3816,7 @@ void tst_qquickpositioners::test_mirroring()
QQuickItem *positionerB = itemB->parentItem();
positionerA->setWidth(positionerA->width() * 2);
positionerB->setWidth(positionerB->width() * 2);
- QTRY_VERIFY(!QQuickItemPrivate::get(positionerA)->polishScheduled && !QQuickItemPrivate::get(positionerB)->polishScheduled);
+ QVERIFY(QQuickTest::qWaitForItemPolished(positionerA) && QQuickTest::qWaitForItemPolished(positionerB));
QTRY_COMPARE(itemA->x(), itemB->x());
}
diff --git a/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp
index 832b973d96..710caaa734 100644
--- a/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp
+++ b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp
@@ -134,7 +134,7 @@ void tst_qquickrectangle::gradient_separate()
// Start off clean
QQuickItemPrivate *rectPriv = QQuickItemPrivate::get(rect);
- QTRY_COMPARE(rectPriv->dirtyAttributes & QQuickItemPrivate::Content, 0);
+ QTRY_COMPARE(rectPriv->dirtyAttributes & QQuickItemPrivate::Content, 0u);
QMetaObject::invokeMethod(rect, "changeGradient");
diff --git a/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp b/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp
index f601f520bb..a57b7d4c1f 100644
--- a/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp
+++ b/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp
@@ -46,6 +46,10 @@ class TestShaderEffect : public QQuickShaderEffect
Q_PROPERTY(QMatrix4x4 mat4x4 READ mat4x4Read NOTIFY dummyChanged)
public:
+ TestShaderEffect(QQuickItem* parent = nullptr) : QQuickShaderEffect(parent)
+ {
+ }
+
QMatrix4x4 mat4x4Read() const { return QMatrix4x4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1); }
QVariant dummyRead() const { return QVariant(); }
@@ -79,6 +83,8 @@ private slots:
void deleteShaderEffectSource();
void twoImagesOneShaderEffect();
+ void withoutQmlEngine();
+
private:
enum PresenceFlags {
VertexPresent = 0x01,
@@ -320,6 +326,16 @@ void tst_qquickshadereffect::twoImagesOneShaderEffect()
delete view;
}
+void tst_qquickshadereffect::withoutQmlEngine()
+{
+ // using a shader without QML engine used to crash
+ auto window = new QQuickWindow;
+ auto shaderEffect = new TestShaderEffect(window->contentItem());
+ shaderEffect->setVertexShader("");
+ QVERIFY(shaderEffect->isComponentComplete());
+ delete window;
+}
+
QTEST_MAIN(tst_qquickshadereffect)
#include "tst_qquickshadereffect.moc"
diff --git a/tests/auto/quick/qquicktableview/data/hiderowsandcolumns.qml b/tests/auto/quick/qquicktableview/data/hiderowsandcolumns.qml
new file mode 100644
index 0000000000..b11cb1476c
--- /dev/null
+++ b/tests/auto/quick/qquicktableview/data/hiderowsandcolumns.qml
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Window 2.3
+
+Item {
+ width: 640
+ height: 450
+
+ property alias tableView: tableView
+ property var rowsToHide
+ property var columnsToHide
+
+ TableView {
+ id: tableView
+ width: 600
+ height: 400
+ anchors.margins: 1
+ clip: true
+ delegate: tableViewDelegate
+ columnSpacing: 1
+ rowSpacing: 1
+ columnWidthProvider: function(column) {
+ if (columnsToHide.includes(column))
+ return 0;
+ }
+ rowHeightProvider: function(row) {
+ if (rowsToHide.includes(row))
+ return 0;
+ }
+ }
+
+ Component {
+ id: tableViewDelegate
+ Rectangle {
+ objectName: "tableViewDelegate"
+ color: "lightgray"
+ border.width: 1
+ implicitWidth: 50
+ implicitHeight: 50
+ Text {
+ anchors.centerIn: parent
+ text: column + "," + row
+ }
+ }
+ }
+
+}
diff --git a/tests/auto/quick/qquicktableview/data/usefaultyrowcolumnprovider.qml b/tests/auto/quick/qquicktableview/data/usefaultyrowcolumnprovider.qml
index 32d1fc9d0d..1e35d65bcd 100644
--- a/tests/auto/quick/qquicktableview/data/usefaultyrowcolumnprovider.qml
+++ b/tests/auto/quick/qquicktableview/data/usefaultyrowcolumnprovider.qml
@@ -56,16 +56,14 @@ Item {
delegate: tableViewDelegate
columnSpacing: 1
rowSpacing: 1
- columnWidthProvider: function(column) { }
- rowHeightProvider: function(row) { return 0 }
+ columnWidthProvider: function(column) { return "notAValidValue" }
+ rowHeightProvider: function(row) { return "notAValidValue" }
}
Component {
id: tableViewDelegate
Rectangle {
objectName: "tableViewDelegate"
- implicitWidth: 20
- implicitHeight: 20
color: "lightgray"
border.width: 1
Text {
diff --git a/tests/auto/quick/qquicktableview/data/userowcolumnprovider.qml b/tests/auto/quick/qquicktableview/data/userowcolumnprovider.qml
index 04d12f8d20..e9f01b6abf 100644
--- a/tests/auto/quick/qquicktableview/data/userowcolumnprovider.qml
+++ b/tests/auto/quick/qquicktableview/data/userowcolumnprovider.qml
@@ -46,6 +46,8 @@ Item {
property alias tableView: tableView
property Component delegate: tableViewDelegate
+ property bool returnNegativeColumnWidth: false
+ property bool returnNegativeRowHeight: false
TableView {
id: tableView
@@ -56,8 +58,16 @@ Item {
delegate: tableViewDelegate
columnSpacing: 1
rowSpacing: 1
- columnWidthProvider: function(column) { return column + 10 }
- rowHeightProvider: function(row) { return row + 10 }
+ columnWidthProvider: function(column) {
+ if (returnNegativeColumnWidth)
+ return -1
+ return column + 10
+ }
+ rowHeightProvider: function(row) {
+ if (returnNegativeRowHeight)
+ return -1
+ return row + 10
+ }
}
Component {
diff --git a/tests/auto/quick/qquicktableview/qquicktableview.pro b/tests/auto/quick/qquicktableview/qquicktableview.pro
index f4d0265dd3..cf831ed5b5 100644
--- a/tests/auto/quick/qquicktableview/qquicktableview.pro
+++ b/tests/auto/quick/qquicktableview/qquicktableview.pro
@@ -1,4 +1,5 @@
CONFIG += testcase
+QT += qmltest
TARGET = tst_qquicktableview
macos:CONFIG -= app_bundle
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
index 22f6e5d654..60d48bb59f 100644
--- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
+++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
@@ -27,6 +27,7 @@
****************************************************************************/
#include <QtTest/QtTest>
+#include <QtQuickTest/quicktest.h>
#include <QtQuick/qquickview.h>
#include <QtQuick/private/qquicktableview_p.h>
@@ -79,8 +80,8 @@ Q_DECLARE_METATYPE(QMarginsF);
DECLARE_TABLEVIEW_VARIABLES
#define WAIT_UNTIL_POLISHED \
- QVERIFY(tableViewPrivate->polishScheduled); \
- QTRY_VERIFY(!tableViewPrivate->polishScheduled)
+ QVERIFY(QQuickTest::qIsPolishScheduled(tableView)); \
+ QVERIFY(QQuickTest::qWaitForItemPolished(tableView))
class tst_QQuickTableView : public QQmlDataTest
{
@@ -110,10 +111,12 @@ private slots:
void checkDelegateWithAnchors();
void checkColumnWidthProvider();
void checkColumnWidthProviderInvalidReturnValues();
+ void checkColumnWidthProviderNegativeReturnValue();
void checkColumnWidthProviderNotCallable();
void checkRowHeightWithoutProvider();
void checkRowHeightProvider();
void checkRowHeightProviderInvalidReturnValues();
+ void checkRowHeightProviderNegativeReturnValue();
void checkRowHeightProviderNotCallable();
void checkForceLayoutFunction();
void checkContentWidthAndHeight();
@@ -156,6 +159,8 @@ private slots:
void checkRebuildViewportOnly();
void useDelegateChooserWithoutDefault();
void checkTableviewInsideAsyncLoader();
+ void hideRowsAndColumns_data();
+ void hideRowsAndColumns();
void checkThatRevisionedPropertiesCannotBeUsedInOldImports();
};
@@ -251,8 +256,9 @@ void tst_QQuickTableView::checkPreload()
WAIT_UNTIL_POLISHED;
if (reuseItems) {
- QSize visibleTableSize = tableViewPrivate->loadedTable.size();
- int expectedPoolSize = visibleTableSize.height() + visibleTableSize.width() + 1;
+ const int rowCount = tableViewPrivate->loadedRows.count();
+ const int columnCount = tableViewPrivate->loadedColumns.count();
+ const int expectedPoolSize = rowCount + columnCount + 1;
QCOMPARE(tableViewPrivate->tableModel->poolSize(), expectedPoolSize);
} else {
QCOMPARE(tableViewPrivate->tableModel->poolSize(), 0);
@@ -321,10 +327,9 @@ void tst_QQuickTableView::checkColumnWidthWithoutProvider()
WAIT_UNTIL_POLISHED;
- QRect table = tableViewPrivate->loadedTable;
- for (int column = table.left(); column <= table.right(); ++column) {
+ for (const int column : tableViewPrivate->loadedColumns.keys()) {
const qreal expectedColumnWidth = tableViewPrivate->sizeHintForColumn(column);
- for (int row = table.top(); row <= table.bottom(); ++row) {
+ for (const int row : tableViewPrivate->loadedRows.keys()) {
const auto item = tableViewPrivate->loadedTableItem(QPoint(column, row))->item;
QCOMPARE(item->width(), expectedColumnWidth);
}
@@ -373,7 +378,7 @@ void tst_QQuickTableView::checkColumnWidthProviderInvalidReturnValues()
tableView->setModel(model);
- QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*Provider.*valid"));
+ QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*implicitHeight.*zero"));
WAIT_UNTIL_POLISHED;
@@ -381,6 +386,23 @@ void tst_QQuickTableView::checkColumnWidthProviderInvalidReturnValues()
QCOMPARE(fxItem->item->width(), kDefaultColumnWidth);
}
+void tst_QQuickTableView::checkColumnWidthProviderNegativeReturnValue()
+{
+ // Check that we fall back to use the implicit width of the delegate
+ // items if the columnWidthProvider return a negative number.
+ LOAD_TABLEVIEW("userowcolumnprovider.qml");
+
+ auto model = TestModelAsVariant(10, 10);
+ view->rootObject()->setProperty("returnNegativeColumnWidth", true);
+
+ tableView->setModel(model);
+
+ WAIT_UNTIL_POLISHED;
+
+ for (auto fxItem : tableViewPrivate->loadedItems)
+ QCOMPARE(fxItem->item->width(), 20);
+}
+
void tst_QQuickTableView::checkColumnWidthProviderNotCallable()
{
// Check that we fall back to use default columns widths, if you
@@ -414,10 +436,9 @@ void tst_QQuickTableView::checkRowHeightWithoutProvider()
WAIT_UNTIL_POLISHED;
- QRect table = tableViewPrivate->loadedTable;
- for (int row = table.top(); row <= table.bottom(); ++row) {
+ for (const int row : tableViewPrivate->loadedRows.keys()) {
const qreal expectedRowHeight = tableViewPrivate->sizeHintForRow(row);
- for (int column = table.left(); column <= table.right(); ++column) {
+ for (const int column : tableViewPrivate->loadedColumns.keys()) {
const auto item = tableViewPrivate->loadedTableItem(QPoint(column, row))->item;
QCOMPARE(item->height(), expectedRowHeight);
}
@@ -454,7 +475,7 @@ void tst_QQuickTableView::checkRowHeightProviderInvalidReturnValues()
tableView->setModel(model);
- QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*Provider.*valid"));
+ QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*implicitHeight.*zero"));
WAIT_UNTIL_POLISHED;
@@ -462,6 +483,23 @@ void tst_QQuickTableView::checkRowHeightProviderInvalidReturnValues()
QCOMPARE(fxItem->item->height(), kDefaultRowHeight);
}
+void tst_QQuickTableView::checkRowHeightProviderNegativeReturnValue()
+{
+ // Check that we fall back to use the implicit height of the delegate
+ // items if the rowHeightProvider return a negative number.
+ LOAD_TABLEVIEW("userowcolumnprovider.qml");
+
+ auto model = TestModelAsVariant(10, 10);
+ view->rootObject()->setProperty("returnNegativeRowHeight", true);
+
+ tableView->setModel(model);
+
+ WAIT_UNTIL_POLISHED;
+
+ for (auto fxItem : tableViewPrivate->loadedItems)
+ QCOMPARE(fxItem->item->height(), 20);
+}
+
void tst_QQuickTableView::checkRowHeightProviderNotCallable()
{
// Check that we fall back to use default row heights, if you
@@ -539,6 +577,8 @@ void tst_QQuickTableView::checkContentWidthAndHeight()
const qreal expectedSizeInit = (tableSize * cellSizeSmall) + ((tableSize - 1) * spacing);
QCOMPARE(tableView->contentWidth(), expectedSizeInit);
QCOMPARE(tableView->contentHeight(), expectedSizeInit);
+ QCOMPARE(tableViewPrivate->averageEdgeSize.width(), cellSizeSmall);
+ QCOMPARE(tableViewPrivate->averageEdgeSize.height(), cellSizeSmall);
// Flick in 5 more rows and columns, but not so far that we start loading in
// the ones that are bigger. Loading in more rows and columns of the same
@@ -549,6 +589,8 @@ void tst_QQuickTableView::checkContentWidthAndHeight()
QCOMPARE(tableView->contentWidth(), expectedSizeInit);
QCOMPARE(tableView->contentHeight(), expectedSizeInit);
+ QCOMPARE(tableViewPrivate->averageEdgeSize.width(), cellSizeSmall);
+ QCOMPARE(tableViewPrivate->averageEdgeSize.height(), cellSizeSmall);
// Flick to row and column 20 (smallCellCount), since there the row and
// column sizes increases with 100. Check that TableView then adjusts
@@ -563,50 +605,61 @@ void tst_QQuickTableView::checkContentWidthAndHeight()
QVERIFY(tableViewPrivate->rebuildScheduled);
WAIT_UNTIL_POLISHED;
+ // Check that the average cell size is now matching the
+ // large cells since they fill up the whole view.
+ QCOMPARE(tableViewPrivate->averageEdgeSize.width(), cellSizeLarge);
+ QCOMPARE(tableViewPrivate->averageEdgeSize.height(), cellSizeLarge);
+
const int largeSizeCellCountInView = qCeil(tableView->width() / cellSizeLarge);
const int columnCount = smallCellCount + largeSizeCellCountInView;
- QCOMPARE(tableViewPrivate->loadedTable.left(), smallCellCount);
- QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1);
+ QCOMPARE(tableViewPrivate->leftColumn(), smallCellCount);
+ QCOMPARE(tableViewPrivate->rightColumn(), columnCount - 1);
const qreal firstHalfLength = smallCellCount * cellSizeSmall;
const qreal secondHalfOneScreenLength = largeSizeCellCountInView * cellSizeLarge;
const qreal lengthAfterFlick = firstHalfLength + secondHalfOneScreenLength;
- const qreal averageCellSize = lengthAfterFlick / columnCount;
- const qreal expectedSizeHalf = (tableSize * averageCellSize) + accumulatedSpacing;
-
- QCOMPARE(tableView->contentWidth(), expectedSizeHalf);
- QCOMPARE(tableView->contentHeight(), expectedSizeHalf);
+ // Check that loadedTableOuterRect has been calculated correct thus far
+ const qreal spacingAfterFlick = (smallCellCount + largeSizeCellCountInView - 1) * spacing;
+ QCOMPARE(tableViewPrivate->loadedTableOuterRect.left(), flickTo + spacing);
+ QCOMPARE(tableViewPrivate->loadedTableOuterRect.right(), lengthAfterFlick + spacingAfterFlick);
+ QCOMPARE(tableViewPrivate->loadedTableOuterRect.top(), flickTo + spacing);
+ QCOMPARE(tableViewPrivate->loadedTableOuterRect.bottom(), lengthAfterFlick + spacingAfterFlick);
+
+ // At this point, we should have the exact content width/height set, because
+ // TableView knows where the large cells start in the viewport, and how many
+ // columns that remain in the model. It will assume that the rest of the the
+ // columns have the same average size as the ones currently inside the viewport.
+ const qreal expectedContentSize = (smallCellCount * cellSizeSmall) + (largeCellCount * cellSizeLarge) + accumulatedSpacing;
+ QCOMPARE(tableView->contentWidth(), expectedContentSize);
+ QCOMPARE(tableView->contentHeight(), expectedContentSize);
// Flick to the end (row/column 100, and overshoot a bit), and
// check that we then end up with the exact content width/height.
const qreal secondHalfLength = largeCellCount * cellSizeLarge;
const qreal expectedFullSize = (firstHalfLength + secondHalfLength) + accumulatedSpacing;
-
- // If we flick more than one page at a time, tableview will jump to the new
- // position and rebuild the table without loading the edges in-between. Which
- // row and column that ends up as new top-left is then based on a prediction, and
- // therefore unreliable. To avoid this to happen (which will also affect the
- // reported size of the table), we flick to the end position in smaller chuncks.
- QVERIFY(!tableViewPrivate->polishScheduled);
- QVERIFY(!tableViewPrivate->rebuildScheduled);
- int pages = qCeil((expectedFullSize - tableView->contentX()) / tableView->width());
- for (int i = 0; i < pages; i++) {
- tableView->setContentX(tableView->contentX() + tableView->width() - 1);
- tableView->setContentY(tableView->contentY() + tableView->height() - 1);
- QVERIFY(!tableViewPrivate->rebuildScheduled);
- }
+ const qreal overshoot = 100;
+ const qreal endPosX = expectedFullSize - tableView->width() + overshoot;
+ const qreal endPosY = expectedFullSize - tableView->height() + overshoot;
+ tableView->setContentX(endPosX);
+ tableView->setContentY(endPosY);
QCOMPARE(tableView->contentWidth(), expectedFullSize);
QCOMPARE(tableView->contentHeight(), expectedFullSize);
- // Flick back to start. Since we know the actual table
- // size, contentWidth/Height shouldn't change.
+ // Flick back to start
tableView->setContentX(0);
tableView->setContentY(0);
- QCOMPARE(tableView->contentWidth(), expectedFullSize);
- QCOMPARE(tableView->contentHeight(), expectedFullSize);
+ // Since we move the viewport more than a page, tableview
+ // will jump to the new position and do a rebuild.
+ QVERIFY(tableViewPrivate->polishScheduled);
+ QVERIFY(tableViewPrivate->rebuildScheduled);
+ WAIT_UNTIL_POLISHED;
+
+ // We should now have the same content width/height as when we started
+ QCOMPARE(tableView->contentWidth(), expectedSizeInit);
+ QCOMPARE(tableView->contentHeight(), expectedSizeInit);
}
void tst_QQuickTableView::checkPageFlicking()
@@ -618,17 +671,18 @@ void tst_QQuickTableView::checkPageFlicking()
const int cellWidth = 100;
const int cellHeight = 50;
auto model = TestModelAsVariant(10000, 10000);
+ const auto &loadedRows = tableViewPrivate->loadedRows;
+ const auto &loadedColumns = tableViewPrivate->loadedColumns;
tableView->setModel(model);
WAIT_UNTIL_POLISHED;
// Sanity check startup table
- QRect tableRect = tableViewPrivate->loadedTable;
- QCOMPARE(tableRect.x(), 0);
- QCOMPARE(tableRect.y(), 0);
- QCOMPARE(tableRect.width(), tableView->width() / cellWidth);
- QCOMPARE(tableRect.height(), tableView->height() / cellHeight);
+ QCOMPARE(tableViewPrivate->topRow(), 0);
+ QCOMPARE(tableViewPrivate->leftColumn(), 0);
+ QCOMPARE(loadedRows.count(), tableView->height() / cellHeight);
+ QCOMPARE(loadedColumns.count(), tableView->width() / cellWidth);
// Since all cells have the same size, the average row/column
// size found by TableView should be exactly equal to this.
@@ -652,11 +706,10 @@ void tst_QQuickTableView::checkPageFlicking()
WAIT_UNTIL_POLISHED;
- tableRect = tableViewPrivate->loadedTable;
- QCOMPARE(tableRect.x(), flickToColumn);
- QCOMPARE(tableRect.y(), 0);
- QCOMPARE(tableRect.width(), tableView->width() / cellWidth);
- QCOMPARE(tableRect.height(), tableView->height() / cellHeight);
+ QCOMPARE(tableViewPrivate->topRow(), 0);
+ QCOMPARE(tableViewPrivate->leftColumn(), flickToColumn);
+ QCOMPARE(loadedColumns.count(), tableView->width() / cellWidth);
+ QCOMPARE(loadedRows.count(), tableView->height() / cellHeight);
// Flick 5000 rows down as well. Since flicking down should only calculate a new row (but
// keep the current column), we deliberatly change the average width to check that it's
@@ -675,11 +728,10 @@ void tst_QQuickTableView::checkPageFlicking()
WAIT_UNTIL_POLISHED;
- tableRect = tableViewPrivate->loadedTable;
- QCOMPARE(tableRect.x(), flickToRow);
- QCOMPARE(tableRect.y(), flickToColumn);
- QCOMPARE(tableRect.width(), tableView->width() / cellWidth);
- QCOMPARE(tableRect.height(), tableView->height() / cellHeight);
+ QCOMPARE(tableViewPrivate->topRow(), flickToColumn);
+ QCOMPARE(tableViewPrivate->leftColumn(), flickToRow);
+ QCOMPARE(loadedRows.count(), tableView->height() / cellHeight);
+ QCOMPARE(loadedColumns.count(), tableView->width() / cellWidth);
}
void tst_QQuickTableView::checkExplicitContentWidthAndHeight()
@@ -729,8 +781,8 @@ void tst_QQuickTableView::checkContentXY()
// Check that we end up at the correct top-left cell:
const qreal delegateWidth = tableViewPrivate->loadedItems.values().first()->item->width();
const int expectedCellXY = qCeil(expectedXY / delegateWidth);
- QCOMPARE(tableViewPrivate->loadedTable.left(), expectedCellXY);
- QCOMPARE(tableViewPrivate->loadedTable.top(), expectedCellXY);
+ QCOMPARE(tableViewPrivate->leftColumn(), expectedCellXY);
+ QCOMPARE(tableViewPrivate->topRow(), expectedCellXY);
}
void tst_QQuickTableView::noDelegate()
@@ -1004,7 +1056,8 @@ void tst_QQuickTableView::fillTableViewButNothingMore()
auto const topLeftFxItem = tableViewPrivate->loadedTableItem(QPoint(0, 0));
auto const topLeftItem = topLeftFxItem->item;
- auto const bottomRightFxItem = tableViewPrivate->loadedTableItem(tableViewPrivate->loadedTable.bottomRight());
+ auto const bottomRightLoadedCell = QPoint(tableViewPrivate->rightColumn(), tableViewPrivate->bottomRow());
+ auto const bottomRightFxItem = tableViewPrivate->loadedTableItem(bottomRightLoadedCell);
auto const bottomRightItem = bottomRightFxItem->item;
const QPoint bottomRightCell = getContextRowAndColumn(bottomRightItem.data());
@@ -1182,15 +1235,13 @@ void tst_QQuickTableView::flick()
WAIT_UNTIL_POLISHED;
- const QRect loadedTable = tableViewPrivate->loadedTable;
-
- const int expectedTableLeft = cellsToFlick - int((margins.left() + spacing.width()) / cellWidth);
- const int expectedTableTop = cellsToFlick - int((margins.top() + spacing.height()) / cellHeight);
+ const int expectedTableLeft = int(cellsToFlick - int((margins.left() + spacing.width()) / cellWidth));
+ const int expectedTableTop = int(cellsToFlick - int((margins.top() + spacing.height()) / cellHeight));
- QCOMPARE(loadedTable.left(), expectedTableLeft);
- QCOMPARE(loadedTable.right(), expectedTableLeft + visualColumnCount);
- QCOMPARE(loadedTable.top(), expectedTableTop);
- QCOMPARE(loadedTable.bottom(), expectedTableTop + visualRowCount);
+ QCOMPARE(tableViewPrivate->leftColumn(), expectedTableLeft);
+ QCOMPARE(tableViewPrivate->rightColumn(), expectedTableLeft + visualColumnCount);
+ QCOMPARE(tableViewPrivate->topRow(), expectedTableTop);
+ QCOMPARE(tableViewPrivate->bottomRow(), expectedTableTop + visualRowCount);
}
}
@@ -1252,10 +1303,10 @@ void tst_QQuickTableView::flickOvershoot()
WAIT_UNTIL_POLISHED;
- QCOMPARE(tableViewPrivate->loadedTable.left(), 0);
- QCOMPARE(tableViewPrivate->loadedTable.right(), 0);
- QCOMPARE(tableViewPrivate->loadedTable.top(), 0);
- QCOMPARE(tableViewPrivate->loadedTable.bottom(), rowCount - 1);
+ QCOMPARE(tableViewPrivate->leftColumn(), 0);
+ QCOMPARE(tableViewPrivate->rightColumn(), 0);
+ QCOMPARE(tableViewPrivate->topRow(), 0);
+ QCOMPARE(tableViewPrivate->bottomRow(), rowCount - 1);
// Flick table out of view right
tableView->setContentX(tableWidth + outsideMargin);
@@ -1264,10 +1315,10 @@ void tst_QQuickTableView::flickOvershoot()
WAIT_UNTIL_POLISHED;
- QCOMPARE(tableViewPrivate->loadedTable.left(), columnCount - 1);
- QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1);
- QCOMPARE(tableViewPrivate->loadedTable.top(), 0);
- QCOMPARE(tableViewPrivate->loadedTable.bottom(), rowCount - 1);
+ QCOMPARE(tableViewPrivate->leftColumn(), columnCount - 1);
+ QCOMPARE(tableViewPrivate->rightColumn(), columnCount - 1);
+ QCOMPARE(tableViewPrivate->topRow(), 0);
+ QCOMPARE(tableViewPrivate->bottomRow(), rowCount - 1);
// Flick table out of view on top
tableView->setContentX(0);
@@ -1276,10 +1327,10 @@ void tst_QQuickTableView::flickOvershoot()
WAIT_UNTIL_POLISHED;
- QCOMPARE(tableViewPrivate->loadedTable.left(), 0);
- QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1);
- QCOMPARE(tableViewPrivate->loadedTable.top(), 0);
- QCOMPARE(tableViewPrivate->loadedTable.bottom(), 0);
+ QCOMPARE(tableViewPrivate->leftColumn(), 0);
+ QCOMPARE(tableViewPrivate->rightColumn(), columnCount - 1);
+ QCOMPARE(tableViewPrivate->topRow(), 0);
+ QCOMPARE(tableViewPrivate->bottomRow(), 0);
// Flick table out of view at the bottom
tableView->setContentX(0);
@@ -1288,10 +1339,10 @@ void tst_QQuickTableView::flickOvershoot()
WAIT_UNTIL_POLISHED;
- QCOMPARE(tableViewPrivate->loadedTable.left(), 0);
- QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1);
- QCOMPARE(tableViewPrivate->loadedTable.top(), rowCount - 1);
- QCOMPARE(tableViewPrivate->loadedTable.bottom(), rowCount - 1);
+ QCOMPARE(tableViewPrivate->leftColumn(), 0);
+ QCOMPARE(tableViewPrivate->rightColumn(), columnCount - 1);
+ QCOMPARE(tableViewPrivate->topRow(), rowCount - 1);
+ QCOMPARE(tableViewPrivate->bottomRow(), rowCount - 1);
// Flick table out of view left and top at the same time
tableView->setContentX(-tableView->width() - outsideMargin);
@@ -1300,10 +1351,10 @@ void tst_QQuickTableView::flickOvershoot()
WAIT_UNTIL_POLISHED;
- QCOMPARE(tableViewPrivate->loadedTable.left(), 0);
- QCOMPARE(tableViewPrivate->loadedTable.right(), 0);
- QCOMPARE(tableViewPrivate->loadedTable.top(), 0);
- QCOMPARE(tableViewPrivate->loadedTable.bottom(), 0);
+ QCOMPARE(tableViewPrivate->leftColumn(), 0);
+ QCOMPARE(tableViewPrivate->rightColumn(), 0);
+ QCOMPARE(tableViewPrivate->topRow(), 0);
+ QCOMPARE(tableViewPrivate->bottomRow(), 0);
// Flick table back to origo
tableView->setContentX(0);
@@ -1312,10 +1363,10 @@ void tst_QQuickTableView::flickOvershoot()
WAIT_UNTIL_POLISHED;
- QCOMPARE(tableViewPrivate->loadedTable.left(), 0);
- QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1);
- QCOMPARE(tableViewPrivate->loadedTable.top(), 0);
- QCOMPARE(tableViewPrivate->loadedTable.bottom(), rowCount - 1);
+ QCOMPARE(tableViewPrivate->leftColumn(), 0);
+ QCOMPARE(tableViewPrivate->rightColumn(), columnCount - 1);
+ QCOMPARE(tableViewPrivate->topRow(), 0);
+ QCOMPARE(tableViewPrivate->bottomRow(), rowCount - 1);
// Flick table out of view right and bottom at the same time
tableView->setContentX(tableWidth + outsideMargin);
@@ -1324,10 +1375,10 @@ void tst_QQuickTableView::flickOvershoot()
WAIT_UNTIL_POLISHED;
- QCOMPARE(tableViewPrivate->loadedTable.left(), columnCount - 1);
- QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1);
- QCOMPARE(tableViewPrivate->loadedTable.top(), rowCount - 1);
- QCOMPARE(tableViewPrivate->loadedTable.bottom(), rowCount - 1);
+ QCOMPARE(tableViewPrivate->leftColumn(), columnCount - 1);
+ QCOMPARE(tableViewPrivate->rightColumn(), columnCount - 1);
+ QCOMPARE(tableViewPrivate->topRow(), rowCount - 1);
+ QCOMPARE(tableViewPrivate->bottomRow(), rowCount - 1);
// Flick table back to origo
tableView->setContentX(0);
@@ -1336,10 +1387,10 @@ void tst_QQuickTableView::flickOvershoot()
WAIT_UNTIL_POLISHED;
- QCOMPARE(tableViewPrivate->loadedTable.left(), 0);
- QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1);
- QCOMPARE(tableViewPrivate->loadedTable.top(), 0);
- QCOMPARE(tableViewPrivate->loadedTable.bottom(), rowCount - 1);
+ QCOMPARE(tableViewPrivate->leftColumn(), 0);
+ QCOMPARE(tableViewPrivate->rightColumn(), columnCount - 1);
+ QCOMPARE(tableViewPrivate->topRow(), 0);
+ QCOMPARE(tableViewPrivate->bottomRow(), rowCount - 1);
}
void tst_QQuickTableView::checkRowColumnCount()
@@ -1353,6 +1404,8 @@ void tst_QQuickTableView::checkRowColumnCount()
const qreal delegateWidth = 100;
const qreal delegateHeight = 50;
auto model = TestModelAsVariant(100, 100);
+ const auto &loadedRows = tableViewPrivate->loadedRows;
+ const auto &loadedColumns = tableViewPrivate->loadedColumns;
tableView->setModel(model);
@@ -1360,17 +1413,15 @@ void tst_QQuickTableView::checkRowColumnCount()
// We expect that the number of created items after start-up should match
//the size of the visible table, pluss one extra preloaded row and column.
- const QSize visibleTableSize = tableViewPrivate->loadedTable.size();
const int qmlCountAfterInit = view->rootObject()->property(maxDelegateCountProp).toInt();
- const int expectedCount = (visibleTableSize.width() + 1) * (visibleTableSize.height() + 1);
+ const int expectedCount = (loadedColumns.count() + 1) * (loadedRows.count() + 1);
QCOMPARE(qmlCountAfterInit, expectedCount);
// This test will keep track of the maximum number of delegate items TableView
// had to show at any point while flicking (in countingtableview.qml). Because
// of the geometries chosen for TableView and the delegate, only complete columns
// will be shown at start-up.
- const QRect loadedTable = tableViewPrivate->loadedTable;
- QVERIFY(loadedTable.height() > loadedTable.width());
+ QVERIFY(loadedRows.count() > loadedColumns.count());
QCOMPARE(tableViewPrivate->loadedTableOuterRect.width(), tableView->width());
QCOMPARE(tableViewPrivate->loadedTableOuterRect.height(), tableView->height());
@@ -1619,8 +1670,8 @@ void tst_QQuickTableView::checkIfDelegatesAreReused()
fxItem->item->setProperty("reusedCount", 0);
}
- const int visibleColumnCount = tableViewPrivate->loadedTable.width();
- const int visibleRowCount = tableViewPrivate->loadedTable.height();
+ const int visibleColumnCount = tableViewPrivate->loadedColumns.count();
+ const int visibleRowCount = tableViewPrivate->loadedRows.count();
const int delegateCountAfterInit = view->rootObject()->property(kDelegatesCreatedCountProp).toInt();
for (int column = 1; column <= (visibleColumnCount * pageFlickCount); ++column) {
@@ -1687,7 +1738,7 @@ void tst_QQuickTableView::checkIfDelegatesAreReusedAsymmetricTableSize()
// Since we have flicked half a delegate to the left, the number of visible
// columns is now one more than the column count were when we started the test.
- const int visibleColumnCount = tableViewPrivate->loadedTable.width();
+ const int visibleColumnCount = tableViewPrivate->loadedColumns.count();
QCOMPARE(visibleColumnCount, columnCount + 1);
// We expect no items to have been pooled so far
@@ -1887,7 +1938,7 @@ void tst_QQuickTableView::checkChangingModelFromDelegate()
// We now expect two rows in the table, one more than initially
QCOMPARE(tableViewPrivate->tableSize.height(), 2);
- QCOMPARE(tableViewPrivate->loadedTable.height(), 2);
+ QCOMPARE(tableViewPrivate->loadedRows.count(), 2);
// And since the QML code tried to add another row as well, we
// expect rebuildScheduled to be true, and a polish event to be pending.
@@ -1897,7 +1948,7 @@ void tst_QQuickTableView::checkChangingModelFromDelegate()
// After handling the polish event, we expect also the third row to now be added
QCOMPARE(tableViewPrivate->tableSize.height(), 3);
- QCOMPARE(tableViewPrivate->loadedTable.height(), 3);
+ QCOMPARE(tableViewPrivate->loadedRows.count(), 3);
}
void tst_QQuickTableView::checkRebuildViewportOnly()
@@ -1982,8 +2033,8 @@ void tst_QQuickTableView::checkTableviewInsideAsyncLoader()
const qreal delegateHeight = 50;
int expectedColumns = qCeil(tableView->width() / delegateWidth);
int expectedRows = qCeil(tableView->height() / delegateHeight);
- QCOMPARE(tableViewPrivate->loadedTable.width(), expectedColumns);
- QCOMPARE(tableViewPrivate->loadedTable.height(), expectedRows);
+ QCOMPARE(tableViewPrivate->loadedColumns.count(), expectedColumns);
+ QCOMPARE(tableViewPrivate->loadedRows.count(), expectedRows);
// Check that the loader was still in a loading state while TableView was creating
// delegate items. If we delayed creating delegate items until we got the first
@@ -2004,6 +2055,92 @@ void tst_QQuickTableView::checkTableviewInsideAsyncLoader()
QVERIFY(height > 0);
};
+#define INT_LIST(indices) QVariant::fromValue(QList<int>() << indices)
+
+void tst_QQuickTableView::hideRowsAndColumns_data()
+{
+ QTest::addColumn<QVariant>("rowsToHide");
+ QTest::addColumn<QVariant>("columnsToHide");
+
+ const auto emptyList = QVariant::fromValue(QList<int>());
+
+ // Hide rows
+ QTest::newRow("first") << INT_LIST(0) << emptyList;
+ QTest::newRow("middle 1") << INT_LIST(1) << emptyList;
+ QTest::newRow("middle 3") << INT_LIST(3) << emptyList;
+ QTest::newRow("last") << INT_LIST(4) << emptyList;
+
+ QTest::newRow("subsequent 0,1") << INT_LIST(0 << 1) << emptyList;
+ QTest::newRow("subsequent 1,2") << INT_LIST(1 << 2) << emptyList;
+ QTest::newRow("subsequent 3,4") << INT_LIST(3 << 4) << emptyList;
+
+ QTest::newRow("all but first") << INT_LIST(1 << 2 << 3 << 4) << emptyList;
+ QTest::newRow("all but last") << INT_LIST(0 << 1 << 2 << 3) << emptyList;
+ QTest::newRow("all but middle") << INT_LIST(0 << 1 << 3 << 4) << emptyList;
+
+ // Hide columns
+ QTest::newRow("first") << emptyList << INT_LIST(0);
+ QTest::newRow("middle 1") << emptyList << INT_LIST(1);
+ QTest::newRow("middle 3") << emptyList << INT_LIST(3);
+ QTest::newRow("last") << emptyList << INT_LIST(4);
+
+ QTest::newRow("subsequent 0,1") << emptyList << INT_LIST(0 << 1);
+ QTest::newRow("subsequent 1,2") << emptyList << INT_LIST(1 << 2);
+ QTest::newRow("subsequent 3,4") << emptyList << INT_LIST(3 << 4);
+
+ QTest::newRow("all but first") << emptyList << INT_LIST(1 << 2 << 3 << 4);
+ QTest::newRow("all but last") << emptyList << INT_LIST(0 << 1 << 2 << 3);
+ QTest::newRow("all but middle") << emptyList << INT_LIST(0 << 1 << 3 << 4);
+
+ // Hide both rows and columns at the same time
+ QTest::newRow("first") << INT_LIST(0) << INT_LIST(0);
+ QTest::newRow("middle 1") << INT_LIST(1) << INT_LIST(1);
+ QTest::newRow("middle 3") << INT_LIST(3) << INT_LIST(3);
+ QTest::newRow("last") << INT_LIST(4) << INT_LIST(4);
+
+ QTest::newRow("subsequent 0,1") << INT_LIST(0 << 1) << INT_LIST(0 << 1);
+ QTest::newRow("subsequent 1,2") << INT_LIST(1 << 2) << INT_LIST(1 << 2);
+ QTest::newRow("subsequent 3,4") << INT_LIST(3 << 4) << INT_LIST(3 << 4);
+
+ QTest::newRow("all but first") << INT_LIST(1 << 2 << 3 << 4) << INT_LIST(1 << 2 << 3 << 4);
+ QTest::newRow("all but last") << INT_LIST(0 << 1 << 2 << 3) << INT_LIST(0 << 1 << 2 << 3);
+ QTest::newRow("all but middle") << INT_LIST(0 << 1 << 3 << 4) << INT_LIST(0 << 1 << 3 << 4);
+
+ // Hide all rows and columns
+ QTest::newRow("all") << INT_LIST(0 << 1 << 2 << 3 << 4) << INT_LIST(0 << 1 << 2 << 3 << 4);
+}
+
+void tst_QQuickTableView::hideRowsAndColumns()
+{
+ // Check that you can hide the first row (corner case)
+ // and that we load the other columns as expected.
+ QFETCH(QVariant, rowsToHide);
+ QFETCH(QVariant, columnsToHide);
+ LOAD_TABLEVIEW("hiderowsandcolumns.qml");
+
+ const QList<int> rowsToHideList = qvariant_cast<QList<int>>(rowsToHide);
+ const QList<int> columnsToHideList = qvariant_cast<QList<int>>(columnsToHide);
+ const int modelSize = 5;
+ auto model = TestModelAsVariant(modelSize, modelSize);
+ view->rootObject()->setProperty("rowsToHide", rowsToHide);
+ view->rootObject()->setProperty("columnsToHide", columnsToHide);
+
+ tableView->setModel(model);
+
+ WAIT_UNTIL_POLISHED;
+
+ const int expectedRowCount = modelSize - rowsToHideList.count();
+ const int expectedColumnCount = modelSize - columnsToHideList.count();
+ QCOMPARE(tableViewPrivate->loadedRows.count(), expectedRowCount);
+ QCOMPARE(tableViewPrivate->loadedColumns.count(), expectedColumnCount);
+
+ for (const int row : tableViewPrivate->loadedRows.keys())
+ QVERIFY(!rowsToHideList.contains(row));
+
+ for (const int column : tableViewPrivate->loadedColumns.keys())
+ QVERIFY(!columnsToHideList.contains(column));
+}
+
void tst_QQuickTableView::checkThatRevisionedPropertiesCannotBeUsedInOldImports()
{
// Check that if you use a QQmlAdaptorModel together with a Repeater, the
diff --git a/tests/auto/quick/qquicktext/qquicktext.pro b/tests/auto/quick/qquicktext/qquicktext.pro
index f76e8c95b2..fdea9dcddd 100644
--- a/tests/auto/quick/qquicktext/qquicktext.pro
+++ b/tests/auto/quick/qquicktext/qquicktext.pro
@@ -11,4 +11,4 @@ include (../../shared/util.pri)
TESTDATA = data/*
-QT += core-private gui-private qml-private quick-private network testlib
+QT += core-private gui-private qml-private quick-private network testlib qmltest
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index a9c35e0cc4..fd0ba0f49b 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -32,6 +32,7 @@
#include <QtQml/qqmlcomponent.h>
#include <QtQuick/private/qquicktext_p.h>
#include <QtQuick/private/qquickmousearea_p.h>
+#include <QtQuickTest/QtQuickTest>
#include <private/qquicktext_p_p.h>
#include <private/qquicktextdocument_p.h>
#include <private/qquickvaluetypes_p.h>
@@ -3142,7 +3143,7 @@ void tst_qquicktext::fontSizeMode()
QVERIFY(myText != nullptr);
myText->setText(text);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
qreal originalWidth = myText->contentWidth();
qreal originalHeight = myText->contentHeight();
@@ -3156,7 +3157,7 @@ void tst_qquicktext::fontSizeMode()
myText->setFont(font);
myText->setFontSizeMode(QQuickText::HorizontalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// Font size reduced to fit within the width of the item.
qreal horizontalFitWidth = myText->contentWidth();
qreal horizontalFitHeight = myText->contentHeight();
@@ -3165,28 +3166,28 @@ void tst_qquicktext::fontSizeMode()
// Elide won't affect the size with HorizontalFit.
myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
QCOMPARE(myText->contentHeight(), horizontalFitHeight);
myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
QCOMPARE(myText->contentHeight(), horizontalFitHeight);
myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
QCOMPARE(myText->contentHeight(), horizontalFitHeight);
myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
myText->setFontSizeMode(QQuickText::VerticalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// Font size increased to fill the height of the item.
qreal verticalFitHeight = myText->contentHeight();
QVERIFY(myText->contentWidth() > myText->width());
@@ -3195,57 +3196,57 @@ void tst_qquicktext::fontSizeMode()
// Elide won't affect the height of a single line with VerticalFit but will crop the width.
myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(myText->truncated());
QVERIFY(myText->contentWidth() <= myText->width() + 2);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(myText->truncated());
QVERIFY(myText->contentWidth() <= myText->width() + 2);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(myText->truncated());
QVERIFY(myText->contentWidth() <= myText->width() + 2);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
myText->setFontSizeMode(QQuickText::Fit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// Should be the same as HorizontalFit with no wrapping.
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
QCOMPARE(myText->contentHeight(), horizontalFitHeight);
// Elide won't affect the size with Fit.
myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
QCOMPARE(myText->contentHeight(), horizontalFitHeight);
myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
QCOMPARE(myText->contentHeight(), horizontalFitHeight);
myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
QCOMPARE(myText->contentHeight(), horizontalFitHeight);
myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
myText->setFontSizeMode(QQuickText::FixedSize);
myText->setWrapMode(QQuickText::Wrap);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
originalWidth = myText->contentWidth();
originalHeight = myText->contentHeight();
@@ -3255,7 +3256,7 @@ void tst_qquicktext::fontSizeMode()
QVERIFY(originalHeight > myText->height());
myText->setFontSizeMode(QQuickText::HorizontalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
// same size as without text wrapping.
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
@@ -3263,16 +3264,16 @@ void tst_qquicktext::fontSizeMode()
// Elide won't affect the size with HorizontalFit.
myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
QCOMPARE(myText->contentHeight(), horizontalFitHeight);
myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
myText->setFontSizeMode(QQuickText::VerticalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// VerticalFit should reduce the size to the wrapped text within the vertical height.
verticalFitHeight = myText->contentHeight();
qreal verticalFitWidth = myText->contentWidth();
@@ -3282,40 +3283,40 @@ void tst_qquicktext::fontSizeMode()
// Elide won't affect the height or width of a wrapped text with VerticalFit.
myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
myText->setFontSizeMode(QQuickText::Fit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// Should be the same as VerticalFit with wrapping.
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
// Elide won't affect the size with Fit.
myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
myText->setFontSizeMode(QQuickText::FixedSize);
myText->setMaximumLineCount(2);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// The original text wrapped should exceed the height of the item.
QVERIFY(originalWidth <= myText->width() + 2);
QVERIFY(originalHeight > myText->height());
myText->setFontSizeMode(QQuickText::HorizontalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
// same size as without text wrapping.
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
@@ -3323,16 +3324,16 @@ void tst_qquicktext::fontSizeMode()
// Elide won't affect the size with HorizontalFit.
myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
QCOMPARE(myText->contentHeight(), horizontalFitHeight);
myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
myText->setFontSizeMode(QQuickText::VerticalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// VerticalFit should reduce the size to the wrapped text within the vertical height.
verticalFitHeight = myText->contentHeight();
verticalFitWidth = myText->contentWidth();
@@ -3342,29 +3343,29 @@ void tst_qquicktext::fontSizeMode()
// Elide won't affect the height or width of a wrapped text with VerticalFit.
myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
myText->setFontSizeMode(QQuickText::Fit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// Should be the same as VerticalFit with wrapping.
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
// Elide won't affect the size with Fit.
myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
}
void tst_qquicktext::fontSizeModeMultiline_data()
@@ -3385,7 +3386,7 @@ void tst_qquicktext::fontSizeModeMultiline()
QVERIFY(myText != nullptr);
myText->setText(text);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
qreal originalWidth = myText->contentWidth();
qreal originalHeight = myText->contentHeight();
@@ -3400,7 +3401,7 @@ void tst_qquicktext::fontSizeModeMultiline()
myText->setFont(font);
myText->setFontSizeMode(QQuickText::HorizontalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// Font size reduced to fit within the width of the item.
QCOMPARE(myText->lineCount(), 2);
qreal horizontalFitWidth = myText->contentWidth();
@@ -3410,7 +3411,7 @@ void tst_qquicktext::fontSizeModeMultiline()
// Right eliding will remove the last line
myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(myText->truncated());
QCOMPARE(myText->lineCount(), 1);
QVERIFY(myText->contentWidth() <= myText->width() + 2);
@@ -3418,22 +3419,22 @@ void tst_qquicktext::fontSizeModeMultiline()
// Left or middle eliding wont have any effect.
myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
QCOMPARE(myText->contentHeight(), horizontalFitHeight);
myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
QCOMPARE(myText->contentHeight(), horizontalFitHeight);
myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
myText->setFontSizeMode(QQuickText::VerticalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// Font size reduced to fit within the height of the item.
qreal verticalFitWidth = myText->contentWidth();
qreal verticalFitHeight = myText->contentHeight();
@@ -3442,58 +3443,58 @@ void tst_qquicktext::fontSizeModeMultiline()
// Elide will have no effect.
myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QVERIFY(myText->contentWidth() <= myText->width() + 2);
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
myText->setFontSizeMode(QQuickText::Fit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// Should be the same as VerticalFit with no wrapping.
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
// Elide won't affect the size with Fit.
myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
myText->setFontSizeMode(QQuickText::FixedSize);
myText->setWrapMode(QQuickText::Wrap);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
originalWidth = myText->contentWidth();
originalHeight = myText->contentHeight();
@@ -3503,7 +3504,7 @@ void tst_qquicktext::fontSizeModeMultiline()
QVERIFY(originalHeight > myText->height());
myText->setFontSizeMode(QQuickText::HorizontalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
// same size as without text wrapping.
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
@@ -3511,16 +3512,16 @@ void tst_qquicktext::fontSizeModeMultiline()
// Text will be elided vertically with HorizontalFit
myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(myText->truncated());
QVERIFY(myText->contentWidth() <= myText->width() + 2);
QVERIFY(myText->contentHeight() <= myText->height() + 2);
myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
myText->setFontSizeMode(QQuickText::VerticalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// VerticalFit should reduce the size to the wrapped text within the vertical height.
verticalFitHeight = myText->contentHeight();
verticalFitWidth = myText->contentWidth();
@@ -3530,40 +3531,40 @@ void tst_qquicktext::fontSizeModeMultiline()
// Elide won't affect the height or width of a wrapped text with VerticalFit.
myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
myText->setFontSizeMode(QQuickText::Fit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// Should be the same as VerticalFit with wrapping.
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
// Elide won't affect the size with Fit.
myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
myText->setFontSizeMode(QQuickText::FixedSize);
myText->setMaximumLineCount(2);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// The original text wrapped should exceed the height of the item.
QVERIFY(originalWidth <= myText->width() + 2);
QVERIFY(originalHeight > myText->height());
myText->setFontSizeMode(QQuickText::HorizontalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
// same size as without text wrapping.
QCOMPARE(myText->contentWidth(), horizontalFitWidth);
@@ -3571,16 +3572,16 @@ void tst_qquicktext::fontSizeModeMultiline()
// Elide won't affect the size with HorizontalFit.
myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(myText->truncated());
QVERIFY(myText->contentWidth() <= myText->width() + 2);
QVERIFY(myText->contentHeight() <= myText->height() + 2);
myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
myText->setFontSizeMode(QQuickText::VerticalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// VerticalFit should reduce the size to the wrapped text within the vertical height.
verticalFitHeight = myText->contentHeight();
verticalFitWidth = myText->contentWidth();
@@ -3590,29 +3591,29 @@ void tst_qquicktext::fontSizeModeMultiline()
// Elide won't affect the height or width of a wrapped text with VerticalFit.
myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
myText->setFontSizeMode(QQuickText::Fit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
// Should be the same as VerticalFit with wrapping.
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
// Elide won't affect the size with Fit.
myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QVERIFY(!myText->truncated());
QCOMPARE(myText->contentWidth(), verticalFitWidth);
QCOMPARE(myText->contentHeight(), verticalFitHeight);
myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
}
void tst_qquicktext::multilengthStrings_data()
@@ -3637,17 +3638,17 @@ void tst_qquicktext::multilengthStrings()
const QString shortText = "fox jumped dog";
myText->setText(longText);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
const qreal longWidth = myText->contentWidth();
const qreal longHeight = myText->contentHeight();
myText->setText(mediumText);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
const qreal mediumWidth = myText->contentWidth();
const qreal mediumHeight = myText->contentHeight();
myText->setText(shortText);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
const qreal shortWidth = myText->contentWidth();
const qreal shortHeight = myText->contentHeight();
@@ -3655,21 +3656,21 @@ void tst_qquicktext::multilengthStrings()
myText->setText(longText + QLatin1Char('\x9c') + mediumText + QLatin1Char('\x9c') + shortText);
myText->setSize(QSizeF(longWidth, longHeight));
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QCOMPARE(myText->contentWidth(), longWidth);
QCOMPARE(myText->contentHeight(), longHeight);
QCOMPARE(myText->truncated(), false);
myText->setSize(QSizeF(mediumWidth, mediumHeight));
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QCOMPARE(myText->contentWidth(), mediumWidth);
QCOMPARE(myText->contentHeight(), mediumHeight);
QCOMPARE(myText->truncated(), true);
myText->setSize(QSizeF(shortWidth, shortHeight));
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(QQuickTest::qWaitForItemPolished(myText));
QCOMPARE(myText->contentWidth(), shortWidth);
QCOMPARE(myText->contentHeight(), shortHeight);
diff --git a/tests/auto/quick/qquicktextedit/data/keys_shortcutoverride.qml b/tests/auto/quick/qquicktextedit/data/keys_shortcutoverride.qml
new file mode 100644
index 0000000000..24bd434830
--- /dev/null
+++ b/tests/auto/quick/qquicktextedit/data/keys_shortcutoverride.qml
@@ -0,0 +1,34 @@
+import QtQuick 2.10
+
+Item {
+ width: 320
+ height: 200
+ property string who : "nobody"
+
+ Shortcut {
+ sequence: "Esc"
+ onActivated: who = "Shortcut"
+ }
+
+ TextEdit {
+ id: txt
+ x: 100
+ text: "enter text"
+ Keys.onShortcutOverride: {
+ who = "TextEdit"
+ event.accepted = (event.key === Qt.Key_Escape)
+ }
+ }
+
+ Rectangle {
+ objectName: "rectangle"
+ width: 90
+ height: width
+ focus: true
+ color: focus ? "red" : "gray"
+ Keys.onShortcutOverride: {
+ who = "Rectangle"
+ event.accepted = (event.key === Qt.Key_Escape)
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index da15ca6b48..ce2a8eb257 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -36,6 +36,7 @@
#include <QtQml/qqmlexpression.h>
#include <QtQml/qqmlcomponent.h>
#include <QtGui/qguiapplication.h>
+#include <private/qquickrectangle_p.h>
#include <private/qquicktextedit_p.h>
#include <private/qquicktextedit_p_p.h>
#include <private/qquicktext_p.h>
@@ -205,6 +206,7 @@ private slots:
void padding();
void QTBUG_51115_readOnlyResetsSelection();
+ void keys_shortcutoverride();
private:
void simulateKeys(QWindow *window, const QList<Key> &keys);
@@ -1260,6 +1262,34 @@ void tst_qquicktextedit::persistentSelection()
edit->setFocus(true);
QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
+ // QTBUG-50587 (persistentSelection with readOnly)
+ edit->setReadOnly(true);
+
+ edit->setPersistentSelection(false);
+ QCOMPARE(edit->persistentSelection(), false);
+ QCOMPARE(spy.count(), 2);
+
+ edit->select(1, 4);
+ QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
+
+ edit->setFocus(false);
+ QCOMPARE(edit->property("selected").toString(), QString());
+
+ edit->setFocus(true);
+ QCOMPARE(edit->property("selected").toString(), QString());
+
+ edit->setPersistentSelection(true);
+ QCOMPARE(edit->persistentSelection(), true);
+ QCOMPARE(spy.count(), 3);
+
+ edit->select(1, 4);
+ QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
+
+ edit->setFocus(false);
+ QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
+
+ edit->setFocus(true);
+ QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
}
void tst_qquicktextedit::selectionOnFocusOut()
@@ -5671,6 +5701,36 @@ void tst_qquicktextedit::QTBUG_51115_readOnlyResetsSelection()
QCOMPARE(obj->selectedText(), QString());
}
+void tst_qquicktextedit::keys_shortcutoverride()
+{
+ // Tests that QML TextEdit receives Keys.onShortcutOverride (QTBUG-68711)
+ QQuickView view;
+ view.setSource(testFileUrl("keys_shortcutoverride.qml"));
+ view.show();
+ view.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+ QObject *root = view.rootObject();
+ QVERIFY(root);
+
+ QQuickTextEdit *textEdit = root->findChild<QQuickTextEdit*>();
+ QVERIFY(textEdit);
+ QQuickRectangle *rectangle = root->findChild<QQuickRectangle*>(QLatin1String("rectangle"));
+ QVERIFY(rectangle);
+
+ // Precondition: check if its not already changed
+ QCOMPARE(root->property("who").value<QString>(), QLatin1String("nobody"));
+
+ // send Key_Escape to the Rectangle
+ QVERIFY(rectangle->hasActiveFocus());
+ QTest::keyPress(&view, Qt::Key_Escape);
+ QCOMPARE(root->property("who").value<QString>(), QLatin1String("Rectangle"));
+
+ // send Key_Escape to TextEdit
+ textEdit->setFocus(true);
+ QTest::keyPress(&view, Qt::Key_Escape);
+ QCOMPARE(root->property("who").value<QString>(), QLatin1String("TextEdit"));
+}
+
QTEST_MAIN(tst_qquicktextedit)
#include "tst_qquicktextedit.moc"
diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp
index 12d54c4bbe..5631ffe047 100644
--- a/tests/auto/quick/shared/viewtestutil.cpp
+++ b/tests/auto/quick/shared/viewtestutil.cpp
@@ -38,6 +38,7 @@
#include <private/qquickwindow_p.h>
#include <private/qquickitemview_p_p.h>
+QT_BEGIN_NAMESPACE
QQuickView *QQuickViewTestUtil::createView()
{
@@ -478,3 +479,5 @@ namespace QQuickTest {
return true;
}
}
+
+QT_END_NAMESPACE
diff --git a/tests/auto/quick/shared/viewtestutil.h b/tests/auto/quick/shared/viewtestutil.h
index 3b57a29777..5e725fdf11 100644
--- a/tests/auto/quick/shared/viewtestutil.h
+++ b/tests/auto/quick/shared/viewtestutil.h
@@ -37,6 +37,8 @@ QT_FORWARD_DECLARE_CLASS(QQuickView)
QT_FORWARD_DECLARE_CLASS(QQuickItemViewPrivate)
QT_FORWARD_DECLARE_CLASS(FxViewItem)
+QT_BEGIN_NAMESPACE
+
namespace QQuickViewTestUtil
{
QQuickView *createView();
@@ -189,6 +191,8 @@ namespace QQuickTest {
bool initView(QQuickView &v, const QUrl &url, bool moveMouseOut, QByteArray *errorMessage);
}
+QT_END_NAMESPACE
+
Q_DECLARE_METATYPE(QQuickViewTestUtil::QaimModel*)
Q_DECLARE_METATYPE(QQuickViewTestUtil::ListChange)
Q_DECLARE_METATYPE(QList<QQuickViewTestUtil::ListChange>)
diff --git a/tests/auto/quick/shared/visualtestutil.h b/tests/auto/quick/shared/visualtestutil.h
index 1cdbaf838b..e623e3e225 100644
--- a/tests/auto/quick/shared/visualtestutil.h
+++ b/tests/auto/quick/shared/visualtestutil.h
@@ -100,7 +100,4 @@ namespace QQuickVisualTestUtil
bool compareImages(const QImage &ia, const QImage &ib, QString *errorMessage);
}
-#define QQUICK_VERIFY_POLISH(item) \
- QTRY_COMPARE(QQuickItemPrivate::get(item)->polishScheduled, false)
-
#endif // QQUICKVISUALTESTUTIL_H
diff --git a/tests/auto/qml/debugger/shared/qqmlinspectorclient.h b/tests/auto/quicktest/polish-qml/data/tst_polish.qml
index bfb489c8f7..d2d5972d43 100644
--- a/tests/auto/qml/debugger/shared/qqmlinspectorclient.h
+++ b/tests/auto/quicktest/polish-qml/data/tst_polish.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -25,35 +25,36 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#ifndef QQMLINSPECTORCLIENT_H
-#define QQMLINSPECTORCLIENT_H
-#include <private/qqmldebugclient_p.h>
+import QtQuick 2.13
+import QtTest 1.13
-class QQmlInspectorClient : public QQmlDebugClient
-{
- Q_OBJECT
+import Test 1.0
-public:
- QQmlInspectorClient(QQmlDebugConnection *connection);
+TestCase {
+ id: testCase
+ name: "polish-qml"
+ when: windowShown
- int setInspectToolEnabled(bool enabled);
- int setShowAppOnTop(bool showOnTop);
- int setAnimationSpeed(qreal speed);
- int select(const QList<int> &objectIds);
- int createObject(const QString &qml, int parentId, const QStringList &imports,
- const QString &filename);
- int moveObject(int childId, int newParentId);
- int destroyObject(int objectId);
+ Component {
+ id: customItemComponent
+ CustomItem {}
+ }
-signals:
- void responseReceived(int requestId, bool result);
+ function test_polish()
+ {
+ var item = createTemporaryObject(customItemComponent, testCase)
+ verify(item)
-protected:
- void messageReceived(const QByteArray &message);
+ item.polishMe()
+ verify(isPolishScheduled(item))
+ verify(item.isPolishScheduled())
-private:
- int m_lastRequestId;
-};
+ verify(waitForItemPolished(item))
+ verify(item.wasUpdatePolishCalled())
-#endif // QQMLINSPECTORCLIENT_H
+ // TODO: test failure conditions when https://bugreports.qt.io/browse/QTBUG-72351 is fixed
+// expectFail("", "Not a valid item")
+// isPolishScheduled(null)
+ }
+}
diff --git a/tests/auto/quicktest/polish-qml/polish-qml.pro b/tests/auto/quicktest/polish-qml/polish-qml.pro
new file mode 100644
index 0000000000..15b913ffe1
--- /dev/null
+++ b/tests/auto/quicktest/polish-qml/polish-qml.pro
@@ -0,0 +1,12 @@
+CONFIG += qmltestcase
+macos:CONFIG -= app_bundle
+TARGET = tst_polish-qml
+
+QT += testlib quick quick-private
+
+include (../../shared/util.pri)
+
+SOURCES += tst_polish-qml.cpp
+
+TESTDATA += \
+ $$PWD/data/*.qml
diff --git a/tests/auto/quicktest/polish-qml/tst_polish-qml.cpp b/tests/auto/quicktest/polish-qml/tst_polish-qml.cpp
new file mode 100644
index 0000000000..e525a8a5af
--- /dev/null
+++ b/tests/auto/quicktest/polish-qml/tst_polish-qml.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 <QtTest/qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuickTest/quicktest.h>
+
+#include "../../shared/util.h"
+
+class CustomItem : public QQuickItem
+{
+ Q_OBJECT
+
+public:
+ CustomItem() {}
+
+ Q_INVOKABLE void polishMe() {
+ polish();
+ }
+
+ Q_INVOKABLE bool isPolishScheduled() const
+ {
+ return QQuickItemPrivate::get(this)->polishScheduled;
+ }
+
+ Q_INVOKABLE bool wasUpdatePolishCalled() const
+ {
+ return updatePolishCalled;
+ }
+
+ void updatePolish() override
+ {
+ updatePolishCalled = true;
+ }
+
+private:
+ bool updatePolishCalled = false;
+};
+
+class TestSetup : public QObject
+{
+ Q_OBJECT
+
+public:
+ TestSetup() {}
+
+public slots:
+ void applicationAvailable()
+ {
+ qmlRegisterType<CustomItem>("Test", 1, 0, "CustomItem");
+ }
+};
+
+QUICK_TEST_MAIN_WITH_SETUP(polish-qml, TestSetup)
+
+#include "tst_polish-qml.moc"
diff --git a/tests/auto/quicktest/polish/data/polish.qml b/tests/auto/quicktest/polish/data/polish.qml
new file mode 100644
index 0000000000..0ab3afda2e
--- /dev/null
+++ b/tests/auto/quicktest/polish/data/polish.qml
@@ -0,0 +1,32 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 Test 1.0
+
+CustomItem {}
diff --git a/tests/auto/quicktest/polish/polish.pro b/tests/auto/quicktest/polish/polish.pro
new file mode 100644
index 0000000000..0dfb4bdf5e
--- /dev/null
+++ b/tests/auto/quicktest/polish/polish.pro
@@ -0,0 +1,12 @@
+CONFIG += qmltestcase
+macos:CONFIG -= app_bundle
+TARGET = tst_polish
+
+QT += testlib quick quick-private
+
+include (../../shared/util.pri)
+
+SOURCES += tst_polish.cpp
+
+TESTDATA += \
+ $$PWD/data/*.qml
diff --git a/tests/auto/quicktest/polish/tst_polish.cpp b/tests/auto/quicktest/polish/tst_polish.cpp
new file mode 100644
index 0000000000..3b96002cd2
--- /dev/null
+++ b/tests/auto/quicktest/polish/tst_polish.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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 <QtTest/qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQuick/qquickitem.h>
+#include <QQuickView>
+#include <QtQuickTest/quicktest.h>
+
+#include "../../shared/util.h"
+
+class CustomItem : public QQuickItem
+{
+ Q_OBJECT
+
+public:
+ CustomItem() {}
+
+ void updatePolish() override
+ {
+ updatePolishCalled = true;
+ }
+
+ bool updatePolishCalled = false;
+};
+
+class tst_Polish : public QQmlDataTest
+{
+ Q_OBJECT
+
+public:
+ tst_Polish();
+
+private slots:
+ void testPolish();
+};
+
+tst_Polish::tst_Polish()
+{
+ qmlRegisterType<CustomItem>("Test", 1, 0, "CustomItem");
+}
+
+void tst_Polish::testPolish()
+{
+ QQuickView view;
+ view.setSource(testFileUrl("polish.qml"));
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+
+ CustomItem *item = qobject_cast<CustomItem*>(view.rootObject());
+ QVERIFY(item);
+
+ item->polish();
+ QVERIFY(QQuickTest::qIsPolishScheduled(item));
+ QVERIFY(!item->updatePolishCalled);
+ QVERIFY(QQuickTest::qWaitForItemPolished(item));
+ QVERIFY(item->updatePolishCalled);
+}
+
+QTEST_MAIN(tst_Polish)
+
+#include "tst_polish.moc"
diff --git a/tests/auto/quicktest/quicktest.pro b/tests/auto/quicktest/quicktest.pro
index 0e3f257e33..6d09f76c1d 100644
--- a/tests/auto/quicktest/quicktest.pro
+++ b/tests/auto/quicktest/quicktest.pro
@@ -1,5 +1,6 @@
TEMPLATE = subdirs
SUBDIRS = \
+ polish \
signalspy \
quicktestmainwithsetup \
testfiltering
diff --git a/tests/manual/scenegraph_lancelot/data/text/text_wrap_elide_maxlines.qml b/tests/manual/scenegraph_lancelot/data/text/text_wrap_elide_maxlines.qml
new file mode 100644
index 0000000000..927f2b3148
--- /dev/null
+++ b/tests/manual/scenegraph_lancelot/data/text/text_wrap_elide_maxlines.qml
@@ -0,0 +1,133 @@
+import QtQuick 2.0
+
+//test wrapping and elision when maximumLineCount is set
+
+Item {
+ width: 320
+ height: 480
+ Rectangle {
+ id: text_area
+ color: "light yellow"
+ x: 50
+ y: 0
+ height: parent.height
+ width: 150
+ }
+ Text {
+ id: text_0000
+ wrapMode: Text.WrapAnywhere
+ text: "The quick brown fox jumps over the lazy dog."
+ x: text_area.x
+ y: text_area.y
+ width: text_area.width
+ maximumLineCount: 2
+ elide: Text.ElideRight
+ color: "red"
+ font.family: "Arial"
+ font.pixelSize: 22
+ }
+ Text {
+ id: text_0001
+ wrapMode: Text.Wrap
+ text: text_0000.text
+ anchors.top: text_0000.bottom
+ anchors.left: text_0000.left
+ width: text_0000.width
+ maximumLineCount: text_0000.maximumLineCount
+ elide: Text.ElideRight
+ color: "blue"
+ font.family: text_0000.font.family
+ font.pixelSize: text_0000.font.pixelSize
+ }
+ Text {
+ id: text_0002
+ wrapMode: Text.WordWrap
+ text: text_0000.text
+ anchors.top: text_0001.bottom
+ anchors.left: text_0000.left
+ width: text_0000.width
+ maximumLineCount: text_0000.maximumLineCount
+ elide: Text.ElideRight
+ color: "green"
+ font.family: text_0000.font.family
+ font.pixelSize: text_0000.font.pixelSize
+ }
+ Text {
+ id: text_0003
+ wrapMode: Text.WrapAnywhere
+ text: "ABCDEFGHIJKL 1234567890123"
+ anchors.top: text_0002.bottom
+ anchors.left: text_0000.left
+ width: 150
+ maximumLineCount: 2
+ elide: Text.ElideRight
+ color: "red"
+ font.family: text_0000.font.family
+ font.pixelSize: text_0000.font.pixelSize
+ }
+ Text {
+ id: text_0004
+ wrapMode: Text.Wrap
+ text: text_0003.text
+ anchors.top: text_0003.bottom
+ anchors.left: text_0000.left
+ width: text_0000.width
+ maximumLineCount: text_0000.maximumLineCount
+ elide: Text.ElideRight
+ color: "blue"
+ font.family: text_0000.font.family
+ font.pixelSize: text_0000.font.pixelSize
+ }
+ Text {
+ id: text_0005
+ wrapMode: Text.WordWrap
+ text: text_0003.text
+ anchors.top: text_0004.bottom
+ anchors.left: text_0000.left
+ width: text_0000.width
+ maximumLineCount: text_0000.maximumLineCount
+ elide: Text.ElideRight
+ color: "green"
+ font.family: text_0000.font.family
+ font.pixelSize: text_0000.font.pixelSize
+ }
+ Text {
+ id: text_0006
+ wrapMode: Text.WrapAnywhere
+ text: "The quick brown 1234567890123"
+ anchors.top: text_0005.bottom
+ anchors.left: text_0000.left
+ width: 150
+ maximumLineCount: 2
+ elide: Text.ElideRight
+ color: "red"
+ font.family: text_0000.font.family
+ font.pixelSize: text_0000.font.pixelSize
+ }
+ Text {
+ id: text_0007
+ wrapMode: Text.Wrap
+ text: text_0006.text
+ anchors.top: text_0006.bottom
+ anchors.left: text_0000.left
+ width: text_0000.width
+ maximumLineCount: text_0000.maximumLineCount
+ elide: Text.ElideRight
+ color: "blue"
+ font.family: text_0000.font.family
+ font.pixelSize: text_0000.font.pixelSize
+ }
+ Text {
+ id: text_0008
+ wrapMode: Text.WordWrap
+ text: text_0006.text
+ anchors.top: text_0007.bottom
+ anchors.left: text_0000.left
+ width: text_0000.width
+ maximumLineCount: text_0000.maximumLineCount
+ elide: Text.ElideRight
+ color: "green"
+ font.family: text_0000.font.family
+ font.pixelSize: text_0000.font.pixelSize
+ }
+}
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index 7dfae2b53d..166c6aabdf 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 Research In Motion.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -164,54 +165,41 @@ class LoadWatcher : public QObject
public:
LoadWatcher(QQmlApplicationEngine *e, int expected)
: QObject(e)
- , earlyExit(false)
- , returnCode(0)
- , expect(expected)
- , haveOne(false)
+ , expectedFileCount(expected)
{
- connect(e, SIGNAL(objectCreated(QObject*,QUrl)),
- this, SLOT(checkFinished(QObject*)));
+ connect(e, &QQmlApplicationEngine::objectCreated, this, &LoadWatcher::checkFinished);
// QQmlApplicationEngine also connects quit() to QCoreApplication::quit
// and exit() to QCoreApplication::exit but if called before exec()
// then QCoreApplication::quit or QCoreApplication::exit does nothing
- connect(e, SIGNAL(quit()),
- this, SLOT(quit()));
- connect(e, &QQmlEngine::exit,
- this, &LoadWatcher::exit);
+ connect(e, &QQmlEngine::quit, this, &LoadWatcher::quit);
+ connect(e, &QQmlEngine::exit, this, &LoadWatcher::exit);
}
- bool earlyExit;
- int returnCode;
-
-private:
- void contain(QObject *o, const QUrl &containPath);
- void checkForWindow(QObject *o);
-
- int expect;
- bool haveOne;
+ bool earlyExit = false;
+ int returnCode = 0;
public Q_SLOTS:
- void checkFinished(QObject *o)
+ void checkFinished(QObject *o, const QUrl &url)
{
+ Q_UNUSED(url)
if (o) {
checkForWindow(o);
- haveOne = true;
if (conf && qae)
for (PartialScene *ps : qAsConst(conf->completers))
if (o->inherits(ps->itemType().toUtf8().constData()))
contain(o, ps->container());
}
- if (haveOne)
+ if (haveWindow)
return;
- if (! --expect) {
+ if (! --expectedFileCount) {
printf("qml: Did not load any objects, exiting.\n");
- std::exit(2);//Different return code from qFatal
+ std::exit(2); // Different return code from qFatal
}
}
void quit() {
- //Will be checked before calling exec()
+ // Will be checked before calling exec()
earlyExit = true;
returnCode = 0;
}
@@ -223,6 +211,14 @@ public Q_SLOTS:
#if defined(QT_GUI_LIB) && QT_CONFIG(opengl)
void onOpenGlContextCreated(QOpenGLContext *context);
#endif
+
+private:
+ void contain(QObject *o, const QUrl &containPath);
+ void checkForWindow(QObject *o);
+
+private:
+ int expectedFileCount;
+ bool haveWindow = false;
};
void LoadWatcher::contain(QObject *o, const QUrl &containPath)
@@ -237,15 +233,17 @@ void LoadWatcher::contain(QObject *o, const QUrl &containPath)
if ((idx = o2->metaObject()->indexOfProperty("containedObject")) != -1)
success = o2->metaObject()->property(idx).write(o2, QVariant::fromValue<QObject*>(o));
if (!success)
- o->setParent(o2); //Set QObject parent, and assume container will react as needed
+ o->setParent(o2); // Set QObject parent, and assume container will react as needed
}
void LoadWatcher::checkForWindow(QObject *o)
{
#if defined(QT_GUI_LIB) && QT_CONFIG(opengl)
- if (verboseMode && o->isWindowType() && o->inherits("QQuickWindow")) {
- connect(o, SIGNAL(openglContextCreated(QOpenGLContext*)),
- this, SLOT(onOpenGlContextCreated(QOpenGLContext*)));
+ if (o->isWindowType() && o->inherits("QQuickWindow")) {
+ haveWindow = true;
+ if (verboseMode)
+ connect(o, SIGNAL(openglContextCreated(QOpenGLContext*)),
+ this, SLOT(onOpenGlContextCreated(QOpenGLContext*)));
}
#else
Q_UNUSED(o)
@@ -274,7 +272,7 @@ void quietMessageHandler(QtMsgType type, const QMessageLogContext &ctxt, const Q
{
Q_UNUSED(ctxt);
Q_UNUSED(msg);
- //Doesn't print anything
+ // Doesn't print anything
switch (type) {
case QtFatalMsg:
exit(-1);
@@ -361,7 +359,7 @@ void noFilesGiven()
exit(1);
}
-//Called before application initialization, removes arguments it uses
+// Called before application initialization, removes arguments it uses
void getAppFlags(int &argc, char **argv)
{
#ifdef QT_GUI_LIB
@@ -471,7 +469,7 @@ int main(int argc, char *argv[])
QString translationFile;
QString dummyDir;
- //Handle main arguments
+ // Handle main arguments
const QStringList argList = app->arguments();
for (int i = 1; i < argList.count(); i++) {
const QString &arg = argList[i];
@@ -493,27 +491,27 @@ int main(int argc, char *argv[])
#endif
else if (arg == QLatin1String("-I")) {
if (i+1 == argList.count())
- continue;//Invalid usage, but just ignore it
+ continue; // Invalid usage, but just ignore it
e.addImportPath(argList[i+1]);
i++;
} else if (arg == QLatin1String("-f")) {
if (i+1 == argList.count())
- continue;//Invalid usage, but just ignore it
+ continue; // Invalid usage, but just ignore it
files << argList[i+1];
i++;
} else if (arg == QLatin1String("-config")){
if (i+1 == argList.count())
- continue;//Invalid usage, but just ignore it
+ continue; // Invalid usage, but just ignore it
confFile = argList[i+1];
i++;
} else if (arg == QLatin1String("-translation")){
if (i+1 == argList.count())
- continue;//Invalid usage, but just ignore it
+ continue; // Invalid usage, but just ignore it
translationFile = argList[i+1];
i++;
} else if (arg == QLatin1String("-dummy-data")){
if (i+1 == argList.count())
- continue;//Invalid usage, but just ignore it
+ continue; // Invalid usage, but just ignore it
dummyDir = argList[i+1];
i++;
} else if (arg == QLatin1String("-gles")) {
@@ -569,7 +567,7 @@ int main(int argc, char *argv[])
qae = &e;
loadConf(confFile, !verboseMode);
- //Load files
+ // Load files
QScopedPointer<LoadWatcher> lw(new LoadWatcher(&e, files.count()));
// Load dummy data before loading QML-files
@@ -582,8 +580,9 @@ int main(int argc, char *argv[])
printf("qml: loading %s\n", qPrintable(url.toString()));
QByteArray strippedFile;
if (getFileSansBangLine(path, strippedFile))
- e.loadData(strippedFile, e.baseUrl().resolved(url)); //QQmlComponent won't resolve it for us, it doesn't know it's a valid file if we loadData
- else //Errors or no bang line
+ // QQmlComponent won't resolve it for us: it doesn't know it's a valid file if we loadData
+ e.loadData(strippedFile, e.baseUrl().resolved(url));
+ else // Errors or no bang line
e.load(url);
}
diff --git a/tools/qmlcachegen/generateloader.cpp b/tools/qmlcachegen/generateloader.cpp
index 68aacf78ce..5b8fc34455 100644
--- a/tools/qmlcachegen/generateloader.cpp
+++ b/tools/qmlcachegen/generateloader.cpp
@@ -26,6 +26,7 @@
**
****************************************************************************/
#include <QByteArray>
+#include <QRegExp>
#include <QString>
#include <QStringList>
#include <QTextStream>
@@ -35,6 +36,8 @@
#include <QFileInfo>
#include <QSaveFile>
+#include <algorithm>
+
/*!
* \internal
* Mangles \a str to be a unique C++ identifier. Characters that are invalid for C++ identifiers
@@ -260,7 +263,8 @@ private:
}
};
-static QByteArray generateResourceDirectoryTree(QTextStream &code, const QStringList &qrcFiles)
+static QByteArray generateResourceDirectoryTree(QTextStream &code, const QStringList &qrcFiles,
+ const QStringList &sortedRetainedFiles)
{
QByteArray call;
if (qrcFiles.isEmpty())
@@ -269,14 +273,15 @@ static QByteArray generateResourceDirectoryTree(QTextStream &code, const QString
VirtualDirectoryEntry resourceDirs;
resourceDirs.name = QStringLiteral("/");
- foreach (const QString &entry, qrcFiles) {
+ for (const QString &entry : qrcFiles) {
const QStringList segments = entry.split(QLatin1Char('/'), QString::SkipEmptyParts);
VirtualDirectoryEntry *dirEntry = &resourceDirs;
for (int i = 0; i < segments.count() - 1; ++i)
dirEntry = dirEntry->append(segments.at(i));
- dirEntry->appendEmptyFile(segments.last());
+ if (!std::binary_search(sortedRetainedFiles.begin(), sortedRetainedFiles.end(), entry))
+ dirEntry->appendEmptyFile(segments.last());
}
if (resourceDirs.isEmpty())
@@ -327,7 +332,9 @@ static QString qtResourceNameForFile(const QString &fileName)
return name;
}
-bool generateLoader(const QStringList &compiledFiles, const QString &outputFileName, const QStringList &resourceFileMappings, QString *errorString)
+bool generateLoader(const QStringList &compiledFiles, const QStringList &sortedRetainedFiles,
+ const QString &outputFileName, const QStringList &resourceFileMappings,
+ QString *errorString)
{
QByteArray generatedLoaderCode;
@@ -338,13 +345,14 @@ bool generateLoader(const QStringList &compiledFiles, const QString &outputFileN
stream << "#include <QtCore/qurl.h>\n";
stream << "\n";
- QByteArray resourceRegisterCall = generateResourceDirectoryTree(stream, compiledFiles);
+ QByteArray resourceRegisterCall = generateResourceDirectoryTree(stream, compiledFiles,
+ sortedRetainedFiles);
stream << "namespace QmlCacheGeneratedCode {\n";
for (int i = 0; i < compiledFiles.count(); ++i) {
const QString compiledFile = compiledFiles.at(i);
const QString ns = symbolNamespaceForPath(compiledFile);
- stream << "namespace " << symbolNamespaceForPath(compiledFile) << " { \n";
+ stream << "namespace " << ns << " { \n";
stream << " extern const unsigned char qmlData[];\n";
stream << " const QQmlPrivate::CachedQmlUnit unit = {\n";
stream << " reinterpret_cast<const QV4::CompiledData::Unit*>(&qmlData), nullptr, nullptr\n";
diff --git a/tools/qmlcachegen/qmlcachegen.cpp b/tools/qmlcachegen/qmlcachegen.cpp
index b6b80a4461..df7468eaef 100644
--- a/tools/qmlcachegen/qmlcachegen.cpp
+++ b/tools/qmlcachegen/qmlcachegen.cpp
@@ -43,8 +43,12 @@
#include "resourcefilemapper.h"
+#include <algorithm>
+
int filterResourceFile(const QString &input, const QString &output);
-bool generateLoader(const QStringList &compiledFiles, const QString &output, const QStringList &resourceFileMappings, QString *errorString);
+bool generateLoader(const QStringList &compiledFiles, const QStringList &retainedFiles,
+ const QString &output, const QStringList &resourceFileMappings,
+ QString *errorString);
QString symbolNamespaceForPath(const QString &relativePath);
QSet<QString> illegalNames;
@@ -104,7 +108,7 @@ static void annotateListElements(QmlIR::Document *document)
{
QStringList listElementNames;
- foreach (const QV4::CompiledData::Import *import, document->imports) {
+ for (const QV4::CompiledData::Import *import : qAsConst(document->imports)) {
const QString uri = document->stringAt(import->uriIndex);
if (uri != QStringLiteral("QtQml.Models") && uri != QStringLiteral("QtQuick"))
continue;
@@ -121,7 +125,7 @@ static void annotateListElements(QmlIR::Document *document)
if (listElementNames.isEmpty())
return;
- foreach (QmlIR::Object *object, document->objects) {
+ for (QmlIR::Object *object : qAsConst(document->objects)) {
if (!listElementNames.contains(document->stringAt(object->inheritedTypeNameIndex)))
continue;
for (QmlIR::Binding *binding = object->firstBinding(); binding; binding = binding->next) {
@@ -420,6 +424,8 @@ int main(int argc, char **argv)
parser.addOption(resourceFileMappingOption);
QCommandLineOption resourceOption(QStringLiteral("resource"), QCoreApplication::translate("main", "Qt resource file that might later contain one of the compiled files"), QCoreApplication::translate("main", "resource-file-name"));
parser.addOption(resourceOption);
+ QCommandLineOption retainOption(QStringLiteral("retain"), QCoreApplication::translate("main", "Qt resource file the contents of which should not be replaced by empty stubs"), QCoreApplication::translate("main", "resource-file-name"));
+ parser.addOption(retainOption);
QCommandLineOption resourcePathOption(QStringLiteral("resource-path"), QCoreApplication::translate("main", "Qt resource file path corresponding to the file being compiled"), QCoreApplication::translate("main", "resource-path"));
parser.addOption(resourcePathOption);
@@ -467,9 +473,13 @@ int main(int argc, char **argv)
if (target == GenerateLoader) {
ResourceFileMapper mapper(sources);
+ ResourceFileMapper retain(parser.values(retainOption));
Error error;
- if (!generateLoader(mapper.qmlCompilerFiles(), outputFileName, parser.values(resourceFileMappingOption), &error.message)) {
+ QStringList retainedFiles = retain.qmlCompilerFiles();
+ std::sort(retainedFiles.begin(), retainedFiles.end());
+ if (!generateLoader(mapper.qmlCompilerFiles(), retainedFiles, outputFileName,
+ parser.values(resourceFileMappingOption), &error.message)) {
error.augment(QLatin1String("Error generating loader stub: ")).print();
return EXIT_FAILURE;
}
diff --git a/tools/qmlcachegen/qtquickcompiler.prf b/tools/qmlcachegen/qtquickcompiler.prf
index dd526f13a3..9c8c7a7b1e 100644
--- a/tools/qmlcachegen/qtquickcompiler.prf
+++ b/tools/qmlcachegen/qtquickcompiler.prf
@@ -16,6 +16,13 @@ defineReplace(qmlCacheResourceFileOutputName) {
return($${name})
}
+defineTest(qtQuickRetainSources) {
+ for(retainedRes, QTQUICK_COMPILER_RETAINED_RESOURCES) {
+ equals(1, $$retainedRes): return(true)
+ }
+ return(false)
+}
+
defineTest(qtQuickSkippedResourceFile) {
for(skippedRes, QTQUICK_COMPILER_SKIPPED_RESOURCES) {
equals(1, $$skippedRes): return(true)
@@ -40,12 +47,18 @@ for(res, RESOURCES) {
contains(rccContents,.*\\.js$)|contains(rccContents,.*\\.qml$)|contains(rccContents,.*\\.mjs$) {
new_resource = $$qmlCacheResourceFileOutputName($$res)
mkpath($$dirname(new_resource))
- remaining_files = $$system($$QML_CACHEGEN_FILTER -filter-resource-file -o $$system_quote($$new_resource) $$system_quote($$absRes),lines)
- !isEmpty(remaining_files) {
- NEWRESOURCES += $$new_resource
- QMLCACHE_LOADER_FLAGS += --resource-file-mapping=$$shell_quote($$absRes=$$new_resource)
+ qtQuickRetainSources($$res) {
+ NEWRESOURCES += $$res
+ QMLCACHE_LOADER_FLAGS += --retain=$$shell_quote($$absRes)
} else {
- QMLCACHE_LOADER_FLAGS += --resource-file-mapping=$$shell_quote($$absRes)
+ remaining_files = $$system($$QML_CACHEGEN_FILTER -filter-resource-file \
+ -o $$system_quote($$new_resource) $$system_quote($$absRes),lines)
+ !isEmpty(remaining_files) {
+ NEWRESOURCES += $$new_resource
+ QMLCACHE_LOADER_FLAGS += --resource-file-mapping=$$shell_quote($$absRes=$$new_resource)
+ } else {
+ QMLCACHE_LOADER_FLAGS += --resource-file-mapping=$$shell_quote($$absRes)
+ }
}
QMLCACHE_RESOURCE_FILES += $$absRes
diff --git a/tools/qmleasing/mainwindow.cpp b/tools/qmleasing/mainwindow.cpp
index c1a87642a5..679b4c0b91 100644
--- a/tools/qmleasing/mainwindow.cpp
+++ b/tools/qmleasing/mainwindow.cpp
@@ -82,7 +82,7 @@ MainWindow::MainWindow(QWidget *parent) :
splineEditor->setPreset(ui_properties.comboBox->currentText());
QVBoxLayout *groupBoxLayout = new QVBoxLayout(ui_properties.groupBox);
- groupBoxLayout->setMargin(0);
+ groupBoxLayout->setContentsMargins(QMargins());
ui_properties.groupBox->setLayout(groupBoxLayout);
groupBoxLayout->addWidget(splineEditor->pointListWidget());
diff --git a/tools/qmleasing/segmentproperties.cpp b/tools/qmleasing/segmentproperties.cpp
index f37527f863..c61feef9a4 100644
--- a/tools/qmleasing/segmentproperties.cpp
+++ b/tools/qmleasing/segmentproperties.cpp
@@ -33,7 +33,7 @@ SegmentProperties::SegmentProperties(QWidget *parent) :
QWidget(parent), m_splineEditor(nullptr), m_blockSignals(false)
{
QVBoxLayout *layout = new QVBoxLayout(this);
- layout->setMargin(0);
+ layout->setContentsMargins(QMargins());
layout->setSpacing(2);
setLayout(layout);
{
diff --git a/tools/qmleasing/splineeditor.cpp b/tools/qmleasing/splineeditor.cpp
index 2a6081903f..69850dc7a1 100644
--- a/tools/qmleasing/splineeditor.cpp
+++ b/tools/qmleasing/splineeditor.cpp
@@ -524,7 +524,7 @@ void SplineEditor::setupPointListWidget()
m_pointListWidget->setWidget(new QWidget(m_pointListWidget));
QVBoxLayout *layout = new QVBoxLayout(m_pointListWidget->widget());
- layout->setMargin(0);
+ layout->setContentsMargins(QMargins());
layout->setSpacing(2);
m_pointListWidget->widget()->setLayout(layout);
diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp
index 60e0f1773f..616de9e80d 100644
--- a/tools/qmlimportscanner/main.cpp
+++ b/tools/qmlimportscanner/main.cpp
@@ -89,13 +89,13 @@ QVariantList findImportsInAst(QQmlJS::AST::UiHeaderItemList *headerItemList, con
{
QVariantList imports;
- // extract uri and version from the imports (which look like "import Foo.Bar 1.2.3")
+ // Extract uri and version from the imports (which look like "import Foo.Bar 1.2.3")
for (QQmlJS::AST::UiHeaderItemList *headerItemIt = headerItemList; headerItemIt; headerItemIt = headerItemIt->next) {
QVariantMap import;
QQmlJS::AST::UiImport *importNode = QQmlJS::AST::cast<QQmlJS::AST::UiImport *>(headerItemIt->headerItem);
if (!importNode)
continue;
- // handle directory imports
+ // Handle directory imports
if (!importNode->fileName.isEmpty()) {
QString name = importNode->fileName.toString();
import[nameLiteral()] = name;
@@ -137,7 +137,7 @@ QVariantMap pluginsForModulePath(const QString &modulePath) {
qmldirFile.open(QIODevice::ReadOnly | QIODevice::Text);
- // a qml import may contain several plugins
+ // A qml import may contain several plugins
QString plugins;
QString classnames;
QStringList dependencies;
@@ -206,7 +206,7 @@ QPair<QString, QString> resolveImportPath(const QString &uri, const QString &ver
}
}
- // remove the last version digit; stop if there are none left
+ // Remove the last version digit; stop if there are none left
if (ver.isEmpty())
break;
@@ -426,7 +426,7 @@ QVariantList findQmlImportsInDirectory(const QString &qmlDir)
if (std::find_if(blacklist.cbegin(), blacklist.cend(), pathStartsWith(path)) != blacklist.cend())
continue;
- // skip obvious build output directories
+ // Skip obvious build output directories
if (path.contains(QLatin1String("Debug-iphoneos")) || path.contains(QLatin1String("Release-iphoneos")) ||
path.contains(QLatin1String("Debug-iphonesimulator")) || path.contains(QLatin1String("Release-iphonesimulator"))
#ifdef Q_OS_WIN
@@ -455,30 +455,29 @@ QSet<QString> importModulePaths(const QVariantList &imports) {
return ret;
}
-// Find Qml Imports Recursively from a root set of qml files.
+// Find qml imports recursively from a root set of qml files.
// The directories in qmlDirs are searched recursively.
// The files in qmlFiles parsed directly.
QVariantList findQmlImportsRecursively(const QStringList &qmlDirs, const QStringList &scanFiles)
{
QVariantList ret;
- // scan all app root qml directories for imports
+ // Scan all app root qml directories for imports
for (const QString &qmlDir : qmlDirs) {
QVariantList imports = findQmlImportsInDirectory(qmlDir);
ret = mergeImports(ret, imports);
}
- // scan app qml files for imports
+ // Scan app qml files for imports
for (const QString &file : scanFiles) {
QVariantList imports = findQmlImportsInFile(file);
ret = mergeImports(ret, imports);
}
-
- // get the paths to theimports found in the app qml
+ // Get the paths to the imports found in the app qml
QSet<QString> toVisit = importModulePaths(ret);
- // recursivly scan for import dependencies.
+ // Recursively scan for import dependencies.
QSet<QString> visited;
while (!toVisit.isEmpty()) {
QString qmlDir = *toVisit.begin();
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp
index 67ffd5a555..f3b931fbbf 100644
--- a/tools/qmlplugindump/main.cpp
+++ b/tools/qmlplugindump/main.cpp
@@ -76,9 +76,9 @@
namespace {
const uint qtQmlMajorVersion = 2;
-const uint qtQmlMinorVersion = QT_VERSION_MINOR;
+const uint qtQmlMinorVersion = 0;
const uint qtQuickMajorVersion = 2;
-const uint qtQuickMinorVersion = QT_VERSION_MINOR;
+const uint qtQuickMinorVersion = 0;
const QString qtQuickQualifiedName = QString::fromLatin1("QtQuick %1.%2")
.arg(qtQuickMajorVersion)
@@ -1136,8 +1136,7 @@ int main(int argc, char *argv[])
QRegularExpressionMatchIterator i = re.globalMatch(merge[1]);
while (i.hasNext()) {
QRegularExpressionMatch m = i.next();
- QString d = m.captured(1);
- mergeDependencies << m.captured(1);
+ mergeDependencies << m.captured(1);
}
mergeComponents = merge [2];
}
diff --git a/tools/qmlpreview/qmlpreviewapplication.cpp b/tools/qmlpreview/qmlpreviewapplication.cpp
index 02f10831ec..17017dae77 100644
--- a/tools/qmlpreview/qmlpreviewapplication.cpp
+++ b/tools/qmlpreview/qmlpreviewapplication.cpp
@@ -104,11 +104,11 @@ void QmlPreviewApplication::parseArguments()
parser.addHelpOption();
parser.addVersionOption();
- parser.addPositionalArgument(QLatin1String("program"),
- tr("The program to be started and previewed."),
- QLatin1String("[program]"));
+ parser.addPositionalArgument(QLatin1String("executable"),
+ tr("The executable to be started and previewed."),
+ QLatin1String("[executable]"));
parser.addPositionalArgument(QLatin1String("parameters"),
- tr("Parameters for the program to be started."),
+ tr("Parameters for the executable to be started."),
QLatin1String("[parameters...]"));
parser.process(*this);
@@ -120,12 +120,12 @@ void QmlPreviewApplication::parseArguments()
if (parser.isSet(verbose))
m_verbose = true;
- m_programArguments = parser.positionalArguments();
- if (!m_programArguments.isEmpty())
- m_programPath = m_programArguments.takeFirst();
+ m_arguments = parser.positionalArguments();
+ if (!m_arguments.isEmpty())
+ m_executablePath = m_arguments.takeFirst();
- if (m_programPath.isEmpty()) {
- logError(tr("You have to specify a program to start."));
+ if (m_executablePath.isEmpty()) {
+ logError(tr("You have to specify an executable to start."));
parser.showHelp(2);
}
}
@@ -143,17 +143,17 @@ void QmlPreviewApplication::run()
m_process.reset(new QProcess(this));
QStringList arguments;
arguments << QString("-qmljsdebugger=file:%1,block,services:QmlPreview").arg(m_socketFile);
- arguments << m_programArguments;
+ arguments << m_arguments;
m_process->setProcessChannelMode(QProcess::MergedChannels);
connect(m_process.data(), &QIODevice::readyRead,
this, &QmlPreviewApplication::processHasOutput);
- connect(m_process.data(), static_cast<void(QProcess::*)(int)>(&QProcess::finished),
+ connect(m_process.data(), QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
this, [this](int){ processFinished(); });
- logStatus(QString("Starting '%1 %2' ...").arg(m_programPath, arguments.join(QLatin1Char(' '))));
- m_process->start(m_programPath, arguments);
+ logStatus(QString("Starting '%1 %2' ...").arg(m_executablePath, arguments.join(QLatin1Char(' '))));
+ m_process->start(m_executablePath, arguments);
if (!m_process->waitForStarted()) {
- logError(QString("Could not run '%1': %2").arg(m_programPath, m_process->errorString()));
+ logError(QString("Could not run '%1': %2").arg(m_executablePath, m_process->errorString()));
exit(1);
}
m_connectTimer.start();
diff --git a/tools/qmlpreview/qmlpreviewapplication.h b/tools/qmlpreview/qmlpreviewapplication.h
index 7da4a9ab5c..51a70cbac3 100644
--- a/tools/qmlpreview/qmlpreviewapplication.h
+++ b/tools/qmlpreview/qmlpreviewapplication.h
@@ -63,8 +63,8 @@ private:
bool sendFile(const QString &path);
void sendDirectory(const QString &path);
- QString m_programPath;
- QStringList m_programArguments;
+ QString m_executablePath;
+ QStringList m_arguments;
QScopedPointer<QProcess> m_process;
bool m_verbose;
diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp
index 6732766b46..f92ffa9ff5 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.cpp
+++ b/tools/qmlprofiler/qmlprofilerapplication.cpp
@@ -29,7 +29,6 @@
#include "qmlprofilerapplication.h"
#include "constants.h"
#include <QtCore/QStringList>
-#include <QtCore/QTextStream>
#include <QtCore/QProcess>
#include <QtCore/QTimer>
#include <QtCore/QDateTime>
@@ -38,6 +37,8 @@
#include <QtCore/QCommandLineParser>
#include <QtCore/QTemporaryFile>
+#include <iostream>
+
static const char commandTextC[] =
"The following commands are available:\n"
"'r', 'record'\n"
@@ -52,8 +53,8 @@ static const char commandTextC[] =
" Stop recording if it is running, then output the\n"
" data, and finally clear it from memory.\n"
"'q', 'quit'\n"
- " Terminate the program if started from qmlprofiler,\n"
- " and qmlprofiler itself.";
+ " Terminate the target process if started from\n"
+ " qmlprofiler, and qmlprofiler itself.";
static const char *features[] = {
"javascript",
@@ -120,10 +121,8 @@ QmlProfilerApplication::~QmlProfilerApplication()
logStatus("Killing process ...");
m_process->kill();
}
- if (isInteractive()) {
- QTextStream err(stderr);
- err << endl;
- }
+ if (isInteractive())
+ std::cerr << std::endl;
delete m_process;
}
@@ -199,11 +198,11 @@ void QmlProfilerApplication::parseArguments()
parser.addHelpOption();
parser.addVersionOption();
- parser.addPositionalArgument(QLatin1String("program"),
- tr("The program to be started and profiled."),
- QLatin1String("[program]"));
+ parser.addPositionalArgument(QLatin1String("executable"),
+ tr("The executable to be started and profiled."),
+ QLatin1String("[executable]"));
parser.addPositionalArgument(QLatin1String("parameters"),
- tr("Parameters for the program to be started."),
+ tr("Parameters for the executable to be started."),
QLatin1String("[parameters...]"));
parser.process(*this);
@@ -252,17 +251,17 @@ void QmlProfilerApplication::parseArguments()
if (parser.isSet(verbose))
m_verbose = true;
- m_programArguments = parser.positionalArguments();
- if (!m_programArguments.isEmpty())
- m_programPath = m_programArguments.takeFirst();
+ m_arguments = parser.positionalArguments();
+ if (!m_arguments.isEmpty())
+ m_executablePath = m_arguments.takeFirst();
- if (m_runMode == LaunchMode && m_programPath.isEmpty()) {
- logError(tr("You have to specify either --attach or a program to start."));
+ if (m_runMode == LaunchMode && m_executablePath.isEmpty()) {
+ logError(tr("You have to specify either --attach or an executable to start."));
parser.showHelp(2);
}
- if (m_runMode == AttachMode && !m_programPath.isEmpty()) {
- logError(tr("--attach cannot be used when starting a program."));
+ if (m_runMode == AttachMode && !m_executablePath.isEmpty()) {
+ logError(tr("--attach cannot be used when starting an executable."));
parser.showHelp(3);
}
}
@@ -469,17 +468,17 @@ void QmlProfilerApplication::run()
arguments << QString::fromLatin1("-qmljsdebugger=%1:%2,block,services:CanvasFrameRate")
.arg(QLatin1String(m_socketFile.isEmpty() ? "port" : "file"))
.arg(m_socketFile.isEmpty() ? QString::number(m_port) : m_socketFile);
- arguments << m_programArguments;
+ arguments << m_arguments;
m_process->setProcessChannelMode(QProcess::MergedChannels);
connect(m_process, &QIODevice::readyRead, this, &QmlProfilerApplication::processHasOutput);
- connect(m_process, static_cast<void(QProcess::*)(int)>(&QProcess::finished),
+ connect(m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
this, [this](int){ processFinished(); });
- logStatus(QString("Starting '%1 %2' ...").arg(m_programPath,
+ logStatus(QString("Starting '%1 %2' ...").arg(m_executablePath,
arguments.join(QLatin1Char(' '))));
- m_process->start(m_programPath, arguments);
+ m_process->start(m_executablePath, arguments);
if (!m_process->waitForStarted()) {
- logError(QString("Could not run '%1': %2").arg(m_programPath,
+ logError(QString("Could not run '%1': %2").arg(m_executablePath,
m_process->errorString()));
exit(1);
}
@@ -539,10 +538,8 @@ void QmlProfilerApplication::disconnected()
void QmlProfilerApplication::processHasOutput()
{
Q_ASSERT(m_process);
- while (m_process->bytesAvailable()) {
- QTextStream out(stderr);
- out << m_process->readAll();
- }
+ while (m_process->bytesAvailable())
+ std::cerr << m_process->readAll().constData();
}
void QmlProfilerApplication::processFinished()
@@ -594,10 +591,9 @@ void QmlProfilerApplication::traceFinished()
void QmlProfilerApplication::prompt(const QString &line, bool ready)
{
if (m_interactive) {
- QTextStream err(stderr);
if (!line.isEmpty())
- err << line << endl;
- err << QLatin1String("> ");
+ std::cerr << qPrintable(line) << std::endl;
+ std::cerr << "> ";
if (ready)
emit readyForCommand();
}
@@ -605,14 +601,12 @@ void QmlProfilerApplication::prompt(const QString &line, bool ready)
void QmlProfilerApplication::logError(const QString &error)
{
- QTextStream err(stderr);
- err << "Error: " << error << endl;
+ std::cerr << "Error: " << qPrintable(error) << std::endl;
}
void QmlProfilerApplication::logStatus(const QString &status)
{
if (!m_verbose)
return;
- QTextStream err(stderr);
- err << status << endl;
+ std::cerr << qPrintable(status) << std::endl;
}
diff --git a/tools/qmlprofiler/qmlprofilerapplication.h b/tools/qmlprofiler/qmlprofilerapplication.h
index 2d00e2b7c5..73b2b231cd 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.h
+++ b/tools/qmlprofiler/qmlprofilerapplication.h
@@ -91,8 +91,8 @@ private:
} m_runMode;
// LaunchMode
- QString m_programPath;
- QStringList m_programArguments;
+ QString m_executablePath;
+ QStringList m_arguments;
QProcess *m_process;
QString m_socketFile;
diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp
index 83d6ce5d72..c6c6ed1c4a 100644
--- a/tools/qmlscene/main.cpp
+++ b/tools/qmlscene/main.cpp
@@ -53,8 +53,8 @@
#include <QtWidgets/QApplication>
#if QT_CONFIG(filedialog)
#include <QtWidgets/QFileDialog>
-#endif
-#endif
+#endif // QT_CONFIG(filedialog)
+#endif // QT_WIDGETS_LIB
#include <QtCore/QTranslator>
#include <QtCore/QLibraryInfo>
diff --git a/tools/tools.pro b/tools/tools.pro
index d3ec380717..73cb6e2293 100644
--- a/tools/tools.pro
+++ b/tools/tools.pro
@@ -10,7 +10,7 @@ qtConfig(qml-devtools) {
qtConfig(commandlineparser):qtConfig(xmlstreamwriter): SUBDIRS += qmlcachegen
}
-qtConfig(thread):!android|android_app {
+qtConfig(thread):!android|android_app:!wasm {
SUBDIRS += \
qml
@@ -28,7 +28,13 @@ qtConfig(thread):!android|android_app {
qmlplugindump
}
}
- qtHaveModule(widgets): SUBDIRS += qmleasing
+ qtHaveModule(widgets) {
+ QT_FOR_CONFIG += widgets
+ qtConfig(dialogbuttonbox) {
+ SUBDIRS += \
+ qmleasing
+ }
+ }
}
qtHaveModule(qmltest): SUBDIRS += qmltestrunner
qtConfig(private_tests): SUBDIRS += qmljs