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.
827b521 to
5579d87
Compare
Add CI workflows to verify the project builds correctly on both Arch Linux (latest) and Deepin crimson. This helps catch any platform-specific compilation issues introduced by the accessor pattern refactor.
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这份代码变更主要做了两件事:
整体来看,代码质量有了显著提升,特别是摒弃了破坏 ODR 和导致未定义行为的宏。以下是针对语法逻辑、代码质量、代码性能和代码安全方面的详细审查与改进建议: 一、 CI/CD 工作流审查1. Arch Linux 工作流 (
|
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.