Bug 995893 part.2 Unregister all references to nsTextStore before releasing its instance r=jimm
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 12 Jul 2014 02:09:59 +0900
changeset 215541 5d68184741eac8d184ff718320482d050abfcfe0
parent 215540 05ae727d8db22d25ef19d4cd6f17681e5418cbed
child 215542 5a9f78740f9cfbd872515bb502f201e9ded081a4
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs995893
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 995893 part.2 Unregister all references to nsTextStore before releasing its instance r=jimm
widget/windows/nsTextStore.cpp
widget/windows/nsTextStore.h
--- a/widget/windows/nsTextStore.cpp
+++ b/widget/windows/nsTextStore.cpp
@@ -571,54 +571,61 @@ nsTextStore::Init(ITfThreadMgr* aThreadM
      this, mIPProfileCookie, mLangProfileCookie));
 
   return true;
 }
 
 nsTextStore::~nsTextStore()
 {
   PR_LOG(sTextStoreLog, PR_LOG_ALWAYS,
-    ("TSF: 0x%p nsTextStore instance is destroyed, "
+    ("TSF: 0x%p nsTextStore instance is destroyed", this));
+}
+
+void
+nsTextStore::Shutdown()
+{
+  PR_LOG(sTextStoreLog, PR_LOG_ALWAYS,
+    ("TSF: 0x%p nsTextStore::Shutdown() "
      "mWidget=0x%p, mDocumentMgr=0x%p, mContext=0x%p, mIPProfileCookie=0x%08X, "
      "mLangProfileCookie=0x%08X",
      this, mWidget.get(), mDocumentMgr.get(), mContext.get(),
      mIPProfileCookie, mLangProfileCookie));
 
   if (mIPProfileCookie != TF_INVALID_COOKIE) {
     nsRefPtr<ITfSource> source;
     HRESULT hr =
       sTsfThreadMgr->QueryInterface(IID_ITfSource, getter_AddRefs(source));
     if (FAILED(hr)) {
       PR_LOG(sTextStoreLog, PR_LOG_ERROR,
-        ("TSF: 0x%p   ~nsTextStore FAILED to get ITfSource instance "
-         "(0x%08X)", this, hr));
+        ("TSF: 0x%p   nsTextStore::Shutdown() FAILED to get "
+         "ITfSource instance (0x%08X)", this, hr));
     } else {
       hr = source->UnadviseSink(mIPProfileCookie);
       if (FAILED(hr)) {
         PR_LOG(sTextStoreLog, PR_LOG_ERROR,
-          ("TSF: 0x%p   ~nsTextStore FAILED to uninstall "
+          ("TSF: 0x%p   nsTextStore::Shutdown() FAILED to uninstall "
            "ITfInputProcessorProfileActivationSink (0x%08X)",
            this, hr));
       }
     }
   }
 
   if (mLangProfileCookie != TF_INVALID_COOKIE) {
     nsRefPtr<ITfSource> source;
     HRESULT hr =
       sTsfThreadMgr->QueryInterface(IID_ITfSource, getter_AddRefs(source));
     if (FAILED(hr)) {
       PR_LOG(sTextStoreLog, PR_LOG_ERROR,
-        ("TSF: 0x%p   ~nsTextStore FAILED to get ITfSource instance "
-         "(0x%08X)", this, hr));
+        ("TSF: 0x%p   nsTextStore::Shutdown() FAILED to get "
+         "ITfSource instance (0x%08X)", this, hr));
     } else {
       hr = source->UnadviseSink(mLangProfileCookie);
       if (FAILED(hr)) {
         PR_LOG(sTextStoreLog, PR_LOG_ERROR,
-          ("TSF: 0x%p   ~nsTextStore FAILED to uninstall "
+          ("TSF: 0x%p   nsTextStore::Shutdown() FAILED to uninstall "
            "ITfActiveLanguageProfileNotifySink (0x%08X)",
            this, hr));
       }
     }
   }
 }
 
 bool
@@ -3857,16 +3864,20 @@ nsTextStore::Initialize()
 }
 
 // static
 void
 nsTextStore::Terminate(void)
 {
   PR_LOG(sTextStoreLog, PR_LOG_ALWAYS, ("TSF: nsTextStore::Terminate()"));
 
+  if (sTsfTextStore) {
+    sTsfTextStore->Shutdown();
+  }
+
   NS_IF_RELEASE(sDisplayAttrMgr);
   NS_IF_RELEASE(sCategoryMgr);
   NS_IF_RELEASE(sTsfTextStore);
   NS_IF_RELEASE(sTsfDisabledDocumentMgr);
   NS_IF_RELEASE(sTsfDisabledContext);
   NS_IF_RELEASE(sInputProcessorProfiles);
   sTsfClientId = 0;
   if (sTsfThreadMgr) {
--- a/widget/windows/nsTextStore.h
+++ b/widget/windows/nsTextStore.h
@@ -221,16 +221,17 @@ public:
   static bool     CurrentKeyboardLayoutHasIME();
 #endif // #ifdef DEBUG
 
 protected:
   nsTextStore();
   ~nsTextStore();
 
   bool Init(ITfThreadMgr* aThreadMgr);
+  void Shutdown();
 
   static void MarkContextAsKeyboardDisabled(ITfContext* aContext);
   static void MarkContextAsEmpty(ITfContext* aContext);
 
   static bool IsTIPCategoryKeyboard(REFCLSID aTextService, LANGID aLangID,
                                     REFGUID aProfile);
   static void GetTIPDescription(REFCLSID aTextService, LANGID aLangID,
                                 REFGUID aProfile, nsAString& aDescription);