Fix regressions on loading broken projects (#3013)

This commit is contained in:
Oskar Wallgren
2016-09-08 22:18:23 +02:00
committed by GitHub
parent a53fd2663b
commit eb86e25fd8
2 changed files with 15 additions and 3 deletions

View File

@@ -340,6 +340,7 @@ private:
QString m_fileName;
QString m_oldFileName;
bool m_modified;
bool m_loadOnLaunch;
volatile bool m_recording;
volatile bool m_exporting;

View File

@@ -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,6 +1083,7 @@ void Song::loadProject( const QString & fileName )
m_loadingProject = false;
m_modified = false;
m_loadOnLaunch = false;
if( gui && gui->mainWindow() )
{
@@ -1180,6 +1190,7 @@ void Song::importProject()
{
ImportFilter::import( ofd.selectedFiles()[0], this );
}
m_loadOnLaunch = false;
}