forked from qt-creator/qt-creator
QmlDesigner: Skip QQuickItem in QtQuick.Templates
Otherwise we have to QQuickItem meta info objects and that creates bugs. Fixes: QDS-12460 Change-Id: Iaf76df6671c4ca73913285b78bf1d6408fbe93be Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
@@ -464,6 +464,33 @@ void addType(Storage::Synchronization::Types &types,
|
|||||||
tracer.end(keyValue("type", type));
|
tracer.end(keyValue("type", type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
|
constexpr auto skipLists = std::make_tuple(
|
||||||
|
std::pair{"QtQuick.Templates-cppnative"sv, std::array{"QQuickItem"_L1}});
|
||||||
|
|
||||||
|
std::span<const QLatin1StringView> getSkipList(std::string_view moduleName)
|
||||||
|
{
|
||||||
|
static constexpr std::span<const QLatin1StringView> emptySkipList;
|
||||||
|
auto currentSkipList = emptySkipList;
|
||||||
|
|
||||||
|
std::apply(
|
||||||
|
[&](const auto &entry) {
|
||||||
|
if (entry.first == moduleName)
|
||||||
|
currentSkipList = entry.second;
|
||||||
|
},
|
||||||
|
skipLists);
|
||||||
|
|
||||||
|
return currentSkipList;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool skipType(const QQmlJSExportedScope &object, std::span<const QLatin1StringView> skipList)
|
||||||
|
{
|
||||||
|
return std::any_of(skipList.begin(), skipList.end(), [&](const QLatin1StringView skip) {
|
||||||
|
return object.scope->internalName() == skip;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void addTypes(Storage::Synchronization::Types &types,
|
void addTypes(Storage::Synchronization::Types &types,
|
||||||
const Storage::Synchronization::ProjectData &projectData,
|
const Storage::Synchronization::ProjectData &projectData,
|
||||||
const QList<QQmlJSExportedScope> &objects,
|
const QList<QQmlJSExportedScope> &objects,
|
||||||
@@ -473,13 +500,19 @@ void addTypes(Storage::Synchronization::Types &types,
|
|||||||
NanotraceHR::Tracer tracer{"add types"_t, category()};
|
NanotraceHR::Tracer tracer{"add types"_t, category()};
|
||||||
types.reserve(Utils::usize(objects) + types.size());
|
types.reserve(Utils::usize(objects) + types.size());
|
||||||
|
|
||||||
for (const auto &object : objects)
|
const auto skipList = getSkipList(storage.moduleName(projectData.moduleId));
|
||||||
|
|
||||||
|
for (const auto &object : objects) {
|
||||||
|
if (skipType(object, skipList))
|
||||||
|
continue;
|
||||||
|
|
||||||
addType(types,
|
addType(types,
|
||||||
projectData.sourceId,
|
projectData.sourceId,
|
||||||
projectData.moduleId,
|
projectData.moduleId,
|
||||||
object,
|
object,
|
||||||
storage,
|
storage,
|
||||||
componentNameWithoutNamespaces);
|
componentNameWithoutNamespaces);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@@ -851,4 +851,26 @@ TEST_F(QmlTypesParser, default_property)
|
|||||||
ElementsAre(Field(&Synchronization::Type::defaultPropertyName, Eq("children"))));
|
ElementsAre(Field(&Synchronization::Type::defaultPropertyName, Eq("children"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(QmlTypesParser, skip_template_item)
|
||||||
|
{
|
||||||
|
ModuleId moduleId = storage.moduleId("QtQuick.Templates-cppnative");
|
||||||
|
Synchronization::ProjectData projectData{qmltypesFileSourceId,
|
||||||
|
qmltypesFileSourceId,
|
||||||
|
moduleId,
|
||||||
|
Synchronization::FileType::QmlTypes};
|
||||||
|
QString source{R"(import QtQuick.tooling 1.2
|
||||||
|
Module{
|
||||||
|
Component { name: "QQuickItem"}
|
||||||
|
Component { name: "QQmlComponent"}})"};
|
||||||
|
|
||||||
|
parser.parse(source, imports, types, projectData);
|
||||||
|
|
||||||
|
ASSERT_THAT(types,
|
||||||
|
UnorderedElementsAre(IsType("QQmlComponent",
|
||||||
|
Synchronization::ImportedType{},
|
||||||
|
Synchronization::ImportedType{},
|
||||||
|
Storage::TypeTraitsKind::Reference,
|
||||||
|
qmltypesFileSourceId)));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Reference in New Issue
Block a user