diff --git a/src/plugins/qmldesigner/CMakeLists.txt b/src/plugins/qmldesigner/CMakeLists.txt index c8dc6675735..be735401b82 100644 --- a/src/plugins/qmldesigner/CMakeLists.txt +++ b/src/plugins/qmldesigner/CMakeLists.txt @@ -78,8 +78,7 @@ extend_qtc_library(QmlDesignerCore ) extend_qtc_library(QmlDesignerCore - CONDITION TARGET Qt6::QmlDomPrivate AND TARGET Qt6::QmlCompilerPrivate AND Qt6_VERSION VERSION_GREATER_EQUAL 6.4.3 - AND NOT (CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_VERSION VERSION_LESS 19) + CONDITION TARGET Qt6::QmlDomPrivate AND TARGET Qt6::QmlCompilerPrivate AND Qt6_VERSION VERSION_GREATER_EQUAL 6.4.3 DEPENDS Qt6::QmlDomPrivate Qt6::QmlCompilerPrivate PUBLIC_DEFINES QDS_HAS_QMLPRIVATE diff --git a/src/plugins/qmldesigner/designercore/projectstorage/modulescanner.cpp b/src/plugins/qmldesigner/designercore/projectstorage/modulescanner.cpp index f6c0f2449c1..ffcf28d7658 100644 --- a/src/plugins/qmldesigner/designercore/projectstorage/modulescanner.cpp +++ b/src/plugins/qmldesigner/designercore/projectstorage/modulescanner.cpp @@ -7,10 +7,9 @@ #include #endif +#include #include -#include - namespace QmlDesigner { namespace { @@ -49,38 +48,30 @@ void ModuleScanner::scan(const QStringList &modulePaths) void ModuleScanner::scan([[maybe_unused]] std::string_view modulePath) { #ifdef QDS_HAS_QMLPRIVATE - try { - const std::filesystem::path installDirectoryPath{modulePath}; + QDirIterator dirIterator{QString::fromUtf8(modulePath), QDir::Dirs, QDirIterator::Subdirectories}; - auto current = std::filesystem::recursive_directory_iterator{installDirectoryPath}; - auto end = std::filesystem::end(current); + while (dirIterator.hasNext()) { + auto directoryPath = dirIterator.next(); + QString qmldirPath = directoryPath + "/qmldir"; + if (QFileInfo::exists(qmldirPath)) { + QQmlDirParser parser; - for (; current != end; ++current) { - const auto &entry = *current; - auto path = entry.path(); + auto content = contentAsQString(qmldirPath); + if (!content) + continue; - if (path.filename() == "qmldir") { - QQmlDirParser parser; + bool hasError = parser.parse(*content); + if (hasError) + continue; - auto content = contentAsQString(QString::fromStdU16String(path.u16string())); - if (!content) - continue; + auto moduleName = parser.typeNamespace(); - bool hasError = parser.parse(*content); - if (hasError) - continue; + if (moduleName.isEmpty() || m_skip(moduleName)) + continue; - auto moduleName = parser.typeNamespace(); - - if (moduleName.isEmpty() || m_skip(moduleName)) - continue; - - m_modules.push_back( - Import::createLibraryImport(moduleName, createVersion(parser.components()))); - } + m_modules.push_back( + Import::createLibraryImport(moduleName, createVersion(parser.components()))); } - } catch (const std::filesystem::filesystem_error &) { - return; } #endif } diff --git a/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp b/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp index 8f680ac3544..c1003915813 100644 --- a/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp +++ b/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp @@ -39,6 +39,7 @@ #include +#include #include #include @@ -344,17 +345,23 @@ void projectQmldirPaths(::ProjectExplorer::Target *target, QStringList &qmldirPa } #ifdef QDS_HAS_QMLPRIVATE -bool skipPath(const std::filesystem::path &path) +QStringView currentDirectoryName(const QString &path) { - auto directory = path.filename(); - qDebug() << path.string().data(); + auto found = std::find(path.rbegin(), path.rend(), u'/'); - bool skip = directory == "QtApplicationManager" || directory == "QtInterfaceFramework" - || directory == "QtOpcUa" || directory == "Qt3D" || directory == "Qt3D" - || directory == "Scene2D" || directory == "Scene3D" || directory == "QtWayland" - || directory == "Qt5Compat"; - if (skip) - qDebug() << "skip" << path.string().data(); + if (found == path.rend()) + return {}; + + return QStringView{found.base(), path.end()}; +} +bool skipPath(const QString &path) +{ + auto directory = currentDirectoryName(path); + + bool skip = directory == u"QtApplicationManager" || directory == u"QtInterfaceFramework" + || directory == u"QtOpcUa" || directory == u"Qt3D" || directory == u"Qt3D" + || directory == u"Scene2D" || directory == u"Scene3D" || directory == u"QtWayland" + || directory == u"Qt5Compat"; return skip; } @@ -366,21 +373,14 @@ void qtQmldirPaths([[maybe_unused]] ::ProjectExplorer::Target *target, #ifdef QDS_HAS_QMLPRIVATE if (useProjectStorage()) { const QString installDirectory = qmlPath(target).toString(); + QDirIterator dirIterator{installDirectory, QDir::Dirs, QDirIterator::Subdirectories}; - const std::filesystem::path installDirectoryPath{installDirectory.toStdString()}; + while (dirIterator.hasNext()) { + auto directoryPath = dirIterator.next(); - auto current = std::filesystem::recursive_directory_iterator{installDirectoryPath}; - auto end = std::filesystem::end(current); - for (; current != end; ++current) { - const auto &entry = *current; - auto path = entry.path(); - if (current.depth() < 3 && !current->is_regular_file() && skipPath(path)) { - current.disable_recursion_pending(); - continue; - } - if (path.filename() == "qmldir") { - qmldirPaths.push_back(QString::fromStdU16String(path.generic_u16string())); - } + QString qmldirPath = directoryPath + "/qmldir"; + if (!skipPath(directoryPath) && QFileInfo::exists(qmldirPath)) + qmldirPaths.push_back(directoryPath); } } #endif