From ca68cd50f2abd92b4d1048346f226303776d76ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C4=83t=C4=83lin=20R=C4=83ceanu?= Date: Sun, 10 Mar 2019 01:36:18 +0200 Subject: [PATCH] Do not explicitly set selection to -1 when deleting all pages Avoid calling wxNotebook::SetSelection(-1) when the notebook is cleared. Closes https://github.com/wxWidgets/wxWidgets/pull/1254 --- src/qt/notebook.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/qt/notebook.cpp b/src/qt/notebook.cpp index bb5750b6a3..0f4c2ae062 100644 --- a/src/qt/notebook.cpp +++ b/src/qt/notebook.cpp @@ -167,13 +167,22 @@ wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const bool wxNotebook::DeleteAllPages() { - if ( !wxNotebookBase::DeleteAllPages() ) - return false; + // Nothing to do if the notebook was not created yet, + // and return true just like other ports do. + if ( !m_qtTabWidget ) + return true; + // Block signals to not receive selection changed updates + // which are sent by Qt after the selected page was deleted. m_qtTabWidget->blockSignals(true); - m_qtTabWidget->clear(); + + // Pages will be deleted one by one in the base class. + // There's no need to explicitly clear() the Qt control. + bool deleted = wxNotebookBase::DeleteAllPages(); + m_qtTabWidget->blockSignals(false); - return true; + + return deleted; } int wxNotebook::SetSelection(size_t page)