diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index b46583bf840..91d76fa254c 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -53,7 +54,7 @@ typedef QSharedPointer SharedPointerFileDialogOptions; NSView *m_accessoryView; NSPopUpButton *m_popupButton; NSTextField *m_textField; - QCocoaFileDialogHelper *m_helper; + QPointer m_helper; NSString *m_currentDirectory; SharedPointerFileDialogOptions m_options; @@ -160,6 +161,8 @@ typedef QSharedPointer SharedPointerFileDialogOptions; // QEventLoop has been interrupted, and the second-most event loop has not // yet been reactivated (regardless if [NSApp run] is still on the stack)), // showing a native modal dialog will fail. + if (!m_helper) + return; QMacAutoReleasePool pool; @@ -285,6 +288,8 @@ typedef QSharedPointer SharedPointerFileDialogOptions; { // This m_delegate function is called when the _name_ filter changes. Q_UNUSED(sender); + if (!m_helper) + return; QString selection = m_nameFilterDropDownList->value([m_popupButton indexOfSelectedItem]); *m_selectedNameFilter = [self findStrippedFilterWithVisualFilterName:selection]; [m_panel validateVisibleColumns]; @@ -369,6 +374,10 @@ typedef QSharedPointer SharedPointerFileDialogOptions; - (void)panelSelectionDidChange:(id)sender { Q_UNUSED(sender); + + if (!m_helper) + return; + if (m_panel.visible) { QString selection = QString::fromNSString(m_panel.URL.path); if (selection != *m_currentSelection) { @@ -382,6 +391,9 @@ typedef QSharedPointer SharedPointerFileDialogOptions; { Q_UNUSED(sender); + if (!m_helper) + return; + if (!(path && path.length) || [path isEqualToString:m_currentDirectory]) return;