diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index f70c9949b01..09a2d6f6e96 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -3014,6 +3014,11 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, rv = channel->GetURI(getter_AddRefs(aURL)); if (NS_FAILED(rv)) return rv; + /* one of many safeguards that prevent death and destruction if + someone is so very very rude as to bring this window down + during this load handler. */ + nsCOMPtr kungFuDeathGrip(this); + //if (!mProcessedEndDocumentLoad) { if (loader == mDocLoader) { mProcessedEndDocumentLoad = PR_TRUE; diff --git a/mozilla/uriloader/base/nsDocLoader.cpp b/mozilla/uriloader/base/nsDocLoader.cpp index 2e567165e6d..3c5dc12e8a6 100644 --- a/mozilla/uriloader/base/nsDocLoader.cpp +++ b/mozilla/uriloader/base/nsDocLoader.cpp @@ -960,6 +960,11 @@ void nsDocLoaderImpl::DocLoaderIsEmpty(nsresult aStatus) { if (mIsLoadingDocument) { PRBool busy = PR_FALSE; + /* In the unimagineably rude circumstance that onload event handlers + triggered by this function actually kill the window ... ok, it's + not unimagineable; it's happened ... this deathgrip keeps this object + alive long enough to survive this function call. */ + nsCOMPtr kungFuDeathGrip(this); IsBusy(busy); if (!busy) { diff --git a/mozilla/webshell/src/nsDocLoader.cpp b/mozilla/webshell/src/nsDocLoader.cpp index 2e567165e6d..3c5dc12e8a6 100644 --- a/mozilla/webshell/src/nsDocLoader.cpp +++ b/mozilla/webshell/src/nsDocLoader.cpp @@ -960,6 +960,11 @@ void nsDocLoaderImpl::DocLoaderIsEmpty(nsresult aStatus) { if (mIsLoadingDocument) { PRBool busy = PR_FALSE; + /* In the unimagineably rude circumstance that onload event handlers + triggered by this function actually kill the window ... ok, it's + not unimagineable; it's happened ... this deathgrip keeps this object + alive long enough to survive this function call. */ + nsCOMPtr kungFuDeathGrip(this); IsBusy(busy); if (!busy) { diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index f70c9949b01..09a2d6f6e96 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -3014,6 +3014,11 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, rv = channel->GetURI(getter_AddRefs(aURL)); if (NS_FAILED(rv)) return rv; + /* one of many safeguards that prevent death and destruction if + someone is so very very rude as to bring this window down + during this load handler. */ + nsCOMPtr kungFuDeathGrip(this); + //if (!mProcessedEndDocumentLoad) { if (loader == mDocLoader) { mProcessedEndDocumentLoad = PR_TRUE;