diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2021-02-25 15:29:40 +0200 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2021-02-26 09:50:15 +0000 |
commit | d41bc944cce5350674a34f80ec61cc20e3adeea4 (patch) | |
tree | aed843c6137119a42d681a933f6bc41b43713e09 | |
parent | 0de044d4794aff533a77f7dfe23815f9e2f4388d (diff) |
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>
-rw-r--r-- | src/plugins/help/helpwidget.cpp | 5 | ||||
-rw-r--r-- | src/plugins/help/openpagesswitcher.cpp | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/plugins/help/helpwidget.cpp b/src/plugins/help/helpwidget.cpp index 65c468ac38..30a62b3381 100644 --- a/src/plugins/help/helpwidget.cpp +++ b/src/plugins/help/helpwidget.cpp @@ -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); } } diff --git a/src/plugins/help/openpagesswitcher.cpp b/src/plugins/help/openpagesswitcher.cpp index 20117828a7..5991efd0dd 100644 --- a/src/plugins/help/openpagesswitcher.cpp +++ b/src/plugins/help/openpagesswitcher.cpp @@ -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) |