Skip to content

Commit

Permalink
MidiAction: fix handleActions (hydrogen-music#1751)
Browse files Browse the repository at this point in the history
While adding a handler function allowing to process multiple actions at once I seem to misinterpreted the intention of `handleAction`s return value.

The value returned by `handleActions` does now indicate whether an action was successfully processed and thus the event triggering the action should be consumed.
  • Loading branch information
theGreatWhiteShark committed May 8, 2023
1 parent 0f5577f commit 15a8075
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/core/MidiAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1228,12 +1228,12 @@ int MidiActionManager::getParameterNumber( const QString& sActionType ) const {

bool MidiActionManager::handleActions( std::vector<std::shared_ptr<Action>> actions ) {

bool bResult = true;
bool bResult = false;

for ( const auto& action : actions ) {
if ( action != nullptr ) {
if ( ! handleAction( action ) ) {
bResult = false;
if ( handleAction( action ) ) {
bResult = true;
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/core/MidiAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,19 @@ class MidiActionManager : public H2Core::Object<MidiActionManager>
* Handles multiple actions at once and calls handleAction()
* on them.
*
* \return true - in case all actions were successful, false - otherwise.
* \return true - if at least one Action was handled
* successfully. Calling functions should treat the event
* resulting in @a actions as consumed.
*/
bool handleActions( std::vector<std::shared_ptr<Action>> );
bool handleActions( std::vector<std::shared_ptr<Action>> actions );
/**
* The handleAction method is the heart of the
* MidiActionManager class. It executes the operations that
* are needed to carry the desired action.
*
* @return true - if @a action was handled successfully.
*/
bool handleAction( std::shared_ptr<Action> );
bool handleAction( std::shared_ptr<Action> action );
/**
* If #__instance equals 0, a new MidiActionManager
* singleton will be created and stored in it.
Expand Down

0 comments on commit 15a8075

Please sign in to comment.