File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ def init(app_name):
6262 interface = "org.freedesktop.Notifications"
6363
6464 mainloop = None
65+ bus = None
6566 try :
6667 if DBusQtMainLoop is not None :
6768 mainloop = DBusQtMainLoop (set_as_default = True )
@@ -76,6 +77,23 @@ def init(app_name):
7677 DBUS_IFACE .connect_to_signal ('NotificationClosed' , _onNotificationClosed )
7778 except Exception as e :
7879 LOG .warning ('Desktop Notify not available:: {}' .format (e ))
80+ # When the SessionBus is constructed with a PyQt5/PyQt6 mainloop
81+ # integration, dbus-python installs a QSocketNotifier on the
82+ # connection fd. If the subsequent get_object/Interface setup
83+ # raises (e.g. ServiceUnknown when no notification daemon owns
84+ # org.freedesktop.Notifications), the Python-side bus reference
85+ # is dropped on exception but the QSocketNotifier keeps the
86+ # underlying C connection alive in a half-initialized state.
87+ # The next QEventLoop tick dispatches a queued message via
88+ # dbus_connection_dispatch() and segfaults inside
89+ # _dbus_list_unlink. Close the bus explicitly so the notifier
90+ # detaches and the connection is fully released.
91+ DBUS_IFACE = None
92+ if bus is not None :
93+ try :
94+ bus .close ()
95+ except Exception :
96+ pass
7997
8098
8199def _onActionInvoked (nid , action ):
You can’t perform that action at this time.
0 commit comments