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的类型要不要统一?
信号是否有依赖插件是否实现
…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。这次代码变更主要是将控制中心的插件工厂接口从 整体设计思路清晰,但在语法逻辑、代码质量、性能和安全性方面存在一些需要改进的隐患。以下是我的详细审查意见: 一、 语法与逻辑问题
二、 代码质量与可读性
三、 代码性能
四、 代码安全
总结与修改建议示例针对 // 修改类名和返回值const
class DccFactoryV2 : public QObject
{
// ...
virtual QString get(const QString ¶m) { return QString(); }
virtual QString set(const QString ¶m) { return QString(); }
// ...
};
// 宏内部增加空指针保护
#define DCC_FULL_FACTORY_CLASS(classname) \\
namespace { \\
class Q_DECL_EXPORT classname##DccFactory : public dccV25::DccFactoryV2 \\
{ \\
Q_OBJECT \\
Q_PLUGIN_METADATA(IID DccFactory_iid) \\
Q_INTERFACES(dccV25::DccFactoryV2); \\
\\
public: \\
using dccV25::DccFactoryV2::DccFactoryV2; \\
void registerType() override \\
{ \\
classname::registerType(); \\
} \\
QObject *create(QObject *parent = nullptr) override \\
{ \\
if (!m_object) { \\
m_object = new classname(this); /* 明确所有权,防止内存泄漏 */ \\
connect(m_object, &classname::propertiesChanged, this, &classname##DccFactory::propertiesChanged); \\
} \\
return m_object; \\
} \\
void active() override \\
{ \\
if (m_object) m_object->active(); \\
else qWarning() << "active() called before create()"; \\
} \\
QString get(const QString ¶m) override \\
{ \\
if (m_object) return m_object->get(param); \\
qWarning() << "get() called before create()"; \\
return QString(); \\
} \\
QString set(const QString ¶m) override \\
{ \\
if (m_object) return m_object->set(param); \\
qWarning() << "set() called before create()"; \\
return QStringLiteral("Error: Object not initialized"); \\
} \\
\\
private: \\
classname *m_object = nullptr; \\
}; \\
}希望这些审查意见对你有所帮助!如果有任何疑问,欢迎随时探讨。 |
|
TAG Bot New tag: 6.1.86 |
|
TAG Bot New tag: 6.1.87 |
|
TAG Bot New tag: 6.1.88 |
Influence:
feat(factory): 升级 DccFactory 至 v2.0,支持生命周期管理与 DBus 数据通道
Influence: