Mac: Safely dispose of scrollbars temporary NSGraphicsContext
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>
Wed, 3 Oct 2012 11:50:02 +0000 (13:50 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 4 Oct 2012 10:14:15 +0000 (12:14 +0200)
When rendering transient scrollbars, we instanciate a specialised
NSGraphicsContext since those need non-opaque rendering. This context
is being used as current context, but it was never properly released
and the previous context never properly restored.

Task-number: QTBUG-27327
Change-Id: I4e867e64a09368dbe64b84b17f07fd8e57bbae24
Reviewed-by: Teemu Katajisto <teemu.katajisto@digia.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
src/widgets/styles/qmacstyle_mac.mm

index 65a39ba..585e510 100644 (file)
@@ -5152,6 +5152,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
                 }
 
                 CGContextSaveGState(cg);
+                [NSGraphicsContext saveGraphicsState];
 
                 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
                      graphicsContextWithGraphicsPort:(CGContextRef)cg flipped:NO]];
@@ -5230,6 +5231,8 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
                 }
 
                 CGContextEndTransparencyLayer(cg);
+
+                [NSGraphicsContext restoreGraphicsState];
                 CGContextRestoreGState(cg);
             } else
 #endif