[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r1602: Split version strings at either "." or "-", so we don't mess (/ trunk/src/control)
Author: edmanm
Date: 2007-01-20 17:42:39 -0500 (Sat, 20 Jan 2007)
New Revision: 1602
Modified:
/
trunk/src/control/torcontrol.cpp
Log:
Split version strings at either "." or "-", so we don't mess up parsing the
patch level. Also only recompute the numeric form of the version when the
string version changes.
Property changes on:
___________________________________________________________________
svk:merge ticket from /vidalia/local [r1605] on 54b3572a-7227-0410-958f-53ecd705b71a
Modified: trunk/src/control/torcontrol.cpp
===================================================================
--- trunk/src/control/torcontrol.cpp 2007-01-20 22:36:53 UTC (rev 1601)
+++ trunk/src/control/torcontrol.cpp 2007-01-20 22:42:39 UTC (rev 1602)
@@ -502,16 +502,26 @@
quint32
TorControl::getTorVersion()
{
+ static QString versionString;
+ static quint32 version = 0;
quint8 major, minor, micro, patch;
- quint32 version = 0;
-
- QStringList parts = getTorVersionString().split(".");
+
+ /* Only recompute the version number if the version string changed */
+ if (versionString == _torVersion)
+ return version;
+ versionString = _torVersion;
+
+ /* Split the version string at either "." or "-" characters */
+ QStringList parts = versionString.split(QRegExp("\\.|-"));
if (parts.size() >= 4) {
major = (quint8)parts.at(0).toUInt();
minor = (quint8)parts.at(1).toUInt();
micro = (quint8)parts.at(2).toUInt();
patch = (quint8)parts.at(3).toUInt();
version = ((major << 24) | (minor << 16) | (micro << 8) | patch);
+ } else {
+ /* Couldn't parse the version string */
+ version = 0;
}
return version;
}