summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorKatarina Behrens <Katarina.Behrens@cib.de>2019-04-16 09:47:31 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-04-17 17:37:52 +0200
commit5a64bc2b1214e6ad8424f57576aa5752a09815d4 (patch)
treefa5665e3574829a59bdcb1d31f91218628ca829f /shell
parent2d85b75b1220484aebd6e583d6d7aee71280e38e (diff)
Stop qt event loop after KDE settings have been read
Two use-cases here in kde5backend 1) kde or qt vclplug has already started qt event loop => just use this loop to read KDE settings 2) no qt event loop runs (we're most likely in gtk3_kde5 vclplug) => start a new event loop, read the settings and stop it In case 2) letting qt event loop run means subsequently all UI ops need to happen in main thread. This is problematic to enforce in non-qt-based vclplugs In both cases, cache those settings for future use - the assumption is, most of them are static during a session anyway. Change-Id: Ifa203f4cdb9a753db808f945762fb131ee83393c Reviewed-on: https://gerrit.libreoffice.org/70808 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'shell')
-rw-r--r--shell/source/backends/kde5be/kde5backend.cxx56
1 files changed, 42 insertions, 14 deletions
diff --git a/shell/source/backends/kde5be/kde5backend.cxx b/shell/source/backends/kde5be/kde5backend.cxx
index e2f6e25c0764..101a21387a4c 100644
--- a/shell/source/backends/kde5be/kde5backend.cxx
+++ b/shell/source/backends/kde5be/kde5backend.cxx
@@ -120,7 +120,7 @@ private:
{
}
- bool enabled_;
+ std::map<OUString, css::beans::Optional<css::uno::Any>> m_KDESettings;
};
OString getDisplayArg()
@@ -148,10 +148,28 @@ OString getExecutable()
return OUStringToOString(aBin, osl_getThreadTextEncoding());
}
+void readKDESettings(std::map<OUString, css::beans::Optional<css::uno::Any>>& rSettings)
+{
+ const std::vector<OUString> aKeys
+ = { "EnableATToolSupport", "ExternalMailer", "SourceViewFontHeight",
+ "SourceViewFontName", "WorkPathVariable", "ooInetFTPProxyName",
+ "ooInetFTPProxyPort", "ooInetHTTPProxyName", "ooInetHTTPProxyPort",
+ "ooInetHTTPSProxyName", "ooInetHTTPSProxyPort", "ooInetNoProxy",
+ "ooInetProxyType" };
+
+ for (const OUString& aKey : aKeys)
+ {
+ css::beans::Optional<css::uno::Any> aValue = kde5access::getValue(aKey);
+ std::pair<OUString, css::beans::Optional<css::uno::Any>> elem
+ = std::make_pair(aKey, aValue);
+ rSettings.insert(elem);
+ }
+}
+
// init the QApplication when we load the kde5backend into a non-Qt vclplug (e.g. Gtk3KDE5)
// TODO: use a helper process to read these values without linking to Qt directly?
// TODO: share this code somehow with Qt5Instance.cxx?
-void initQApp()
+void initQApp(std::map<OUString, css::beans::Optional<css::uno::Any>>& rSettings)
{
const auto aDisplay = getDisplayArg();
int nFakeArgc = aDisplay.isEmpty() ? 2 : 3;
@@ -169,36 +187,42 @@ void initQApp()
unsetenv("SESSION_MANAGER");
}
- auto app = new QApplication(nFakeArgc, pFakeArgv);
- QObject::connect(app, &QObject::destroyed, app, [nFakeArgc, pFakeArgv]() {
+ std::unique_ptr<QApplication> app(new QApplication(nFakeArgc, pFakeArgv));
+ QObject::connect(app.get(), &QObject::destroyed, app.get(), [nFakeArgc, pFakeArgv]() {
for (int i = 0; i < nFakeArgc; ++i)
delete pFakeArgv[i];
delete[] pFakeArgv;
});
+ readKDESettings(rSettings);
+
if (session_manager != nullptr)
{
// coverity[tainted_string] - trusted source for setenv
setenv("SESSION_MANAGER", session_manager, 1);
free(session_manager);
}
-
- QApplication::setQuitOnLastWindowClosed(false);
}
Service::Service()
- : enabled_(false)
{
css::uno::Reference<css::uno::XCurrentContext> context(css::uno::getCurrentContext());
if (context.is())
{
- if (!qApp)
- {
- initQApp();
- }
OUString desktop;
context->getValueByName("system.desktop-environment") >>= desktop;
- enabled_ = desktop == "KDE5" && qApp != nullptr;
+
+ if (desktop == "KDE5")
+ {
+ if (!qApp) // no qt event loop yet
+ {
+ // so we start one and read KDE settings
+ initQApp(m_KDESettings);
+ }
+ else // someone else (most likely kde/qt vclplug) has started qt event loop
+ // all that is left to do is to read KDE settings
+ readKDESettings(m_KDESettings);
+ }
}
}
@@ -218,8 +242,12 @@ css::uno::Any Service::getPropertyValue(OUString const& PropertyName)
|| PropertyName == "ooInetHTTPSProxyPort" || PropertyName == "ooInetNoProxy"
|| PropertyName == "ooInetProxyType")
{
- return css::uno::makeAny(enabled_ ? kde5access::getValue(PropertyName)
- : css::beans::Optional<css::uno::Any>());
+ std::map<OUString, css::beans::Optional<css::uno::Any>>::iterator it
+ = m_KDESettings.find(PropertyName);
+ if (it != m_KDESettings.end())
+ return css::uno::makeAny(it->second);
+ else
+ return css::uno::makeAny(css::beans::Optional<css::uno::Any>());
}
else if (PropertyName == "givenname" || PropertyName == "sn"
|| PropertyName == "TemplatePathVariable")