fix for bug 115152, lots of service-manager warnings on exit. r=nhotta, sr=darin
This commit is contained in:
Родитель
332ffd40b2
Коммит
9b8cd4a627
|
@ -395,6 +395,8 @@ NS_IMETHODIMP nsMetaCharsetObserver::Observe(nsISupports *aSubject,
|
|||
nsresult rv = NS_OK;
|
||||
if (!nsCRT::strcmp(aTopic, APPSTARTUP_CATEGORY))
|
||||
rv = Start();
|
||||
else if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID))
|
||||
rv = End();
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -406,6 +408,10 @@ NS_IMETHODIMP nsMetaCharsetObserver::Start()
|
|||
if (bMetaCharsetObserverStarted == PR_FALSE) {
|
||||
bMetaCharsetObserverStarted = PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = do_GetService("@mozilla.org/observer-service;1", &res);
|
||||
if (NS_SUCCEEDED(res))
|
||||
obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIParserService> parserService(do_GetService(kParserServiceCID));
|
||||
|
||||
if (!parserService) {
|
||||
|
|
|
@ -74,6 +74,7 @@ static NS_DEFINE_CID(kDNSServiceCID, NS_DNSSERVICE_CID);
|
|||
static NS_DEFINE_CID(kErrorServiceCID, NS_ERRORSERVICE_CID);
|
||||
static NS_DEFINE_CID(kProtocolProxyServiceCID, NS_PROTOCOLPROXYSERVICE_CID);
|
||||
static NS_DEFINE_CID(kStdURLParserCID, NS_STDURLPARSER_CID);
|
||||
static NS_DEFINE_CID(kNoAuthParserCID, NS_NOAUTHURLPARSER_CID);
|
||||
|
||||
// A general port blacklist. Connections to these ports will not be avoided unless
|
||||
// the protocol overrides.
|
||||
|
@ -230,6 +231,7 @@ nsIOService::Init()
|
|||
do_GetService("@mozilla.org/observer-service;1");
|
||||
NS_ASSERTION(observerService, "Failed to get observer service");
|
||||
if (observerService) {
|
||||
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE);
|
||||
observerService->AddObserver(this, kProfileChangeNetTeardownTopic, PR_TRUE);
|
||||
observerService->AddObserver(this, kProfileChangeNetRestoreTopic, PR_TRUE);
|
||||
}
|
||||
|
@ -247,7 +249,6 @@ nsIOService::~nsIOService()
|
|||
temp = NS_STATIC_CAST(nsISupports*, mURLParsers[i]);
|
||||
NS_IF_RELEASE(temp);
|
||||
}
|
||||
(void)SetOffline(PR_TRUE);
|
||||
if (mFileTransportService)
|
||||
(void)mFileTransportService->Shutdown();
|
||||
}
|
||||
|
@ -1040,5 +1041,9 @@ nsIOService::Observe(nsISupports *subject,
|
|||
mOfflineForProfileChange = PR_FALSE;
|
||||
}
|
||||
}
|
||||
else if (!nsCRT::strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
|
||||
// go offline to shutdown certain services before actual destruction
|
||||
SetOffline(PR_TRUE);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -199,11 +199,8 @@ private:
|
|||
nsCOMPtr<nsIObserver> mCharsetMenuObserver;
|
||||
nsCOMPtr<nsISupportsArray> mDecoderList;
|
||||
|
||||
nsresult Done();
|
||||
nsresult SetCharsetCheckmark(nsString * aCharset, PRBool aValue);
|
||||
|
||||
nsresult FreeResources();
|
||||
|
||||
nsresult InitStaticMenu(nsISupportsArray * aDecs,
|
||||
nsIRDFResource * aResource, const char * aKey, nsVoidArray * aArray);
|
||||
nsresult InitCacheMenu(nsISupportsArray * aDecs, nsIRDFResource * aResource,
|
||||
|
@ -252,7 +249,7 @@ private:
|
|||
nsresult RemoveFlaggedCharsets(nsISupportsArray * aList, nsString * aProp);
|
||||
nsresult NewRDFContainer(nsIRDFDataSource * aDataSource,
|
||||
nsIRDFResource * aResource, nsIRDFContainer ** aResult);
|
||||
void FreeMenuItemArray(nsVoidArray * aArray);
|
||||
static void FreeMenuItemArray(nsVoidArray * aArray);
|
||||
PRInt32 FindMenuItemInArray(nsVoidArray * aArray, nsIAtom * aCharset,
|
||||
nsMenuEntry ** aResult);
|
||||
nsresult ReorderMenuItemArray(nsVoidArray * aArray);
|
||||
|
@ -275,6 +272,9 @@ public:
|
|||
nsresult RefreshMaileditMenu();
|
||||
nsresult RefreshComposerMenu();
|
||||
|
||||
nsresult Done();
|
||||
nsresult FreeResources();
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Interface nsICurrentCharsetListener [declaration]
|
||||
|
||||
|
@ -368,28 +368,28 @@ NS_IMETHODIMP nsCharsetMenuObserver::Observe(nsISupports *aSubject, const char *
|
|||
if (nodeName.Equals(NS_LITERAL_STRING("browser"))) {
|
||||
rv = mCharsetMenu->InitBrowserMenu();
|
||||
}
|
||||
if (nodeName.Equals(NS_LITERAL_STRING("composer"))) {
|
||||
else if (nodeName.Equals(NS_LITERAL_STRING("composer"))) {
|
||||
rv = mCharsetMenu->InitComposerMenu();
|
||||
}
|
||||
if (nodeName.Equals(NS_LITERAL_STRING("mailview"))) {
|
||||
else if (nodeName.Equals(NS_LITERAL_STRING("mailview"))) {
|
||||
rv = mCharsetMenu->InitMailviewMenu();
|
||||
}
|
||||
if (nodeName.Equals(NS_LITERAL_STRING("mailedit"))) {
|
||||
else if (nodeName.Equals(NS_LITERAL_STRING("mailedit"))) {
|
||||
rv = mCharsetMenu->InitMaileditMenu();
|
||||
rv = mCharsetMenu->InitOthers();
|
||||
}
|
||||
if (nodeName.Equals(NS_LITERAL_STRING("more-menu"))) {
|
||||
else if (nodeName.Equals(NS_LITERAL_STRING("more-menu"))) {
|
||||
rv = mCharsetMenu->InitSecondaryTiers();
|
||||
rv = mCharsetMenu->InitAutodetMenu();
|
||||
}
|
||||
if (nodeName.Equals(NS_LITERAL_STRING("other"))) {
|
||||
else if (nodeName.Equals(NS_LITERAL_STRING("other"))) {
|
||||
rv = mCharsetMenu->InitOthers();
|
||||
rv = mCharsetMenu->InitMaileditMenu();
|
||||
}
|
||||
}
|
||||
|
||||
//pref event handler
|
||||
if (!nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
|
||||
else if (!nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
|
||||
nsDependentString prefName(someData);
|
||||
|
||||
if (prefName.Equals(NS_LITERAL_STRING(kBrowserStaticPrefKey))) {
|
||||
|
@ -403,6 +403,13 @@ NS_IMETHODIMP nsCharsetMenuObserver::Observe(nsISupports *aSubject, const char *
|
|||
else if (prefName.Equals(NS_LITERAL_STRING(kMaileditPrefKey))) {
|
||||
rv = mCharsetMenu->RefreshMaileditMenu();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
else if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
|
||||
mCharsetMenu->Done();
|
||||
|
||||
mCharsetMenu->FreeResources();
|
||||
}
|
||||
|
||||
NS_TIMELINE_STOP_TIMER("nsCharsetMenu:Observe");
|
||||
|
@ -475,10 +482,14 @@ nsCharsetMenu::nsCharsetMenu()
|
|||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &res);
|
||||
|
||||
if (NS_SUCCEEDED(res))
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = observerService->AddObserver(mCharsetMenuObserver,
|
||||
"charsetmenu-selected",
|
||||
PR_FALSE);
|
||||
res = observerService->AddObserver(mCharsetMenuObserver,
|
||||
NS_XPCOM_SHUTDOWN_OBSERVER_ID,
|
||||
PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(res), "Failed to initialize nsCharsetMenu");
|
||||
|
@ -488,13 +499,6 @@ nsCharsetMenu::nsCharsetMenu()
|
|||
|
||||
nsCharsetMenu::~nsCharsetMenu()
|
||||
{
|
||||
Done();
|
||||
|
||||
FreeMenuItemArray(&mBrowserMenu);
|
||||
FreeMenuItemArray(&mMailviewMenu);
|
||||
FreeMenuItemArray(&mComposerMenu);
|
||||
|
||||
FreeResources();
|
||||
}
|
||||
|
||||
// XXX collapse these 2 in one
|
||||
|
@ -752,6 +756,10 @@ nsresult nsCharsetMenu::FreeResources()
|
|||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
FreeMenuItemArray(&mBrowserMenu);
|
||||
FreeMenuItemArray(&mMailviewMenu);
|
||||
FreeMenuItemArray(&mComposerMenu);
|
||||
|
||||
if (mCharsetMenuObserver) {
|
||||
nsCOMPtr<nsIPrefBranchInternal> pbi = do_QueryInterface(mPrefs);
|
||||
if (pbi) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче