Fixing bug 131841. Don't make calls on weak XPCOM (nsIPresShell in this case) pointers since the objects might go away during the call, this lead to a crash in this particular case. r=sicking@bigfoot.com, sr=vidur@netscape.com, brendan@mozilla.org

git-svn-id: svn://10.0.0.236/trunk@121802 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jst%netscape.com
2002-05-18 00:02:50 +00:00
parent 0a83abb080
commit 9dc48e1db8
4 changed files with 105 additions and 74 deletions

View File

@@ -1353,8 +1353,8 @@ nsHTMLDocument::SetDTDMode(nsDTDMode aMode)
if (mCSSLoader) {
mCSSLoader->SetQuirkMode(PRBool(eDTDMode_strict!= mDTDMode));
}
nsIPresShell* shell = (nsIPresShell*) mPresShells.SafeElementAt(0);
if (nsnull != shell) {
nsCOMPtr<nsIPresShell> shell = (nsIPresShell*)mPresShells.SafeElementAt(0);
if (shell) {
nsCOMPtr<nsIPresContext> pc;
shell->GetPresContext(getter_AddRefs(pc));
if (pc) {
@@ -1523,7 +1523,9 @@ nsHTMLDocument::FlushPendingNotifications(PRBool aFlushReflows,
if (aFlushReflows) {
PRInt32 i = 0, n = mPresShells.Count();
while ((i < n) && (isSafeToFlush)) {
nsIPresShell* shell = NS_STATIC_CAST(nsIPresShell*, mPresShells[i]);
nsCOMPtr<nsIPresShell> shell =
NS_STATIC_CAST(nsIPresShell*, mPresShells[i]);
if (shell) {
shell->IsSafeToFlush(isSafeToFlush);
}
@@ -2443,7 +2445,7 @@ nsHTMLDocument::OpenCommon(nsIURI* aSourceURL)
nsCOMPtr<nsIWebShell> webShell;
// Get the webshell of our primary presentation shell
nsIPresShell* shell = (nsIPresShell*) mPresShells.SafeElementAt(0);
nsCOMPtr<nsIPresShell> shell = (nsIPresShell*)mPresShells.SafeElementAt(0);
if (shell) {
nsCOMPtr<nsIPresContext> cx;
shell->GetPresContext(getter_AddRefs(cx));
@@ -3253,7 +3255,7 @@ nsHTMLDocument::GetSelection(nsAString& aReturn)
consoleService->LogStringMessage(NS_LITERAL_STRING("Deprecated method document.getSelection() called. Please use window.getSelection() instead.").get());
}
nsIPresShell* shell = (nsIPresShell*)mPresShells.SafeElementAt(0);
nsCOMPtr<nsIPresShell> shell = (nsIPresShell*)mPresShells.SafeElementAt(0);
if (!shell) {
return NS_OK;