From 5f3950c620d8faf2afeb6209c5bfe04093fd2270 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Tue, 12 Dec 2023 08:05:26 +0100 Subject: [PATCH] Terminal: Defer shell model init MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Speculative fix for sometimes slow load times of the Terminal plugin on Windows Task-number: QTCREATORBUG-29840 Change-Id: I6782db075bfaa25fbabe2bac2a8f0f3b4af4f833 Reviewed-by: André Hartmann Reviewed-by: David Schulz --- src/plugins/terminal/terminalpane.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/plugins/terminal/terminalpane.cpp b/src/plugins/terminal/terminalpane.cpp index e6a9af415fb..3e4ce3e8b79 100644 --- a/src/plugins/terminal/terminalpane.cpp +++ b/src/plugins/terminal/terminalpane.cpp @@ -273,11 +273,15 @@ void TerminalPane::initActions() cmd->setAttribute(Command::CA_UpdateIcon); } +static Internal::ShellModel *shellModel() +{ + static Internal::ShellModel model; + return &model; +} + void TerminalPane::createShellMenu() { - const Internal::ShellModel *shellModel = new Internal::ShellModel(&m_shellMenu); - - connect(&m_shellMenu, &QMenu::aboutToShow, &m_shellMenu, [shellModel, this] { + connect(&m_shellMenu, &QMenu::aboutToShow, &m_shellMenu, [this] { m_shellMenu.clear(); const auto addItems = [this](const QList &items) { @@ -292,9 +296,9 @@ void TerminalPane::createShellMenu() } }; - addItems(shellModel->local()); + addItems(shellModel()->local()); m_shellMenu.addSection(Tr::tr("Devices")); - addItems(shellModel->remote()); + addItems(shellModel()->remote()); }); }