summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFabien Freling <fabien.freling@nokia.com>2010-11-25 16:21:12 (GMT)
committerFabien Freling <fabien.freling@nokia.com>2010-11-25 16:24:40 (GMT)
commit2ab77ea436c1ad1a35b0c8e2183aa78edbbe4765 (patch)
tree7928a5256adf12e8b65ed5e89f846fa7afe3e9ca /src
parent6f5ed5836bd96b69d47aa3260118b3b49dddc82f (diff)
downloadQt-2ab77ea436c1ad1a35b0c8e2183aa78edbbe4765.zip
Qt-2ab77ea436c1ad1a35b0c8e2183aa78edbbe4765.tar.gz
Qt-2ab77ea436c1ad1a35b0c8e2183aa78edbbe4765.tar.bz2
Fix some memory leaks.
Update the retain/release mechanism for CGContexts. Some leaks were due to unnecessary retain calls. Task-number: QTBUG-15373 Reviewed-by: Samuel Rødal
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm2
-rw-r--r--src/gui/painting/qpaintengine_mac.cpp3
-rw-r--r--src/gui/painting/qunifiedtoolbarsurface_mac.cpp2
-rw-r--r--src/gui/painting/qwindowsurface_mac.cpp2
-rw-r--r--src/gui/painting/qwindowsurface_raster.cpp3
5 files changed, 11 insertions, 1 deletions
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index d5363bd..e02cf11 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -554,6 +554,7 @@ static int qCocoaViewCount = 0;
}
CGContextRef cg = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
+ CGContextRetain(cg);
qwidgetprivate->hd = cg;
// We steal the CGContext for flushing in the unified toolbar with the raster engine.
@@ -653,6 +654,7 @@ static int qCocoaViewCount = 0;
}
qwidgetprivate->hd = 0;
CGContextRestoreGState(cg);
+ CGContextRelease(cg);
}
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
diff --git a/src/gui/painting/qpaintengine_mac.cpp b/src/gui/painting/qpaintengine_mac.cpp
index e5323d8..601cf86 100644
--- a/src/gui/painting/qpaintengine_mac.cpp
+++ b/src/gui/painting/qpaintengine_mac.cpp
@@ -131,8 +131,9 @@ QMacCGContext::QMacCGContext(QPainter *p)
CGContextTranslateCTM(context, native.dx(), native.dy());
}
+ } else {
+ CGContextRetain(context);
}
- CGContextRetain(context);
}
diff --git a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp
index b25757b..ace0a46 100644
--- a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp
+++ b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp
@@ -188,6 +188,8 @@ void QUnifiedToolbarSurface::flush(QWidget *widget, const QRegion &rgn, const QP
// Restore context.
CGContextRestoreGState(context);
+ CGContextRelease(context);
+ widget->d_func()->cgContext = 0;
widget->d_func()->hasOwnContext = false;
}
diff --git a/src/gui/painting/qwindowsurface_mac.cpp b/src/gui/painting/qwindowsurface_mac.cpp
index 1c97ebb..9f24532 100644
--- a/src/gui/painting/qwindowsurface_mac.cpp
+++ b/src/gui/painting/qwindowsurface_mac.cpp
@@ -82,6 +82,7 @@ void QMacWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint
extern CGContextRef qt_mac_graphicsContextFor(QWidget *);
CGContextRef context = qt_mac_graphicsContextFor(widget);
#endif
+ CGContextRetain(context);
CGContextSaveGState(context);
// Flip context.
@@ -109,6 +110,7 @@ void QMacWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint
#else
CGContextFlush(context);
#endif
+ CGContextRelease(context);
}
void QMacWindowSurface::setGeometry(const QRect &rect)
diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp
index ae73d7d..2b4e125 100644
--- a/src/gui/painting/qwindowsurface_raster.cpp
+++ b/src/gui/painting/qwindowsurface_raster.cpp
@@ -285,6 +285,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi
extern CGContextRef qt_mac_graphicsContextFor(QWidget *);
CGContextRef context = qt_mac_graphicsContextFor(widget);
#endif
+ CGContextRetain(context);
CGContextSaveGState(context);
// Flip context.
@@ -317,6 +318,8 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi
// Restore context.
CGContextRestoreGState(context);
+ CGContextRelease(context);
+
#endif // Q_WS_MAC