]> git.sesse.net Git - vlc/commitdiff
Fixed gtk core-dump on exit. Used code from gtk plugin for this.
authorJean-Paul Saman <jpsaman@videolan.org>
Mon, 22 Jul 2002 21:04:55 +0000 (21:04 +0000)
committerJean-Paul Saman <jpsaman@videolan.org>
Mon, 22 Jul 2002 21:04:55 +0000 (21:04 +0000)
plugins/familiar/familiar.c
plugins/familiar/familiar.h

index c1ea04cd876b6f29c5ffb3d7de23e719c742a9c7..753aa1efc02e1751a7c8a457d07d7cae60c9ebc7 100644 (file)
@@ -2,7 +2,7 @@
  * familiar.c : familiar plugin for vlc
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: familiar.c,v 1.3 2002/07/22 20:52:42 jpsaman Exp $
+ * $Id: familiar.c,v 1.4 2002/07/22 21:04:55 jpsaman Exp $
  *
  * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
  *
 #include "familiar_support.h"
 #include "familiar.h"
 
+/*****************************************************************************
+ * Local variables (mutex-protected).
+ *****************************************************************************/
+static void ** pp_global_data = NULL;
+
+/*****************************************************************************
+ * g_atexit: kludge to avoid the Gtk+ thread to segfault at exit
+ *****************************************************************************
+ * gtk_init() makes several calls to g_atexit() which calls atexit() to
+ * register tidying callbacks to be called at program exit. Since the Gtk+
+ * plugin is likely to be unloaded at program exit, we have to export this
+ * symbol to intercept the g_atexit() calls. Talk about crude hack.
+ *****************************************************************************/
+void g_atexit( GVoidFunc func )
+{
+    intf_thread_t *p_intf;
+
+    int i_dummy;
+
+    if( pp_global_data == NULL )
+    {
+        atexit( func );
+        return;
+    }
+
+    p_intf = (intf_thread_t *)*pp_global_data;
+    if( p_intf == NULL )
+    {
+        return;
+    }
+
+    for( i_dummy = 0;
+         i_dummy < MAX_ATEXIT && p_intf->p_sys->pf_callback[i_dummy] != NULL;
+         i_dummy++ )
+    {
+        ;
+    }
+
+    if( i_dummy >= MAX_ATEXIT - 1 )
+    {
+        msg_Err( p_intf, "too many atexit() callbacks to register" );
+        return;
+    }
+
+    p_intf->p_sys->pf_callback[i_dummy]     = func;
+    p_intf->p_sys->pf_callback[i_dummy + 1] = NULL;
+}
+
 /*****************************************************************************
  * Local prototypes.
  *****************************************************************************/
index 235474766311a1f15ddfe6296cafcd54e605d115..7afe150165473ea926d923554627337a7e80dfe1 100644 (file)
@@ -2,7 +2,7 @@
  * familiar.h: private Gtk+ interface description
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: familiar.h,v 1.2 2002/07/22 19:49:40 jpsaman Exp $
+ * $Id: familiar.h,v 1.3 2002/07/22 21:04:55 jpsaman Exp $
  *
  * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
  *
@@ -21,6 +21,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MAX_ATEXIT                 10
+
 /*****************************************************************************
  * intf_sys_t: description and status of Gtk+ interface
  *****************************************************************************/
@@ -31,5 +33,8 @@ struct intf_sys_t
 
     /* The input thread */
     input_thread_t *    p_input;
+
+    /* XXX: Ugly kludge, see gtk.c */
+    void             ( *pf_callback[MAX_ATEXIT] ) ( void );
 };