diff options
author | Paul Olav Tvete <paul.tvete@nokia.com> | 2010-08-19 09:52:55 (GMT) |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@nokia.com> | 2010-08-19 09:52:55 (GMT) |
commit | 872ccdcc090cec252cea2109d2fc9f2f2ee4c795 (patch) | |
tree | 7b14b977528cb6e833a765afce3c9bf6e55c94af /src/gui/kernel/qwidget.cpp | |
parent | 74d519f87e804b624ac76337fe2905d512d363fc (diff) | |
parent | f6cfafde26b4735965be8df0d11e9d7c297c75b9 (diff) | |
download | Qt-872ccdcc090cec252cea2109d2fc9f2f2ee4c795.zip Qt-872ccdcc090cec252cea2109d2fc9f2f2ee4c795.tar.gz Qt-872ccdcc090cec252cea2109d2fc9f2f2ee4c795.tar.bz2 |
Merge remote branch 'qt/4.7' into lighthouse-4.7
Conflicts:
src/opengl/qgl_p.h
Diffstat (limited to 'src/gui/kernel/qwidget.cpp')
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 61 |
1 files changed, 45 insertions, 16 deletions
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 9946d5d..7ea81bb 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -165,47 +165,76 @@ static inline bool hasBackingStoreSupport() extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); // qapplication.cpp extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp +/*! + \internal + \class QWidgetBackingStoreTracker + \brief Class which allows tracking of which widgets are using a given backing store -QRefCountedWidgetBackingStore::QRefCountedWidgetBackingStore() + QWidgetBackingStoreTracker is a thin wrapper around a QWidgetBackingStore pointer, + which maintains a list of the QWidgets which are currently using the backing + store. This list is modified via the registerWidget and unregisterWidget functions. + */ + +QWidgetBackingStoreTracker::QWidgetBackingStoreTracker() : m_ptr(0) - , m_count(0) { } -QRefCountedWidgetBackingStore::~QRefCountedWidgetBackingStore() +QWidgetBackingStoreTracker::~QWidgetBackingStoreTracker() { delete m_ptr; } -void QRefCountedWidgetBackingStore::create(QWidget *widget) +/*! + \internal + Destroy the contained QWidgetBackingStore, if not null, and clear the list of + widgets using the backing store, then create a new QWidgetBackingStore, providing + the QWidget. + */ +void QWidgetBackingStoreTracker::create(QWidget *widget) { destroy(); m_ptr = new QWidgetBackingStore(widget); - m_count = 0; } -void QRefCountedWidgetBackingStore::destroy() +/*! + \internal + Destroy the contained QWidgetBackingStore, if not null, and clear the list of + widgets using the backing store. + */ +void QWidgetBackingStoreTracker::destroy() { delete m_ptr; m_ptr = 0; - m_count = 0; + m_widgets.clear(); } -void QRefCountedWidgetBackingStore::ref() +/*! + \internal + Add the widget to the list of widgets currently using the backing store. + If the widget was already in the list, this function is a no-op. + */ +void QWidgetBackingStoreTracker::registerWidget(QWidget *w) { Q_ASSERT(m_ptr); - ++m_count; + Q_ASSERT(w->internalWinId()); + Q_ASSERT(qt_widget_private(w)->maybeBackingStore() == m_ptr); + m_widgets.insert(w); } -void QRefCountedWidgetBackingStore::deref() +/*! + \internal + Remove the widget from the list of widgets currently using the backing store. + If the widget was in the list, and removing it causes the list to be empty, + the backing store is deleted. + If the widget was not in the list, this function is a no-op. + */ +void QWidgetBackingStoreTracker::unregisterWidget(QWidget *w) { - if (m_count) { - Q_ASSERT(m_ptr); - if (0 == --m_count) { - delete m_ptr; - m_ptr = 0; - } + if (m_widgets.remove(w) && m_widgets.isEmpty()) { + delete m_ptr; + m_ptr = 0; } } |