Commit 5ad01800 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

Core: Fix memory leak

Detected by valgrind

Change-Id: Iae3845edfcf1933c90b6b20b6af3909324ceb6fe
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 92fbbaea
......@@ -158,14 +158,14 @@ void WindowList::addWindow(QWidget *window)
m_windowActionIds.append(id);
auto action = new QAction(window->windowTitle(), 0);
m_windowActions.append(action);
connect(action, &QAction::triggered, [action]() { WindowList::activateWindow(action); });
QObject::connect(action, &QAction::triggered, [action]() { WindowList::activateWindow(action); });
action->setCheckable(true);
action->setChecked(false);
Command *cmd = ActionManager::registerAction(action, id,
Context(Constants::C_GLOBAL));
cmd->setAttribute(Command::CA_UpdateText);
ActionManager::actionContainer(Constants::M_WINDOW)->addAction(cmd, Constants::G_WINDOW_LIST);
connect(window, &QWidget::windowTitleChanged, [window]() { WindowList::updateTitle(window); });
QObject::connect(window, &QWidget::windowTitleChanged, [window]() { WindowList::updateTitle(window); });
if (m_dockMenu)
m_dockMenu->addAction(action);
if (window->isActiveWindow())
......@@ -200,7 +200,7 @@ void WindowList::removeWindow(QWidget *window)
QTC_ASSERT(index >= 0, return);
ActionManager::unregisterAction(m_windowActions.last(), m_windowActionIds.last());
m_windowActions.removeLast();
delete m_windowActions.takeLast();
m_windowActionIds.removeLast();
m_windows.removeOne(window);
......
......@@ -44,9 +44,8 @@ QT_END_NAMESPACE
namespace Core {
namespace Internal {
class WindowList : public QObject
class WindowList
{
Q_OBJECT
public:
static void addWindow(QWidget *window);
static void removeWindow(QWidget *window);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment