mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 23:05:04 +01:00
Lua may call C++ functions with throw. Catch them
This commit is contained in:
parent
fb745cc5a8
commit
2cc32456ab
5 changed files with 54 additions and 18 deletions
|
|
@ -3927,8 +3927,7 @@ ARDOUR_UI::route_setup_info (const std::string& script_path)
|
||||||
}
|
}
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
cerr << "LuaException:" << e.what () << endl;
|
cerr << "LuaException:" << e.what () << endl;
|
||||||
return rv;
|
} catch (...) { }
|
||||||
}
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3976,6 +3975,8 @@ ARDOUR_UI::meta_route_setup (const std::string& script_path)
|
||||||
}
|
}
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
cerr << "LuaException:" << e.what () << endl;
|
cerr << "LuaException:" << e.what () << endl;
|
||||||
|
} catch (...) {
|
||||||
|
display_insufficient_ports_message ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4006,6 +4007,8 @@ ARDOUR_UI::meta_session_setup (const std::string& script_path)
|
||||||
}
|
}
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
cerr << "LuaException:" << e.what () << endl;
|
cerr << "LuaException:" << e.what () << endl;
|
||||||
|
} catch (...) {
|
||||||
|
display_insufficient_ports_message ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1161,6 +1161,11 @@ LuaInstance::init ()
|
||||||
_lua_clear = new luabridge::LuaRef(lua_mgr["clear"]);
|
_lua_clear = new luabridge::LuaRef(lua_mgr["clear"]);
|
||||||
|
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
|
fatal << string_compose (_("programming error: %1"),
|
||||||
|
std::string ("Failed to setup Lua action interpreter") + e.what ())
|
||||||
|
<< endmsg;
|
||||||
|
abort(); /*NOTREACHED*/
|
||||||
|
} catch (...) {
|
||||||
fatal << string_compose (_("programming error: %1"),
|
fatal << string_compose (_("programming error: %1"),
|
||||||
X_("Failed to setup Lua action interpreter"))
|
X_("Failed to setup Lua action interpreter"))
|
||||||
<< endmsg;
|
<< endmsg;
|
||||||
|
|
@ -1229,7 +1234,7 @@ LuaInstance::set_state (const XMLNode& node)
|
||||||
(*_lua_load)(std::string ((const char*)buf, size));
|
(*_lua_load)(std::string ((const char*)buf, size));
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
cerr << "LuaException:" << e.what () << endl;
|
cerr << "LuaException:" << e.what () << endl;
|
||||||
}
|
} catch (...) { }
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
std::string name;
|
std::string name;
|
||||||
if (lua_action_name (i, name)) {
|
if (lua_action_name (i, name)) {
|
||||||
|
|
@ -1249,7 +1254,7 @@ LuaInstance::set_state (const XMLNode& node)
|
||||||
SlotChanged (p->id(), p->name(), p->signals()); /* EMIT SIGNAL */
|
SlotChanged (p->id(), p->name(), p->signals()); /* EMIT SIGNAL */
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
cerr << "LuaException:" << e.what () << endl;
|
cerr << "LuaException:" << e.what () << endl;
|
||||||
}
|
} catch (...) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1340,6 +1345,10 @@ LuaInstance::interactive_add (LuaScriptInfo::ScriptType type, int id)
|
||||||
string msg = string_compose (_("Loading Session script '%1' failed: %2"), spd.name(), e.what ());
|
string msg = string_compose (_("Loading Session script '%1' failed: %2"), spd.name(), e.what ());
|
||||||
Gtk::MessageDialog am (msg);
|
Gtk::MessageDialog am (msg);
|
||||||
am.run ();
|
am.run ();
|
||||||
|
} catch (...) {
|
||||||
|
string msg = string_compose (_("Loading Session script '%1' failed: %2"), spd.name(), "Unknown Exception");
|
||||||
|
Gtk::MessageDialog am (msg);
|
||||||
|
am.run ();
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
@ -1386,7 +1395,7 @@ LuaInstance::call_action (const int id)
|
||||||
lua.collect_garbage_step ();
|
lua.collect_garbage_step ();
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
cerr << "LuaException:" << e.what () << endl;
|
cerr << "LuaException:" << e.what () << endl;
|
||||||
}
|
} catch (...) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -1403,7 +1412,7 @@ LuaInstance::render_icon (int i, cairo_t* cr, int w, int h, uint32_t clr)
|
||||||
(*_lua_render_icon)(i + 1, (Cairo::Context *)&ctx, w, h, clr);
|
(*_lua_render_icon)(i + 1, (Cairo::Context *)&ctx, w, h, clr);
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
cerr << "LuaException:" << e.what () << endl;
|
cerr << "LuaException:" << e.what () << endl;
|
||||||
}
|
} catch (...) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
@ -1429,6 +1438,8 @@ LuaInstance::set_lua_action (
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
cerr << "LuaException:" << e.what () << endl;
|
cerr << "LuaException:" << e.what () << endl;
|
||||||
return false;
|
return false;
|
||||||
|
} catch (...) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
_session->set_dirty ();
|
_session->set_dirty ();
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1442,6 +1453,8 @@ LuaInstance::remove_lua_action (const int id)
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
cerr << "LuaException:" << e.what () << endl;
|
cerr << "LuaException:" << e.what () << endl;
|
||||||
return false;
|
return false;
|
||||||
|
} catch (...) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
ActionChanged (id, ""); /* EMIT SIGNAL */
|
ActionChanged (id, ""); /* EMIT SIGNAL */
|
||||||
_session->set_dirty ();
|
_session->set_dirty ();
|
||||||
|
|
@ -1463,8 +1476,7 @@ LuaInstance::lua_action_name (const int id, std::string& rv)
|
||||||
return true;
|
return true;
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
cerr << "LuaException:" << e.what () << endl;
|
cerr << "LuaException:" << e.what () << endl;
|
||||||
return false;
|
} catch (...) { }
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1494,7 +1506,7 @@ LuaInstance::lua_action_has_icon (const int id)
|
||||||
}
|
}
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
cerr << "LuaException:" << e.what () << endl;
|
cerr << "LuaException:" << e.what () << endl;
|
||||||
}
|
} catch (...) { }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1529,8 +1541,7 @@ LuaInstance::lua_action (const int id, std::string& name, std::string& script, L
|
||||||
return true;
|
return true;
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
cerr << "LuaException:" << e.what () << endl;
|
cerr << "LuaException:" << e.what () << endl;
|
||||||
return false;
|
} catch (...) { }
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1553,7 +1564,7 @@ LuaInstance::register_lua_slot (const std::string& name, const std::string& scri
|
||||||
}
|
}
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
cerr << "LuaException:" << e.what () << endl;
|
cerr << "LuaException:" << e.what () << endl;
|
||||||
}
|
} catch (...) { }
|
||||||
|
|
||||||
if (ah.none ()) {
|
if (ah.none ()) {
|
||||||
cerr << "Script registered no hooks." << endl;
|
cerr << "Script registered no hooks." << endl;
|
||||||
|
|
@ -1570,7 +1581,7 @@ LuaInstance::register_lua_slot (const std::string& name, const std::string& scri
|
||||||
return true;
|
return true;
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
cerr << "LuaException:" << e.what () << endl;
|
cerr << "LuaException:" << e.what () << endl;
|
||||||
}
|
} catch (...) { }
|
||||||
_session->set_dirty ();
|
_session->set_dirty ();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1661,6 +1672,8 @@ LuaCallback::LuaCallback (Session *s,
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
cerr << "LuaException:" << e.what () << endl;
|
cerr << "LuaException:" << e.what () << endl;
|
||||||
throw failed_constructor ();
|
throw failed_constructor ();
|
||||||
|
} catch (...) {
|
||||||
|
throw failed_constructor ();
|
||||||
}
|
}
|
||||||
|
|
||||||
_id.reset ();
|
_id.reset ();
|
||||||
|
|
@ -1699,7 +1712,7 @@ LuaCallback::LuaCallback (Session *s, XMLNode & node)
|
||||||
(*_lua_load)(std::string ((const char*)buf, size));
|
(*_lua_load)(std::string ((const char*)buf, size));
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
cerr << "LuaException:" << e.what () << endl;
|
cerr << "LuaException:" << e.what () << endl;
|
||||||
}
|
} catch (...) { }
|
||||||
g_free (buf);
|
g_free (buf);
|
||||||
|
|
||||||
set_session (s);
|
set_session (s);
|
||||||
|
|
@ -1859,6 +1872,11 @@ LuaCallback::init (void)
|
||||||
_lua_load = new luabridge::LuaRef(lua_mgr["restore"]);
|
_lua_load = new luabridge::LuaRef(lua_mgr["restore"]);
|
||||||
|
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
|
fatal << string_compose (_("programming error: %1"),
|
||||||
|
std::string ("Failed to setup Lua callback interpreter: ") + e.what ())
|
||||||
|
<< endmsg;
|
||||||
|
abort(); /*NOTREACHED*/
|
||||||
|
} catch (...) {
|
||||||
fatal << string_compose (_("programming error: %1"),
|
fatal << string_compose (_("programming error: %1"),
|
||||||
X_("Failed to setup Lua callback interpreter"))
|
X_("Failed to setup Lua callback interpreter"))
|
||||||
<< endmsg;
|
<< endmsg;
|
||||||
|
|
@ -1907,7 +1925,7 @@ LuaCallback::lua_slot (std::string& name, std::string& script, ActionHook& ah, A
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
cerr << "LuaException:" << e.what () << endl;
|
cerr << "LuaException:" << e.what () << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
} catch (...) { }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -286,6 +286,12 @@ LuaWindow::run_script ()
|
||||||
}
|
}
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
append_text (string_compose (_("LuaException: %1"), e.what()));
|
append_text (string_compose (_("LuaException: %1"), e.what()));
|
||||||
|
} catch (Glib::Exception const& e) {
|
||||||
|
append_text (string_compose (_("Glib Exception: %1"), e.what()));
|
||||||
|
} catch (std::exception const& e) {
|
||||||
|
append_text (string_compose (_("C++ Exception: %1"), e.what()));
|
||||||
|
} catch (...) {
|
||||||
|
append_text (string_compose (_("C++ Exception: %1"), "..."));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// script with factory method
|
// script with factory method
|
||||||
|
|
@ -304,6 +310,12 @@ LuaWindow::run_script ()
|
||||||
lua->do_command ("factory = nil;");
|
lua->do_command ("factory = nil;");
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
append_text (string_compose (_("LuaException: %1"), e.what()));
|
append_text (string_compose (_("LuaException: %1"), e.what()));
|
||||||
|
} catch (Glib::Exception const& e) {
|
||||||
|
append_text (string_compose (_("Glib Exception: %1"), e.what()));
|
||||||
|
} catch (std::exception const& e) {
|
||||||
|
append_text (string_compose (_("C++ Exception: %1"), e.what()));
|
||||||
|
} catch (...) {
|
||||||
|
append_text (string_compose (_("C++ Exception: %1"), "..."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1686,7 +1686,7 @@ ProcessorEntry::LuaPluginDisplay::render_inline (cairo_t *cr, uint32_t width)
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
cerr << "LuaException:" << e.what () << endl;
|
cerr << "LuaException:" << e.what () << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
} catch (...) { }
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -221,8 +221,11 @@ SessionDialog::meta_master_bus_profile (std::string script_path) const
|
||||||
err = lua.do_file (script_path);
|
err = lua.do_file (script_path);
|
||||||
} catch (luabridge::LuaException const& e) {
|
} catch (luabridge::LuaException const& e) {
|
||||||
err = -1;
|
err = -1;
|
||||||
|
} catch (...) {
|
||||||
|
err = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return UINT32_MAX;
|
return UINT32_MAX;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue