From 02e36f2d3f1fd1d48dbe67eed59c76d07f4d6f93 Mon Sep 17 00:00:00 2001 From: bsalomon Date: Fri, 22 Aug 2014 12:01:46 -0700 Subject: [PATCH] Fix leak of GrResourceCacheEntry R=robertphillips@google.com TBR=robertphillips@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/502543002 --- src/gpu/GrContext.cpp | 5 +++-- src/gpu/GrResourceCache.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index b420df2bc8..63beb7de22 100755 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -548,8 +548,9 @@ void GrContext::unlockScratchTexture(GrTexture* texture) { if (texture->wasDestroyed()) { if (texture->getCacheEntry()->key().isScratch()) { // This texture was detached from the cache but the cache still had a ref to it but - // not a pointer to it. - texture->unref(); + // not a pointer to it. This will unref the texture and delete its resource cache + // entry. + delete texture->getCacheEntry(); } return; } diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h index 235b11a394..82ffbeabfe 100644 --- a/src/gpu/GrResourceCache.h +++ b/src/gpu/GrResourceCache.h @@ -152,6 +152,7 @@ private: SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrResourceCacheEntry); friend class GrResourceCache; + friend class GrContext; }; ///////////////////////////////////////////////////////////////////////////////