geode
geode copied to clipboard
Modified destructor overrides modified constructor
trafficstars
Geode Issue
- [x] I confirm that this bug is NOT related to a mod but directly to Geode Loader itself.
Platform
Windows
SDK commit
9388860
Geode Version
v4.6.1
Mods Installed
POC, see below
Expected Behavior
When using $modify (or equivalent) on a class with both void constructor() and void destructor() (where both have bindings), both modifications should apply.
Actual Behavior
Only the destructor's modification seems to apply.
Steps to Reproduce
geode newand create a minimal mod template.- Build the following proof-of-concept mod:
#include <Geode/Geode.hpp>
using namespace geode::prelude;
#include <Geode/modify/LevelBrowserLayer.hpp>
class $modify(LevelBrowserLayer) {
void constructor() {
log::info("constructor");
new(this) LevelBrowserLayer();
}
void destructor() {
log::info("destructor");
LevelBrowserLayer::~LevelBrowserLayer();
}
};
- Launch GD with Geode and just this mod. Show the platform console.
- Enter and exit the saved levels list. Observe that only
destructorgets logged. - As a sanity check, comment out the destructor part of the mod, rebuild, and observe that
constructorgets logged.
Additional Information
I think it's because the below identifies the destructor with the same name as the constructor (forgetting the tilde)?
https://github.com/geode-sdk/geode/blob/08ca8093ac94a10ca48a06069af51f43149565cd/loader/include/Geode/modify/Modify.hpp#L107
I encountered this bug with PlayLayer while working on a mod.