refactor: replace private access hacks with accessor pattern - #625
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: zccrs 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 |
There was a problem hiding this comment.
Pull request overview
This PR removes preprocessor-based private/protected access hacks and replaces them with a template-based private accessor pattern for reaching Qt private members, while also adding new CI workflows to build the project on Deepin (crimson) and Arch Linux.
Changes:
- Added a new header implementing an explicit-template-instantiation-based private member accessor and convenience macros.
- Refactored
DQMLGlobalObjectto accessQSGNodeprivate fields via the new accessor macros instead of#define private public. - Updated scenegraph rendering logic in
dbackdropnode.cppand introduced new GitHub Actions build workflows for Deepin and Arch Linux.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/util/dprivateaccessor_p.h |
Adds the template-based private accessor pattern + macros. |
src/private/dqmlglobalobject.cpp |
Replaces #define private public usage with accessor tags/macros for QSGNode internals. |
src/private/dbackdropnode.cpp |
Removes access-hack macros and updates renderer invocation flow. |
.github/workflows/dtkdeclarative-deepin-build.yml |
Adds Deepin (crimson) container build workflow that builds dependencies from source and produces .deb artifacts. |
.github/workflows/dtkdeclarative-archlinux-build.yml |
Adds Arch Linux container build workflow producing install artifacts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5579d87 to
a262b4e
Compare
|
|
||
| #include <algorithm> | ||
|
|
||
| #ifndef QT_NO_OPENGL |
There was a problem hiding this comment.
已处理,这个条件编译已经去掉,当前直接保留 static_assert(sizeof(QSGRenderer) == 432),并已随最新 force-push 一起更新。
|
已更新这个 PR:\n\n1. 代码已经 rebase 到 upstream 最新,并去掉了混入的 fork |
|
补充说明一下刚才的更新:\n\n1. 这个 PR 的 head 用的是 |
|
补充一下 GitHub Action 那条提交的处理:当前 PR 仍保持只包含本次修复,不再把 workflow 提交带回 |
|
TAG Bot New tag: 6.7.43 |
|
TAG Bot New tag: 6.7.44 |
|
TAG Bot New tag: 6.7.45 |
|
TAG Bot New tag: 6.7.46 |
Remove all '#define private/protected public' hacks and replace them with a proper C++ template-based private accessor pattern using explicit template instantiation (friend injection trick), mirroring the approach used in linuxdeepin/treeland#875. Adds src/util/dprivateaccessor_p.h with Accessor/AccessorImpl templates and D_DECLARE_PRIVATE_MEMBER, D_PRIVATE_MEMBER macros. All helpers live at global scope so ADL correctly resolves the friend-injected get() function.
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // tests/ut_qsgrenderer_accessor.cpp
// 增加注释说明未构造对象的安全性
void init()
{
std::memset(buffer, 0, sizeof(buffer));
// 注意:此处未调用 QSGRenderer 构造函数。
// 仅用于测试位域内存布局的读写,不可调用涉及虚函数或复杂状态的成员方法。
renderer = reinterpret_cast<QSGRenderer *>(buffer);
} |
|
TAG Bot New tag: 6.7.47 |
Remove all '#define private/protected public' hacks and replace them with a proper C++ template-based private accessor pattern using explicit template instantiation (friend injection trick), mirroring the approach used in linuxdeepin/treeland#875.
Add src/private/dprivateaccessor_p.h with Accessor/AccessorImpl templates and D_DECLARE_PRIVATE_MEMBER, D_DECLARE_PRIVATE_METHOD, D_DECLARE_PRIVATE_CONST_METHOD, D_PRIVATE_MEMBER, D_PRIVATE_CALL macros. All helpers are in global namespace so ADL correctly finds the friend-injected get() function.