summaryrefslogtreecommitdiff
path: root/src/qml/jsruntime
Commit message (Collapse)AuthorAgeFilesLines
...
* V4: Fix index calculations in String prototypeUlf Hermann2022-08-311-17/+17
| | | | | | | | | We generally have to do those calculations in double as we must not collapse inf into 0. Task-number: QTBUG-100242 Change-Id: Iaf8082160a1ab25060c131ee1a5fa259bbd31214 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Fix IntryinsicTypeArrayPrototype::method_copyWithinUlf Hermann2022-08-311-32/+31
| | | | | | | | | | | We cannot cast infinities of type double to integers because the behavior of that operation varies between platforms. Rather, keep all operations in double until we clamp the values to the dimensions of the array. Task-number: QTBUG-100242 Change-Id: Id95e8382cb6a4370586c2b331906273f65b5c82e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Inline some PropertyAttribute storageUlf Hermann2022-08-302-20/+59
| | | | | | | | | As PropertyAttribute is only one byte long, we can fit 4 or 8 of them into the space the pointer needs. Doing so avoids some allocations. Change-Id: Icea975d51d16eca7d4ace74c5763ea261b0bb8ea Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Do not update proto usage before engine is fully initializedUlf Hermann2022-08-304-2/+48
| | | | | | | | | Updating the prototype usage is very expensive. We only need to do it once there are lookups. Before the engine is fully initialized there are no lookups. Change-Id: Ic919a1f8955718d417e7747ea72e009d443c42fd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Avoid both virtual and override on destructorsJohannes Kauffmann2022-08-281-1/+1
| | | | | | | | | | | Destructors don't need to be declared virtual when the destructor from the parent class is already declared virtual. Additionally, this removes the last usage of Q_DECL_OVERRIDE. Pick-to: 6.4 Change-Id: I7d43f5d5fbb1423319adde04d4994ada9daab6b1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix error when calling byteLength on detached ArrayBufferBenjamin Terrier2022-08-251-1/+4
| | | | | | | | | | | | | | | | | ArrayBuffer constructed from en empty QByteArray are detached, calling byteLength should not throw an error. According to ECMA specifications the `byteLength` property of a detached ArrayBuffer should retrurn 0. See https://tc39.es/ecma262/multipage/structured-data.html#sec-get-arraybuffer.prototype.bytelength [ChangeLog][QtQml][Important Behavior Changes] ArrayBuffer.byteLength() now returns 0 on detached ArrayBuffers, conforming to ECMAScript 2021. Fixes: QTBUG-103925 Change-Id: Ib1c325eff25459980e10a1f3cd9fb7cb3b8eb5e5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove stray qDebug()Ulf Hermann2022-08-241-1/+0
| | | | | | | | | Amends commit af1ef35fa00a466d3af04c17b59fcb4ea38f396a. Pick-to: 6.4 6.3 Task-number: QTBUG-92192 Change-Id: I7523b9294d543eaaf2c37f4d2d4456758cdb6e3e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Create Translation Bindings without CompiledData::BindingSami Shalayel2022-08-152-19/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To add translation bindings to qmltc, the methods used to create translation bindings need to be adapted to work without QV4::CompiledData::Binding as it is not available from qmltc. Instead, information already available from the QQmlJSScope should be used, along with a newly introduced helper class QQmlTranslation. Details: Add a QQmlTranslation class that represents a call to qsTr, qsTrId etc that knows how to translate itself (without needing any ExecutableCompilationUnit or Binding). It encapsulates the information needed to create a translation binding. ExecutableCompilationUnit::bindingValueAsString refactored so its functionality can be used without Binding. Instead, it uses only the translationId, see ExecutableCompilationUnit::translateFromId and ExecutableCompilationUnit::translateFrom. Refactored QQmlTranslationBinding to work with QQmlTranslation instead of CompiledData::Binding. Same for QQmlCppBinding::createTranslationBindingForBindable, QQmlTranslationPropertyBinding::create and QQmlCppBinding::createTranslationBindingForNonBindable. Changed TranslationBindingInformation to work without CompiledData::Binding, and also removed static unused QString ProxyTranslator::originStringFromInformation( const TranslationBindingInformation &translationBindingInformation) as I could not find out what this origin string is. Same for the translation debugging in qmldb_preview. Added QmltcCodeGenerator::generate_createTranslationBindingOnProperty. Added #if to avoid compilation error for standalone DOM compilation due to the new QQmlTranslation class. Task-number: QTBUG-105345 Change-Id: Iccd94d5cba4eaf63901233451fec48051c855c2a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* JSON: Properly handle bad objects in JSON.stringify()Ulf Hermann2022-08-072-6/+30
| | | | | | | | | | | | | | | | | | For objects with circular structures we generate a proper error message and fail earlier. For objects with excessive recursion we throw a range error rather than crashing. This behavior is modeled after node's behavior in such circumstances. We use the existing stack overflow detection to determine when to throw the range error. Testing shows that on windows the limit was insufficient. Lower it. Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-92192 Change-Id: I25dd302f65f359111e42492df3c71549c4ed7157 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* V4: Mark InternalClass parents when running GCUlf Hermann2022-08-037-64/+210
| | | | | | | | | | | | | | | | We need to preserve them as they notify us about protoId related changes. In order to avoid wasting heap space in case many properties are added and removed from the same object, we put a mechanism in place to rebuild the InternalClass hierarchy if many redundant transitions are detected. Amends commit 69d76d59cec0dcff4c52eef24e779fbef14beeca. Pick-to: 5.15 6.2 6.3 6.4 Fixes: QTBUG-91687 Task-number: QTBUG-58559 Change-Id: I3238931b5919ed2b98059e0b7f928334284ce7bf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Fix exponentiation operatorUlf Hermann2022-08-033-50/+3
| | | | | | | | | | We need to use the same algorithm as for Math.pow(...). Since we have jsExponentiate() now, we can use it in all those places. The strange AIX special case is definitely not useful anymore. Task-number: QTBUG-105188 Change-Id: I43a251c71f1b547ad36855ac197080bfea8c94e3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix several more improperly placed #include mocThiago Macieira2022-07-281-2/+2
| | | | | | | | | | | | | | Like commit qtbase/638893bea083b619b73b33a7dd5589fb2c4c4242. Script to find them: git grep -l '#include.*moc' \*.cpp \*.mm | \ xargs awk '/QT_BEGIN_NAMESPACE/ { i=1 } /QT_END_NAMESPACE/ { i=0 } /#include.*moc/ && i { print ARGV[ARGIND], $0 }' Pick-to: 6.4 Change-Id: I6f936da6f6e84d649f70fffd17058fd05cfc5c6d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove QV4:PropertyHash::removeIdentifier()Ulf Hermann2022-07-272-29/+0
| | | | | | | You cannot actually remove anything from these hashes. Change-Id: I4b08639f56e3198f48dac1fabfd324cca87c3fdc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Allow conversion from string to QByteArray when setting bindablesUlf Hermann2022-07-251-0/+2
| | | | | | | | | We allow it everywhere else, too. Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-105044 Change-Id: I714e5d501a780310791523c5f35a87681c69b1fb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove #include qvariant_p.hThiago Macieira2022-07-251-1/+0
| | | | | | | | It isn't used. Change-Id: I3859764fed084846bcb0fffd1704497a9998d30e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix precedence between JS and QML scopesUlf Hermann2022-07-251-18/+28
| | | | | | | | | | | | | | | | | In case of a JS context, we need to do the JS lookup early in order to override imports with locally defined functions. [ChangeLog][QtQml][Important Behavior Changes] The precedence between imports and locally defined functions and variables in JavaScript files has been fixed. If you import a JavaScript file from a QML file, the functions inside the JavaScript file should obviously override anything imported from the QML context. This behavior has been restored. Pick-to: 6.4 Task-number: QTBUG-91687 Change-Id: I119e3109f96ffad7455daaf1a5f17bad31fa8e33 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Qml: When cloning a stack frame, also clone its instruction pointerUlf Hermann2022-07-222-5/+9
| | | | | | | | | | | | Otherwise we get an out of range access when looking for the line number. To be extra safe, we also add another guard against this to the lineNumber() function. Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-90466 Change-Id: I4d9cb52ecba2631696537f02a3c1b75c3658ceb8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix array-like methods on V4 sequencesUlf Hermann2022-07-194-104/+134
| | | | | | | | | | | | | We need to properly convert value type lists on assignment and we need to add the "length" property to the own properties. Furthermore, the V4 sequence methods were confused about integer type ranges. We teach them about qsizetype, properly range check everything, and drop the artificial limitation to INT_MAX. Pick-to: 6.4 Task-number: QTBUG-82443 Change-Id: Ie5af1130c9e78e412c171e6fa26a28a6a7a5d498 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove Qt key words from header filesYuhang Zhao2022-07-191-1/+1
| | | | | | | | | | | So that users can use QT_NO_KEYWORDS when linking against QtDeclarative, even if they are using private headers. Docs, examples and tools are not touched because it's not necessary. Pick-to: 6.4 Change-Id: Idc30797074aaa72576429ebdaaf915d7f5acf84e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Implement array methods for QQmlListPropertyUlf Hermann2022-07-169-95/+111
| | | | | | | | | | | | | | | | | | The test revealed that the fill() method of JS arrays did not properly range-check its parameters. Fix that, too. [ChangeLog][QtQml][Important Behavior Changes] QQmlListProperty behaves like a JavaScript Array now. You can use map(), reduce(), forEach() etc on it. This also includes a slight change of behavior to the push() method. push() now returns the new list length, and it checks the length to not exceed UINT_MAX. Task-number: QTBUG-58831 Fixes: QTBUG-49613 Fixes: QTBUG-99041 Change-Id: Ia64d73fb704449c280fbbc7ddcf20f4698c82e09 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* UrlObject: Add colon after schemeLeticia Valladares2022-07-141-4/+12
| | | | | | | | | | | | | This change adds a colon after scheme in methods 'setProtocol' and 'setUrl' on its protocol line. Likewise, this includes a test called 'colonAfterProtocol' to check if colons were correctly added by using different schemes: ftp, http and https, or if colons were removed when setting the scheme (i.e. from protocol 'ftp:', 'ftp:http:' or 'ftp:::' to 'ftp'). Fixes: QTBUG-103746 Change-Id: I8f847bedd23e476e0ae7901a2f3f3963da3ca04d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* ResolveOverloaded: add debug output for resolutionFabian Kosmale2022-07-121-5/+35
| | | | | | | | This is helpful to understand why exactly a certain method overload has been chosen. Change-Id: Ia6895d628cd25589a2bb8144544d0f827c5fb730 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML engine: Let string match QUrl during overload resolutionFabian Kosmale2022-07-121-0/+2
| | | | | | | | | | | | | | | If an overload set contains a function with a QUrl parameter, and we pass in a string, that would have resulted in the worst-possible score of 10 for that function. Given that URLs are often provided as strings in QML for convenience (instead of using e.g. Qt.url), that is arguably a bad idea. Starting from this commit, they'll get a score of 6: QJsonValue still wins (to minimize the risk of breaking existing overload sets), but we no longer claim that there is no match at all for such a parameter. Change-Id: Ic0faa0029c9d5f14aff143cbd7fd4859d9ac2b2a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: Re-add the Qt namespace enums to the Qt objectUlf Hermann2022-07-051-2/+12
| | | | | | | | | | | They were replaced with an extension to the Qt singleton in Qt6. However, the singleton is only available when QtQml is imported. We can easily provide the enums using the metaobject of the Qt namespace. Pick-to: 6.4 Change-Id: I5f58d30c749c0cb9e531df180a5cbe75c92e1aa6 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Implement virtualOwnPropertyKeys for QQmlTypeWrapperUlf Hermann2022-07-051-1/+1
| | | | | | | Fixes: QTBUG-82591 Change-Id: I3cc39f00b5384065c9f2f226e64dee9fa3fcddac Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QmlCompiler: Really fix writing into argument valuesUlf Hermann2022-07-051-3/+15
| | | | | | | | | | | | | | | | | | | | | | Arguments are now treated as registers "written" at the beginning of the first basic block. By modeling them this way, we can avoid all the complicated logic on whether to use a local or the arguments array when accessing any particular one of them. Furthermore, we can detect whether they are overwritten or not. If they are not overwritten, we can initialize them as a const reference into the arguments array. This way we save a copy. Treating the arguments as generic registers causes the basic blocks pass to aggressively adjust their types, pushing some conversions back into the QML engine. This is good. Unused arguments become void, for example, and don't have to be passed at all. However, we also need a special case for QJSPrimitiveValue arguments now. Pick-to: 6.4 Fixes: QTBUG-104462 Change-Id: I994bea0929bd508aa41db58dee4a7f12cd20f053 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Silence MSVC warning in qv4sparsearray_p.hSami Shalayel2022-06-271-4/+4
| | | | | | | | Rename variable to not shadow another. Fixes: QTBUG-104366 Change-Id: I6906ec6ded8fc19469fa1b1676d57d1082c5a01c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Move itemmodel sequential types from QtQml to QtQml.ModelsMaximilian Goldstein2022-06-151-11/+0
| | | | | | | | | | Otherwise we'd have to create a cyclic dependency between QtQml and QtQml.Models Fixes: QTBUG-104124 Change-Id: Ie62d81ab403166842c39eb1e10748a9835b0705c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-11152-5781/+309
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix the build with tracing enabledShawn Rutledge2022-06-101-4/+4
| | | | | | | | | line() and column() are functions to be called, not variables. Pick-to: 6.2 6.3 6.4 Task-number: QTBUG-102862 Change-Id: I0d447f1b3723efbcac7180c5253fd1ac2bd295ad Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use qtbase's new (private) QLocalTime for Date's UTC offsetsEdward Welbourne2022-06-101-133/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | This puts all use of system time_t functions in one place, instead of spreading it out. Its implementation improves on what was formerly done in V4 Date's offset calculations, while simplifying them and eliminating most of the #if-ery. Add four more test-cases to tst_qqmlqt::dateTimeConversion(), based on issues seen on MinGW, getting the time-zone wrong due to the failure of localtime_r(); MinGW can use localtime_s, as QLocalTime now does. Revised tst_qqmllocale::timeZoneUpdated()'s conditions. The QEXPECT_FAIL()s have stopped triggering, at least on Darwin, and the issue isn't that Date.timeZoneUpdated() wasn't working, it's that (now only on Android and Windows) we don't have a way to set the system time-zone referenced by the system functions that QLocalTime calls to get time-zone offsets. Setting the TZ environment variable only works on faithful POSIX implementations. Pick-to: 6.4 Fixes: QTBUG-85149 Fixes: QTBUG-95993 Fixes: QTBUG-102971 Change-Id: I7bc983b9fd7167e3bab3db41dbc1c6f4a78665b9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QJSEngine: optimize isInterrupted handlingMarc Mutz2022-06-042-3/+3
| | | | | | | | | | | The isInterrupted flag is just that: a flag, so it doesn't require acquire/release semantics when loading/storing. Use relaxed loads and stores instead. Change-Id: I6d733a6bebcfc7f2b786265fc28f9ba7e25bb1c7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Allow retrieval of sequences from QJSValueUlf Hermann2022-06-024-431/+461
| | | | | | | | | | | | | | As we can store sequence types in QJSValue, we should be able to retrieve them, too. Move the declaration of the QV4::Sequence struct into a header to make it less of a hassle to identify sequences. Change-Id: I3e45bfe193c669107f90cd6c502765c0c9f60fb0 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Replace synthetic AOT functions with property-to-property bindingsUlf Hermann2022-05-243-19/+2
| | | | | | | | | Those should be more efficient and make your feet attract fewer projectiles. Fixes: QTBUG-103588 Change-Id: I8b25b9edb1edf5e112dbcba5bba898646d29ae2b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Port QV4::CompiledData::Binding to new special integer bitfieldUlf Hermann2022-05-111-1/+1
| | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I9f8bc5fa45c61f77ee95b055a3d8de001da8f8c5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Port QV4::CompiledData::Location to new special integer bitfieldUlf Hermann2022-05-113-6/+13
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: If0d6f893f2351a4146ddf125be4079b5e312f308 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Port QV4::CompiledData::Lookup to new special integer bitfieldUlf Hermann2022-05-111-2/+2
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I8cc6db56642f1cd2d16e80ba5c49ffd7c6fdcd8c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Port icutils::Node to new special integer bitfieldUlf Hermann2022-05-111-1/+1
| | | | | | | Change-Id: I46f4f21bda1360d09e2c49a1f04dbe411fb46f7d Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Port QV4::CompiledData::RegExp to new special integer bitfieldUlf Hermann2022-05-111-2/+2
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I37be080387bf086d84761b056140cc5a99d161ed Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Port QV4::CompiledData::Object to new special integer bitfieldUlf Hermann2022-05-111-6/+7
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: Ia57a16313e883a8d4dab15c971181440ed1d2214 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Port QV4::CompiledData::JSClassMember to new special integer bitfieldUlf Hermann2022-05-111-2/+2
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I0a7d86450011f1664d61db4d78317dafbcfbb8cf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Add a TU for QV4::Debugging::Debugger to de-inline dtor & includemocsMarc Mutz2022-05-092-1/+54
| | | | | | | | | | | | Destructors of polymorphic classes should be out-of-line. Header moc files should be included into the implementation files. Both need a TU, so add one. Task-number: QTBUG-102948 Task-number: QTBUG-45582 Change-Id: Ia596ec1cab1e4c1f91e42cf217a7df7cbd0d91ad Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qv4string: port away from std::aligned_storageMarc Mutz2022-05-091-1/+1
| | | | | | | | | | | It's deprecated in C++23. Just use an explicitly-aligned char array directly, wrapped in a struct to avoid decays to char*. Task-number: QTBUG-99122 Pick-to: 6.3 6.2 Change-Id: I9b876534502363e40247cde3db315330efa0454b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* V4 Engine: Don't try to convert JS functions to other typesUlf Hermann2022-05-091-1/+4
| | | | | | | | | | | When converting a JS value to a variant, if we notice that we get a QJSValue again, there is no point in trying to convert it further. We'll just run into infinite recursion. Pick-to: 6.3 Fixes: QTBUG-102545 Change-Id: I0a40e21287e5460e5e214101aabe8d2b4bf0afad Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtDeclarative: replace qSwap with std::swap/member-swap where possibleMarc Mutz2022-05-071-1/+1
| | | | | | | | | | | | | | | | | | | | qSwap() is a monster that looks for ADL overloads of swap() and also detects the noexcept of the wrapped swap() function, so it should only be used when the argument type is unknown. In the vast majority of cases, the type is known to be efficiently std::swap()able or to have a member-swap. Call either of these. For the common case of pointer types, circumvent the expensive trait checks on std::swap() by using our hand-rolled qt_ptr_swap() template, the advantage being that it can be unconditionally noexcept, removing all type traits instantiations. In QQmlPropertyCacheAliasCreator, replace the qSwap() with std::move(). Task-number: QTBUG-97601 Pick-to: 6.3 6.2 5.15 Change-Id: I8b78a3ad287ce8565ca258ff38261e4d2cf0be63 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Simplify ToDateTime() and fix a typo in its docEdward Welbourne2022-05-021-2/+2
| | | | | | | | | | | The QDateTime::fromMSecsSinceEpoch(t, Qt::UTC).toTimeSpec(spec) call is in fact equivalent to QDateTime::fromMSecsSinceEpoch(t, spec), I just got confused when I last changed it ! The \tt in the doc comment should simply have been \a t. Change-Id: I460e4105bfa981fd5e44fb57d447fb035f0a4781 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Qml: includemocsMarc Mutz2022-04-292-0/+4
| | | | | | | | | | | | Including moc files directly into their classes' TU tends to improve codegen and enables extended compiler warnings, e.g. about unused private functions or fields. Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-102948 Change-Id: Ie39c60a19ba562affe6bd52ba68b38db95298cf3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qv4promiseobject.cpp: Fix namespacesUlf Hermann2022-04-291-2/+4
| | | | | | | | All of the file should be in the Qt namespace. Change-Id: I9f5a56dbc9771bb8d7148db6ebd4ed3e8f724e08 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* Make QQmlEngine resolve closures when executing runtime functionsAndrei Golubev2022-04-272-16/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | QML can create a function which holds a closure in the cases like: onSignal: function() { ... } If the left-hand side is a signal handler (or similar), we want to execute the *inner* function when a signal is called, not the outer one. However, under certain conditions (e.g. we use `this`), the outer function must also be called beforehand to correctly setup the calling scope for the inner function Thus, make the QQmlEnginePrivate::executeRuntimeFunction() do that: always call an outer function first and then the inner one if present. This creates an overhead when dealing with certain signal handlers but we could optimize it later if needed Note that the case `property var prop: function() { return 42; }` where a property contains a callable function is no longer supported by the executeRuntimeFunction() routine (we always call the inner code now). This is fine since qmltc (the main beneficiary of the routine) does not rely on this functionality when dealing with property bindings Given the change, qmltc can be simplified to only work with absolute function indices, ignoring the nesting problem altogether Change-Id: I61f61587b6fe700cb695b3b7a213d9cfab0eb746 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Generalize QQmlAbstractBinding::isValueTypeProxy()Ulf Hermann2022-04-251-1/+1
| | | | | | | | | Instead of a bool we can just return an enum of the actual kind. This way all the checks become more readable. Furthermore, we can eliminate a dynamic_cast without sacrificing readability. Change-Id: I8a38687f9b796cd47196a6ab0385624c737e4435 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>