diff options
author | Sami Shalayel <sami.shalayel@qt.io> | 2022-09-28 20:04:44 +0200 |
---|---|---|
committer | Sami Shalayel <sami.shalayel@qt.io> | 2022-11-23 10:29:25 +0100 |
commit | 3103bf5a4267cef2c402649cade0a18024a9130b (patch) | |
tree | 9d8d0b45394260e7c1f133673dee00d7cc0b833d /tools | |
parent | ed47bff4118f677e135f3b7c113b035ac991c5ca (diff) |
QQmlJSImportVisitor: warn when uncreatables are created
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>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmltc/qmltcvisitor.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/qmltc/qmltcvisitor.cpp b/tools/qmltc/qmltcvisitor.cpp index 3143316652..c777076d0c 100644 --- a/tools/qmltc/qmltcvisitor.cpp +++ b/tools/qmltc/qmltcvisitor.cpp @@ -103,7 +103,10 @@ void QmltcVisitor::findCppIncludes() // look in type's base type auto base = type->baseType(); - Q_ASSERT(base || !type->isComposite()); + if (!base && type->isComposite()) + // in this case, qqmljsimportvisitor would have already print an error message + // about the missing type, so just return silently without crashing + return; if (!base || visitType(base)) return; addCppInclude(base); |