geode icon indicating copy to clipboard operation
geode copied to clipboard

Modified destructor overrides modified constructor

Open EmeraldBlock opened this issue 4 months ago • 0 comments
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

  1. geode new and create a minimal mod template.
  2. 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();
	}
};
  1. Launch GD with Geode and just this mod. Show the platform console.
  2. Enter and exit the saved levels list. Observe that only destructor gets logged.
  3. As a sanity check, comment out the destructor part of the mod, rebuild, and observe that constructor gets 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.

EmeraldBlock avatar Jun 27 '25 01:06 EmeraldBlock