13
0

Abort when Action cast failed

Previously the action-manager only called ::abort() when
an action could no be found. This add a further restriction
that the expected class must match.
This commit is contained in:
Robin Gareus 2019-02-28 23:57:32 +01:00
parent 8244026533
commit fc7dc6a214
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -310,27 +310,34 @@ ActionManager::get_action (char const * group_name, char const * action_name, bo
RefPtr<ToggleAction>
ActionManager::get_toggle_action (char const * group_name, char const * action_name, bool or_die)
{
RefPtr<Action> act = get_action (group_name, action_name, or_die);
RefPtr<ToggleAction> act = Glib::RefPtr<ToggleAction>::cast_dynamic (get_action (group_name, action_name, or_die));
if (!act) {
return RefPtr<ToggleAction>();
if (act) {
return act;
}
return Glib::RefPtr<ToggleAction>::cast_dynamic (act);
if (or_die) {
::abort ();
}
return RefPtr<ToggleAction>();
}
RefPtr<RadioAction>
ActionManager::get_radio_action (char const * group_name, char const * action_name, bool or_die)
{
RefPtr<Action> act = get_action (group_name, action_name, or_die);
RefPtr<RadioAction> act = Glib::RefPtr<RadioAction>::cast_dynamic (get_action (group_name, action_name, or_die));
if (!act) {
return RefPtr<RadioAction>();
if (act) {
return act;
}
return Glib::RefPtr<RadioAction>::cast_dynamic (act);
}
if (or_die) {
::abort ();
}
return RefPtr<RadioAction>();
}
RefPtr<ActionGroup>
ActionManager::create_action_group (void * owner, string const & name)