Minor refactoring
All checks were successful
Build and Publish WASM version of demo / Build-And-Deploy (push) Successful in 17s
All checks were successful
Build and Publish WASM version of demo / Build-And-Deploy (push) Successful in 17s
Prevent creating a screen-less PendingAction with invalid type.
This commit is contained in:
parent
89e19cf084
commit
ff03f30809
1 changed files with 15 additions and 1 deletions
|
@ -14,7 +14,21 @@ Screen::Screen(std::weak_ptr<ScreenStack> stack) : stack(stack) {}
|
||||||
ScreenStack::PendingAction::PendingAction() : screen(), action(Action::NOP) {}
|
ScreenStack::PendingAction::PendingAction() : screen(), action(Action::NOP) {}
|
||||||
|
|
||||||
ScreenStack::PendingAction::PendingAction(Action action)
|
ScreenStack::PendingAction::PendingAction(Action action)
|
||||||
: screen(), action(action) {}
|
: screen(), action(action) {
|
||||||
|
switch (action) {
|
||||||
|
case Action::PUSH_SCREEN:
|
||||||
|
case Action::CONSTRUCT_SCREEN:
|
||||||
|
// Cannot push non-existant screen.
|
||||||
|
this->action = Action::NOP;
|
||||||
|
#ifndef NDEBUG
|
||||||
|
std::clog << "WARNING: Cannot create PendingAction with PUSH_SCREEN or "
|
||||||
|
"CONSTRUCT_SCREEN!\n";
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ScreenStack::PendingAction::PendingAction(Screen::Ptr &&screen)
|
ScreenStack::PendingAction::PendingAction(Screen::Ptr &&screen)
|
||||||
: screen(std::forward<Screen::Ptr>(screen)), action(Action::PUSH_SCREEN) {}
|
: screen(std::forward<Screen::Ptr>(screen)), action(Action::PUSH_SCREEN) {}
|
||||||
|
|
Loading…
Reference in a new issue