diff --git a/Mixer/Mixer.C b/Mixer/Mixer.C index 2feb913..0cf4cbe 100644 --- a/Mixer/Mixer.C +++ b/Mixer/Mixer.C @@ -566,6 +566,14 @@ Mixer::command_new ( const char *path, const char *display_name ) void Mixer::command_quit ( void ) { + if ( Loggable::dirty() ) + { + int i = fl_choice( "There have been changes since the last save. Quitting now will discard them", "Discard", "Cancel", NULL ); + + if ( i != 0 ) + return; + } + quit(); } diff --git a/Mixer/Project.C b/Mixer/Project.C index 4d298cc..00f67d9 100644 --- a/Mixer/Project.C +++ b/Mixer/Project.C @@ -172,8 +172,11 @@ Project::save ( void ) // tle->save_timeline_settings(); - return mixer->save(); + int r = mixer->save(); + Loggable::clear_dirty(); + + return r; // return Loggable::save_unjournaled_state(); } @@ -279,7 +282,7 @@ Project::open ( const char *name ) // timeline->zoom_fit(); - + Loggable::clear_dirty(); MESSAGE( "Loaded project \"%s\"", name ); diff --git a/nonlib/Loggable.C b/nonlib/Loggable.C index 61e0062..508c441 100644 --- a/nonlib/Loggable.C +++ b/nonlib/Loggable.C @@ -45,7 +45,7 @@ using std::max; FILE *Loggable::_fp; unsigned int Loggable::_log_id = 0; int Loggable::_level = 0; - +int Loggable::_dirty = 0; off_t Loggable::_undo_offset = 0; std::map Loggable::_loggables; @@ -686,6 +686,8 @@ Loggable::log_end ( void ) log( "%s 0x%X set ", class_name(), _id ); log_print( _old_state, new_state ); + + ++_dirty; } delete new_state; @@ -703,6 +705,8 @@ Loggable::log_end ( void ) void Loggable::log_create ( void ) const { + ++_dirty; + if ( ! _fp ) /* replaying, don't bother */ return; @@ -753,6 +757,8 @@ Loggable::log_destroy ( void ) const /* the unjournaled state may have changed: make a note of it. */ record_unjournaled(); + ++_dirty; + if ( ! _fp ) /* tearing down... don't bother */ return; diff --git a/nonlib/Loggable.H b/nonlib/Loggable.H index 66c4d32..34ce464 100644 --- a/nonlib/Loggable.H +++ b/nonlib/Loggable.H @@ -95,6 +95,8 @@ private: int _nest; + static int _dirty; /* count of changes */ + static void ensure_size ( size_t n ); void log_print ( const Log_Entry *o, const Log_Entry *n ) const; @@ -183,6 +185,9 @@ public: static bool do_this ( const char *s, bool reverse ); + static int dirty ( void ) { return _dirty; } + static void clear_dirty ( void ) { _dirty = 0; } + void log_create ( void ) const; protected: