Bug 1052343 part.6 Don't destroy nsTextStore instance during it's locking the document r=emk

This commit is contained in:
Masayuki Nakano 2014-09-02 09:27:26 +09:00
parent c94065c322
commit c3d778e5d4
2 changed files with 22 additions and 4 deletions

View File

@ -1177,6 +1177,7 @@ nsTextStore::nsTextStore()
, mIsRecordingActionsWithoutLock(false) , mIsRecordingActionsWithoutLock(false)
, mPendingOnSelectionChange(false) , mPendingOnSelectionChange(false)
, mPendingOnLayoutChange(false) , mPendingOnLayoutChange(false)
, mPendingDestroy(false)
, mNativeCaretIsCreated(false) , mNativeCaretIsCreated(false)
{ {
for (int32_t i = 0; i < NUM_OF_SUPPORTED_ATTRS; i++) { for (int32_t i = 0; i < NUM_OF_SUPPORTED_ATTRS; i++) {
@ -1258,8 +1259,15 @@ bool
nsTextStore::Destroy() nsTextStore::Destroy()
{ {
PR_LOG(sTextStoreLog, PR_LOG_ALWAYS, PR_LOG(sTextStoreLog, PR_LOG_ALWAYS,
("TSF: 0x%p nsTextStore::Destroy(), mComposition.IsComposing()=%s", ("TSF: 0x%p nsTextStore::Destroy(), mLock=%s, "
this, GetBoolName(mComposition.IsComposing()))); "mComposition.IsComposing()=%s",
this, GetLockFlagNameStr(mLock).get(),
GetBoolName(mComposition.IsComposing())));
if (mLock) {
mPendingDestroy = true;
return true;
}
// If there is composition, TSF keeps the composition even after the text // If there is composition, TSF keeps the composition even after the text
// store destroyed. So, we should clear the composition here. // store destroyed. So, we should clear the composition here.
@ -1430,6 +1438,9 @@ nsTextStore::RequestLock(DWORD dwLockFlags,
("TSF: 0x%p Locking (%s) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" ("TSF: 0x%p Locking (%s) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>",
this, GetLockFlagNameStr(mLock).get())); this, GetLockFlagNameStr(mLock).get()));
// Don't release this instance during this lock because this is called by
// TSF but they don't grab us during this call.
nsRefPtr<nsTextStore> kungFuDeathGrip(this);
*phrSession = mSink->OnLockGranted(mLock); *phrSession = mSink->OnLockGranted(mLock);
PR_LOG(sTextStoreLog, PR_LOG_ALWAYS, PR_LOG(sTextStoreLog, PR_LOG_ALWAYS,
("TSF: 0x%p Unlocked (%s) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" ("TSF: 0x%p Unlocked (%s) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
@ -1454,7 +1465,7 @@ nsTextStore::RequestLock(DWORD dwLockFlags,
// The document is now completely unlocked. // The document is now completely unlocked.
mLock = 0; mLock = 0;
if (mPendingOnLayoutChange) { if (!mPendingDestroy && mPendingOnLayoutChange) {
mPendingOnLayoutChange = false; mPendingOnLayoutChange = false;
if (mSink) { if (mSink) {
PR_LOG(sTextStoreLog, PR_LOG_ALWAYS, PR_LOG(sTextStoreLog, PR_LOG_ALWAYS,
@ -1478,7 +1489,7 @@ nsTextStore::RequestLock(DWORD dwLockFlags,
} }
} }
if (mPendingOnSelectionChange) { if (!mPendingDestroy && mPendingOnSelectionChange) {
mPendingOnSelectionChange = false; mPendingOnSelectionChange = false;
if (mSink) { if (mSink) {
PR_LOG(sTextStoreLog, PR_LOG_ALWAYS, PR_LOG(sTextStoreLog, PR_LOG_ALWAYS,
@ -1488,6 +1499,10 @@ nsTextStore::RequestLock(DWORD dwLockFlags,
} }
} }
if (mPendingDestroy) {
Destroy();
}
PR_LOG(sTextStoreLog, PR_LOG_ALWAYS, PR_LOG(sTextStoreLog, PR_LOG_ALWAYS,
("TSF: 0x%p nsTextStore::RequestLock() succeeded: *phrSession=%s", ("TSF: 0x%p nsTextStore::RequestLock() succeeded: *phrSession=%s",
this, GetTextStoreReturnValueName(*phrSession))); this, GetTextStoreReturnValueName(*phrSession)));

View File

@ -732,6 +732,9 @@ protected:
// ITfContextOwnerServices::OnLayoutChange() after the layout is fixed and // ITfContextOwnerServices::OnLayoutChange() after the layout is fixed and
// the document is unlocked. // the document is unlocked.
bool mPendingOnLayoutChange; bool mPendingOnLayoutChange;
// During the documet is locked, we shouldn't destroy the instance.
// If this is true, the instance will be destroyed after unlocked.
bool mPendingDestroy;
// While there is native caret, this is true. Otherwise, false. // While there is native caret, this is true. Otherwise, false.
bool mNativeCaretIsCreated; bool mNativeCaretIsCreated;