Bug 940426 - part 2 - don't observe xpcom-shutdown in nsXULTemplateBuilder; r=bz
authorNathan Froyd <froydnj@mozilla.com>
Tue, 19 Nov 2013 20:04:15 -0500
changeset 156660 daf343a5478c5369e7bcf877834313968a4b6653
parent 156659 828b7a8e6647eec741ab541e0b1cdb6f0d88a8e6
child 156661 430d402e2c45a89b22bf21940243ed53260662c9
push idunknown
push userunknown
push dateunknown
reviewersbz
bugs940426
milestone28.0a1
Bug 940426 - part 2 - don't observe xpcom-shutdown in nsXULTemplateBuilder; r=bz
content/xul/templates/src/nsXULTemplateBuilder.cpp
--- a/content/xul/templates/src/nsXULTemplateBuilder.cpp
+++ b/content/xul/templates/src/nsXULTemplateBuilder.cpp
@@ -97,16 +97,17 @@ PRLogModuleInfo* gXULTemplateLog;
 //
 
 nsXULTemplateBuilder::nsXULTemplateBuilder(void)
     : mQueriesCompiled(false),
       mFlags(0),
       mTop(nullptr),
       mObservedDocument(nullptr)
 {
+    MOZ_COUNT_CTOR(nsXULTemplateBuilder);
 }
 
 static PLDHashOperator
 DestroyMatchList(nsISupports* aKey, nsTemplateMatch*& aMatch, void* aContext)
 {
     // delete all the matches in the list
     while (aMatch) {
         nsTemplateMatch* next = aMatch->mNext;
@@ -123,16 +124,18 @@ nsXULTemplateBuilder::~nsXULTemplateBuil
 
     if (--gRefCnt == 0) {
         NS_IF_RELEASE(gRDFService);
         NS_IF_RELEASE(gRDFContainerUtils);
         NS_IF_RELEASE(gSystemPrincipal);
         NS_IF_RELEASE(gScriptSecurityManager);
         NS_IF_RELEASE(gObserverService);
     }
+
+    MOZ_COUNT_DTOR(nsXULTemplateBuilder);
 }
 
 
 nsresult
 nsXULTemplateBuilder::InitGlobals()
 {
     nsresult rv;
 
@@ -171,27 +174,25 @@ nsXULTemplateBuilder::InitGlobals()
     return NS_OK;
 }
 
 void
 nsXULTemplateBuilder::StartObserving(nsIDocument* aDocument)
 {
     aDocument->AddObserver(this);
     mObservedDocument = aDocument;
-    gObserverService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
     gObserverService->AddObserver(this, DOM_WINDOW_DESTROYED_TOPIC, false);
 }
 
 void
 nsXULTemplateBuilder::StopObserving()
 {
     MOZ_ASSERT(mObservedDocument);
     mObservedDocument->RemoveObserver(this);
     mObservedDocument = nullptr;
-    gObserverService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
     gObserverService->RemoveObserver(this, DOM_WINDOW_DESTROYED_TOPIC);
 }
 
 void
 nsXULTemplateBuilder::CleanUp(bool aIsFinal)
 {
     for (int32_t q = mQuerySets.Length() - 1; q >= 0; q--) {
         nsTemplateQuerySet* qs = mQuerySets[q];
@@ -1077,18 +1078,16 @@ nsXULTemplateBuilder::Observe(nsISupport
     // doesn't know about. See bug 394514.
     if (!strcmp(aTopic, DOM_WINDOW_DESTROYED_TOPIC)) {
         nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aSubject);
         if (window) {
             nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
             if (doc && doc == mObservedDocument)
                 NodeWillBeDestroyed(doc);
         }
-    } else if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
-        UninitTrue();
     }
     return NS_OK;
 }
 //----------------------------------------------------------------------
 //
 // nsIDocumentOberver interface
 //