diff options
Diffstat (limited to 'src/FbTk/Luamm.cc')
-rw-r--r-- | src/FbTk/Luamm.cc | 9 |
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 | } |