Cocoa: Properly clean window mask data

Also, get rid of qt_mac_toCGImage and QPainter warnings.

Change-Id: I9e2a0e93d74c318d99651de9222994615e082ac9
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
Gabriel de Dietrich 2013-03-26 18:18:04 +01:00 committed by The Qt Project
parent f65bfe11e1
commit 6db10834b0
2 changed files with 6 additions and 4 deletions

View File

@ -764,6 +764,9 @@ CGContextRef qt_mac_cg_context(QPaintDevice *pdev)
return ret;
}
// qpaintengine_mac.mm
extern void qt_mac_cgimage_data_free(void *, const void *memoryToFree, size_t);
CGImageRef qt_mac_toCGImage(const QImage &qImage, bool isMask, uchar **dataCopy)
{
int width = qImage.width();
@ -777,8 +780,7 @@ CGImageRef qt_mac_toCGImage(const QImage &qImage, bool isMask, uchar **dataCopy)
const uchar *imageData = qImage.bits();
if (dataCopy) {
delete[] *dataCopy;
*dataCopy = new uchar[qImage.byteCount()];
*dataCopy = static_cast<uchar *>(malloc(qImage.byteCount()));
memcpy(*dataCopy, imageData, qImage.byteCount());
}
int bitDepth = qImage.depth();
@ -789,7 +791,7 @@ CGImageRef qt_mac_toCGImage(const QImage &qImage, bool isMask, uchar **dataCopy)
NULL,
dataCopy ? *dataCopy : imageData,
qImage.byteCount(),
NULL);
dataCopy ? qt_mac_cgimage_data_free : NULL);
CGImageRef cgImage = 0;
if (isMask) {

View File

@ -102,7 +102,6 @@ static QTouchDevice *touchDevice = 0;
{
CGImageRelease(m_maskImage);
m_maskImage = 0;
delete[] m_maskData;
m_maskData = 0;
m_window = 0;
if (m_subscribesForGlobalFrameNotifications) {
@ -322,6 +321,7 @@ static QTouchDevice *touchDevice = 0;
CGImageRelease(m_maskImage);
if (region->isEmpty()) {
m_maskImage = 0;
return;
}
const QRect &rect = region->boundingRect();