From f01076856b4443d19eff0dd6bc52bd4387f55ccd Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Wed, 18 Jul 2012 21:04:47 +0200 Subject: [PATCH] Don't add double "/" to paths. --- src/core/FilePath.cpp | 19 ++++++++++++------- src/core/FilePath.h | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/core/FilePath.cpp b/src/core/FilePath.cpp index 231d146a..82e330d7 100644 --- a/src/core/FilePath.cpp +++ b/src/core/FilePath.cpp @@ -27,7 +27,12 @@ FilePath* FilePath::m_instance(Q_NULLPTR); QString FilePath::dataPath(const QString& name) { - return m_basePath + name; + if (name.isEmpty() || name.startsWith('/')) { + return m_dataPath + name; + } + else { + return m_dataPath + "/" + name; + } } QString FilePath::pluginPath(const QString& name) @@ -76,12 +81,12 @@ QIcon FilePath::icon(const QString& category, const QString& name, bool fromThem pngSizes << "16" << "22" << "24" << "32" << "48" << "64" << "128"; QString filename; Q_FOREACH (const QString& size, pngSizes) { - filename = QString("%1/icons/application/%2x%2/%3/%4.png").arg(m_basePath, size, category, name); + filename = QString("%1/icons/application/%2x%2/%3/%4.png").arg(m_dataPath, size, category, name); if (QFile::exists(filename)) { icon.addFile(filename); } } - filename = QString("%1/icons/application/scalable/%3/%4.svgz").arg(m_basePath, category, name); + filename = QString("%1/icons/application/scalable/%3/%4.svgz").arg(m_dataPath, category, name); if (QFile::exists(filename)) { icon.addFile(filename); } @@ -111,18 +116,18 @@ FilePath::FilePath() } #endif - if (m_basePath.isEmpty()) { - qWarning("DataPath::DataPath: can't find data dir"); + if (m_dataPath.isEmpty()) { + qWarning("FilePath::DataPath: can't find data dir"); } else { - m_basePath = QDir::cleanPath(m_basePath) + "/"; + m_dataPath = QDir::cleanPath(m_dataPath); } } bool FilePath::testSetDir(const QString& dir) { if (QFile::exists(dir + "/icons/database/C00_Password.png")) { - m_basePath = dir; + m_dataPath = dir; return true; } else { diff --git a/src/core/FilePath.h b/src/core/FilePath.h index 3ecb7af9..5c5339d0 100644 --- a/src/core/FilePath.h +++ b/src/core/FilePath.h @@ -39,7 +39,7 @@ private: static FilePath* m_instance; - QString m_basePath; + QString m_dataPath; Q_DISABLE_COPY(FilePath) };