mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Fix various shutdown leaks. Add static Shutdown method to gfxPlatform as the entry point for thebes cleanup and use the virtual destructor of the platform-specific gfxPlatform objects to do platform-specific cleanup. b=374286 r=vlad
This commit is contained in:
parent
e1e938706d
commit
367d5607f1
@ -133,6 +133,13 @@ nsThebesDeviceContext::~nsThebesDeviceContext()
|
||||
{
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsThebesDeviceContext::Shutdown()
|
||||
{
|
||||
delete gSystemFonts;
|
||||
gSystemFonts = nsnull;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsThebesDeviceContext::SetDPI()
|
||||
{
|
||||
|
@ -67,6 +67,8 @@ public:
|
||||
nsThebesDeviceContext();
|
||||
virtual ~nsThebesDeviceContext();
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_IMETHOD Init(nsNativeWidget aWidget);
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "nsThebesBlender.h"
|
||||
#include "nsThebesFontMetrics.h"
|
||||
#include "nsThebesFontEnumerator.h"
|
||||
#include "gfxPlatform.h"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesFontMetrics)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesBlender)
|
||||
@ -145,6 +146,8 @@ static const nsModuleComponentInfo components[] =
|
||||
PR_STATIC_CALLBACK(void)
|
||||
nsThebesGfxModuleDtor(nsIModule *self)
|
||||
{
|
||||
nsThebesDeviceContext::Shutdown();
|
||||
gfxPlatform::Shutdown();
|
||||
}
|
||||
|
||||
NS_IMPL_NSGETMODULE_WITH_DTOR(nsGfxModule, components, nsThebesGfxModuleDtor)
|
||||
|
@ -47,6 +47,7 @@ class gfxFontconfigUtils;
|
||||
class NS_EXPORT gfxBeOSPlatform : public gfxPlatform {
|
||||
public:
|
||||
gfxBeOSPlatform();
|
||||
virtual ~gfxBeOSPlatform();
|
||||
|
||||
static gfxBeOSPlatform *GetPlatform() {
|
||||
return (gfxBeOSPlatform*) gfxPlatform::GetPlatform();
|
||||
|
@ -56,6 +56,11 @@ public:
|
||||
*/
|
||||
static gfxPlatform *GetPlatform();
|
||||
|
||||
/**
|
||||
* Clean up static objects to shut down thebes.
|
||||
*/
|
||||
static void Shutdown();
|
||||
|
||||
/**
|
||||
* Return PR_TRUE if we're to use Glitz for acceleration.
|
||||
*/
|
||||
@ -119,7 +124,7 @@ public:
|
||||
|
||||
protected:
|
||||
gfxPlatform() { }
|
||||
virtual ~gfxPlatform() { }
|
||||
virtual ~gfxPlatform();
|
||||
|
||||
};
|
||||
|
||||
|
@ -48,6 +48,7 @@ class gfxFontconfigUtils;
|
||||
class THEBES_API gfxPlatformGtk : public gfxPlatform {
|
||||
public:
|
||||
gfxPlatformGtk();
|
||||
virtual ~gfxPlatformGtk();
|
||||
|
||||
static gfxPlatformGtk *GetPlatform() {
|
||||
return (gfxPlatformGtk*) gfxPlatform::GetPlatform();
|
||||
|
@ -49,6 +49,20 @@ gfxBeOSPlatform::gfxBeOSPlatform()
|
||||
sFontconfigUtils = gfxFontconfigUtils::GetFontconfigUtils();
|
||||
}
|
||||
|
||||
gfxBeOSPlatform::~gfxBeOSPlatform()
|
||||
{
|
||||
gfxFontconfigUtils::Shutdown();
|
||||
sFontconfigUtils = nsnull;
|
||||
|
||||
#if 0
|
||||
// It would be nice to do this (although it might need to be after
|
||||
// the cairo shutdown that happens in ~gfxPlatform). It even looks
|
||||
// idempotent. But it has fatal assertions that fire if stuff is
|
||||
// leaked, and we hit them.
|
||||
FcFini();
|
||||
#endif
|
||||
}
|
||||
|
||||
already_AddRefed<gfxASurface>
|
||||
gfxBeOSPlatform::CreateOffscreenSurface (PRUint32 width,
|
||||
PRUint32 height,
|
||||
|
@ -47,6 +47,8 @@
|
||||
#include "nsIAtom.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
/* static */ gfxFontconfigUtils* gfxFontconfigUtils::sUtils = nsnull;
|
||||
|
||||
gfxFontconfigUtils::gfxFontconfigUtils()
|
||||
{
|
||||
mAliasTable.Init(50);
|
||||
|
@ -55,12 +55,16 @@ public:
|
||||
gfxFontconfigUtils();
|
||||
|
||||
static gfxFontconfigUtils* GetFontconfigUtils() {
|
||||
static gfxFontconfigUtils* sUtils = nsnull;
|
||||
if (!sUtils)
|
||||
sUtils = new gfxFontconfigUtils();
|
||||
return sUtils;
|
||||
}
|
||||
|
||||
static void Shutdown() {
|
||||
delete sUtils;
|
||||
sUtils = nsnull;
|
||||
}
|
||||
|
||||
nsresult GetFontList(const nsACString& aLangGroup,
|
||||
const nsACString& aGenericFamily,
|
||||
nsStringArray& aListOfFonts);
|
||||
@ -72,6 +76,8 @@ public:
|
||||
void *aClosure, PRBool& aAborted);
|
||||
|
||||
protected:
|
||||
static gfxFontconfigUtils* sUtils;
|
||||
|
||||
PRInt32 IsExistingFont(const nsACString& aFontName);
|
||||
nsresult GetResolvedFonts(const nsACString& aName,
|
||||
gfxFontNameList* aResult);
|
||||
|
@ -59,6 +59,8 @@
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
gfxPlatform *gPlatform = nsnull;
|
||||
int gGlitzState = -1;
|
||||
|
||||
@ -82,6 +84,22 @@ gfxPlatform::GetPlatform()
|
||||
return gPlatform;
|
||||
}
|
||||
|
||||
void
|
||||
gfxPlatform::Shutdown()
|
||||
{
|
||||
delete gPlatform;
|
||||
gPlatform = nsnull;
|
||||
}
|
||||
|
||||
gfxPlatform::~gfxPlatform()
|
||||
{
|
||||
// The cairo folks think we should only clean up in debug builds,
|
||||
// but we're generally in the habit of trying to shut down as
|
||||
// cleanly as possible even in production code, so call this
|
||||
// cairo_debug_* function unconditionally.
|
||||
cairo_debug_reset_static_data();
|
||||
}
|
||||
|
||||
PRBool
|
||||
gfxPlatform::UseGlitz()
|
||||
{
|
||||
|
@ -86,6 +86,23 @@ gfxPlatformGtk::gfxPlatformGtk()
|
||||
sFontconfigUtils = gfxFontconfigUtils::GetFontconfigUtils();
|
||||
}
|
||||
|
||||
gfxPlatformGtk::~gfxPlatformGtk()
|
||||
{
|
||||
gfxFontconfigUtils::Shutdown();
|
||||
sFontconfigUtils = nsnull;
|
||||
#ifndef THEBES_USE_PANGO_CAIRO
|
||||
pango_xft_shutdown_display(GDK_DISPLAY(), 0);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// It would be nice to do this (although it might need to be after
|
||||
// the cairo shutdown that happens in ~gfxPlatform). It even looks
|
||||
// idempotent. But it has fatal assertions that fire if stuff is
|
||||
// leaked, and we hit them.
|
||||
FcFini();
|
||||
#endif
|
||||
}
|
||||
|
||||
already_AddRefed<gfxASurface>
|
||||
gfxPlatformGtk::CreateOffscreenSurface(const gfxIntSize& size,
|
||||
gfxASurface::gfxImageFormat imageFormat)
|
||||
|
Loading…
Reference in New Issue
Block a user