summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2009-09-11 07:00:26 (GMT)
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2009-09-11 07:00:26 (GMT)
commitebefcd1c0d4286a58bea2b4859d471df07f1f013 (patch)
treeb7ce4e0f709cd0dcc51eeb7c9d9265a6f972a90a /src/corelib/global
parent0adc0bc91d0745177a30ce5899583f5e127d01b9 (diff)
downloadQt-ebefcd1c0d4286a58bea2b4859d471df07f1f013.zip
Qt-ebefcd1c0d4286a58bea2b4859d471df07f1f013.tar.gz
Qt-ebefcd1c0d4286a58bea2b4859d471df07f1f013.tar.bz2
Optimized S60 version check.
Use pure Symbian code to get S60 version, because if done using QDir, there will be a call back to this method, resulting doing this expensive operation twice before the cache kicks in. Pure Symbian code also makes this method ~10x faster, speeding up the application launch. Task-number: 260757 Reviewed-by: Janne Anttila
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qglobal.cpp50
1 files changed, 29 insertions, 21 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index a790dc1..9909b7b 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -75,6 +75,11 @@
#if defined(Q_OS_SYMBIAN)
#include <e32def.h>
#include <e32debug.h>
+#include <f32file.h>
+# include "private/qcore_symbian_p.h"
+
+_LIT(qt_S60Filter, "Series60v?.*.sis");
+_LIT(qt_S60SystemInstallDir, "z:\\system\\install\\");
#endif
QT_BEGIN_NAMESPACE
@@ -1786,28 +1791,31 @@ QSysInfo::S60Version QSysInfo::s60Version()
if (cachedS60Version != -1)
return cachedS60Version;
- QDir dir(QLatin1String("z:\\system\\install"));
- QStringList filters;
- filters << QLatin1String("Series60v?.*.sis");
- dir.setNameFilters(filters);
-
- QStringList names = dir.entryList(QDir::NoFilter, QDir::Name | QDir::Reversed | QDir::IgnoreCase);
- if (names.size() == 0)
- return cachedS60Version = SV_S60_Unknown;
-
- int major, minor;
- major = names[0][9].toAscii() - '0';
- minor = names[0][11].toAscii() - '0';
- if (major == 3) {
- if (minor == 1) {
- return cachedS60Version = SV_S60_3_1;
- } else if (minor == 2) {
- return cachedS60Version = SV_S60_3_2;
- }
- } else if (major == 5) {
- if (minor == 0) {
- return cachedS60Version = SV_S60_5_0;
+ // Use pure Symbian code, because if done using QDir, there will be a call back
+ // to this method, resulting doing this expensive operation twice before the cache kicks in.
+ // Pure Symbian code also makes this method ~10x faster, speeding up the application launch.
+ RFs rfs = qt_s60GetRFs();
+ TFindFile fileFinder(rfs);
+ CDir* contents;
+ TInt err = fileFinder.FindWildByDir(qt_S60Filter, qt_S60SystemInstallDir, contents);
+ if (err == KErrNone) {
+ err = contents->Sort(EDescending|ESortByName);
+ if (err == KErrNone) {
+ TInt major = (*contents)[0].iName[9] - '0';
+ TInt minor = (*contents)[0].iName[11] - '0';
+ if (major == 3) {
+ if (minor == 1) {
+ return cachedS60Version = SV_S60_3_1;
+ } else if (minor == 2) {
+ return cachedS60Version = SV_S60_3_2;
+ }
+ } else if (major == 5) {
+ if (minor == 0) {
+ return cachedS60Version = SV_S60_5_0;
+ }
+ }
}
+ delete contents;
}
return cachedS60Version = SV_S60_Unknown;