From 606d6de4b14a21833b6930c250d9a31a5293bac1 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 18 Apr 2020 18:13:32 +0200 Subject: Consistent Lua script error and print() output 2/2 --- gtk2_ardour/ardour_ui.cc | 13 +++++++++++-- gtk2_ardour/editor_actions.cc | 3 +++ gtk2_ardour/luainstance.cc | 42 ++++++++++++++++++++++++++++++++++++++++++ gtk2_ardour/processor_box.cc | 1 + gtk2_ardour/session_dialog.cc | 5 ++++- 5 files changed, 61 insertions(+), 3 deletions(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 7b55621ab9..9475e86d73 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -2237,9 +2237,9 @@ ARDOUR_UI::import_metadata () static void _lua_print (std::string s) { #ifndef NDEBUG - std::cout << "LuaInstance: " << s << "\n"; + std::cout << "LuaTemplate: " << s << "\n"; #endif - PBD::info << "LuaInstance: " << s << endmsg; + PBD::info << "LuaTemplate: " << s << endmsg; } std::map @@ -2283,7 +2283,10 @@ ARDOUR_UI::route_setup_info (const std::string& script_path) } } } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; } catch (...) { } return rv; } @@ -2331,7 +2334,10 @@ ARDOUR_UI::meta_route_setup (const std::string& script_path) fn (args)(); } } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; } catch (...) { display_insufficient_ports_message (); } @@ -2363,7 +2369,10 @@ ARDOUR_UI::meta_session_setup (const std::string& script_path) fn ()(); } } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; } catch (...) { display_insufficient_ports_message (); } diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index c735600324..dcf30724bd 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -811,7 +811,10 @@ Editor::trigger_script_by_name (const std::string script_name) fn (args)(); } } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; } catch (...) { cerr << "Lua script failed: " << script_path << endl; } diff --git a/gtk2_ardour/luainstance.cc b/gtk2_ardour/luainstance.cc index 775b94b5ca..2309e05325 100644 --- a/gtk2_ardour/luainstance.cc +++ b/gtk2_ardour/luainstance.cc @@ -1461,7 +1461,10 @@ LuaInstance::set_state (const XMLNode& node) try { (*_lua_load)(std::string ((const char*)buf, size)); } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; } catch (...) { } for (int i = 0; i < MAX_LUA_ACTION_SCRIPTS; ++i) { std::string name; @@ -1482,7 +1485,10 @@ LuaInstance::set_state (const XMLNode& node) p->drop_callback.connect (_slotcon, MISSING_INVALIDATOR, boost::bind (&LuaInstance::unregister_lua_slot, this, p->id()), gui_context()); SlotChanged (p->id(), p->name(), p->signals()); /* EMIT SIGNAL */ } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; } catch (...) { } } } @@ -1650,7 +1656,10 @@ LuaInstance::call_action (const int id) (*_lua_call_action)(id + 1); lua.collect_garbage_step (); } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; } catch (...) { } } @@ -1667,7 +1676,10 @@ LuaInstance::render_icon (int i, cairo_t* cr, int w, int h, uint32_t clr) try { (*_lua_render_icon)(i + 1, (Cairo::Context *)&ctx, w, h, clr); } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; } catch (...) { } } @@ -1692,7 +1704,10 @@ LuaInstance::set_lua_action ( (*_lua_add_action)(id + 1, name, script, bytecode, iconfunc, tbl_arg); ActionChanged (id, name); /* EMIT SIGNAL */ } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; return false; } catch (...) { return false; @@ -1707,7 +1722,10 @@ LuaInstance::remove_lua_action (const int id) try { (*_lua_del_action)(id + 1); } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; return false; } catch (...) { return false; @@ -1731,7 +1749,10 @@ LuaInstance::lua_action_name (const int id, std::string& rv) } return true; } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; } catch (...) { } return false; } @@ -1761,7 +1782,10 @@ LuaInstance::lua_action_has_icon (const int id) return ref["icon"].cast(); } } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; } catch (...) { } return false; } @@ -1796,7 +1820,10 @@ LuaInstance::lua_action (const int id, std::string& name, std::string& script, L LuaScriptParams::ref_to_params (args, &rargs); return true; } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; } catch (...) { } return false; } @@ -1819,7 +1846,10 @@ LuaInstance::register_lua_slot (const std::string& name, const std::string& scri ah = signals(); } } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; } catch (...) { } if (ah.none ()) { @@ -1837,7 +1867,10 @@ LuaInstance::register_lua_slot (const std::string& name, const std::string& scri set_dirty (); return true; } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; } catch (...) { } return false; } @@ -1926,7 +1959,10 @@ LuaCallback::LuaCallback (Session *s, const std::string& bytecode = LuaScripting::get_factory_bytecode (script); (*_lua_add)(name, script, bytecode, tbl_arg); } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; throw failed_constructor (); } catch (...) { throw failed_constructor (); @@ -1967,7 +2003,10 @@ LuaCallback::LuaCallback (Session *s, XMLNode & node) try { (*_lua_load)(std::string ((const char*)buf, size)); } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; } catch (...) { } g_free (buf); @@ -2179,7 +2218,10 @@ LuaCallback::lua_slot (std::string& name, std::string& script, ActionHook& ah, A LuaScriptParams::ref_to_params (args, &rargs); return true; } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; return false; } catch (...) { } return false; diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index fcecfbe215..13a1dd2448 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -1740,6 +1740,7 @@ ProcessorEntry::LuaPluginDisplay::render_inline (cairo_t *cr, uint32_t width) #ifndef NDEBUG cerr << "LuaException:" << e.what () << endl; #endif + PBD::warning << "LuaException: " << e.what () << endmsg; } catch (...) { } return 0; } diff --git a/gtk2_ardour/session_dialog.cc b/gtk2_ardour/session_dialog.cc index be8b067b92..fd4d43d8b6 100644 --- a/gtk2_ardour/session_dialog.cc +++ b/gtk2_ardour/session_dialog.cc @@ -203,12 +203,15 @@ SessionDialog::meta_master_bus_profile (std::string script_path) try { err = lua.do_file (script_path); } catch (luabridge::LuaException const& e) { +#ifndef NDEBUG + cerr << "LuaException:" << e.what () << endl; +#endif + PBD::warning << "LuaException: " << e.what () << endmsg; err = -1; } catch (...) { err = -1; } - if (err) { return UINT32_MAX; } -- cgit v1.2.3