Fix crash in QFileDialog::iconProvider() with native dialogs

Task-number: QTBUG-49600
Change-Id: Ied28c0e7efa6b4dce25705dab98377848db5a6d3
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
This commit is contained in:
Joni Poikelin 2015-11-24 09:51:12 +02:00
parent 045abe631c
commit e4d1bf9829
2 changed files with 11 additions and 0 deletions

View File

@ -1938,6 +1938,8 @@ void QFileDialog::setIconProvider(QFileIconProvider *provider)
QFileIconProvider *QFileDialog::iconProvider() const
{
Q_D(const QFileDialog);
if (!d->model)
return Q_NULLPTR;
return d->model->iconProvider();
}

View File

@ -165,6 +165,7 @@ private slots:
#endif // QT_BUILD_INTERNAL
#endif
void rejectModalDialogs();
void QTBUG49600_nativeIconProviderCrash();
private:
void cleanupSettingsFile();
@ -1487,5 +1488,13 @@ void tst_QFiledialog::rejectModalDialogs()
QVERIFY(file.isEmpty());
}
void tst_QFiledialog::QTBUG49600_nativeIconProviderCrash()
{
if (!QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(QPlatformTheme::FileDialog))
QSKIP("This platform always uses widgets to realize its QFileDialog, instead of the native file dialog.");
QFileDialog fd;
fd.iconProvider();
}
QTEST_MAIN(tst_QFiledialog)
#include "tst_qfiledialog.moc"