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
=== modified file 'modules/Ubuntu/Components/plugin/statesaverbackend_p.cpp'
--- modules/Ubuntu/Components/plugin/statesaverbackend_p.cpp 2014-09-04 16:24:57 +0000
+++ modules/Ubuntu/Components/plugin/statesaverbackend_p.cpp 2014-10-02 15:21:30 +0000
@@ -72,15 +72,28 @@
72 delete m_archive.data();72 delete m_archive.data();
73 m_archive.clear();73 m_archive.clear();
74 }74 }
75 QString applicationName(qgetenv("APP_ID"));75 QString applicationName(UCApplication::instance().applicationName());
76 if (applicationName.isEmpty()) {76 if (applicationName.isEmpty()) {
77 applicationName = UCApplication::instance().applicationName();77 qCritical() << "[StateSaver] Cannot create appstate file, application name not defined.";
78 return;
78 }79 }
79 // make sure the path is in sync with https://wiki.ubuntu.com/SecurityTeam/Specifications/ApplicationConfinement80 // make sure the path is in sync with https://wiki.ubuntu.com/SecurityTeam/Specifications/ApplicationConfinement
80 // the file must be saved under XDG_RUNTIME_DIR/<APP_PKGNAME> path.81 // the file must be saved under XDG_RUNTIME_DIR/<APP_PKGNAME> path.
81 m_archive = new QSettings(QString("%1/%2/statesaver.appstate")82 // NOTE!!: we cannot use QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation)
82 .arg(QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation))83 // as that is going to perform a chmod +w on the path, see bug #1359831. Therefore we must
83 .arg(applicationName), QSettings::NativeFormat);84 // fetch the XDG_RUNTIME_DIR either from QStandardPaths::standardLocations() or from env var
85 // see bug https://bugreports.qt-project.org/browse/QTBUG-41735
86 QString runtimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
87 if (runtimeDir.isEmpty()) {
88 runtimeDir = qgetenv("XDG_RUNTIME_DIR");
89 }
90 if (runtimeDir.isEmpty()) {
91 qCritical() << "[StateSaver] No XDG_RUNTIME_DIR path set, cannot create appstate file.";
92 return;
93 }
94 m_archive = new QSettings(QString("%1/%2/statesaver.appstate").
95 arg(runtimeDir).
96 arg(applicationName), QSettings::NativeFormat);
84 m_archive->setFallbacksEnabled(false);97 m_archive->setFallbacksEnabled(false);
85}98}
8699
87100
=== modified file 'modules/Ubuntu/Components/plugin/ucapplication.cpp'
--- modules/Ubuntu/Components/plugin/ucapplication.cpp 2014-08-08 10:43:55 +0000
+++ modules/Ubuntu/Components/plugin/ucapplication.cpp 2014-10-02 15:21:30 +0000
@@ -35,6 +35,9 @@
35 */35 */
36UCApplication::UCApplication(QObject* parent) : QObject(parent), m_context(0)36UCApplication::UCApplication(QObject* parent) : QObject(parent), m_context(0)
37{37{
38 // Make sure we receive application name changes from C++ modules
39 connect(QCoreApplication::instance(), &QCoreApplication::applicationNameChanged,
40 this, &UCApplication::applicationNameChanged);
38}41}
3942
40void UCApplication::setContext(QQmlContext* context) {43void UCApplication::setContext(QQmlContext* context) {
@@ -68,7 +71,5 @@
68 engine->setOfflineStoragePath(dataFolder);71 engine->setOfflineStoragePath(dataFolder);
69 // Get Qtlabs.settings to use a sane path72 // Get Qtlabs.settings to use a sane path
70 QCoreApplication::setOrganizationDomain(applicationName);73 QCoreApplication::setOrganizationDomain(applicationName);
71
72 Q_EMIT applicationNameChanged();
73}74}
7475

Subscribers

People subscribed via source and target branches