diff options
author | Gareth Stockwell <ext-gareth.stockwell@nokia.com> | 2010-05-11 15:50:00 (GMT) |
---|---|---|
committer | Gareth Stockwell <ext-gareth.stockwell@nokia.com> | 2010-06-02 13:40:47 (GMT) |
commit | d7057e7c1f1a4769c6e9b0e1c54446d5104c1484 (patch) | |
tree | 5278dbf2b152a39939d41b628df49e66ae5a8d8b /tests | |
parent | 3a72235d7cf2aa953cb32654545c480fd2d08866 (diff) | |
download | Qt-d7057e7c1f1a4769c6e9b0e1c54446d5104c1484.zip Qt-d7057e7c1f1a4769c6e9b0e1c54446d5104c1484.tar.gz Qt-d7057e7c1f1a4769c6e9b0e1c54446d5104c1484.tar.bz2 |
Added reference counting to QWidgetBackingStore
On Symbian, the top-level widget's backing store must be destroyed when
it is no longer required, in order to conserve memory. The criteria
for destroying the backing store is when neither the TLW nor any of
its native descendents (which share the backing store) are visible.
In order to implement this requirement, a count must be kept of the
number of native widgets which are using the TLW's backing store.
This patch provides the mechanism for maintaining this count, and for
destroying the backing store when the count is decremented to zero.
No calls to either the increment nor decrement functions are made,
however, by this code included in this patch; this code will be added
to only the Symbian backend by a subsequent patch.
Task-number: QTBUG-8697
Reviewed-by: Bjørn Erik Nilsen
Reviewed-by: Jason Barron
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qwidget/tst_qwidget.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index f4add5a..9369f4a 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -9500,9 +9500,7 @@ void tst_QWidget::destroyBackingStore() QTRY_VERIFY(w.numPaintEvents > 0); w.reset(); w.update(); - delete qt_widget_private(&w)->topData()->backingStore; - qt_widget_private(&w)->topData()->backingStore = 0; - qt_widget_private(&w)->topData()->backingStore = new QWidgetBackingStore(&w); + qt_widget_private(&w)->topData()->backingStore.create(&w); w.update(); QApplication::processEvents(); @@ -9524,7 +9522,7 @@ QWidgetBackingStore* backingStore(QWidget &widget) QWidgetBackingStore *backingStore = 0; #ifdef QT_BUILD_INTERNAL if (QTLWExtra *topExtra = qt_widget_private(&widget)->maybeTopData()) - backingStore = topExtra->backingStore; + backingStore = topExtra->backingStore.data(); #endif return backingStore; } @@ -10244,15 +10242,12 @@ class scrollWidgetWBS : public QWidget public: void deleteBackingStore() { - if (static_cast<QWidgetPrivate*>(d_ptr.data())->maybeBackingStore()) { - delete static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore; - static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore = 0; - } + static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore.destroy(); } void enableBackingStore() { if (!static_cast<QWidgetPrivate*>(d_ptr.data())->maybeBackingStore()) { - static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore = new QWidgetBackingStore(this); + static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore.create(this); static_cast<QWidgetPrivate*>(d_ptr.data())->invalidateBuffer(this->rect()); repaint(); } |