Use wxScopedPtr instead of explicit delete in printing sample

No real changes, just make the code a bit safer.
This commit is contained in:
Vadim Zeitlin
2019-02-03 22:45:13 +01:00
parent 7a05aa6dc0
commit 21a7ff2aa3

View File

@@ -38,6 +38,7 @@
#if wxUSE_GRAPHICS_CONTEXT
#include "wx/graphics.h"
#include "wx/scopedptr.h"
#endif
#ifdef __WXMAC__
@@ -219,7 +220,7 @@ void MyApp::Draw(wxDC&dc)
dc.DrawBitmap( m_bitmap, 10, 10 );
#if wxUSE_GRAPHICS_CONTEXT
wxGraphicsContext *gc = wxGraphicsContext::CreateFromUnknownDC(dc);
wxScopedPtr<wxGraphicsContext> gc(wxGraphicsContext::CreateFromUnknownDC(dc));
if (gc)
{
@@ -247,8 +248,6 @@ void MyApp::Draw(wxDC&dc)
gc->GetTextExtent(text, &w, &h);
gc->SetPen( *wxBLACK_PEN );
gc->DrawRectangle(25.0, 60.0, w, h);
delete gc;
}
#endif