summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJanne Koskinen <janne.p.koskinen@digia.com>2009-11-25 12:10:45 (GMT)
committerJanne Koskinen <janne.p.koskinen@digia.com>2009-11-25 12:10:45 (GMT)
commitcee1c16a4738e30db5c011f4ae7e273387b5d998 (patch)
tree8fdf92bbe62efa0e7286551842985f5b5ddf7a22 /tests
parent6bf1037df75d8d6f697f9f49d8d7fbe9b2cabc98 (diff)
downloadQt-cee1c16a4738e30db5c011f4ae7e273387b5d998.zip
Qt-cee1c16a4738e30db5c011f4ae7e273387b5d998.tar.gz
Qt-cee1c16a4738e30db5c011f4ae7e273387b5d998.tar.bz2
Fixed crash when scrolling with deleted backingstore
In Symbian we save memory by deleting widget backingstore from non-visible windows. 12-key FEP is fullscreen and causes the backing store to be deleted but still continues to scroll the view to show current caret position in focused lineedit control. Task-number: QTBUG-5922 Reviewed-by: Jason Barron
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 1e3f5f8..9960f47 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -391,6 +391,7 @@ private slots:
#endif
void focusProxyAndInputMethods();
+ void scrollWithoutBackingStore();
private:
bool ensureScreenSize(int width, int height);
@@ -9703,5 +9704,42 @@ void tst_QWidget::focusProxyAndInputMethods()
delete toplevel;
}
+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;
+ }
+ }
+ 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())->invalidateBuffer(this->rect());
+ repaint();
+ }
+ }
+};
+
+void tst_QWidget::scrollWithoutBackingStore()
+{
+ scrollWidgetWBS scrollable;
+ scrollable.resize(100,100);
+ QLabel child(QString("@"),&scrollable);
+ child.resize(50,50);
+ scrollable.show();
+ QTest::qWaitForWindowShown(&scrollable);
+ scrollable.scroll(50,50);
+ QCOMPARE(child.pos(),QPoint(50,50));
+ scrollable.deleteBackingStore();
+ scrollable.scroll(-25,-25);
+ QCOMPARE(child.pos(),QPoint(25,25));
+ scrollable.enableBackingStore();
+ QCOMPARE(child.pos(),QPoint(25,25));
+}
+
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"