aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
Commit message (Collapse)AuthorAgeFilesLines
* Fix .import within .js files with CONFIG+=qtquickcompilerSimon Hausmann2018-05-115-0/+29
| | | | | | | | | | | | | | | | | When loading a .js file without QQC, we scan the sources and use the ScriptDirectivesCollector to extract things like .pragma library or .import ahead of time. That information is passed on to the compilation unit generator for serialization. When compiling .js files ahead of time, we also used the same collector, but we forgot to save the data into the right location before serialization, so we essentially lost the imports. This patch fixes that by centralizing this code into the ScriptDirectivesCollector itself. [ChangeLog][QtQml] Fix regression with .import in .js files not working when using CONFIG+=qtquickcompiler. Change-Id: I5413c14b1b8bd3114a997011534fe55cdb7634aa Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix loading of composite singletons from resourcesSimon Hausmann2018-05-082-0/+18
| | | | | | | | | | | | | | Commit f6bbeeb417102c61e8bf23f41e412ed9753a348d began normalizing the resource urls in the type loader, which broke loading of qml singletons from resources, as the normalized url is also used for the "pragma singleton" verification to check that the singleton is in the meta-type registry. If the registration was done with a non-normalized url, the check would fail with a misleading error message. Task-number: QTBUG-68025 Change-Id: I1093ee0cbee884b4a51195c302c8908f748e747e Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Christopher Adams <chris.adams@jollamobile.com>
* Tests: Silence Clang warningsFriedemann Kleint2018-04-271-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | ./stringmodel.h(63,9): warning: 'rowCount' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] int rowCount(const QModelIndex &) const ^ ./stringmodel.h(73,17): warning: 'columnCount' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] virtual int columnCount(const QModelIndex &) const ^ ./stringmodel.h(83,25): warning: 'index' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] virtual QModelIndex index(int row, int column, const QModelIndex &parent) const ./stringmodel.h(92,25): warning: 'parent' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] virtual QModelIndex parent(const QModelIndex &) const ^ ./stringmodel.h(97,14): warning: 'data' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] QVariant data (const QModelIndex & index, int role) const ^ tst_qquicklistview.cpp(8695,18): warning: unused variable 'ctxt' [-Wunused-variable] QQmlContext *ctxt = window->rootContext(); Task-number: QTBUG-63512 Change-Id: Ie928981a601d0462cfadd093815d110f6971d7f5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix qmlInfo and friends for anonymous componentsSimon Hausmann2018-04-272-0/+22
| | | | | | | | | When used on for example delegates we can and should also print the line number and column where the component is declared. Change-Id: I0f02c675425700cde119352d0001895cc31a4c73 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Michael Brasser <michael.brasser@live.com>
* Normalize URL before loading typesErik Verbruggen2018-04-274-0/+36
| | | | | | | | | This prevents loading of types with slightly different paths multiple times, like "qrc:/One.qml" and "qrc:///One.qml". Task-number: QTBUG-65723 Change-Id: I6e26db6d1d271b2ed37b97eb990618843e99c372 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Make the shared test code independent of QtQmlUlf Hermann2018-04-2411-16/+44
| | | | | | | | | This enables us to drop the QML dependency from a number of tests. This is desirable because we want to test that we didn't do any incompatible changes to the debug framework. Change-Id: I937dd45d3079eac15c200c9d68bb4c911f61afc0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Make QtQmlDebug independent of QtQmlUlf Hermann2018-04-241-47/+37
| | | | | | | | | | | | | | | | This means QtQmlDebug needs its own qqmlprofilerdefintions.h. This is a good thing because this way we notice if we change the definitions in an incompatible way. The test uses QtQmlDebug after all. Also, qqmldebugserviceinterfaces_p.h is not available anymore, which means the service names have to be spelled out. This, also, is beneficial as it prevents us from accidentally changing the names. In the context of QmlDebug we don't need to namespace the profiler definitions, either. This simplifies some code. Task-number: QTBUG-60996 Change-Id: Ibb39e48c9b758687d68b8ce4431f45eb26939a09 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Update submodule now that I've fixed the actual bug hereEdward Welbourne2018-04-231-0/+0
| | | | | | | | | | | The submodule has now reverted my "fix" for a test the ES spec initially lead me to think was misguided; the test is fine, in fact, but I was using the wrong time-zone to run it. That's now fixed here, so we can take in the revert of the mis-fix. Task-number: QTBUG-67010 Change-Id: I89c8236ce11ee4dc16eb145e37f4510e19977bb2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Use Los Angeles to represent PST8PDT, not VancouverEdward Welbourne2018-04-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This amends commit 2b8b7a162be52f8cd6c2bc39f498a1ddfb59dd68. The very last test (15.9.5.43-0-8) in the ES test-suite relies on constructing a time *just* outside the valid range, to provoke (and check it gets) a RangeError. However, it uses the current time-zone offset in computing this; and the local time -> UTC conversion in the Date constructor uses the zone information for the zone at the given time. The TZ db uses each zone's local mean solar time for the period before a formal zone was introduced; and Vancouver is further West than the nominal meridian for its zone. The test code throws in an hour's correction in case it's run in daylight-saving time, which would put the test time, when run during standard time, an hour (and a millisecond, rather than just the millisecond) outside the valid Date range, so as to ensure it's still a ms outside when the test is run during DST. However, the 12m28s mean solar offset overcomes the 1ms and puts the time back in range durign DST (but still 47m32.001s outside during standard time, which is why this problem only surfaced when North America entered summer time). Fortunately, Los Angeles is further East than the meridian in question, and uses the same zone. Task-number: QTBUG-67010 Change-Id: I58fd7bf14366ebe5842b8abd7e6802c9c78ca27e Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix calling Qt.binding() on bound functionsLars Knoll2018-04-163-0/+59
| | | | | | | | | | | | | | | | | | | Calling Qt.binding() on a bound function object is a valid use case and used to work until Qt 5.8. The problem was that we optimized the code in QQmlBinding and QQmlJavascriptExpression to directly work on a QV4::Function, so this wouldn't work anymore. To fix this make sure recursive calls to Function.bind() are unrolled (so that the BoundFunction's target is never a bound function itself), then add the bound function as an optional member to the QQmlBinding and use it's bound arguments if present. Task-number: QTBUG-61927 Change-Id: I472214ddd82fc2a1212efd9b769861fc43d2ddaf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix JSON.stringify with sequence typesSimon Hausmann2018-04-162-6/+21
| | | | | | | | | | Stringify::JA takes an ArrayObject* but it merely gets the length property and does indexed get calls. Those work also on array-like objects such as our sequence wrappers. Task-number: QTBUG-45018 Change-Id: I4ec4f89a2e09c918fbc2ff1d48ae5915e67ce280 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Warn about non spec compliant extension being usedLars Knoll2018-04-112-4/+4
| | | | | | | | | | | | eval("function(){}") would return a function object in our engine. This is not compliant with the ES spec, so warn about it, as it'll start throwing a syntax error in 5.12. Also fix the two places where we were using that syntax in our auto tests. Change-Id: I573c2ad0ec4955570b857c69edef2f75998d55a9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix XMLHttpRequest when used with QQmlEngine::evaluateSimon Hausmann2018-04-092-0/+37
| | | | | | | | | | | | | | | | | | | | | | | Our XHR implementation insists on a valid QQmlContext when processing callbacks. This is to protect against callbacks being triggered after dynamic QML contexts such as delegates have been destroyed. Unfortunately those checks are too strict and make it impossible to use XHR from within plain JS scripts (where v4->callingQmlContext() will return a null pointer). Dispatching the callbacks in functions that are directly called from QML/JS is safe and something we can do unconditionally. This applies to the callbacks triggered from abort() and open() for example. When we're called from QNetworkAccessManager we should enforce the continued existence of a QML context only if it was present at send() time. Task-number: QTBUG-67337 Change-Id: I8235f6ef407adc3eaeeff4eee72238ba6750afb2 Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Valery Kotov <vkotov@luxoft.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QQmlDebuggingEnabler test: Relax output string conditionUlf Hermann2018-04-061-4/+8
| | | | | | | | | | | | Apparently the "qml: " prefix to strings output via console.log() is not reliable. We can also get "qml <function> - ", as seen in the test log. Also, increase the timeouts. The test log indicates that they are too small. Change-Id: Icb0da329e52273f9300504047b79b1ad41c02892 Task-number: QTBUG-67505 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QmlProfiler test: Keep recording until we receive the needed eventsUlf Hermann2018-03-281-2/+15
| | | | | | | | We can apparently catch the engine at a point where it has already registered but not compiled anything. Change-Id: I09cd7fefe731a61a6f2095e125516ecf57c602cb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix QQmlExpression::hasError()/error() on syntax errorsSimon Hausmann2018-03-271-1/+5
| | | | | | | | | | | | Record errors that happen during QV4::Script::parse() time in the same way as we record errors during binding evaluation, in order to correctly set the error state of QQmlExpression. This also removes dead code about setting line, description, etc. which is taken care of by ExecutionEngine::catchExceptionAsQmlError. Task-number: QTBUG-67240 Change-Id: I2d586e16803d0883cdd2d1d262b4c67202c00562 Reviewed-by: Michael Brasser <michael.brasser@live.com>
* Fix CONFIG+=qtquickcompiler with paths that contain spacesSimon Hausmann2018-03-274-0/+25
| | | | | | | | Map spaces to underscores as well. Task-number: QTBUG-54683 Change-Id: Id73c086a2845111623df631c06733ba2b42249e0 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Qml Profiler: Store and send URL of compile eventsUlf Hermann2018-03-271-0/+36
| | | | | | Task-number: QTBUG-67354 Change-Id: I7251095570d5ba8d0a62d854cfcbc339b2455747 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Use a separate process for testing perf.map fileUlf Hermann2018-03-274-68/+99
| | | | | | | | | | | | The environment change was too fragile. If the JIT ran before the relevant test function was executed, it would set the doProfile flag to false, and never re-evaluate the environment variable. The qmljs binary is only available for private tests, and the test didn't quite fit into qjsengine anyway. Therefore a new test for the QV4Assembler class that genertes the map files is added. Change-Id: Ice0c18daaee9f0f4f0f15eba0261bcc01aa4b105 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QML Tooling: Wait for QML trace to be started in QML profiler testUlf Hermann2018-03-271-0/+3
| | | | | | | | | | If we don't wait for anything else, we need to wait for at least the "trace started" message before we disable profiling. Otherwise we might disable the profiling before the first engine registers, which will give us no trace at all. Change-Id: I9fb64e82bd05c60640ffbbd2ece5e99edfa97f4a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add test for jump strict-not-equal undefined on 32bitErik Verbruggen2018-03-261-0/+21
| | | | | | | | | | | | Commit 86702c3be53fda404ebe331207f9062675c952e0 and e2218f8b5c527a6da52ae4dc8a381b3ff68d3cd0 were submitted directly to the 5.9 and 5.6 branches. As the problem does not exist per-se in 5.11 there is no fix required. This commit only adds the test coverage for this issue to avoid regressing. Change-Id: Ic5f5d56f52f3855d20755f771804025f8a93acd9 Task-number: QTBUG-66832 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Fix QQmlListModel crash when appending an empty array in debug modeDaniel Vrátil2018-03-201-0/+22
| | | | | | | | | Calling QQmlListModel::append() with an empty JS array triggers an assert in QAbstractItemModel::beginInsertRows() because it's called with negative "last" parameter. Change-Id: I202da260d79f2e6677c663c5785ff754c715fef8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix QML data structure version checking for ahead-of-time generated filesSimon Hausmann2018-03-205-3/+54
| | | | | | | | | | | | | | | | | | We must also do version checking for QML and JS files that were compiled ahead of time and are embedded in resources. If the lookup for the original source code fails, then we must generate an appropriate error message. As an upside we get better error reporting when trying to load an empty file and Qt.include() now reports the error message in the statusText field. The error reporting for imported scripts was not changed as importing an empty script is (oddly) allowed. Task-number: QTBUG-66986 Change-Id: Ie0ef81af371a51ecf8c66ae7954d43f5cc6c12de Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Handle function expressions as signal handlersErik Verbruggen2018-03-201-0/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are two ways to use function expressions on the right-hand side of bindings: property var somethingPressed somethingPressed: function() { /* ..press something else.. */ } signal buttonPressed onButtonPressed: function() { /* ..handle buttonPress.. */ } In the former case, it declares a property that holds a function. So on initialization, the right-hand side of the binding returns a closure that gets assigned to the property 'somethingPressed'. In the latter case, the signal handler is explicitly marked as a function for clarity. So, the handler should not be returning the closure, but the handler should *be* the closure. In general, it is not possible to detect if the left-hand side is a property or a signal handler when generating QML cache files ahead of time. So for this case, we mark the function as only returning a closure. Then when instantiating the object, we check if it is a signal handler, and if the handler is marked as only returning a closure. If so, we set that closure to be the signal handler. Task-number: QTBUG-57043 Task-number: QTBUG-50328 Change-Id: I3008ddd847e30b7d0adef07344a326f84d85f1ba Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix assigning objects to QJSValue propertiesSimon Hausmann2018-03-202-0/+6
| | | | | | | | | | | | | | We support simple object bindings such as someProperty: Rectangle { ... } when the type of "someProperty" is QVariant, but we produce an error when it's QJSValue. There is no good reason for that, and the fix for QTBUG-67118 requires this. Change-Id: Ia5dc88749bcba0b5c781a6ab2b4a9fb92299e0ac Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix out of bounds reads in Array.concatLars Knoll2018-03-201-0/+14
| | | | | | | | | | In some cases, when our simple array data had an offset and data would wrap around, ArrayData::append would write out of bounds data into the new array, leading to crashes. Task-number: QTBUG-51581 Change-Id: I55172542ef0b94d263cfc9a17d7ca49ec6c3a565 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QML debugger: Don't crash when creating objects on engine destructionUlf Hermann2018-03-191-0/+24
| | | | | | | | | | You can create further objects while the QML engine is being destroyed. The debug service is not interested in those because they will be rather short lived anyway. Task-number: QTBUG-62458 Change-Id: If5395ef058268e0e956d159bc636495da1c0c98f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Restore the QV4_WRITE_PERF_MAP featureUlf Hermann2018-03-191-0/+68
| | | | | | | | We want to be able to generate perf map files for JITed code. Task-number: QTBUG-67056 Change-Id: I56899e1dbf184083d94efe926d21fca4f9ea1e18 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Pass "this" object when evaluating debug jobsUlf Hermann2018-03-171-0/+32
| | | | | | | | | We have to explicitly specify the "this" object on QV4::Function::call, otherwise it will assume undefined or the QML global object. Task-number: QTBUG-66942 Change-Id: I1af7742b4fee1b49e9760a413834daf3edb15d74 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add a test that verifies the this object in signal handlersSimon Hausmann2018-03-172-13/+25
| | | | | | | | | | Ask expected, this passes currently. The this object is set to the scope object in QQmlJavaScriptExpression::evaluate, which QQmlBoundSignalExpression::evaluate calls. Task-number: QTBUG-66942 Change-Id: I16a709768f9c798910377a52b5e882bb6d554a5f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix lookup of enums declared in QML singletonsSimon Hausmann2018-03-163-0/+9
| | | | | | | | | | | | | | | | | | | | | Given the following expression var x = MySingleton.MyEnumValue where MySingleton is a QML (composite) singleton and MyEnumValue comes from a QML declared enum, we had code in place up to (and including) 5.10 to attempt to optimize that expression to a enum constant at compile time. In 5.10 that optimization does not exist anymore. In <= 5.10 we would also skip the optimization under certain circumstances (too many statementes, etc.). The fallback that is in place for handling this at run-time tried to be smart by avoiding the QQmlContextWrapper::get lookup and return straight a reference to the singleton as QObject. That works for regular property lookups, but it fails when trying to look up something like an enum, that isn't a meta-object property. Change-Id: I1819b9d8ae06a3f595e067bf5b018c4065be76bb Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tests: add autotest for Q_GADGET derived template classNils Jeisecke2018-03-141-0/+29
| | | | | | | | This tests the effectivity of the qtbase fixes for QTBUG-66744. Task-number: QTBUG-66744 Change-Id: I5bb041082ae4ce6cb91076c3f1279ac7bdcae4f0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix failing ch15.9.5.43-0-8 after US summer time changeSimon Hausmann2018-03-121-0/+0
| | | | | | | | | | Eddy fixed the issue in the testsuite itself and this change bumps the submodule to include the fix. (It also brings in the .gitignore fix, which was omitted from an earlier merge by accident). Task-number: QTBUG-67010 Change-Id: I006a2c8babb135187eeb5c296b616e7c1208cd4c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix issue with bindings to aliases that cannot yet be resolvedErik Verbruggen2018-03-092-0/+25
| | | | | | | | | | | | | | When an alias points to a child object which has not yet been initialized, it's id won't have been registered yet, so setting up a binding to it will result in a crash. The fix is: when setting a binding target fails, and its target property is an alias, queue them until all bindings have been set up, and try again. Task-number: QTBUG-57041 Change-Id: I4dc5a6d25c0a32fed9fd952c955e2006c76be45a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Clean up memory leaks in testsSimon Hausmann2018-03-081-272/+196
| | | | | | | | | | A call to QQmlComponent::create() transfer ownership of the created object to the caller. Many tests forgot to delete the object or only deleted it manually if all tests passed. The simplest way to avoid leaks this way is to store the returned value in a QScopedPointer. Change-Id: I6173f440eddedd4f3eab5026f710602a263246c9 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix unnecessary evaluation of dependent bindingsSimon Hausmann2018-03-083-0/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Given two simple bindings in this order property int firstVar: secondVar property int secondVar: ... then the binding expression for "secondVar" ends up being evaluated twice at run-time. The first time happens when enabling the binding expression for "firstVar", which results in the engine detecting that there is a dependency onto another binding that has not been enabled yet. This is when QQmlData::flushPendingBinding(Impl) enables the expression for secondVar and does an initial evaluation. Afterwards the QQmlObjectCreator continues enabling the next binding in ::finalize(), which will end up evaluating secondVar a second time, unnecessarily. We can detect this case inside setEnabled and only call update() if we transition from disabled to enabled state. This should also cover the case of bindings created and assigned dynamically through QtQuick PropertyChanges / States, as those call setEnabled(false) before removing the binding (to replace it with something else) and setEnabled(true) when reverting the state (in QQmlPropertyPrivate::setBinding). Change-Id: I447432891eabff2c4393f5abfee1092992746fa0 Task-number: QTBUG-66945 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix group property bindings for aliases that point to id objectsSimon Hausmann2018-03-082-0/+26
| | | | | | | | | | | | | | | | | | When declaring bindings within a group property and that group property itself is a locally declared alias, then by the time we try to determine property caches for the group property we will fail as the aliases haven't been resolved yet. To fix this we can keep track of such group property declarations (encapsulated in the QQmlInstantiatingBindingContext that has all we need) and after we've resolved the aliases (added them to the property caches), we can go back and fill in the entries in the propertyCaches array for the group properties. Task-number: QTBUG-51043 Change-Id: I5613513db3977934bcc51a3df530de47d57326f9 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Michael Brasser <michael.brasser@live.com>
* Fix calling Qt.createComponent() from QQmlEngine::evaluate()Simon Hausmann2018-03-081-0/+12
| | | | | | | | | | | | | If we're run from a top-level evaluate() call from the JS engine, then let's assume that any created components are top-level components that belong to the root QML engine context. This is not quite a typical use-case, but our API allows for this and this seems like an easy and sensible solution. Task-number: QTBUG-66792 Change-Id: Ic1c9171c257e8e60c0b2c43f9194bd038744ed2d Reviewed-by: Oleg Yadrov <oleg.yadrov@qt.io> Reviewed-by: Michael Brasser <michael.brasser@live.com>
* Fix regression involving aliases on case-insensitive file systemsMitch Curtis2018-03-082-0/+21
| | | | | | | | | | | | | | When initializing a QQmlProperty with the following syntax: QQmlProperty property(root, "testType.objectName", QQmlEngine::contextForObject(root)); only try to look up types (for each token after splitting on the '.') if the token starts with an uppercase letter, as 1e350a8c now enforces that type names begin with an uppercase letter. Task-number: QTBUG-66715 Change-Id: Iab64be1deb971dca256fc65d358c773837222a57 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix QQmlEngine::retranslate() with PropertyChangesSimon Hausmann2018-02-263-3/+19
| | | | | | | | | When changing the language, we need to re-apply the state of items and re-run the translations if present. Task-number: QTBUG-66541 Change-Id: I83a542af033990ef9a0f92801c5f52d3a5ec722c Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* init variables where they are declared when possible (clang-tidy)Shawn Rutledge2018-02-2614-91/+61
| | | | | | | | clang-tidy -p compile_commands.json $file -checks='-*,modernize-use-default-member-init,readability-redundant-member-init' -config='{CheckOptions: [{key: modernize-use-default-member-init.UseAssignment, value: "1"}]}' -header-filter='qtdeclarative' -fix Change-Id: I705f3235ff129ba68b0d8dad54a083e29fcead5f Reviewed-by: Johan Helsing <johan.helsing@qt.io>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-2673-1325/+1325
| | | | | | | | | | | | | From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Make sure we can call properties of constantsErik Verbruggen2018-02-231-1/+12
| | | | | | | | | This might not be the most useful thing to have, but it's part of JS, so we better handle it. Task-number: QTBUG-66027 Change-Id: Ib40c90515a3ffd1d065d962d6c79a5e3960e2703 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Disallow the use of id properties with value type group propertiesSimon Hausmann2018-02-223-0/+9
| | | | | | | | | | | While it is valid to assign an id to group properties that are QObjects, it is not possible to support this with group properties that are value types, as we do not have QObject instances and id references are limited to those. Change-Id: I7601d0fe00d1261dd711e34f45550db797773f9a Task-number: QTBUG-51525 Reviewed-by: Michael Brasser <michael.brasser@live.com>
* Fix ListModel.get(idx) == ListModel.get(idx)Simon Hausmann2018-02-221-0/+1
| | | | | | | | | | | | | | | | | This is a regression introduced with commit 4876ea6a18ccdfd72014582aa5d50ab9f6b6ec9e. Where we previously always returned the same JS object, we would afterwards return a new JS object for every invocation, which breaks reference comparison. As we store the JS wrapper for the list element in the QQmlData->jsWrapper we can avoid repeated allocations. In order for that wrapper to keep working after modifications (insertion, etc.) to the list model, we have to replace the static element index with a reference to the node model meta-object, which also has an element index that however is kept up-to-date by the list model itself. Change-Id: I4368de6b6d86687fe96fbf73bd60b80b69d7b058 Task-number: QTBUG-52017 Reviewed-by: Michael Brasser <michael.brasser@live.com>
* Allow setting values in value type group properties in "on" assignmentsSimon Hausmann2018-02-222-0/+28
| | | | | | | | | | | | | Assigning to a group property inside a property value source or interceptor as part of an "on assignment" is perfectly valid. That is because while "color" is a value type property, the on assignment means we're actually setting easing.type (in the example and test) on the property value source, not the color, and that one is a QObject. The same goes for interceptors. Change-Id: I505a658977a578894d6dfb00bf5c65b41e42b12f Task-number: QTBUG-56600 Reviewed-by: Michael Brasser <michael.brasser@live.com>
* Correctly set this object when calling scope/context functionsErik Verbruggen2018-02-202-0/+25
| | | | | | | | | | | | | When a function is called that is in a QML scope or a QML context, set the 'this' object to the QML scope. This is done by introducing two new interpreter instructions, which get the context passed in. Note: this patch is 5.11 specific. 5.9 had a similair issue, but the implementation is quite different, so that was fixed separately. Task-number: QTBUG-66432 Change-Id: Ie43150cdd26360025895df28d31264985abf1c15 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.9' into 5.11Liang Qi2018-02-183-0/+43
|\ | | | | | | | | | | | | | | Conflicts: .qmake.conf tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp Change-Id: I7feb9772fc35066f56b7c073482b53ca8c86c70b
| * Fix memory leak with JS importsSimon Hausmann2018-02-093-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Strictly speaking this is a regression introduced with commit e22b624d9ab1f36021adb9cdbfa9b37054282bb8, making the QQmlContextData objects reference counted, especially from the V4 QML context wrapper objects. That change (correct as it is) introduced an accidental circular dependency in the simple scenario of importing a .js file in a .qml file: Each time the type in the .qml file is instantiated, we create a dedicated QQmlContextData for the .js file. If the .js file has no imports itself, that new context will get the same ctx->importedScripts JS array as the QML context of the .qml file. That is a strong reference via QV4::PersistentValue. That array in turn contains the QV4::QmlContextWrapper that belongs to the imported script, which in turn holds a strong reference (via refcount) to the script's context. This patch breaks the circular reference when we perform context invalidation, as the least intrusive measure. For the auto-test to work, we must also clear the qmlContext persistent of the QV4::Script that's used to evaluate the .js file. In subsequent imports that persistent will be initialized to new values, so it will only hold a strong reference to the last import, but strictly speaking that is still a leak - hence also part of this fix. Change-Id: I3e543c946e5e683425072dc3df7e49ca0e0c0215 Task-number: QTBUG-66189 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Fix "Expression depends on non-NOTIFYable properties" regressionMitch Curtis2018-02-172-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CONSTANT properties are by nature non-NOTIFYable. The issue behind the regression is caused by the fact that we were capturing a property regardless of whether or not it was const. There were two states that captureRequired was expressing: true: We're reading the property of a QObject, and we're not quite sure where the QObject comes from or what it is. So, when reading that property at run-time, make sure that we capture where we read that property so that if it changes we can re-evaluate the entire expression. false: We're reading the property of a QObject, and we know that it's the scope object or context object, which we know very well. Instead of registering a property capture every time, we can do that ahead of time and then register all those captures in one shot in registerQmlDependencies(). There is a third state that is only relevant when captureRequired is false: We're reading a property from the scope or context object, but it's a CONSTANT property, so we don't need to register a dependency at all. This patch adds replaces captureRequired with the PropertyCapturePolicy enum, which accounts for the third state and, as a bonus, makes the code easier to understand. Task-number: QTBUG-66361 Change-Id: I6cef1deb76538fbdacf1324b4467403dd40dd7de Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>