diff --git a/gfx/src/gtk/nsGfxFactoryGTK.cpp b/gfx/src/gtk/nsGfxFactoryGTK.cpp index ae6aaed70c5a..616164dfd0ef 100644 --- a/gfx/src/gtk/nsGfxFactoryGTK.cpp +++ b/gfx/src/gtk/nsGfxFactoryGTK.cpp @@ -180,5 +180,11 @@ static nsModuleComponentInfo components[] = nsScreenManagerGtkConstructor } }; -NS_IMPL_NSGETMODULE("nsGfxGTKModule", components) +PR_STATIC_CALLBACK(void) +nsGfxGTKModuleDtor(nsIModule *self) +{ + nsRenderingContextGTK::Shutdown(); +} + +NS_IMPL_NSGETMODULE_WITH_DTOR("nsGfxGTKModule", components, nsGfxGTKModuleDtor) diff --git a/gfx/src/gtk/nsRenderingContextGTK.cpp b/gfx/src/gtk/nsRenderingContextGTK.cpp index ca97cb1b9d07..d1a57ccc19a6 100644 --- a/gfx/src/gtk/nsRenderingContextGTK.cpp +++ b/gfx/src/gtk/nsRenderingContextGTK.cpp @@ -45,7 +45,7 @@ static NS_DEFINE_CID(kRegionCID, NS_REGION_CID); gdk.height = ns.height; \ PR_END_MACRO -static nsGCCache *gcCache = new nsGCCache(); +static nsGCCache *gcCache = nsnull; nsRenderingContextGTK::nsRenderingContextGTK() { @@ -102,6 +102,12 @@ nsRenderingContextGTK::~nsRenderingContextGTK() } } +/*static*/ nsresult +nsRenderingContextGTK::Shutdown() +{ + delete gcCache; + return NS_OK; +} NS_IMETHODIMP nsRenderingContextGTK::Init(nsIDeviceContext* aContext, nsIWidget *aWindow) @@ -519,6 +525,10 @@ void nsRenderingContextGTK::UpdateGC() mClipRegion->GetNativeRegion((void*&)rgn); } + if (!gcCache) { + gcCache = new nsGCCache(); + if (!gcCache) return; + } mGC = gcCache->GetGC(mSurface->GetDrawable(), &values, valuesMask, diff --git a/gfx/src/gtk/nsRenderingContextGTK.h b/gfx/src/gtk/nsRenderingContextGTK.h index 43a9efecb48e..993ee455821a 100644 --- a/gfx/src/gtk/nsRenderingContextGTK.h +++ b/gfx/src/gtk/nsRenderingContextGTK.h @@ -51,6 +51,7 @@ class nsRenderingContextGTK : public nsRenderingContextImpl public: nsRenderingContextGTK(); virtual ~nsRenderingContextGTK(); + static nsresult Shutdown(); // release statics NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW