Skip to content

Commit 35eaaf7

Browse files
committed
refactor: use new register helper
1 parent 4d7f4eb commit 35eaaf7

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/mod/MyMod.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66

77
namespace my_mod {
88

9-
static std::unique_ptr<MyMod> instance;
10-
11-
MyMod& MyMod::getInstance() { return *instance; }
9+
MyMod& MyMod::getInstance() {
10+
static MyMod instance;
11+
return instance;
12+
}
1213

1314
bool MyMod::load() {
1415
getSelf().getLogger().debug("Loading...");
@@ -30,4 +31,4 @@ bool MyMod::disable() {
3031

3132
} // namespace my_mod
3233

33-
LL_REGISTER_MOD(my_mod::MyMod, my_mod::instance);
34+
LL_REGISTER_MOD(my_mod::MyMod, my_mod::MyMod::getInstance());

src/mod/MyMod.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class MyMod {
99
public:
1010
static MyMod& getInstance();
1111

12-
MyMod(ll::mod::NativeMod& self) : mSelf(self) {}
12+
MyMod() : mSelf(*ll::mod::NativeMod::current()) {}
1313

1414
[[nodiscard]] ll::mod::NativeMod& getSelf() const { return mSelf; }
1515

0 commit comments

Comments
 (0)