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

This commit is contained in:
mscott%netscape.com 1999-03-30 00:34:12 +00:00
Родитель be1ef22ce3
Коммит 3367bf0671
1 изменённых файлов: 21 добавлений и 17 удалений

Просмотреть файл

@ -48,23 +48,6 @@ nsBaseAppCore::nsBaseAppCore()
{ {
IncInstanceCount(); IncInstanceCount();
NS_INIT_REFCNT(); 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() nsBaseAppCore::~nsBaseAppCore()
@ -127,6 +110,27 @@ NS_IMETHODIMP
nsBaseAppCore::Init(const nsString& aId) nsBaseAppCore::Init(const nsString& aId)
{ {
mId = 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; return NS_OK;
} }