diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c index 846eaf0c62d1a333199f48c9fc03b6f4b0123f9b..92c216aa43b19b3c4a9f387b28fa4cf82c13e9da 100644 --- a/sflphone-client-gnome/src/actions.c +++ b/sflphone-client-gnome/src/actions.c @@ -185,6 +185,7 @@ sflphone_hung_up( callable_obj_t * c) calltree_remove_call(current_calls, c, NULL); c->_state = CALL_STATE_DIALING; call_remove_all_errors(c); + free_callable_obj_t(c); update_actions(); #if GTK_CHECK_VERSION(2,10,0) status_tray_icon_blink( FALSE ); diff --git a/sflphone-client-gnome/src/callable_obj.c b/sflphone-client-gnome/src/callable_obj.c index 2cfeb7a1a153bc3ee793cbf53ce150448fff0252..d34564b9711f792012e2f604237344dd90800ec8 100644 --- a/sflphone-client-gnome/src/callable_obj.c +++ b/sflphone-client-gnome/src/callable_obj.c @@ -129,6 +129,19 @@ void call_remove_all_errors(callable_obj_t * call) g_ptr_array_foreach (call->_error_dialogs, (GFunc) gtk_widget_destroy, NULL); } +void *threaded_clock_incrementer(void *pc) { + + int count = 0; + + callable_obj_t *call = (callable_obj_t *)pc; + + while(call->clockStarted) { + DEBUG("Clock started: %d", call->clockStarted); + DEBUG("Clock: %d\n", count++); + sleep(1); + } +} + 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) { @@ -162,6 +175,10 @@ void create_new_call (callable_type_t type, call_state_t state, gchar* callID , obj->_callID = g_strdup (call_id); obj->_confID = NULL; + obj->clockStarted = 1; + + pthread_create(&(obj->tid), NULL, threaded_clock_incrementer, obj); + *new_call = obj; } @@ -255,6 +272,10 @@ void create_history_entry_from_serialized_form (gchar *timestamp, gchar *details void free_callable_obj_t (callable_obj_t *c) { + c->clockStarted = 0; + + pthread_join(c->tid, NULL); + g_free (c->_callID); g_free (c->_accountID); g_free (c->_peer_name); diff --git a/sflphone-client-gnome/src/callable_obj.h b/sflphone-client-gnome/src/callable_obj.h index 21f46fe55e6a31f17f6a8894ce1c19863c7ad8ef..414245854f06956d82d24a607561f8742e4a4904 100644 --- a/sflphone-client-gnome/src/callable_obj.h +++ b/sflphone-client-gnome/src/callable_obj.h @@ -154,6 +154,8 @@ typedef struct { // thread id to increment clock pthread_t tid; + int clockStarted; + } callable_obj_t; void create_new_call (callable_type_t, call_state_t, gchar*, gchar*, gchar*, gchar*, callable_obj_t **); diff --git a/sflphone-client-gnome/src/contacts/calltree.c b/sflphone-client-gnome/src/contacts/calltree.c index 11da3e3f12e477e07762ec952e56220c9b6aa815..34a615acabb1e023b84be8b8bec5809740630824 100644 --- a/sflphone-client-gnome/src/contacts/calltree.c +++ b/sflphone-client-gnome/src/contacts/calltree.c @@ -74,17 +74,6 @@ enum { COLUMN_ACCOUNT_PTR, }; - -void *threaded_clock_incrementer(void *call) { - - int count = 0; - - while(1) { - printf("Clock: %d\n", count++); - sleep(1); - } -} - /** * Show popup menu */