From 49475a44169acac768d496d7aca232dacbb2ae6d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 5 Feb 2023 13:50:26 +0100 Subject: [PATCH] Cleanup: use ScopeGuard. --- src/wx/timeline.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index 2a8555e7c..604a00f39 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -35,6 +35,7 @@ #include "lib/film.h" #include "lib/image_content.h" #include "lib/playlist.h" +#include "lib/scope_guard.h" #include "lib/text_content.h" #include "lib/timer.h" #include "lib/video_content.h" @@ -155,13 +156,13 @@ Timeline::paint_labels () return; } + ScopeGuard sg = [gc]() { delete gc; }; + int vsx, vsy; _labels_canvas->GetViewStart (&vsx, &vsy); gc->Translate (-vsx * _x_scroll_rate, -vsy * _y_scroll_rate + tracks_y_offset()); _labels_view->paint (gc, {}); - - delete gc; } @@ -176,6 +177,8 @@ Timeline::paint_main () return; } + ScopeGuard sg = [gc]() { delete gc; }; + int vsx, vsy; _main_canvas->GetViewStart (&vsx, &vsy); gc->Translate (-vsx * _x_scroll_rate, -vsy * _y_scroll_rate); @@ -225,8 +228,6 @@ Timeline::paint_main () path.MoveToPoint (ph, 0); path.AddLineToPoint (ph, pixels_per_track() * _tracks + 32); gc->StrokePath (path); - - delete gc; } -- 2.30.2