Change OverlayController from singleton pattern to regular RAII

The singleton pattern was poorly implemented and didn't provide the
benefits usually associated with the singleton pattern, with all the
negatives.

Refer to this github issue:
https://github.com/OpenVR-Advanced-Settings/OpenVR-AdvancedSettings/issues/29
This commit is contained in:
Vasily
2019-01-11 23:04:55 +01:00
parent 227757bd5c
commit 6ce10bd2f0
3 changed files with 39 additions and 53 deletions
+1 -18
View File
@@ -94,16 +94,12 @@ public: // I know it's an ugly hack to make them public to enable external
AccessibilityTabController accessibilityTabController;
private:
OverlayController( bool desktopMode, bool noSound )
: QObject(), desktopMode( desktopMode ), noSound( noSound )
{
}
QPoint getMousePositionForEvent( vr::VREvent_Mouse_t mouse );
public:
OverlayController( bool desktopMode, bool noSound, QQmlEngine& qmlEngine );
virtual ~OverlayController();
void Init( QQmlEngine* qmlEngine );
void Shutdown();
bool isDashboardVisible()
@@ -174,21 +170,8 @@ signals:
private:
static QSettings* _appSettings;
static std::unique_ptr<OverlayController> singleton;
public:
static OverlayController* getInstance()
{
return singleton.get();
}
static OverlayController* createInstance( bool desktopMode, bool noSound )
{
singleton.reset(
new advsettings::OverlayController( desktopMode, noSound ) );
return singleton.get();
}
static QSettings* appSettings()
{
return _appSettings;