From e2f5b2779fb386becd9c27386ac63ba7e798bb06 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 11 Sep 2013 12:09:22 +0200 Subject: [PATCH] Changed lifetime of RENDER_SETTINGS (now they are accessible right after PAINTER object is created). --- common/painter.cpp | 5 ++--- include/painter.h | 11 ++++------- pcbnew/pcb_painter.cpp | 2 ++ pcbnew/pcb_painter.h | 4 +++- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/common/painter.cpp b/common/painter.cpp index 5787b5427c..8b9d1c6568 100644 --- a/common/painter.cpp +++ b/common/painter.cpp @@ -64,14 +64,13 @@ void RENDER_SETTINGS::update() PAINTER::PAINTER( GAL* aGal ) : - m_gal( aGal ), m_settings( NULL ), m_brightenedColor( 0.0, 1.0, 0.0, 0.9 ) + m_gal( aGal ), m_brightenedColor( 0.0, 1.0, 0.0, 0.9 ) { } PAINTER::~PAINTER() { - delete m_settings; } @@ -91,7 +90,7 @@ void PAINTER::DrawBrightened( const VIEW_ITEM* aItem ) m_gal->PushDepth(); m_gal->SetLayerDepth( -1.0 ); - // Draw semitransparent box that marks items as brightened + // Draw an outline that marks items as brightened m_gal->SetIsStroke( true ); m_gal->SetLineWidth( 100000.0 ); m_gal->SetStrokeColor( m_brightenedColor ); diff --git a/include/painter.h b/include/painter.h index 7384b37c10..c846bdc98d 100644 --- a/include/painter.h +++ b/include/painter.h @@ -32,7 +32,7 @@ #include #include - +#include class EDA_ITEM; class COLORS_DESIGN_SETTINGS; @@ -187,10 +187,7 @@ public: */ virtual void ApplySettings( RENDER_SETTINGS* aSettings ) { - if( m_settings ) - delete m_settings; - - m_settings = aSettings; + m_settings.reset( aSettings ); } /** @@ -207,7 +204,7 @@ public: */ virtual RENDER_SETTINGS* GetSettings() const { - return m_settings; + return m_settings.get(); } /** @@ -233,7 +230,7 @@ protected: GAL* m_gal; /// Colors and display modes settings that are going to be used when drawing items. - RENDER_SETTINGS* m_settings; + boost::shared_ptr m_settings; /// Color of brightened item frame COLOR4D m_brightenedColor; diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 21936aa3ca..742ef0e188 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -191,6 +191,8 @@ void PCB_RENDER_SETTINGS::update() PCB_PAINTER::PCB_PAINTER( GAL* aGal ) : PAINTER( aGal ) { + m_settings.reset( new PCB_RENDER_SETTINGS() ); + m_pcbSettings = (PCB_RENDER_SETTINGS*) m_settings.get(); } diff --git a/pcbnew/pcb_painter.h b/pcbnew/pcb_painter.h index c8ce09a4bb..d7f922e623 100644 --- a/pcbnew/pcb_painter.h +++ b/pcbnew/pcb_painter.h @@ -27,6 +27,7 @@ #define __CLASS_PCB_PAINTER_H #include +#include #include class EDA_ITEM; @@ -130,10 +131,11 @@ public: PAINTER::ApplySettings( aSettings ); // Store PCB specific render settings - m_pcbSettings = dynamic_cast( aSettings ); + m_pcbSettings = (PCB_RENDER_SETTINGS*) m_settings.get(); //dynamic_cast( aSettings ); } protected: + /// Just a properly casted pointer to settings PCB_RENDER_SETTINGS* m_pcbSettings; // Drawing functions for various types of PCB-specific items