From a83bd3ab926a2d4018e8dcb2c13be754e73c58bb Mon Sep 17 00:00:00 2001 From: "attinasi%netscape.com" Date: Tue, 26 Feb 2002 00:13:49 +0000 Subject: [PATCH] Safety checks, in case the normalFont cannot be realized (due to system font exhaustion). b=117736 r=rbs sr=shaver a=asa git-svn-id: svn://10.0.0.236/trunk@115334 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsTextFrame.cpp | 16 +++++++++++++--- mozilla/layout/html/base/src/nsTextFrame.cpp | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index d622e1fdaf9..c3ab4be0cb8 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -634,7 +634,7 @@ public: } ~TextStyle() { - NS_RELEASE(mNormalFont); + NS_IF_RELEASE(mNormalFont); NS_IF_RELEASE(mSmallFont); mFont = nsnull; @@ -4558,8 +4558,18 @@ nsTextFrame::MeasureText(nsIPresContext* aPresContext, aTextData.mX = 0; if (aTextData.mMeasureText) { - aTs.mNormalFont->GetMaxAscent(aTextData.mAscent); - aTs.mNormalFont->GetMaxDescent(aTextData.mDescent); + // NOTE: in some cases, when font resources are exhausted, we end up with no normal font. + // This will cause a crash because we are not handling it at the source and everyplace else + // assumes the normal font is non-null. + // This bit of ASSERTION / Runtime checking is to prevent the crash, but is only wallpaper. + // We need to handle the problem when the font is being realized - currently that just throws + // an assertion and we continue on. + // See bug 117736 + NS_ASSERTION(aTs.mNormalFont, "null normal font, probably ran out of font resources"); + if (aTs.mNormalFont) { + aTs.mNormalFont->GetMaxAscent(aTextData.mAscent); + aTs.mNormalFont->GetMaxDescent(aTextData.mDescent); + } } for (;;firstThing = PR_FALSE) { #ifdef IBMBIDI diff --git a/mozilla/layout/html/base/src/nsTextFrame.cpp b/mozilla/layout/html/base/src/nsTextFrame.cpp index d622e1fdaf9..c3ab4be0cb8 100644 --- a/mozilla/layout/html/base/src/nsTextFrame.cpp +++ b/mozilla/layout/html/base/src/nsTextFrame.cpp @@ -634,7 +634,7 @@ public: } ~TextStyle() { - NS_RELEASE(mNormalFont); + NS_IF_RELEASE(mNormalFont); NS_IF_RELEASE(mSmallFont); mFont = nsnull; @@ -4558,8 +4558,18 @@ nsTextFrame::MeasureText(nsIPresContext* aPresContext, aTextData.mX = 0; if (aTextData.mMeasureText) { - aTs.mNormalFont->GetMaxAscent(aTextData.mAscent); - aTs.mNormalFont->GetMaxDescent(aTextData.mDescent); + // NOTE: in some cases, when font resources are exhausted, we end up with no normal font. + // This will cause a crash because we are not handling it at the source and everyplace else + // assumes the normal font is non-null. + // This bit of ASSERTION / Runtime checking is to prevent the crash, but is only wallpaper. + // We need to handle the problem when the font is being realized - currently that just throws + // an assertion and we continue on. + // See bug 117736 + NS_ASSERTION(aTs.mNormalFont, "null normal font, probably ran out of font resources"); + if (aTs.mNormalFont) { + aTs.mNormalFont->GetMaxAscent(aTextData.mAscent); + aTs.mNormalFont->GetMaxDescent(aTextData.mDescent); + } } for (;;firstThing = PR_FALSE) { #ifdef IBMBIDI