summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qwidget_p.h
diff options
context:
space:
mode:
authorGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-05-11 15:50:00 (GMT)
committerGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-06-02 13:40:47 (GMT)
commitd7057e7c1f1a4769c6e9b0e1c54446d5104c1484 (patch)
tree5278dbf2b152a39939d41b628df49e66ae5a8d8b /src/gui/kernel/qwidget_p.h
parent3a72235d7cf2aa953cb32654545c480fd2d08866 (diff)
downloadQt-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 'src/gui/kernel/qwidget_p.h')
-rw-r--r--src/gui/kernel/qwidget_p.h44
1 files changed, 42 insertions, 2 deletions
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index 555647c..9f7ad95 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -110,13 +110,53 @@ class QWidgetItemV2;
class QStyle;
+class Q_AUTOTEST_EXPORT QRefCountedWidgetBackingStore
+{
+public:
+ QRefCountedWidgetBackingStore();
+ ~QRefCountedWidgetBackingStore();
+
+ void create(QWidget *tlw);
+ void destroy();
+
+ void ref();
+ void deref();
+
+ inline QWidgetBackingStore* data()
+ {
+ return m_ptr;
+ }
+
+ inline QWidgetBackingStore* operator->()
+ {
+ return m_ptr;
+ }
+
+ inline QWidgetBackingStore& operator*()
+ {
+ return *m_ptr;
+ }
+
+ inline operator bool() const
+ {
+ return (0 != m_ptr);
+ }
+
+private:
+ Q_DISABLE_COPY(QRefCountedWidgetBackingStore)
+
+private:
+ QWidgetBackingStore* m_ptr;
+ int m_count;
+};
+
struct QTLWExtra {
// *************************** Cross-platform variables *****************************
// Regular pointers (keep them together to avoid gaps on 64 bits architectures).
QIcon *icon; // widget icon
QPixmap *iconPixmap;
- QWidgetBackingStore *backingStore;
+ QRefCountedWidgetBackingStore backingStore;
QWindowSurface *windowSurface;
QPainter *sharedPainter;
@@ -907,7 +947,7 @@ inline QWidgetBackingStore *QWidgetPrivate::maybeBackingStore() const
{
Q_Q(const QWidget);
QTLWExtra *x = q->window()->d_func()->maybeTopData();
- return x ? x->backingStore : 0;
+ return x ? x->backingStore.data() : 0;
}
QT_END_NAMESPACE