winrt: Check validity of options shared pointer

QErrorMessage autotests managed to create a scenario where the options
are not initialized yet, causing a crash later on.

Change-Id: Iabad6f181f2bfdc81a9c73f0e67c8ba70753fec6
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
Maurice Kalinowski 2016-08-25 09:59:06 +02:00
parent f4b2115b51
commit 5f895fe0e2

View File

@ -108,6 +108,9 @@ bool QWinRTMessageDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModa
Q_D(QWinRTMessageDialogHelper); Q_D(QWinRTMessageDialogHelper);
QSharedPointer<QMessageDialogOptions> options = this->options(); QSharedPointer<QMessageDialogOptions> options = this->options();
if (!options.data())
return false;
const QString informativeText = options->informativeText(); const QString informativeText = options->informativeText();
const QString title = options->windowTitle(); const QString title = options->windowTitle();
const QString text = informativeText.isEmpty() ? options->text() : (options->text() + QLatin1Char('\n') + informativeText); const QString text = informativeText.isEmpty() ? options->text() : (options->text() + QLatin1Char('\n') + informativeText);