mirror of
https://github.com/aseprite/aseprite.git
synced 2024-09-15 15:14:16 +00:00
Fix memory leak loading images for a ImageView widget
This commit is contained in:
parent
736f63132b
commit
8b242bdf06
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@ -480,7 +480,7 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
|
||||
try {
|
||||
she::Surface* sur = she::instance()->loadRgbaSurface(rf.filename().c_str());
|
||||
widget = new ImageView(sur, 0);
|
||||
widget = new ImageView(sur, 0, true);
|
||||
}
|
||||
catch (...) {
|
||||
throw base::Exception("Error loading %s file", file);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2001-2013, 2015 David Capello
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -20,13 +20,20 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
ImageView::ImageView(she::Surface* sur, int align)
|
||||
ImageView::ImageView(she::Surface* sur, int align, bool dispose)
|
||||
: Widget(kImageViewWidget)
|
||||
, m_sur(sur)
|
||||
, m_disposeSurface(dispose)
|
||||
{
|
||||
setAlign(align);
|
||||
}
|
||||
|
||||
ImageView::~ImageView()
|
||||
{
|
||||
if (m_disposeSurface)
|
||||
delete m_sur;
|
||||
}
|
||||
|
||||
void ImageView::onSizeHint(SizeHintEvent& ev)
|
||||
{
|
||||
gfx::Rect box;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2001-2013 David Capello
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -16,10 +16,10 @@ namespace she {
|
||||
|
||||
namespace ui {
|
||||
|
||||
class ImageView : public Widget
|
||||
{
|
||||
class ImageView : public Widget {
|
||||
public:
|
||||
ImageView(she::Surface* sur, int align);
|
||||
ImageView(she::Surface* sur, int align, bool disposeSurface);
|
||||
~ImageView();
|
||||
|
||||
protected:
|
||||
void onSizeHint(SizeHintEvent& ev) override;
|
||||
@ -27,6 +27,7 @@ namespace ui {
|
||||
|
||||
private:
|
||||
she::Surface* m_sur;
|
||||
bool m_disposeSurface;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
|
Loading…
Reference in New Issue
Block a user