aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel
diff options
context:
space:
mode:
authorAntti Kaijanmäki <antti.kaijanmaki@canonical.com>2014-04-02 09:28:57 +0300
committerAntti Kaijanmäki <antti.kaijanmaki@canonical.com>2014-04-02 09:28:57 +0300
commit5809d6f617aafd138de41ef4f7af57cc6d6703e5 (patch)
tree43c334bc22d9f5b7328300a1028ce4dbfe7938dc /libqmenumodel
parent94aac0751db1c9d07d40d8c9303a0a287d69cd79 (diff)
downloadqmenumodel-5809d6f617aafd138de41ef4f7af57cc6d6703e5.tar.gz
qmenumodel-5809d6f617aafd138de41ef4f7af57cc6d6703e5.tar.bz2
qmenumodel-5809d6f617aafd138de41ef4f7af57cc6d6703e5.zip
UnityMenuModel::setName: handle empty strings properly.
Diffstat (limited to 'libqmenumodel')
-rw-r--r--libqmenumodel/src/unitymenumodel.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp
index a2aae31..6b57493 100644
--- a/libqmenumodel/src/unitymenumodel.cpp
+++ b/libqmenumodel/src/unitymenumodel.cpp
@@ -294,13 +294,23 @@ void UnityMenuModel::setBusName(const QByteArray &name)
{
priv->clearName();
- if (priv->nameWatchId)
+ if (priv->nameWatchId) {
g_bus_unwatch_name (priv->nameWatchId);
+ priv->nameWatchId = 0;
+ }
+ priv->busName = name;
+ if (name.isEmpty())
+ return;
+
+ /* We could do a g_dbus_is_name() check here if we want to
+ * validate the name before passing it to g_bus_watch_name().
+ * Currently if an invalid name is passed nameWatchId becomes 0
+ * and g_bus_watch_name() prints out a nasty GCritical.
+ */
priv->nameWatchId = g_bus_watch_name (G_BUS_TYPE_SESSION, name.constData(), G_BUS_NAME_WATCHER_FLAGS_AUTO_START,
UnityMenuModelPrivate::nameAppeared, UnityMenuModelPrivate::nameVanished,
priv, NULL);
- priv->busName = name;
}
QVariantMap UnityMenuModel::actions() const