Help: Fix crash with previous/next document in help mode

"Previous/next Open Document in History" crashed in help mode when only
a single page is open.
Disable the actions in this case, and add a guard that prevents setting
the current page to an invalid index.

Fixes: QDS-3743
Change-Id: I569292d8c348269dd12d2ebb089c03173cbd4bc2
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Miikka Heikkinen
2021-02-25 15:29:40 +02:00
parent 0de044d479
commit d41bc944cc
2 changed files with 7 additions and 2 deletions

View File

@@ -934,7 +934,10 @@ void HelpWidget::updateCloseButton()
{
if (supportsPages()) {
const bool closeOnReturn = LocalHelpManager::returnOnClose() && m_style == ModeWidget;
m_closeAction->setEnabled(closeOnReturn || m_viewerStack->count() > 1);
const bool hasMultiplePages = m_viewerStack->count() > 1;
m_closeAction->setEnabled(closeOnReturn || hasMultiplePages);
m_gotoPrevious->setEnabled(hasMultiplePages);
m_gotoNext->setEnabled(hasMultiplePages);
}
}

View File

@@ -81,7 +81,9 @@ void OpenPagesSwitcher::gotoPreviousPage()
void OpenPagesSwitcher::selectAndHide()
{
setVisible(false);
emit setCurrentPage(m_openPagesWidget->currentIndex());
QModelIndex index = m_openPagesWidget->currentIndex();
if (index.isValid())
emit setCurrentPage(index);
}
void OpenPagesSwitcher::selectCurrentPage(int index)