summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristoph Schleifenbaum <christoph.schleifenbaum@kdab.com>2012-04-10 17:15:44 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-12 04:15:10 +0200
commit5a2ef8ebddd5546acbf13f37af8d8ecc1178be31 (patch)
tree30c810b400c829dbe423f170168aeea4af7dfe6a /src
parent3918386779da4bfaf65c209eea9aa64c3c5bca69 (diff)
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 <bradley.hughes@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm4
2 files changed, 8 insertions, 0 deletions
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<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(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<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(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<QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *>(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<QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *>(mDelegate)->mQtFont;
}