~chris.gagnon/ubuntu-ui-toolkit/fix-bug-1388896

« back to all changes in this revision

Viewing changes to modules/Ubuntu/Components/plugin/statesaverbackend_p.cpp

  • Committer: CI bot
  • Author(s): Zsombor Egri, Michael Sheldon, Zoltán Balogh, Christian Dywan, Tim Peeters
  • Date: 2014-10-07 12:09:27 UTC
  • mfrom: (1000.249.11 landing-0711)
  • Revision ID: ps-jenkins@lists.canonical.com-20141007120927-ucysonqxn60vu8gz
  [ Michael Sheldon ]
  * Removes the keyboard anchor animation as this is now implemented
    in the keyboard.

  [ Tim Peeters ]
  * PageStack push returns the pushed page. Fixes LP: #1361919
  * Add selection mode as a preset to the header configuration.
    Fixes LP: #1370146.

  [ Zsombor Egri ]
  * Fix Dialog foreground sizing. Fixes LP: #1337555, LP: #1337556.
  * Workaround for StateSaver to fall back to use qgetenv() when
    QStandardPaths fails to return XDG_RUNTIME_DIR path.
    Fixes LP: #1363112.

  [ Christian Dywan ]
  * Add unit tests for MathUtils API.
    Fixes LP: #1244685.
  * Text field hint should use the same font as the editor.
    Fixes LP: #1237400.
  * Read-only text fields mustn't have a clear button.
    Fixes LP: #1337257.
  * autopilot package should source-depend on QML plugin.
    Fixes LP: #1236085.
 

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
        delete m_archive.data();
73
73
        m_archive.clear();
74
74
    }
75
 
    QString applicationName(qgetenv("APP_ID"));
 
75
    QString applicationName(UCApplication::instance().applicationName());
76
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
80
    // make sure the path is in sync with https://wiki.ubuntu.com/SecurityTeam/Specifications/ApplicationConfinement
80
81
    // the file must be saved under XDG_RUNTIME_DIR/<APP_PKGNAME> path.
81
 
    m_archive = new QSettings(QString("%1/%2/statesaver.appstate")
82
 
                              .arg(QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation))
83
 
                              .arg(applicationName), QSettings::NativeFormat);
 
82
    // NOTE!!: we cannot use QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation)
 
83
    // as that is going to perform a chmod +w on the path, see bug #1359831. Therefore we must
 
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
97
    m_archive->setFallbacksEnabled(false);
85
98
}
86
99