From d00a9464977f78f869560cadafcab51fe744a75c Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 26 May 2014 11:47:02 +0200 Subject: [PATCH] Set orgname to make inspector settings persistent --- qutebrowser/app.py | 1 + qutebrowser/utils/misc.py | 34 ++++++++++++++++++++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index df98113f0..ae875aaf9 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -236,6 +236,7 @@ class QuteBrowser(QApplication): def _init_misc(self): """Initialize misc things.""" + self.setOrganizationName("qutebrowser") self.setApplicationName("qutebrowser") self.setApplicationVersion(qutebrowser.__version__) self.messagebridge = MessageBridge() diff --git a/qutebrowser/utils/misc.py b/qutebrowser/utils/misc.py index ffec4d422..588f7a652 100644 --- a/qutebrowser/utils/misc.py +++ b/qutebrowser/utils/misc.py @@ -210,18 +210,28 @@ def get_standard_dir(typ): typ: A member of the QStandardPaths::StandardLocation enum, see http://qt-project.org/doc/qt-5/qstandardpaths.html#StandardLocation-enum """ - # FIXME RuntimeLocation "can be empty on some systems", wat. - path = QStandardPaths.writableLocation(typ) - # Qt seems to use '/' as path separator even on Windows... - path = path.replace('/', os.sep) - appname = QCoreApplication.instance().applicationName() - if (typ == QStandardPaths.ConfigLocation and - path.split(os.sep)[-1] != appname): - # Workaround for https://bugreports.qt-project.org/browse/QTBUG-38872 - path = os.path.join(path, appname) - if not os.path.exists(path): - os.makedirs(path) - return path + qapp = QCoreApplication.instance() + orgname = qapp.organizationName() + # We need to temporarely unset the organisationname here since the + # webinspector wants it to be set to store its persistent data correctly, + # but we don't want that to happen. + qapp.setOrganizationName(None) + try: + # FIXME RuntimeLocation "can be empty on some systems", wat. + path = QStandardPaths.writableLocation(typ) + # Qt seems to use '/' as path separator even on Windows... + path = path.replace('/', os.sep) + appname = qapp.applicationName() + if (typ == QStandardPaths.ConfigLocation and + path.split(os.sep)[-1] != appname): + # Workaround for + # https://bugreports.qt-project.org/browse/QTBUG-38872 + path = os.path.join(path, appname) + if not os.path.exists(path): + os.makedirs(path) + return path + finally: + qapp.setOrganizationName(orgname) def actute_warning():