From 44bae773a093482e3d5734b67ab53a9651f182f1 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 4b5ec62c..5b003bf1 100644 --- a/simgear/canvas/ODGauge.cxx +++ b/simgear/canvas/ODGauge.cxx @@ -298,8 +298,8 @@ namespace canvas { if( camera.valid() && Canvas::getSystemAdapter() ) Canvas::getSystemAdapter()->removeCamera(camera.get()); - camera.release(); - texture.release(); + camera = nullptr; + texture = nullptr; _flags &= ~AVAILABLE; }