diff options
author | Mitch Curtis <[email protected]> | 2025-08-13 10:57:10 +0800 |
---|---|---|
committer | Qt Cherry-pick Bot <[email protected]> | 2025-08-15 08:10:17 +0000 |
commit | 654ff0181cc13cdb4240b01f2c23e52d0e259170 (patch) | |
tree | 18988ade7816adc6a8db79666d40a62a2bd1ff48 | |
parent | 685d880ba605d55a531d3c37fad276e98129cb44 (diff) |
Dialogs: only return valid QPlatformDialogHelper if Qt Quick dialog is
If we don't do this, QQuickAbstractDialog::create will see that
m_handle is valid and call onCreate, which tries to call selectedFiles
and we get a crash.
Amends f9421abbdf4d2e2be06febf9f75a2b62e6875835.
Pick-to: 6.9 6.8 6.5
Change-Id: Id522e068c689a5bc5662466e446f99586bc7c738
Reviewed-by: Oliver Eftevaag <[email protected]>
(cherry picked from commit 93ea1a12ec532c77c22519062cb19007e6dd0db4)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
-rw-r--r-- | src/quickdialogs/quickdialogsquickimpl/qquickdialogimplfactory.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/quickdialogs/quickdialogsquickimpl/qquickdialogimplfactory.cpp b/src/quickdialogs/quickdialogsquickimpl/qquickdialogimplfactory.cpp index 340695fe11..ffc27daaf0 100644 --- a/src/quickdialogs/quickdialogsquickimpl/qquickdialogimplfactory.cpp +++ b/src/quickdialogs/quickdialogsquickimpl/qquickdialogimplfactory.cpp @@ -29,25 +29,35 @@ std::unique_ptr<QPlatformDialogHelper> QQuickDialogImplFactory::createPlatformDi std::unique_ptr<QPlatformDialogHelper> dialogHelper; switch (type) { case QQuickDialogType::ColorDialog: { - dialogHelper.reset(new QQuickPlatformColorDialog(parent)); + auto *quickPlatformDialog = new QQuickPlatformColorDialog(parent); + if (quickPlatformDialog->isValid()) + dialogHelper.reset(quickPlatformDialog); break; } #if QT_CONFIG(quick_listview) && QT_CONFIG(quick_draganddrop) case QQuickDialogType::FileDialog: { - dialogHelper.reset(new QQuickPlatformFileDialog(parent)); + auto *quickPlatformDialog = new QQuickPlatformFileDialog(parent); + if (quickPlatformDialog->isValid()) + dialogHelper.reset(quickPlatformDialog); break; } case QQuickDialogType::FolderDialog: { - dialogHelper.reset(new QQuickPlatformFolderDialog(parent)); + auto *quickPlatformDialog = new QQuickPlatformFolderDialog(parent); + if (quickPlatformDialog->isValid()) + dialogHelper.reset(quickPlatformDialog); break; } case QQuickDialogType::FontDialog: { - dialogHelper.reset(new QQuickPlatformFontDialog(parent)); + auto *quickPlatformDialog = new QQuickPlatformFontDialog(parent); + if (quickPlatformDialog->isValid()) + dialogHelper.reset(quickPlatformDialog); break; } #endif case QQuickDialogType::MessageDialog: { - dialogHelper.reset(new QQuickPlatformMessageDialog(parent)); + auto *quickPlatformDialog = new QQuickPlatformMessageDialog(parent); + if (quickPlatformDialog->isValid()) + dialogHelper.reset(quickPlatformDialog); break; } default: |