Skip to content

Instantly share code, notes, and snippets.

@robertknight
Created June 12, 2012 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertknight/2918736 to your computer and use it in GitHub Desktop.
Save robertknight/2918736 to your computer and use it in GitHub Desktop.
Fix for QTBUG-23205
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 030e31b..0df81a4 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -5490,7 +5490,12 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
Q_Q(QWidget);
#ifndef QT_NO_GRAPHICSEFFECT
- if (graphicsEffect && graphicsEffect->isEnabled()) {
+ bool useGraphicsEffect = graphicsEffect && graphicsEffect->isEnabled();
+#ifdef QT_MAC_USE_COCOA
+ // Graphics effects do not currently work on non-alien Cocoa widgets
+ useGraphicsEffect = useGraphicsEffect && !q->internalWinId();
+#endif
+ if (useGraphicsEffect) {
QGraphicsEffectSource *source = graphicsEffect->d_func()->source;
QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
(source->d_func());
@@ -5500,10 +5505,28 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
if (!sharedPainter) {
QPaintEngine *paintEngine = pdev->paintEngine();
paintEngine->d_func()->systemClip = rgn.translated(offset);
- QPainter p(pdev);
- p.translate(offset);
- context.painter = &p;
- graphicsEffect->draw(&p);
+
+#ifdef Q_WS_MAC
+ // see comments about redirection on Mac below.
+ QWidget* pdevWidget = pdev->devType() == QInternal::Widget ? static_cast<QWidget*>(pdev) : 0;
+ if (pdevWidget) {
+ pdevWidget->setAttribute(Qt::WA_WState_InPaintEvent);
+ }
+#endif
+
+ {
+ QPainter p(pdev);
+ p.translate(offset);
+ context.painter = &p;
+ graphicsEffect->draw(&p);
+ }
+
+#ifdef Q_WS_MAC
+ if (pdevWidget) {
+ pdevWidget->setAttribute(Qt::WA_WState_InPaintEvent, false);
+ }
+#endif
+
paintEngine->d_func()->systemClip = QRegion();
} else {
context.painter = sharedPainter;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment