Do not change the current Directory

Qt has a really strange API for directories. when you create a QDir
and set's the currentDir on *that* QDir you created, it's for the
whole application and not just for that variable. Then when the
variable is out of scope, the directory doesn't change back - ugh.

The solution is not to call setCurrentDir on the newly created QDir (which
was quite good since it's also a code cleanup. )

[Dirk Hohndel: modified to undo the far less elegant fix I had made in an
               earlier commit]

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2013-12-06 18:30:05 -02:00 committed by Dirk Hohndel
parent b04666922b
commit 61d5aac2e8

View file

@ -1765,9 +1765,7 @@ LanguageModel* LanguageModel::instance()
LanguageModel::LanguageModel(QObject* parent): QAbstractListModel(parent) LanguageModel::LanguageModel(QObject* parent): QAbstractListModel(parent)
{ {
QSettings s; QSettings s;
QDir d; QDir d(getSubsurfaceDataPath("translations"));
QString cwd = d.currentPath();
d.setCurrent( getSubsurfaceDataPath("translations") );
QStringList result = d.entryList(); QStringList result = d.entryList();
Q_FOREACH(const QString& s, result){ Q_FOREACH(const QString& s, result){
if ( !s.endsWith(".qm") ){ if ( !s.endsWith(".qm") ){
@ -1775,7 +1773,6 @@ LanguageModel::LanguageModel(QObject* parent): QAbstractListModel(parent)
} }
languages.push_back( (s == "subsurface_source.qm") ? "English" : s); languages.push_back( (s == "subsurface_source.qm") ? "English" : s);
} }
d.setCurrent(cwd);
} }
QVariant LanguageModel::data(const QModelIndex& index, int role) const QVariant LanguageModel::data(const QModelIndex& index, int role) const