Skip to content

Commit

Permalink
Do not notify service owner change if initial query fails.
Browse files Browse the repository at this point in the history
When using valgrind, it's very likely the GetNameOwner will fail with
timeout, which does not mean anything. Only org.freedesktop.DBus.Error.NameHasNoOwner
is meaningful to us.
  • Loading branch information
wengxt committed Apr 22, 2024
1 parent 26e833e commit 4312998
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/lib/fcitx-utils/dbus/servicewatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class ServiceWatcherPrivate : public TrackableObject<ServiceWatcherPrivate> {
std::string newName;
if (msg.type() != dbus::MessageType::Error) {
msg >> newName;
} else {
if (msg.errorName() != "org.freedesktop.DBus.Error.NameHasNoOwner") {
return false;
}
}
for (auto &entry : watcherMap_.view(pivotKey)) {
entry(pivotKey, "", newName);
Expand Down
8 changes: 5 additions & 3 deletions src/modules/dbus/dbusmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,9 +784,11 @@ DBusModule::DBusModule(Instance *instance)
});

selfWatcher_ = serviceWatcher_->watchService(
FCITX_DBUS_SERVICE,
[uniqueName, instance](const std::string &, const std::string &,
const std::string &newName) {
FCITX_DBUS_SERVICE, [uniqueName, instance](const std::string &service,
const std::string &oldName,
const std::string &newName) {
FCITX_INFO() << "Service name change: " << service << " " << oldName
<< " " << newName;
if (newName != uniqueName) {
instance->exit();
}
Expand Down

0 comments on commit 4312998

Please sign in to comment.