Skip to content

Commit

Permalink
patch Qt 5.4.1 to use XDG_CONFIG_DIRS in QSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
ellis committed Apr 23, 2015
1 parent 02cda21 commit bafde0f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
42 changes: 42 additions & 0 deletions pkgs/development/libraries/qt-5/5.4/0013-xdg_config_dirs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
diff --git a/qsettings.cpp b/qsettings.cpp
index 35b3ed4..210dfeb 100644
--- a/qsettings.cpp
+++ b/qtbase/src/corelib/io/qsettings.cpp
@@ -1174,6 +1174,24 @@ QConfFileSettingsPrivate::QConfFileSettingsPrivate(QSettings::Format format,
if (!application.isEmpty())
confFiles[F_System | F_Application].reset(QConfFile::fromName(systemPath + appFile, false));
confFiles[F_System | F_Organization].reset(QConfFile::fromName(systemPath + orgFile, false));
+
+#if !defined(Q_OS_WIN)
+ // Add directories specified in $XDG_CONFIG_DIRS
+ const QString pathEnv = QString::fromLocal8Bit(getenv("XDG_CONFIG_DIRS"));
+ if (!pathEnv.isEmpty()) {
+ const QStringList pathEntries = pathEnv.split(QLatin1Char(':'), QString::SkipEmptyParts);
+ if (!pathEntries.isEmpty()) {
+ int j = 4; // This is the number of confFiles set above -- we need to start adding $XDG_CONFIG_DIRS after those.
+ for (int k = 0; k < pathEntries.size() && j < NumConfFiles - 1; ++k) {
+ const QString& path = pathEntries.at(k);
+ if (!application.isEmpty())
+ confFiles[j++].reset(QConfFile::fromName(path + QDir::separator() + appFile, false));
+ confFiles[j++].reset(QConfFile::fromName(path + QDir::separator() + orgFile, false));
+ }
+ }
+ }
+#endif
+
#else
QString confName = getPath(format, QSettings::UserScope) + org;
if (!application.isEmpty())
diff --git a/qsettings_p.h b/qsettings_p.h
index a28b583..b2a240d 100644
--- a/qsettings_p.h
+++ b/qtbase/src/corelib/io/qsettings_p.h
@@ -244,7 +244,7 @@ public:
F_Organization = 0x1,
F_User = 0x0,
F_System = 0x2,
- NumConfFiles = 4
+ NumConfFiles = 40 // HACK: increase NumConfFiles from 4 to 40 in order to accommodate more paths in $XDG_CONFIG_DIRS -- ellis
#else
SandboxConfFile = 0,
NumConfFiles = 1
1 change: 1 addition & 0 deletions pkgs/development/libraries/qt-5/5.4/qtbase.nix
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ stdenv.mkDerivation {
(substituteAll { src = ./0010-dlopen-libXcursor.patch; inherit libXcursor; })
(substituteAll { src = ./0011-dlopen-openssl.patch; inherit openssl; })
(substituteAll { src = ./0012-dlopen-dbus.patch; dbus_libs = dbus; })
./0013-xdg_config_dirs.patch
];

preConfigure = ''
Expand Down

0 comments on commit bafde0f

Please sign in to comment.