diff options
author | Pavel Labath <pavelo@centrum.sk> | 2013-02-18 21:01:15 (GMT) |
---|---|---|
committer | Pavel Labath <pavelo@centrum.sk> | 2013-02-18 21:04:22 (GMT) |
commit | 4ea546a91e7188ad6a95931637b7b928abd38342 (patch) | |
tree | 4bfc84d34b2beba3a293320c1a02a4540488e323 /src/FbTk/LuaUtil.cc | |
parent | 2eacf0ee090f5f6280f69a96d370928260b24877 (diff) | |
download | fluxbox_pavel-4ea546a91e7188ad6a95931637b7b928abd38342.zip fluxbox_pavel-4ea546a91e7188ad6a95931637b7b928abd38342.tar.bz2 |
Fix unspecified construction order of Lua::s_init_functions
Diffstat (limited to 'src/FbTk/LuaUtil.cc')
-rw-r--r-- | src/FbTk/LuaUtil.cc | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/FbTk/LuaUtil.cc b/src/FbTk/LuaUtil.cc index 700ef1a..8f382e8 100644 --- a/src/FbTk/LuaUtil.cc +++ b/src/FbTk/LuaUtil.cc | |||
@@ -57,9 +57,26 @@ namespace { | |||
57 | return 0; | 57 | return 0; |
58 | } | 58 | } |
59 | 59 | ||
60 | struct AutoVector: public std::vector<Lua::InitFunction *> { | ||
61 | ~AutoVector() { | ||
62 | for(iterator it = begin(); it != end(); ++it) | ||
63 | delete *it; | ||
64 | } | ||
65 | }; | ||
66 | typedef AutoVector InitFunctions; | ||
67 | |||
68 | InitFunctions *s_init_functions; | ||
60 | } // anonymous namespace | 69 | } // anonymous namespace |
61 | 70 | ||
62 | Lua::InitFunctions Lua::s_init_functions; | 71 | void Lua::doRegisterInitFunction(std::auto_ptr<InitFunction> fn) { |
72 | struct InitHelper { | ||
73 | InitHelper() { s_init_functions = new InitFunctions; } | ||
74 | ~InitHelper() { delete s_init_functions; } | ||
75 | }; | ||
76 | static InitHelper helper; | ||
77 | |||
78 | s_init_functions->push_back(fn.release()); | ||
79 | } | ||
63 | 80 | ||
64 | Lua::Lua() { | 81 | Lua::Lua() { |
65 | checkstack(1); | 82 | checkstack(1); |
@@ -73,8 +90,8 @@ Lua::Lua() { | |||
73 | 90 | ||
74 | makeReadOnly(lua::GLOBALSINDEX, true); | 91 | makeReadOnly(lua::GLOBALSINDEX, true); |
75 | 92 | ||
76 | InitFunctions::const_iterator it_end = s_init_functions.end(); | 93 | InitFunctions::const_iterator it_end = s_init_functions->end(); |
77 | for(InitFunctions::const_iterator it = s_init_functions.begin(); it != it_end; ++it) | 94 | for(InitFunctions::const_iterator it = s_init_functions->begin(); it != it_end; ++it) |
78 | (**it)(*this); | 95 | (**it)(*this); |
79 | } | 96 | } |
80 | 97 | ||