Closed Bug 671792 Opened 15 years ago Closed 15 years ago

"ASSERTION: ImmAssociateContextEx failed to restore default IMC"

Categories

(Core :: Widget: Win32, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla9

People

(Reporter: jruderman, Assigned: bbondy)

References

Details

(Keywords: testcase)

Attachments

(1 file)

1. In the address bar, enter http://www.squarefree.com/bug662261/x.test 2. Right-click Firefox's taskbar icon and select "close all windows" Result: ###!!! ASSERTION: ImmAssociateContextEx failed to restore default IMC: 'ret || !nsIMM32Handler::IsIMEAvailable()', file widget/src/windows/nsWindow.cpp, line 8038
I can reproduce this so I'll take it.
Assignee: nobody → netzen
The assertion was failing because of a GetLastError() of invalid handle on the Win32 API call to "::ImmAssociateContextEx(mWnd, .._)". The problem was that we were destroying the window twice. The call "DispatchStandardEvent(NS_DESTROY);" inside "nsWindow::OnDestroy" was sometimes leading to "nsXULWindow::Destroy" which would in turn call "mWindow->Destroy()" a second time. Where the error happened. We were already checking to make sure we didn't destroy twice with "if (nsnull == mWnd) return NS_OK" in "nsWindow::Destroy()" but this would only check that we finished the WM_DESTROY message, not that we already started the WM_DESTROY message. Instead we should check that we have started the WM_DESTROY message to ensure the above situation doens't happen. This can be done by changing: "if (nsnull == mWnd) return NS_OK" to " if (mOnDestroyCalled) return NS_OK;"
Attachment #546938 - Flags: review?(neil)
This patch also fixes a different similar error in Bug 622312.
Blocks: 622312
Aha, so OnDestroy calls DispatchStandardEvent(NS_DESTROY) which normally does nothing, because something else has been destroyed first. But sometimes it hasn't, in which case nsXULWindow tries to destroy the nsWindow again...
Right, basically from within the destroy it can lead to another destroy. We had a check for double destroy but the way we checked it was if the destroy was done, and not if the destroy had already started.
Attachment #546938 - Flags: review?(neil) → review+
Attachment #546938 - Flags: checkin?
Comment on attachment 546938 [details] [diff] [review] Patch for ASSERTION: ImmAssociateContextEx failed to restore default IMC Going to run through try before checkin?
Attachment #546938 - Flags: checkin?
pushed to mozilla-inbound.
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla9
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: