From b77e7a5a976f9c386cb5577fff6315f522bb8b16 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Thu, 23 Oct 2014 22:01:35 -0700 Subject: [PATCH] fixed reentrancy when closing flyout --- cocos/ui/UIEditBox/UIEditBoxImpl-winrt.cpp | 23 ++++++++++++++++++---- cocos/ui/UIEditBox/UIEditBoxImpl-winrt.h | 1 + 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-winrt.cpp b/cocos/ui/UIEditBox/UIEditBoxImpl-winrt.cpp index 0d6988a77a..798b33c89f 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-winrt.cpp +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-winrt.cpp @@ -136,23 +136,34 @@ void EditBoxWinRT::OpenXamlEditBox(Platform::String^ strText) void EditBoxWinRT::Closed(Platform::Object^ sender, Platform::Object^ e) { + critical_section::scoped_lock lock(m_criticalSection); RemoveControls(); } void EditBoxWinRT::Done(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { + critical_section::scoped_lock lock(m_criticalSection); QueueText(); - RemoveControls(); + HideFlyout(); } void EditBoxWinRT::Cancel(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { - RemoveControls(); + HideFlyout(); } void EditBoxWinRT::HideKeyboard(Windows::UI::ViewManagement::InputPane^ inputPane, Windows::UI::ViewManagement::InputPaneVisibilityEventArgs^ args) { - RemoveControls(); + critical_section::scoped_lock lock(m_criticalSection); + HideFlyout(); +} + +void EditBoxWinRT::HideFlyout() +{ + if (m_flyout) + { + m_flyout->Hide(); + } } void EditBoxWinRT::RemoveControls() @@ -182,7 +193,6 @@ void EditBoxWinRT::RemoveControls() if (m_flyout != nullptr) { m_flyout->Closed -= m_closedToken; - m_flyout->Hide(); m_flyout = nullptr; } @@ -278,6 +288,11 @@ void EditBoxWinRT::SetInputScope(TextBox^ box, EditBox::InputMode inputMode) void EditBoxWinRT::QueueText() { + if ((m_passwordBox == nullptr) && (m_textBox == nullptr)) + { + return; + } + m_strText = m_inputFlag == EditBox::InputFlag::PASSWORD ? m_passwordBox->Password : m_textBox->Text; std::shared_ptr e(new UIEditBoxEvent(this, m_strText, m_receiveHandler)); cocos2d::GLViewImpl::sharedOpenGLView()->QueueEvent(e); diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-winrt.h b/cocos/ui/UIEditBox/UIEditBoxImpl-winrt.h index 7cfc4b43c4..68cb26e739 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-winrt.h +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-winrt.h @@ -59,6 +59,7 @@ namespace ui { void Cancel(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void Closed(Platform::Object^ sender, Platform::Object^ e); void HideKeyboard(Windows::UI::ViewManagement::InputPane^ inputPane, Windows::UI::ViewManagement::InputPaneVisibilityEventArgs^ args); + void HideFlyout(); Platform::Agile m_dispatcher; Platform::Agile m_panel;