Cocoa: add qWarnining when trying to create 0 width/height CGImages
Add meaningful warnings when trying to create 0 width/height CGImages. This way it is easier to track down the place where valid size is not used. Change-Id: Id261ddf72d5487afcdb1a2a6d0d9079700888545 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
parent
1bd710cbc7
commit
179437bdba
@ -79,6 +79,12 @@ static void drawImageReleaseData (void *info, const void *, size_t)
|
||||
|
||||
CGImageRef qt_mac_image_to_cgimage(const QImage &img)
|
||||
{
|
||||
if (img.width() <= 0 || img.height() <= 0) {
|
||||
qWarning() << Q_FUNC_INFO <<
|
||||
"trying to set" << img.width() << "x" << img.height() << "size for CGImage";
|
||||
return 0;
|
||||
}
|
||||
|
||||
QImage *image;
|
||||
if (img.depth() != 32)
|
||||
image = new QImage(img.convertToFormat(QImage::Format_ARGB32_Premultiplied));
|
||||
|
@ -192,12 +192,20 @@ static QTouchDevice *touchDevice = 0;
|
||||
{
|
||||
CGImageRelease(m_cgImage);
|
||||
|
||||
int width = image->width();
|
||||
int height = image->height();
|
||||
|
||||
if (width <= 0 || height <= 0) {
|
||||
qWarning() << Q_FUNC_INFO <<
|
||||
"setting invalid size" << width << "x" << height << "for qnsview image";
|
||||
m_cgImage = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
const uchar *imageData = image->bits();
|
||||
int bitDepth = image->depth();
|
||||
int colorBufferSize = 8;
|
||||
int bytesPrLine = image->bytesPerLine();
|
||||
int width = image->width();
|
||||
int height = image->height();
|
||||
|
||||
CGColorSpaceRef cgColourSpaceRef = CGColorSpaceCreateDeviceRGB();
|
||||
|
||||
|
@ -1022,7 +1022,8 @@ void QCoreGraphicsPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, co
|
||||
image = qt_mac_create_imagemask(pm, sr);
|
||||
} else if (differentSize) {
|
||||
QCFType<CGImageRef> img = qt_mac_image_to_cgimage(pm.toImage());
|
||||
image = CGImageCreateWithImageInRect(img, CGRectMake(qRound(sr.x()), qRound(sr.y()), qRound(sr.width()), qRound(sr.height())));
|
||||
if (img)
|
||||
image = CGImageCreateWithImageInRect(img, CGRectMake(qRound(sr.x()), qRound(sr.y()), qRound(sr.width()), qRound(sr.height())));
|
||||
} else {
|
||||
image = qt_mac_image_to_cgimage(pm.toImage());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user