aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Luamm.cc
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-06-14 15:02:07 (GMT)
committerPavel Labath <pavelo@centrum.sk>2013-02-16 23:19:15 (GMT)
commit008539ba1b107f09770539a9c7fd9c0997369a01 (patch)
treee8b3a1357ee8ede91826117930e1680ca910a226 /src/FbTk/Luamm.cc
parent75caeaf59a50004f102f37a6a7f96dad6228a70d (diff)
downloadfluxbox_pavel-008539ba1b107f09770539a9c7fd9c0997369a01.zip
fluxbox_pavel-008539ba1b107f09770539a9c7fd9c0997369a01.tar.bz2
Lua exceptions can now outlive thier lua context
Diffstat (limited to 'src/FbTk/Luamm.cc')
-rw-r--r--src/FbTk/Luamm.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/FbTk/Luamm.cc b/src/FbTk/Luamm.cc
index c4ea2e0..563be9c 100644
--- a/src/FbTk/Luamm.cc
+++ b/src/FbTk/Luamm.cc
@@ -173,7 +173,7 @@ namespace lua {
173 } 173 }
174 174
175 exception::exception(state *l) 175 exception::exception(state *l)
176 : std::runtime_error(get_error_msg(l)), L(l) 176 : std::runtime_error(get_error_msg(l)), L(l), L_valid(l->get_valid())
177 { 177 {
178 L->checkstack(1); 178 L->checkstack(1);
179 179
@@ -184,7 +184,7 @@ namespace lua {
184 } 184 }
185 185
186 exception::exception(const exception &other) 186 exception::exception(const exception &other)
187 : std::runtime_error(other), L(other.L) 187 : std::runtime_error(other), L(other.L), L_valid(other.L_valid)
188 { 188 {
189 L->checkstack(2); 189 L->checkstack(2);
190 190
@@ -196,7 +196,7 @@ namespace lua {
196 196
197 exception::~exception() throw() 197 exception::~exception() throw()
198 { 198 {
199 if(not L) 199 if(not L or not *L_valid)
200 return; 200 return;
201 L->checkstack(1); 201 L->checkstack(1);
202 202
@@ -217,7 +217,7 @@ namespace lua {
217 } 217 }
218 218
219 state::state() 219 state::state()
220 : cobj(luaL_newstate()) 220 : cobj(luaL_newstate()), valid(new bool(true))
221 { 221 {
222 if(cobj == NULL) { 222 if(cobj == NULL) {
223 // docs say this can happen only in case of a memory allocation error 223 // docs say this can happen only in case of a memory allocation error
@@ -249,6 +249,7 @@ namespace lua {
249 luaL_openlibs(cobj); 249 luaL_openlibs(cobj);
250 } 250 }
251 catch(...) { 251 catch(...) {
252 *valid = false;
252 lua_close(cobj); 253 lua_close(cobj);
253 throw; 254 throw;
254 } 255 }