Make sure action textures get deleted.

This commit is contained in:
Steven Mattera 2018-09-28 16:29:50 -04:00
parent c752b59eaf
commit 8bcf9d2f6b
5 changed files with 21 additions and 3 deletions

View File

@ -24,3 +24,10 @@ Action::Action(ActionButton actionButton, string actionText) {
textWidth = 0;
textHeight = 0;
}
Action::~Action() {
if (textTexture != NULL) {
SDL_DestroyTexture(textTexture);
textTexture = NULL;
}
}

View File

@ -39,4 +39,5 @@ class Action {
int textHeight;
Action(ActionButton actionButton, string actionText);
~Action();
};

View File

@ -24,6 +24,7 @@ AppUpdateScene::AppUpdateScene() {
_footerView = new FooterView();
_footerView->frame = { 0, 647, 1280, 73 };
_footerView->actions.push_back(new Action(A_BUTTON, "Next"));
addSubView(_headerView);
addSubView(_footerView);
@ -39,7 +40,7 @@ AppUpdateScene::~AppUpdateScene() {
void AppUpdateScene::handleButton(u32 buttons) {
if (buttons & KEY_A) {
SceneDirector::currentScene = SCENE_ALL_DONE;
SceneDirector::currentScene = SCENE_PACKAGE_SELECT;
}
}

View File

@ -16,6 +16,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "PackageSelectScene.hpp"
#include "../SceneDirector.hpp"
PackageSelectScene::PackageSelectScene() {
_headerView = new HeaderView();
@ -37,7 +38,9 @@ PackageSelectScene::~PackageSelectScene() {
}
void PackageSelectScene::handleButton(u32 buttons) {
if (buttons & KEY_A) {
SceneDirector::currentScene = SCENE_ALL_DONE;
}
}
void PackageSelectScene::render(SDL_Rect rect, double dTime) {

View File

@ -49,7 +49,13 @@ FooterView::FooterView() : View() {
}
}
FooterView::~FooterView() {}
FooterView::~FooterView() {
for (list<Action *>::iterator it = actions.begin(); it != actions.end(); it++) {
delete (*it);
}
actions.clear();
}
void FooterView::render(SDL_Rect rect) {
// Divider.