From ea80d01f8b445495ecdfe5266971dedb67cff6cd Mon Sep 17 00:00:00 2001 From: Spekular Date: Wed, 21 Jan 2015 13:04:19 +0100 Subject: [PATCH] Adds dialog when project is opened that was made with a different version of LMMS Remove Commented Out Code Update DataFile.cpp Update DataFile.cpp Update DataFile.cpp Changes per tresf's advice, adds comments Git??? Please work :/ Update DataFile.cpp Adds dialog when project is opened that was made with a different version of LMMS Remove Commented Out Code Update DataFile.cpp Update DataFile.cpp Update DataFile.cpp Changes per tresf's advice, adds comments Git??? Please work :/ Update DataFile.cpp --- src/core/DataFile.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/core/DataFile.cpp b/src/core/DataFile.cpp index 0cd7a5703..a9739f412 100644 --- a/src/core/DataFile.cpp +++ b/src/core/DataFile.cpp @@ -37,6 +37,7 @@ #include "ConfigManager.h" #include "ProjectVersion.h" +#include "ProjectVersion.h" #include "SongEditor.h" #include "Effect.h" #include "lmmsversion.h" @@ -779,10 +780,35 @@ void DataFile::loadData( const QByteArray & _data, const QString & _sourceFile ) m_type = type( root.attribute( "type" ) ); m_head = root.elementsByTagName( "head" ).item( 0 ).toElement(); - if( root.hasAttribute( "creatorversion" ) && - root.attribute( "creatorversion" ) != LMMS_VERSION ) + + if( root.hasAttribute( "creatorversion" ) ) { - upgrade(); + //compareType defaults to Build,so it doesn't have to be set here + ProjectVersion createdWith = root.attribute( "creatorversion" ); + ProjectVersion openedWith = LMMS_VERSION;; + + if (createdWith != openedWith) + { + //Only one compareType needs to be set, and "[The] ProjectVersion return type + //from the setCompareType(...) function [...] saves a few lines of code!" (@tresf) + if ( createdWith.setCompareType(Minor) != openedWith) + { + QMessageBox::information( NULL, + SongEditor::tr( "Project Version Mismatch" ), + SongEditor::tr( + "This project was created with " + "LMMS version %1, but version %2 " + "is installed") + .arg( root.attribute( "creatorversion" ) ) + .arg( LMMS_VERSION ) ); + } + + //The upgrade needs to happen after the warning as it updates the project version. + if( createdWith.setCompareType(Build) < openedWith ) + { + upgrade(); + } + } } m_content = root.elementsByTagName( typeName( m_type ) ).