auto-saves every minute and recovers upon crash

auto-save time is not configurable yet. saves "recover.mmp" to
WORKING_DIR every 60 seconds. Deletes recover.mmp on successful
close of LMMS. If recover.mmp is found upon start, it loads that
project.
(cherry picked from comit f73ccadc17)
This commit is contained in:
Andrew Kelley
2009-11-10 21:41:45 -07:00
committed by Tobias Doerffel
parent 6280fd9faf
commit d75677b9d3
3 changed files with 29 additions and 2 deletions

View File

@@ -72,7 +72,8 @@ MainWindow::MainWindow( void ) :
m_workspace( NULL ),
m_templatesMenu( NULL ),
m_recentlyOpenedProjectsMenu( NULL ),
m_toolsMenu( NULL )
m_toolsMenu( NULL ),
m_autoSaveTimer( this )
{
setAttribute( Qt::WA_DeleteOnClose );
@@ -182,6 +183,10 @@ MainWindow::MainWindow( void ) :
m_updateTimer.start( 1000 / 20, this ); // 20 fps
// connect auto save
connect(&m_autoSaveTimer, SIGNAL(timeout()), this, SLOT(autoSave()));
m_autoSaveTimer.start(1000 * 60); // 1 minute
}
@@ -898,6 +903,9 @@ void MainWindow::closeEvent( QCloseEvent * _ce )
{
if( mayChangeProject() )
{
// delete recovery file
QDir working(configManager::inst()->workingDir());
working.remove("recover.mmp");
_ce->accept();
}
else
@@ -969,7 +977,7 @@ void MainWindow::keyReleaseEvent( QKeyEvent * _ke )
void MainWindow::timerEvent( QTimerEvent * )
void MainWindow::timerEvent( QTimerEvent * _te)
{
emit periodicUpdate();
}
@@ -1037,6 +1045,13 @@ void MainWindow::browseHelp( void )
void MainWindow::autoSave()
{
QDir work(configManager::inst()->workingDir());
engine::getSong()->saveProjectAs(work.absoluteFilePath("recover.mmp"));
}
#include "moc_MainWindow.cxx"