Merge lp:~3v1n0/sni-qt/use-xdg-runtime-dir into lp:sni-qt

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: 105
Merged at revision: 105
Proposed branch: lp:~3v1n0/sni-qt/use-xdg-runtime-dir
Merge into: lp:sni-qt
Diff against target: 33 lines (+6/-2)
2 files modified
src/fsutils.cpp (+5/-2)
tests/auto/fsutilstest.cpp (+1/-0)
To merge this branch: bzr merge lp:~3v1n0/sni-qt/use-xdg-runtime-dir
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Review via email: mp+314628@code.launchpad.net

Commit message

fsutils: always use $XDG_RUNTIME_DIR if it's set for saving icons

Now that also $SNAP supports it, we can just be less hackish

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/fsutils.cpp'
2--- src/fsutils.cpp 2016-11-16 17:00:33 +0000
3+++ src/fsutils.cpp 2017-01-12 15:23:22 +0000
4@@ -33,13 +33,16 @@
5 QString generateTempDir(const QString& prefix)
6 {
7 QDir dir;
8+ QString path = QString::fromUtf8(getenv("XDG_RUNTIME_DIR"));
9
10- if (!getenv("SNAP")) {
11+ if (!path.isEmpty()) {
12+ dir.setPath(path);
13+ } else if (!getenv("SNAP")) {
14 dir = QDir::temp();
15 } else {
16 // Try to get the .cache from $XDG_CACHE_HOME, if it's not set,
17 // it has to be in ~/.cache as per XDG standard
18- QString path = QString::fromUtf8(getenv("XDG_CACHE_HOME"));
19+ path = QString::fromUtf8(getenv("XDG_CACHE_HOME"));
20 if (path.isEmpty()) {
21 path = QDir::cleanPath(QDir::homePath() + "/.cache");
22 }
23
24=== modified file 'tests/auto/fsutilstest.cpp'
25--- tests/auto/fsutilstest.cpp 2011-10-15 12:32:18 +0000
26+++ tests/auto/fsutilstest.cpp 2017-01-12 15:23:22 +0000
27@@ -49,6 +49,7 @@
28 {
29 QDir::setCurrent(m_baseDirName);
30 m_sandBoxDirName = m_baseDirName + "/sandbox";
31+ setenv("XDG_RUNTIME_DIR", m_sandBoxDirName.toLocal8Bit().constData(), 1 /*overwrite*/);
32 setenv("TMPDIR", m_sandBoxDirName.toLocal8Bit().constData(), 1 /*overwrite*/);
33 }
34

Subscribers

People subscribed via source and target branches