Mixer: Warn if user attempts to quit without saving.

This commit is contained in:
Jonathan Moore Liles 2010-01-31 21:14:56 -06:00
parent 237861db95
commit 5fecc4b673
4 changed files with 25 additions and 3 deletions

View File

@ -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();
}

View File

@ -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 );

View File

@ -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 <unsigned int, Loggable::log_pair > 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;

View File

@ -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: