From: Carl Hetherington Date: Sun, 5 Feb 2023 12:50:26 +0000 (+0100) Subject: Cleanup: use ScopeGuard. X-Git-Tag: v2.16.43~30 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=49475a44169acac768d496d7aca232dacbb2ae6d Cleanup: use ScopeGuard. --- 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; }