From 336a0500ebc2721318f7481d4de07f6fb5518f62 Mon Sep 17 00:00:00 2001 From: Alexandre Savard <alexandre.savard@savoirfairelinux.com> Date: Wed, 11 Aug 2010 14:18:03 -0400 Subject: [PATCH] [#3853] Stop callableobj thread outside free_callable_obj_t --- sflphone-client-gnome/src/actions.c | 2 ++ sflphone-client-gnome/src/callable_obj.c | 32 ++++++++++++++++++------ sflphone-client-gnome/src/callable_obj.h | 3 +++ 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c index 265b4e25b4..b1cb7caaf7 100644 --- a/sflphone-client-gnome/src/actions.c +++ b/sflphone-client-gnome/src/actions.c @@ -410,6 +410,8 @@ sflphone_hang_up() calltree_update_call (history, selectedCall, NULL); + stop_call_clock (selectedCall); + calltree_update_clock(); } diff --git a/sflphone-client-gnome/src/callable_obj.c b/sflphone-client-gnome/src/callable_obj.c index 54e0f1226c..6bd0d3c775 100644 --- a/sflphone-client-gnome/src/callable_obj.c +++ b/sflphone-client-gnome/src/callable_obj.c @@ -136,6 +136,8 @@ void threaded_clock_incrementer (void *pc) while (call->clockStarted) { + DEBUG ("CALL CLOCK"); + int duration; time_t start, current; @@ -184,6 +186,27 @@ void threaded_clock_incrementer (void *pc) } + DEBUG ("CallableObj: Stopping Thread"); + + g_thread_exit (NULL); + +} + +void stop_call_clock (callable_obj_t *c) +{ + + DEBUG ("CallableObj: Stop call clock"); + + if (!c) { + ERROR ("CallableObj: Callable object is NULL"); + return; + } + + if (c->_type == CALL && c->clockStarted) { + c->clockStarted = 0; + /// no need to join here, only need to call g_thread_exit at the end of the threaded function + // g_thread_join (c->tid); + } } void create_new_call (callable_type_t type, call_state_t state, gchar* callID , gchar* accountID, gchar* peer_name, gchar* peer_number, callable_obj_t ** new_call) @@ -332,14 +355,7 @@ void free_callable_obj_t (callable_obj_t *c) { DEBUG ("CallableObj: Free callable object"); - if (!c) - ERROR ("CallableObj: Callable object is NULL"); - - if (c->_type == CALL) { - c->clockStarted = 0; - - g_thread_join (c->tid); - } + stop_call_clock (c); g_free (c->_callID); g_free (c->_accountID); diff --git a/sflphone-client-gnome/src/callable_obj.h b/sflphone-client-gnome/src/callable_obj.h index 4518dcd6ea..c240a48a9f 100644 --- a/sflphone-client-gnome/src/callable_obj.h +++ b/sflphone-client-gnome/src/callable_obj.h @@ -200,6 +200,9 @@ attach_thumbnail (callable_obj_t *, GdkPixbuf *); void free_callable_obj_t (callable_obj_t *c); +void +stop_call_clock (callable_obj_t *c); + /** * @return gchar* A random ID */ -- GitLab