guarding agains NULL

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71767 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2012-06-14 21:51:19 +00:00
parent 7d5b794ce4
commit f5fac4471b

View File

@@ -1035,8 +1035,10 @@ wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const
{
unsigned char *sourcedata = (unsigned char*) GetRawAccess() ;
unsigned char *destdata = (unsigned char*) ret.BeginRawAccess() ;
wxASSERT( (sourcedata != NULL) && (destdata != NULL) ) ;
wxASSERT((sourcedata != NULL) && (destdata != NULL));
if ( (sourcedata != NULL) && (destdata != NULL) )
{
int sourcelinesize = GetBitmapData()->GetBytesPerRow() ;
int destlinesize = ret.GetBitmapData()->GetBytesPerRow() ;
unsigned char *source = sourcedata + rect.x * 4 + rect.y * sourcelinesize ;
@@ -1047,8 +1049,9 @@ wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const
memcpy( dest , source , destlinesize ) ;
}
}
ret.EndRawAccess() ;
}
if ( M_BITMAPDATA->m_bitmapMask )
{
@@ -1063,6 +1066,8 @@ wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const
unsigned char *destdata = (unsigned char * ) maskbuf.GetWriteBuf( maskbufsize ) ;
wxASSERT( (source != NULL) && (destdata != NULL) ) ;
if ( (source != NULL) && (destdata != NULL) )
{
source += rect.x * kMaskBytesPerPixel + rect.y * sourcelinesize ;
unsigned char *dest = destdata ;
@@ -1072,6 +1077,7 @@ wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const
}
maskbuf.UngetWriteBuf( maskbufsize ) ;
}
ret.SetMask( new wxMask( maskbuf , destwidth , destheight , rowBytes ) ) ;
}
else if ( HasAlpha() )
@@ -1607,7 +1613,8 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
size_t size = m_bytesPerRow * m_height ;
unsigned char * destdatabase = (unsigned char*) m_memBuf.GetWriteBuf( size ) ;
wxASSERT( destdatabase != NULL ) ;
if ( destdatabase != NULL)
{
memset( destdatabase , 0 , size ) ;
unsigned char * srcdatabase = (unsigned char*) bitmap.GetRawAccess() ;
size_t sourceBytesRow = bitmap.GetBitmapData()->GetBytesPerRow();
@@ -1631,7 +1638,7 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
*destdata++ = 0x00 ;
}
}
}
m_memBuf.UngetWriteBuf( size ) ;
RealizeNative() ;