bug 1331320 install X11 error handler through Xlib in plugin process as GTK2 does not use g_error r?glandium
MozReview-Commit-ID: 9Io2fABc2hI
--- a/dom/plugins/ipc/PluginModuleChild.cpp
+++ b/dom/plugins/ipc/PluginModuleChild.cpp
@@ -19,16 +19,17 @@
#include "pratom.h"
#include "nsDebug.h"
#include "nsCOMPtr.h"
#include "nsPluginsDir.h"
#include "nsXULAppAPI.h"
#ifdef MOZ_X11
+# include "nsX11ErrorHandler.h"
# include "mozilla/X11Util.h"
#endif
#include "mozilla/ipc/ProcessChild.h"
#include "mozilla/plugins/PluginInstanceChild.h"
#include "mozilla/plugins/StreamNotifyChild.h"
#include "mozilla/plugins/BrowserStreamChild.h"
#include "mozilla/plugins/PluginStreamChild.h"
#include "mozilla/dom/CrashReporterChild.h"
@@ -603,17 +604,17 @@ PluginModuleChild::InitGraphics()
real_gtk_plug_embedded = *embedded;
*embedded = wrap_gtk_plug_embedded;
#else
// may not be necessary on all platforms
#endif
#ifdef MOZ_X11
// Do this after initializing GDK, or GDK will install its own handler.
- XRE_InstallX11ErrorHandler();
+ InstallX11ErrorHandler();
#endif
return true;
}
void
PluginModuleChild::DeinitGraphics()
{
#if defined(MOZ_X11) && defined(NS_FREE_PERMANENT_DATA)
--- a/toolkit/xre/moz.build
+++ b/toolkit/xre/moz.build
@@ -65,16 +65,17 @@ else:
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3':
UNIFIED_SOURCES += [
'nsGDKErrorHandler.cpp',
]
if CONFIG['MOZ_X11']:
+ EXPORTS += ['nsX11ErrorHandler.h']
UNIFIED_SOURCES += [
'nsX11ErrorHandler.cpp',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
UNIFIED_SOURCES += [
'nsAndroidStartup.cpp',
]
--- a/toolkit/xre/nsX11ErrorHandler.cpp
+++ b/toolkit/xre/nsX11ErrorHandler.cpp
@@ -144,21 +144,19 @@ X11Error(Display *display, XErrorEvent *
#endif
#endif
NS_RUNTIMEABORT(notes.get());
return 0; // not reached
}
}
-#if (MOZ_WIDGET_GTK != 3)
void
InstallX11ErrorHandler()
{
XSetErrorHandler(X11Error);
Display *display = mozilla::DefaultXDisplay();
NS_ASSERTION(display, "No X display");
if (PR_GetEnv("MOZ_X_SYNC")) {
XSynchronize(display, True);
}
}
-#endif
--- a/toolkit/xre/nsX11ErrorHandler.h
+++ b/toolkit/xre/nsX11ErrorHandler.h
@@ -1,12 +1,17 @@
/* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef MOZ_X11
#include <X11/Xlib.h>
-#if (MOZ_WIDGET_GTK != 3)
+
+/**
+ * InstallX11ErrorHandler is not suitable for processes running with GTK3 as
+ * GDK3 will replace the handler. This is still used for the plugin process,
+ * which runs with GTK2.
+ **/
void InstallX11ErrorHandler();
-#endif
+
extern "C" int X11Error(Display *display, XErrorEvent *event);
#endif