diff options
author | Gabriel de Dietrich <gabriel.dedietrich@digia.com> | 2013-03-26 18:18:04 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-08 17:23:15 +0200 |
commit | 6db10834b03861943ccfde93105e2a603414e8b8 (patch) | |
tree | c016c92be634cd3624d4fdaef2aa3057448ad6dd /src | |
parent | f65bfe11e1e6bb3b2a13ce050c184b97a87f3237 (diff) |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoahelpers.mm | 8 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.mm | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 5ec2cea362..795ae53605 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -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) { diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 3046b898df..568cc4bebf 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -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(); |