From a2bc154ed0e38d164dd7141d1c44be299f3051e7 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 9 Aug 2021 10:41:47 +0200 Subject: [PATCH] Fix a crash when searching again for the last 12th item Don't connect updateFilterButton() to the QStackedWidget::currentChanged(). Call updateFilterButton() explicitly by the end of setCurrentIndex(). Fixes: QTCREATORBUG-26099 Change-Id: I7cba97346e1f6c73171a9b83381e271750d50f25 Reviewed-by: Eike Ziller --- src/plugins/coreplugin/find/searchresultwindow.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/plugins/coreplugin/find/searchresultwindow.cpp b/src/plugins/coreplugin/find/searchresultwindow.cpp index 9fcbda4e802..1e0f46da0e4 100644 --- a/src/plugins/coreplugin/find/searchresultwindow.cpp +++ b/src/plugins/coreplugin/find/searchresultwindow.cpp @@ -190,8 +190,6 @@ namespace Internal { return; m_searchResultWidgets.at(visibleSearchIndex())->showFilterWidget(m_filterButton); }); - connect(m_widget, &QStackedWidget::currentChanged, - this, &SearchResultWindowPrivate::updateFilterButton); } void SearchResultWindowPrivate::setCurrentIndex(int index, bool focus) @@ -214,16 +212,17 @@ namespace Internal { m_newSearchButton->setEnabled(true); } q->navigateStateChanged(); + updateFilterButton(); } void SearchResultWindowPrivate::moveWidgetToTop() { auto widget = qobject_cast(sender()); QTC_ASSERT(widget, return); - int index = m_searchResultWidgets.indexOf(widget); + const int index = m_searchResultWidgets.indexOf(widget); if (index == 0) return; // nothing to do - int internalIndex = index + 1/*account for "new search" entry*/; + const int internalIndex = index + 1/*account for "new search" entry*/; QString searchEntry = m_recentSearchesBox->itemText(internalIndex); m_searchResultWidgets.removeAt(index);