NxWidgets::CImage: Allow NULL bitmaps. From Petteri Aimonen

This commit is contained in:
Gregory Nutt 2013-06-04 07:54:26 -06:00
parent d69d3cd080
commit 1e7b43629a
2 changed files with 46 additions and 33 deletions

View File

@ -347,25 +347,28 @@
1.8 2013-xx-xx Gregory Nutt <gnutt@nuttx.org>
* NxWM::CMediaPlayer: shell application for an MP3 Media Player with
Kconfig settings to enable it. I plan to write this app to help
develop and test the MP3 codec chip driver. It really doesn't do
anything yet except display a text box saying "Coming soon", and I
need to minimize the icon size a bit. From Ken Pettit (2013-5-11).
* NxWidgets/nxwm/src/glyph_mediaplayer.cxx: Smaller version of the
media player glyph. From Ken Pettit (2013-5-12).
* NxWidgets/nxwm/include/ccalibration.hxx and src/ccalibration.cxx:
Fix a race condition that would cause the calibration screen
to fail to come up when its icon was touched (From Ken Pettit,
2013-5-12).
* Kconfig: Default priorities for NxWidget and NxWM threads
should be 100, not 50, to be consistent with other default priorities.
* NxWidgets::CGlyphSliderHorizontal and NxWidgets::CGlyphSliderHorizontalGrip:
New widgets added by Ken Pettit (2013-5-15).
* NxWidgets/UnitTests/CGlyphSliderHorizontal: Addes a unit test for the
NxWidgets::CGlyphSliderHorizontal class. From Ken Pettit (2013-5-17) .
* NxWidgets::CGlyphSliderHorizontal: Fix a drawing error. From Ken
Pettit (2013-5-17).
* UnitTests/*/Makefile and .gitignore: Update the way that NSH
the Unit Tests are registered as built-in NSH applications (2013-5-30).
* NxWM::CMediaPlayer: shell application for an MP3 Media Player with
Kconfig settings to enable it. I plan to write this app to help
develop and test the MP3 codec chip driver. It really doesn't do
anything yet except display a text box saying "Coming soon", and I
need to minimize the icon size a bit. From Ken Pettit (2013-5-11).
* NxWidgets/nxwm/src/glyph_mediaplayer.cxx: Smaller version of the
media player glyph. From Ken Pettit (2013-5-12).
* NxWidgets/nxwm/include/ccalibration.hxx and src/ccalibration.cxx:
Fix a race condition that would cause the calibration screen
to fail to come up when its icon was touched (From Ken Pettit,
2013-5-12).
* Kconfig: Default priorities for NxWidget and NxWM threads
should be 100, not 50, to be consistent with other default priorities.
* NxWidgets::CGlyphSliderHorizontal and NxWidgets::CGlyphSliderHorizontalGrip:
New widgets added by Ken Pettit (2013-5-15).
* NxWidgets/UnitTests/CGlyphSliderHorizontal: Addes a unit test for the
NxWidgets::CGlyphSliderHorizontal class. From Ken Pettit (2013-5-17) .
* NxWidgets::CGlyphSliderHorizontal: Fix a drawing error. From Ken
Pettit (2013-5-17).
* UnitTests/*/Makefile and .gitignore: Update the way that NSH
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).

View File

@ -138,19 +138,29 @@ CImage::CImage(CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y,
void CImage::getPreferredDimensions(CRect &rect) const
{
nxgl_coord_t width = m_bitmap->getWidth();
nxgl_coord_t height = m_bitmap->getHeight();
if (!m_flags.borderless)
if (!m_bitmap)
{
width += (m_borderSize.left + m_borderSize.right);
height += (m_borderSize.top + m_borderSize.bottom);
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 height = m_bitmap->getHeight();
rect.setX(m_rect.getX());
rect.setY(m_rect.getY());
rect.setWidth(width);
rect.setHeight(height);
if (!m_flags.borderless)
{
width += (m_borderSize.left + m_borderSize.right);
height += (m_borderSize.top + m_borderSize.bottom);
}
rect.setX(m_rect.getX());
rect.setY(m_rect.getY());
rect.setWidth(width);
rect.setHeight(height);
}
}
/**
@ -440,7 +450,7 @@ void CImage::onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y)
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;
}
@ -455,7 +465,7 @@ void CImage::setImageLeft(nxgl_coord_t column)
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;
}