Lua may call C++ functions with throw. Catch them
This commit is contained in:
parent
fb745cc5a8
commit
2cc32456ab
|
@ -3927,8 +3927,7 @@ ARDOUR_UI::route_setup_info (const std::string& script_path)
|
|||
}
|
||||
} catch (luabridge::LuaException const& e) {
|
||||
cerr << "LuaException:" << e.what () << endl;
|
||||
return rv;
|
||||
}
|
||||
} catch (...) { }
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -3976,6 +3975,8 @@ ARDOUR_UI::meta_route_setup (const std::string& script_path)
|
|||
}
|
||||
} catch (luabridge::LuaException const& e) {
|
||||
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) {
|
||||
cerr << "LuaException:" << e.what () << endl;
|
||||
} catch (...) {
|
||||
display_insufficient_ports_message ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1161,6 +1161,11 @@ LuaInstance::init ()
|
|||
_lua_clear = new luabridge::LuaRef(lua_mgr["clear"]);
|
||||
|
||||
} 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"),
|
||||
X_("Failed to setup Lua action interpreter"))
|
||||
<< endmsg;
|
||||
|
@ -1229,7 +1234,7 @@ LuaInstance::set_state (const XMLNode& node)
|
|||
(*_lua_load)(std::string ((const char*)buf, size));
|
||||
} catch (luabridge::LuaException const& e) {
|
||||
cerr << "LuaException:" << e.what () << endl;
|
||||
}
|
||||
} catch (...) { }
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
std::string 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 */
|
||||
} catch (luabridge::LuaException const& e) {
|
||||
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 ());
|
||||
Gtk::MessageDialog am (msg);
|
||||
am.run ();
|
||||
} catch (...) {
|
||||
string msg = string_compose (_("Loading Session script '%1' failed: %2"), spd.name(), "Unknown Exception");
|
||||
Gtk::MessageDialog am (msg);
|
||||
am.run ();
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
@ -1386,7 +1395,7 @@ LuaInstance::call_action (const int id)
|
|||
lua.collect_garbage_step ();
|
||||
} catch (luabridge::LuaException const& e) {
|
||||
cerr << "LuaException:" << e.what () << endl;
|
||||
}
|
||||
} catch (...) { }
|
||||
}
|
||||
|
||||
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);
|
||||
} catch (luabridge::LuaException const& e) {
|
||||
cerr << "LuaException:" << e.what () << endl;
|
||||
}
|
||||
} catch (...) { }
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1429,6 +1438,8 @@ LuaInstance::set_lua_action (
|
|||
} catch (luabridge::LuaException const& e) {
|
||||
cerr << "LuaException:" << e.what () << endl;
|
||||
return false;
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
_session->set_dirty ();
|
||||
return true;
|
||||
|
@ -1442,6 +1453,8 @@ LuaInstance::remove_lua_action (const int id)
|
|||
} catch (luabridge::LuaException const& e) {
|
||||
cerr << "LuaException:" << e.what () << endl;
|
||||
return false;
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
ActionChanged (id, ""); /* EMIT SIGNAL */
|
||||
_session->set_dirty ();
|
||||
|
@ -1463,8 +1476,7 @@ LuaInstance::lua_action_name (const int id, std::string& rv)
|
|||
return true;
|
||||
} catch (luabridge::LuaException const& e) {
|
||||
cerr << "LuaException:" << e.what () << endl;
|
||||
return false;
|
||||
}
|
||||
} catch (...) { }
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1494,7 +1506,7 @@ LuaInstance::lua_action_has_icon (const int id)
|
|||
}
|
||||
} catch (luabridge::LuaException const& e) {
|
||||
cerr << "LuaException:" << e.what () << endl;
|
||||
}
|
||||
} catch (...) { }
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1529,8 +1541,7 @@ LuaInstance::lua_action (const int id, std::string& name, std::string& script, L
|
|||
return true;
|
||||
} catch (luabridge::LuaException const& e) {
|
||||
cerr << "LuaException:" << e.what () << endl;
|
||||
return false;
|
||||
}
|
||||
} catch (...) { }
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1553,7 +1564,7 @@ LuaInstance::register_lua_slot (const std::string& name, const std::string& scri
|
|||
}
|
||||
} catch (luabridge::LuaException const& e) {
|
||||
cerr << "LuaException:" << e.what () << endl;
|
||||
}
|
||||
} catch (...) { }
|
||||
|
||||
if (ah.none ()) {
|
||||
cerr << "Script registered no hooks." << endl;
|
||||
|
@ -1570,7 +1581,7 @@ LuaInstance::register_lua_slot (const std::string& name, const std::string& scri
|
|||
return true;
|
||||
} catch (luabridge::LuaException const& e) {
|
||||
cerr << "LuaException:" << e.what () << endl;
|
||||
}
|
||||
} catch (...) { }
|
||||
_session->set_dirty ();
|
||||
return false;
|
||||
}
|
||||
|
@ -1656,11 +1667,13 @@ LuaCallback::LuaCallback (Session *s,
|
|||
}
|
||||
|
||||
try {
|
||||
const std::string& bytecode = LuaScripting::get_factory_bytecode (script);
|
||||
(*_lua_add)(name, script, bytecode, tbl_arg);
|
||||
const std::string& bytecode = LuaScripting::get_factory_bytecode (script);
|
||||
(*_lua_add)(name, script, bytecode, tbl_arg);
|
||||
} catch (luabridge::LuaException const& e) {
|
||||
cerr << "LuaException:" << e.what () << endl;
|
||||
throw failed_constructor ();
|
||||
} catch (...) {
|
||||
throw failed_constructor ();
|
||||
}
|
||||
|
||||
_id.reset ();
|
||||
|
@ -1699,7 +1712,7 @@ LuaCallback::LuaCallback (Session *s, XMLNode & node)
|
|||
(*_lua_load)(std::string ((const char*)buf, size));
|
||||
} catch (luabridge::LuaException const& e) {
|
||||
cerr << "LuaException:" << e.what () << endl;
|
||||
}
|
||||
} catch (...) { }
|
||||
g_free (buf);
|
||||
|
||||
set_session (s);
|
||||
|
@ -1859,6 +1872,11 @@ LuaCallback::init (void)
|
|||
_lua_load = new luabridge::LuaRef(lua_mgr["restore"]);
|
||||
|
||||
} 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"),
|
||||
X_("Failed to setup Lua callback interpreter"))
|
||||
<< endmsg;
|
||||
|
@ -1907,7 +1925,7 @@ LuaCallback::lua_slot (std::string& name, std::string& script, ActionHook& ah, A
|
|||
} catch (luabridge::LuaException const& e) {
|
||||
cerr << "LuaException:" << e.what () << endl;
|
||||
return false;
|
||||
}
|
||||
} catch (...) { }
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -286,6 +286,12 @@ LuaWindow::run_script ()
|
|||
}
|
||||
} catch (luabridge::LuaException const& e) {
|
||||
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 {
|
||||
// script with factory method
|
||||
|
@ -304,6 +310,12 @@ LuaWindow::run_script ()
|
|||
lua->do_command ("factory = nil;");
|
||||
} catch (luabridge::LuaException const& e) {
|
||||
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
|
||||
cerr << "LuaException:" << e.what () << endl;
|
||||
#endif
|
||||
}
|
||||
} catch (...) { }
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -221,8 +221,11 @@ SessionDialog::meta_master_bus_profile (std::string script_path) const
|
|||
err = lua.do_file (script_path);
|
||||
} catch (luabridge::LuaException const& e) {
|
||||
err = -1;
|
||||
} catch (...) {
|
||||
err = -1;
|
||||
}
|
||||
|
||||
|
||||
if (err) {
|
||||
return UINT32_MAX;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user