From af523475c44ec90c04b28ab01933de2904105944 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sat, 3 May 2008 17:50:32 -0500 Subject: [PATCH] Work on making system reset possible. --- Timeline/Loggable.C | 24 ++++++++++++++++++++++++ Timeline/Loggable.H | 1 + Timeline/TLE.fl | 7 +++++-- Timeline/Track.C | 3 +++ Timeline/Track.H | 2 +- 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Timeline/Loggable.C b/Timeline/Loggable.C index 9edf612..abe5a09 100644 --- a/Timeline/Loggable.C +++ b/Timeline/Loggable.C @@ -69,6 +69,30 @@ Loggable::open ( const char *filename ) return true; } +/** close journal and delete all loggable objects */ +bool +Loggable::close ( void ) +{ + + DMESSAGE( "closing journal and destroying all journaled objects" ); + + fclose( _fp ); + + _fp = NULL; + + for ( int i = _log_id; i--; ) + { + Loggable ** l = &_loggables[ i ]; + + if ( *l ) + delete *l; + + *l = NULL; + } + + return true; +} + /** sigh. parse a string of ":name value :name value" pairs into an * array of strings, one per pair */ // FIXME: doesn't handle the case of :name ":foo bar", nested quotes diff --git a/Timeline/Loggable.H b/Timeline/Loggable.H index 7f1f0dd..c1dc0f6 100644 --- a/Timeline/Loggable.H +++ b/Timeline/Loggable.H @@ -100,6 +100,7 @@ private: public: static bool open ( const char *filename ); + static bool close ( void ); static void undo ( void ); static int undo_index ( void ) { return _undo_index; } static void compact ( void ); diff --git a/Timeline/TLE.fl b/Timeline/TLE.fl index 6e6a8be..f57c337 100644 --- a/Timeline/TLE.fl +++ b/Timeline/TLE.fl @@ -126,7 +126,10 @@ free( path );} {} } { MenuItem {} { label {&New} - xywh {0 0 40 25} deactivate + callback {Loggable::close(); +// timeline->reset(); +main_window->redraw();} selected + xywh {0 0 40 25} } MenuItem {} { label {&Open} @@ -536,7 +539,7 @@ delete win;} class Timeline } Fl_Box {} { - label {} selected + label {} xywh {450 0 475 22} labeltype SHADOW_LABEL labelfont 2 code0 {o->label( session_display_name );} } diff --git a/Timeline/Track.C b/Timeline/Track.C index 7f3801e..d7ad116 100644 --- a/Timeline/Track.C +++ b/Timeline/Track.C @@ -239,6 +239,9 @@ Track::Track ( const char *L, int channels ) : Track::~Track ( ) { + /* FIXME: why is this necessary? */ + timeline->remove_track( this ); + log_destroy(); } diff --git a/Timeline/Track.H b/Timeline/Track.H index 6ac2fc3..65d3bee 100644 --- a/Timeline/Track.H +++ b/Timeline/Track.H @@ -53,7 +53,7 @@ class Track : public Fl_Group, public Loggable public: Track ( const char *L, int channels=1 ); - ~Track ( ); + virtual ~Track ( ); static bool soloing ( void ) { return _soloing; }