From 58253fafc6d3c0a535833e674d8930a46138c25f Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 25 May 2009 09:30:20 +0200 Subject: BT: Mac: Crash when using QFontDialog If creating a native QFontDialog and delete it, the native dialog will still show. And worse, it will call the deleted QDialog counterpart. This fix will clean up (and close the native dialog) when the QDialog is deleted. Task-number: 254397 Reviewed-by: Trenton Schulz --- src/gui/dialogs/qfontdialog.cpp | 8 ++++++++ src/gui/dialogs/qfontdialog_mac.mm | 1 + 2 files changed, 9 insertions(+) diff --git a/src/gui/dialogs/qfontdialog.cpp b/src/gui/dialogs/qfontdialog.cpp index 4c5bf4f..aa1c553 100644 --- a/src/gui/dialogs/qfontdialog.cpp +++ b/src/gui/dialogs/qfontdialog.cpp @@ -337,6 +337,14 @@ void QFontDialogPrivate::init() QFontDialog::~QFontDialog() { +#ifdef Q_WS_MAC + Q_D(QFontDialog); + if (d->delegate) { + QFontDialogPrivate::closeCocoaFontPanel(d->delegate); + QFontDialogPrivate::sharedFontPanelAvailable = true; + return; + } +#endif } /*! diff --git a/src/gui/dialogs/qfontdialog_mac.mm b/src/gui/dialogs/qfontdialog_mac.mm index 50917a1..13f7149 100644 --- a/src/gui/dialogs/qfontdialog_mac.mm +++ b/src/gui/dialogs/qfontdialog_mac.mm @@ -566,6 +566,7 @@ void *QFontDialogPrivate::openCocoaFontPanel(const QFont &initial, void QFontDialogPrivate::closeCocoaFontPanel(void *delegate) { + QMacCocoaAutoReleasePool pool; QCocoaFontPanelDelegate *theDelegate = static_cast(delegate); NSWindow *ourPanel = [theDelegate actualPanel]; [ourPanel close]; -- cgit v0.12