Use QScopedPointer to manage memory

Although the QBackingStore constructor takes a QWindow* as a parameter,
it does not inherit QObject and doesn't become a QObject child of the
QWindow. Use QScopedPointer to avoid memory leaks.

Pick-to: 6.2
Change-Id: Ib065163a9149d002f8220a0257bd78549062c595
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
This commit is contained in:
Tang Haixiang 2021-10-21 16:32:59 +08:00 committed by Volker Hilsheimer
parent f5fbad669d
commit c4856a9075

View File

@ -53,6 +53,7 @@
//! [1]
#include <QtGui>
#include <QScopedPointer>
class RasterWindow : public QWindow
{
@ -73,7 +74,7 @@ protected:
void exposeEvent(QExposeEvent *event) override;
private:
QBackingStore *m_backingStore;
QScopedPointer<QBackingStore> m_backingStore;
};
//! [1]
#endif // RASTERWINDOW_H