Guard functions with wxCHECK macros rather than wxASSERT
If bitmap context was not created successfully the function execution should be terminated.
This commit is contained in:
parent
2bba863937
commit
3c0dbc17de
@ -246,10 +246,10 @@ bool wxBitmapRefData::Create(CGImageRef image, double scale)
|
|||||||
{
|
{
|
||||||
m_hBitmap = CGBitmapContextCreate(NULL, m_width, m_height, 8, m_bytesPerRow, wxMacGetGenericRGBColorSpace(), kCGImageAlphaPremultipliedFirst);
|
m_hBitmap = CGBitmapContextCreate(NULL, m_width, m_height, 8, m_bytesPerRow, wxMacGetGenericRGBColorSpace(), kCGImageAlphaPremultipliedFirst);
|
||||||
}
|
}
|
||||||
|
wxCHECK_MSG(m_hBitmap, false, wxT("Unable to create CGBitmapContext context"));
|
||||||
CGRect rect = CGRectMake(0, 0, m_width, m_height);
|
CGRect rect = CGRectMake(0, 0, m_width, m_height);
|
||||||
CGContextDrawImage(m_hBitmap, rect, image);
|
CGContextDrawImage(m_hBitmap, rect, image);
|
||||||
|
|
||||||
wxASSERT_MSG(m_hBitmap, wxT("Unable to create CGBitmapContext context"));
|
|
||||||
CGContextTranslateCTM(m_hBitmap, 0, m_height);
|
CGContextTranslateCTM(m_hBitmap, 0, m_height);
|
||||||
CGContextScaleCTM(m_hBitmap, 1 * m_scaleFactor, -1 * m_scaleFactor);
|
CGContextScaleCTM(m_hBitmap, 1 * m_scaleFactor, -1 * m_scaleFactor);
|
||||||
}
|
}
|
||||||
@ -283,7 +283,7 @@ bool wxBitmapRefData::Create(int w, int h, int WXUNUSED(d), double logicalscale)
|
|||||||
|
|
||||||
size_t m_bytesPerRow = GetBestBytesPerRow(m_width * 4);
|
size_t m_bytesPerRow = GetBestBytesPerRow(m_width * 4);
|
||||||
m_hBitmap = CGBitmapContextCreate(NULL, m_width, m_height, 8, m_bytesPerRow, wxMacGetGenericRGBColorSpace(), kCGImageAlphaNoneSkipFirst);
|
m_hBitmap = CGBitmapContextCreate(NULL, m_width, m_height, 8, m_bytesPerRow, wxMacGetGenericRGBColorSpace(), kCGImageAlphaNoneSkipFirst);
|
||||||
wxASSERT_MSG(m_hBitmap, wxT("Unable to create CGBitmapContext context"));
|
wxCHECK_MSG(m_hBitmap, false, wxT("Unable to create CGBitmapContext context"));
|
||||||
CGContextTranslateCTM(m_hBitmap, 0, m_height);
|
CGContextTranslateCTM(m_hBitmap, 0, m_height);
|
||||||
CGContextScaleCTM(m_hBitmap, 1 * GetScaleFactor(), -1 * GetScaleFactor());
|
CGContextScaleCTM(m_hBitmap, 1 * GetScaleFactor(), -1 * GetScaleFactor());
|
||||||
|
|
||||||
@ -372,8 +372,7 @@ void wxBitmapRefData::UseAlpha( bool use )
|
|||||||
CGContextRef hBitmap = CGBitmapContextCreate(NULL, GetWidth(), GetHeight(), 8, GetBytesPerRow(), wxMacGetGenericRGBColorSpace(), use ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst );
|
CGContextRef hBitmap = CGBitmapContextCreate(NULL, GetWidth(), GetHeight(), 8, GetBytesPerRow(), wxMacGetGenericRGBColorSpace(), use ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst );
|
||||||
|
|
||||||
memcpy(CGBitmapContextGetData(hBitmap),CGBitmapContextGetData(m_hBitmap),GetBytesPerRow()*GetHeight());
|
memcpy(CGBitmapContextGetData(hBitmap),CGBitmapContextGetData(m_hBitmap),GetBytesPerRow()*GetHeight());
|
||||||
|
wxCHECK_RET( hBitmap , wxT("Unable to create CGBitmapContext context") ) ;
|
||||||
wxASSERT_MSG( hBitmap , wxT("Unable to create CGBitmapContext context") ) ;
|
|
||||||
CGContextTranslateCTM( hBitmap, 0, GetHeight() );
|
CGContextTranslateCTM( hBitmap, 0, GetHeight() );
|
||||||
CGContextScaleCTM( hBitmap, GetScaleFactor(), -GetScaleFactor() );
|
CGContextScaleCTM( hBitmap, GetScaleFactor(), -GetScaleFactor() );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user