Create sidechain ports when created from template (#0007680)
[ardour.git] / libs / ardour / luascripting.cc
index e2fc9d49f109a5c2572cf7648e771c6ed3430dc0..e748fb656e792752bbb0792bb0f7eca2b2fd3ee0 100644 (file)
@@ -262,7 +262,7 @@ LuaScripting::scan_script (const std::string &fn, const std::string &sc)
                try {
                        std::string script = Glib::file_get_contents (fn);
                        sha1_write (&s, (const uint8_t *) script.c_str(), script.size ());
-               } catch (Glib::FileError err) {
+               } catch (Glib::FileError const& err) {
                        return LuaScriptInfoPtr();
                }
        }
@@ -294,9 +294,11 @@ LuaScripting::scan_script (const std::string &fn, const std::string &sc)
 
                luabridge::LuaRef lua_ss = luabridge::getGlobal (L, "session_setup");
                if (lua_ss.isFunction ()) {
-                       if (lua_ss () == true) {
-                               lsi->subtype |= LuaScriptInfo::SessionSetup;
-                       }
+                       try {
+                               if (lua_ss () == true) {
+                                       lsi->subtype |= LuaScriptInfo::SessionSetup;
+                               }
+                       } catch (...) { }
                }
 
        }
@@ -371,10 +373,16 @@ LuaScriptParams::script_params (const LuaScriptInfoPtr& lsi, const std::string &
 
 LuaScriptParamList
 LuaScriptParams::script_params (const std::string& s, const std::string &pname, bool file)
+{
+       LuaState lua;
+       return LuaScriptParams::script_params (lua, s, pname, file);
+}
+
+LuaScriptParamList
+LuaScriptParams::script_params (LuaState& lua, const std::string& s, const std::string &pname, bool file)
 {
        LuaScriptParamList rv;
 
-       LuaState lua;
        lua_State* L = lua.getState();
        lua.sandbox (true);
        lua.do_command ("function ardour () end");
@@ -385,7 +393,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;
        }
 
@@ -402,6 +410,7 @@ LuaScriptParams::script_params (const std::string& s, const std::string &pname,
                                std::string title = i.value ()["title"].cast<std::string> ();
                                std::string dflt;
                                bool optional = false;
+                               bool preseeded = false;
 
                                if (i.value ()["default"].isString ()) {
                                        dflt = i.value ()["default"].cast<std::string> ();
@@ -409,7 +418,10 @@ LuaScriptParams::script_params (const std::string& s, const std::string &pname,
                                if (i.value ()["optional"].isBoolean ()) {
                                        optional = i.value ()["optional"].cast<bool> ();
                                }
-                               LuaScriptParamPtr lsspp (new LuaScriptParam(name, title, dflt, optional));
+                               if (i.value ()["preseeded"].isBoolean ()) {
+                                       preseeded = i.value ()["preseeded"].cast<bool> ();
+                               }
+                               LuaScriptParamPtr lsspp (new LuaScriptParam(name, title, dflt, optional, preseeded));
                                rv.push_back (lsspp);
                        }
                }
@@ -482,7 +494,7 @@ LuaScripting::try_compile (const std::string& script, const LuaScriptParamList&
                cerr << e.what() << "\n";
 #endif
                lua_print (e.what());
-       }
+       } catch (...) { }
 
        return false;
 }
@@ -513,7 +525,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 "";
 }