gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot/window.cpp
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2011年12月28日 15:46:36 +0100
committerFrancesco Abbate <francesco.bbt@gmail.com>2011年12月31日 17:04:49 +0100
commit4662604d57b8e0614494af1f2059ed554a3d3ae0 (patch)
tree6e18e33d8cba9058bc0cf9804086e3ea2c94b541 /agg-plot/window.cpp
parent583b8b134aba335f47ca4f357ae6afd019312866 (diff)
downloadgsl-shell-4662604d57b8e0614494af1f2059ed554a3d3ae0.tar.gz
Ensure all windows are closed before exit
Diffstat (limited to 'agg-plot/window.cpp')
-rw-r--r--agg-plot/window.cpp 25
1 files changed, 23 insertions, 2 deletions
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)
{
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月12日 14:28:51 +0000

AltStyle によって変換されたページ (->オリジナル) /