improved thread/exception-safety for window creation and show function - 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-ST <francesco.abbate@st.com>2011年01月03日 14:30:43 +0100
committerfrancesco <francesco.bbt@gmail.com>2011年01月03日 20:56:08 +0100
commit1d0382f13c23443d26a330fcb89742a7befe0450 (patch)
tree6733bb5bb062875205cde819ff14d291923e694a /agg-plot/window.cpp
parent7f73acc24c47f7e0ef6f367db12a184a23e5faa2 (diff)
downloadgsl-shell-1d0382f13c23443d26a330fcb89742a7befe0450.tar.gz
improved thread/exception-safety for window creation and show function
Signed-off-by: francesco-ST <francesco.abbate@st.com>
Diffstat (limited to 'agg-plot/window.cpp')
-rw-r--r--agg-plot/window.cpp 35
1 files changed, 32 insertions, 3 deletions
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;
}
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月13日 10:59:20 +0000

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