Skip to content

Commit

Permalink
Merge branch 'GlobedGD:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
blu3berryys authored Jan 10, 2025
2 parents 3687db9 + b1a3b78 commit 5903203
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/managers/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#include <util/singleton.hpp>

class GlobedSettings : public SingletonBase<GlobedSettings> {
friend class SingletonBase;
class GlobedSettings : public SingletonLeakBase<GlobedSettings> {
friend class SingletonLeakBase;
GlobedSettings();

public:
Expand Down
21 changes: 21 additions & 0 deletions src/util/singleton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,24 @@ class SingletonBase {
destructed = true;
}
};

// This is like SingletonBase except not freed during program exit
template <typename Derived>
class SingletonLeakBase {
public:
// no copy
SingletonLeakBase(const SingletonLeakBase&) = delete;
SingletonLeakBase& operator=(const SingletonLeakBase&) = delete;
// no move
SingletonLeakBase(SingletonLeakBase&&) = delete;
SingletonLeakBase& operator=(SingletonLeakBase&&) = delete;

static Derived& get() {
static Derived* instance = new Derived();
return *instance;
}


protected:
SingletonLeakBase() {}
};

0 comments on commit 5903203

Please sign in to comment.