aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Ionascu <stanislav.ionascu@nokia.com>2010-12-03 10:54:17 +0200
committerStanislav Ionascu <stanislav.ionascu@nokia.com>2010-12-03 15:29:55 +0200
commit033d8b60f6f4e938dd64525c718d02d4b129c0fb (patch)
treeff3b22f21456d0aa0e4e3e342ddde65753dac95c
parentc5314bb4d710a50915b2432c44938b1502e3121e (diff)
Fixes: NB#204938 - List view private is destroyed while the event loop is processed.
RevBy: Sergiy Dubovik, Armin Berres Details: Do not delete the private class immediately, but postpone it, as Qt docs suggest.
-rw-r--r--src/views/mlistview.cpp7
-rw-r--r--src/views/mlistview_p.cpp25
-rw-r--r--src/views/mlistview_p.h4
3 files changed, 33 insertions, 3 deletions
diff --git a/src/views/mlistview.cpp b/src/views/mlistview.cpp
index 9f6eea87..a7ed76ec 100644
--- a/src/views/mlistview.cpp
+++ b/src/views/mlistview.cpp
@@ -58,9 +58,10 @@ void MListView::init()
if(d_ptr) {
d_ptr->disconnectSignalsFromModelToListView();
headersCreator = d_ptr->headersCreator;
- }
- delete d_ptr;
+ // Schedule deletion as we might have some events pending for delivery.
+ d_ptr->destroy();
+ }
if (model()->columns() > 1) {
if (model()->showGroups())
@@ -154,7 +155,7 @@ void MListView::applyStyle()
{
MWidgetView::applyStyle();
- if (d_ptr) {
+ if (d_ptr) {
d_ptr->clearVisibleItemsArray();
d_ptr->updateItemHeight();
d_ptr->updateSeparators();
diff --git a/src/views/mlistview_p.cpp b/src/views/mlistview_p.cpp
index af7a64c1..7972d533 100644
--- a/src/views/mlistview_p.cpp
+++ b/src/views/mlistview_p.cpp
@@ -57,6 +57,7 @@ MListViewPrivate::MListViewPrivate() : recycler(new MWidgetRecycler)
clearVisibleOnRelayout = false;
scrollToAnimation = new QPropertyAnimation(this);
+ isDeleted = false;
movingDetectorTimer.setSingleShot(true);
connect(&movingDetectorTimer, SIGNAL(timeout()), this, SLOT(movingDetectionTimerTimeout()));
@@ -139,6 +140,12 @@ void MListViewPrivate::deleteVisibleItemsArray()
visibleItems.clear();
}
+void MListViewPrivate::destroy()
+{
+ isDeleted = true;
+ deleteLater();
+}
+
void MListViewPrivate::clearFirstAndLastVisibleRows()
{
updateFirstVisibleRow(QModelIndex());
@@ -210,6 +217,9 @@ MWidget *MListViewPrivate::createCell(int row)
void MListViewPrivate::viewportRectChanged(const QRectF &viewportRect)
{
+ if (isDeleted)
+ return;
+
if (viewportRect.topLeft() != oldViewportRectPosition) {
movingDetectorTimer.start(MOVINGDETECTORTIMEOUT);
@@ -224,11 +234,17 @@ void MListViewPrivate::viewportRectChanged(const QRectF &viewportRect)
void MListViewPrivate::viewportPositionChanged(const QPointF &position)
{
+ if (isDeleted)
+ return;
+
updateViewportRect(position - listPosition, QSizeF(viewWidth, pannableViewport->size().height()));
}
void MListViewPrivate::viewportSizeChanged(const QSizeF &size)
{
+ if (isDeleted)
+ return;
+
updateViewportRect(viewportTopLeft, QSizeF(viewWidth, size.height()));
updateScrollToTargetPosition();
}
@@ -237,6 +253,9 @@ void MListViewPrivate::viewportRangeChanged(const QRectF &range)
{
Q_UNUSED(range);
+ if (isDeleted)
+ return;
+
updateScrollToTargetPosition();
}
@@ -279,6 +298,9 @@ void MListViewPrivate::updateListGeometry()
void MListViewPrivate::updateViewportRect(const QPointF &position, const QSizeF &size)
{
+ if (isDeleted)
+ return;
+
if ((viewportTopLeft != position) || (viewportVisibleHeight < size.height()) || (forceRepaint)) {
forceRepaint = false;
@@ -583,6 +605,9 @@ void MListViewPrivate::_q_itemLongTapped(const QPointF &pos)
void MListViewPrivate::_q_relayoutItemsIfNeeded()
{
+ if (isDeleted)
+ return;
+
if (controller->isVisible())
q_ptr->relayoutItemsInViewportRect();
}
diff --git a/src/views/mlistview_p.h b/src/views/mlistview_p.h
index 7b50d485..cb67947e 100644
--- a/src/views/mlistview_p.h
+++ b/src/views/mlistview_p.h
@@ -111,6 +111,7 @@ public:
void scrollToPos(const QPointF &targetPosition, MList::AnimationMode mode);
void deleteVisibleItemsArray();
+ void destroy();
public:
virtual void createSeparators();
@@ -207,6 +208,9 @@ public:
// Scroll animation
QPropertyAnimation *scrollToAnimation;
+
+ //
+ bool isDeleted;
};
class MPlainListViewPrivate : public MListViewPrivate