Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.8.3, 5.4.0 Beta
-
None
-
Windows Home 7.
Description
If QTranslator::load is called with a filename and no directory, QCoreApplication::applicationDirPath() is not used as the default path for non-Symbian OS. The logic in #ifdef Q_OS_SYMBIAN for dir.isEmpty() should also be included in the #else clause of the #ifdef. Without this, the current directory is used instead which on Windows 7 defualts to the level above the directory where the .exe file is created. This problem occurs in the example hellotr.
The example program does work correctly if the call to load is modified to provide QCoreApplication::applicationDirPath() as the directory argument to load.
bool QTranslator::load(const QString & filename, const QString & directory, const QString & search_delimiters, const QString & suffix) { Q_D(QTranslator); d->clear(); QString fname = filename; QString prefix; if (QFileInfo(filename).isRelative()) { #ifdef Q_OS_SYMBIAN //TFindFile doesn't like path in the filename QString dir(directory); int slash = filename.lastIndexOf(QLatin1Char('/')); slash = qMax(slash, filename.lastIndexOf(QLatin1Char('\\'))); if (slash >=0) { //so move the path component into the directory prefix if (dir.isEmpty()) dir = filename.left(slash + 1); else dir = dir + QLatin1Char('/') + filename.left(slash + 1); fname = fname.mid(slash + 1); } if (dir.isEmpty()) prefix = QCoreApplication::applicationDirPath(); else prefix = QFileInfo(dir).absoluteFilePath(); //TFindFile doesn't like dirty paths if (prefix.length() > 2 && prefix.at(1) == QLatin1Char(':') && prefix.at(0).isLetter()) prefix[0] = QLatin1Char('Y'); #else prefix = directory; #endif if (prefix.length() && !prefix.endsWith(QLatin1Char('/'))) prefix += QLatin1Char('/'); } }