libgui: fix an EGLImage leak
This moves the call to ConsumerBase::abandon from the ConsumerBase dtor to
ConsumerBase::onLastStrongRef. The abandon call relies on virtual methods to
perform the clean-up, so calling it from the ConsumerBase dtor after the
derived classes dtors ran was skipping some of the clean-up. The
onLastStrongRef method should get called just before the most derived class's
dtor gets called.
Bug: 8349135
Change-Id: I836946826927cc1ed69c049049f525f92b17a269
diff --git a/include/gui/ConsumerBase.h b/include/gui/ConsumerBase.h
index 78a3608..8a7545d 100644
--- a/include/gui/ConsumerBase.h
+++ b/include/gui/ConsumerBase.h
@@ -89,6 +89,18 @@
// buffers from the given BufferQueue.
ConsumerBase(const sp<BufferQueue> &bufferQueue);
+ // onLastStrongRef gets called by RefBase just before the dtor of the most
+ // derived class. It is used to clean up the buffers so that ConsumerBase
+ // can coordinate the clean-up by calling into virtual methods implemented
+ // by the derived classes. This would not be possible from the
+ // ConsuemrBase dtor because by the time that gets called the derived
+ // classes have already been destructed.
+ //
+ // This methods should not need to be overridden by derived classes, but
+ // if they are overridden the ConsumerBase implementation must be called
+ // from the derived class.
+ virtual void onLastStrongRef(const void* id);
+
// Implementation of the BufferQueue::ConsumerListener interface. These
// calls are used to notify the ConsumerBase of asynchronous events in the
// BufferQueue. These methods should not need to be overridden by derived