diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c index 265b4e25b46ef9ed20381b86a87a6ef85d51056d..b1cb7caaf7e7f996c13e849dbe3a5c68092e791a 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 54e0f1226c662f1199743f9902f1093e51dc392b..6bd0d3c775aa9e4e0baec9a053aa15e6b3ee74cf 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 4518dcd6ea1d0e8818fe59824b34bf822b8dbbbf..c240a48a9fac5c125c1a8fe59fd3b7604fe97066 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 */