diff --git a/escher/include/escher/dynamic_view_controller.h b/escher/include/escher/dynamic_view_controller.h index e370ef4f4..6016864da 100644 --- a/escher/include/escher/dynamic_view_controller.h +++ b/escher/include/escher/dynamic_view_controller.h @@ -3,8 +3,12 @@ #include -/* Dynamic view controllers dynamically construct their views when appearring and - * delete them when disappearing. */ +/* Dynamic view controllers dynamically construct their views when appearring + * and delete them when disappearing. + * The load method is called before any methods viewWillAppear, + * didEnterResponderChain and didBecomeFirstResponder. The unload method is + * called after viewWillDisappear, willExitResponderChain or + * willResignFirstResponder. */ class DynamicViewController : public ViewController { public: diff --git a/escher/src/modal_view_controller.cpp b/escher/src/modal_view_controller.cpp index 3d37517b8..3618626be 100644 --- a/escher/src/modal_view_controller.cpp +++ b/escher/src/modal_view_controller.cpp @@ -119,11 +119,11 @@ void ModalViewController::displayModalViewController(ViewController * vc, float void ModalViewController::dismissModalViewController() { m_currentModalViewController->viewDidDisappear(); - m_currentModalViewController->unloadView(); - m_currentModalViewController = nullptr; m_regularViewController->viewWillAppear(); app()->setFirstResponder(m_previousResponder); m_contentView.dismissModalView(); + m_currentModalViewController->unloadView(); + m_currentModalViewController = nullptr; } void ModalViewController::didBecomeFirstResponder() { diff --git a/escher/src/stack_view_controller.cpp b/escher/src/stack_view_controller.cpp index ddab48b77..669dc632d 100644 --- a/escher/src/stack_view_controller.cpp +++ b/escher/src/stack_view_controller.cpp @@ -86,11 +86,11 @@ void StackViewController::push(ViewController * vc, KDColor textColor, KDColor b m_view.pushStack(frame); /* Add the frame to the model */ pushModel(frame); + setupActiveViewController(); if (m_numberOfChildren > 1) { m_childrenFrame[m_numberOfChildren-2].viewController()->viewDidDisappear(); m_childrenFrame[m_numberOfChildren-2].viewController()->unloadView(); } - setupActiveViewController(); } void StackViewController::pop() { diff --git a/escher/src/tab_view_controller.cpp b/escher/src/tab_view_controller.cpp index 542fac4bc..1fd66fbfb 100644 --- a/escher/src/tab_view_controller.cpp +++ b/escher/src/tab_view_controller.cpp @@ -118,16 +118,18 @@ void TabViewController::setActiveTab(int8_t i, bool forceReactive) { m_view.setActiveView(activeVC->view()); } m_view.m_tabView.setActiveIndex(i); - if (m_activeChildIndex >= 0 && m_activeChildIndex != i) { - m_children[m_activeChildIndex]->viewDidDisappear(); - m_children[m_activeChildIndex]->unloadView(); - } - m_activeChildIndex = i; if (i >= 0) { m_children[i]->viewWillAppear(); } } app()->setFirstResponder(activeVC); + if (i != m_activeChildIndex || forceReactive) { + if (m_activeChildIndex >= 0 && m_activeChildIndex != i) { + m_children[m_activeChildIndex]->viewDidDisappear(); + m_children[m_activeChildIndex]->unloadView(); + } + m_activeChildIndex = i; + } } void TabViewController::setSelectedTab(int8_t i) { diff --git a/ion/src/device/power.cpp b/ion/src/device/power.cpp index 98c696555..5110ac7f5 100644 --- a/ion/src/device/power.cpp +++ b/ion/src/device/power.cpp @@ -1,5 +1,4 @@ #include -#include "regs/regs.h" #include "battery.h" #include "device.h" #include "display.h" @@ -7,6 +6,7 @@ #include "led.h" #include "usb.h" #include "wakeup.h" +#include "regs/regs.h" void Ion::Power::suspend() { Device::shutdownPeripherals();