Commit 505b3841 authored by Maciej Suminski's avatar Maciej Suminski

Removed a few memory leaks.

parent 75026d87
...@@ -220,6 +220,7 @@ set( PCB_COMMON_SRCS ...@@ -220,6 +220,7 @@ set( PCB_COMMON_SRCS
../pcbnew/class_zone_settings.cpp ../pcbnew/class_zone_settings.cpp
../pcbnew/classpcb.cpp ../pcbnew/classpcb.cpp
../pcbnew/ratsnest_data.cpp ../pcbnew/ratsnest_data.cpp
../pcbnew/ratsnest_viewitem.cpp
../pcbnew/collectors.cpp ../pcbnew/collectors.cpp
../pcbnew/netlist_reader.cpp ../pcbnew/netlist_reader.cpp
../pcbnew/legacy_netlist_reader.cpp ../pcbnew/legacy_netlist_reader.cpp
......
...@@ -36,10 +36,8 @@ ...@@ -36,10 +36,8 @@
using namespace KIGFX; using namespace KIGFX;
WORKSHEET_VIEWITEM::WORKSHEET_VIEWITEM( const std::string& aFileName, const std::string& aSheetName, WORKSHEET_VIEWITEM::WORKSHEET_VIEWITEM( const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ) :
const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ) :
EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type
m_fileName( aFileName ), m_sheetName( aSheetName ),
m_titleBlock( aTitleBlock ), m_pageInfo( aPageInfo ), m_sheetNumber( 1 ), m_sheetCount( 1 ) {} m_titleBlock( aTitleBlock ), m_pageInfo( aPageInfo ), m_sheetNumber( 1 ), m_sheetCount( 1 ) {}
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <climits> #include <climits>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <cmath>
#include <math/math_util.h> #include <math/math_util.h>
......
...@@ -47,8 +47,7 @@ class GAL; ...@@ -47,8 +47,7 @@ class GAL;
class WORKSHEET_VIEWITEM : public EDA_ITEM class WORKSHEET_VIEWITEM : public EDA_ITEM
{ {
public: public:
WORKSHEET_VIEWITEM( const std::string& aFileName, const std::string& aSheetName, WORKSHEET_VIEWITEM( const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock );
const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock );
/** /**
* Function SetFileName() * Function SetFileName()
......
...@@ -43,6 +43,8 @@ ...@@ -43,6 +43,8 @@
#include <reporter.h> #include <reporter.h>
#include <base_units.h> #include <base_units.h>
#include <ratsnest_data.h> #include <ratsnest_data.h>
#include <ratsnest_viewitem.h>
#include <worksheet_viewitem.h>
#include <pcbnew.h> #include <pcbnew.h>
#include <colors_selection.h> #include <colors_selection.h>
...@@ -104,7 +106,13 @@ BOARD::BOARD() : ...@@ -104,7 +106,13 @@ BOARD::BOARD() :
SetCurrentNetClass( m_NetClasses.GetDefault()->GetName() ); SetCurrentNetClass( m_NetClasses.GetDefault()->GetName() );
// Initialize ratsnest
m_ratsnest = new RN_DATA( this ); m_ratsnest = new RN_DATA( this );
m_ratsnestViewItem = new KIGFX::RATSNEST_VIEWITEM( m_ratsnest );
// Initialize view item for displaying worksheet frame
m_worksheetViewItem = new KIGFX::WORKSHEET_VIEWITEM( &m_paper, &m_titles );
m_worksheetViewItem->SetFileName( std::string( m_fileName.mb_str() ) );
} }
...@@ -116,10 +124,11 @@ BOARD::~BOARD() ...@@ -116,10 +124,11 @@ BOARD::~BOARD()
Delete( area_to_remove ); Delete( area_to_remove );
} }
delete m_worksheetViewItem;
delete m_ratsnestViewItem;
delete m_ratsnest; delete m_ratsnest;
m_FullRatsnest.clear(); m_FullRatsnest.clear();
m_LocalRatsnest.clear(); m_LocalRatsnest.clear();
DeleteMARKERs(); DeleteMARKERs();
......
...@@ -58,6 +58,12 @@ class NETLIST; ...@@ -58,6 +58,12 @@ class NETLIST;
class REPORTER; class REPORTER;
class RN_DATA; class RN_DATA;
namespace KIGFX
{
class RATSNEST_VIEWITEM;
class WORKSHEET_VIEWITEM;
}
// non-owning container of item candidates when searching for items on the same track. // non-owning container of item candidates when searching for items on the same track.
typedef std::vector< TRACK* > TRACK_PTRS; typedef std::vector< TRACK* > TRACK_PTRS;
...@@ -227,6 +233,8 @@ private: ...@@ -227,6 +233,8 @@ private:
EDA_RECT m_BoundingBox; EDA_RECT m_BoundingBox;
NETINFO_LIST m_NetInfo; ///< net info list (name, design constraints .. NETINFO_LIST m_NetInfo; ///< net info list (name, design constraints ..
RN_DATA* m_ratsnest; RN_DATA* m_ratsnest;
KIGFX::RATSNEST_VIEWITEM* m_ratsnestViewItem; ///< VIEW_ITEM that draws ratsnest
KIGFX::WORKSHEET_VIEWITEM* m_worksheetViewItem; ///< VIEW_ITEM that draws worksheet frame
BOARD_DESIGN_SETTINGS m_designSettings; BOARD_DESIGN_SETTINGS m_designSettings;
ZONE_SETTINGS m_zoneSettings; ZONE_SETTINGS m_zoneSettings;
...@@ -367,6 +375,24 @@ public: ...@@ -367,6 +375,24 @@ public:
return m_ratsnest; return m_ratsnest;
} }
/**
* Function GetRatsnestViewItem()
* returns VIEW_ITEM responsible for drawing the ratsnest for the board.
*/
KIGFX::RATSNEST_VIEWITEM* GetRatsnestViewItem() const
{
return m_ratsnestViewItem;
}
/**
* Function GetWorksheetViewItem()
* returns VIEW_ITEM responsible for drawing the worksheet frame.
*/
KIGFX::WORKSHEET_VIEWITEM* GetWorksheetViewItem() const
{
return m_worksheetViewItem;
}
/** /**
* Function DeleteMARKERs * Function DeleteMARKERs
* deletes ALL MARKERS from the board. * deletes ALL MARKERS from the board.
......
...@@ -596,26 +596,22 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const ...@@ -596,26 +596,22 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
view->Add( zone ); view->Add( zone );
} }
// Add an entry for the worksheet layout KIGFX::WORKSHEET_VIEWITEM* worksheet = aBoard->GetWorksheetViewItem();
KIGFX::WORKSHEET_VIEWITEM* worksheet = new KIGFX::WORKSHEET_VIEWITEM( worksheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) );
std::string( aBoard->GetFileName().mb_str() ),
std::string( GetScreenDesc().mb_str() ),
&GetPageSettings(), &GetTitleBlock() );
BASE_SCREEN* screen = GetScreen(); BASE_SCREEN* screen = GetScreen();
if( screen != NULL ) if( screen != NULL )
{ {
worksheet->SetSheetNumber( GetScreen()->m_ScreenNumber ); worksheet->SetSheetNumber( screen->m_ScreenNumber );
worksheet->SetSheetCount( GetScreen()->m_NumberOfScreens ); worksheet->SetSheetCount( screen->m_NumberOfScreens );
} }
view->Add( worksheet ); view->Add( worksheet );
view->Add( aBoard->GetRatsnestViewItem() );
// Add an entry for the ratsnest // Limit panning to the size of worksheet frame
RN_DATA* ratsnest = aBoard->GetRatsnest(); view->SetPanBoundary( aBoard->GetWorksheetViewItem()->ViewBBox() );
ratsnest->Recalculate();
view->Add( new KIGFX::RATSNEST_VIEWITEM( ratsnest ) );
view->SetPanBoundary( worksheet->ViewBBox() );
view->RecacheAllItems( true ); view->RecacheAllItems( true );
if( IsGalCanvasActive() ) if( IsGalCanvasActive() )
......
...@@ -338,9 +338,13 @@ void PNS_ROUTER::ClearWorld() ...@@ -338,9 +338,13 @@ void PNS_ROUTER::ClearWorld()
if( m_placer ) if( m_placer )
delete m_placer; delete m_placer;
if( m_previewItems )
delete m_previewItems;
m_clearanceFunc = NULL; m_clearanceFunc = NULL;
m_world = NULL; m_world = NULL;
m_placer = NULL; m_placer = NULL;
m_previewItems = NULL;
} }
......
...@@ -32,10 +32,14 @@ ...@@ -32,10 +32,14 @@
class PNS_SOLID : public PNS_ITEM class PNS_SOLID : public PNS_ITEM
{ {
public: public:
PNS_SOLID() : PNS_ITEM( SOLID ) PNS_SOLID() : PNS_ITEM( SOLID ), m_shape( NULL )
{ {
m_movable = false; m_movable = false;
m_shape = NULL; }
~PNS_SOLID()
{
delete m_shape;
} }
PNS_ITEM* Clone() const; PNS_ITEM* Clone() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment