Skip to content

Commit

Permalink
Fix regressions on loading broken projects (LMMS#3013)
Browse files Browse the repository at this point in the history
  • Loading branch information
zonkmachine authored Sep 8, 2016
1 parent 5942b64 commit 65f4114
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/Song.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 14 additions & 3 deletions src/core/Song.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ),
Expand Down Expand Up @@ -911,6 +912,7 @@ void Song::createNewProject()
QCoreApplication::sendPostedEvents();

m_modified = false;
m_loadOnLaunch = false;

if( gui->mainWindow() )
{
Expand All @@ -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();
}

}


Expand All @@ -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();
Expand Down Expand Up @@ -1074,6 +1083,7 @@ void Song::loadProject( const QString & fileName )

m_loadingProject = false;
m_modified = false;
m_loadOnLaunch = false;

if( gui && gui->mainWindow() )
{
Expand Down Expand Up @@ -1180,6 +1190,7 @@ void Song::importProject()
{
ImportFilter::import( ofd.selectedFiles()[0], this );
}
m_loadOnLaunch = false;
}


Expand Down

0 comments on commit 65f4114

Please sign in to comment.