summaryrefslogtreecommitdiffstats
path: root/src/gui/dialogs/qcolordialog.cpp
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2009-07-28 15:54:20 +0200
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2009-07-28 15:59:21 +0200
commitb0482e0b13ea3c20674515ffdafb66c14231cc56 (patch)
tree2f1c00258544d473b65f1b1d1fdcbf31cac46fd9 /src/gui/dialogs/qcolordialog.cpp
parentac92e906114ed7216cfd99e0deecfb7be0fd91ec (diff)
Regression: QColorDialog crash on Mac when accepting with keyboard
Basically, the crash happends because we release the dialog when the ok button is clicked. But when the button is clicked with the keyboard (actually cocoa emulates a click when pressing enter), it also tries to do some focus handling on the button afterwards. But at that point, the button is already freed up. With a crash as the result. This patch goes through a lot of the code, and rewrites it so we doesnt free up the cocoa objects before the destructor of the QColorDialog is called. Task-number: 258445 Reviewed-by: msorvig
Diffstat (limited to 'src/gui/dialogs/qcolordialog.cpp')
-rw-r--r--src/gui/dialogs/qcolordialog.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp
index 510c0c41e8..e56faa28a0 100644
--- a/src/gui/dialogs/qcolordialog.cpp
+++ b/src/gui/dialogs/qcolordialog.cpp
@@ -1582,8 +1582,7 @@ void QColorDialog::setCurrentColor(const QColor &color)
d->setCurrentAlpha(color.alpha());
#ifdef Q_WS_MAC
- if (d->delegate)
- QColorDialogPrivate::setColor(d->delegate, color);
+ d->setCocoaPanelColor(color);
#endif
}
@@ -1724,19 +1723,16 @@ void QColorDialog::setVisible(bool visible)
#if defined(Q_WS_MAC)
if (visible) {
- if (!d->delegate && QColorDialogPrivate::sharedColorPanelAvailable &&
- !(testAttribute(Qt::WA_DontShowOnScreen) || (d->opts & DontUseNativeDialog))){
- d->delegate = QColorDialogPrivate::openCocoaColorPanel(
- currentColor(), parentWidget(), windowTitle(), options(), d);
+ if (d->delegate || (QColorDialogPrivate::sharedColorPanelAvailable &&
+ !(testAttribute(Qt::WA_DontShowOnScreen) || (d->opts & DontUseNativeDialog)))){
+ d->openCocoaColorPanel(currentColor(), parentWidget(), windowTitle(), options());
QColorDialogPrivate::sharedColorPanelAvailable = false;
setAttribute(Qt::WA_DontShowOnScreen);
}
setWindowFlags(windowModality() == Qt::WindowModal ? Qt::Sheet : DefaultWindowFlags);
} else {
if (d->delegate) {
- QColorDialogPrivate::closeCocoaColorPanel(d->delegate);
- d->delegate = 0;
- QColorDialogPrivate::sharedColorPanelAvailable = true;
+ d->closeCocoaColorPanel();
setAttribute(Qt::WA_DontShowOnScreen, false);
}
}
@@ -1839,6 +1835,14 @@ QRgb QColorDialog::getRgba(QRgb initial, bool *ok, QWidget *parent)
QColorDialog::~QColorDialog()
{
+ Q_D(QColorDialog);
+#if defined(Q_WS_MAC)
+ if (d->delegate) {
+ d->releaseCocoaColorPanelDelegate();
+ QColorDialogPrivate::sharedColorPanelAvailable = true;
+ }
+#endif
+
#ifndef QT_NO_SETTINGS
if (!customSet) {
QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));