author | francesco-ST <francesco.abbate@st.com> | 2011年01月03日 14:30:43 +0100 |
---|---|---|
committer | francesco <francesco.bbt@gmail.com> | 2011年01月03日 20:56:08 +0100 |
commit | 1d0382f13c23443d26a330fcb89742a7befe0450 (patch) | |
tree | 6733bb5bb062875205cde819ff14d291923e694a /agg-plot/window.cpp | |
parent | 7f73acc24c47f7e0ef6f367db12a184a23e5faa2 (diff) | |
download | gsl-shell-1d0382f13c23443d26a330fcb89742a7befe0450.tar.gz |
-rw-r--r-- | agg-plot/window.cpp | 35 |
diff --git a/agg-plot/window.cpp b/agg-plot/window.cpp index 0fbcf000..32ff234d 100644 --- a/agg-plot/window.cpp +++ b/agg-plot/window.cpp @@ -418,18 +418,46 @@ int window_generic_oper_ext (lua_State *L, return 0; } +bool window::start (lua_State *L) +{ + this->lock(); + + if (this->status != canvas_window::running) + { + typedef canvas_window::thread_info thread_info; + std::auto_ptr<thread_info> inf(new thread_info(L, this)); + + this->window_id = object_index_add (L, -1); + inf->window_id = this->window_id; + + if (! this->start_new_thread (inf)) + { + object_index_remove (L, this->window_id); + this->unlock(); + return false; + } + } + else + { + this->unlock(); + return false; + } + + return true; +} + int window_new (lua_State *L) { window *win = push_new_object<window>(L, GS_WINDOW, colors::white); const char *spec = lua_tostring (L, 1); - win->start_new_thread (L); + if (! win->start(L)) + return luaL_error (L, "error during window initialization"); if (spec) { win->split(spec); - // return luaL_error(L, window::error_message(window::invalid_split_string)); } return 1; @@ -439,7 +467,8 @@ int window_show (lua_State *L) { window *win = object_check<window>(L, 1, GS_WINDOW); - win->start_new_thread (L); + if (! win->start(L)) + return luaL_error (L, "error during window initialization"); return 0; } |