Fixed a memleak in GerbView

Changed m_painter PAINTER* to unique_ptr<PAINTER> to avoid confusion
regarding the objection destruction.
This commit is contained in:
Maciej Suminski 2017-10-30 09:36:31 +01:00
parent a4440395be
commit 3a8b4a2fb7
3 changed files with 6 additions and 6 deletions

View File

@ -38,8 +38,8 @@ EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalTy
{
setDefaultLayerDeps();
m_painter = new KIGFX::GERBVIEW_PAINTER( m_gal );
m_view->SetPainter( m_painter );
m_painter.reset( new KIGFX::GERBVIEW_PAINTER( m_gal ) );
m_view->SetPainter( m_painter.get() );
// Load display options (such as filled/outline display of items).
auto frame = static_cast< GERBVIEW_FRAME* >( GetParentEDAFrame() );

View File

@ -35,6 +35,7 @@
#include <wx/timer.h>
#include <math/vector2d.h>
#include <msgpanel.h>
#include <memory>
class BOARD;
class EDA_DRAW_FRAME;
@ -271,7 +272,7 @@ protected:
KIGFX::VIEW* m_view;
/// Contains information about how to draw items using GAL
KIGFX::PAINTER* m_painter;
std::unique_ptr<KIGFX::PAINTER> m_painter;
/// Control for VIEW (moving, zooming, etc.)
KIGFX::WX_VIEW_CONTROLS* m_viewControls;

View File

@ -107,8 +107,8 @@ EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalTy
setDefaultLayerOrder();
setDefaultLayerDeps();
m_painter = new KIGFX::PCB_PAINTER( m_gal );
m_view->SetPainter( m_painter );
m_painter.reset( new KIGFX::PCB_PAINTER( m_gal ) );
m_view->SetPainter( m_painter.get() );
// Load display options (such as filled/outline display of items).
// Can be made only if the parent window is an EDA_DRAW_FRAME (or a derived class)
@ -125,7 +125,6 @@ EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalTy
PCB_DRAW_PANEL_GAL::~PCB_DRAW_PANEL_GAL()
{
delete m_painter;
}