(svn r8937) [cpp_gui] -Fix(r8931): the global map of Window Factories needs to be constructed on the fly. Otherwise it is not sure that it will be constructed before first WindowFactory. (Bjarni)
--- a/src/window.cpp Tue Feb 27 23:42:47 2007 +0000
+++ b/src/window.cpp Tue Feb 27 23:54:28 2007 +0000
@@ -17,8 +17,6 @@
#include "helpers.hpp"
#include "widget/window_events.hpp"
-/*static*/ WindowFactory::Factories WindowFactory::s_factories;
-
// delta between mouse cursor and upper left corner of dragged window
static Point _drag_delta;
--- a/src/window.h Tue Feb 27 23:42:47 2007 +0000
+++ b/src/window.h Tue Feb 27 23:54:28 2007 +0000
@@ -1032,7 +1032,11 @@
typedef std::map<WindowClass, WindowFactory*> Factories;
- static Factories s_factories;
+ static Factories& GetFactories()
+ {
+ static Factories s_factories;
+ return s_factories;
+ }
WindowClass m_cls;
CreateFn m_creator;
@@ -1041,19 +1045,19 @@
: m_cls(cls)
, m_creator(creator)
{
- std::pair<Factories::iterator, bool> P = s_factories.insert(Factories::value_type(m_cls, this));
+ std::pair<Factories::iterator, bool> P = GetFactories().insert(Factories::value_type(m_cls, this));
assert(P.second);
}
~WindowFactory()
{
- s_factories.erase(m_cls);
+ GetFactories().erase(m_cls);
}
static BaseWindow* NewWindow(WindowClass cls, WindowNumber num)
{
- Factories::iterator it = s_factories.find(cls);
- if (it == s_factories.end()) return NULL;
+ Factories::iterator it = GetFactories().find(cls);
+ if (it == GetFactories().end()) return NULL;
WindowFactory *f = (*it).second;
BaseWindow *w = f->m_creator(num);
return w;