Commit f38af6a3 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Solved multiple bugs in project manager

parent b0b13fa8
......@@ -516,12 +516,8 @@ bool MainWindow::restoreSession()
}
else
{
QString lastProject = recentProjects.first() + "backup";
if ( QFile::exists( lastProject ) == true )
{
ProjectManager::getInstance()->loadProject( lastProject );
if ( ProjectManager::getInstance()->loadEmergencyBackup( recentProjects.first() ) == true )
ret = true;
}
else
QMessageBox::warning( this, tr( "Can't restore project" ), tr( "VLMC didn't manage to restore your project. We appology for the inconvenience" ) );
}
......
......@@ -96,7 +96,6 @@ void ProjectManager::cleanChanged( bool val )
void ProjectManager::loadTimeline()
{
QDomElement root = m_domDocument->documentElement();
QFileInfo fInfo( *m_projectFile );
MainWorkflow::getInstance()->loadProject( root.firstChildElement( "timeline" ) );
emit projectUpdated( m_projectName, true );
......@@ -116,16 +115,6 @@ void ProjectManager::loadProject( const QString& fileName )
if ( closeProject() == false )
return ;
// Append the item to the recents list
m_recentsProjects.removeAll( fileName );
m_recentsProjects.prepend( fileName );
while ( m_recentsProjects.count() > 15 )
m_recentsProjects.removeLast();
QSettings s;
s.setValue( "RecentsProjects", m_recentsProjects );
s.sync();
m_projectFile = new QFile( fileName );
m_domDocument = new QDomDocument;
......@@ -133,6 +122,26 @@ void ProjectManager::loadProject( const QString& fileName )
m_domDocument->setContent( m_projectFile );
m_projectFile->close();
if ( ProjectManager::isBackupFile( fileName ) == false )
{
// Append the item to the recents list
m_recentsProjects.removeAll( fileName );
m_recentsProjects.prepend( fileName );
while ( m_recentsProjects.count() > 15 )
m_recentsProjects.removeLast();
QSettings s;
s.setValue( "RecentsProjects", m_recentsProjects );
s.sync();
}
else
{
//Delete the project file representation, so the next time the user
//saves its project, vlmc will ask him where to save it.
delete m_projectFile;
m_projectFile = NULL;
}
QDomElement root = m_domDocument->documentElement();
parseProjectNode( root.firstChildElement( "project" ) );
......@@ -270,3 +279,19 @@ void ProjectManager::emergencyBackup()
__saveProject( name );
}
}
bool ProjectManager::loadEmergencyBackup( const QString& projectName )
{
QString lastProject = projectName + "backup";
if ( QFile::exists( lastProject ) == true )
{
loadProject( lastProject );
return true;
}
return false;
}
bool ProjectManager::isBackupFile( const QString& projectFile )
{
return projectFile.endsWith( "backup" );
}
......@@ -45,6 +45,7 @@ public:
QStringList recentsProjects() const;
bool closeProject();
bool askForSaveIfModified();
bool loadEmergencyBackup( const QString& projectFile );
static void signalHandler( int sig );
......@@ -56,6 +57,7 @@ private:
void __saveProject( const QString& fileName );
void parseProjectNode( const QDomElement& node );
void emergencyBackup();
static bool isBackupFile( const QString& projectFile );
ProjectManager();
~ProjectManager();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment