diff options
Diffstat (limited to 'WebCore/plugins/qt/PluginPackageQt.cpp')
-rw-r--r-- | WebCore/plugins/qt/PluginPackageQt.cpp | 63 |
1 files changed, 40 insertions, 23 deletions
diff --git a/WebCore/plugins/qt/PluginPackageQt.cpp b/WebCore/plugins/qt/PluginPackageQt.cpp index 07149f3..d92fffe 100644 --- a/WebCore/plugins/qt/PluginPackageQt.cpp +++ b/WebCore/plugins/qt/PluginPackageQt.cpp @@ -35,8 +35,6 @@ namespace WebCore { -typedef void gtkInitFunc(int *argc, char ***argv); - bool PluginPackage::fetchInfo() { if (!load()) @@ -92,6 +90,39 @@ static NPError staticPluginQuirkRequiresGtkToolKit_NPN_GetValue(NPP instance, NP return NPN_GetValue(instance, variable, value); } +static void initializeGtk(QLibrary* module = 0) +{ + // Ensures missing Gtk initialization in some versions of Adobe's flash player + // plugin do not cause crashes. See BR# 40567, 44324, and 44405 for details. + if (module) { + typedef void *(*gtk_init_ptr)(int*, char***); + gtk_init_ptr gtkInit = (gtk_init_ptr)module->resolve("gtk_init"); + if (gtkInit) { + // Prevent gtk_init() from replacing the X error handlers, since the Gtk + // handlers abort when they receive an X error, thus killing the viewer. +#ifdef Q_WS_X11 + int (*old_error_handler)(Display*, XErrorEvent*) = XSetErrorHandler(0); + int (*old_io_error_handler)(Display*) = XSetIOErrorHandler(0); +#endif + gtkInit(0, 0); +#ifdef Q_WS_X11 + XSetErrorHandler(old_error_handler); + XSetIOErrorHandler(old_io_error_handler); +#endif + return; + } + } + + QLibrary library("libgtk-x11-2.0.so.0"); + if (library.load()) { + typedef void *(*gtk_init_check_ptr)(int*, char***); + gtk_init_check_ptr gtkInitCheck = (gtk_init_check_ptr)library.resolve("gtk_init_check"); + // NOTE: We're using gtk_init_check() since gtk_init() calls exit() on failure. + if (gtkInitCheck) + (void) gtkInitCheck(0, 0); + } +} + bool PluginPackage::load() { if (m_isLoaded) { @@ -111,7 +142,6 @@ bool PluginPackage::load() NP_InitializeFuncPtr NP_Initialize; NPError npErr; - gtkInitFunc* gtkInit; NP_Initialize = (NP_InitializeFuncPtr)m_module->resolve("NP_Initialize"); m_NPP_Shutdown = (NPP_ShutdownProcPtr)m_module->resolve("NP_Shutdown"); @@ -128,26 +158,13 @@ bool PluginPackage::load() // nspluginwrapper relies on the toolkit value to know if glib is available // It does so in NP_Initialize with a null instance, therefore it is done this way: m_browserFuncs.getvalue = staticPluginQuirkRequiresGtkToolKit_NPN_GetValue; - } - - // WORKAROUND: Prevent gtk based plugin crashes such as BR# 40567 by - // explicitly forcing the initializing of Gtk, i.e. calling gtk_init, - // whenver the symbol is present in the plugin library loaded above. - // Note that this workaround is based on code from the NSPluginClass ctor - // in KDE's kdebase/apps/nsplugins/viewer/nsplugin.cpp file. - gtkInit = (gtkInitFunc*)m_module->resolve("gtk_init"); - if (gtkInit) { - // Prevent gtk_init() from replacing the X error handlers, since the Gtk - // handlers abort when they receive an X error, thus killing the viewer. -#ifdef Q_WS_X11 - int (*old_error_handler)(Display*, XErrorEvent*) = XSetErrorHandler(0); - int (*old_io_error_handler)(Display*) = XSetIOErrorHandler(0); -#endif - gtkInit(0, 0); -#ifdef Q_WS_X11 - XSetErrorHandler(old_error_handler); - XSetIOErrorHandler(old_io_error_handler); -#endif + // Workaround Adobe's failure to properly initialize Gtk in some versions + // of their flash player plugin. + initializeGtk(); + } else if (m_path.contains("flashplayer")) { + // Workaround Adobe's failure to properly initialize Gtk in some versions + // of their flash player plugin. + initializeGtk(m_module); } #if defined(XP_UNIX) |