Bug 626602, part 8.1: Close the XDisplay to free the gfxXlibSurface DisplayTable, for the sake of leak checkers. r=karlt
authorChris Jones <jones.chris.g@gmail.com>
Tue, 08 Feb 2011 18:44:14 -0600
changeset 62207 9d3141affbe59260de88d44ce9696148a66b6d07
parent 62206 fd046a4bbb19bf67bfe1157a874a9dc2e559ccd6
child 62208 a96c75dbc1518b048819170162ba2c9bec16cd40
push id18641
push usercjones@mozilla.com
push dateWed, 09 Feb 2011 00:44:41 +0000
treeherdermozilla-central@fa1a4b6abff0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs626602
milestone2.0b12pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 626602, part 8.1: Close the XDisplay to free the gfxXlibSurface DisplayTable, for the sake of leak checkers. r=karlt
dom/plugins/PluginModuleChild.cpp
dom/plugins/PluginModuleChild.h
--- a/dom/plugins/PluginModuleChild.cpp
+++ b/dom/plugins/PluginModuleChild.cpp
@@ -132,24 +132,19 @@ PluginModuleChild::PluginModuleChild() :
 }
 
 PluginModuleChild::~PluginModuleChild()
 {
     NS_ASSERTION(gInstance == this, "Something terribly wrong here!");
     if (mLibrary) {
         PR_UnloadLibrary(mLibrary);
     }
-#ifdef MOZ_WIDGET_QT
-    nsQAppInstance::Release();
-    if (sGtkLib) {
-        PR_UnloadLibrary(sGtkLib);
-        sGtkLib = nsnull;
-        s_gtk_init = nsnull;
-    }
-#endif
+
+    DeinitGraphics();
+
     gInstance = nsnull;
 }
 
 // static
 PluginModuleChild*
 PluginModuleChild::current()
 {
     NS_ASSERTION(gInstance, "Null instance!");
@@ -554,16 +549,36 @@ PluginModuleChild::InitGraphics()
 #ifdef MOZ_X11
     // Do this after initializing GDK, or GDK will install its own handler.
     XRE_InstallX11ErrorHandler();
 #endif
 
     return true;
 }
 
+void
+PluginModuleChild::DeinitGraphics()
+{
+#ifdef MOZ_WIDGET_QT
+    nsQAppInstance::Release();
+    if (sGtkLib) {
+        PR_UnloadLibrary(sGtkLib);
+        sGtkLib = nsnull;
+        s_gtk_init = nsnull;
+    }
+#endif
+
+#if defined(MOZ_X11) && defined(NS_FREE_PERMANENT_DATA)
+    // We free some data off of XDisplay close hooks, ensure they're
+    // run.  Closing the display is pretty scary, so we only do it to
+    // silence leak checkers.
+    XCloseDisplay(DefaultXDisplay());
+#endif
+}
+
 bool
 PluginModuleChild::AnswerNP_Shutdown(NPError *rv)
 {
     AssertPluginThread();
 
     // the PluginModuleParent shuts down this process after this RPC
     // call pops off its stack
 
--- a/dom/plugins/PluginModuleChild.h
+++ b/dom/plugins/PluginModuleChild.h
@@ -256,16 +256,17 @@ public:
       if (mQuirks == QUIRKS_NOT_INITIALIZED)
         mQuirks = 0;
       mQuirks |= quirk;
     }
 
 private:
     void InitQuirksModes(const nsCString& aMimeType);
     bool InitGraphics();
+    void DeinitGraphics();
 #if defined(MOZ_WIDGET_GTK2)
     static gboolean DetectNestedEventLoop(gpointer data);
     static gboolean ProcessBrowserEvents(gpointer data);
 
     NS_OVERRIDE
     virtual void EnteredCxxStack();
     NS_OVERRIDE
     virtual void ExitedCxxStack();