Closed
Bug 370265
Opened 18 years ago
Closed 18 years ago
nsDOMScriptObjectHolder/NS_DropScriptObject tries to get service while shutting down
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
People
(Reporter: peterv, Assigned: peterv)
References
Details
Attachments
(1 file)
(deleted),
patch
|
jst
:
review+
jst
:
superreview+
|
Details | Diff | Splinter Review |
NS_DropScriptObject tries to get the DOMScriptObjectFactory to get the language runtime to drop the script object. This can happen during shutdown when getting that service fails and so we don't drop the script object. We should probably do something like sScriptRuntime/sScriptRootCount in nsContentUtils, ie cache the runtime for as long as we have script objects to drop.
Assignee | ||
Comment 1•18 years ago
|
||
Assignee | ||
Updated•18 years ago
|
Attachment #254937 -
Flags: review?(mhammond)
Assignee | ||
Comment 3•18 years ago
|
||
Comment on attachment 254937 [details] [diff] [review]
v1
Jst, maybe you can r/sr this?
Attachment #254937 -
Flags: superreview?(jst)
Comment 4•18 years ago
|
||
Comment on attachment 254937 [details] [diff] [review]
v1
>Index: content/base/public/nsContentUtils.h
>===================================================================
>RCS file: /Users/peterv/source/cvs.mozilla.org/cvsroot/mozilla/content/base/public/nsContentUtils.h,v
>retrieving revision 1.117
>diff -u -p -r1.117 nsContentUtils.h
>--- content/base/public/nsContentUtils.h 1 Feb 2007 15:13:58 -0000 1.117
>+++ content/base/public/nsContentUtils.h 12 Feb 2007 21:34:37 -0000
>@@ -52,6 +52,8 @@
> #include "nsDOMClassInfoID.h"
> #include "nsIClassInfo.h"
> #include "nsIDOM3Node.h"
>+#include "nsIScriptRuntime.h"
>+#include "nsIScriptGlobalObject.h"
>
> class nsIDOMScriptObjectFactory;
> class nsIXPConnect;
>@@ -84,7 +86,6 @@ class nsIWordBreaker;
> class nsIJSRuntimeService;
> class nsIEventListenerManager;
> class nsIScriptContext;
>-class nsIScriptGlobalObject;
> template<class E> class nsCOMArray;
> class nsIPref;
> class nsVoidArray;
>@@ -953,6 +954,32 @@ public:
> }
> }
>
>+ static nsresult HoldScriptObject(PRUint32 aLangID, void *aObject);
>+ static nsresult DropScriptObject(PRUint32 aLangID, void *aObject);
>+
>+ class ScriptObjectHolder
>+ {
>+ public:
>+ ScriptObjectHolder(PRUint32 aLangID) : mLangID(aLangID),
>+ mObject(nsnull)
>+ {
>+ }
>+ ~ScriptObjectHolder()
>+ {
>+ DropScriptObject(mLangID, mObject);
>+ }
>+ nsresult set(void *aObject)
>+ {
>+ nsresult rv = HoldScriptObject(mLangID, aObject);
>+ if (NS_SUCCEEDED(rv)) {
>+ mObject = aObject;
>+ }
>+ return rv;
>+ }
>+ PRUint32 mLangID;
>+ void *mObject;
>+ };
>+
> private:
> static nsresult doReparentContentWrapper(nsIContent *aChild,
> JSContext *cx,
>@@ -963,6 +990,8 @@ private:
>
> static nsresult EnsureStringBundle(PropertiesFile aFile);
>
>+ static nsIDOMScriptObjectFactory *GetDOMScriptObjectFactory();
>+
> static nsIDOMScriptObjectFactory *sDOMScriptObjectFactory;
>
> static nsIXPConnect *sXPConnect;
>@@ -1004,8 +1033,11 @@ private:
> // For now, we don't want to automatically clean this up in Shutdown(), since
> // consumers might unfortunately end up wanting to use it after that
> static nsIJSRuntimeService* sJSRuntimeService;
>- static JSRuntime* sScriptRuntime;
>- static PRInt32 sScriptRootCount;
>+ static JSRuntime* sJSScriptRuntime;
>+ static PRInt32 sJSScriptRootCount;
>+
>+ static nsIScriptRuntime* sScriptRuntimes[NS_STID_ARRAY_UBOUND];
>+ static PRInt32 sScriptRootCount[NS_STID_ARRAY_UBOUND];
>
> #ifdef IBMBIDI
> static nsIBidiKeyboard* sBidiKeyboard;
>Index: content/base/src/nsContentUtils.cpp
>===================================================================
>RCS file: /Users/peterv/source/cvs.mozilla.org/cvsroot/mozilla/content/base/src/nsContentUtils.cpp,v
>retrieving revision 1.200
>diff -u -p -r1.200 nsContentUtils.cpp
>--- content/base/src/nsContentUtils.cpp 30 Jan 2007 06:25:07 -0000 1.200
>+++ content/base/src/nsContentUtils.cpp 12 Feb 2007 20:55:15 -0000
>@@ -173,8 +173,10 @@ nsILineBreaker *nsContentUtils::sLineBre
> nsIWordBreaker *nsContentUtils::sWordBreaker;
> nsVoidArray *nsContentUtils::sPtrsToPtrsToRelease;
> nsIJSRuntimeService *nsContentUtils::sJSRuntimeService;
>-JSRuntime *nsContentUtils::sScriptRuntime;
>-PRInt32 nsContentUtils::sScriptRootCount = 0;
>+JSRuntime *nsContentUtils::sJSScriptRuntime;
>+PRInt32 nsContentUtils::sJSScriptRootCount = 0;
>+nsIScriptRuntime *nsContentUtils::sScriptRuntimes[NS_STID_ARRAY_UBOUND];
>+PRInt32 nsContentUtils::sScriptRootCount[NS_STID_ARRAY_UBOUND];
> #ifdef IBMBIDI
> nsIBidiKeyboard *nsContentUtils::sBidiKeyboard = nsnull;
> #endif
>@@ -223,12 +225,6 @@ EventListenerManagerHashClearEntry(PLDHa
> lm->~EventListenerManagerMapEntry();
> }
>
>-PR_STATIC_CALLBACK(void)
>-NopClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry)
>-{
>- // Do nothing
>-}
>-
> // static
> nsresult
> nsContentUtils::Init()
>@@ -596,18 +592,9 @@ nsContentUtils::Shutdown()
> nsISupports *
In nsContentUtils::GetClassInfoInstance(nsDOMClassInfoID aID):
+ nsIDOMScriptObjectFactory *factory = GetDOMScriptObjectFactory();
- return sDOMScriptObjectFactory->GetClassInfoInstance(aID);
+ return factory ? factory->GetClassInfoInstance(aID) : nsnull;
Wouldn't it be cool if the DOM script object factory had a static method for this (and every other place where we call GetDOMScriptObjectFactory() for that matter) so that we wouldn't need to check if the factory exists (duh) and call through virtual functions?
r+sr=jst either way.
Attachment #254937 -
Flags: superreview?(jst)
Attachment #254937 -
Flags: superreview+
Attachment #254937 -
Flags: review?(mhammond)
Attachment #254937 -
Flags: review+
Assignee | ||
Comment 5•18 years ago
|
||
I'll file a bug on the GetClassInfoInstance stuff.
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•