[aseprite] 25/64: Fix memory leak loading images for a ImageView widget
Tobias Hansen
thansen at moszumanska.debian.org
Tue Jun 21 14:43:02 UTC 2016
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit 8b242bdf062f05daef1d90618cf3c26beb31bbdc
Author: David Capello <davidcapello at gmail.com>
Date: Wed May 11 12:58:27 2016 -0300
Fix memory leak loading images for a ImageView widget
---
src/app/widget_loader.cpp | 4 ++--
src/ui/image_view.cpp | 11 +++++++++--
src/ui/image_view.h | 9 +++++----
3 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/src/app/widget_loader.cpp b/src/app/widget_loader.cpp
index af2ff07..210d3cf 100644
--- a/src/app/widget_loader.cpp
+++ b/src/app/widget_loader.cpp
@@ -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);
diff --git a/src/ui/image_view.cpp b/src/ui/image_view.cpp
index 960a647..a87ca5c 100644
--- a/src/ui/image_view.cpp
+++ b/src/ui/image_view.cpp
@@ -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;
diff --git a/src/ui/image_view.h b/src/ui/image_view.h
index a650341..b018574 100644
--- a/src/ui/image_view.h
+++ b/src/ui/image_view.h
@@ -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
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list