From fb507bc9e0c9043a0fdbc72d0d80955e9db1531a Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Fri, 19 Dec 2008 16:18:56 +0000 Subject: [PATCH] fixed broken version comparing which indicated 0.x.y to be less than 0.x.y-patch - fixes messed up projects when loading files created with LMMS 0.4.0 git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1958 0778d3d1-df1d-0410-868b-ea421aaaa00d --- src/core/project_version.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/core/project_version.cpp b/src/core/project_version.cpp index 5577db70e..525af341a 100644 --- a/src/core/project_version.cpp +++ b/src/core/project_version.cpp @@ -42,7 +42,7 @@ int projectVersion::compare( const projectVersion & _v1, n2 = _v2.section( '.', 0, 0 ).toInt(); if( n1 != n2 ) { - return( n1 - n2 ); + return n1 - n2; } // Minor @@ -50,7 +50,7 @@ int projectVersion::compare( const projectVersion & _v1, n2 = _v2.section( '.', 1, 1 ).toInt(); if( n1 != n2 ) { - return( n1 - n2 ); + return n1 - n2; } // Release @@ -58,12 +58,24 @@ int projectVersion::compare( const projectVersion & _v1, n2 = _v2.section( '.', 2 ).section( '-', 0, 0 ).toInt(); if( n1 != n2 ) { - return( n1 - n2 ); + return n1 - n2; } // Build - return( QString::compare( _v1.section( '.', 2 ).section( '-', 1 ), - _v2.section( '.', 2 ).section( '-', 1 ) ) ); + const QString b1 = _v1.section( '.', 2 ).section( '-', 1 ); + const QString b2 = _v2.section( '.', 2 ).section( '-', 1 ); + + // make sure 0.x.y > 0.x.y-patch + if( b1.isEmpty() ) + { + return 1; + } + if( b2.isEmpty() ) + { + return -1; + } + + return QString::compare( b1, b2 ); }