Merge lp:~zsombi/ubuntu-ui-toolkit/statesaver_path into lp:ubuntu-ui-toolkit/staging

Proposed by Zsombor Egri
Status: Merged
Approved by: Cris Dywan
Approved revision: 1274
Merged at revision: 1274
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/statesaver_path
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 58 lines (+21/-7)
2 files modified
modules/Ubuntu/Components/plugin/statesaverbackend_p.cpp (+18/-5)
modules/Ubuntu/Components/plugin/ucapplication.cpp (+3/-2)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/statesaver_path
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Cris Dywan Approve
Review via email: mp+236847@code.launchpad.net

Commit message

Workaround for StateSaver to fall back to use qgetenv() when QStandardPaths fails to return XDG_RUNTIME_DIR path.

To post a comment you must log in.
Revision history for this message
Cris Dywan (kalikiana) wrote :

Looking good!

review: Approve
Revision history for this message
Bill Filler (bfiller) wrote :

+1 from me, tested on device and working

Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/plugin/statesaverbackend_p.cpp'
2--- modules/Ubuntu/Components/plugin/statesaverbackend_p.cpp 2014-09-04 16:24:57 +0000
3+++ modules/Ubuntu/Components/plugin/statesaverbackend_p.cpp 2014-10-02 15:21:30 +0000
4@@ -72,15 +72,28 @@
5 delete m_archive.data();
6 m_archive.clear();
7 }
8- QString applicationName(qgetenv("APP_ID"));
9+ QString applicationName(UCApplication::instance().applicationName());
10 if (applicationName.isEmpty()) {
11- applicationName = UCApplication::instance().applicationName();
12+ qCritical() << "[StateSaver] Cannot create appstate file, application name not defined.";
13+ return;
14 }
15 // make sure the path is in sync with https://wiki.ubuntu.com/SecurityTeam/Specifications/ApplicationConfinement
16 // the file must be saved under XDG_RUNTIME_DIR/<APP_PKGNAME> path.
17- m_archive = new QSettings(QString("%1/%2/statesaver.appstate")
18- .arg(QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation))
19- .arg(applicationName), QSettings::NativeFormat);
20+ // NOTE!!: we cannot use QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation)
21+ // as that is going to perform a chmod +w on the path, see bug #1359831. Therefore we must
22+ // fetch the XDG_RUNTIME_DIR either from QStandardPaths::standardLocations() or from env var
23+ // see bug https://bugreports.qt-project.org/browse/QTBUG-41735
24+ QString runtimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
25+ if (runtimeDir.isEmpty()) {
26+ runtimeDir = qgetenv("XDG_RUNTIME_DIR");
27+ }
28+ if (runtimeDir.isEmpty()) {
29+ qCritical() << "[StateSaver] No XDG_RUNTIME_DIR path set, cannot create appstate file.";
30+ return;
31+ }
32+ m_archive = new QSettings(QString("%1/%2/statesaver.appstate").
33+ arg(runtimeDir).
34+ arg(applicationName), QSettings::NativeFormat);
35 m_archive->setFallbacksEnabled(false);
36 }
37
38
39=== modified file 'modules/Ubuntu/Components/plugin/ucapplication.cpp'
40--- modules/Ubuntu/Components/plugin/ucapplication.cpp 2014-08-08 10:43:55 +0000
41+++ modules/Ubuntu/Components/plugin/ucapplication.cpp 2014-10-02 15:21:30 +0000
42@@ -35,6 +35,9 @@
43 */
44 UCApplication::UCApplication(QObject* parent) : QObject(parent), m_context(0)
45 {
46+ // Make sure we receive application name changes from C++ modules
47+ connect(QCoreApplication::instance(), &QCoreApplication::applicationNameChanged,
48+ this, &UCApplication::applicationNameChanged);
49 }
50
51 void UCApplication::setContext(QQmlContext* context) {
52@@ -68,7 +71,5 @@
53 engine->setOfflineStoragePath(dataFolder);
54 // Get Qtlabs.settings to use a sane path
55 QCoreApplication::setOrganizationDomain(applicationName);
56-
57- Q_EMIT applicationNameChanged();
58 }
59

Subscribers

People subscribed via source and target branches