author | francesco-ST <francesco.abbate@st.com> | 2011年02月02日 18:13:11 +0100 |
---|---|---|
committer | francesco-ST <francesco.abbate@st.com> | 2011年02月02日 18:13:11 +0100 |
commit | 87feed1b8c36fd42a3750d01382a4978971416cc (patch) | |
tree | 90f68f0d96a64b3f8ea14fb59655c8154808a24f /agg-plot/window.cpp | |
parent | 00cb071098589dc5824509d7e7786fde16a00ff2 (diff) | |
download | gsl-shell-87feed1b8c36fd42a3750d01382a4978971416cc.tar.gz |
-rw-r--r-- | agg-plot/window.cpp | 15 |
diff --git a/agg-plot/window.cpp b/agg-plot/window.cpp index f7cb9ed2..398efbdc 100644 --- a/agg-plot/window.cpp +++ b/agg-plot/window.cpp @@ -371,9 +371,15 @@ typedef void (window::*window_slot_method_type)(int slot_id); int window_generic_oper (lua_State *L, window_slot_method_type method) { - window *win = object_check<window>(L, 1, GS_WINDOW); + window_boxed *win = object_check<window_boxed>(L, 1, GS_WINDOW); int slot_id = luaL_checkinteger (L, 2); + // we check to be sure that the window was not garbage collected + // by Lua. In this case the destructor was called but the momory + // itself is not disposed. Since the is_alive method is non-virtual + // that shoud be always fine. + if (! win->is_alive()) return 0; + win->lock(); if (win->status == canvas_window::running) { @@ -389,9 +395,12 @@ int window_generic_oper_ext (lua_State *L, void (window::*method)(int, param_type), param_type param) { - window *win = object_check<window>(L, 1, GS_WINDOW); + window_boxed *win = object_check<window_boxed>(L, 1, GS_WINDOW); int slot_id = luaL_checkinteger (L, 2); + // see comment is the function window_generic_oper + if (! win->is_alive()) return 0; + win->lock(); if (win->status == canvas_window::running) { @@ -431,7 +440,7 @@ void window::start (lua_State *L, gslshell::ret_status& st) int window_new (lua_State *L) { - window *win = push_new_object<window>(L, GS_WINDOW, colors::white); + window_boxed *win = push_new_object<window_boxed>(L, GS_WINDOW, colors::white); const char *spec = lua_tostring (L, 1); gslshell::ret_status st; |