Terminal: Defer shell model init

Speculative fix for sometimes slow load times of the Terminal
plugin on Windows

Task-number: QTCREATORBUG-29840
Change-Id: I6782db075bfaa25fbabe2bac2a8f0f3b4af4f833
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-12-12 08:05:26 +01:00
parent c622601db5
commit 5f3950c620

View File

@@ -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<Internal::ShellModelItem> &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());
});
}