Skip to content

Commit

Permalink
BUG:378313 Fix warnings about qlayout
Browse files Browse the repository at this point in the history
Patch by  Bruno P. Kinoshita, Thanks!
  • Loading branch information
hallarempt committed Mar 31, 2017
1 parent e02948b commit 1d2343c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion plugins/dockers/historydocker/HistoryDock.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ HistoryDock::HistoryDock()
QVBoxLayout *vl = new QVBoxLayout(page); QVBoxLayout *vl = new QVBoxLayout(page);
m_undoView = new KisUndoView(this); m_undoView = new KisUndoView(this);
vl->addWidget(m_undoView); vl->addWidget(m_undoView);
QHBoxLayout *hl = new QHBoxLayout(page); QHBoxLayout *hl = new QHBoxLayout();
hl->addSpacerItem(new QSpacerItem(10, 1, QSizePolicy::Expanding, QSizePolicy::Fixed)); hl->addSpacerItem(new QSpacerItem(10, 1, QSizePolicy::Expanding, QSizePolicy::Fixed));
m_bnConfigure = new QToolButton(page); m_bnConfigure = new QToolButton(page);
m_bnConfigure->setIcon(KisIconUtils::loadIcon("configure")); m_bnConfigure->setIcon(KisIconUtils::loadIcon("configure"));
connect(m_bnConfigure, SIGNAL(clicked(bool)), SLOT(configure())); connect(m_bnConfigure, SIGNAL(clicked(bool)), SLOT(configure()));
hl->addWidget(m_bnConfigure); hl->addWidget(m_bnConfigure);
vl->addItem(hl); vl->addItem(hl);
vl->addLayout(hl);


setWidget(page); setWidget(page);
setWindowTitle(i18n("Undo History")); setWindowTitle(i18n("Undo History"));
Expand Down

3 comments on commit 1d2343c

@MrZaus
Copy link

@MrZaus MrZaus commented on 1d2343c Mar 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@hallarempt
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@MrZaus
Copy link

@MrZaus MrZaus commented on 1d2343c Mar 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.