summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcus Tillmanns <marcus.tillmanns@qt.io>2023-03-28 10:48:59 +0200
committerMarcus Tillmanns <marcus.tillmanns@qt.io>2023-04-03 07:53:23 +0000
commit94c4800ad8b6e591c2167c787efdff59be750f1b (patch)
tree93ecb996313b80dcbd4aad49fb3efe33ad1ce12e /src
parent0015c666d2a6646cb58b9b73e839a9b52c64d71e (diff)
downloadqt-creator-94c4800ad8b6e591c2167c787efdff59be750f1b.tar.gz
Terminal: Fix crash when reusing TerminalWidget
Change-Id: I9d30df1abbecabd3909078e0a609fe5ba96769ae Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/terminal/terminalwidget.cpp6
-rw-r--r--src/plugins/terminal/terminalwidget.h3
2 files changed, 6 insertions, 3 deletions
diff --git a/src/plugins/terminal/terminalwidget.cpp b/src/plugins/terminal/terminalwidget.cpp
index a7b3590a59..65c19576cf 100644
--- a/src/plugins/terminal/terminalwidget.cpp
+++ b/src/plugins/terminal/terminalwidget.cpp
@@ -131,7 +131,6 @@ TerminalWidget::~TerminalWidget()
// The Aggregate stuff tries to do clever deletion of the children, but we
// we don't want that.
m_aggregate->remove(this);
- m_aggregate->remove(m_search.get());
}
void TerminalWidget::setupPty()
@@ -279,7 +278,10 @@ void TerminalWidget::setupSurface()
{
m_shellIntegration.reset(new ShellIntegration());
m_surface = std::make_unique<Internal::TerminalSurface>(QSize{80, 60}, m_shellIntegration.get());
- m_search = std::make_unique<TerminalSearch>(m_surface.get());
+ m_search = TerminalSearchPtr(new TerminalSearch(m_surface.get()), [this](TerminalSearch *p) {
+ m_aggregate->remove(p);
+ delete p;
+ });
connect(m_search.get(), &TerminalSearch::hitsChanged, this, &TerminalWidget::updateViewport);
connect(m_search.get(), &TerminalSearch::currentHitChanged, this, [this] {
diff --git a/src/plugins/terminal/terminalwidget.h b/src/plugins/terminal/terminalwidget.h
index 215d8c6d58..8498f35f83 100644
--- a/src/plugins/terminal/terminalwidget.h
+++ b/src/plugins/terminal/terminalwidget.h
@@ -217,7 +217,8 @@ private:
Utils::FilePath m_cwd;
Utils::CommandLine m_currentCommand;
- std::unique_ptr<TerminalSearch> m_search;
+ using TerminalSearchPtr = std::unique_ptr<TerminalSearch, std::function<void(TerminalSearch *)>>;
+ TerminalSearchPtr m_search;
Aggregation::Aggregate *m_aggregate{nullptr};
SearchHit m_lastSelectedHit{};