mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 16:46:35 +01:00
r283@gandalf: fugalh | 2006-08-09 08:13:37 -0600
Save state basics, including adding PBD::ID to the delinquents. Compiles but needs to be tested (because I can't get the whole thing to compile on OSX due to the Rect problem). git-svn-id: svn://localhost/ardour2/branches/undo@769 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
5fc16bf95f
commit
c26215c1e5
21 changed files with 122 additions and 13 deletions
|
|
@ -1298,6 +1298,7 @@ ARDOUR_UI::start_engine ()
|
||||||
settings for a new session
|
settings for a new session
|
||||||
*/
|
*/
|
||||||
session->save_state ("");
|
session->save_state ("");
|
||||||
|
session->save_history ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* there is too much going on, in too many threads, for us to
|
/* there is too much going on, in too many threads, for us to
|
||||||
|
|
@ -1471,6 +1472,7 @@ ARDOUR_UI::save_state_canfail (string name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = session->save_state (name)) != 0) {
|
if ((ret = session->save_state (name)) != 0) {
|
||||||
|
session->save_history();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,7 @@ ARDOUR_UI::unload_session ()
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
session->save_state ("");
|
session->save_state ("");
|
||||||
|
session->save_history();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,9 @@ class AutomationLine : public sigc::trackable, public Stateful
|
||||||
XMLNode& get_state (void);
|
XMLNode& get_state (void);
|
||||||
int set_state (const XMLNode&);
|
int set_state (const XMLNode&);
|
||||||
|
|
||||||
|
PBD::ID id() { return _id; }
|
||||||
protected:
|
protected:
|
||||||
|
PBD::ID _id;
|
||||||
string _name;
|
string _name;
|
||||||
guint32 _height;
|
guint32 _height;
|
||||||
uint32_t _line_color;
|
uint32_t _line_color;
|
||||||
|
|
|
||||||
|
|
@ -143,6 +143,8 @@ class Editor : public PublicEditor
|
||||||
XMLNode& get_state ();
|
XMLNode& get_state ();
|
||||||
int set_state (const XMLNode& );
|
int set_state (const XMLNode& );
|
||||||
|
|
||||||
|
PBD::ID id() { return _id; }
|
||||||
|
|
||||||
void set_mouse_mode (Editing::MouseMode, bool force=true);
|
void set_mouse_mode (Editing::MouseMode, bool force=true);
|
||||||
void step_mouse_mode (bool next);
|
void step_mouse_mode (bool next);
|
||||||
Editing::MouseMode current_mouse_mode () { return mouse_mode; }
|
Editing::MouseMode current_mouse_mode () { return mouse_mode; }
|
||||||
|
|
@ -347,6 +349,8 @@ class Editor : public PublicEditor
|
||||||
ARDOUR::AudioEngine& engine;
|
ARDOUR::AudioEngine& engine;
|
||||||
bool constructed;
|
bool constructed;
|
||||||
|
|
||||||
|
PBD::ID _id;
|
||||||
|
|
||||||
PlaylistSelector* _playlist_selector;
|
PlaylistSelector* _playlist_selector;
|
||||||
|
|
||||||
void set_frames_per_unit (double);
|
void set_frames_per_unit (double);
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ class AudioRegionGainLine : public AutomationLine
|
||||||
|
|
||||||
void remove_point (ControlPoint&);
|
void remove_point (ControlPoint&);
|
||||||
|
|
||||||
|
PBD::ID id() { return _id; }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -33,6 +34,8 @@ class AudioRegionGainLine : public AutomationLine
|
||||||
AudioRegionView& rv;
|
AudioRegionView& rv;
|
||||||
|
|
||||||
UndoAction get_memento();
|
UndoAction get_memento();
|
||||||
|
|
||||||
|
PBD::ID _id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,8 @@ class AutomationList : public StateManager, public Stateful
|
||||||
XMLNode &get_state(void);
|
XMLNode &get_state(void);
|
||||||
int set_state (const XMLNode &s);
|
int set_state (const XMLNode &s);
|
||||||
|
|
||||||
|
PBD::ID id() { return _id; }
|
||||||
|
|
||||||
void set_max_xval (double);
|
void set_max_xval (double);
|
||||||
double get_max_xval() const { return max_xval; }
|
double get_max_xval() const { return max_xval; }
|
||||||
|
|
||||||
|
|
@ -182,6 +184,7 @@ class AutomationList : public StateManager, public Stateful
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
PBD::ID _id;
|
||||||
struct State : public ARDOUR::StateManager::State {
|
struct State : public ARDOUR::StateManager::State {
|
||||||
AutomationEventList events;
|
AutomationEventList events;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,10 @@ class Location : public Stateful, public sigc::trackable
|
||||||
XMLNode& get_state (void);
|
XMLNode& get_state (void);
|
||||||
int set_state (const XMLNode&);
|
int set_state (const XMLNode&);
|
||||||
|
|
||||||
|
PBD::ID id() { return _id; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
PBD::ID _id;
|
||||||
string _name;
|
string _name;
|
||||||
jack_nframes_t _start;
|
jack_nframes_t _start;
|
||||||
jack_nframes_t _end;
|
jack_nframes_t _end;
|
||||||
|
|
@ -145,6 +148,7 @@ class Locations : public Stateful, public StateManager
|
||||||
|
|
||||||
XMLNode& get_state (void);
|
XMLNode& get_state (void);
|
||||||
int set_state (const XMLNode&);
|
int set_state (const XMLNode&);
|
||||||
|
PBD::ID id() { return _id; }
|
||||||
|
|
||||||
Location* auto_loop_location () const;
|
Location* auto_loop_location () const;
|
||||||
Location* auto_punch_location () const;
|
Location* auto_punch_location () const;
|
||||||
|
|
@ -197,6 +201,8 @@ class Locations : public Stateful, public StateManager
|
||||||
|
|
||||||
Change restore_state (StateManager::State&);
|
Change restore_state (StateManager::State&);
|
||||||
StateManager::State* state_factory (std::string why) const;
|
StateManager::State* state_factory (std::string why) const;
|
||||||
|
|
||||||
|
PBD::ID _id;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ARDOUR
|
} // namespace ARDOUR
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ class Playlist : public Stateful, public StateManager {
|
||||||
EditMode get_edit_mode() const { return _edit_mode; }
|
EditMode get_edit_mode() const { return _edit_mode; }
|
||||||
void set_edit_mode (EditMode);
|
void set_edit_mode (EditMode);
|
||||||
|
|
||||||
|
PBD::ID id() { return _id; }
|
||||||
/* Editing operations */
|
/* Editing operations */
|
||||||
|
|
||||||
void add_region (const Region&, jack_nframes_t position, float times = 1, bool with_save = true);
|
void add_region (const Region&, jack_nframes_t position, float times = 1, bool with_save = true);
|
||||||
|
|
@ -273,6 +274,8 @@ class Playlist : public Stateful, public StateManager {
|
||||||
void unset_freeze_child (Playlist*);
|
void unset_freeze_child (Playlist*);
|
||||||
|
|
||||||
void timestamp_layer_op (Region&);
|
void timestamp_layer_op (Region&);
|
||||||
|
|
||||||
|
PBD::ID _id;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace ARDOUR */
|
} /* namespace ARDOUR */
|
||||||
|
|
|
||||||
|
|
@ -477,6 +477,7 @@ class Session : public sigc::trackable, public Stateful
|
||||||
int save_state (string snapshot_name, bool pending = false);
|
int save_state (string snapshot_name, bool pending = false);
|
||||||
int restore_state (string snapshot_name);
|
int restore_state (string snapshot_name);
|
||||||
int save_template (string template_name);
|
int save_template (string template_name);
|
||||||
|
int save_history ();
|
||||||
|
|
||||||
static int rename_template (string old_name, string new_name);
|
static int rename_template (string old_name, string new_name);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -238,6 +238,7 @@ class TempoMap : public Stateful, public StateManager {
|
||||||
|
|
||||||
XMLNode& get_state (void);
|
XMLNode& get_state (void);
|
||||||
int set_state (const XMLNode&);
|
int set_state (const XMLNode&);
|
||||||
|
PBD::ID id();
|
||||||
|
|
||||||
void dump (std::ostream&) const;
|
void dump (std::ostream&) const;
|
||||||
void clear ();
|
void clear ();
|
||||||
|
|
@ -315,6 +316,8 @@ class TempoMap : public Stateful, public StateManager {
|
||||||
|
|
||||||
void save_state (std::string why);
|
void save_state (std::string why);
|
||||||
|
|
||||||
|
PBD::ID _id;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}; /* namespace ARDOUR */
|
}; /* namespace ARDOUR */
|
||||||
|
|
|
||||||
|
|
@ -1011,6 +1011,7 @@ Session::auto_punch_start_changed (Location* location)
|
||||||
if (get_record_enabled() && get_punch_in()) {
|
if (get_record_enabled() && get_punch_in()) {
|
||||||
/* capture start has been changed, so save new pending state */
|
/* capture start has been changed, so save new pending state */
|
||||||
save_state ("", true);
|
save_state ("", true);
|
||||||
|
save_history();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1328,6 +1329,7 @@ Session::maybe_enable_record ()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
save_state ("", true);
|
save_state ("", true);
|
||||||
|
save_history();
|
||||||
|
|
||||||
if (_transport_speed) {
|
if (_transport_speed) {
|
||||||
if (!punch_in) {
|
if (!punch_in) {
|
||||||
|
|
@ -1922,6 +1924,7 @@ Session::add_diskstream (Diskstream* dstream)
|
||||||
|
|
||||||
set_dirty();
|
set_dirty();
|
||||||
save_state (_current_snapshot_name);
|
save_state (_current_snapshot_name);
|
||||||
|
save_history();
|
||||||
|
|
||||||
DiskstreamAdded (dstream); /* EMIT SIGNAL */
|
DiskstreamAdded (dstream); /* EMIT SIGNAL */
|
||||||
}
|
}
|
||||||
|
|
@ -2674,6 +2677,7 @@ Session::remove_source (Source* source)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
save_state (_current_snapshot_name);
|
save_state (_current_snapshot_name);
|
||||||
|
save_history();
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceRemoved(source); /* EMIT SIGNAL */
|
SourceRemoved(source); /* EMIT SIGNAL */
|
||||||
|
|
|
||||||
|
|
@ -608,6 +608,7 @@ Session::create (bool& new_session, string* mix_template, jack_nframes_t initial
|
||||||
_state_of_the_state = Clean;
|
_state_of_the_state = Clean;
|
||||||
|
|
||||||
if (save_state (_current_snapshot_name)) {
|
if (save_state (_current_snapshot_name)) {
|
||||||
|
save_history();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1690,6 +1691,7 @@ Session::set_state (const XMLNode& node)
|
||||||
|
|
||||||
if (state_was_pending) {
|
if (state_was_pending) {
|
||||||
save_state (_current_snapshot_name);
|
save_state (_current_snapshot_name);
|
||||||
|
save_history();
|
||||||
remove_pending_capture_state ();
|
remove_pending_capture_state ();
|
||||||
state_was_pending = false;
|
state_was_pending = false;
|
||||||
}
|
}
|
||||||
|
|
@ -2477,6 +2479,7 @@ void
|
||||||
Session::auto_save()
|
Session::auto_save()
|
||||||
{
|
{
|
||||||
save_state (_current_snapshot_name);
|
save_state (_current_snapshot_name);
|
||||||
|
save_history();
|
||||||
}
|
}
|
||||||
|
|
||||||
RouteGroup *
|
RouteGroup *
|
||||||
|
|
@ -3278,3 +3281,48 @@ Session::add_instant_xml (XMLNode& node, const std::string& dir)
|
||||||
Stateful::add_instant_xml (node, dir);
|
Stateful::add_instant_xml (node, dir);
|
||||||
Config->add_instant_xml (node, get_user_ardour_path());
|
Config->add_instant_xml (node, get_user_ardour_path());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
Session::save_history ()
|
||||||
|
{
|
||||||
|
XMLTree tree;
|
||||||
|
string xml_path;
|
||||||
|
string bak_path;
|
||||||
|
|
||||||
|
tree.set_root (&history.get_state());
|
||||||
|
|
||||||
|
xml_path = _path + _current_snapshot_name + ".history";
|
||||||
|
|
||||||
|
bak_path = xml_path + ".bak";
|
||||||
|
|
||||||
|
if ((access (xml_path.c_str(), F_OK) == 0) &&
|
||||||
|
(rename (xml_path.c_str(), bak_path.c_str())))
|
||||||
|
{
|
||||||
|
error << _("could not backup old history file, current history not saved.") << endmsg;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tree.write (xml_path))
|
||||||
|
{
|
||||||
|
error << string_compose (_("history could not be saved to %1"), xml_path) << endmsg;
|
||||||
|
|
||||||
|
/* don't leave a corrupt file lying around if it is
|
||||||
|
* possible to fix.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (unlink (xml_path.c_str()))
|
||||||
|
{
|
||||||
|
error << string_compose (_("could not remove corrupt history file %1"), xml_path) << endmsg;
|
||||||
|
} else {
|
||||||
|
if (rename (bak_path.c_str(), xml_path.c_str()))
|
||||||
|
{
|
||||||
|
error << string_compose (_("could not restore history file from backup %1"), bak_path) << endmsg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -411,6 +411,7 @@ Session::non_realtime_stop (bool abort)
|
||||||
if ((post_transport_work & PostTransportLocate) && get_record_enabled()) {
|
if ((post_transport_work & PostTransportLocate) && get_record_enabled()) {
|
||||||
/* capture start has been changed, so save pending state */
|
/* capture start has been changed, so save pending state */
|
||||||
save_state ("", true);
|
save_state ("", true);
|
||||||
|
save_history();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* always try to get rid of this */
|
/* always try to get rid of this */
|
||||||
|
|
|
||||||
|
|
@ -206,6 +206,7 @@ Track::set_name (string str, void *src)
|
||||||
|
|
||||||
if ((ret = IO::set_name (str, src)) == 0) {
|
if ((ret = IO::set_name (str, src)) == 0) {
|
||||||
_session.save_state ("");
|
_session.save_state ("");
|
||||||
|
_session.save_history();
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,6 @@
|
||||||
XMLNode &Command::get_state()
|
XMLNode &Command::get_state()
|
||||||
{
|
{
|
||||||
XMLNode *node = new XMLNode ("Command");
|
XMLNode *node = new XMLNode ("Command");
|
||||||
// TODO
|
node->add_content("WARNING: Somebody forgot to subclass Command.");
|
||||||
return *node;
|
return *node;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include <pbd/id.h>
|
#include <pbd/id.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace PBD;
|
using namespace PBD;
|
||||||
|
|
@ -45,6 +46,13 @@ ID::print (char* buf) const
|
||||||
snprintf (buf, 16, "%" PRIu64, id);
|
snprintf (buf, 16, "%" PRIu64, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string ID::to_s() const
|
||||||
|
{
|
||||||
|
char buf[16]; // see print()
|
||||||
|
print(buf);
|
||||||
|
return string(buf);
|
||||||
|
}
|
||||||
|
|
||||||
ID&
|
ID&
|
||||||
ID::operator= (string str)
|
ID::operator= (string str)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ class ID {
|
||||||
}
|
}
|
||||||
|
|
||||||
void print (char* buf) const;
|
void print (char* buf) const;
|
||||||
|
std::string to_s() const;
|
||||||
|
|
||||||
static uint64_t counter() { return _counter; }
|
static uint64_t counter() { return _counter; }
|
||||||
static void init_counter (uint64_t val) { _counter = val; }
|
static void init_counter (uint64_t val) { _counter = val; }
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
#define __lib_pbd_memento_command_h__
|
#define __lib_pbd_memento_command_h__
|
||||||
|
|
||||||
#include <pbd/command.h>
|
#include <pbd/command.h>
|
||||||
|
#include <pbd/xml++.h>
|
||||||
#include <sigc++/slot.h>
|
#include <sigc++/slot.h>
|
||||||
|
|
||||||
/** This command class is initialized with before and after mementos
|
/** This command class is initialized with before and after mementos
|
||||||
|
|
@ -42,9 +43,9 @@ class MementoCommand : public Command
|
||||||
virtual XMLNode &get_state()
|
virtual XMLNode &get_state()
|
||||||
{
|
{
|
||||||
XMLNode *node = new XMLNode("MementoCommand");
|
XMLNode *node = new XMLNode("MementoCommand");
|
||||||
// obj.id
|
node->add_property("obj_id", obj.id().to_s());
|
||||||
// key is "MementoCommand" or something
|
node->add_child_nocopy(before);
|
||||||
// before and after mementos
|
node->add_child_nocopy(after);
|
||||||
return *node;
|
return *node;
|
||||||
}
|
}
|
||||||
// TODO does this need a copy constructor?
|
// TODO does this need a copy constructor?
|
||||||
|
|
@ -64,10 +65,9 @@ public:
|
||||||
void undo() { obj.set_state(before); }
|
void undo() { obj.set_state(before); }
|
||||||
virtual XMLNode &get_state()
|
virtual XMLNode &get_state()
|
||||||
{
|
{
|
||||||
XMLNode *node = new XMLNode("MementoUndoCommand"); // XXX
|
XMLNode *node = new XMLNode("MementoUndoCommand");
|
||||||
// obj.id
|
node->add_property("obj_id", obj.id().to_s());
|
||||||
// key is "MementoCommand" or something
|
node->add_child_nocopy(before);
|
||||||
// before and after mementos
|
|
||||||
return *node;
|
return *node;
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -86,10 +86,9 @@ public:
|
||||||
void undo() { /* noop */ }
|
void undo() { /* noop */ }
|
||||||
virtual XMLNode &get_state()
|
virtual XMLNode &get_state()
|
||||||
{
|
{
|
||||||
XMLNode *node = new XMLNode("MementoUndoCommand");
|
XMLNode *node = new XMLNode("MementoRedoCommand");
|
||||||
// obj.id
|
node->add_property("obj_id", obj.id().to_s());
|
||||||
// key is "MementoCommand" or something
|
node->add_child_nocopy(after);
|
||||||
// before and after mementos
|
|
||||||
return *node;
|
return *node;
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,8 @@ class UndoHistory
|
||||||
void clear_undo ();
|
void clear_undo ();
|
||||||
void clear_redo ();
|
void clear_redo ();
|
||||||
|
|
||||||
|
XMLNode &get_state();
|
||||||
|
void save_state();
|
||||||
private:
|
private:
|
||||||
list<UndoTransaction> UndoList;
|
list<UndoTransaction> UndoList;
|
||||||
list<UndoTransaction> RedoList;
|
list<UndoTransaction> RedoList;
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include <pbd/undo.h>
|
#include <pbd/undo.h>
|
||||||
#include <pbd/xml++.h>
|
#include <pbd/xml++.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace sigc;
|
using namespace sigc;
|
||||||
|
|
@ -86,7 +87,11 @@ UndoTransaction::redo ()
|
||||||
XMLNode &UndoTransaction::get_state()
|
XMLNode &UndoTransaction::get_state()
|
||||||
{
|
{
|
||||||
XMLNode *node = new XMLNode ("UndoTransaction");
|
XMLNode *node = new XMLNode ("UndoTransaction");
|
||||||
// TODO
|
|
||||||
|
list<Command*>::iterator it;
|
||||||
|
for (it=actions.begin(); it!=actions.end(); it++)
|
||||||
|
node->add_child_nocopy((*it)->get_state());
|
||||||
|
|
||||||
return *node;
|
return *node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -142,3 +147,14 @@ UndoHistory::clear ()
|
||||||
RedoList.clear ();
|
RedoList.clear ();
|
||||||
UndoList.clear ();
|
UndoList.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XMLNode & UndoHistory::get_state()
|
||||||
|
{
|
||||||
|
XMLNode *node = new XMLNode ("UndoHistory");
|
||||||
|
|
||||||
|
list<UndoTransaction>::iterator it;
|
||||||
|
for (it=UndoList.begin(); it != UndoList.end(); it++)
|
||||||
|
node->add_child_nocopy(it->get_state());
|
||||||
|
|
||||||
|
return *node;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,7 @@ void
|
||||||
BasicUI::save_state ()
|
BasicUI::save_state ()
|
||||||
{
|
{
|
||||||
session->save_state ("");
|
session->save_state ("");
|
||||||
|
session->save_history();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue