From bd463e887aa21f467cd6815658f65fe9e6aa3f57 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 12 Apr 2016 00:32:18 +0200 Subject: [PATCH] improve luawindow save/load/revert --- gtk2_ardour/luawindow.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/luawindow.cc b/gtk2_ardour/luawindow.cc index 155c6908ac..b841b3b6ea 100644 --- a/gtk2_ardour/luawindow.cc +++ b/gtk2_ardour/luawindow.cc @@ -605,7 +605,7 @@ LuaWindow::script_selection_changed (ScriptBufferPtr n, bool force) Glib::RefPtr tb (entry.get_buffer()); - if ((n->flags & Buffer_Valid)) { + if (_current_buffer->flags & Buffer_Valid) { _current_buffer->script = tb->get_text(); } @@ -671,6 +671,7 @@ LuaWindow::ScriptBuffer::ScriptBuffer (const std::string& n) , flags (Buffer_Scratch | Buffer_Valid) { script = + "---- this header is (only) required to save the script\n" "-- ardour { [\"type\"] = \"Snippet\", name = \"\" }\n" "-- function factory () return function () -- -- end end\n"; } @@ -708,11 +709,12 @@ LuaWindow::ScriptBuffer::~ScriptBuffer () bool LuaWindow::ScriptBuffer::load () { + assert (!(flags & Buffer_Valid)); if (!(flags & Buffer_HasFile)) return false; - if (flags & Buffer_Valid) return true; try { script = Glib::file_get_contents (path); flags |= Buffer_Valid; + flags &= BufferFlags(~Buffer_Dirty); } catch (Glib::FileError e) { return false; }