13
0

Lua may call C++ functions with throw. Catch them

This commit is contained in:
Robin Gareus 2017-08-19 01:05:18 +02:00
parent 2a9bf034bb
commit fb745cc5a8
4 changed files with 24 additions and 9 deletions

View File

@ -238,8 +238,7 @@ LuaProc::load_script ()
try {
lua_dsp_init (_session.nominal_frame_rate ());
} catch (luabridge::LuaException const& e) {
;
}
} catch (...) { }
}
_ctrl_params.clear ();
@ -354,6 +353,8 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan
}
} catch (luabridge::LuaException const& e) {
_iotable = NULL;
} catch (...) {
_iotable = NULL;
}
}
@ -584,6 +585,8 @@ LuaProc::configure_io (ChanCount in, ChanCount out)
std::cerr << "LuaException: " << e.what () << "\n";
#endif
return false;
} catch (...) {
return false;
}
}
}
@ -734,6 +737,8 @@ LuaProc::connect_and_run (BufferSet& bufs,
std::cerr << "LuaException: " << e.what () << "\n";
#endif
return -1;
} catch (...) {
return -1;
}
#ifdef WITH_LUAPROC_STATS
int64_t t1 = g_get_monotonic_time ();

View File

@ -385,7 +385,7 @@ LuaScriptParams::script_params (const std::string& s, const std::string &pname,
} else {
lua.do_command (s);
}
} catch (luabridge::LuaException const& e) {
} catch (...) {
return rv;
}
@ -482,7 +482,7 @@ LuaScripting::try_compile (const std::string& script, const LuaScriptParamList&
cerr << e.what() << "\n";
#endif
lua_print (e.what());
}
} catch (...) { }
return false;
}
@ -513,7 +513,7 @@ LuaScripting::get_factory_bytecode (const std::string& script, const std::string
if (lua_factory.isFunction()) {
return (lua_dump(lua_factory)).cast<std::string> ();
}
} catch (luabridge::LuaException const& e) { }
} catch (...) { }
return "";
}

View File

@ -5513,7 +5513,7 @@ Session::registered_lua_functions ()
if (!i.key ().isString ()) { assert(0); continue; }
rv.push_back (i.key ().cast<std::string> ());
}
} catch (luabridge::LuaException const& e) { }
} catch (...) { }
return rv;
}
@ -5529,7 +5529,7 @@ Session::try_run_lua (pframes_t nframes)
if (_n_lua_scripts == 0) return;
Glib::Threads::Mutex::Lock tm (lua_lock, Glib::Threads::TRY_LOCK);
if (tm.locked ()) {
try { (*_lua_run)(nframes); } catch (luabridge::LuaException const& e) { }
try { (*_lua_run)(nframes); } catch (...) { }
lua.collect_garbage_step ();
}
}
@ -5661,7 +5661,12 @@ Session::setup_lua ()
_lua_cleanup = new luabridge::LuaRef(lua_sess["cleanup"]);
} catch (luabridge::LuaException const& e) {
fatal << string_compose (_("programming error: %1"),
X_("Failed to setup Lua interpreter"))
std::string ("Failed to setup session Lua interpreter") + e.what ())
<< endmsg;
abort(); /*NOTREACHED*/
} catch (...) {
fatal << string_compose (_("programming error: %1"),
X_("Failed to setup session Lua interpreter"))
<< endmsg;
abort(); /*NOTREACHED*/
}
@ -5687,6 +5692,11 @@ Session::scripts_changed ()
}
_n_lua_scripts = cnt;
} catch (luabridge::LuaException const& e) {
fatal << string_compose (_("programming error: %1"),
std::string ("Indexing Lua Session Scripts failed.") + e.what ())
<< endmsg;
abort(); /*NOTREACHED*/
} catch (...) {
fatal << string_compose (_("programming error: %1"),
X_("Indexing Lua Session Scripts failed."))
<< endmsg;

View File

@ -1683,7 +1683,7 @@ Session::set_state (const XMLNode& node, int version)
(*_lua_load)(std::string ((const char*)buf, size));
} catch (luabridge::LuaException const& e) {
cerr << "LuaException:" << e.what () << endl;
}
} catch (...) { }
g_free (buf);
}
}