static gchar *workingdir=NULL;
static char *progpath=NULL;
gchar *linphone_logfile=NULL;
-static gboolean app_terminated=FALSE;
static GOptionEntry linphone_options[]={
{
}
}
+static void linphone_gtk_quit(void){
+ gdk_threads_leave();
+ linphone_gtk_destroy_log_window();
+ linphone_core_destroy(the_core);
+ linphone_gtk_log_uninit();
+}
+
#ifdef HAVE_GTK_OSX
+/*
+This is not the correct way to implement block termination.
+The good way would be to call gtk_main_quit(), and return TRUE.
+Unfortunately this does not work, because if we return TRUE the NSApplication sometimes calls the CFRunLoop recursively, which prevents gtk_main() to exit.
+As a result the program cannot exit at all.
+As a workaround we do all the cleanup (unregistration and config save) within the handler.
+*/
static gboolean on_block_termination(void){
gtk_main_quit();
- g_message("Block termination returning %i",!app_terminated);
- return !app_terminated;
+ linphone_gtk_quit();
+ return FALSE;
}
#endif
linphone_gtk_check_for_new_version();
gtk_main();
- gdk_threads_leave();
- linphone_gtk_destroy_log_window();
- linphone_core_destroy(the_core);
- linphone_gtk_log_uninit();
- app_terminated=TRUE;
+ linphone_gtk_quit();
#ifndef HAVE_GTK_OSX
/*workaround a bug on win32 that makes status icon still present in the systray even after program exit.*/
gtk_status_icon_set_visible(icon,FALSE);