diff --git a/src/lib/deskflow/ServerApp.cpp b/src/lib/deskflow/ServerApp.cpp index 993c85230..5c89b1c48 100644 --- a/src/lib/deskflow/ServerApp.cpp +++ b/src/lib/deskflow/ServerApp.cpp @@ -519,10 +519,8 @@ int ServerApp::mainLoop() try { appUtil().startNode(); } catch (...) { - // a fatal startup failure (e.g. the listen address is already in use) - // exits by throwing, which unwinds past the cleanup at the end of this - // function. tear the server down here so the screen and its worker - // threads don't outlive the app and call into freed globals on exit. + // a fatal startup failure exits by throwing, skipping the cleanup below; + // tear down here so the screen's worker threads don't outlive the app. cleanupServer(); throw; } diff --git a/src/lib/platform/PortalInputCapture.cpp b/src/lib/platform/PortalInputCapture.cpp index c5e3f54de..957ebc757 100644 --- a/src/lib/platform/PortalInputCapture.cpp +++ b/src/lib/platform/PortalInputCapture.cpp @@ -205,12 +205,15 @@ PortalInputCapture::~PortalInputCapture() if (m_session) { using enum Signal; XdpSession *parentSession = xdp_input_capture_session_get_session(m_session); - g_signal_handler_disconnect(G_OBJECT(parentSession), m_signals.at(SessionClosed)); + if (m_signals.at(SessionClosed) != 0) + g_signal_handler_disconnect(parentSession, m_signals.at(SessionClosed)); g_signal_handler_disconnect(m_session, m_signals.at(Disabled)); g_signal_handler_disconnect(m_session, m_signals.at(Activated)); g_signal_handler_disconnect(m_session, m_signals.at(Deactivated)); g_signal_handler_disconnect(m_session, m_signals.at(ZonesChanged)); - g_signal_handler_disconnect(m_session, m_signals.at(SelectionTransfer)); +#ifdef HAVE_LIBPORTAL_CLIPBOARD + g_signal_handler_disconnect(parentSession, m_signals.at(SelectionTransfer)); +#endif g_object_unref(m_session); }