QWidget: replace manual memory management with unique_ptr [5/N]: extra->topextra
It is a bit frustrating that all the initialization and cleanup code are not in the QTLWExtra ctor and dtor. But that is for another patch. Change-Id: I0e45f89c1a53eb2f9a5699d3fbbef1a628b55432 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>bb10
parent
45c5cc6199
commit
70c624d93e
|
|
@ -1785,7 +1785,8 @@ void QWidgetPrivate::createTLExtra()
|
|||
if (!extra)
|
||||
createExtra();
|
||||
if (!extra->topextra) {
|
||||
QTLWExtra* x = extra->topextra = new QTLWExtra;
|
||||
extra->topextra = qt_make_unique<QTLWExtra>();
|
||||
QTLWExtra* x = extra->topextra.get();
|
||||
x->backingStore = 0;
|
||||
x->sharedPainter = 0;
|
||||
x->incw = x->inch = 0;
|
||||
|
|
@ -1820,7 +1821,6 @@ void QWidgetPrivate::createExtra()
|
|||
if (!extra) { // if not exists
|
||||
extra = new QWExtra;
|
||||
extra->glContext = 0;
|
||||
extra->topextra = 0;
|
||||
#if QT_CONFIG(graphicsview)
|
||||
extra->proxyWidget = 0;
|
||||
#endif
|
||||
|
|
@ -1866,7 +1866,6 @@ void QWidgetPrivate::deleteExtra()
|
|||
if (extra->topextra) {
|
||||
deleteTLSysExtra();
|
||||
// extra->topextra->backingStore destroyed in QWidgetPrivate::deleteTLSysExtra()
|
||||
delete extra->topextra;
|
||||
}
|
||||
delete extra;
|
||||
// extra->xic destroyed in QWidget::destroy()
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ struct QWExtra {
|
|||
|
||||
// Regular pointers (keep them together to avoid gaps on 64 bits architectures).
|
||||
void *glContext; // if the widget is hijacked by QGLWindowSurface
|
||||
QTLWExtra *topextra; // only useful for TLWs
|
||||
std::unique_ptr<QTLWExtra> topextra; // only useful for TLWs
|
||||
#if QT_CONFIG(graphicsview)
|
||||
QGraphicsProxyWidget *proxyWidget; // if the widget is embedded
|
||||
#endif
|
||||
|
|
@ -993,12 +993,12 @@ inline QWExtra *QWidgetPrivate::extraData() const
|
|||
inline QTLWExtra *QWidgetPrivate::topData() const
|
||||
{
|
||||
const_cast<QWidgetPrivate *>(this)->createTLExtra();
|
||||
return extra->topextra;
|
||||
return extra->topextra.get();
|
||||
}
|
||||
|
||||
inline QTLWExtra *QWidgetPrivate::maybeTopData() const
|
||||
{
|
||||
return extra ? extra->topextra : nullptr;
|
||||
return extra ? extra->topextra.get() : nullptr;
|
||||
}
|
||||
|
||||
inline QPainter *QWidgetPrivate::sharedPainter() const
|
||||
|
|
|
|||
Loading…
Reference in New Issue