From 87b4c6a3048f34bfb828285fbd48237aa60464cf Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 4 Jun 2013 07:54:26 -0600 Subject: NxWidgets::CImage: Allow NULL bitmaps. From Petteri Aimonen --- NxWidgets/ChangeLog.txt | 45 +++++++++++++++++++---------------- NxWidgets/libnxwidgets/src/cimage.cxx | 34 ++++++++++++++++---------- 2 files changed, 46 insertions(+), 33 deletions(-) (limited to 'NxWidgets') diff --git a/NxWidgets/ChangeLog.txt b/NxWidgets/ChangeLog.txt index 0737e5ca3..f83364b9a 100644 --- a/NxWidgets/ChangeLog.txt +++ b/NxWidgets/ChangeLog.txt @@ -347,25 +347,28 @@ 1.8 2013-xx-xx Gregory Nutt -* 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). diff --git a/NxWidgets/libnxwidgets/src/cimage.cxx b/NxWidgets/libnxwidgets/src/cimage.cxx index 9b3137129..b9b93ebb6 100644 --- a/NxWidgets/libnxwidgets/src/cimage.cxx +++ b/NxWidgets/libnxwidgets/src/cimage.cxx @@ -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; } -- cgit v1.2.3