Skip to content

Commit e0e0f88

Browse files
18202781743deepin-bot[bot]
authored andcommitted
fix: prevent duplicate QML import paths
1. Added check to avoid prepending DDE_SHELL_QML_INSTALL_DIR if it already exists in import path list 2. This prevents duplicate paths and maintains correct search order for QML imports 3. The change ensures consistent behavior when environment variables add the same path 4. Fixes issue where duplicate paths could cause import resolution problems fix: 防止 QML 导入路径重复 1. 添加检查避免在导入路径列表中已存在 DDE_SHELL_QML_INSTALL_DIR 时重复 添加 2. 防止路径重复并保持 QML 导入的正确搜索顺序 3. 确保当环境变量添加相同路径时行为一致 4. 修复重复路径可能导致导入解析问题的情况
1 parent 83021e8 commit e0e0f88

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

frame/qmlengine.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ class DQmlEnginePrivate : public DObjectPrivate
3939
QObject::connect(s_engine, &QQmlEngine::quit, qApp, &QCoreApplication::quit);
4040
auto paths = s_engine->importPathList();
4141
// high priority for builtin plugin.
42-
paths.prepend(DDE_SHELL_QML_INSTALL_DIR);
42+
if (!paths.contains(DDE_SHELL_QML_INSTALL_DIR))
43+
paths.prepend(DDE_SHELL_QML_INSTALL_DIR);
4344
const QString rootDir = QCoreApplication::applicationDirPath();
4445
QDir pluginDir(rootDir);
4546
if (pluginDir.cd("../plugins")) {
46-
paths.prepend(pluginDir.absolutePath());
47+
if (!paths.contains(pluginDir.absolutePath()))
48+
paths.prepend(pluginDir.absolutePath());
4749
}
4850
s_engine->setImportPathList(paths);
4951
qCDebug(dsLog()) << "Engine importPaths" << s_engine->importPathList();

0 commit comments

Comments
 (0)