Skip to content

Conversation

@deepin-ci-robot
Copy link
Contributor

@deepin-ci-robot deepin-ci-robot commented Nov 14, 2025

Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#549

Summary by Sourcery

Synchronize changes from linuxdeepin/dtkdeclarative to improve example applications and streamline build/install scripts.

Enhancements:

  • Compute Chameleon plugin import and style paths at runtime in example apps instead of using a hardcoded CHAMELEON_PATH macro

Build:

  • Remove obsolete CHAMELEON_PATH definition from examples CMakeLists and update Qt6 CMakeLists to install only the qmldir file for plugins instead of the entire directory

Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#549
@deepin-ci-robot
Copy link
Contributor Author

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: deepin-ci-robot

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 14, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Synchronized dtkdeclarative sources by replacing the compile-time CHAMELEON_PATH define in example apps with a runtime-computed path, removed obsolete CHAMELEON_PATH macros from CMake, and streamlined qt6 plugin installation to only deploy the qmldir file.

Class diagram for main.cpp changes in example apps

classDiagram
    class QQmlApplicationEngine {
        +addImportPath(path: QString)
    }
    class QQuickStyle {
        +addStylePath(path: QString)
        +setStyle(style: QString)
    }
    class QGuiApplication {
        +applicationDirPath(): QString
    }
    class main {
        +chameleonPath: QString
        +engine: QQmlApplicationEngine
        +setupStylePaths()
    }
    main --> QQmlApplicationEngine
    main --> QQuickStyle
    main --> QGuiApplication
Loading

File-Level Changes

Change Details Files
Replaced CHAMELEON_PATH macro with a runtime-computed chameleonPath for plugin import and style paths
  • Defined chameleonPath using applicationDirPath
  • Updated engine.addImportPath to use chameleonPath
  • Replaced QQuickStyle::addStylePath and setStyle calls to use chameleonPath
examples/exhibition/main.cpp
examples/qml-inspect/main.cpp
Removed CHAMELEON_PATH definition from examples CMakeLists
  • Eliminated CHAMELEON_PATH variable assignment
  • Dropped -DCHAMELEON_PATH preprocessor definition
examples/CMakeLists.txt
Adjusted qt6 plugin installation to only deploy qmldir file
  • Replaced install(DIRECTORY) with install(FILES) targeting qmldir
qt6/src/CMakeLists.txt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `examples/exhibition/main.cpp:84` </location>
<code_context>

 #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) && defined(QT_NO_DEBUG)
-    QQuickStyle::setStyle(CHAMELEON_PATH"/Chameleon");
+    QQuickStyle::setStyle(chameleonPath"/Chameleon");
 #else
     QQuickStyle::setStyle("Chameleon");
</code_context>

<issue_to_address>
**issue (bug_risk):** String concatenation with chameleonPath may not behave as expected.

Use chameleonPath + "/Chameleon" for proper string concatenation in C++.
</issue_to_address>

### Comment 2
<location> `examples/qml-inspect/main.cpp:33` </location>
<code_context>

 #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) && defined(QT_NO_DEBUG)
-    QQuickStyle::setStyle(CHAMELEON_PATH"/Chameleon");
+    QQuickStyle::setStyle(chameleonPath"/Chameleon");
 #else
     QQuickStyle::setStyle("Chameleon");
</code_context>

<issue_to_address>
**issue (bug_risk):** String concatenation with chameleonPath may not behave as expected.

Use chameleonPath + "/Chameleon" for proper string concatenation in C++.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.


#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) && defined(QT_NO_DEBUG)
QQuickStyle::setStyle(CHAMELEON_PATH"/Chameleon");
QQuickStyle::setStyle(chameleonPath"/Chameleon");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): String concatenation with chameleonPath may not behave as expected.

Use chameleonPath + "/Chameleon" for proper string concatenation in C++.


#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) && defined(QT_NO_DEBUG)
QQuickStyle::setStyle(CHAMELEON_PATH"/Chameleon");
QQuickStyle::setStyle(chameleonPath"/Chameleon");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): String concatenation with chameleonPath may not behave as expected.

Use chameleonPath + "/Chameleon" for proper string concatenation in C++.

@deepin-ci-robot
Copy link
Contributor Author

deepin pr auto review

我来对这个git diff进行代码审查:

  1. CMakeLists.txt 修改:
-set(CHAMELEON_PATH "${PROJECT_BINARY_DIR}/plugins")
add_definitions(
-    -DCHAMELEON_PATH="${CHAMELEON_PATH}"
    -DQT_DEPRECATED_WARNINGS
)

修改评价:

  • 优点:移除了编译时定义的CHAMELEON_PATH,改用运行时动态获取,增加了灵活性
  • 改进建议:无,这个改动是合理的
  1. main.cpp 修改(exhibition和qml-inspect):
- engine.addImportPath(CHAMELEON_PATH);
+ const QString chameleonPath = QStringLiteral("%1/../../../plugins").arg(QGuiApplication::applicationDirPath());
+ engine.addImportPath(chameleonPath);

评价:

  • 优点:

    1. 使用运行时路径计算替代编译时定义,提高了灵活性
    2. 使用QStringLiteral提高字符串处理效率
    3. 使用QGuiApplication::applicationDirPath()获取标准路径,更可靠
  • 安全性建议:

    1. 路径计算使用了硬编码的"../../../plugins",建议:
      • 添加路径存在性检查
      • 考虑使用相对路径配置化
      • 添加路径规范化处理防止路径遍历攻击
  • 性能建议:

    1. 可以将路径计算结果缓存,避免重复计算
    2. QStringLiteral的使用是好的,但可以考虑将路径字符串提取为常量
  1. qt6/src/CMakeLists.txt 修改:
-install(DIRECTORY "${PLUGIN_OUTPUT_DIR}/${URI_PATH}/" DESTINATION "${QML_INSTALL_DIR}/${URI_PATH}")
+install(FILES "${PLUGIN_OUTPUT_DIR}/${URI_PATH}/qmldir" DESTINATION "${QML_INSTALL_DIR}/${URI_PATH}")

评价:

  • 优点:

    1. 从安装整个目录改为只安装qmldir文件,更精确
    2. 减少了不必要的文件安装,提高了安装效率
  • 改进建议:

    1. 建议添加文件存在性检查
    2. 可以考虑添加错误处理机制

总体建议:

  1. 路径处理方面:

    • 建议添加路径验证和错误处理
    • 考虑使用更安全的路径拼接方式
    • 可以添加路径配置选项
  2. 代码健壮性:

    • 添加必要的错误检查
    • 考虑不同平台的路径分隔符问题
    • 添加日志记录以便调试
  3. 性能优化:

    • 考虑缓存计算结果
    • 使用更高效的字符串处理方式
  4. 安全性:

    • 添加路径合法性检查
    • 防止路径遍历攻击
    • 考虑权限检查

这些修改整体上是积极的,但在实际使用中建议添加更多的错误处理和安全检查。

@18202781743 18202781743 merged commit 62ed432 into master Nov 17, 2025
14 of 16 checks passed
@18202781743 18202781743 deleted the sync-pr-549-nosync branch November 17, 2025 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants