Bug 1368318 Call TSFTextStore::ThinksHavingFocus() before clearing sEnabledTextStore since the method refers it r?m_kato
MozReview-Commit-ID: GdALZTWioNW
--- a/widget/windows/TSFTextStore.cpp
+++ b/widget/windows/TSFTextStore.cpp
@@ -4976,32 +4976,33 @@ TSFTextStore::OnFocusChange(bool aGotFoc
GetInputContextString(aContext).get(),
sThreadMgr.get(), sEnabledTextStore.get()));
if (NS_WARN_IF(!IsInTSFMode())) {
return NS_ERROR_NOT_AVAILABLE;
}
RefPtr<ITfDocumentMgr> prevFocusedDocumentMgr;
+ bool hasFocus = ThinksHavingFocus();
RefPtr<TSFTextStore> oldTextStore = sEnabledTextStore.forget();
- // If currently sEnableTextStore has focus, notifies TSF of losing focus.
- if (ThinksHavingFocus()) {
+ // If currently oldTextStore still has focus, notifies TSF of losing focus.
+ if (hasFocus) {
RefPtr<ITfThreadMgr> threadMgr = sThreadMgr;
DebugOnly<HRESULT> hr =
threadMgr->AssociateFocus(
oldTextStore->mWidget->GetWindowHandle(),
nullptr, getter_AddRefs(prevFocusedDocumentMgr));
NS_ASSERTION(SUCCEEDED(hr), "Disassociating focus failed");
NS_ASSERTION(prevFocusedDocumentMgr == oldTextStore->mDocumentMgr,
"different documentMgr has been associated with the window");
}
- // If there is sEnabledTextStore, we don't use it in the new focused editor.
- // Release it now.
+ // Even if there was a focused TextStore, we won't use it with new focused
+ // editor. So, release it now.
if (oldTextStore) {
oldTextStore->Destroy();
}
if (NS_WARN_IF(!sThreadMgr)) {
MOZ_LOG(sTextStoreLog, LogLevel::Error,
(" TSFTextStore::OnFocusChange() FAILED, due to "
"sThreadMgr being destroyed during calling "