fix even more memory leaks

This commit is contained in:
jacob1 2013-02-24 19:11:37 -05:00
parent b92bd245c8
commit fbf52794e5
8 changed files with 42 additions and 5 deletions

View File

@ -188,6 +188,10 @@ GameController::~GameController()
{ {
delete localBrowser; delete localBrowser;
} }
if (options)
{
delete options;
}
if(ui::Engine::Ref().GetWindow() == gameView) if(ui::Engine::Ref().GetWindow() == gameView)
{ {
ui::Engine::Ref().CloseWindow(); ui::Engine::Ref().CloseWindow();

View File

@ -179,6 +179,10 @@ GameModel::~GameModel()
{ {
delete *iter; delete *iter;
} }
for(std::vector<QuickOption*>::iterator iter = quickOptions.begin(), end = quickOptions.end(); iter != end; ++iter)
{
delete *iter;
}
delete sim; delete sim;
delete ren; delete ren;
if(placeSave) if(placeSave)

View File

@ -22,6 +22,7 @@ void ToolButton::OnMouseClick(int x, int y, unsigned int button)
void ToolButton::OnMouseUnclick(int x, int y, unsigned int button) void ToolButton::OnMouseUnclick(int x, int y, unsigned int button)
{ {
isButtonDown = false;
if(isButtonDown) if(isButtonDown)
{ {
if(button == BUTTON_LEFT) if(button == BUTTON_LEFT)
@ -32,7 +33,6 @@ void ToolButton::OnMouseUnclick(int x, int y, unsigned int button)
SetSelectionState(2); SetSelectionState(2);
DoAction(); DoAction();
} }
isButtonDown = false;
} }
void ToolButton::Draw(const ui::Point& screenPos) void ToolButton::Draw(const ui::Point& screenPos)

View File

@ -46,6 +46,8 @@ Engine::~Engine()
delete windows.top(); delete windows.top();
windows.pop(); windows.pop();
} }
if (lastBuffer)
free(lastBuffer);
} }
void Engine::Begin(int width, int height) void Engine::Begin(int width, int height)

View File

@ -316,5 +316,11 @@ void PreviewModel::Update()
PreviewModel::~PreviewModel() { PreviewModel::~PreviewModel() {
if(save) if(save)
delete save; delete save;
if(saveComments)
{
for(int i = 0; i < saveComments->size(); i++)
delete saveComments->at(i);
delete saveComments;
}
} }

View File

@ -411,7 +411,7 @@ void PreviewView::NotifySaveChanged(PreviewModel * sender)
float factorY = ((float)YRES/2)/((float)savePreview->Size.Y); float factorY = ((float)YRES/2)/((float)savePreview->Size.Y);
float scaleFactor = factorY < factorX ? factorY : factorX; float scaleFactor = factorY < factorX ? factorY : factorX;
savePreview->Data = Graphics::resample_img(oldData, savePreview->Size.X, savePreview->Size.Y, savePreview->Size.X*scaleFactor, savePreview->Size.Y*scaleFactor); savePreview->Data = Graphics::resample_img(oldData, savePreview->Size.X, savePreview->Size.Y, savePreview->Size.X*scaleFactor, savePreview->Size.Y*scaleFactor);
delete oldData; delete[] oldData;
savePreview->Size.X *= scaleFactor; savePreview->Size.X *= scaleFactor;
savePreview->Size.Y *= scaleFactor; savePreview->Size.Y *= scaleFactor;
} }
@ -453,14 +453,14 @@ void PreviewView::NotifyCommentBoxEnabledChanged(PreviewModel * sender)
if(addCommentBox) if(addCommentBox)
{ {
RemoveComponent(addCommentBox); RemoveComponent(addCommentBox);
addCommentBox = NULL;
delete addCommentBox; delete addCommentBox;
addCommentBox = NULL;
} }
if(submitCommentButton) if(submitCommentButton)
{ {
RemoveComponent(submitCommentButton); RemoveComponent(submitCommentButton);
submitCommentButton = NULL;
delete submitCommentButton; delete submitCommentButton;
submitCommentButton = NULL;
} }
if(sender->GetCommentBoxEnabled()) if(sender->GetCommentBoxEnabled())
{ {
@ -561,6 +561,17 @@ void PreviewView::NotifyCommentsChanged(PreviewModel * sender)
} }
}*/ }*/
PreviewView::~PreviewView() { PreviewView::~PreviewView()
{
if(addCommentBox)
{
RemoveComponent(addCommentBox);
delete addCommentBox;
}
if(submitCommentButton)
{
RemoveComponent(submitCommentButton);
delete submitCommentButton;
}
} }

View File

@ -88,6 +88,8 @@ void SearchController::Exit()
} }
if(callback) if(callback)
callback->ControllerExit(); callback->ControllerExit();
delete callback;
callback = NULL;
//HasExited = true; //HasExited = true;
} }
@ -101,6 +103,7 @@ SearchController::~SearchController()
} }
delete searchModel; delete searchModel;
delete searchView; delete searchView;
delete callback;
} }
void SearchController::DoSearch(std::string query, bool now) void SearchController::DoSearch(std::string query, bool now)

View File

@ -252,6 +252,13 @@ SearchView::~SearchView()
RemoveComponent(previousButton); RemoveComponent(previousButton);
RemoveComponent(infoLabel); RemoveComponent(infoLabel);
for(int i = 0; i < saveButtons.size(); i++)
{
RemoveComponent(saveButtons[i]);
delete saveButtons[i];
}
saveButtons.clear();
delete nextButton; delete nextButton;
delete previousButton; delete previousButton;
delete infoLabel; delete infoLabel;