diff --git a/src/sshview.cpp b/src/sshview.cpp index ca89730..e643f11 100644 --- a/src/sshview.cpp +++ b/src/sshview.cpp @@ -151,13 +151,8 @@ bool SshView::startConnection() return false; } - // Connect to the terminal's finished signal to detect disconnection - connect(m_terminalPart, &KParts::ReadOnlyPart::destroyed, this, [this]() { - if (!m_quitting) { - setStatus(Disconnected); - Q_EMIT disconnected(); - } - }); + // KonsolePart emits terminalExited() when the process (ssh) exits. + connect(m_terminalPart, SIGNAL(terminalExited()), this, SLOT(handleTerminalExited())); // Start SSH directly via startProgram for clean process lifecycle. terminalInterface->startProgram(sshPath, sshCommand); @@ -170,6 +165,14 @@ bool SshView::startConnection() return true; } +void SshView::handleTerminalExited() +{ + if (!m_quitting) { + setStatus(Disconnected); + Q_EMIT disconnected(); + } +} + void SshView::startQuittingConnection() { m_quitting = true; diff --git a/src/sshview.h b/src/sshview.h index 4ff960d..0eeaa06 100644 --- a/src/sshview.h +++ b/src/sshview.h @@ -55,6 +55,9 @@ protected: void handleMouseEvent(QMouseEvent *event) override; void handleLocalClipboardChanged(const QMimeData *data) override; +private Q_SLOTS: + void handleTerminalExited(); + private: bool loadKonsolePart(); QStringList buildSshCommand() const;