From 101ad30530c44ff6741a9c396e74c9f7a889fded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Thu, 3 Nov 2016 13:49:45 +0100 Subject: [PATCH] [escher] In input view controller, ensure doing nothing in constructor Change-Id: Idd03a0d04a5ae7a43b1dc457bb25e0e0bb1a1d43 --- escher/include/escher/input_view_controller.h | 5 +++-- escher/src/input_view_controller.cpp | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/escher/include/escher/input_view_controller.h b/escher/include/escher/input_view_controller.h index ab5e173fb..22c1dbdfe 100644 --- a/escher/include/escher/input_view_controller.h +++ b/escher/include/escher/input_view_controller.h @@ -17,7 +17,8 @@ public: private: class ContentView : public View { public: - ContentView(View * subview); + ContentView(); + void setMainView(View * subview); int numberOfSubviews() const override; View * subviewAtIndex(int index) override; void layoutSubviews() override; @@ -33,9 +34,9 @@ private: }; void showInput(bool show); void setTextBody(const char * text); - void setPreviousResponder(Responder * previousResponder); ContentView m_contentView; Responder * m_previousResponder; + ViewController * m_regularViewController; Invocation m_successAction; Invocation m_failureAction; }; diff --git a/escher/src/input_view_controller.cpp b/escher/src/input_view_controller.cpp index a45dc7a76..b09b9712d 100644 --- a/escher/src/input_view_controller.cpp +++ b/escher/src/input_view_controller.cpp @@ -2,15 +2,19 @@ #include #include -InputViewController::ContentView::ContentView(View * subview) : +InputViewController::ContentView::ContentView() : View(), - m_mainView(subview), + m_mainView(nullptr), m_textField(nullptr, m_textBody, 255), m_visibleInput(false) { m_textBody[0] = 0; } +void InputViewController::ContentView::setMainView(View * subview) { + m_mainView = subview; +} + int InputViewController::ContentView::numberOfSubviews() const { if (m_visibleInput) { return 2; @@ -59,8 +63,9 @@ TextField * InputViewController::ContentView::textField() { InputViewController::InputViewController(Responder * parentResponder, ViewController * child) : ViewController(parentResponder), - m_contentView(child->view()), + m_contentView(), m_previousResponder(nullptr), + m_regularViewController(child), m_successAction(Invocation(nullptr, nullptr)), m_failureAction(Invocation(nullptr, nullptr)) { @@ -68,6 +73,9 @@ InputViewController::InputViewController(Responder * parentResponder, ViewContro } View * InputViewController::view() { + if (m_contentView.subviewAtIndex(0) == nullptr) { + m_contentView.setMainView(m_regularViewController->view()); + } return &m_contentView; } @@ -79,10 +87,6 @@ const char * InputViewController::textBody() { return m_contentView.textField()->textBuffer(); } -void InputViewController::setPreviousResponder(Responder * previousResponder) { - m_previousResponder = previousResponder; -} - void InputViewController::showInput(bool show) { m_contentView.setVisibleInput(show); if (show) { @@ -118,7 +122,6 @@ bool InputViewController::handleEvent(Ion::Events::Event event) { void InputViewController::edit(Responder * caller, const char * initialContent, void * context, Invocation::Action successAction, Invocation::Action failureAction) { m_successAction = Invocation(successAction, context); m_failureAction = Invocation(failureAction, context); - setPreviousResponder(caller); setTextBody(initialContent); showInput(true); }