From 3367bf06715e98c49470b4f7973f43274ac3578d Mon Sep 17 00:00:00 2001 From: "mscott%netscape.com" Date: Tue, 30 Mar 1999 00:34:12 +0000 Subject: [PATCH] Move the code to register the app core into the app cores manager from the constructor of the app core into the init function of the app core. Why? nsIAppCoresManager::Add requires that the app core have an id. The id doesn't get assigned until the app core gets initialized. a=mcmullen, rod spears --- xpfe/AppCores/src/nsBaseAppCore.cpp | 38 ++++++++++++++++------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/xpfe/AppCores/src/nsBaseAppCore.cpp b/xpfe/AppCores/src/nsBaseAppCore.cpp index 7abc0200f83..c7b04f5344b 100644 --- a/xpfe/AppCores/src/nsBaseAppCore.cpp +++ b/xpfe/AppCores/src/nsBaseAppCore.cpp @@ -48,23 +48,6 @@ nsBaseAppCore::nsBaseAppCore() { IncInstanceCount(); NS_INIT_REFCNT(); - -#ifdef NS_DEBUG - printf("Adding app core to AppCoreManager in the base constructor.\n"); -#endif - nsIDOMAppCoresManager * appCoreManager; - nsresult rv = nsServiceManager::GetService( - kAppCoresManagerCID, - kIDOMAppCoresManagerIID, - (nsISupports**)&appCoreManager); - if (NS_FAILED(rv)) - return; - rv = appCoreManager->Add((nsIDOMBaseAppCore *)this); -#ifdef NS_DEBUG - if (NS_FAILED(rv)) - printf("...failed!\n"); -#endif - nsServiceManager::ReleaseService(kAppCoresManagerCID, appCoreManager); } nsBaseAppCore::~nsBaseAppCore() @@ -127,6 +110,27 @@ NS_IMETHODIMP nsBaseAppCore::Init(const nsString& aId) { mId = aId; + + // this used to be in the constructor of the base class, but + // nsIAppCoreManager::Add requires that the app core being added + // has a id. So we can't do it until the app core has been initialized + +#ifdef NS_DEBUG + printf("Adding app core to AppCoreManager in the base initialization.\n"); +#endif + nsIDOMAppCoresManager * appCoreManager; + nsresult rv = nsServiceManager::GetService( + kAppCoresManagerCID, + kIDOMAppCoresManagerIID, + (nsISupports**)&appCoreManager); + if (NS_FAILED(rv)) + return rv; + rv = appCoreManager->Add((nsIDOMBaseAppCore *)this); +#ifdef NS_DEBUG + if (NS_FAILED(rv)) + printf("...failed!\n"); +#endif + nsServiceManager::ReleaseService(kAppCoresManagerCID, appCoreManager); return NS_OK; }