1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

Avoid naked delete

This commit is contained in:
Paul Licameli 2019-06-21 14:17:15 -04:00
parent a8e2b22ea2
commit 0ce6b2b05e

View File

@ -350,14 +350,17 @@ void TrackArt::DrawTrackName( TrackPanelDrawingContext &context, const Track * t
image.InitAlpha(); image.InitAlpha();
unsigned char *alpha=image.GetAlpha(); unsigned char *alpha=image.GetAlpha();
memset(alpha, wxIMAGE_ALPHA_TRANSPARENT, image.GetWidth()*image.GetHeight()); memset(alpha, wxIMAGE_ALPHA_TRANSPARENT, image.GetWidth()*image.GetHeight());
wxGraphicsContext &gc=*wxGraphicsContext::Create(image); {
// This is to a gc, not a dc. std::unique_ptr< wxGraphicsContext >
AColor::UseThemeColour( &gc, clrTrackInfoSelected, clrTrackPanelText, opacity ); pGc{ wxGraphicsContext::Create(image) };
// Draw at 1,1, not at 0,0 to avoid clipping of the antialiasing. auto &gc = *pGc;
gc.DrawRoundedRectangle( 1, 1, x+16, y+4, 8.0 ); // This is to a gc, not a dc.
// delete the gc so as to free and so update the wxImage. AColor::UseThemeColour( &gc, clrTrackInfoSelected, clrTrackPanelText, opacity );
delete &gc; // Draw at 1,1, not at 0,0 to avoid clipping of the antialiasing.
gc.DrawRoundedRectangle( 1, 1, x+16, y+4, 8.0 );
// destructor of gc updates the wxImage.
}
wxBitmap bitmap( image ); wxBitmap bitmap( image );
dc.DrawBitmap( bitmap, rect.x+6, rect.y); dc.DrawBitmap( bitmap, rect.x+6, rect.y);
#endif #endif