[aseprite] 34/250: Use a UniquePtr<> to store the new image in new_image_from_mask()

Tobias Hansen thansen at moszumanska.debian.org
Sun Dec 20 15:27:08 UTC 2015


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit 77e16cecd0887be50796ab298a835b09414da60a
Author: David Capello <davidcapello at gmail.com>
Date:   Mon Sep 14 12:54:00 2015 -0300

    Use a UniquePtr<> to store the new image in new_image_from_mask()
---
 src/app/util/new_image_from_mask.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/app/util/new_image_from_mask.cpp b/src/app/util/new_image_from_mask.cpp
index c8352be..d54362c 100644
--- a/src/app/util/new_image_from_mask.cpp
+++ b/src/app/util/new_image_from_mask.cpp
@@ -12,6 +12,7 @@
 #include "app/util/new_image_from_mask.h"
 
 #include "app/document.h"
+#include "base/unique_ptr.h"
 #include "doc/image_impl.h"
 #include "doc/mask.h"
 #include "doc/site.h"
@@ -32,14 +33,13 @@ doc::Image* new_image_from_mask(const doc::Site& site, const doc::Mask* srcMask)
   const Image* srcMaskBitmap = srcMask->bitmap();
   const gfx::Rect& srcBounds = srcMask->bounds();
   int x, y, u, v, getx, gety;
-  Image *dst;
   const Image *src = site.image(&x, &y);
 
   ASSERT(srcSprite);
   ASSERT(srcMask);
   ASSERT(srcMaskBitmap);
 
-  dst = Image::create(srcSprite->pixelFormat(), srcBounds.w, srcBounds.h);
+  base::UniquePtr<Image> dst(Image::create(srcSprite->pixelFormat(), srcBounds.w, srcBounds.h));
   if (!dst)
     return nullptr;
 
@@ -61,14 +61,14 @@ doc::Image* new_image_from_mask(const doc::Site& site, const doc::Mask* srcMask)
           gety = v+srcBounds.y-y;
 
           if ((getx >= 0) && (getx < src->width()) &&
-            (gety >= 0) && (gety < src->height()))
+              (gety >= 0) && (gety < src->height()))
             dst->putPixel(u, v, src->getPixel(getx, gety));
         }
       }
     }
   }
 
-  return dst;
+  return dst.release();
 }
 
 } // namespace app

-- 
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