QToolButton: fix read of uninitialized variable

Calling style() can trigger a call into user code which can read
the tool button's members before they are initialized

==3566== Conditional jump or move depends on uninitialised value(s)
==3566==    at 0x421C39: MyProxyStyle::pixelMetric(QStyle::PixelMetric, QStyleOption const*, QWidget const*) const (MyProxyStyle.cpp:635)
==3566==    by 0x504B8B1: QRenderRule::QRenderRule(QVector<QCss::Declaration> const&, QObject const*) (qstylesheetstyle.cpp:1004)
==3566==    by 0x504D084: QStyleSheetStyle::renderRule(QObject const*, int, unsigned long long) const (qstylesheetstyle.cpp:1747)
==3566==    by 0x504D4A5: QStyleSheetStyle::renderRule(QObject const*, QStyleOption const*, int) const (qstylesheetstyle.cpp:2023)
==3566==    by 0x504FF02: QStyleSheetStyle::styleHint(QStyle::StyleHint, QStyleOption const*, QWidget const*, QStyleHintReturn*) const (qstylesheetstyle.cpp:5146)
==3566==    by 0x517B2D0: QToolButtonPrivate::init() (qtoolbutton.cpp:193)

Change-Id: I56bca15d3ec7cd7b255a83dca786532a2f9b9b48
Reviewed-by: David Faure <david.faure@kdab.com>
bb10
Sérgio Martins 2016-08-23 20:42:42 +01:00
parent a0d3455ee3
commit bd9f3c50df
1 changed files with 1 additions and 2 deletions

View File

@ -190,7 +190,6 @@ QToolButton::QToolButton(QWidget * parent)
void QToolButtonPrivate::init()
{
Q_Q(QToolButton);
delay = q->style()->styleHint(QStyle::SH_ToolButton_PopupDelay, 0, q);
defaultAction = 0;
#ifndef QT_NO_TOOLBAR
if (qobject_cast<QToolBar*>(parent))
@ -216,7 +215,7 @@ void QToolButtonPrivate::init()
#endif
setLayoutItemMargins(QStyle::SE_ToolButtonLayoutItem);
delay = q->style()->styleHint(QStyle::SH_ToolButton_PopupDelay, 0, q);
}
/*!