From da750c5995236591541916e3517aef3421a47f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Garc=C3=ADa=20Li=C3=B1=C3=A1n?= Date: Tue, 31 Aug 2021 18:04:50 +0200 Subject: [PATCH] Canvas: Set pointers to NULL instead of calling .release() The Canvas camera and texture get recreated in several circumstances. Calling .release() on a ref_ptr will just return the raw pointer and 'delete' won't be called. The proper way to explicitly delete an object managed by a ref_ptr is to set the ref_ptr to NULL. This will delete it as long as it's not referenced by any other ref_ptr. --- simgear/canvas/ODGauge.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simgear/canvas/ODGauge.cxx b/simgear/canvas/ODGauge.cxx index 8a6b1421..5f371d22 100644 --- a/simgear/canvas/ODGauge.cxx +++ b/simgear/canvas/ODGauge.cxx @@ -297,8 +297,8 @@ namespace canvas { if( camera.valid() && Canvas::getSystemAdapter() ) Canvas::getSystemAdapter()->removeCamera(camera.get()); - camera.release(); - texture.release(); + camera = nullptr; + texture = nullptr; _flags &= ~AVAILABLE; }