Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Unified Diff: src/core/SkImageCacherator.cpp

Issue 1345523002: we must own/free the generator, even if we fail to return a cacherator (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkImageCacherator.cpp
diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp
index bdcd64f56ddedd896ea6d3f5a66274d6f2468b0f..b138853e6136eb70bb8eb65c99a9a7739e167cc9 100644
--- a/src/core/SkImageCacherator.cpp
+++ b/src/core/SkImageCacherator.cpp
@@ -27,6 +27,10 @@ SkImageCacherator* SkImageCacherator::NewFromGenerator(SkImageGenerator* gen,
if (!gen) {
return nullptr;
}
+
+ // We are required to take ownership of gen, regardless of if we return a cacherator or not
+ SkAutoTDelete<SkImageGenerator> genHolder(gen);
+
const SkImageInfo& info = gen->getInfo();
if (info.isEmpty()) {
return nullptr;
@@ -46,6 +50,10 @@ SkImageCacherator* SkImageCacherator::NewFromGenerator(SkImageGenerator* gen,
subset = &bounds;
}
+ // Now that we know we can hand-off the generator (to be owned by the cacherator) we can
+ // release our holder. (we DONT want to delete it here anymore)
tomhudson 2015/09/14 16:58:16 Nit: two words "any more" unless you're Edgar Alle
+ genHolder.detach();
+
return new SkImageCacherator(gen, gen->getInfo().makeWH(subset->width(), subset->height()),
SkIPoint::Make(subset->x(), subset->y()), uniqueID);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698