From caacd1377fb25652c62e9ff10341fdfdf0140d2c Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 24 Jan 2005 20:09:46 +0000 Subject: [PATCH] Backport Till's fix: Fix at least one of the reasons for the infamous "suddenly the headers list is empty", also known as the "QGArray::at: Absolute index n out of range" issue, by making sure that the quick search is only updated after a new list view item has been completed added, not right after the KListViewItem ctor, where we don't have valid folder index entries in the header list items yet, which the status quick search needs. svn path=/branches/proko2/kdepim/; revision=382046 --- headerlistquicksearch.cpp | 10 ++++++++++ kmheaders.cpp | 2 +- kmheaders.h | 15 +++++++++++---- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/headerlistquicksearch.cpp b/headerlistquicksearch.cpp index a2f82de14..9ca6251b2 100644 --- a/headerlistquicksearch.cpp +++ b/headerlistquicksearch.cpp @@ -73,6 +73,16 @@ HeaderListQuickSearch::HeaderListQuickSearch( QWidget *parent, this, SLOT( slotStatusChanged( int ) ) ); label->setBuddy( mStatusCombo ); + + /* Disable the signal connected by KListViewSearchLine since it will call + * itemAdded during KMHeaders::readSortOrder() which will in turn result + * in getMsgBaseForItem( item ) wanting to access items which are no longer + * there. Rather rely on KMHeaders::msgAdded and its signal. */ + disconnect(listView, SIGNAL(itemAdded(QListViewItem *)), + this, SLOT(itemAdded(QListViewItem *))); + KMHeaders *headers = static_cast( listView ); + connect( headers, SIGNAL( msgAddedToListView( QListViewItem * ) ), + this, SLOT( itemAdded( QListViewItem* ) ) ); } HeaderListQuickSearch::~HeaderListQuickSearch() diff --git a/kmheaders.cpp b/kmheaders.cpp index e2ee2db4c..baf6ffdf6 100644 --- a/kmheaders.cpp +++ b/kmheaders.cpp @@ -1251,7 +1251,7 @@ void KMHeaders::msgAdded(int id) connect( this, SIGNAL(currentChanged(QListViewItem*)), this, SLOT(highlightMessage(QListViewItem*))); - emit messageListUpdated(); + emit msgAddedToListView( hi ); END_TIMER(msgAdded); SHOW_TIMER(msgAdded); } diff --git a/kmheaders.h b/kmheaders.h index 8134f6c4c..678f9b4b7 100644 --- a/kmheaders.h +++ b/kmheaders.h @@ -169,14 +169,21 @@ public: signals: /** emitted when the list view item corresponding to this message has been selected */ - virtual void selected(KMMessage *); + void selected(KMMessage *); /** emitted when the list view item corresponding to this message has been double clicked */ - virtual void activated(KMMessage *); + void activated(KMMessage *); /** emitted when we might be about to delete messages */ - virtual void maybeDeleting(); + void maybeDeleting(); /** emitted when the list of messages has been completely rebuilt */ - virtual void messageListUpdated(); + void messageListUpdated(); + + /** emitted after a new item has been fully built and added to the + * list view. We can't use KListView::itemAdded, as that is emitted + * from the ctor of the item, at which point the building of the item + * is not yet far enough along to update the quick search, which is + * what is connected to this signal. */ + void msgAddedToListView( QListViewItem* ); public slots: /** For when a list view item has been double clicked */