Closed Bug 40992 Opened 26 years ago Closed 24 years ago

Add function to test if XPCom is currently initted

Categories

(Core :: XPCOM, enhancement, P3)

x86
Linux
enhancement

Tracking

()

RESOLVED WONTFIX

People

(Reporter: madams, Assigned: dougt)

References

Details

(Keywords: topembed+)

This patch adds a NS_XPCOMInitted() function which returns NS_OK if xpcom has been initted, and NS_ERROR_NOT_INITIALIZED otherwise. This is useful if there are a few different places in a product which use XPCom and need to verify if xpcom has been started or has already been shut down. ------------------------------------------------------------------------- Index: xpcom/components/nsIServiceManager.h =================================================================== RCS file: /cvsroot/mozilla/xpcom/components/nsIServiceManager.h,v retrieving revision 1.35 diff -u -r1.35 nsIServiceManager.h --- xpcom/components/nsIServiceManager.h 2000/05/20 18:55:35 1.35 +++ xpcom/components/nsIServiceManager.h 2000/05/30 12:52:34 @@ -379,6 +379,14 @@ extern NS_COM nsresult NS_ShutdownXPCOM(nsIServiceManager* servMgr); + +//////////////////////////////////////////////////////////////////////////////// +// Test method to see if XPCOM is currently initted. If so, returns NS_OK. +// Otherwise, returns NS_ERROR_NOT_INITIALIZED. +extern nsresult NS_COM +NS_XPCOMInitted(); + + //////////////////////////////////////////////////////////////////////////////// // Observing xpcom shutdown Index: xpcom/build/nsXPComInit.cpp =================================================================== RCS file: /cvsroot/mozilla/xpcom/build/nsXPComInit.cpp,v retrieving revision 1.68 diff -u -r1.68 nsXPComInit.cpp --- xpcom/build/nsXPComInit.cpp 2000/05/13 23:34:11 1.68 +++ xpcom/build/nsXPComInit.cpp 2000/05/30 12:53:47 @@ -189,6 +189,15 @@ extern nsIServiceManager* gServiceManager; extern PRBool gShuttingDown; +nsresult NS_COM NS_XPCOMInitted() +{ + if( gServiceManager != NULL ) { + return NS_OK; + } + return NS_ERROR_NOT_INITIALIZED; +} + + nsresult NS_COM NS_InitXPCOM(nsIServiceManager* *result, nsIFile* binDirectory )
You might want to use an else before returning NS_ERROR_NOT_INITIALIZED, but other than that, patch looks good to me
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: patch
Moving all current open XPCOM and XPCOM Registry bugs to rayw since dp is on sabbatical. rayw is now default assignee for these components.
Assignee: dp → rayw
Status: NEW → ASSIGNED
Target Milestone: --- → M20
Edward: Welcome to xpcom!
Status: ASSIGNED → NEW
QA Contact: leger → rayw
Target Milestone: M20 → mozilla1.0
Assigning rest of xpcom stuff to myself (from Ray).
Assignee: rayw → warren
reasigning warren bugs to default component owners.
Assignee: warren → kandrot
QA Contact: rayw → scc
Target Milestone: mozilla1.0 → ---
reassign all kandrot xpcom bug.
Assignee: kandrot → dougt
Blocks: 98283
No. this is not a good way to fix the xpcom reentrancy problem. You should be able to call InitXPCOM as many times as you like as long as it is paired with a shutdown. Of course reentrancy is not there yet, but still, this function should not be exposed.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → WONTFIX
Keywords: topembed+
You need to log in before you can comment on or make changes to this bug.