# HG changeset patch # User KUDr # Date 1172620468 0 # Node ID 7c8ec33959b1a7788a41e4c3a0d2a58270271b8d # Parent 3fa43db5af9132609babd458b55cd1508aff6be2 (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) diff -r 3fa43db5af91 -r 7c8ec33959b1 src/window.cpp --- 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; diff -r 3fa43db5af91 -r 7c8ec33959b1 src/window.h --- 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 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 P = s_factories.insert(Factories::value_type(m_cls, this)); + std::pair 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;