Fix deleting of GrGpuResource when abanonded and refs go to zero.
Abandoning would cause us to unref all the command buffer usages, but
then in notifyARefIsZero we would delete the abandoned resources even
though we still had a real ref. Then when that ref went away we would
crash.
Change-Id: I05dc2ba9a67c35c36a36704f4b81d6eef4e860e6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/382916
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp
index 716dfa8..7a40bf5 100644
--- a/src/gpu/GrGpuResource.cpp
+++ b/src/gpu/GrGpuResource.cpp
@@ -160,8 +160,10 @@
void GrGpuResource::notifyARefCntIsZero(LastRemovedRef removedRef) const {
if (this->wasDestroyed()) {
- // We've already been removed from the cache. Goodbye cruel world!
- delete this;
+ if (this->hasNoCommandBufferUsages() && !this->hasRef()) {
+ // We've already been removed from the cache. Goodbye cruel world!
+ delete this;
+ }
return;
}