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/branches/lmms/stable-0.4@1961 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-12-19 16:21:34 +00:00
parent 340c47baf0
commit 10f2fab3d2
2 changed files with 19 additions and 6 deletions

View File

@@ -47,7 +47,7 @@ public:
inline bool operator<( const projectVersion & _v1, const char * _str )
{
return( projectVersion::compare( _v1, projectVersion( _str ) ) < 0 );
return projectVersion::compare( _v1, projectVersion( _str ) ) < 0;
}

View File

@@ -4,6 +4,7 @@
* project_version.cpp - compare versions in import upgrades
*
* Copyright (c) 2007 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -42,7 +43,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 +51,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 +59,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 );
}