feat(factory): upgrade DccFactory to v2.0 with lifecycle and DBus data channel#3228
feat(factory): upgrade DccFactory to v2.0 with lifecycle and DBus data channel#3228caixr23 wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: caixr23 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| class DccObject; | ||
|
|
||
| class DccFactory : public QObject | ||
| class DccFactory_20 : public QObject |
There was a problem hiding this comment.
保留DccFactory名,旧插件处理会不会冲突
| }; \ | ||
| } | ||
|
|
||
| #define DCC_FULL_FACTORY_CLASS(classname) \ |
There was a problem hiding this comment.
命名带版本号可以不冲突 DCC_FACTORY_V20_CLASS
| Q_SIGNALS: | ||
| // 模块中有设置项变化时,发出该信号 | ||
| // 命名valuesChanged() 待定 | ||
| void propertiesChanged(const QVariantMap &properties); |
There was a problem hiding this comment.
信号命名问题,数据类型用QString(json)还是QVariantMap,get/set的类型要不要统一?
信号是否有依赖插件是否实现
|
TAG Bot New tag: 6.1.86 |
|
TAG Bot New tag: 6.1.87 |
|
TAG Bot New tag: 6.1.88 |
|
TAG Bot New tag: 6.1.89 |
…a channel 1. Rename DccFactory to DccFactory_20, bump IID to v2.0 2. Add registerType() for QML type registration in main thread 3. Add active() for post-creation activation in main thread 4. Add get/set virtual methods for DBus-triggered data access in worker thread 5. Add DCC_FULL_FACTORY_CLASS macro with singleton create and full lifecycle delegation to classname::registerType/active/get/set 6. Preserve v1.0 interface in dccfactoryold.h for backward compatibility 7. Wire DBus get/set slots in ControlCenterDBusAdaptor and DccManager (async dispatch pending) 8. Migrate DefAppModel plugin as first v2.0 adopter, move qmlRegisterType into static registerType() Influence: 1. Verify existing v1.0 plugins still load via old interface 2. Verify DefAppModel QML types register correctly on startup feat(factory): 升级 DccFactory 至 v2.0,支持生命周期管理与 DBus 数据通道 1. 将 DccFactory 重命名为 DccFactory_20,IID 升级为 v2.0 2. 新增 registerType() 用于在主线程中注册 QML 类型 3. 新增 active() 用于在主线程中执行创建后激活 4. 新增 get/set 虚函数用于在子线程中响应 DBus 数据请求 5. 新增 DCC_FULL_FACTORY_CLASS 宏,支持单例创建及完整生命周期 委托至 classname::registerType/active/get/set 6. 在 dccfactoryold.h 中保留 v1.0 接口以向后兼容 7. 在 ControlCenterDBusAdaptor 和 DccManager 中接入 DBus get/set (异步分发待实现) 8. 迁移 DefAppModel 插件作为首个 v2.0 适配示例,将 qmlRegisterType 移入静态 registerType() Influence: 1. 验证已有的 v1.0 插件仍能通过旧接口正常加载 2. 验证 DefAppModel 的 QML 类型在启动时正确注册
deepin pr auto review你好!我是CodeGeeX。我仔细审查了你提供的Git Diff,本次修改主要是将DDE控制中心的插件工厂接口从v1.0升级到v2.0,增加了生命周期管理(注册、激活)和跨进程数据交互(通过DBus的Get/Set)的能力。 整体设计思路清晰,但代码在语法逻辑、代码质量、代码性能和代码安全方面存在一些需要重点关注的问题,特别是多线程并发和内存管理方面的隐患。 以下是详细的审查意见和改进建议: 一、 语法与逻辑错误1. QObject *create(QObject *parent = nullptr) override {
if (!m_object) {
m_object = new classname(parent); // [1] 内存泄漏风险
connect(m_object, &classname::propertiesChanged, this, &classname##DccFactory::propertiesChanged);
}
return m_object;
}
2. QString DccManager::get(const QString &module, const QString ¶m) {
auto message = this->message();
setDelayedReply(true);
// TODO:异步调用对应module的Factory的get函数
return QString(); // [致命错误]
}
3. virtual const QString get(const QString ¶m) { return QString(); }
virtual const QString set(const QString ¶m) { return QString(); }
二、 代码质量1. 宏
2. 版权年份修改 (2027 -> 2026)
3. 命名规范不一致
三、 代码性能1.
2.
四、 代码安全1. 多线程数据竞争
2. DBus 接口的安全校验
3. 模块名注入风险
总结与核心修改建议代码示例针对最致命的 // 在 DCC_FULL_FACTORY_CLASS 宏中,修改 create 和 active 的逻辑
public:
using dccV25::DccFactory_20::DccFactory_20;
void registerType() override {
classname::registerType();
}
QObject *create(QObject *parent = nullptr) override {
// 注意:如果设计为单例,parent不应由外部传入,或者不使用单例模式
// 这里假设设计意图是单例,忽略parent
if (!m_object) {
m_object = new classname();
connect(m_object, &classname::propertiesChanged, this, &classname##DccFactory::propertiesChanged);
}
return m_object;
}
void active() override {
if (m_object) { // 必须判空,因为 create 可能还没被调用
m_object->active();
}
}
const QString get(const QString ¶m) override {
// TODO: 此处存在多线程并发访问 m_object 的风险,需加锁或确保 m_object 在 active 前已完全初始化且不再析构
if (m_object) {
return m_object->get(param);
}
return QString();
}
const QString set(const QString ¶m) override {
if (m_object) {
return m_object->set(param);
}
return QString("Object not initialized");
}同时,请务必修复 |
|
TAG Bot New tag: 6.1.90 |
|
TAG Bot New tag: 6.1.91 |
Influence:
feat(factory): 升级 DccFactory 至 v2.0,支持生命周期管理与 DBus 数据通道
Influence: