Give Adafruit_GFX a virtual destructor except on AVR

Deleting a canvas or display through an Adafruit_GFX pointer called
only the base destructor, so the canvas buffer leaked (#369). AVR is
left out because a virtual destructor links malloc and free into
display sketches that never use the heap (+602 bytes on an Uno).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mikey SklarandClaude Opus 5.5 committed 2026-10-21 13:09:49 -07:00
1 parent 85ce269b27
commit 019a40791e
1 file changed
+5
+5
View File
@@ -19,6 +19,11 @@ class Adafruit_GFX : public Print {
public:
Adafruit_GFX(int16_t w, int16_t h); // Constructor
#if !defined(__AVR__)
// Virtual so deleting a canvas or display through an Adafruit_GFX pointer
// frees it. Skipped on AVR, where it links malloc/free into every sketch.
virtual ~Adafruit_GFX() {}
#endif
/**********************************************************************/
/*!