From 4a8c7e432931b27e7a5440a6d15bde999e962f35 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Wed, 20 May 2009 11:25:32 +0200 Subject: Fix a crash where QCocoaWindow get events after its widget is dead MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The invariant that QCocoaWindow's lifetime is contained in a QWidget is simply not true. A top-level QWidget gets associated with a QCocoaWindow (which is reference counted). However, it can be the case that we've destroyed our QWidget, the link is removed, the window is hidden, but the window still gets an event. In that case we would crash with an eventual null pointer access. However, we don't really need to do anything in this case, so just call super and return. Task-number: 253402 Reviewed-by: Morten Sørvig --- src/gui/kernel/qcocoapanel_mac.mm | 11 +++++++++-- src/gui/kernel/qcocoawindow_mac.mm | 13 ++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qcocoapanel_mac.mm b/src/gui/kernel/qcocoapanel_mac.mm index c69826f..b2941fe 100644 --- a/src/gui/kernel/qcocoapanel_mac.mm +++ b/src/gui/kernel/qcocoapanel_mac.mm @@ -107,9 +107,16 @@ QT_USE_NAMESPACE - (void)sendEvent:(NSEvent *)event { - [self retain]; - QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self]; + + // Cocoa can hold onto the window after we've disavowed its knowledge. So, + // if we get sent an event afterwards just have it go through the super's + // version and don't do any stuff with Qt. + if (!widget) { + [super sendEvent:event]; + return; + } + [self retain]; QT_MANGLE_NAMESPACE(QCocoaView) *view = static_cast(qt_mac_nativeview_for(widget)); Qt::MouseButton mouseButton = cocoaButton2QtButton([event buttonNumber]); diff --git a/src/gui/kernel/qcocoawindow_mac.mm b/src/gui/kernel/qcocoawindow_mac.mm index 89f481f..8e62f02 100644 --- a/src/gui/kernel/qcocoawindow_mac.mm +++ b/src/gui/kernel/qcocoawindow_mac.mm @@ -128,12 +128,19 @@ QT_USE_NAMESPACE - (void)sendEvent:(NSEvent *)event { - [self retain]; - QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self]; + + // Cocoa can hold onto the window after we've disavowed its knowledge. So, + // if we get sent an event afterwards just have it go through the super's + // version and don't do any stuff with Qt. + if (!widget) { + [super sendEvent:event]; + return; + } + + [self retain]; QT_MANGLE_NAMESPACE(QCocoaView) *view = static_cast(qt_mac_nativeview_for(widget)); Qt::MouseButton mouseButton = cocoaButton2QtButton([event buttonNumber]); - // sometimes need to redirect mouse events to the popup. QWidget *popup = qAppInstance()->activePopupWidget(); if (popup && popup != widget) { -- cgit v0.12 From 387db114cf09e60b43b13c36c83ef8cf07ee6553 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 20 May 2009 11:59:54 +0200 Subject: qdoc: Moved qdoc comments from qmacstyle_mac.mm to qstyles.qdoc The .mm file is not read by qdoc for packages other than for the MAC. This problem is overcome by moving the qdoc comments from the .mm file to a .qdoc file in doc/src, because all these files are read by qdoc for each of the packages. #Task-number: 252566 --- .commit-template | 14 +-- doc/src/qstyles.qdoc | 261 ++++++++++++++++++++++++++++++++++++++++ src/gui/styles/qmacstyle_mac.mm | 158 +----------------------- 3 files changed, 273 insertions(+), 160 deletions(-) create mode 100644 doc/src/qstyles.qdoc diff --git a/.commit-template b/.commit-template index 589ca89..171b67b 100644 --- a/.commit-template +++ b/.commit-template @@ -1,10 +1,8 @@ -# ===[ Subject ]==========[ one line, please wrap at 72 characters ]===| +qdoc: Moved qdoc comments from qmacstyle_mac.mm to qstyles.qdoc -# ---[ Details ]---------[ remember extra blank line after subject ]---| +The .mm file is not read by qdoc for packages other than for the MAC. +This problem is overcome by moving the qdoc comments from the .mm file +to a .qdoc file in doc/src, because all these files are read by qdoc +for each of the packages. -# ---[ Fields ]-----------------[ uncomment and edit as applicable ]---| - -#Task-number: -#Reviewed-by: - -# ==================================[ please wrap at 72 characters ]===| +#Task-number: 252566 diff --git a/doc/src/qstyles.qdoc b/doc/src/qstyles.qdoc new file mode 100644 index 0000000..e17097a --- /dev/null +++ b/doc/src/qstyles.qdoc @@ -0,0 +1,261 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +/*! + \class QMacStyle + \brief The QMacStyle class provides a Mac OS X style using the Apple Appearance Manager. + + \ingroup appearance + + This class is implemented as a wrapper to the HITheme + APIs, allowing applications to be styled according to the current + theme in use on Mac OS X. This is done by having primitives + in QStyle implemented in terms of what Mac OS X would normally theme. + + \warning This style is only available on Mac OS X because it relies on the + HITheme APIs. + + There are additional issues that should be taken + into consideration to make an application compatible with the + \link http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html + Apple Human Interface Guidelines \endlink. Some of these issues are outlined + below. + + \list + + \i Layout - The restrictions on window layout are such that some + aspects of layout that are style-dependent cannot be achieved + using QLayout. Changes are being considered (and feedback would be + appreciated) to make layouts QStyle-able. Some of the restrictions + involve horizontal and vertical widget alignment and widget size + (covered below). + + \i Widget size - Mac OS X allows widgets to have specific fixed sizes. Qt + does not fully implement this behavior so as to maintain cross-platform + compatibility. As a result some widgets sizes may be inappropriate (and + subsequently not rendered correctly by the HITheme APIs).The + QWidget::sizeHint() will return the appropriate size for many + managed widgets (widgets enumerated in \l QStyle::ContentsType). + + \i Effects - QMacStyle uses HITheme for performing most of the drawing, but + also uses emulation in a few cases where HITheme does not provide the + required functionality (for example, tab bars on Panther, the toolbar + separator, etc). We tried to make the emulation as close to the original as + possible. Please report any issues you see in effects or non-standard + widgets. + + \endlist + + There are other issues that need to be considered in the feel of + your application (including the general color scheme to match the + Aqua colors). The Guidelines mentioned above will remain current + with new advances and design suggestions for Mac OS X. + + Note that the functions provided by QMacStyle are + reimplementations of QStyle functions; see QStyle for their + documentation. + + \img qmacstyle.png + \sa QWindowsXPStyle, QWindowsStyle, QPlastiqueStyle, QCDEStyle, QMotifStyle +*/ + + +/*! + \enum QMacStyle::WidgetSizePolicy + + \value SizeSmall + \value SizeLarge + \value SizeMini + \value SizeDefault + \omitvalue SizeNone +*/ + +/*! \fn QMacStyle::QMacStyle() + Constructs a QMacStyle object. +*/ + +/*! \fn QMacStyle::~QMacStyle() + Destructs a QMacStyle object. +*/ + +/*! \fn void QMacStyle::polish(QPalette &pal) + \reimp +*/ + +/*! \fn void QMacStyle::polish(QApplication *) + \reimp +*/ + +/*! \fn void QMacStyle::unpolish(QApplication *) + \reimp +*/ + +/*! \fn void QMacStyle::polish(QWidget* w) + \reimp +*/ + +/*! \fn void QMacStyle::unpolish(QWidget* w) + \reimp +*/ + +/*! \fn int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QWidget *widget) const + \reimp +*/ + +/*! \fn QPalette QMacStyle::standardPalette() const + \reimp +*/ + +/*! \fn int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w, QStyleHintReturn *hret) const + \reimp +*/ + +/*! \fn QPixmap QMacStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const + \reimp +*/ + +/*! \fn QPixmap QMacStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget) const + \reimp +*/ + +/*! + \enum QMacStyle::FocusRectPolicy + + This type is used to signify a widget's focus rectangle policy. + + \value FocusEnabled show a focus rectangle when the widget has focus. + \value FocusDisabled never show a focus rectangle for the widget. + \value FocusDefault show a focus rectangle when the widget has + focus and the widget is a QSpinWidget, QDateTimeEdit, QLineEdit, + QListBox, QListView, editable QTextEdit, or one of their + subclasses. +*/ + +/*! \fn void QMacStyle::setFocusRectPolicy(QWidget *w, FocusRectPolicy policy) + \obsolete + Sets the focus rectangle policy of \a w. The \a policy can be one of + \l{QMacStyle::FocusRectPolicy}. + + This is now simply an interface to the Qt::WA_MacShowFocusRect attribute and the + FocusDefault value does nothing anymore. If you want to set a widget back + to its default value, you must save the old value of the attribute before + you change it. + + \sa focusRectPolicy() QWidget::setAttribute() +*/ + +/*! \fn QMacStyle::FocusRectPolicy QMacStyle::focusRectPolicy(const QWidget *w) + \obsolete + Returns the focus rectangle policy for the widget \a w. + + The focus rectangle policy can be one of \l{QMacStyle::FocusRectPolicy}. + + In 4.3 and up this function will simply test for the + Qt::WA_MacShowFocusRect attribute and will never return + QMacStyle::FocusDefault. + + \sa setFocusRectPolicy(), QWidget::testAttribute() +*/ + +/*! \fn void QMacStyle::setWidgetSizePolicy(const QWidget *widget, WidgetSizePolicy policy) + + \obsolete + + Call QWidget::setAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize, + or Qt::WA_MacNormalSize instead. +*/ + +/*! \fn QMacStyle::WidgetSizePolicy QMacStyle::widgetSizePolicy(const QWidget *widget) + \obsolete + + Call QWidget::testAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize, + or Qt::WA_MacNormalSize instead. +*/ + +/*! \fn void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const + + \reimp +*/ + +/*! \fn void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p, const QWidget *w) const + + \reimp +*/ + +/*! \fn QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *widget) const + + \reimp +*/ + +/*! \fn void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const + \reimp +*/ + +/*! \fn QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *widget) const + \reimp +*/ + +/*! \fn QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const + \reimp +*/ + +/*! \fn QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &csz, const QWidget *widget) const + \reimp +*/ + +/*! \fn void QMacStyle::drawItemText(QPainter *p, const QRect &r, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole) const + \reimp +*/ + +/*! \fn bool QMacStyle::event(QEvent *e) + \reimp +*/ + +/*! \fn QIcon QMacStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt, const QWidget *widget) const + \internal +*/ + +/*! \fn int QMacStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option, const QWidget *widget) const + + \internal +*/ + diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 7a870fe..2e47526 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -39,6 +39,11 @@ ** ****************************************************************************/ +/*! + Note: The qdoc comments for QMacStyle are contained in + .../doc/src/qstyles.qdoc. +*/ + #include "qmacstyle_mac.h" #if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC) @@ -1988,87 +1993,12 @@ void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonD p->drawPixmap(int(macRect.origin.x), int(macRect.origin.y) + finalyoff, width, height, pm); } -/*! - \class QMacStyle - \brief The QMacStyle class provides a Mac OS X style using the Apple Appearance Manager. - - \ingroup appearance - - This class is implemented as a wrapper to the HITheme - APIs, allowing applications to be styled according to the current - theme in use on Mac OS X. This is done by having primitives - in QStyle implemented in terms of what Mac OS X would normally theme. - - \warning This style is only available on Mac OS X because it relies on the - HITheme APIs. - - There are additional issues that should be taken - into consideration to make an application compatible with the - \link http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html - Apple Human Interface Guidelines \endlink. Some of these issues are outlined - below. - - \list - - \i Layout - The restrictions on window layout are such that some - aspects of layout that are style-dependent cannot be achieved - using QLayout. Changes are being considered (and feedback would be - appreciated) to make layouts QStyle-able. Some of the restrictions - involve horizontal and vertical widget alignment and widget size - (covered below). - - \i Widget size - Mac OS X allows widgets to have specific fixed sizes. Qt - does not fully implement this behavior so as to maintain cross-platform - compatibility. As a result some widgets sizes may be inappropriate (and - subsequently not rendered correctly by the HITheme APIs).The - QWidget::sizeHint() will return the appropriate size for many - managed widgets (widgets enumerated in \l QStyle::ContentsType). - - \i Effects - QMacStyle uses HITheme for performing most of the drawing, but - also uses emulation in a few cases where HITheme does not provide the - required functionality (for example, tab bars on Panther, the toolbar - separator, etc). We tried to make the emulation as close to the original as - possible. Please report any issues you see in effects or non-standard - widgets. - - \endlist - - There are other issues that need to be considered in the feel of - your application (including the general color scheme to match the - Aqua colors). The Guidelines mentioned above will remain current - with new advances and design suggestions for Mac OS X. - - Note that the functions provided by QMacStyle are - reimplementations of QStyle functions; see QStyle for their - documentation. - - \img qmacstyle.png - \sa QWindowsXPStyle, QWindowsStyle, QPlastiqueStyle, QCDEStyle, QMotifStyle -*/ - - -/*! - \enum QMacStyle::WidgetSizePolicy - - \value SizeSmall - \value SizeLarge - \value SizeMini - \value SizeDefault - \omitvalue SizeNone -*/ - -/*! - Constructs a QMacStyle object. -*/ QMacStyle::QMacStyle() : QWindowsStyle() { d = new QMacStylePrivate(this); } -/*! - Destructs a QMacStyle object. -*/ QMacStyle::~QMacStyle() { delete qt_mac_backgroundPattern; @@ -2142,7 +2072,6 @@ void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QPoint } } -/*! \reimp */ void QMacStyle::polish(QPalette &pal) { if (!qt_mac_backgroundPattern) { @@ -2166,17 +2095,14 @@ void QMacStyle::polish(QPalette &pal) } } -/*! \reimp */ void QMacStyle::polish(QApplication *) { } -/*! \reimp */ void QMacStyle::unpolish(QApplication *) { } -/*! \reimp */ void QMacStyle::polish(QWidget* w) { d->addWidget(w); @@ -2240,7 +2166,6 @@ void QMacStyle::polish(QWidget* w) } } -/*! \reimp */ void QMacStyle::unpolish(QWidget* w) { d->removeWidget(w); @@ -2271,7 +2196,6 @@ void QMacStyle::unpolish(QWidget* w) QWindowsStyle::unpolish(w); } -/*! \reimp */ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QWidget *widget) const { int controlSize = getControlSize(opt, widget); @@ -2650,7 +2574,6 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW return ret; } -/*! \reimp */ QPalette QMacStyle::standardPalette() const { QPalette pal = QWindowsStyle::standardPalette(); @@ -2660,7 +2583,6 @@ QPalette QMacStyle::standardPalette() const return pal; } -/*! \reimp */ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w, QStyleHintReturn *hret) const { @@ -2955,7 +2877,6 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w return ret; } -/*! \reimp */ QPixmap QMacStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const { @@ -2981,7 +2902,6 @@ QPixmap QMacStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixm } -/*! \reimp */ QPixmap QMacStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget) const { @@ -3012,31 +2932,7 @@ QPixmap QMacStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOpt } return icon.pixmap(size, size); } -/*! - \enum QMacStyle::FocusRectPolicy - - This type is used to signify a widget's focus rectangle policy. - - \value FocusEnabled show a focus rectangle when the widget has focus. - \value FocusDisabled never show a focus rectangle for the widget. - \value FocusDefault show a focus rectangle when the widget has - focus and the widget is a QSpinWidget, QDateTimeEdit, QLineEdit, - QListBox, QListView, editable QTextEdit, or one of their - subclasses. -*/ - -/*! - \obsolete - Sets the focus rectangle policy of \a w. The \a policy can be one of - \l{QMacStyle::FocusRectPolicy}. - - This is now simply an interface to the Qt::WA_MacShowFocusRect attribute and the - FocusDefault value does nothing anymore. If you want to set a widget back - to its default value, you must save the old value of the attribute before - you change it. - \sa focusRectPolicy() QWidget::setAttribute() -*/ void QMacStyle::setFocusRectPolicy(QWidget *w, FocusRectPolicy policy) { switch (policy) { @@ -3049,29 +2945,11 @@ void QMacStyle::setFocusRectPolicy(QWidget *w, FocusRectPolicy policy) } } -/*! - \obsolete - Returns the focus rectangle policy for the widget \a w. - - The focus rectangle policy can be one of \l{QMacStyle::FocusRectPolicy}. - - In 4.3 and up this function will simply test for the - Qt::WA_MacShowFocusRect attribute and will never return - QMacStyle::FocusDefault. - - \sa setFocusRectPolicy(), QWidget::testAttribute() -*/ QMacStyle::FocusRectPolicy QMacStyle::focusRectPolicy(const QWidget *w) { return w->testAttribute(Qt::WA_MacShowFocusRect) ? FocusEnabled : FocusDisabled; } -/*! - \obsolete - - Call QWidget::setAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize, - or Qt::WA_MacNormalSize instead. -*/ void QMacStyle::setWidgetSizePolicy(const QWidget *widget, WidgetSizePolicy policy) { QWidget *wadget = const_cast(widget); @@ -3080,12 +2958,6 @@ void QMacStyle::setWidgetSizePolicy(const QWidget *widget, WidgetSizePolicy poli wadget->setAttribute(Qt::WA_MacMiniSize, policy == SizeMini); } -/*! - \obsolete - - Call QWidget::testAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize, - or Qt::WA_MacNormalSize instead. -*/ QMacStyle::WidgetSizePolicy QMacStyle::widgetSizePolicy(const QWidget *widget) { while (widget) { @@ -3101,7 +2973,6 @@ QMacStyle::WidgetSizePolicy QMacStyle::widgetSizePolicy(const QWidget *widget) return SizeDefault; } -/*! \reimp */ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const { @@ -3534,7 +3405,6 @@ static inline QPixmap darkenPixmap(const QPixmap &pixmap) -/*! \reimp */ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p, const QWidget *w) const { @@ -4558,7 +4428,7 @@ static void setLayoutItemMargins(int left, int top, int right, int bottom, QRect rect->adjust(left, top, right, bottom); } } -/*! \reimp */ + QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *widget) const { @@ -4852,7 +4722,6 @@ static inline void drawToolbarButtonArrow(const QRect &toolButtonRect, ThemeDraw HIThemeDrawPopupArrow(&hirect, &padi, cg, kHIThemeOrientationNormal); } -/*! \reimp */ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const { @@ -5349,7 +5218,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex } } -/*! \reimp */ QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *widget) const @@ -5480,7 +5348,6 @@ QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc, return sc; } -/*! \reimp */ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const { @@ -5820,7 +5687,6 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op return ret; } -/*! \reimp */ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &csz, const QWidget *widget) const { @@ -6107,9 +5973,6 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, return sz; } -/*! - \reimp -*/ void QMacStyle::drawItemText(QPainter *p, const QRect &r, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole) const { @@ -6118,9 +5981,6 @@ void QMacStyle::drawItemText(QPainter *p, const QRect &r, int flags, const QPale QWindowsStyle::drawItemText(p, r, flags, pal, enabled, text, textRole); } -/*! - \reimp -*/ bool QMacStyle::event(QEvent *e) { if(e->type() == QEvent::FocusIn) { @@ -6195,9 +6055,6 @@ void qt_mac_constructQIconFromIconRef(const IconRef icon, const IconRef overlayI } } -/*! - \internal -*/ QIcon QMacStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt, const QWidget *widget) const { @@ -6311,9 +6168,6 @@ QIcon QMacStyle::standardIconImplementation(StandardPixmap standardIcon, const Q return QWindowsStyle::standardIconImplementation(standardIcon, opt, widget); } -/*! - \internal -*/ int QMacStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, -- cgit v0.12 From a9722dffb48559c27f2f4cd99ebc082f717a9e60 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 20 May 2009 11:57:52 +0200 Subject: make QSslSocket test work also for shadow builds ... by being able to load the certificates also in a shadow build directory Reviewed-by: Thiago --- tests/auto/qsslsocket/qsslsocket.pro | 6 ++++++ tests/auto/qsslsocket/tst_qsslsocket.cpp | 30 +++++++++++++++--------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/tests/auto/qsslsocket/qsslsocket.pro b/tests/auto/qsslsocket/qsslsocket.pro index 147b40d..c29fc68 100644 --- a/tests/auto/qsslsocket/qsslsocket.pro +++ b/tests/auto/qsslsocket/qsslsocket.pro @@ -7,6 +7,12 @@ QT -= gui TARGET = tst_qsslsocket +!wince* { +DEFINES += SRCDIR=\\\"$$PWD/\\\" +} else { +DEFINES += SRCDIR=\\\"./\\\" +} + win32 { CONFIG(debug, debug|release) { DESTDIR = debug diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index 5c99164..0aa93fe 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -577,7 +577,7 @@ void tst_QSslSocket::connectToHostEncrypted() QSslSocketPtr socket = newSocket(); this->socket = socket; - socket->addCaCertificates(QLatin1String("certs/qt-test-server-cacert.pem")); + QVERIFY(socket->addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"))); #ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND connect(&socket, SIGNAL(sslErrors(QList)), this, SLOT(untrustedWorkaroundSlot(QList))); @@ -648,7 +648,7 @@ void tst_QSslSocket::peerCertificateChain() QSslSocketPtr socket = newSocket(); this->socket = socket; - QList caCertificates = QSslCertificate::fromPath(QLatin1String("certs/qt-test-server-cacert.pem")); + QList caCertificates = QSslCertificate::fromPath(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem")); QVERIFY(caCertificates.count() == 1); socket->addCaCertificates(caCertificates); @@ -709,7 +709,7 @@ void tst_QSslSocket::protocol() QSslSocketPtr socket = newSocket(); this->socket = socket; - QList certs = QSslCertificate::fromPath("certs/qt-test-server-cacert.pem"); + QList certs = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem"); // qDebug() << "certs:" << certs.at(0).issuerInfo(QSslCertificate::CommonName); socket->setCaCertificates(certs); @@ -792,7 +792,7 @@ void tst_QSslSocket::setCaCertificates() QSslSocket socket; QCOMPARE(socket.caCertificates(), QSslSocket::defaultCaCertificates()); - socket.setCaCertificates(QSslCertificate::fromPath("certs/qt-test-server-cacert.pem")); + socket.setCaCertificates(QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem")); QCOMPARE(socket.caCertificates().size(), 1); socket.setCaCertificates(socket.defaultCaCertificates()); QCOMPARE(socket.caCertificates(), QSslSocket::defaultCaCertificates()); @@ -823,13 +823,13 @@ protected: socket = new QSslSocket(this); connect(socket, SIGNAL(sslErrors(const QList &)), this, SLOT(ignoreErrorSlot())); - QFile file("certs/fluke.key"); + QFile file(SRCDIR "certs/fluke.key"); QVERIFY(file.open(QIODevice::ReadOnly)); QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey); QVERIFY(!key.isNull()); socket->setPrivateKey(key); - QList localCert = QSslCertificate::fromPath("certs/fluke.cert"); + QList localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert"); QVERIFY(!localCert.isEmpty()); QVERIFY(localCert.first().handle()); socket->setLocalCertificate(localCert.first()); @@ -930,7 +930,7 @@ void tst_QSslSocket::addDefaultCaCertificate() // Reset the global CA chain QSslSocket::setDefaultCaCertificates(QSslSocket::systemCaCertificates()); - QList flukeCerts = QSslCertificate::fromPath("certs/qt-test-server-cacert.pem"); + QList flukeCerts = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem"); QCOMPARE(flukeCerts.size(), 1); QList globalCerts = QSslSocket::defaultCaCertificates(); QVERIFY(!globalCerts.contains(flukeCerts.first())); @@ -1014,7 +1014,7 @@ void tst_QSslSocket::wildcard() // responds with the wildcard, and QSslSocket should accept that as a // valid connection. This was broken in 4.3.0. QSslSocketPtr socket = newSocket(); - socket->addCaCertificates(QLatin1String("certs/qt-test-server-cacert.pem")); + socket->addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem")); this->socket = socket; #ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND connect(socket, SIGNAL(sslErrors(QList)), @@ -1040,7 +1040,7 @@ protected: socket->ignoreSslErrors(); // Only set the certificate - QList localCert = QSslCertificate::fromPath("certs/fluke.cert"); + QList localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert"); QVERIFY(!localCert.isEmpty()); QVERIFY(localCert.first().handle()); socket->setLocalCertificate(localCert.first()); @@ -1199,13 +1199,13 @@ protected: socket = new QSslSocket(this); connect(socket, SIGNAL(sslErrors(const QList &)), this, SLOT(ignoreErrorSlot())); - QFile file("certs/fluke.key"); + QFile file(SRCDIR "certs/fluke.key"); QVERIFY(file.open(QIODevice::ReadOnly)); QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey); QVERIFY(!key.isNull()); socket->setPrivateKey(key); - QList localCert = QSslCertificate::fromPath("certs/fluke.cert"); + QList localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert"); QVERIFY(!localCert.isEmpty()); QVERIFY(localCert.first().handle()); socket->setLocalCertificate(localCert.first()); @@ -1363,8 +1363,8 @@ protected: { socket = new QSslSocket(this); - socket->setPrivateKey("certs/fluke.key"); - socket->setLocalCertificate("certs/fluke.cert"); + socket->setPrivateKey(SRCDIR "certs/fluke.key"); + socket->setLocalCertificate(SRCDIR "certs/fluke.cert"); socket->setSocketDescriptor(socketDescriptor); socket->startServerEncryption(); } @@ -1487,7 +1487,7 @@ void tst_QSslSocket::resetProxy() // make sure the connection works, and then set a nonsense proxy, and then // make sure it does not work anymore QSslSocket socket; - socket.addCaCertificates(QLatin1String("certs/qt-test-server-cacert.pem")); + socket.addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem")); socket.setProxy(goodProxy); socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); QVERIFY2(socket.waitForConnected(10000), qPrintable(socket.errorString())); @@ -1500,7 +1500,7 @@ void tst_QSslSocket::resetProxy() // set the nonsense proxy and make sure the connection does not work, // and then set the right proxy and make sure it works QSslSocket socket2; - socket2.addCaCertificates(QLatin1String("certs/qt-test-server-cacert.pem")); + socket2.addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem")); socket2.setProxy(badProxy); socket2.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); QVERIFY(! socket2.waitForConnected(10000)); -- cgit v0.12 From c02f3b1934a4ab300f593b91ee9fd302207a96f5 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 20 May 2009 12:04:37 +0200 Subject: qdoc: I overwrote the commit template. --- .commit-template | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.commit-template b/.commit-template index 171b67b..589ca89 100644 --- a/.commit-template +++ b/.commit-template @@ -1,8 +1,10 @@ -qdoc: Moved qdoc comments from qmacstyle_mac.mm to qstyles.qdoc +# ===[ Subject ]==========[ one line, please wrap at 72 characters ]===| -The .mm file is not read by qdoc for packages other than for the MAC. -This problem is overcome by moving the qdoc comments from the .mm file -to a .qdoc file in doc/src, because all these files are read by qdoc -for each of the packages. +# ---[ Details ]---------[ remember extra blank line after subject ]---| -#Task-number: 252566 +# ---[ Fields ]-----------------[ uncomment and edit as applicable ]---| + +#Task-number: +#Reviewed-by: + +# ==================================[ please wrap at 72 characters ]===| -- cgit v0.12 From b28e95cd2fbdd0f8ad5030e6fc3beede057548da Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Wed, 20 May 2009 12:16:11 +0200 Subject: Remove bad documentation about window modality and QMessageBox. QMessageBox is like QDialog. It doesn't have any extra magic with window modality on creation, so don't advertise that it does. The note about using message boxes as sheets is also updated. --- src/gui/dialogs/qmessagebox.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp index 5e59501..fb3bcb8 100644 --- a/src/gui/dialogs/qmessagebox.cpp +++ b/src/gui/dialogs/qmessagebox.cpp @@ -706,15 +706,10 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button) Constructs a message box with no text and no buttons. \a parent is passed to the QDialog constructor. - If \a parent is 0, the message box is an \l{Qt::ApplicationModal} - {application modal} dialog box. If \a parent is a widget, the - message box is \l{Qt::WindowModal} {window modal} relative to \a - parent. - - On Mac OS X, if \a parent is not 0 and you want your message box - to appear as a Qt::Sheet of that parent, set the message box's - \l{setWindowModality()} {window modality} to Qt::WindowModal - (default). Otherwise, the message box will be a standard dialog. + On Mac OS X, if you want your message box to appear + as a Qt::Sheet of its \a parent, set the message box's + \l{setWindowModality()} {window modality} to Qt::WindowModal or use open(). + Otherwise, the message box will be a standard dialog. */ QMessageBox::QMessageBox(QWidget *parent) -- cgit v0.12 From b7e01ff7d994d704cbcd876a77bf32cbdf66c17b Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 20 May 2009 12:45:11 +0200 Subject: Revert focus apparance on itemviews for X11 We changed this primarily for the mac as active appearance on widgets in itemviews should depend on the window activation state and not on the focus widget. It was explicitly added back for windows only but has been reported as a bug on X11 as well so we might as well keep it mac-only for now. Reviewed-by: mortens --- src/gui/itemviews/qabstractitemview.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 7a3d674..c77395a 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -3220,9 +3220,9 @@ QStyleOptionViewItem QAbstractItemView::viewOptions() const option.state &= ~QStyle::State_MouseOver; option.font = font(); -#ifdef Q_WS_WIN - // Note this is currently required on Windows - // do give non-focused item views inactive appearance +#ifndef Q_WS_MAC + // On mac the focus appearance follows window activation + // not widget activation if (!hasFocus()) option.state &= ~QStyle::State_Active; #endif -- cgit v0.12 From 25f86fbab2e7d23832b0bb8ae8530289258e2aa5 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Wed, 20 May 2009 12:59:41 +0200 Subject: Silence warning by MSVC. Reviewed-By: TrustMe --- src/xmlpatterns/expr/qpath.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xmlpatterns/expr/qpath.cpp b/src/xmlpatterns/expr/qpath.cpp index 33bfa0f..a60f622 100644 --- a/src/xmlpatterns/expr/qpath.cpp +++ b/src/xmlpatterns/expr/qpath.cpp @@ -170,7 +170,7 @@ Expression::Ptr Path::compress(const StaticContext::Ptr &context) /* We do this as late as we can, such that we pick up the most recent type * from the operand. */ - if(m_isLast && !m_kind == XSLTForEach && m_operand2->staticType()->itemType() == BuiltinTypes::item) + if(m_isLast && m_kind != XSLTForEach && m_operand2->staticType()->itemType() == BuiltinTypes::item) m_checkXPTY0018 = true; return me; -- cgit v0.12 From fdefbb820f1ebf9fbde0f683ea6d05923e8c04e4 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 20 May 2009 13:25:27 +0200 Subject: QComboBox: style change event should not resets custom item delegates Regression from 4.4 introduced while fixing task 167106 Autotest: tst_QComboBox::task253944_itemDelegateIsReset() Task-number: 253944 Reviewed-by: jbache --- src/gui/widgets/qcombobox.cpp | 22 ++++++++++++++++------ src/gui/widgets/qcombobox_p.h | 6 +++--- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 09a51fe..a5a98d4 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -947,7 +947,7 @@ QComboBoxPrivateContainer* QComboBoxPrivate::viewContainer() container = new QComboBoxPrivateContainer(new QComboBoxListView(q), q); container->itemView()->setModel(model); container->itemView()->setTextElideMode(Qt::ElideMiddle); - updateDelegate(); + updateDelegate(true); updateLayoutDirection(); QObject::connect(container, SIGNAL(itemSelected(QModelIndex)), q, SLOT(_q_itemSelected(QModelIndex))); @@ -1567,15 +1567,25 @@ bool QComboBox::isEditable() const return d->lineEdit != 0; } -void QComboBoxPrivate::updateDelegate() +/*! \internal + update the default delegate + depending on the style's SH_ComboBox_Popup hint, we use a different default delegate. + + but we do not change the delegate is the combobox use a custom delegate, + unless \a force is set to true. + */ +void QComboBoxPrivate::updateDelegate(bool force) { Q_Q(QComboBox); QStyleOptionComboBox opt; q->initStyleOption(&opt); - if (q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q)) - q->setItemDelegate(new QComboMenuDelegate(q->view(), q)); - else - q->setItemDelegate(new QComboBoxDelegate(q->view(), q)); + if (q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q)) { + if (force || qobject_cast(q->itemDelegate())) + q->setItemDelegate(new QComboMenuDelegate(q->view(), q)); + } else { + if (force || qobject_cast(q->itemDelegate())) + q->setItemDelegate(new QComboBoxDelegate(q->view(), q)); + } } QIcon QComboBoxPrivate::itemIcon(const QModelIndex &index) const diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h index c39a231..a55b439 100644 --- a/src/gui/widgets/qcombobox_p.h +++ b/src/gui/widgets/qcombobox_p.h @@ -256,7 +256,7 @@ private: }; class QComboMenuDelegate : public QAbstractItemDelegate -{ +{ Q_OBJECT public: QComboMenuDelegate(QObject *parent, QComboBox *cmb) : QAbstractItemDelegate(parent), mCombo(cmb) {} @@ -285,7 +285,7 @@ private: // Vista does not use the new theme for combo boxes and there might // be other side effects from using the new class class QComboBoxDelegate : public QItemDelegate -{ +{ Q_OBJECT public: QComboBoxDelegate(QObject *parent, QComboBox *cmb) : QItemDelegate(parent), mCombo(cmb) {} @@ -367,7 +367,7 @@ public: int itemRole() const; void updateLayoutDirection(); void setCurrentIndex(const QModelIndex &index); - void updateDelegate(); + void updateDelegate(bool force = false); void keyboardSearchString(const QString &text); void modelChanged(); -- cgit v0.12 From 27df3cb8c0e547d9174fd0571b16ed554eb2432d Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 20 May 2009 14:25:38 +0200 Subject: qdoc: Moved a qdoc comment to a file that is in all packages. Task-number: 252565 --- src/gui/dialogs/qpagesetupdialog.cpp | 6 ++++++ src/gui/dialogs/qpagesetupdialog_mac.mm | 3 --- src/gui/styles/qmacstyle_mac.mm | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gui/dialogs/qpagesetupdialog.cpp b/src/gui/dialogs/qpagesetupdialog.cpp index 63775d2..682071a 100644 --- a/src/gui/dialogs/qpagesetupdialog.cpp +++ b/src/gui/dialogs/qpagesetupdialog.cpp @@ -180,6 +180,12 @@ void QPageSetupDialog::open(QObject *receiver, const char *member) QDialog::open(); } +#if defined(Q_WS_MAC) || defined(Q_OS_WIN) +/*! \fn void QPageSetupDialog::setVisible(bool visible) + \reimp +*/ +#endif + QT_END_NAMESPACE #endif diff --git a/src/gui/dialogs/qpagesetupdialog_mac.mm b/src/gui/dialogs/qpagesetupdialog_mac.mm index 401d95f..24aef34 100644 --- a/src/gui/dialogs/qpagesetupdialog_mac.mm +++ b/src/gui/dialogs/qpagesetupdialog_mac.mm @@ -251,9 +251,6 @@ QPageSetupDialog::QPageSetupDialog(QWidget *parent) d->ep = static_cast(d->printer->paintEngine())->d_func(); } -/*! - \reimp -*/ void QPageSetupDialog::setVisible(bool visible) { Q_D(QPageSetupDialog); diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 2e47526..e4829dc 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -39,7 +39,7 @@ ** ****************************************************************************/ -/*! +/* Note: The qdoc comments for QMacStyle are contained in .../doc/src/qstyles.qdoc. */ -- cgit v0.12 From 6e03459f72b090695767f263e1d51e5182f5f317 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Wed, 20 May 2009 14:52:23 +0200 Subject: Don't draw an arrow for toolbuttons that are text only and have a menu. I made this change to make things look a bit better on the mac. However, a toolbutton with text only looks strange and as a bonus the arrow covers some of the text, which no one wants. It seems that similar consructions in Cocoa don't show the arrow for text button, so we shouldn't either. Task-number: 253339 Reviewed-by: Jens Bache-Wiig --- src/gui/styles/qmacstyle_mac.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index e4829dc..1be3d6e 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -5104,7 +5104,8 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex arrowOpt.state = tb->state; arrowOpt.palette = tb->palette; drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget); - } else if (tb->features & QStyleOptionToolButton::HasMenu) { + } else if ((tb->features & QStyleOptionToolButton::HasMenu) + && (tb->toolButtonStyle != Qt::ToolButtonTextOnly && !tb->icon.isNull())) { drawToolbarButtonArrow(tb->rect, tds, cg); } if (tb->state & State_On) { -- cgit v0.12