mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps] Container::switchTo returns a bool (false if could not switch)
This commit is contained in:
committed by
EmilieNumworks
parent
4128ebb864
commit
a7208ade0f
@@ -152,18 +152,19 @@ bool AppsContainer::dispatchEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::USBEnumeration) {
|
||||
if (Ion::USB::isPlugged()) {
|
||||
App::Snapshot * activeSnapshot = (activeApp() == nullptr ? appSnapshotAtIndex(0) : activeApp()->snapshot());
|
||||
if (activeApp() == nullptr || activeApp()->prepareForExit()) {
|
||||
if (switchTo(usbConnectedAppSnapshot())) {
|
||||
/* Just after a software update, the battery timer does not have time to
|
||||
* fire before the calculator enters DFU mode. As the DFU mode blocks the
|
||||
* event loop, we update the battery state "manually" here. */
|
||||
updateBatteryState();
|
||||
switchTo(usbConnectedAppSnapshot());
|
||||
Ion::USB::DFU();
|
||||
switchTo(activeSnapshot);
|
||||
bool switched = switchTo(activeSnapshot);
|
||||
assert(switched);
|
||||
(void) switched; // Silence compilation warning about unused variable.
|
||||
didProcessEvent = true;
|
||||
} else {
|
||||
/* activeApp()->prepareForExit() returned false, which means that the
|
||||
* app needs another event loop to prepare for being switched off.
|
||||
/* We could not switch apps, which means that the current app needs
|
||||
* another event loop to prepare for being switched off.
|
||||
* Discard the current enumeration interruption.
|
||||
* The USB host tries a few times in a row to enumerate the device, so
|
||||
* hopefully the device will get another enumeration event soon and this
|
||||
@@ -222,7 +223,7 @@ bool AppsContainer::processEvent(Ion::Events::Event event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void AppsContainer::switchTo(App::Snapshot * snapshot) {
|
||||
bool AppsContainer::switchTo(App::Snapshot * snapshot) {
|
||||
if (activeApp() && snapshot != activeApp()->snapshot()) {
|
||||
resetShiftAlphaStatus();
|
||||
}
|
||||
@@ -234,7 +235,7 @@ void AppsContainer::switchTo(App::Snapshot * snapshot) {
|
||||
if (snapshot) {
|
||||
m_window.setTitle(snapshot->descriptor()->upperName());
|
||||
}
|
||||
Container::switchTo(snapshot);
|
||||
return Container::switchTo(snapshot);
|
||||
}
|
||||
|
||||
void AppsContainer::run() {
|
||||
@@ -251,15 +252,14 @@ void AppsContainer::run() {
|
||||
/* Normal execution. The exception checkpoint must be created before
|
||||
* switching to the first app, because the first app might create nodes on
|
||||
* the pool. */
|
||||
bool switched =
|
||||
#if EPSILON_ONBOARDING_APP
|
||||
switchTo(onBoardingAppSnapshot());
|
||||
switchTo(onBoardingAppSnapshot());
|
||||
#else
|
||||
if (numberOfApps() == 2) {
|
||||
switchTo(appSnapshotAtIndex(1));
|
||||
} else {
|
||||
switchTo(appSnapshotAtIndex(0));
|
||||
}
|
||||
switchTo(appSnapshotAtIndex(numberOfApps() == 2 ? 1 : 0));
|
||||
#endif
|
||||
assert(switched);
|
||||
(void) switched; // Silence compilation warning about unused variable.
|
||||
} else {
|
||||
// Exception
|
||||
if (activeApp() != nullptr) {
|
||||
@@ -276,7 +276,9 @@ void AppsContainer::run() {
|
||||
* history here, we will be stuck outside the calculation app. */
|
||||
activeApp()->snapshot()->reset();
|
||||
}
|
||||
switchTo(appSnapshotAtIndex(0));
|
||||
bool switched = switchTo(appSnapshotAtIndex(0));
|
||||
assert(switched);
|
||||
(void) switched; // Silence compilation warning about unused variable.
|
||||
Poincare::Tidy();
|
||||
activeApp()->displayWarning(I18n::Message::PoolMemoryFull1, I18n::Message::PoolMemoryFull2, true);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
VariableBoxController * variableBoxController();
|
||||
void suspend(bool checkIfPowerKeyReleased = false);
|
||||
virtual bool dispatchEvent(Ion::Events::Event event) override;
|
||||
void switchTo(App::Snapshot * snapshot) override;
|
||||
bool switchTo(App::Snapshot * snapshot) override;
|
||||
void run() override;
|
||||
bool updateBatteryState();
|
||||
void refreshPreferences();
|
||||
|
||||
@@ -41,7 +41,9 @@ PopUpController::ContentView::ContentView(Responder * parentResponder) :
|
||||
m_okButton(this, I18n::Message::Ok, Invocation([](void * context, void * sender) {
|
||||
PopUpController::ContentView * view = (PopUpController::ContentView *)context;
|
||||
AppsContainer * appsContainer = (AppsContainer *)view->app()->container();
|
||||
appsContainer->switchTo(appsContainer->hardwareTestAppSnapshot());
|
||||
bool switched = appsContainer->switchTo(appsContainer->hardwareTestAppSnapshot());
|
||||
assert(switched);
|
||||
(void) switched; // Silence compilation warning about unused variable.
|
||||
return true;
|
||||
}, this), KDFont::SmallFont),
|
||||
m_warningTextView(KDFont::SmallFont, I18n::Message::Warning, 0.5, 0.5, KDColorWhite, KDColorBlack),
|
||||
|
||||
@@ -58,7 +58,9 @@ Controller::Controller(Responder * parentResponder, ::AppsContainer * container,
|
||||
|
||||
bool Controller::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
||||
m_container->switchTo(m_container->appSnapshotAtIndex(m_selectionDataSource->selectedRow()*k_numberOfColumns+m_selectionDataSource->selectedColumn()+1));
|
||||
bool switched = m_container->switchTo(m_container->appSnapshotAtIndex(m_selectionDataSource->selectedRow()*k_numberOfColumns+m_selectionDataSource->selectedColumn()+1));
|
||||
assert(switched);
|
||||
(void) switched; // Silence compilation warning about unused variable.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,9 @@ bool PopUpController::handleEvent(Ion::Events::Event event) {
|
||||
app()->dismissModalViewController();
|
||||
AppsContainer * appsContainer = (AppsContainer *)app()->container();
|
||||
if (appsContainer->activeApp()->snapshot() == appsContainer->onBoardingAppSnapshot()) {
|
||||
appsContainer->switchTo(appsContainer->appSnapshotAtIndex(0));
|
||||
bool switched = appsContainer->switchTo(appsContainer->appSnapshotAtIndex(0));
|
||||
assert(switched);
|
||||
(void) switched; // Silence compilation warning about unused variable.
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
virtual void run();
|
||||
App * activeApp();
|
||||
virtual bool dispatchEvent(Ion::Events::Event event) override;
|
||||
virtual void switchTo(App::Snapshot * snapshot);
|
||||
virtual bool switchTo(App::Snapshot * snapshot);
|
||||
protected:
|
||||
virtual Window * window() = 0;
|
||||
private:
|
||||
|
||||
@@ -13,14 +13,14 @@ Container::~Container() {
|
||||
}
|
||||
}
|
||||
|
||||
void Container::switchTo(App::Snapshot * snapshot) {
|
||||
bool Container::switchTo(App::Snapshot * snapshot) {
|
||||
if (m_activeApp && snapshot == m_activeApp->snapshot()) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
if (m_activeApp && !m_activeApp->prepareForExit()) {
|
||||
/* activeApp()->prepareForExit() returned false, which means that the app
|
||||
* needs another event loop to prepare for being switched off. */
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (m_activeApp) {
|
||||
m_activeApp->willBecomeInactive();
|
||||
@@ -34,6 +34,7 @@ void Container::switchTo(App::Snapshot * snapshot) {
|
||||
m_activeApp->didBecomeActive(window());
|
||||
window()->redraw();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
App * Container::activeApp() {
|
||||
|
||||
Reference in New Issue
Block a user