Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of DMBasicGUI by
Diff: Application/ImageButton.cpp
- Revision:
- 9:ce69a7adfe9c
- Parent:
- 6:7917b0894655
- Child:
- 11:265884fa7fdd
--- a/Application/ImageButton.cpp Sat Jan 17 14:07:25 2015 +0100 +++ b/Application/ImageButton.cpp Tue Jan 20 09:05:30 2015 +0100 @@ -23,31 +23,33 @@ ImageButton::ImageButton(COLOR_T* fb, uint16_t x, uint16_t y, uint16_t width, uint16_t height) : Clickable(fb, x, y, width, height) { + _imgUp.pointerToFree = NULL; _imgUp.pixels = NULL; + _imgDown.pointerToFree = NULL; _imgDown.pixels = NULL; } ImageButton::~ImageButton() { - if (_imgUp.pixels != NULL) { - free(_imgUp.pixels); - _imgUp.pixels = NULL; + if (_imgUp.pointerToFree != NULL) { + free(_imgUp.pointerToFree); + _imgUp.pointerToFree = NULL; } - if (_imgDown.pixels != NULL) { - free(_imgDown.pixels); - _imgDown.pixels = NULL; + if (_imgDown.pointerToFree != NULL) { + free(_imgDown.pointerToFree); + _imgDown.pointerToFree = NULL; } } bool ImageButton::loadImages(const char* imgUp, const char* imgDown) { - if (_imgUp.pixels != NULL) { - free(_imgUp.pixels); - _imgUp.pixels = NULL; + if (_imgUp.pointerToFree != NULL) { + free(_imgUp.pointerToFree); + _imgUp.pointerToFree = NULL; } - if (_imgDown.pixels != NULL) { - free(_imgDown.pixels); - _imgDown.pixels = NULL; + if (_imgDown.pointerToFree != NULL) { + free(_imgDown.pointerToFree); + _imgDown.pointerToFree = NULL; } if (Image::decode(imgUp, Image::RES_16BIT, &_imgUp) != 0) { DMBoard::instance().logger()->printf("Failed to load %s\n", imgUp); @@ -65,13 +67,13 @@ bool ImageButton::loadImages(const unsigned char* imgUp, unsigned int imgUpSize, const unsigned char* imgDown, unsigned int imgDownSize) { - if (_imgUp.pixels != NULL) { - free(_imgUp.pixels); - _imgUp.pixels = NULL; + if (_imgUp.pointerToFree != NULL) { + free(_imgUp.pointerToFree); + _imgUp.pointerToFree = NULL; } - if (_imgDown.pixels != NULL) { - free(_imgDown.pixels); - _imgDown.pixels = NULL; + if (_imgDown.pointerToFree != NULL) { + free(_imgDown.pointerToFree); + _imgDown.pointerToFree = NULL; } if (Image::decode(imgUp, imgUpSize, Image::RES_16BIT, &_imgUp) != 0) { DMBoard::instance().logger()->printf("Failed to load %s\n", imgUp);