b=454735 Make gfxFont more tolerant to shutdown of the gfxFontCache r=roc

This commit is contained in:
Karl Tomlinson 2008-09-22 08:41:40 +12:00
parent cc1a3203b5
commit fb0d6fc718

View File

@ -454,9 +454,8 @@ public:
--mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "gfxFont");
if (mRefCnt == 0) {
// Don't delete just yet; return the object to the cache for
// possibly recycling within some time limit
gfxFontCache::GetCache()->NotifyReleased(this);
NotifyReleased();
// |this| may have been deleted.
return 0;
}
return mRefCnt;
@ -467,8 +466,21 @@ public:
protected:
nsAutoRefCnt mRefCnt;
public:
void NotifyReleased() {
gfxFontCache *cache = gfxFontCache::GetCache();
if (cache) {
// Don't delete just yet; return the object to the cache for
// possibly recycling within some time limit
cache->NotifyReleased(this);
} else {
// The cache may have already been shut down.
delete this;
}
}
gfxFont(gfxFontEntry *aFontEntry, const gfxFontStyle *aFontStyle);
public:
virtual ~gfxFont();
const nsString& GetName() const { return mFontEntry->Name(); }
@ -637,7 +649,6 @@ public:
protected:
nsRefPtr<gfxFontEntry> mFontEntry;
// The family name of the font
PRPackedBool mIsValid;
nsExpirationState mExpirationState;
gfxFontStyle mStyle;
@ -1480,9 +1491,10 @@ private:
};
class THEBES_API gfxFontGroup : public gfxTextRunFactory {
public:
protected:
gfxFontGroup(const nsAString& aFamilies, const gfxFontStyle *aStyle);
public:
virtual ~gfxFontGroup() {
mFonts.Clear();
}