prevent crash is something goes wrong processing a PDF in OSX

This commit is contained in:
Luis Ángel San Martín 2016-04-26 16:17:54 +02:00
parent 7fe2ad526b
commit 71ba1de373

View File

@ -97,6 +97,15 @@ QImage MacOSXPDFComic::getPage(const int pageNum)
lastPageData = (void *)dataRef;
if(!lastPageData)
{
QLOG_ERROR() << "Unable to extract image from PDF file using CGPDFDocument";
CGImageRelease(image);
CGContextRelease(bitmapContext);
CGColorSpaceRelease(genericColorSpace);
return QImage();
}
const uchar *bytes = (const uchar *)CFDataGetBytePtr(dataRef);
qtImage = QImage(bytes, pageRect.size.width, pageRect.size.height, QImage::Format_ARGB32);