зеркало из https://github.com/mozilla/pjs.git
fix leak of nsIPref Service
This commit is contained in:
Родитель
a2827c5018
Коммит
90cb21d54f
|
@ -34,6 +34,9 @@ static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
|||
nsUnicodeMappingUtil *nsUnicodeMappingUtil::gSingleton = nsnull;
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
static nsIPref* gPref = nsnull;
|
||||
static int gUnicodeMappingUtilCount = 0;
|
||||
|
||||
nsUnicodeMappingUtil::nsUnicodeMappingUtil()
|
||||
{
|
||||
InitScriptEnabled();
|
||||
|
@ -42,6 +45,7 @@ nsUnicodeMappingUtil::nsUnicodeMappingUtil()
|
|||
InitScriptFontMapping();
|
||||
InitBlockToScriptMapping(); // this must be called after InitScriptEnabled()
|
||||
gCache = new nsUnicodeFontMappingCache();
|
||||
++gUnicodeMappingUtilCount;
|
||||
}
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
|
@ -55,6 +59,9 @@ nsUnicodeMappingUtil::~nsUnicodeMappingUtil()
|
|||
}
|
||||
if(gCache)
|
||||
delete gCache;
|
||||
|
||||
if(0 == --gUnicodeMappingUtilCount)
|
||||
NS_IF_RELEASE(gPref);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
@ -223,7 +230,6 @@ ScriptCode nsUnicodeMappingUtil::MapLangGroupToScriptCode(const char* aLangGroup
|
|||
return smRoman;
|
||||
}
|
||||
}
|
||||
static nsIPref* gPref = nsnull;
|
||||
|
||||
#define FACESIZE 255 // font name is Str255 in Mac script code
|
||||
void
|
||||
|
|
|
@ -64,10 +64,15 @@ PLHashTable* nsFontMetricsWin::gFontWeights = nsnull;
|
|||
#undef CHAR_BUFFER_SIZE
|
||||
#define CHAR_BUFFER_SIZE 1024
|
||||
|
||||
static nsIPref* gPref = nsnull;
|
||||
|
||||
static int gFontMetricsWinCount = 0;
|
||||
|
||||
nsFontMetricsWin :: nsFontMetricsWin()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mSpaceWidth = 0;
|
||||
++gFontMetricsWinCount;
|
||||
}
|
||||
|
||||
nsFontMetricsWin :: ~nsFontMetricsWin()
|
||||
|
@ -101,6 +106,11 @@ nsFontMetricsWin :: ~nsFontMetricsWin()
|
|||
delete mGeneric;
|
||||
mGeneric = nsnull;
|
||||
}
|
||||
|
||||
if (0 == --gFontMetricsWinCount) {
|
||||
NS_IF_RELEASE(gPref);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef LEAK_DEBUG
|
||||
|
@ -2293,8 +2303,6 @@ typedef struct PrefEnumInfo
|
|||
nsFontMetricsWin* mMetrics;
|
||||
} PrefEnumInfo;
|
||||
|
||||
static nsIPref* gPref = nsnull;
|
||||
|
||||
void
|
||||
PrefEnumCallback(const char* aName, void* aClosure)
|
||||
{
|
||||
|
|
|
@ -48,6 +48,9 @@ static PRLogModuleInfo * FontMetricsXlibLM = PR_NewLogModule("FontMetricsXlib");
|
|||
|
||||
static Display *gDisplay = NULL;
|
||||
|
||||
static int gFontMetricsXlibCount = 0;
|
||||
static nsIPref* gPref = nsnull;
|
||||
|
||||
nsFontMetricsXlib::nsFontMetricsXlib()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
@ -72,6 +75,8 @@ nsFontMetricsXlib::nsFontMetricsXlib()
|
|||
mUnderlineSize = 0;
|
||||
mUnderlineOffset = 0;
|
||||
mSpaceWidth = 0;
|
||||
|
||||
gFontMetricsXlibCount++;
|
||||
}
|
||||
|
||||
nsFontMetricsXlib::~nsFontMetricsXlib()
|
||||
|
@ -105,6 +110,9 @@ nsFontMetricsXlib::~nsFontMetricsXlib()
|
|||
|
||||
#endif
|
||||
|
||||
if (0 == --gFontMetricsXlibCount) {
|
||||
NS_IF_RELEASE(gPref);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsFontMetricsXlib, kIFontMetricsIID)
|
||||
|
@ -2277,8 +2285,6 @@ FindFamily(nsFontSearch* aSearch, nsString* aName)
|
|||
TryFamily(aSearch, family);
|
||||
}
|
||||
|
||||
static nsIPref* gPref = nsnull;
|
||||
|
||||
static void
|
||||
PrefEnumCallback(const char* aName, void* aClosure)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче