From c9f9deab819b4fed528205fcb5479c68ce9092d9 Mon Sep 17 00:00:00 2001 From: Kevin Ollivier Date: Sat, 22 Nov 2008 04:10:31 +0000 Subject: [PATCH 1/1] Forward port event handler fixes to trunk. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56886 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/osx/carbon/private/mactext.h | 1 + include/wx/osx/carbon/toplevel.h | 2 ++ include/wx/osx/uma.h | 2 +- src/html/htmlctrl/webkit/webkit.mm | 11 ++++++++++- src/osx/carbon/textctrl.cpp | 3 ++- src/osx/toplevel_osx.cpp | 11 +++++++++++ 6 files changed, 27 insertions(+), 3 deletions(-) diff --git a/include/wx/osx/carbon/private/mactext.h b/include/wx/osx/carbon/private/mactext.h index e401f2b652..5cbeb0a2dc 100644 --- a/include/wx/osx/carbon/private/mactext.h +++ b/include/wx/osx/carbon/private/mactext.h @@ -45,6 +45,7 @@ protected : // contains the tag for the content (is different for password and non-password controls) OSType m_valueTag ; + WXEVENTHANDLERREF m_macTextCtrlEventHandler ; public : ControlEditTextSelectionRec m_selection ; }; diff --git a/include/wx/osx/carbon/toplevel.h b/include/wx/osx/carbon/toplevel.h index 726c5d256a..7983b8c5c6 100644 --- a/include/wx/osx/carbon/toplevel.h +++ b/include/wx/osx/carbon/toplevel.h @@ -44,6 +44,8 @@ public: const wxString& name = wxFrameNameStr); virtual ~wxTopLevelWindowMac(); + + virtual bool Destroy(); virtual wxPoint GetClientAreaOrigin() const; diff --git a/include/wx/osx/uma.h b/include/wx/osx/uma.h index 899dae109e..451f2f71f6 100644 --- a/include/wx/osx/uma.h +++ b/include/wx/osx/uma.h @@ -1,3 +1,3 @@ -#if __WXOSX_CARBON__ +#if wxOSX_USE_CARBON #include "wx/osx/carbon/uma.h" #endif diff --git a/src/html/htmlctrl/webkit/webkit.mm b/src/html/htmlctrl/webkit/webkit.mm index 27216cb00b..7e28d801ed 100644 --- a/src/html/htmlctrl/webkit/webkit.mm +++ b/src/html/htmlctrl/webkit/webkit.mm @@ -468,7 +468,16 @@ bool wxWebKitCtrl::Create(wxWindow *parent, wxWebKitCtrl::~wxWebKitCtrl() { - + MyFrameLoadMonitor* myFrameLoadMonitor = [m_webView frameLoadDelegate]; + MyPolicyDelegate* myPolicyDelegate = [m_webView policyDelegate]; + [m_webView setFrameLoadDelegate: nil]; + [m_webView setPolicyDelegate: nil]; + + if (myFrameLoadMonitor) + [myFrameLoadMonitor release]; + + if (myPolicyDelegate) + [myPolicyDelegate release]; } // ---------------------------------------------------------------------------- diff --git a/src/osx/carbon/textctrl.cpp b/src/osx/carbon/textctrl.cpp index fc308b6712..ee9dd86bec 100644 --- a/src/osx/carbon/textctrl.cpp +++ b/src/osx/carbon/textctrl.cpp @@ -509,11 +509,12 @@ void wxMacUnicodeTextControl::InstallEventHandlers() { ::InstallControlEventHandler( m_controlRef , GetwxMacUnicodeTextControlEventHandlerUPP(), GetEventTypeCount(unicodeTextControlEventList), unicodeTextControlEventList, this, - NULL); + (EventHandlerRef*) &m_macTextCtrlEventHandler); } wxMacUnicodeTextControl::~wxMacUnicodeTextControl() { + ::RemoveEventHandler((EventHandlerRef) m_macTextCtrlEventHandler); } void wxMacUnicodeTextControl::VisibilityChanged(bool shown) diff --git a/src/osx/toplevel_osx.cpp b/src/osx/toplevel_osx.cpp index 1886e988c9..738b5d607d 100644 --- a/src/osx/toplevel_osx.cpp +++ b/src/osx/toplevel_osx.cpp @@ -87,6 +87,17 @@ wxTopLevelWindowMac::~wxTopLevelWindowMac() { } +bool wxTopLevelWindowMac::Destroy() +{ + // NB: this will get called during destruction if we don't do it now, + // and may fire a kill focus event on a control being destroyed +#if wxOSX_USE_CARBON + if (m_nowpeer->GetWXWindow()) + ClearKeyboardFocus( (WindowRef)m_nowpeer->GetWXWindow() ); +#endif + return wxTopLevelWindowBase::Destroy(); +} + // ---------------------------------------------------------------------------- // wxTopLevelWindowMac maximize/minimize -- 2.45.2