Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/python/qtvcp/lib/sys_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def init(app_name):
interface = "org.freedesktop.Notifications"

mainloop = None
bus = None
try:
if DBusQtMainLoop is not None:
mainloop = DBusQtMainLoop(set_as_default=True)
Expand All @@ -76,6 +77,23 @@ def init(app_name):
DBUS_IFACE.connect_to_signal('NotificationClosed', _onNotificationClosed)
except Exception as e:
LOG.warning('Desktop Notify not available:: {}'.format(e))
# When the SessionBus is constructed with a PyQt5/PyQt6 mainloop
# integration, dbus-python installs a QSocketNotifier on the
# connection fd. If the subsequent get_object/Interface setup
# raises (e.g. ServiceUnknown when no notification daemon owns
# org.freedesktop.Notifications), the Python-side bus reference
# is dropped on exception but the QSocketNotifier keeps the
# underlying C connection alive in a half-initialized state.
# The next QEventLoop tick dispatches a queued message via
# dbus_connection_dispatch() and segfaults inside
# _dbus_list_unlink. Close the bus explicitly so the notifier
# detaches and the connection is fully released.
DBUS_IFACE = None
if bus is not None:
try:
bus.close()
except Exception:
pass


def _onActionInvoked(nid, action):
Expand Down
Loading