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()); }); }