Fix UB in QWidgetItemV2::~QWidgetItemV2

We might get there because 'wid' is already partially deleted (called
from ~QObject). In that case, it is an undefined behavior to call a
QWidget member function on it. Use QObjectPrivate::get instead.

Change-Id: I6da314bf8385684d1332aa031a2d92012941303b
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
bb10
Olivier Goffart 2017-03-02 08:57:48 +01:00 committed by Olivier Goffart (Woboq GmbH)
parent 8387d87bdc
commit 2b13ba0ca0
1 changed files with 1 additions and 1 deletions

View File

@ -767,7 +767,7 @@ QWidgetItemV2::QWidgetItemV2(QWidget *widget)
QWidgetItemV2::~QWidgetItemV2()
{
if (wid) {
QWidgetPrivate *wd = wid->d_func();
auto *wd = static_cast<QWidgetPrivate *>(QObjectPrivate::get(wid));
if (wd->widgetItem == this)
wd->widgetItem = 0;
}