The LiveWindow instance isn't a global static

The LiveWindow singleton instance shouldn't be a global static
variable, since the order that global statics are constructed is
undefined, and it's required by other constructors.

Change-Id: I2edccc1f723f0ea41b1347379b3e3778a50afcdc
This commit is contained in:
Thomas Clark
2014-07-29 16:12:23 -04:00
parent 26e90a988b
commit 038478e437
2 changed files with 4 additions and 9 deletions

View File

@@ -14,7 +14,7 @@ struct LiveWindowComponent
bool isSensor;
LiveWindowComponent()
{}//WTF?
{}
LiveWindowComponent(std::string subsystem, std::string name, bool isSensor)
{
this->subsystem = subsystem;
@@ -54,7 +54,6 @@ private:
std::vector<LiveWindowSendable *> m_sensors;
std::map<LiveWindowSendable *, LiveWindowComponent> m_components;
static LiveWindow *m_instance;
ITable *m_liveWindowTable;
ITable *m_statusTable;

View File

@@ -3,8 +3,6 @@
#include <algorithm>
#include <sstream>
LiveWindow* LiveWindow::m_instance = NULL;
/**
* Get an instance of the LiveWindow main class
* This is a singleton to guarantee that there is only a single instance regardless of
@@ -12,11 +10,9 @@ LiveWindow* LiveWindow::m_instance = NULL;
*/
LiveWindow * LiveWindow::GetInstance()
{
if (m_instance == NULL)
{
m_instance = new LiveWindow();
}
return m_instance;
static LiveWindow* instance = new LiveWindow();
return instance;
}
/**