Crash while doing Flash IME. b=443024 r=josh,masayuki sr=vladimir
authorSteven Michaud <smichaud@pobox.com>
Mon, 14 Jul 2008 09:38:49 -0500
changeset 15931 98c39a7f345a689c6e561e09e817951df0f91126
parent 15930 306d738a3e40eeacf199f56c0a5c49be6ee11c5c
child 15932 1c55b2f069f78d3d2cb1a4468ed55c26d0ec8e28
push idunknown
push userunknown
push dateunknown
reviewersjosh, masayuki, vladimir
bugs443024
milestone1.9.1a1pre
Crash while doing Flash IME. b=443024 r=josh,masayuki sr=vladimir
widget/src/cocoa/nsChildView.h
widget/src/cocoa/nsChildView.mm
--- a/widget/src/cocoa/nsChildView.h
+++ b/widget/src/cocoa/nsChildView.h
@@ -190,16 +190,18 @@ extern "C" long TSMProcessRawKeyEvent(Ev
 //-------------------------------------------------------------------------
 
 class nsTSMManager {
 public:
   static PRBool IsComposing() { return sComposingView ? PR_TRUE : PR_FALSE; }
   static PRBool IsIMEEnabled() { return sIsIMEEnabled; }
   static PRBool IgnoreCommit() { return sIgnoreCommit; }
 
+  static void OnDestroyView(NSView<mozView>* aDestroyingView);
+
   // Note that we cannot get the actual state in TSM. But we can trust this
   // value. Because nsIMEStateManager reset this at every focus changing.
   static PRBool IsRomanKeyboardsOnly() { return sIsRomanKeyboardsOnly; }
 
   static PRBool GetIMEOpenState();
 
   static void StartComposing(NSView<mozView>* aComposingView);
   static void UpdateComposing(NSString* aComposingString);
--- a/widget/src/cocoa/nsChildView.mm
+++ b/widget/src/cocoa/nsChildView.mm
@@ -2266,16 +2266,17 @@ NSEvent* gLastDragEvent = nil;
   ::SetPort(NULL);
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 
 - (void)widgetDestroyed
 {
+  nsTSMManager::OnDestroyView(self);
   mGeckoChild = nsnull;
   // Just in case we're destroyed abruptly and missed the draggingExited
   // or performDragOperation message.
   NS_IF_RELEASE(mDragService);
 }
 
 
 // mozView method, return our gecko child view widget. Note this does not AddRef.
@@ -6001,16 +6002,28 @@ static BOOL keyUpAlreadySentKeyDown = NO
 #endif /* ACCESSIBILITY */
 
 @end
 
 
 #pragma mark -
 
 
+void
+nsTSMManager::OnDestroyView(NSView<mozView>* aDestroyingView)
+{
+  if (aDestroyingView != sComposingView)
+    return;
+  if (IsComposing()) {
+    CancelIME(); // XXX Might CancelIME() fail because sComposingView is being destroyed?
+    EndComposing();
+  }
+}
+
+
 PRBool
 nsTSMManager::GetIMEOpenState()
 {
   return GetScriptManagerVariable(smKeyScript) != smRoman ? PR_TRUE : PR_FALSE;
 }
 
 
 void