Boost singleton and undefined reference
- by Ockonal
Hello, I globally use singleton pattern in my project. To make it easier - boost::singleton.
Current project uses Ogre3d library for rendering. Here is some class:
class GraphicSystem : public singleton<GraphicSystem>
{
private:
Ogre::RenderWindow *mWindow;
public:
Ogre::RenderWindow *getWindow() const { return mWindow; }
};
In GraphicSystem constructor I fill the mWindow value:
mWindow = mRoot->createRenderWindow(...);
I cheked it, everything makes normally. So, now I have to use handler for the window in input system (to get window handle).
Somewhere else in another class:
Ogre::RenderWindow *temp = GraphicSystem::get_mutable_instance().getWindow();
GraphicSystem::get_mutable_instance().getWindow()->getCustomAttribute("WINDOW", &mWindowHandle);
temp is 0x00, and there is segfault at last line (getting custon attribute). I can't understand, why does singleton returns undefined pointer for the window. All another singleton-based classes work well.