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 */