summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm8
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm2
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();