You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/modify.md
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,6 +102,27 @@ You still need to call the base destructor itself for calling the original.
102
102
103
103
**This pattern is the same for constructors.**
104
104
105
+
### Fields destructor
106
+
107
+
Modifying destructors the traditional way is highly unreliable and outright broken in some Geode versions. The more recommended and more reliable way is utilizing the Fields struct and adding your destructor logic there.
108
+
109
+
```cpp
110
+
class $modify(CreatorLayer) {
111
+
struct Fields {
112
+
~Fields {
113
+
log::info("CreatorLayer is destructed");
114
+
}
115
+
}
116
+
117
+
bool init() {
118
+
CreatorLayer::init();
119
+
m_fields.self();
120
+
}
121
+
};
122
+
```
123
+
124
+
Do note that you need to initialize the Fields struct manually at some point during the class's lifespan for this to work. See the [Fields tutorial](/tutorials/fields.md) for more information.
125
+
105
126
## Using without macros
106
127
107
128
If you need to refrain from using the `$modify` macro (clang-format really cries when it sees the macro so), here is how you would do it:
0 commit comments