зеркало из https://github.com/mozilla/pjs.git
Fix leaks of some arrays on shutdown. Bug 209568, r=bstell, sr=bryner
This commit is contained in:
Родитель
55c04f87d7
Коммит
95cf40c10b
|
@ -37,7 +37,7 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsISupportsArray.idl"
|
||||
#include "nsIArray.idl"
|
||||
|
||||
[noscript, uuid(70406f93-5b53-49a0-b5a7-ebf533bfe59b)]
|
||||
interface nsIFontCatalogEntry : nsISupports
|
||||
|
@ -78,12 +78,12 @@ interface nsITrueTypeFontCatalogEntry : nsIFontCatalogEntry
|
|||
[noscript, uuid(a3057187-c40f-4ffa-9160-2b16482053b1)]
|
||||
interface nsIFontCatalogService : nsISupports
|
||||
{
|
||||
nsISupportsArray getFontCatalogEntries(in ACString familyName,
|
||||
in ACString language,
|
||||
in unsigned short weight,
|
||||
in unsigned short width,
|
||||
in unsigned short slant,
|
||||
in unsigned short spacing);
|
||||
nsIArray getFontCatalogEntries(in ACString familyName,
|
||||
in ACString language,
|
||||
in unsigned short weight,
|
||||
in unsigned short width,
|
||||
in unsigned short slant,
|
||||
in unsigned short spacing);
|
||||
|
||||
// Definition for weight
|
||||
const unsigned short kFCWeightAny = 0;
|
||||
|
|
|
@ -944,7 +944,7 @@ PRBool
|
|||
nsFreeTypeFace::FreeFace(nsHashKey* aKey, void* aData, void* aClosure)
|
||||
{
|
||||
nsFreeTypeFace *face = (nsFreeTypeFace*) aData;
|
||||
delete face;
|
||||
NS_RELEASE(face);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
@ -1037,9 +1037,12 @@ nsFreeTypeGetFaceID(nsFontCatalogEntry *aFce)
|
|||
NS_ASSERTION(face, "memory error while creating nsFreeTypeFace");
|
||||
if (!face)
|
||||
return nsnull;
|
||||
NS_ADDREF(face);
|
||||
nsresult rv = face->Init(aFce);
|
||||
if (NS_FAILED(rv))
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(face);
|
||||
return nsnull;
|
||||
}
|
||||
gFreeTypeFaces->Put(&key, face);
|
||||
}
|
||||
return face;
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
#endif
|
||||
#include "nsFontPSDebug.h"
|
||||
|
||||
#include "nsArray.h"
|
||||
|
||||
extern nsIAtom *gUsersLocale;
|
||||
#define NS_IS_BOLD(weight) ((weight) > 400 ? 1 : 0)
|
||||
|
||||
|
@ -1037,7 +1039,7 @@ nsFontPSFreeType::AddFontEntries(nsACString& aFamilyName, nsACString& aLanguage,
|
|||
nsCOMPtr<nsIFontCatalogService> fcs(do_GetService(kFCSCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsISupportsArray> entryList = nsnull;
|
||||
nsCOMPtr<nsIArray> entryList;
|
||||
rv = fcs->GetFontCatalogEntries(aFamilyName, aLanguage,
|
||||
aWeight, aWidth, aSlant, aSpacing,
|
||||
getter_AddRefs(entryList));
|
||||
|
@ -1046,16 +1048,13 @@ nsFontPSFreeType::AddFontEntries(nsACString& aFamilyName, nsACString& aLanguage,
|
|||
PRUint32 i, count = 0;
|
||||
NS_ENSURE_TRUE(entryList, NS_ERROR_FAILURE);
|
||||
|
||||
rv = entryList->Count(&count);
|
||||
rv = entryList->GetLength(&count);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
ADD_ENTRY_FONTPS_PRINTF((" count = %d", count));
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
nsCOMPtr<nsISupports> item;
|
||||
rv = entryList->GetElementAt(i, getter_AddRefs(item));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsITrueTypeFontCatalogEntry> entry(do_QueryInterface(item, &rv));
|
||||
nsCOMPtr<nsITrueTypeFontCatalogEntry> entry = do_QueryElementAt(entryList,
|
||||
i, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCAutoString fontname, stylename;
|
||||
|
|
|
@ -57,6 +57,7 @@ PRUint32 gFontDebug = 0 | NS_FONT_DEBUG_FONT_SCAN;
|
|||
#include "nsLocalFile.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsITimelineService.h"
|
||||
#include "nsArray.h"
|
||||
|
||||
//
|
||||
// Short overview:
|
||||
|
@ -165,7 +166,7 @@ nsFT2FontCatalog::GetFontCatalogEntries(const nsACString & aFamilyName,
|
|||
PRUint16 aWidth,
|
||||
PRUint16 aSlant,
|
||||
PRUint16 aSpacing,
|
||||
nsISupportsArray **_retval)
|
||||
nsIArray **_retval)
|
||||
{
|
||||
#if (!defined(MOZ_ENABLE_FREETYPE2))
|
||||
*_retval = nsnull;
|
||||
|
@ -183,8 +184,8 @@ nsFT2FontCatalog::GetFontCatalogEntries(const nsACString & aFamilyName,
|
|||
GetFontNames(aFamilyName, aLanguage, aWeight, aWidth, aSlant, aSpacing, fc);
|
||||
nsCOMPtr<nsITrueTypeFontCatalogEntry> aFce;
|
||||
nsCOMPtr<nsISupports> genericFce;
|
||||
nsCOMPtr<nsISupportsArray> entries;
|
||||
NS_NewISupportsArray(getter_AddRefs(entries));
|
||||
nsCOMPtr<nsIMutableArray> entries;
|
||||
NS_NewArray(getter_AddRefs(entries));
|
||||
if (!entries)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -192,7 +193,7 @@ nsFT2FontCatalog::GetFontCatalogEntries(const nsACString & aFamilyName,
|
|||
for (i = 0; i < fc->numFonts; i++) {
|
||||
aFce = nsFreeTypeGetFaceID(fc->fonts[i]);
|
||||
genericFce = do_QueryInterface(aFce);
|
||||
entries->InsertElementAt(genericFce, 0);
|
||||
entries->InsertElementAt(genericFce, 0, PR_FALSE);
|
||||
}
|
||||
|
||||
free(fc->fonts);
|
||||
|
|
|
@ -61,6 +61,7 @@ void nsFT2FontNode::GetFontNames(const char* aPattern,
|
|||
#include "nsFreeType.h"
|
||||
#include "nsFontFreeType.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsArray.h"
|
||||
|
||||
nsHashtable* nsFT2FontNode::mFreeTypeNodes = nsnull;
|
||||
PRBool nsFT2FontNode::sInited = PR_FALSE;
|
||||
|
@ -116,7 +117,7 @@ nsFT2FontNode::GetFontNames(const char* aPattern, nsFontNodeArray* aNodes)
|
|||
char *pattern, *foundry, *family, *charset, *encoding;
|
||||
const char *charSetName;
|
||||
nsFontNode *node;
|
||||
nsISupportsArray* arrayFC;
|
||||
nsCOMPtr<nsIArray> arrayFC;
|
||||
nsCAutoString familyTmp, languageTmp;
|
||||
|
||||
FONT_CATALOG_PRINTF(("looking for FreeType font matching %s", aPattern));
|
||||
|
@ -139,13 +140,13 @@ nsFT2FontNode::GetFontNames(const char* aPattern, nsFontNodeArray* aNodes)
|
|||
if (family)
|
||||
familyTmp.Assign(family);
|
||||
|
||||
sFcs->GetFontCatalogEntries(familyTmp, languageTmp, 0, 0, 0, 0, &arrayFC);
|
||||
sFcs->GetFontCatalogEntries(familyTmp, languageTmp, 0, 0, 0, 0,
|
||||
getter_AddRefs(arrayFC));
|
||||
if (!arrayFC)
|
||||
goto cleanup_and_return;
|
||||
arrayFC->Count(&count);
|
||||
arrayFC->GetLength(&count);
|
||||
for (i = 0; i < count; i++) {
|
||||
nsISupports* item = (nsISupports*)arrayFC->ElementAt(i);
|
||||
nsCOMPtr<nsITrueTypeFontCatalogEntry> fce = do_QueryInterface(item);
|
||||
nsCOMPtr<nsITrueTypeFontCatalogEntry> fce = do_QueryElementAt(arrayFC, i);
|
||||
if (!fce)
|
||||
continue;
|
||||
nsCAutoString foundryName, familyName;
|
||||
|
@ -297,17 +298,17 @@ PRBool
|
|||
nsFT2FontNode::LoadNodeTable()
|
||||
{
|
||||
int j;
|
||||
nsISupportsArray* arrayFC;
|
||||
nsCOMPtr<nsIArray> arrayFC;
|
||||
nsCAutoString family, language;
|
||||
sFcs->GetFontCatalogEntries(family, language, 0, 0, 0, 0, &arrayFC);
|
||||
sFcs->GetFontCatalogEntries(family, language, 0, 0, 0, 0,
|
||||
getter_AddRefs(arrayFC));
|
||||
if (!arrayFC)
|
||||
return PR_FALSE;
|
||||
PRUint32 count, i;
|
||||
arrayFC->Count(&count);
|
||||
arrayFC->GetLength(&count);
|
||||
for (i = 0; i < count; i++) {
|
||||
nsISupports* item = (nsISupports*)arrayFC->ElementAt(i);
|
||||
const char *charsetName;
|
||||
nsCOMPtr<nsITrueTypeFontCatalogEntry> fce = do_QueryInterface(item);
|
||||
nsCOMPtr<nsITrueTypeFontCatalogEntry> fce = do_QueryElementAt(arrayFC, i);
|
||||
if (!fce)
|
||||
continue;
|
||||
PRUint32 flags, codePageRange1, codePageRange2;
|
||||
|
|
Загрузка…
Ссылка в новой задаче