mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 15:25:01 +01:00
use a new unhandled (thus far) exception rather than ::abort() when an action is undefined
This commit is contained in:
parent
a3986f703d
commit
21110444c1
2 changed files with 28 additions and 5 deletions
|
|
@ -70,6 +70,20 @@ typedef std::vector<ActionState> ActionStates;
|
||||||
static ActionStates action_states_to_restore;
|
static ActionStates action_states_to_restore;
|
||||||
static bool actions_disabled = false;
|
static bool actions_disabled = false;
|
||||||
|
|
||||||
|
|
||||||
|
ActionManager::MissingActionException::MissingActionException (std::string const & str)
|
||||||
|
: missing_action_name (str)
|
||||||
|
{
|
||||||
|
std::cerr << "MAE: " << str << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
ActionManager::MissingActionException::what () const throw ()
|
||||||
|
{
|
||||||
|
/* XXX memory leak */
|
||||||
|
return strdup (string_compose ("missing action: %1", missing_action_name).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ActionManager::init ()
|
ActionManager::init ()
|
||||||
{
|
{
|
||||||
|
|
@ -195,7 +209,7 @@ ActionManager::set_toggleaction_state (const string& n, bool s)
|
||||||
|
|
||||||
if (last_slash == 0) {
|
if (last_slash == 0) {
|
||||||
fatal << string_compose ("programmer error: %1 %2", "illegal toggle action name", name) << endmsg;
|
fatal << string_compose ("programmer error: %1 %2", "illegal toggle action name", name) << endmsg;
|
||||||
abort(); /*NOTREACHED*/
|
throw MissingActionException (n);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -254,7 +268,7 @@ ActionManager::get_action (const string& name, bool or_die)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (or_die) {
|
if (or_die) {
|
||||||
::abort ();
|
throw MissingActionException (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
cerr << "Failed to find action: [" << name << ']' << endl;
|
cerr << "Failed to find action: [" << name << ']' << endl;
|
||||||
|
|
@ -299,7 +313,7 @@ ActionManager::get_action (char const * group_name, char const * action_name, bo
|
||||||
}
|
}
|
||||||
|
|
||||||
if (or_die) {
|
if (or_die) {
|
||||||
::abort ();
|
throw MissingActionException (string_compose ("%1/%2", group_name, action_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
cerr << "Failed to find action (2): [" << fullpath << ']' << endl;
|
cerr << "Failed to find action (2): [" << fullpath << ']' << endl;
|
||||||
|
|
@ -317,7 +331,7 @@ ActionManager::get_toggle_action (char const * group_name, char const * action_n
|
||||||
}
|
}
|
||||||
|
|
||||||
if (or_die) {
|
if (or_die) {
|
||||||
::abort ();
|
throw MissingActionException (string_compose ("%1/%2", group_name, action_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
return RefPtr<ToggleAction>();
|
return RefPtr<ToggleAction>();
|
||||||
|
|
@ -333,7 +347,7 @@ ActionManager::get_radio_action (char const * group_name, char const * action_na
|
||||||
}
|
}
|
||||||
|
|
||||||
if (or_die) {
|
if (or_die) {
|
||||||
::abort ();
|
throw MissingActionException (string_compose ("%1/%2", group_name, action_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
return RefPtr<RadioAction>();
|
return RefPtr<RadioAction>();
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#define __libgtkmm2ext_actions_h__
|
#define __libgtkmm2ext_actions_h__
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
#include <gtkmm/action.h>
|
#include <gtkmm/action.h>
|
||||||
#include <gtkmm/radioaction.h>
|
#include <gtkmm/radioaction.h>
|
||||||
|
|
@ -51,6 +52,14 @@ namespace ActionManager {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
class LIBGTKMM2EXT_API MissingActionException : public std::exception {
|
||||||
|
public:
|
||||||
|
MissingActionException (std::string const & str);
|
||||||
|
const char *what() const throw();
|
||||||
|
private:
|
||||||
|
std::string missing_action_name;
|
||||||
|
};
|
||||||
|
|
||||||
LIBGTKMM2EXT_API extern void init ();
|
LIBGTKMM2EXT_API extern void init ();
|
||||||
|
|
||||||
LIBGTKMM2EXT_API extern std::string unbound_string; /* the key string returned if an action is not bound */
|
LIBGTKMM2EXT_API extern std::string unbound_string; /* the key string returned if an action is not bound */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue