From 5a2ef8ebddd5546acbf13f37af8d8ecc1178be31 Mon Sep 17 00:00:00 2001 From: Christoph Schleifenbaum Date: Tue, 10 Apr 2012 17:15:44 +0200 Subject: Cocoa: Proper handling of mDelegate mDelegate keeps the pointer to a QNSFontPanelDelegate, which reacts on the NSFontPanel used by this dialog helper. It has to be created before it can be used. On a read-only access, this has been fixed to return a default-constructed value (like QFont()). For writing access (like setting the font) the delegate was already created. The same applies to mDelegate to QNSColorPanelDelegate respective. Change-Id: I36b89c16d98db9275aa31d399fe094b1d56d800d Reviewed-by: Bradley T. Hughes --- src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm | 4 ++++ src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm index fd4d6605a9..405cacee01 100644 --- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm @@ -395,6 +395,8 @@ void QCocoaColorDialogHelper::hide_sys() QCocoaColorDialogHelper::DialogCode QCocoaColorDialogHelper::dialogResultCode_sys() { + if (!mDelegate) + return QPlatformDialogHelper::Rejected; QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *delegate = static_cast(mDelegate); return [delegate dialogResultCode]; } @@ -429,6 +431,8 @@ void QCocoaColorDialogHelper::setCurrentColor_sys(const QColor &color) QColor QCocoaColorDialogHelper::currentColor_sys() const { + if (!mDelegate) + return QColor(); return reinterpret_cast(mDelegate)->mQtColor; } diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm index d05a0156b1..1e89270775 100644 --- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm @@ -414,6 +414,8 @@ void QCocoaFontDialogHelper::hide_sys() QCocoaFontDialogHelper::DialogCode QCocoaFontDialogHelper::dialogResultCode_sys() { + if (!mDelegate) + return QPlatformDialogHelper::Rejected; QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *delegate = static_cast(mDelegate); return [delegate dialogResultCode]; } @@ -448,6 +450,8 @@ void QCocoaFontDialogHelper::setCurrentFont_sys(const QFont &font) QFont QCocoaFontDialogHelper::currentFont_sys() const { + if (!mDelegate) + return QFont(); return reinterpret_cast(mDelegate)->mQtFont; } -- cgit v1.2.3