fix: disconnect portal selection-transfer from parent session

Wrong session logged a glib critical on teardown.
This commit is contained in:
Nick Bolton 2026-07-08 13:06:40 +01:00 committed by Chris Rizzitello
parent f0f3428d50
commit 4cb5c3ec9c
2 changed files with 7 additions and 6 deletions

View file

@ -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;
}

View file

@ -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);
}