Permalink
Browse files

BUG:378313 Fix warnings about qlayout

Patch by  Bruno P. Kinoshita, Thanks!
  • Loading branch information...
boudewijnrempt committed Mar 31, 2017
1 parent e02948b commit 1d2343c0cacfb0b105fbe86c2bcef975a09b1041
Showing with 2 additions and 1 deletion.
  1. +2 −1 plugins/dockers/historydocker/HistoryDock.cpp
@@ -38,13 +38,14 @@ HistoryDock::HistoryDock()
QVBoxLayout *vl = new QVBoxLayout(page);
m_undoView = new KisUndoView(this);
vl->addWidget(m_undoView);
- QHBoxLayout *hl = new QHBoxLayout(page);
+ QHBoxLayout *hl = new QHBoxLayout();
hl->addSpacerItem(new QSpacerItem(10, 1, QSizePolicy::Expanding, QSizePolicy::Fixed));
m_bnConfigure = new QToolButton(page);
m_bnConfigure->setIcon(KisIconUtils::loadIcon("configure"));
connect(m_bnConfigure, SIGNAL(clicked(bool)), SLOT(configure()));
hl->addWidget(m_bnConfigure);
vl->addItem(hl);
+ vl->addLayout(hl);
setWidget(page);
setWindowTitle(i18n("Undo History"));

3 comments on commit 1d2343c

@MrZaus

This comment has been minimized.

Show comment
Hide comment
@MrZaus

MrZaus Mar 24, 2018

After your fix there is the allocation of memory and the assignment to the bare pointer. If something happens at that moment there might be memory leak. Preventing it is a very good reason for setting a parent in a constructor.

After your fix there is the allocation of memory and the assignment to the bare pointer. If something happens at that moment there might be memory leak. Preventing it is a very good reason for setting a parent in a constructor.

@boudewijnrempt

This comment has been minimized.

Show comment
Hide comment
@boudewijnrempt

boudewijnrempt Mar 26, 2018

Contributor

The addLayout method sets a parent object on hl, so there is no memory leak.

Contributor

boudewijnrempt replied Mar 26, 2018

The addLayout method sets a parent object on hl, so there is no memory leak.

@MrZaus

This comment has been minimized.

Show comment
Hide comment
@MrZaus

MrZaus Mar 28, 2018

The addLayout sets a parent object, however there is plenty of code before it is called. It is possible to have an exception somewhere in the middle.

The addLayout sets a parent object, however there is plenty of code before it is called. It is possible to have an exception somewhere in the middle.

Please sign in to comment.