Fix load/save Lua Editor scripts
authorRobin Gareus <robin@gareus.org>
Mon, 12 Nov 2018 01:30:46 +0000 (02:30 +0100)
committerRobin Gareus <robin@gareus.org>
Mon, 12 Nov 2018 01:30:46 +0000 (02:30 +0100)
* callbacks are unregistered during session-deletion, skip saving them
  during session destruction.
* prevent duplicate state restore, re-load script with the session, not
  window instance.

gtk2_ardour/luainstance.cc

index 3a7285db6c2bc7d67fe51cf3d3da0f6d9d4638c3..4303794bfe7c52c0150ea1bd4b6b8174e134d998 100644 (file)
@@ -1095,8 +1095,6 @@ LuaInstance::LuaInstance ()
 {
        lua.Print.connect (&_lua_print);
        init ();
-
-       load_state ();
 }
 
 LuaInstance::~LuaInstance ()
@@ -1321,6 +1319,9 @@ LuaInstance::save_state ()
 void
 LuaInstance::set_dirty ()
 {
+       if (!_session || _session->deletion_in_progress()) {
+               return;
+       }
        save_state ();
        _session->set_dirty (); // XXX is this reasonable?
 }
@@ -1393,6 +1394,7 @@ LuaInstance::set_state (const XMLNode& node)
                }
        }
 
+       assert (_callbacks.empty());
        if ((child = find_named_node (node, "ActionHooks"))) {
                for (XMLNodeList::const_iterator n = child->children ().begin (); n != child->children ().end (); ++n) {
                        try {