From 44271bfecef4e49577886e7b8dd4afa0c1ad3ebc Mon Sep 17 00:00:00 2001 From: "scc%netscape.com" Date: Tue, 21 Sep 1999 21:10:22 +0000 Subject: [PATCH] take action to prevent re-entering the destructor git-svn-id: svn://10.0.0.236/trunk@48618 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/uriloader/base/nsDocLoader.cpp | 11 +++++++++++ mozilla/webshell/src/nsDocLoader.cpp | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/mozilla/uriloader/base/nsDocLoader.cpp b/mozilla/uriloader/base/nsDocLoader.cpp index 478933f78a4..70ef4e0e783 100644 --- a/mozilla/uriloader/base/nsDocLoader.cpp +++ b/mozilla/uriloader/base/nsDocLoader.cpp @@ -352,6 +352,17 @@ nsDocLoaderImpl::Init() nsDocLoaderImpl::~nsDocLoaderImpl() { + /* + |ClearWeakReferences()| here is intended to prevent people holding weak references + from re-entering this destructor since |QueryReferent()| will |AddRef()| me, and the + subsequent |Release()| will try to destroy me. At this point there should be only + weak references remaining (otherwise, we wouldn't be getting destroyed). + + An alternative would be incrementing our refcount (consider it a compressed flag + saying "Don't re-destroy."). I haven't yet decided which is better. [scc] + */ + ClearWeakReferences(); + Destroy(); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, diff --git a/mozilla/webshell/src/nsDocLoader.cpp b/mozilla/webshell/src/nsDocLoader.cpp index 478933f78a4..70ef4e0e783 100644 --- a/mozilla/webshell/src/nsDocLoader.cpp +++ b/mozilla/webshell/src/nsDocLoader.cpp @@ -352,6 +352,17 @@ nsDocLoaderImpl::Init() nsDocLoaderImpl::~nsDocLoaderImpl() { + /* + |ClearWeakReferences()| here is intended to prevent people holding weak references + from re-entering this destructor since |QueryReferent()| will |AddRef()| me, and the + subsequent |Release()| will try to destroy me. At this point there should be only + weak references remaining (otherwise, we wouldn't be getting destroyed). + + An alternative would be incrementing our refcount (consider it a compressed flag + saying "Don't re-destroy."). I haven't yet decided which is better. [scc] + */ + ClearWeakReferences(); + Destroy(); PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,