Bug 913138 - Release nsLayoutStatics when the layout module is unloaded. r=bsmedberg

This commit is contained in:
Bobby Holley 2014-04-08 15:51:33 -07:00
parent fe303ddb4d
commit 6f6701effe

View File

@ -352,35 +352,6 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsITelephonyProvider,
//-----------------------------------------------------------------------------
// Per bug 209804, it is necessary to observe the "xpcom-shutdown" event and
// perform shutdown of the layout modules at that time instead of waiting for
// our module destructor to run. If we do not do this, then we risk holding
// references to objects in other component libraries that have already been
// shutdown (and possibly unloaded if 60709 is ever fixed).
class LayoutShutdownObserver MOZ_FINAL : public nsIObserver
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
};
NS_IMPL_ISUPPORTS1(LayoutShutdownObserver, nsIObserver)
NS_IMETHODIMP
LayoutShutdownObserver::Observe(nsISupports *aSubject,
const char *aTopic,
const char16_t *someData)
{
if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
Shutdown();
nsContentUtils::XPCOMShutdown();
}
return NS_OK;
}
//-----------------------------------------------------------------------------
static bool gInitialized = false;
// Perform our one-time intialization for this module
@ -411,24 +382,6 @@ Initialize()
return rv;
}
// Add our shutdown observer.
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
if (observerService) {
LayoutShutdownObserver* observer = new LayoutShutdownObserver();
if (!observer) {
Shutdown();
return NS_ERROR_OUT_OF_MEMORY;
}
observerService->AddObserver(observer, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
} else {
NS_WARNING("Could not get an observer service. We will leak on shutdown.");
}
#ifdef DEBUG
nsStyleContext::AssertStyleStructMaxDifferenceValid();
#endif
@ -1293,6 +1246,8 @@ static const mozilla::Module::CategoryEntry kLayoutCategories[] = {
static void
LayoutModuleDtor()
{
Shutdown();
nsContentUtils::XPCOMShutdown();
nsScriptSecurityManager::Shutdown();
xpcModuleDtor();
}