don't change the current project when auto-saving

every time auto-save ran, it would change the current project to
"recover.mmp". Now it doesn't do this because Song has
guiSaveProject(), guiSaveProjectAs(), and saveProjectFile().
(the latter is used for auto-save)
This commit is contained in:
Andrew Kelley
2009-11-13 18:43:08 -07:00
parent f73ccadc17
commit 953522f34a
4 changed files with 22 additions and 15 deletions

View File

@@ -151,9 +151,10 @@ public:
// file management
void createNewProject();
void createNewProjectFromTemplate( const QString & _template );
void loadProject( const QString & _file_name );
bool saveProject();
bool saveProjectAs( const QString & _file_name );
void loadProject( const QString & _filename );
bool guiSaveProject();
bool guiSaveProjectAs( const QString & _filename );
bool saveProjectFile( const QString & _filename );
inline const QString & projectFileName() const
{
return m_fileName;

View File

@@ -531,7 +531,7 @@ int main( int argc, char * * argv )
}
else
{
engine::getSong()->saveProjectAs( file_to_save );
engine::getSong()->saveProjectFile( file_to_save );
return( 0 );
}
}

View File

@@ -994,10 +994,8 @@ void song::loadProject( const QString & _file_name )
}
// save current song
bool song::saveProject()
// only save current song as _filename and do nothing else
bool song::saveProjectFile( const QString & _filename )
{
multimediaProject mmp( multimediaProject::SongProject );
@@ -1006,7 +1004,6 @@ bool song::saveProject()
m_masterVolumeModel.saveSettings( mmp, mmp.head(), "mastervol" );
m_masterPitchModel.saveSettings( mmp, mmp.head(), "masterpitch" );
saveState( mmp, mmp.content() );
m_globalAutomationTrack->saveState( mmp, mmp.content() );
@@ -1024,8 +1021,17 @@ bool song::saveProject()
saveControllerStates( mmp, mmp.content() );
return mmp.writeFile( _filename );
}
// save current song and update the gui
bool song::guiSaveProject()
{
multimediaProject mmp( multimediaProject::SongProject );
m_fileName = mmp.nameWithExtension( m_fileName );
if( mmp.writeFile( m_fileName ) == true && engine::hasGUI() )
if( saveProjectFile( m_fileName ) && engine::hasGUI() )
{
textFloat::displayMessage( tr( "Project saved" ),
tr( "The project %1 is now saved."
@@ -1052,12 +1058,12 @@ bool song::saveProject()
// save current song in given filename
bool song::saveProjectAs( const QString & _file_name )
bool song::guiSaveProjectAs( const QString & _file_name )
{
QString o = m_oldFileName;
m_oldFileName = m_fileName;
m_fileName = _file_name;
if( saveProject() == false )
if( guiSaveProject() == false )
{
m_fileName = m_oldFileName;
m_oldFileName = o;

View File

@@ -1007,7 +1007,7 @@ bool MainWindow::saveProject()
}
else
{
engine::getSong()->saveProject();
engine::getSong()->guiSaveProject();
}
return true;
}
@@ -1036,7 +1036,7 @@ bool MainWindow::saveProjectAs()
if( sfd.exec () == QFileDialog::Accepted &&
!sfd.selectedFiles().isEmpty() && sfd.selectedFiles()[0] != "" )
{
engine::getSong()->saveProjectAs(
engine::getSong()->guiSaveProjectAs(
sfd.selectedFiles()[0] );
return true;
}
@@ -1568,7 +1568,7 @@ void MainWindow::toggleRecordAutomation( bool _recording )
void MainWindow::autoSave()
{
QDir work(configManager::inst()->workingDir());
engine::getSong()->saveProjectAs(work.absoluteFilePath("recover.mmp"));
engine::getSong()->saveProjectFile(work.absoluteFilePath("recover.mmp"));
}