Skip to content

Commit

Permalink
Improved memory management in wxSVGFileDC.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaartenBent committed Mar 15, 2016
1 parent 6e1dbf9 commit c50fd98
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions include/wx/dcsvg.h
Expand Up @@ -229,14 +229,14 @@ class WXDLLIMPEXP_CORE wxSVGFileDCImpl : public wxDCImpl
// their current values in wxDC.
void DoStartNewGraphics();

wxFileOutputStream *m_outfile;
wxString m_filename;
int m_sub_images; // number of png format images we have
bool m_OK;
bool m_graphics_changed; // set by Set{Brush,Pen}()
int m_width, m_height;
double m_dpi;
wxSVGBitmapHandler* m_bmp_handler; // class to handle bitmaps
wxScopedPtr<wxFileOutputStream> m_outfile;
wxScopedPtr<wxSVGBitmapHandler> m_bmp_handler; // class to handle bitmaps

// The clipping nesting level is incremented by every call to
// SetClippingRegion() and reset when DestroyClippingRegion() is called.
Expand Down
12 changes: 5 additions & 7 deletions src/common/dcsvg.cpp
Expand Up @@ -411,8 +411,8 @@ void wxSVGFileDCImpl::Init (const wxString &filename, int Width, int Height,

////////////////////code here

m_bmp_handler = NULL;
m_outfile = new wxFileOutputStream(filename);
m_bmp_handler.reset();
m_outfile.reset(new wxFileOutputStream(filename));
m_OK = m_outfile->IsOk();
if (m_OK)
{
Expand Down Expand Up @@ -448,7 +448,6 @@ wxSVGFileDCImpl::~wxSVGFileDCImpl()

s += wxS("</g> \n</svg> \n");
write(s);
delete m_outfile;
}

void wxSVGFileDCImpl::DoGetSizeMM( int *width, int *height ) const
Expand Down Expand Up @@ -502,7 +501,7 @@ void wxSVGFileDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset

for (int i = 1; i < n; ++i)
{
s += wxString::Format(wxS("L%d %d"), (points[i].x + xoffset), (points[i].y + yoffset));
s += wxString::Format(wxS("L%d %d "), (points[i].x + xoffset), (points[i].y + yoffset));
CalcBoundingBox(points[i].x + xoffset, points[i].y + yoffset);
}

Expand Down Expand Up @@ -973,8 +972,7 @@ void wxSVGFileDCImpl::SetBackgroundMode( int mode )

void wxSVGFileDCImpl::SetBitmapHandler(wxSVGBitmapHandler* handler)
{
delete m_bmp_handler;
m_bmp_handler = handler;
m_bmp_handler.reset(handler);
}

void wxSVGFileDCImpl::SetBrush(const wxBrush& brush)
Expand Down Expand Up @@ -1096,7 +1094,7 @@ void wxSVGFileDCImpl::DoDrawBitmap(const class wxBitmap & bmp, wxCoord x, wxCoor

// If we don't have any bitmap handler yet, use the default one.
if ( !m_bmp_handler )
m_bmp_handler = new wxSVGBitmapFileHandler();
m_bmp_handler.reset(new wxSVGBitmapFileHandler());

m_bmp_handler->ProcessBitmap(bmp, x, y, *m_outfile);
}
Expand Down

0 comments on commit c50fd98

Please sign in to comment.