Ensure all windows are closed before exit - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot/canvas-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/canvas-window.cpp
parent583b8b134aba335f47ca4f357ae6afd019312866 (diff)
downloadgsl-shell-4662604d57b8e0614494af1f2059ed554a3d3ae0.tar.gz
Ensure all windows are closed before exit
Diffstat (limited to 'agg-plot/canvas-window.cpp')
-rw-r--r--agg-plot/canvas-window.cpp 36
1 files changed, 28 insertions, 8 deletions
diff --git a/agg-plot/canvas-window.cpp b/agg-plot/canvas-window.cpp
index ddc18fa9..60598484 100644
--- a/agg-plot/canvas-window.cpp
+++ b/agg-plot/canvas-window.cpp
@@ -62,15 +62,12 @@ bool canvas_window::start_new_thread (std::auto_ptr<canvas_window::thread_info>&
return false;
pthread_attr_t attr[1];
- pthread_t win_thread[1];
pthread_attr_init (attr);
- pthread_attr_setdetachstate (attr, PTHREAD_CREATE_DETACHED);
-
- this->status = canvas_window::starting;
+ pthread_attr_setdetachstate (attr, PTHREAD_CREATE_JOINABLE);
void *user_data = (void *) inf.get();
- if (pthread_create(win_thread, attr, canvas_thread_function, user_data))
+ if (pthread_create(&m_thread, attr, canvas_thread_function, user_data))
{
this->status = canvas_window::error;
pthread_attr_destroy (attr);
@@ -108,9 +105,32 @@ canvas_thread_function (void *_inf)
win->unlock();
- GSL_SHELL_LOCK();
- window_index_remove (inf->L, inf->window_id);
- GSL_SHELL_UNLOCK();
+ pthread_mutex_lock (gsl_shell_shutdown_mutex);
+ if (!gsl_shell_shutting_down)
+ {
+ GSL_SHELL_LOCK();
+ window_index_remove (inf->L, inf->window_id);
+ GSL_SHELL_UNLOCK();
+ }
+ pthread_mutex_unlock (gsl_shell_shutdown_mutex);
return NULL;
}
+
+void
+canvas_window::shutdown_close()
+{
+ lock();
+ if (status == canvas_window::running)
+ {
+ close_request();
+ unlock();
+ pthread_mutex_unlock (gsl_shell_shutdown_mutex);
+ pthread_join(m_thread, NULL);
+ pthread_mutex_lock (gsl_shell_shutdown_mutex);
+ }
+ else
+ {
+ unlock();
+ }
+}
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月13日 18:25:34 +0000

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