NxWidgets::CImage: Allow NULL bitmaps. From Petteri Aimonen
This commit is contained in:
parent
d69d3cd080
commit
1e7b43629a
@ -368,4 +368,7 @@
|
|||||||
Pettit (2013-5-17).
|
Pettit (2013-5-17).
|
||||||
* UnitTests/*/Makefile and .gitignore: Update the way that NSH
|
* UnitTests/*/Makefile and .gitignore: Update the way that NSH
|
||||||
the Unit Tests are registered as built-in NSH applications (2013-5-30).
|
the Unit Tests are registered as built-in NSH applications (2013-5-30).
|
||||||
|
* NxWidgets::CImage: Allow a NULL pointer for a bitmap. Add protection
|
||||||
|
to prevent dereferencing the NULL pointer. From Petteri Aimonen
|
||||||
|
(2013-6-3).
|
||||||
|
|
||||||
|
@ -137,6 +137,15 @@ CImage::CImage(CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void CImage::getPreferredDimensions(CRect &rect) const
|
void CImage::getPreferredDimensions(CRect &rect) const
|
||||||
|
{
|
||||||
|
if (!m_bitmap)
|
||||||
|
{
|
||||||
|
rect.setX(m_rect.getX());
|
||||||
|
rect.setY(m_rect.getY());
|
||||||
|
rect.setWidth(0);
|
||||||
|
rect.setHeight(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
nxgl_coord_t width = m_bitmap->getWidth();
|
nxgl_coord_t width = m_bitmap->getWidth();
|
||||||
nxgl_coord_t height = m_bitmap->getHeight();
|
nxgl_coord_t height = m_bitmap->getHeight();
|
||||||
@ -152,6 +161,7 @@ void CImage::getPreferredDimensions(CRect &rect) const
|
|||||||
rect.setWidth(width);
|
rect.setWidth(width);
|
||||||
rect.setHeight(height);
|
rect.setHeight(height);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw the area of this widget that falls within the clipping region.
|
* Draw the area of this widget that falls within the clipping region.
|
||||||
@ -440,7 +450,7 @@ void CImage::onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y)
|
|||||||
|
|
||||||
void CImage::setImageLeft(nxgl_coord_t column)
|
void CImage::setImageLeft(nxgl_coord_t column)
|
||||||
{
|
{
|
||||||
if (column > 0 && column <= m_bitmap->getWidth())
|
if (m_bitmap && column > 0 && column <= m_bitmap->getWidth())
|
||||||
{
|
{
|
||||||
m_origin.x = column;
|
m_origin.x = column;
|
||||||
}
|
}
|
||||||
@ -455,7 +465,7 @@ void CImage::setImageLeft(nxgl_coord_t column)
|
|||||||
|
|
||||||
void CImage::setImageTop(nxgl_coord_t row)
|
void CImage::setImageTop(nxgl_coord_t row)
|
||||||
{
|
{
|
||||||
if (row > 0 && row <= m_bitmap->getHeight())
|
if (m_bitmap && row > 0 && row <= m_bitmap->getHeight())
|
||||||
{
|
{
|
||||||
m_origin.x = row;
|
m_origin.x = row;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user