From 1f20fbbad8cf9deda3743003bbc40b14ba06465d Mon Sep 17 00:00:00 2001 From: Hans Fugal Date: Sat, 12 Aug 2006 21:57:07 +0000 Subject: [PATCH 1/8] merge from trunk git-svn-id: svn://localhost/ardour2/branches/undo@802 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/SConscript | 7 ++ gtk2_ardour/au_pluginui.cc | 125 +++++++++++++++++++++++++++++--- gtk2_ardour/au_pluginui.h | 48 ++++++++++++ gtk2_ardour/audio_time_axis.cc | 2 - gtk2_ardour/mixer_strip.cc | 2 - gtk2_ardour/plugin_ui.cc | 1 + gtk2_ardour/plugin_ui.h | 14 +--- gtk2_ardour/redirect_box.cc | 5 +- gtk2_ardour/region_view.cc | 8 +- gtk2_ardour/route_time_axis.cc | 2 - libs/ardour/ardour/audio_unit.h | 4 + libs/ardour/audio_unit.cc | 20 ++++- libs/pbd/pbd/rcu.h | 99 +++++++++++++++---------- 13 files changed, 264 insertions(+), 73 deletions(-) create mode 100644 gtk2_ardour/au_pluginui.h diff --git a/gtk2_ardour/SConscript b/gtk2_ardour/SConscript index 2a7250eaa4..658caac1e3 100644 --- a/gtk2_ardour/SConscript +++ b/gtk2_ardour/SConscript @@ -200,6 +200,11 @@ mtest_files=Split(""" mtest.cc """) + +rcu_files=Split(""" +rcu.cc +""") + itest_files=Split(""" itest.cc """) @@ -215,6 +220,7 @@ if env['VST']: if gtkardour['COREAUDIO']: extra_sources += coreaudio_files gtkardour.Append(CCFLAGS='-DHAVE_COREAUDIO') + gtkardour.Append(LINKFLAGS='-framework Carbon') gtkardour.Merge([libraries['appleutility']]) if env['FFT_ANALYSIS']: @@ -238,6 +244,7 @@ ardourlib = gtkardour.SharedLibrary(target = 'ardourgtk', source = gtkardour_fil mtest = gtkardour.Program(target = 'mtest', source = mtest_files) itest = gtkardour.Program(target = 'itest', source = itest_files) +rcu = gtkardour.Program(target = 'rcu', source = rcu_files) my_subst_dict = { } my_subst_dict['%INSTALL_PREFIX%'] = install_prefix diff --git a/gtk2_ardour/au_pluginui.cc b/gtk2_ardour/au_pluginui.cc index e4a5c73fe9..092e34d50b 100644 --- a/gtk2_ardour/au_pluginui.cc +++ b/gtk2_ardour/au_pluginui.cc @@ -18,37 +18,102 @@ */ -#include #include +#include -#include "plugin_ui.h" +#include + +#include "au_pluginui.h" +#include "gui_thread.h" + +#include +#include + +#include #include "i18n.h" using namespace ARDOUR; using namespace PBD; -AUPluginUI::AUPluginUI (boost::shared_ptr ap) +AUPluginUI::AUPluginUI (boost::shared_ptr insert) { - if ((au = boost::dynamic_pointer_cast (ap->plugin())) == 0) { + if ((au = boost::dynamic_pointer_cast (insert->plugin())) == 0) { error << _("unknown type of editor-supplying plugin (note: no AudioUnit support in this version of ardour)") << endmsg; throw failed_constructor (); } + OSStatus err = noErr; + + CAComponentDescription desc; + Component carbonViewComponent = NULL; + AudioUnitCarbonView carbonView = NULL; + + GetComponentInfo(au->get_comp()->Comp(), &desc, 0, 0, 0); + carbonViewComponent = get_carbon_view_component(desc.componentSubType); + err = OpenAComponent(carbonViewComponent, &carbonView); + + Rect rec; + rec.top = 0; + rec.left = 0; + rec.bottom = 400; + rec.right = 500; + + ProcessSerialNumber ourPSN; + + /* Here we will set the MacOSX native section of the process to the foreground for putting up this + * dialog box. First step is to get our process serial number. We do this by calling + * GetCurrentProcess. + * First Argument: On success this PSN will be our PSN on return. + * Return Value: A Macintosh error indicating success or failure. + */ + err = GetCurrentProcess(&ourPSN); + + //If no error then set this process to be frontmost. + if (err == noErr) { + /* Calling SetFrontProcess to make us frontmost. + * First Argument: The Process Serial Number of the process we want to make frontmost. Here + * of course we pass our process serial number + * Return Value: An error value indicating success or failure. We just ignore the return + * value here. + */ + (void)SetFrontProcess(&ourPSN); + } else { + error << "couldn't get current process" << endmsg; + } + + err = CreateNewWindow (kDocumentWindowClass, kWindowStandardFloatingAttributes, &rec, &wr); + + ComponentResult auResult; + ControlRef rootControl = NULL; + GetRootControl(wr, &rootControl); + + int width = 500; + int height = 400; + Float32Point location = {30, 30}; + Float32Point size = {width, height}; + ControlRef audioUnitControl = NULL; + + auResult = AudioUnitCarbonViewCreate(carbonView, + au->get_au()->AU(), + wr, + rootControl, + &location, + &size, + &audioUnitControl); + + ShowWindow (wr); + BringToFront (wr); +// AudioUnitCarbonViewSetEventListener(carbonView, EventListener, this); #if 0 - set_position (Gtk::WIN_POS_MOUSE); set_name ("PluginEditor"); add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK); signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), reinterpret_cast (this))); - insert->GoingAway.connect (mem_fun(*this, &PluginUIWindow::plugin_going_away)); +#endif - if (scrollable) { - gint h = _pluginui->get_preferred_height (); - if (h > 600) h = 600; - set_default_size (450, h); - } -#endif + insert->GoingAway.connect (mem_fun(*this, &AUPluginUI::plugin_going_away)); + info << "AUPluginUI created" << endmsg; } @@ -56,3 +121,39 @@ AUPluginUI::~AUPluginUI () { // nothing to do here - plugin destructor destroys the GUI } + +void +AUPluginUI::plugin_going_away (ARDOUR::Redirect* ignored) +{ + ENSURE_GUI_THREAD(bind (mem_fun(*this, &AUPluginUI::plugin_going_away), ignored)); + + delete_when_idle (this); +} + +Component +AUPluginUI::get_carbon_view_component(OSType subtype) +{ + ComponentDescription desc; + Component component; + + desc.componentType = kAudioUnitCarbonViewComponentType; // 'auvw' + desc.componentSubType = subtype; + desc.componentManufacturer = 0; + desc.componentFlags = 0; + desc.componentFlagsMask = 0; + + // First see if we can find a carbon view designed specifically for this + // plug-in: + + component = FindNextComponent(NULL, &desc); + if (component) + return component; + + // If not, grab the generic carbon view, which will create a GUI for + // any Audio Unit. + + desc.componentSubType = kAUCarbonViewSubType_Generic; + component = FindNextComponent(NULL, &desc); + + return component; +} diff --git a/gtk2_ardour/au_pluginui.h b/gtk2_ardour/au_pluginui.h new file mode 100644 index 0000000000..2dcefcc42f --- /dev/null +++ b/gtk2_ardour/au_pluginui.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2006 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __au_plugin_ui_h__ +#define __au_plugin_ui_h__ + +#include + +#include +#include + +namespace ARDOUR { + class AUPlugin; + class PluginInsert; + class Redirect; +} + +class AUPluginUI +{ + public: + AUPluginUI (boost::shared_ptr); + ~AUPluginUI (); + + private: + WindowRef wr; + boost::shared_ptr au; + + void plugin_going_away (ARDOUR::Redirect*); + Component get_carbon_view_component(OSType subtype); +}; + +#endif // __au_plugin_ui_h__ diff --git a/gtk2_ardour/audio_time_axis.cc b/gtk2_ardour/audio_time_axis.cc index 9ae94d1fe0..f8ace8244f 100644 --- a/gtk2_ardour/audio_time_axis.cc +++ b/gtk2_ardour/audio_time_axis.cc @@ -60,8 +60,6 @@ #include "keyboard.h" #include "pan_automation_time_axis.h" #include "playlist_selector.h" -#include "plugin_selector.h" -#include "plugin_ui.h" #include "prompter.h" #include "public_editor.h" #include "audio_region_view.h" diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index 4f3dc720d9..b089883c80 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -50,9 +50,7 @@ #include "mixer_strip.h" #include "mixer_ui.h" #include "keyboard.h" -#include "plugin_selector.h" #include "public_editor.h" -#include "plugin_ui.h" #include "send_ui.h" #include "io_selector.h" #include "utils.h" diff --git a/gtk2_ardour/plugin_ui.cc b/gtk2_ardour/plugin_ui.cc index 4619d50359..154c2fd3cf 100644 --- a/gtk2_ardour/plugin_ui.cc +++ b/gtk2_ardour/plugin_ui.cc @@ -205,3 +205,4 @@ PlugUIBase::bypass_toggled () insert->set_active (!x, this); } } + diff --git a/gtk2_ardour/plugin_ui.h b/gtk2_ardour/plugin_ui.h index 5c940843f7..fd5516cee1 100644 --- a/gtk2_ardour/plugin_ui.h +++ b/gtk2_ardour/plugin_ui.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2000 Paul Davis + Copyright (C) 2000-2006 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -234,16 +234,4 @@ class VSTPluginUI : public PlugUIBase, public Gtk::VBox }; #endif // VST_SUPPORT -#ifdef HAVE_COREAUDIO -class AUPluginUI -{ - public: - AUPluginUI (boost::shared_ptr); - ~AUPluginUI (); - - private: - boost::shared_ptr au; -}; -#endif // HAVE_COREAUDIO - #endif /* __ardour_plugin_ui_h__ */ diff --git a/gtk2_ardour/redirect_box.cc b/gtk2_ardour/redirect_box.cc index f93dfb9433..058cc9f5ab 100644 --- a/gtk2_ardour/redirect_box.cc +++ b/gtk2_ardour/redirect_box.cc @@ -54,7 +54,6 @@ #include "route_redirect_selection.h" #include "mixer_ui.h" #include "actions.h" - #include "plugin_ui.h" #include "send_ui.h" #include "io_selector.h" @@ -63,6 +62,10 @@ #include "i18n.h" +#ifdef HAVE_COREAUDIO +#include "au_pluginui.h" +#endif + using namespace sigc; using namespace ARDOUR; using namespace PBD; diff --git a/gtk2_ardour/region_view.cc b/gtk2_ardour/region_view.cc index ebec4261ac..8e80b147e5 100644 --- a/gtk2_ardour/region_view.cc +++ b/gtk2_ardour/region_view.cc @@ -111,10 +111,14 @@ RegionView::init (Gdk::Color& basic_color, bool wfd) compute_colors (basic_color); name_highlight->set_data ("regionview", this); - name_text->set_data ("regionview", this); + + if (name_text) { + name_text->set_data ("regionview", this); + } /* an equilateral triangle */ - ArdourCanvas::Points shape; + + ArdourCanvas::Points shape; shape.push_back (Gnome::Art::Point (-((sync_mark_width-1)/2), 1)); shape.push_back (Gnome::Art::Point ((sync_mark_width - 1)/2, 1)); shape.push_back (Gnome::Art::Point (0, sync_mark_width - 1)); diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index 0d7405e4f6..6e578a13e7 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -61,8 +61,6 @@ #include "gui_thread.h" #include "keyboard.h" #include "playlist_selector.h" -#include "plugin_selector.h" -#include "plugin_ui.h" #include "point_selection.h" #include "prompter.h" #include "public_editor.h" diff --git a/libs/ardour/ardour/audio_unit.h b/libs/ardour/ardour/audio_unit.h index 348a8ff863..a007f41d2b 100644 --- a/libs/ardour/ardour/audio_unit.h +++ b/libs/ardour/ardour/audio_unit.h @@ -86,6 +86,9 @@ class AUPlugin : public ARDOUR::Plugin bool has_editor () const; + CAAudioUnit* get_au () { return unit; } + CAComponent* get_comp () { return comp; } + private: CAComponent* comp; CAAudioUnit* unit; @@ -110,6 +113,7 @@ class AUPluginInfo : public PluginInfo { private: static std::string get_name (CAComponentDescription&); + void setup_nchannels (CAComponentDescription&); }; typedef boost::shared_ptr AUPluginInfoPtr; diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc index 0a31df40ee..ad98621814 100644 --- a/libs/ardour/audio_unit.cc +++ b/libs/ardour/audio_unit.cc @@ -137,7 +137,7 @@ AUPlugin::get_parameter (uint32_t which) const int AUPlugin::get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const { - return -1; + return 0; } uint32_t @@ -325,6 +325,7 @@ AUPluginInfo::discover () plug->type = ARDOUR::AudioUnit; plug->n_inputs = 0; plug->n_outputs = 0; + // plug->setup_nchannels (temp); plug->category = "AudioUnit"; plug->desc = new CAComponentDescription(temp); @@ -376,3 +377,20 @@ AUPluginInfo::get_name (CAComponentDescription& comp_desc) return CFStringRefToStdString(itemName); } + +void +AUPluginInfo::setup_nchannels (CAComponentDescription& comp_desc) +{ + CAAudioUnit unit; + + CAAudioUnit::Open (comp_desc, unit); + + if (unit.SupportsNumChannels()) { + n_inputs = n_outputs = 0; + } else { + AUChannelInfo cinfo; + size_t info_size = sizeof(cinfo); + OSStatus err = AudioUnitGetProperty (unit.AU(), kAudioUnitProperty_SupportedNumChannels, kAudioUnitScope_Global, + 0, &cinfo, &info_size); + } +} diff --git a/libs/pbd/pbd/rcu.h b/libs/pbd/pbd/rcu.h index 6d9586cb3c..58a92a206a 100644 --- a/libs/pbd/pbd/rcu.h +++ b/libs/pbd/pbd/rcu.h @@ -6,32 +6,29 @@ #include + template class RCUManager { -public: - - RCUManager (T* new_rcu_value) - : m_rcu_value(new_rcu_value) - { + public: + RCUManager (T* new_rcu_value) { + m_rcu_value = new boost::shared_ptr (new_rcu_value); } - virtual ~RCUManager() { } + virtual ~RCUManager() { delete m_rcu_value; } - boost::shared_ptr reader () const { return m_rcu_value; } + boost::shared_ptr reader () const { return *((boost::shared_ptr *) g_atomic_pointer_get (&m_rcu_value)); } - // should be private virtual boost::shared_ptr write_copy () = 0; - - // should be private - virtual void update (boost::shared_ptr new_value) = 0; - -protected: - - boost::shared_ptr m_rcu_value; - - + virtual bool update (boost::shared_ptr new_value) = 0; + + protected: + boost::shared_ptr* m_rcu_value; + + // this monstrosity is needed because of some wierd behavior by g++ + + gpointer * the_pointer() const { return (gpointer *) &m_rcu_value; } }; @@ -49,37 +46,63 @@ public: virtual boost::shared_ptr write_copy () { m_lock.lock(); - - // I hope this is doing what I think it is doing :) - boost::shared_ptr new_copy(new T(*RCUManager::m_rcu_value)); - - // XXX todo remove old copies with only 1 reference from the list. - + + // clean out any dead wood + + typename std::list >::iterator i; + + for (i = m_dead_wood.begin(); i != m_dead_wood.end(); ) { + if ((*i).use_count() == 1) { + i = m_dead_wood.erase (i); + } else { + ++i; + } + } + + // store the current + + current_write_old = RCUManager::m_rcu_value; + + boost::shared_ptr new_copy (new T(**current_write_old)); + return new_copy; } - virtual void update (boost::shared_ptr new_value) + virtual bool update (boost::shared_ptr new_value) { - // So a current reader doesn't hold the only reference to - // the existing value when we assign it a new value which - // should ensure that deletion of old values doesn't - // occur in a reader thread. - boost::shared_ptr old_copy = RCUManager::m_rcu_value; - // we hold the lock at this point effectively blocking // other writers. - RCUManager::m_rcu_value = new_value; - - - // XXX add the old value to the list of old copies. - + + boost::shared_ptr* new_spp = new boost::shared_ptr (new_value); + + // update, checking that nobody beat us to it + + bool ret = g_atomic_pointer_compare_and_exchange (RCUManager::the_pointer(), + (gpointer) current_write_old, + (gpointer) new_spp); + + if (ret) { + + // successful update : put the old value into dead_wood, + + m_dead_wood.push_back (*current_write_old); + + // now delete it - this gets rid of the shared_ptr but + // because dead_wood contains another shared_ptr that + // references the same T, the underlying object lives on + + delete current_write_old; + } + m_lock.unlock(); + + return ret; } private: - Glib::Mutex m_lock; - - std::list > m_old_values; + Glib::Mutex m_lock; + boost::shared_ptr* current_write_old; + std::list > m_dead_wood; }; template From 26e553caa8621e50d0a831651e5f8f69178e84b2 Mon Sep 17 00:00:00 2001 From: Hans Fugal Date: Sat, 12 Aug 2006 22:31:45 +0000 Subject: [PATCH 2/8] git-svn-id: svn://localhost/ardour2/branches/undo@808 d708f5d6-7413-0410-9779-e7cbd77b26cf From 8ee6045cf4210e38ac391788f52e0b5724382581 Mon Sep 17 00:00:00 2001 From: Hans Fugal Date: Sat, 12 Aug 2006 22:33:00 +0000 Subject: [PATCH 3/8] r321@gandalf: fugalh | 2006-08-12 15:48:28 -0600 Behold serialized undo. git-svn-id: svn://localhost/ardour2/branches/undo@809 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_ui.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index c054de9808..e5367d6280 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -1486,7 +1486,6 @@ ARDOUR_UI::restore_state (string name) name = session->name(); } session->restore_state (name); - session->restore_history (name); } } From 3bb693a79d1c0719b8d4d9d74ee0b8d7584dba30 Mon Sep 17 00:00:00 2001 From: Hans Fugal Date: Sat, 12 Aug 2006 22:33:10 +0000 Subject: [PATCH 4/8] r322@gandalf: fugalh | 2006-08-12 15:49:05 -0600 A few ardev and ardbg enhancements. git-svn-id: svn://localhost/ardour2/branches/undo@810 d708f5d6-7413-0410-9779-e7cbd77b26cf From 5d965fb582d21b394fe3a49216de478e06357cdc Mon Sep 17 00:00:00 2001 From: Hans Fugal Date: Sat, 12 Aug 2006 22:33:20 +0000 Subject: [PATCH 5/8] r329@gandalf: fugalh | 2006-08-12 15:54:49 -0600 Cleaning up some printf debugging git-svn-id: svn://localhost/ardour2/branches/undo@811 d708f5d6-7413-0410-9779-e7cbd77b26cf From 0cde6a54ed2f7ba5e3f5567f7ab52cf502fc13a6 Mon Sep 17 00:00:00 2001 From: Hans Fugal Date: Sat, 12 Aug 2006 22:33:38 +0000 Subject: [PATCH 6/8] git-svn-id: svn://localhost/ardour2/branches/undo@812 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/plugin_ui.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/gtk2_ardour/plugin_ui.cc b/gtk2_ardour/plugin_ui.cc index 154c2fd3cf..4619d50359 100644 --- a/gtk2_ardour/plugin_ui.cc +++ b/gtk2_ardour/plugin_ui.cc @@ -205,4 +205,3 @@ PlugUIBase::bypass_toggled () insert->set_active (!x, this); } } - From e0d1b7cb4bfa2b988d5fe79309e0c4b36ccafc76 Mon Sep 17 00:00:00 2001 From: Hans Fugal Date: Sat, 12 Aug 2006 22:33:48 +0000 Subject: [PATCH 7/8] r338@gandalf: fugalh | 2006-08-12 16:30:19 -0600 Oops, forgot one git-svn-id: svn://localhost/ardour2/branches/undo@813 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/location.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc index 5b5f733138..ca88a2851b 100644 --- a/libs/ardour/location.cc +++ b/libs/ardour/location.cc @@ -834,3 +834,14 @@ Locations::num_range_markers () const } return cnt; } + +Location * +Locations::get_location_by_id(PBD::ID id) +{ + LocationList::iterator it; + for (it = locations.begin(); it != locations.end(); it++) + if (id == (*it)->id()) + return *it; + + return 0; +} From 92ab1124809b247707515b7fb03b8c37326fd57c Mon Sep 17 00:00:00 2001 From: Hans Fugal Date: Sat, 12 Aug 2006 23:19:56 +0000 Subject: [PATCH 8/8] Remove -x from ardbg, fix bug in memento command factory git-svn-id: svn://localhost/ardour2/branches/undo@814 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardbg | 2 +- libs/ardour/session_command.cc | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/ardbg b/gtk2_ardour/ardbg index cac20f3c2f..dde203219e 100755 --- a/gtk2_ardour/ardbg +++ b/gtk2_ardour/ardbg @@ -1,4 +1,4 @@ -#!/bin/sh -x +#!/bin/sh dir=`dirname "$0"` source $dir/ardev_common.sh exec gdb $dir/ardour.bin $* diff --git a/libs/ardour/session_command.cc b/libs/ardour/session_command.cc index 8c1a4b32cf..dbe0ffccdd 100644 --- a/libs/ardour/session_command.cc +++ b/libs/ardour/session_command.cc @@ -24,6 +24,7 @@ Command *Session::memento_command_factory(XMLNode *n) { PBD::ID id; XMLNode *before = 0, *after = 0; + XMLNode *child; /* get id */ id = PBD::ID(n->property("obj_id")->value()); @@ -33,10 +34,23 @@ Command *Session::memento_command_factory(XMLNode *n) { before = new XMLNode(*n->children().front()); after = new XMLNode(*n->children().back()); + child = before; } else if (n->name() == "MementoUndoCommand") + { before = new XMLNode(*n->children().front()); + child = before; + } else if (n->name() == "MementoRedoCommand") + { after = new XMLNode(*n->children().front()); + child = after; + } + + if (!child) + { + error << _("Tried to reconstitute a MementoCommand with no contents, failing. id=") << id.to_s() << endmsg; + return 0; + } /* create command */ @@ -59,7 +73,7 @@ Command *Session::memento_command_factory(XMLNode *n) return new MementoCommand(*_tempo_map, before, after); else if (obj_T == "Playlist" || obj_T == "AudioPlaylist") { - if (Playlist *pl = playlist_by_name(before->property("name")->value())) + if (Playlist *pl = playlist_by_name(child->property("name")->value())) return new MementoCommand(*pl, before, after); } else if (obj_T == "Route") // inlcudes AudioTrack