aboutsummaryrefslogtreecommitdiffstats
path: root/tools
Commit message (Collapse)AuthorAgeFilesLines
* qmlls, qmllint: Avoid memory leaksUlf Hermann2023-01-161-6/+6
| | | | | | | | Fixes: QTBUG-104643 Change-Id: I5ca0fea2ef6f822b70c08bc6e49f0d07a732b299 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> (cherry picked from commit 7b0b09d87c36dfc67f0488d1ad87d720f721dea4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix some qsizetype vs. quint32 problemsUlf Hermann2023-01-161-1/+6
| | | | | | | | | | | On 32bit platforms you cannot losslessly convert quint32 to qsizetype. However, in the places we are facing here, we are only interested in signed 32bit numbers anyway. Change-Id: I93a07c2847bd5bfae426dccbb6c0e33c5758442d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 4e1fe071ff05b92ed12fdf59a2185e1254b411cf) Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmlplugindump: Don't crash on value types with extensionsUlf Hermann2023-01-041-1/+2
| | | | | | | | | | | | We have some internal value types without their own base metaobjects, but with extensions. qmlplugindump is not designed to handle those. Skip them. Fixes: QTBUG-109562 Change-Id: I3c4925790ac905077e6ea07724c898b32dd6e59a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit a933e28bd67e29d073ad76312a44e0a89f1db301) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmlls: Remove unused variablePeter Varga2022-12-141-2/+0
| | | | | | | | | | | Fixes Clang -Wunused-but-set-variable warning. Amends 25ac957f6da559333938430eec9cc341823e22cc Change-Id: If959b846a211796297ee2e05923e9ba3d32ae15f Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 27e3bebe47e897f5bf0dcb4ef3a6129995b61ab0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmake: Fix generated *_qmlcache.cpp file pathsJoerg Bornemann2022-12-141-0/+1
| | | | | | | | | | | | | | | | | | ...for source files that are outside of the source directory. Having QML files that are generated in the build directory led to *_qmlcache.cpp files with very long file names, hitting file system limitations on Windows. Apply the same fix that was done for generated qmlcache.qrc files in commit 5d7710a623ecde64316c42fd097db386ac28dd51. Task-number: QTBUG-108150 Change-Id: Icef9dbf40fc7ade54b584bcdc8799c4cc95ac76d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit e4feab199220ae022927d8471bd96779ea4bca48) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Remove Qt keywords from all headersYuhang Zhao2022-12-0916-26/+20
| | | | | | | It's good practice to do so. Change-Id: I72435ff99aaee942c1d3b488ec5dedd7e82d1047 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: fix handlers for c++-signalsSami Shalayel2022-12-072-7/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow qmltc to generate handlers for c++-defined signals with const parameters by changing the safeguard to avoid type mismatch between slots and signals. First, remove the qOverload in the generated QObject::connect call to be able the connect slots and signals with different types (namely, pass by const references and pass by value should be interchangeable but is not allowed by qOverload). Second, save in QQmlJSMetaParameter when types are passed by pointer. Like this, qqmljsimportvisitor can check if a value type is indeed passed by value or const reference in a C++ signal. The same for reference types that need to be passed by (const and non-const) pointer. Print a message when an type is passed by argument in an incompatible way instead of letting qmltc generate uncompilable code, which makes the compiler print out cryptical messages. Third, add a qqmlcpptypehelpers template that decides if value types should be passed by value or reference, by letting the c++ compiler check if sizeof(T) > 3*sizeof(void*). Fixes: QTBUG-107625 Fixes: QTBUG-107622 Change-Id: I1a00532df591d10f74c1fd00dff5b7fccf40cb22 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlJSMetaParameter: Encapsulate parameter informationSami Shalayel2022-12-022-26/+14
| | | | | | | | | | | | | | | | | | | Previously, there were four lists that contained each one entry for each parameter. There was one list responsible for the names, types, type names and const-qualifiers but this was quite bothersome to use (e.g. they not always had the same length). This commit introduces QQmlJSMetaParameter to encapsulate all the information required when manipulating parameters. This reduce the 4 lists to one, making parameters easier to handle and QQmlJSMetaMethod easier to read. This is a purely refactoring change, no new functionality was added. Task-number: QTBUG-107625 Change-Id: Ia41b823c9e6294ee26e828071b802cac6b4058ce Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: error out when encoutering invalid filenamesSami Shalayel2022-12-021-0/+10
| | | | | | | | | | | | | | | | | | | | Dashes and other special characters in qml filenames makes life quite complicated, the generated cpp file will contain everywhere and be uncompilable. Instead, directly print an error message explaoining which names are allowed for type compilation and return. Reasoning: The name of the qml file is also the name of the qml object. For example, using a dash in the filename makes the corresponding qml type have a dash in its name and renders the type mostly unsuable in qml. Therefore, only allow characters, digits and underscores. Pick-to: 6.4 Fixes: QTBUG-107079 Change-Id: I4bff12e4a644b479213e7cc578207c8a443fc517 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: document new behavior of --jsonSami Shalayel2022-11-281-1/+2
| | | | | | | | | | | | | | | Amends 5c04d174282a9a36ce12b26e1807d3d5051a7f33. The behavior of qmllint changed in the above-mentioned commit, as it started expecting a file argument for the --json option. Before, it was not expecting any and always writing to stdout. Document the new behavior in the docs and in the --help command, especially the part about using '-' to restore the old behavior. Fixes: QTBUG-108913 Pick-to: 6.4 Change-Id: I3a69a794a5362a575437d3d832d6e038c7a0755a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Build: install the metatypes inside Qt's own arch-specific data dirThiago Macieira2022-11-241-1/+1
| | | | | | | | We don't want it in /lib64/metatypes, but instead /lib64/qt6/metatypes Pick-to: 6.4 Change-Id: Id8e48e8f498c4a029619fffd17293602d7fd8bd8 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* qmlformat: add 'ensure new line between functions' optionXavier BESSON2022-11-241-0/+11
| | | | | | Fixes: QTBUG-108659 Change-Id: I3e21727bd946089d89ce9c42f640f05230de8c8e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlJSImportVisitor: warn when uncreatables are createdSami Shalayel2022-11-231-1/+4
| | | | | | | | | | | | | | | | | | | | | | isCreatable in qqmljsscope just returns the value of the flag as it was read from the qmltypes, which is slightly confusing as isCreatable is an opt-out option. Instead, isCreatable should reflect whether the type is creatable or not. A type is uncreatable if and only if it is a singleton, an attached type, a c++ type with QML_UNCREATABLE and types without default constructor. This uncreatibility can also be inherited to composite types. Types without default constructor require QML_UNCREATABLE or QML_ANONYMOUS, and will be handled in another commit. Now that uncreatable types can be detected, emit a warning when a singleton or an uncreatable type is created: up to now no such warning was emitted. This warning can be seen when using qmllint or qmltc. By the way, also fix qmltc to not assert when something goes wrong (e.g. because an uncreatable or singleton type was created). Change-Id: I9a82106a801d14063407eb4e54858b1ca9fd578b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: add singleton supportSami Shalayel2022-11-233-7/+29
| | | | | | | | | | | | Add singleton support to qmltc. Add the QML_SINGLETON annotation to the class, generate a static T* create(QQmlEngine*, QJSEngine*) method for the engine and also add test this new functionality. Fixes: QTBUG-106828 Change-Id: I7b6b39ab0c8a427b3166562c3f04cf4a7eaa20e2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* tooling: silence -Wextra-semi-stmtTim Blechmann2022-11-162-10/+10
| | | | | | | | silence clang's -Wextra-semi-stmt Pick-to: 6.4 Change-Id: I5dee9ec46b44076f0fc0590399131b1b267e1ad2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmlformat: add 'ensure new line between objects' optionXavier BESSON2022-11-141-0/+12
| | | | | | | | This option allows to format files into more 'refreshing' ones. It improves readability thanks to a clearer visualization of objects inside files. Change-Id: Ic3592e87ae16d14d70317d09d819cc5d331be822 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltyperegistrar: add IsConstant for method parametersSami Shalayel2022-11-111-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Mark method parameters with IsConstant instead of including "const " in the typename, which makes type resolution in the qml compilers impossible. This also avoids a crash in qmltc happening when qmltc sees a signal defined in C++ that has a const parameter. When qmltyperegistrar writes out the types in the qmltypes, check if it starts with a const, remove it and add instead IsConstant: true. The name returned by MOC is normalized so no need to check for "volatile const" or "const volatile" (its always the latter) and no need to filter out for extra whitespace. Once the const is read by the qmltypes reader, propagate the const-information around using a newly introduced enum called QQmlJSMetaMethod::PConstness that can currently be Const or NonConst. Also add the isConstant property to the Parameter.qml in the tooling module. Add a test to see if the IsConstant information is written into the qmltypes. This is also required for QTBUG-107625. Fixes: QTBUG-108147 Task-number: QTBUG-107625 Change-Id: I13bda0a27fe83867f259b751468788128fec82ed Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Allow lists as arguments to methodsUlf Hermann2022-11-103-18/+20
| | | | | | | | | | | | | | | | | | | Since lists are allowed as property types, you should be able to pass them as arguments to methods, too. For now we only handle QML-defined methods, implemented by adding JavaScript functions to your QML elements. The usual type coercion rules apply if you pass JavaScript arrays to such methods. That is, it usually works. We now resolve properties with the "list" flag to their actual types (QQmlListProperty or QList) already when populating the QQmlJSScope, and store the list types as members of QQmlJSScope rather than as a special map in QQmlJSTypeResolver. This allows us to do the same to lists passed as arguments and simplifies some of the type analysis. Fixes: QTBUG-107171 Change-Id: Idf71ccdc1d59f472c17084a36b5d7879c4d959c0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: support inline components from different qml filesSami Shalayel2022-10-311-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | Make qmltc aware that inline components can be shared between files such that it does not complain about not finding them. Typical usage are `MyOtherFile.MyInlineComponent {}` and `ModuleName.MyOtherFile.MyInlineComponent {}` for an an inline component called MyInlineComponent defined in MyOtherFile.qml, maybe also in a module called ModuleName. Make QQmlJSScope::findType() aware that inline components exists (and potentially that they might also appear in namespaced types). They can also be "imported" or reexported from basetypes and/or deeply nested in some children scopes. Also make it public so that qqmljsimportvisitor can use it when processing property types. Added some tests testing both notations (with and without the qualifed module name). Also add a test to see if there is no confusion between the enums and the inline components (due to their very similar notations). Fixes: QTBUG-106592 Change-Id: I8f2d4790729902ffa664fd0eb1b7c3279af8ddca Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: Add some sugar for generated reference-type-list propertiesSami Shalayel2022-10-282-2/+117
| | | | | | | | | | | | | | | When compiling a reference type list with qmltc into a QQmlListProperty, also generate helper methods to make the manipulation of those lists by the user easier in c++. For a list myList, generate the methods myListAt(), myListAppend(), ... as shown in the Birthdayparty example. Also add some documentation about the ownership of the arguments, and tests to see if the list can be accessed from C++. Task-number: QTBUG-107570 Change-Id: Iec0041015311639ead39660fdccf147749566592 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: extend QmltcMethod with optional commentsSami Shalayel2022-10-282-1/+8
| | | | | | | | | | | | | | | | The methods generated with Qmltc are facing the user: therefore add the possibility to add internal comments before generating the method call such that the user can be warned or informed about certain unclear behaviors. For example, the methods asked for in QTBUG-107570 needs to warn the user about ownership issues on the arguments to avoid dangling pointer references. Task-number: QTBUG-107570 Change-Id: Id04ff7f9a36daad1da836bb421901b9b706a05e7 Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmlformat: do not generate backup filesSemih Yavuz2022-10-241-1/+2
| | | | | | | | | | qmlformat used to backup the original input file up to 2 copies when used with --inplace mode. Change this hardcoded number into 0 and generate no backup file. Fixes: QTBUG-107685 Change-Id: Ifca86968fa65be0fd678012fc2e41b9ed8601d21 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Clean up comments after porting to Q_UNREACHABLE_RETURN()Marc Mutz2022-10-201-2/+0
| | | | | | | These are no longer needed. Change-Id: Id923f71e3452c7ac78a03ea5defeed4b189dc799 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Port to new Q_UNREACHABLE_RETURN()Marc Mutz2022-10-203-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator to convert sequences of Q_UNREACHABLE() + return into Q_UNREACHABLE_RETURN(), newly added to qtbase. const std::string unr = "unr", val = "val", ret = "ret"; auto makeUnreachableReturn = cat("Q_UNREACHABLE_RETURN(", ifBound(val, cat(node(val)), cat("")), ")"); auto ignoringSwitchCases = [](auto stmt) { return anyOf(stmt, switchCase(subStmt(stmt))); }; makeRule(stmt(ignoringSwitchCases(stmt(isExpandedFromMacro("Q_UNREACHABLE")).bind(unr)), nextStmt(returnStmt(optionally(hasReturnValue(expr().bind(val)))).bind(ret))), {changeTo(node(unr), cat(makeUnreachableReturn, ";")), // TODO: why is the ; lost w/o this? changeTo(node(ret), cat(""))}, cat("use ", makeUnreachableReturn)); a.k.a qt-use-unreachable-return. subStmt() and nextStmt() are non-standard matchers. There was one false positive, suppressed it with NOLINTNEXTLINE. It's not really a false positiive, it's just that Clang sees the world in one way and if conditonal compilation (#if) differs for other compilers, Clang doesn't know better. This is an artifact of matching two consecutive statements. Change-Id: I3855b2dc8523db1ea860f72ad9818738162495c6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Add a separate flag for the "pragma Strict" checkUlf Hermann2022-10-201-1/+2
| | | | | | | | | | | | | We want to trigger the qFatal() when running qmlcachegen or qmlsc, but we don't want to trigger it in qmllint, even if we are using the same QtMsgType for the severity of the messages. In turn, demote qmlCompiler messages to QtWarningMsg in qmlcachegen. Pick-to: 6.4 Task-number: QTBUG-107168 Change-Id: Ib660df41742b2d426241eb29ac4c91f4933c5ba1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-10-132-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that on() was replaced with a matcher that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Change-Id: I58e1b41b91c34d2e860dbb5847b3752edbfc6fc9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmlplugindump: Warn if we can't change the directoryUlf Hermann2022-10-111-1/+4
| | | | | | | | | | | It's unclear why we even have to change to the import path, but given the brittle nature of qmlplugindump, let's keep it that way and simply output a message if it fails. The static analyzer complains about a missing return value check. Coverity-Id: 401048 Change-Id: I72e6258dceb7df76a87584b6fe4f5236d754f7cc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmljsimportvisitor: rename m_currentInlineComponent to m_currentRootSami Shalayel2022-10-101-4/+4
| | | | | | | | | | | Small refactor to improve readability: rename qqmljsimportvisitor::m_currentInlineComponentName to m_currentRootName as it denotes the current inline component OR the document root. The previous naming implied wrongly that it was useless when outside an inline component. Change-Id: Ie3c9aa10182f0c9e50650cecaa3e3eb1e37e90eb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: fix code generation for implicit componentsSami Shalayel2022-10-101-15/+35
| | | | | | | | | | | | | | | | | | | | Do not check if a type is implictly wrapped during visitation, as this information is only made available by QQmlJSImportVisitor after(!) the visit. Move this into the postvisit step of qmltc, and write some internal documentation so this error will hopefully not be done again by some qmltc contributor (e.g., me). Now that implicit components are correctly recognized as such, they can be compiled correctly and the c++-code generated by qmltc can again be compiled. Added also a test to see if all childrens of the repeater are correctly instantiated. Pick-to: 6.4 Fixes: QTBUG-107091 Change-Id: I8fce018b83316f8786ae5ca15e5af27c30bb1d37 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-0717-43/+43
| | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace. Task-number: QTBUG-99313 Change-Id: I601bf70f020f511019ed28731ba53b14b765dbf0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-0716-67/+67
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlls: Avoid access to uninitialized capabilityMagnus Groß2022-10-041-1/+1
| | | | | | | | | | | | | | | | | The experimental capability may be uninitialized and store a std::nullopt, but right now we call isObject() on it regardless. This will crash immediately when compiled with GLIBCXX_ASSERTIONS defined. Fix this by checking for std::nullopt, before calling isObject() on this std::optional. Pick-to: 6.4 Change-Id: Ic5f353d586f1187dcbd81f882f59de217d60d089 Reviewed-by: Moody Liu <mooodyhunter@outlook.com> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: support basic inline componentsSami Shalayel2022-09-266-119/+300
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds basic inline component support to qmltc. Implementation details: * added tests: ** (for all tests: see if QQmlComponent would do the same thing) ** try simple inline components ** try inline components extending other inline components ** try recursive inline components (inline component A contain a B that itself contains a A) ** make sure ids in inline components are in their own context, and ** make sure alias inside of inline components work ** remove qmltc_qprocess that tests the error message when inline components are encountered ** test that inline components get their own context (by aliasing a property that they should not be able to see) ** test that also empty components work ** other tests inspired from those at tst_qqmllanguage * separate types depending on the inline component they belong in qmltcvisitor and qmltccompiler ** mostly by replacing T with QHash<QString, T>, where the belonging inline component name serves as hash key ** added a list of inline component names in qmltc * generate correct qmltc-code for inline components ** as they sometimes have mimic a document root and sometimes not ** generate their own "typeCount"-method ** fixed naming used in qmltc generated code by using the inline component names from the qqmljsscope. There is one missing feature (using inline components from other files, using QmlFileName.MyInlineComponent) that will be added in a separate commit. Fixes: QTBUG-106882 Change-Id: Iabe1a8b787027367d73d34bcd93c5f7b5480d217 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: stop using QQmlListReference to appendSami Shalayel2022-09-261-6/+10
| | | | | | | | | | | | | | Instead of using a QQmlListReference to append into lists, use directly the underlying QList<T*> for types compiled with qmltc and QQmlListProperty<T> for types not compiled with qmltc (e.g. types defined in c++). Add a test that tests the private c++ backed "data" property of QQuickItem and different kind of lists (QtObjects and HelloWorlds). Also, append multiple objects to QLists in one go. Fixes: QTBUG-104664 Change-Id: Id5ce6307a241c4c8a167feca677ba5e9b492bc07 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: append to lists in one goSami Shalayel2022-09-224-62/+108
| | | | | | | | | | | | | | | | | | | | Instead of calling the methods to get the elements-to-be-appended and the append-calls alternatively, put first all the elements-to-be-appended on the stack before appending them all one after the other. Instead of compiling list bindings right away into an append call, collect all consecutive elements of a same list before printing all append calls. This requires knowing when all bindings are processed (else the last listbinding are collected but never compiled), such that this changes QmltcCompiler::compileBinding to accept lists of bindings instead of single bindings. Added private fields to QmltcCompiler to save the property of the current list and the list bindings collected so far. Fixes: QTBUG-106783 Change-Id: I75f71e828875e3d95540e6f33574bee7fa8bccbf Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: refactor compileBinding to be less unwieldySami Shalayel2022-09-222-308/+425
| | | | | | | | | | | | | | | | | QmltcCompiler::compileBinding was getting big and unwieldy as it was compiling any kind of binding in a big switch-statement all by itself. Move the binding specific logic into separate helper methods and add a method that calls the right helper method depending on the binding type. This change prepares the code for QTBUG-106783. Task-number: QTBUG-106783 Change-Id: I900e182a82ae780186ad79a5cb5db31bd0548e33 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Add --bare option to qmltc and qmlcachegenUlf Hermann2022-09-092-2/+14
| | | | | | | | | | We need those to prevent usage of the host Qt's import path when building QML files for the target. Task-number: QTBUG-106365 Pick-to: 6.4 6.4.0 Change-Id: I34499af850fb759603206cb429ff97633c76054d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-09-0719-19/+19
| | | | | | | Task-number: QTBUG-105718 Change-Id: Id89ed14990804a5024183e75382cc539d4293da1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QML: Make modules imported with registerModule() available in QMLUlf Hermann2022-09-021-4/+6
| | | | | | | | | So far, you could only use them from pure JavaScript programs. Also, fix re-exporting parts of native modules. Fixes: QTBUG-105901 Change-Id: I170017083284e6457b1aa0c6e606fd26227edae3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: test support for generalized group propertiesSami Shalayel2022-09-011-1/+4
| | | | | | | | | | | | Test support for generalized group properties in qmltc. Also, force group property bindings to be deferred when they belong to a generalized grouped property, while "not-generalized" grouped properties never are deferred. Fixes: QTBUG-105378 Change-Id: Iadc64d7033f9446ccf53e305d8831c7d348f257c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: add some internal documentationSami Shalayel2022-08-311-0/+49
| | | | | | | | add some documentation to qmltc's internal behavior that is not self-documenting enough. Change-Id: I131ee875944e294e0472519573ace4058f4f1821 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: test alias on properties with attributesSami Shalayel2022-08-312-4/+23
| | | | | | | | | | | | | | | | | | | | | | | Add tests to qmltc to see if it behaves well for aliases to different kinds of properties, and compares if the engine shares the same behavior. Same for the attributes in the QMetaProperties. Changes: * add some more MOC information to aliases ** always add NOTIFY to aliases (like the engine does) ** always set DESIGNABLE to false for aliases (like the engine does) ** always set CONSTANT to false for aliases (like the engine does) ** always set STORED to false for aliases (like the engine does) Test if: * default aliases works when compiled via qmltc * attributes of aliases are set correctly in QMetaProperty and compare it to the attributes of the QMetaProperty obtained from the engine. * aliases can read/written/reset/notified Fixes: QTBUG-105708 Change-Id: I66b9c43c8c8de3dbd2b33d5ce15cd42ffb377ce7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Prepare for moving qVersion() from qglobal.h to qlibraryinfo.hSona Kurazyan2022-08-302-0/+2
| | | | | | | Include qlibraryinfo.h where it's used. Change-Id: Ie2ea09458380e012f594e765b50a311a20b423d8 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QtDeclarative: port away from deprecated qSetGlobalQHashSeed(0)Ivan Solovev2022-08-295-5/+5
| | | | | | | | Use QHashSeed::setDeterministicGlobalSeed() instead Task-number: QTBUG-105102 Change-Id: I1d13f3872b335ff9998f7c4538d3b9c3c77fe232 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* qmlimportscanner: Don't crash on invalid argumentUlf Hermann2022-08-291-1/+5
| | | | | | | | | | | | | Apparently you can pass one "root path" as a bare argument, but you have to specify "-rootPath" if you want to pass more than one. The whole concept of a "root path" is wrong. Therefore let's not add more ways to specify root paths. It should not crash, though. Pick-to: 6.4 Fixes: QTBUG-104928 Change-Id: Ie8a10ac7208f927fdb1fed0f87c088739b41c983 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltyperegistrar: Fix file inclusion and writing to stdoutUlf Hermann2022-08-291-12/+1
| | | | | | | | | | | | | | | Apparently if you write #include into a raw string literal, the file is included right there, as part of the string. We don't want this. Therefore, write the #include as regular string. Furthermore, drop some dead code, and make sure we actually write to stdout if no -o option is given. Amends commit dbe42f643532ef8f639fb063f4a99d92e0f6f732. Change-Id: Ia4074dd486bdf9430acec4ac2564f9e654b5e3a8 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: translation binding supportSami Shalayel2022-08-253-0/+110
| | | | | | | | | | | | | | | | | | | | | | | Implement and test support for translation bindings in qmltc: * qsTr() * QT_TR_NOOP() * qsTrId() * QT_TRID_NOOP() Not compiled by qmltc, but instead interpreted as script bindings: * combinations like qsTr(qsTr()) * qsTranslate() (as in qmlsc) * QT_TRANSLATE_NOOP() (as in qmlsc) Add the *.qm files directly to the resources as qt_add_translations() is not available from qtdeclarative (the cmake function lives in qttools that depends on qtdeclarative). Fixes: QTBUG-104637 Task-Id: QTBUG-105346 Change-Id: Ia9433c2bcef01f3486358d963059d9779c67708c Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmlls: reduce latency by using "dry" QHttpMessageStreamParserSami Shalayel2022-08-121-7/+35
| | | | | | | | | | | | | | | | | | StdinReader::run() (qmllanguageservertool.cpp) just uses readSome, which might read just a single character (and on several platforms that is what it does), and then sends it via signal to another thread. This is rather expensive, we should read larger chunks to be more efficient, but we should never wait for more data if a full message was already read (to avoid deadlocks). This commit uses QHttpMessageStreamParser in dry mode to know when to send the data via the signal, that is, when a message has been entirely read. Change-Id: Iee795ded0a539413ec15c686a416f2ccf6673ec9 Task-number: QTBUG-104553 Fixes: QTBUG-104150 Pick-to: 6.4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltyperegistrar: refactor FILE* to QTextStreamSami Shalayel2022-08-041-8/+7
| | | | | | | | | | | | Replace the use of FILE* in qqmltyperegistrar to QTextStream to make qqmltyperegistrar more easy to use, as getting a FILE* to a temporary file on any qt supported platform seems to be really complicated. Uses QString for all QTextStream related operations as it formats char16_t* as pointer addresses. Change-Id: I2d1c71b22076d3083207b8d6fe20c7bb8a0c14ee Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlls: Move back to binUlf Hermann2022-08-041-1/+0
| | | | | | | | | | | | qmlls is a user facing tool. People are supposed to set up the editors to call it. For that, they should see it. Amends commit 399cdef52bc921356458897b37c0682e255a66fc. Pick-to: 6.3 6.4 Change-Id: I495e830171636e187ce3fe592ff4b60959ce701c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>