Skip to content

fix: resolve non-reproducible DBUS code generation issue#497

Merged
18202781743 merged 1 commit intolinuxdeepin:masterfrom
18202781743:master
Aug 19, 2025
Merged

fix: resolve non-reproducible DBUS code generation issue#497
18202781743 merged 1 commit intolinuxdeepin:masterfrom
18202781743:master

Conversation

@18202781743
Copy link
Contributor

@18202781743 18202781743 commented Aug 12, 2025

Changed QSet to QStringList for annotations collection to ensure
deterministic output order
Added removeDuplicates() call to maintain uniqueness while preserving
order
This fixes non-reproducible builds caused by QSet's unpredictable
iteration order

Log: Fixed DBUS code generation reproducibility issue

Influence:

  1. Verify DBUS interface code generation produces identical output for
    same inputs
  2. Test with multiple interface definitions containing annotations
  3. Check build reproducibility across different systems

fix: 修复DBUS代码生成不可重复的问题

将注解集合从QSet改为QStringList以确保输出顺序确定性
添加removeDuplicates()调用在保持顺序的同时确保唯一性
修复了由于QSet迭代顺序不可预测导致的构建不可重复问题

Log: 修复了DBUS代码生成不可重复的问题

Influence:

  1. 验证相同输入下DBUS接口代码生成是否产生相同输出
  2. 测试包含多个注解的接口定义
  3. 检查不同系统间的构建可重复性

@18202781743 18202781743 requested review from BLumia and mhduiy August 12, 2025 09:46
deepin-ci-robot added a commit to linuxdeepin/dtk6core that referenced this pull request Aug 12, 2025
Synchronize source files from linuxdeepin/dtkcore.

Source-pull-request: linuxdeepin/dtkcore#497
@deepin-bot
Copy link
Contributor

deepin-bot bot commented Aug 14, 2025

TAG Bot

New tag: 5.7.21
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #499

deepin-ci-robot added a commit to linuxdeepin/dtk6core that referenced this pull request Aug 19, 2025
Synchronize source files from linuxdeepin/dtkcore.

Source-pull-request: linuxdeepin/dtkcore#497
deepin-ci-robot added a commit to linuxdeepin/dtk6core that referenced this pull request Aug 19, 2025
Synchronize source files from linuxdeepin/dtkcore.

Source-pull-request: linuxdeepin/dtkcore#497
@18202781743 18202781743 changed the title fix: treat compiler warnings as errors fix: resolve DBUS reentrancy issue in dtk Aug 19, 2025
Changed QSet to QStringList for annotations collection to ensure
deterministic output order
Added removeDuplicates() call to maintain uniqueness while preserving
order
This fixes non-reproducible builds caused by QSet's unpredictable
iteration order

Log: Fixed DBUS code generation reproducibility issue

Influence:
1. Verify DBUS interface code generation produces identical output for
same inputs
2. Test with multiple interface definitions containing annotations
3. Check build reproducibility across different systems

fix: 修复DBUS代码生成不可重复的问题

将注解集合从QSet改为QStringList以确保输出顺序确定性
添加removeDuplicates()调用在保持顺序的同时确保唯一性
修复了由于QSet迭代顺序不可预测导致的构建不可重复问题

Log: 修复了DBUS代码生成不可重复的问题

Influence:
1. 验证相同输入下DBUS接口代码生成是否产生相同输出
2. 测试包含多个注解的接口定义
3. 检查不同系统间的构建可重复性
@18202781743 18202781743 changed the title fix: resolve DBUS reentrancy issue in dtk fix: resolve non-reproducible DBUS code generation issue Aug 19, 2025
deepin-ci-robot added a commit to linuxdeepin/dtk6core that referenced this pull request Aug 19, 2025
Synchronize source files from linuxdeepin/dtkcore.

Source-pull-request: linuxdeepin/dtkcore#497
@deepin-ci-robot
Copy link
Contributor

deepin pr auto review

我对这段代码的审查意见如下:

  1. 数据结构选择:
  • 原代码使用 QSet<QString> 存储注解,新代码改用 QStringList,这可能会影响性能。
  • QSet 的查找和插入操作的时间复杂度是 O(1),而 QStringList 是 O(n)。
  • 建议保持使用 QSet,除非有特殊原因需要保留注解的顺序。
  1. 去重操作:
  • 新代码添加了 removeDuplicates() 调用,这是一个 O(n) 操作。
  • 如果使用 QSet,可以自动去重,无需此操作。
  1. 代码质量:
  • 变量命名 annotations 比较通用,可以考虑更具描述性的名称,如 collectedAnnotations
  • 注解处理逻辑应该封装为单独的函数,提高代码可读性和可维护性。
  1. 性能优化:
  • 如果确实需要使用 QStringList,建议在添加注解时就去重,而不是最后统一处理。
  • 可以使用 QSet 进行临时去重,最后再转换为 QStringList(如果需要保持顺序)。
  1. 代码安全:
  • 注解处理中使用了字符串查找 annotation.indexOf('<'),建议添加边界检查,防止空字符串或无效输入。

改进建议:

// 保持使用 QSet,自动去重且性能更好
QSet<QString> collectedAnnotations;
for (const QDBusIntrospection::Interface *interface : interfaces) {
    for (const auto &method : interface->methods) {
        for (int i(0); i != method.outputArgs.size(); ++i) {
            const QDBusIntrospection::Argument &arg = method.outputArgs[i];
            if (!arg.annotations.isEmpty()) {
                for (const QString &annotation : arg.annotations) {
                    // 可以添加注解的预处理或验证
                    collectedAnnotations.insert(annotation);
                }
            }
        }
        // 处理方法的注解
        if (!method.annotations.isEmpty()) {
            for (const QString &annotation : method.annotations) {
                collectedAnnotations.insert(annotation);
            }
        }
    }
    // 处理接口的注解
    if (!interface->annotations.isEmpty()) {
        for (const QString &annotation : interface->annotations) {
            collectedAnnotations.insert(annotation);
        }
    }
}

if (!skipIncludeAnnotations) {
    for (const QString &annotation : collectedAnnotations) {
        // 添加边界检查
        if (!annotation.isEmpty() && annotation.indexOf('<') == -1) {
            // 处理注解
        }
    }
}

这些改进可以提高代码的性能、可读性和安全性,同时保持原有功能不变。

@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, mhduiy, robertkill

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

@18202781743 18202781743 merged commit 39b91e4 into linuxdeepin:master Aug 19, 2025
19 of 20 checks passed
18202781743 pushed a commit to linuxdeepin/dtk6core that referenced this pull request Aug 19, 2025
Synchronize source files from linuxdeepin/dtkcore.

Source-pull-request: linuxdeepin/dtkcore#497
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.

4 participants