summaryrefslogtreecommitdiff
path: root/src/actions.cpp
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2013-07-13 19:04:22 +0200
committerAndrzej Rybczak <electricityispower@gmail.com>2013-07-13 19:04:22 +0200
commit7167d036d048521e8e38d3ae0bb51fa7d6187539 (patch)
tree1985cb51c8f5def17780a0aaa2dc64f669b7d0c4 /src/actions.cpp
parentfb9df0caee164330322d94df67e3d7c74d2fc9db (diff)
actions: require action to be non-null if we query by action type
Diffstat (limited to 'src/actions.cpp')
-rw-r--r--src/actions.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/actions.cpp b/src/actions.cpp
index 27c51bc6..5f6811c9 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -282,11 +282,14 @@ bool isMPDMusicDirSet()
return true;
}
-BaseAction *get(Actions::Type at)
+BaseAction &get(Actions::Type at)
{
if (AvailableActions.empty())
populateActions();
- return AvailableActions[at];
+ BaseAction *action = AvailableActions[at];
+ // action should be always present if action type in queried
+ assert(action != nullptr);
+ return *action;
}
BaseAction *get(const std::string &name)
@@ -348,9 +351,9 @@ void MouseEvent::run()
) // volume
{
if (m_mouse_event.bstate & BUTTON2_PRESSED)
- get(Type::VolumeDown)->execute();
+ get(Type::VolumeDown).execute();
else
- get(Type::VolumeUp)->execute();
+ get(Type::VolumeUp).execute();
}
else if (m_mouse_event.bstate & (BUTTON1_PRESSED | BUTTON2_PRESSED | BUTTON3_PRESSED | BUTTON4_PRESSED))
myScreen->mouseButtonPressed(m_mouse_event);
@@ -2573,8 +2576,8 @@ void seek()
int old_timeout = wFooter->getTimeout();
wFooter->setTimeout(500);
- auto seekForward = Actions::get(Actions::Type::SeekForward);
- auto seekBackward = Actions::get(Actions::Type::SeekBackward);
+ auto seekForward = &Actions::get(Actions::Type::SeekForward);
+ auto seekBackward = &Actions::get(Actions::Type::SeekBackward);
SeekingInProgress = true;
while (true)