diff --git a/include/Song.h b/include/Song.h index 56f3ffe9b86..c8c5656e927 100644 --- a/include/Song.h +++ b/include/Song.h @@ -340,6 +340,7 @@ private slots: QString m_fileName; QString m_oldFileName; bool m_modified; + bool m_loadOnLaunch; volatile bool m_recording; volatile bool m_exporting; diff --git a/src/core/Song.cpp b/src/core/Song.cpp index 845540f93f4..f51df87515f 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -85,6 +85,7 @@ Song::Song() : m_fileName(), m_oldFileName(), m_modified( false ), + m_loadOnLaunch( true ), m_recording( false ), m_exporting( false ), m_exportLoop( false ), @@ -911,6 +912,7 @@ void Song::createNewProject() QCoreApplication::sendPostedEvents(); m_modified = false; + m_loadOnLaunch = false; if( gui->mainWindow() ) { @@ -928,11 +930,11 @@ void Song::createNewProjectFromTemplate( const QString & templ ) // saving... m_fileName = m_oldFileName = ""; // update window title + m_loadOnLaunch = false; if( gui->mainWindow() ) { gui->mainWindow()->resetWindowTitle(); } - } @@ -947,17 +949,24 @@ void Song::loadProject( const QString & fileName ) Engine::projectJournal()->setJournalling( false ); + m_oldFileName = m_fileName; m_fileName = fileName; - m_oldFileName = fileName; DataFile dataFile( m_fileName ); // if file could not be opened, head-node is null and we create // new project - if( dataFile.validate( fileName.right( fileName.lastIndexOf(".") ) ) ) + if( dataFile.head().isNull() ) { + if( m_loadOnLaunch ) + { + createNewProject(); + } + m_fileName = m_oldFileName; return; } + m_oldFileName = m_fileName; + clearProject(); clearErrors(); @@ -1074,11 +1083,13 @@ void Song::loadProject( const QString & fileName ) m_loadingProject = false; m_modified = false; + m_loadOnLaunch = false; if( gui && gui->mainWindow() ) { gui->mainWindow()->resetWindowTitle(); } + qDebug() << "End of Song::loadProject..."; } @@ -1180,6 +1191,7 @@ void Song::importProject() { ImportFilter::import( ofd.selectedFiles()[0], this ); } + m_loadOnLaunch = false; }