From 75a05074505d757da082a1efed7262e992ade56e Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Wed, 17 Jul 2013 23:58:21 -0700 Subject: [PATCH 3/5] D-Bus server: LocaledListener must not fail without session bus The listening functionality is meant to be optional, which includes running inside an environment which doesn't even have a system D-Bus, like the nightly testing. --- src/dbus/server/localed-listener.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/dbus/server/localed-listener.cpp b/src/dbus/server/localed-listener.cpp index 730489b..bc24aa3 100644 --- a/src/dbus/server/localed-listener.cpp +++ b/src/dbus/server/localed-listener.cpp @@ -74,7 +74,11 @@ LocaledListener::LocaledListener(): m_propertiesChanged(*this, PROPERTIES_CHANGED_SIGNAL), m_propertiesGet(*this, PROPERTIES_GET) { - m_propertiesChanged.activate(boost::bind(&LocaledListener::onPropertiesChange, this, _1, _2, _3)); + if (getConnection()) { + m_propertiesChanged.activate(boost::bind(&LocaledListener::onPropertiesChange, this, _1, _2, _3)); + } else { + SE_LOG_DEBUG(NULL, "localed: not activating, no connection"); + } }; @@ -157,10 +161,14 @@ void LocaledListener::emitLocaleEnv(const LocaleEnv &env) void LocaledListener::check(const boost::function &result) { - SE_LOG_DEBUG(NULL, "localed: get current Locale property"); - m_propertiesGet.start(std::string(LOCALED_INTERFACE), - std::string(LOCALED_LOCALE_PROPERTY), - boost::bind(&LocaledListener::processLocaleProperty, m_self, _1, _2, true, result)); + if (getConnection()) { + SE_LOG_DEBUG(NULL, "localed: get current Locale property"); + m_propertiesGet.start(std::string(LOCALED_INTERFACE), + std::string(LOCALED_LOCALE_PROPERTY), + boost::bind(&LocaledListener::processLocaleProperty, m_self, _1, _2, true, result)); + } else { + processLocaleProperty(LocaleVariant(), "no D-Bus connection", true, result); + } } void LocaledListener::setLocale(const LocaleEnv &locale) -- 1.7.10.4