Fix one-time leak of nsGCCache. r=pavlov@netscape.com sr=waterson@netscape.com b=60215

This commit is contained in:
dbaron%fas.harvard.edu 2001-01-10 04:10:07 +00:00
parent 994a352f4c
commit 66680e0a0e
3 changed files with 19 additions and 2 deletions

View File

@ -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)

View File

@ -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,

View File

@ -51,6 +51,7 @@ class nsRenderingContextGTK : public nsRenderingContextImpl
public:
nsRenderingContextGTK();
virtual ~nsRenderingContextGTK();
static nsresult Shutdown(); // release statics
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW