Mixer: Warn if user attempts to quit without saving.
This commit is contained in:
parent
237861db95
commit
5fecc4b673
|
@ -566,6 +566,14 @@ Mixer::command_new ( const char *path, const char *display_name )
|
||||||
void
|
void
|
||||||
Mixer::command_quit ( 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();
|
quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,8 +172,11 @@ Project::save ( void )
|
||||||
|
|
||||||
// tle->save_timeline_settings();
|
// tle->save_timeline_settings();
|
||||||
|
|
||||||
return mixer->save();
|
int r = mixer->save();
|
||||||
|
|
||||||
|
Loggable::clear_dirty();
|
||||||
|
|
||||||
|
return r;
|
||||||
// return Loggable::save_unjournaled_state();
|
// return Loggable::save_unjournaled_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +282,7 @@ Project::open ( const char *name )
|
||||||
|
|
||||||
// timeline->zoom_fit();
|
// timeline->zoom_fit();
|
||||||
|
|
||||||
|
Loggable::clear_dirty();
|
||||||
|
|
||||||
MESSAGE( "Loaded project \"%s\"", name );
|
MESSAGE( "Loaded project \"%s\"", name );
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ using std::max;
|
||||||
FILE *Loggable::_fp;
|
FILE *Loggable::_fp;
|
||||||
unsigned int Loggable::_log_id = 0;
|
unsigned int Loggable::_log_id = 0;
|
||||||
int Loggable::_level = 0;
|
int Loggable::_level = 0;
|
||||||
|
int Loggable::_dirty = 0;
|
||||||
off_t Loggable::_undo_offset = 0;
|
off_t Loggable::_undo_offset = 0;
|
||||||
|
|
||||||
std::map <unsigned int, Loggable::log_pair > Loggable::_loggables;
|
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( "%s 0x%X set ", class_name(), _id );
|
||||||
|
|
||||||
log_print( _old_state, new_state );
|
log_print( _old_state, new_state );
|
||||||
|
|
||||||
|
++_dirty;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete new_state;
|
delete new_state;
|
||||||
|
@ -703,6 +705,8 @@ Loggable::log_end ( void )
|
||||||
void
|
void
|
||||||
Loggable::log_create ( void ) const
|
Loggable::log_create ( void ) const
|
||||||
{
|
{
|
||||||
|
++_dirty;
|
||||||
|
|
||||||
if ( ! _fp )
|
if ( ! _fp )
|
||||||
/* replaying, don't bother */
|
/* replaying, don't bother */
|
||||||
return;
|
return;
|
||||||
|
@ -753,6 +757,8 @@ Loggable::log_destroy ( void ) const
|
||||||
/* the unjournaled state may have changed: make a note of it. */
|
/* the unjournaled state may have changed: make a note of it. */
|
||||||
record_unjournaled();
|
record_unjournaled();
|
||||||
|
|
||||||
|
++_dirty;
|
||||||
|
|
||||||
if ( ! _fp )
|
if ( ! _fp )
|
||||||
/* tearing down... don't bother */
|
/* tearing down... don't bother */
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -95,6 +95,8 @@ private:
|
||||||
|
|
||||||
int _nest;
|
int _nest;
|
||||||
|
|
||||||
|
static int _dirty; /* count of changes */
|
||||||
|
|
||||||
static void ensure_size ( size_t n );
|
static void ensure_size ( size_t n );
|
||||||
|
|
||||||
void log_print ( const Log_Entry *o, const Log_Entry *n ) const;
|
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 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;
|
void log_create ( void ) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Reference in New Issue