]> git.sesse.net Git - vlc/commitdiff
* ./src/misc/modules_plugin.h.in: when opening the KDE plugin, we first
authorSam Hocevar <sam@videolan.org>
Mon, 10 Feb 2003 20:11:14 +0000 (20:11 +0000)
committerSam Hocevar <sam@videolan.org>
Mon, 10 Feb 2003 20:11:14 +0000 (20:11 +0000)
    dlopen(libstdc++) to avoid dlopen(kde_plugin) from crashing. Call me evil.

src/misc/modules_plugin.h.in

index 192b53ddd081f62642e83fd84d56a5c29c561576..07c4696493c2f165fda1c555f83536a5476af512 100644 (file)
@@ -2,7 +2,7 @@
  * modules_plugin.h : Plugin management functions used by the core application.
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: modules_plugin.h.in,v 1.8 2002/12/06 10:10:39 sam Exp $
+ * $Id: modules_plugin.h.in,v 1.9 2003/02/10 20:11:14 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -42,16 +42,31 @@ static int module_load( const MYCHAR * psz_filename, module_handle_t * handle )
     return( *handle == NULL );
 
 #elif defined(RTLD_NOW)
+    /* static is OK, we are called atomically */
+    static vlc_bool_t b_kde = VLC_FALSE;
+
 #   if defined(SYS_LINUX)
-    /* We should NOT open modules with RTLD_GLOBAL, or we are going to get
-     * namespace collisions when two modules have common public symbols,
-     * but ALSA is being a pest here. */
-    if( strstr( psz_filename, "alsa" ) )
+    /* XXX HACK #1 - we should NOT open modules with RTLD_GLOBAL, or we
+     * are going to get namespace collisions when two modules have common
+     * public symbols, but ALSA is being a pest here. */
+    if( strstr( psz_filename, "alsa_plugin" ) )
     {
         *handle = dlopen( psz_filename, RTLD_NOW | RTLD_GLOBAL );
         return( *handle == NULL );
     }
 #   endif
+    /* XXX HACK #2 - the ugly KDE workaround. It seems that libkdewhatever
+     * causes dlopen() to segfault if libstdc++ is not loaded in the caller,
+     * so we just load libstdc++. Bwahahaha! ph34r! -- Sam. */
+    if( !b_kde && !strstr( psz_filename, "kde" ) )
+    {
+        dlopen( "libstdc++.so.6", RTLD_NOW )
+         || dlopen( "libstdc++.so.5", RTLD_NOW )
+         || dlopen( "libstdc++.so.4", RTLD_NOW )
+         || dlopen( "libstdc++.so.3", RTLD_NOW );
+        b_kde = VLC_TRUE;
+    }
+
     *handle = dlopen( psz_filename, RTLD_NOW );
     return( *handle == NULL );