author | Francesco Abbate <francesco.bbt@gmail.com> | 2011年12月28日 15:46:36 +0100 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2011年12月31日 17:04:49 +0100 |
commit | 4662604d57b8e0614494af1f2059ed554a3d3ae0 (patch) | |
tree | 6e18e33d8cba9058bc0cf9804086e3ea2c94b541 /agg-plot/window.cpp | |
parent | 583b8b134aba335f47ca4f357ae6afd019312866 (diff) | |
download | gsl-shell-4662604d57b8e0614494af1f2059ed554a3d3ae0.tar.gz |
-rw-r--r-- | agg-plot/window.cpp | 25 |
diff --git a/agg-plot/window.cpp b/agg-plot/window.cpp index 7625b73e..d27b85e7 100644 --- a/agg-plot/window.cpp +++ b/agg-plot/window.cpp @@ -398,7 +398,7 @@ void window::start (lua_State *L, gslshell::ret_status& st) { this->lock(); - if (status != canvas_window::running && status != canvas_window::starting) + if (status != canvas_window::running) { typedef canvas_window::thread_info thread_info; std::auto_ptr<thread_info> inf(new thread_info(L, this)); @@ -455,7 +455,20 @@ window_show (lua_State *L) int window_free (lua_State *L) { - return object_free<window>(L, 1, GS_WINDOW); + window *win = object_check<window>(L, 1, GS_WINDOW); + + /* it is important here to lock to ensure that there isn't any thread starting + a new graphical window right now */ + win->lock(); + + /* This should never happens. Running windows are never garbage collected + and before closing lua_State all the graphical windows are closed and + their threads have naturally finished. */ + assert(win->status != window::running); + + win->unlock(); + win->~window(); + return 0; } int @@ -564,6 +577,14 @@ window_close (lua_State *L) return 0; } +int +window_close_wait (lua_State *L) +{ + window *win = object_check<window>(L, 1, GS_WINDOW); + win->shutdown_close(); + return 0; +} + void window_register (lua_State *L) { |