This will (hopefully) solve the memory leaks in dynamic ribbons and image button widgets

This commit is contained in:
Marc Coll Carrillo
2014-10-03 22:11:21 +02:00
parent cc41327db3
commit f520e38cd5
2 changed files with 5 additions and 8 deletions

View File

@@ -23,7 +23,6 @@
#include "utils/vs.hpp"
#include <IGUIEnvironment.h>
#include <sstream>
#include <iostream>
#include <algorithm>
@@ -45,6 +44,7 @@ DynamicRibbonWidget::DynamicRibbonWidget(const bool combo, const bool multi_row)
m_check_inside_me = true;
m_supports_multiplayer = true;
m_scrolling_enabled = true;
m_animated_contents = false;
// by default, set all players to have no selection in this ribbon
for (unsigned int n=0; n<MAX_PLAYER_COUNT; n++)
@@ -61,7 +61,7 @@ DynamicRibbonWidget::DynamicRibbonWidget(const bool combo, const bool multi_row)
// -----------------------------------------------------------------------------
DynamicRibbonWidget::~DynamicRibbonWidget()
{
m_font->drop();
delete m_font;
if (m_animated_contents)
{
GUIEngine::needsUpdate.remove(this);

View File

@@ -293,8 +293,8 @@ video::ITexture* IconButtonWidget::getDeactivatedTexture(video::ITexture* textur
u32 g;
video::IVideoDriver* driver = irr_driver->getVideoDriver();
video::IImage* image = driver->createImageFromData (texture->getColorFormat(),
texture->getSize(), texture->lock(), false);
std::auto_ptr<video::IImage> image (driver->createImageFromData (texture->getColorFormat(),
texture->getSize(), texture->lock(), false));
texture->unlock();
//Turn the image into grayscale
@@ -309,10 +309,7 @@ video::ITexture* IconButtonWidget::getDeactivatedTexture(video::ITexture* textur
}
}
texture = driver->addTexture(texture->getName().getPath() + "_disabled", image);
image->drop();
return texture;
return driver->addTexture(texture->getName().getPath() + "_disabled", image.get ());
}
// -----------------------------------------------------------------------------