From 603ccb3d715b1d6e9969b2df8ab27461f51728fb Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 13 May 2010 14:11:07 +0100 Subject: Window visibility changes update TLW backing store reference count * When a native window becomes completely invisible, the reference count of the top-level widget's backing store is decremented. * When a previously invisible native window becomes either partially or fully visible: - If the top-level widget has a backing store, its reference count is incremented. - Otherwise, the top-level widget creates a backing store with an initial reference count of 1. Task-number: QTBUG-8697 Reviewed-by: Jason Barron --- src/gui/kernel/qapplication_s60.cpp | 23 ++++++++++++++++------- tests/auto/qwidget/tst_qwidget.cpp | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 6997326..78027b2 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1703,18 +1703,27 @@ int QApplicationPrivate::symbianProcessWsEvent(const QSymbianEvent *symbianEvent return 1; const TWsVisibilityChangedEvent *visChangedEvent = event->VisibilityChanged(); QWidget *w = QWidgetPrivate::mapper->value(control); - if (!w->d_func()->maybeTopData()) + QWidget *const window = w->window(); + if (!window->d_func()->maybeTopData()) break; + QRefCountedWidgetBackingStore &backingStore = window->d_func()->maybeTopData()->backingStore; if (visChangedEvent->iFlags & TWsVisibilityChangedEvent::ENotVisible) { - w->d_func()->topData()->backingStore.destroy(); + // Decrement backing store reference count + backingStore.deref(); // In order to ensure that any resources used by the window surface // are immediately freed, we flush the WSERV command buffer. S60->wsSession().Flush(); - } else if ((visChangedEvent->iFlags & TWsVisibilityChangedEvent::EPartiallyVisible) - && !w->d_func()->maybeBackingStore()) { - w->d_func()->topData()->backingStore.create(w); - w->d_func()->invalidateBuffer(w->rect()); - w->repaint(); + } else if (visChangedEvent->iFlags & TWsVisibilityChangedEvent::EPartiallyVisible) { + if (backingStore.data()) { + // Increment backing store reference count + backingStore.ref(); + } else { + // Create backing store with an initial reference count of 1 + backingStore.create(window); + backingStore.ref(); + w->d_func()->invalidateBuffer(w->rect()); + w->repaint(); + } } return 1; } diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 9369f4a..7d4f8ff 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -9635,7 +9635,6 @@ void tst_QWidget::destroyBackingStoreWhenHidden() // Backing store should remain unchanged despite child window obscuring // parent window - QEXPECT_FAIL("", "QTBUG-8697", Continue); QVERIFY(parentBs == backingStore(parent)); QVERIFY(0 == backingStore(child)); } @@ -9742,6 +9741,7 @@ void tst_QWidget::destroyBackingStoreWhenHidden() QVERIFY(0 != backingStore(child)); // Parent is obscured, therefore its backing store should be destroyed + QEXPECT_FAIL("", "QTBUG-10643", Continue); QVERIFY(0 == backingStore(parent)); // Disable full screen -- cgit v0.12