Core: Guard against pages that forgot to create their widgets

This should not happen, but when it happens, the resulting crash is
quite cryptic. Make it a bit more obvious.

Change-Id: Icbe40206cfdbae93ccb072d7027fcaf109f2f39f
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2023-07-07 13:08:45 +02:00
parent 57b6b8630c
commit 2a731003cf
2 changed files with 7 additions and 3 deletions

View File

@@ -132,6 +132,7 @@ QWidget *IOptionsPage::widget()
if (!m_widget) {
if (m_widgetCreator) {
m_widget = m_widgetCreator();
QTC_CHECK(m_widget);
} else if (m_settingsProvider) {
m_widget = new IOptionsPageWidget;
AspectContainer *container = m_settingsProvider();

View File

@@ -345,9 +345,12 @@ private:
void showEvent(QShowEvent *event) final
{
if (!widget()) {
QWidget *inner = m_page->widget();
if (QWidget *inner = m_page->widget()) {
setWidget(inner);
inner->setAutoFillBackground(false);
} else {
QTC_CHECK(false);
}
}
QScrollArea::showEvent(event);