diff options
| author | Sebastian Englbrecht <[email protected]> | 2026-05-23 15:31:27 +0200 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2026-05-28 08:59:00 +0000 |
| commit | 0d6302ef9be3387d3a62093ae18c92ec84e5a2e1 (patch) | |
| tree | da9746a74e90cb04b022770a92aee6617f9f1d52 /src/panels/terminal | |
| parent | 3efeaaffd4cb13168e9327ec146f0a40ff9d75af (diff) | |
terminalpanel: delete konsolePart in destructor, use unique_ptr for KXMLGUIBuilder
Deleting konsolePart before QObject child cleanup ensures
m_konsolePartClientBuilder is still alive when the lambda connected
to m_terminalWidget::destroyed fires and calls factory->removeClient().
Diffstat (limited to 'src/panels/terminal')
| -rw-r--r-- | src/panels/terminal/terminalpanel.cpp | 8 | ||||
| -rw-r--r-- | src/panels/terminal/terminalpanel.h | 4 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/panels/terminal/terminalpanel.cpp b/src/panels/terminal/terminalpanel.cpp index 2ed6cd33e..55773345c 100644 --- a/src/panels/terminal/terminalpanel.cpp +++ b/src/panels/terminal/terminalpanel.cpp @@ -50,9 +50,10 @@ TerminalPanel::TerminalPanel(QWidget *parent) TerminalPanel::~TerminalPanel() { if (m_konsolePart) { - // Avoid when QObject cleanup, which comes after our destructor, deletes the konsolePart - // and subsequently calls back into our slot when the destructor has already run. disconnect(m_konsolePart, &KParts::ReadOnlyPart::destroyed, this, &TerminalPanel::terminalExited); + // Delete before QObject child cleanup, while m_konsolePartClientBuilder is still alive. + delete m_konsolePart; + m_konsolePart = nullptr; } } @@ -179,7 +180,8 @@ void TerminalPanel::showEvent(QShowEvent *event) // namely the one of the single inner terminal and not the outer KonsolePart if (!m_konsolePart->factory() && m_terminalWidget) { if (!m_konsolePart->clientBuilder()) { - m_konsolePart->setClientBuilder(new KXMLGUIBuilder(m_terminalWidget)); + m_konsolePartClientBuilder = std::make_unique<KXMLGUIBuilder>(m_terminalWidget); + m_konsolePart->setClientBuilder(m_konsolePartClientBuilder.get()); } auto factory = new KXMLGUIFactory(m_konsolePart->clientBuilder(), this); diff --git a/src/panels/terminal/terminalpanel.h b/src/panels/terminal/terminalpanel.h index 7f4e9e36c..d6ed4b981 100644 --- a/src/panels/terminal/terminalpanel.h +++ b/src/panels/terminal/terminalpanel.h @@ -12,6 +12,9 @@ #include <QQueue> +#include <memory> + +class KXMLGUIBuilder; class TerminalInterface; class KActionCollection; class KMessageWidget; @@ -94,6 +97,7 @@ private: QWidget *m_terminalWidget; KMessageWidget *m_konsolePartMissingMessage; KParts::ReadOnlyPart *m_konsolePart; + std::unique_ptr<KXMLGUIBuilder> m_konsolePartClientBuilder; QString m_konsolePartCurrentDirectory; QQueue<QString> m_sendCdToTerminalHistory; org::kde::KIOFuse::VFS m_kiofuseInterface; |
