Changeset 65728 in webkit


Ignore:
Timestamp:
Aug 20, 2010 1:12:08 AM (14 years ago)
Author:
andreas.kling@nokia.com
Message:

2010-08-20 Andreas Kling <andreas.kling@nokia.com>

Reviewed by Kenneth Rohde Christiansen.

[Qt] Initialize GDK before loading plugins
https://bugs.webkit.org/show_bug.cgi?id=44324

Attempt to call gdk_init_check() before loading any plugins.
This prevents various crashes and freezes in Adobe's Flash plugin.

  • plugins/qt/PluginPackageQt.cpp: (WebCore::initializeGdkIfPossible): (WebCore::PluginPackage::load):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r65727 r65728  
     12010-08-20  Andreas Kling  <andreas.kling@nokia.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        [Qt] Initialize GDK before loading plugins
     6        https://bugs.webkit.org/show_bug.cgi?id=44324
     7
     8        Attempt to call gdk_init_check() before loading any plugins.
     9        This prevents various crashes and freezes in Adobe's Flash plugin.
     10
     11        * plugins/qt/PluginPackageQt.cpp:
     12        (WebCore::initializeGdkIfPossible):
     13        (WebCore::PluginPackage::load):
     14
    1152010-08-20  Dan Bernstein  <mitz@apple.com>
    216
  • trunk/WebCore/plugins/qt/PluginPackageQt.cpp

    r61307 r65728  
    3535
    3636namespace WebCore {
    37 
    38 typedef void gtkInitFunc(int *argc, char ***argv);
    3937
    4038bool PluginPackage::fetchInfo()
     
    9391}
    9492
     93static void initializeGdkIfPossible()
     94{
     95    static bool attemptMade = false;
     96
     97    if (attemptMade)
     98        return;
     99
     100    attemptMade = true;
     101
     102    QLibrary library("libgdk-x11-2.0.so.0");
     103    if (!library.load())
     104        return;
     105
     106    typedef void *(*gdk_init_check_ptr)(int*, char***);
     107    gdk_init_check_ptr gdk_init_check = (gdk_init_check_ptr)library.resolve("gdk_init_check");
     108    if (!gdk_init_check)
     109        return;
     110
     111    // NOTE: We're using gdk_init_check() since gdk_init() may exit() on failure.
     112    (void) gdk_init_check(0, 0);
     113}
     114
    95115bool PluginPackage::load()
    96116{
     
    112132    NP_InitializeFuncPtr NP_Initialize;
    113133    NPError npErr;
    114     gtkInitFunc* gtkInit;
    115134
    116135    NP_Initialize = (NP_InitializeFuncPtr)m_module->resolve("NP_Initialize");
     
    131150    }
    132151
    133     // WORKAROUND: Prevent gtk based plugin crashes such as BR# 40567 by
    134     // explicitly forcing the initializing of Gtk, i.e. calling gtk_init,
    135     // whenver the symbol is present in the plugin library loaded above.
    136     // Note that this workaround is based on code from the NSPluginClass ctor
    137     // in KDE's kdebase/apps/nsplugins/viewer/nsplugin.cpp file.
    138     gtkInit = (gtkInitFunc*)m_module->resolve("gtk_init");
    139     if (gtkInit) {
    140         // Prevent gtk_init() from replacing the X error handlers, since the Gtk
    141         // handlers abort when they receive an X error, thus killing the viewer.
    142 #ifdef Q_WS_X11
    143         int (*old_error_handler)(Display*, XErrorEvent*) = XSetErrorHandler(0);
    144         int (*old_io_error_handler)(Display*) = XSetIOErrorHandler(0);
    145 #endif
    146         gtkInit(0, 0);
    147 #ifdef Q_WS_X11
    148         XSetErrorHandler(old_error_handler);
    149         XSetIOErrorHandler(old_io_error_handler);
    150 #endif
    151     }
     152    // Try to initialize GDK - some versions of the Flash plugin depend on this.
     153    initializeGdkIfPossible();
    152154
    153155#if defined(XP_UNIX)
Note: See TracChangeset for help on using the changeset viewer.