Fixed a few memory leaks and Valgrind warnings.

This commit is contained in:
Maciej Suminski 2014-07-09 15:02:56 +02:00
parent da67880907
commit 72c70148e8
14 changed files with 68 additions and 89 deletions

View File

@ -38,6 +38,7 @@ RENDER_SETTINGS::RENDER_SETTINGS()
m_highlightEnabled = false;
m_hiContrastEnabled = false;
m_hiContrastFactor = 0.2;
m_highlightNetcode = -1;
m_outlineWidth = 1;
m_worksheetLineWidth = 100000;

View File

@ -47,6 +47,8 @@ public:
///> Copy constructor
CONTEXT_MENU( const CONTEXT_MENU& aMenu );
virtual ~CONTEXT_MENU() {};
/**
* Function SetTitle()
* Sets title for the context menu. The title is shown as a text label shown on the top of

View File

@ -117,9 +117,8 @@ protected:
bool m_useCmpFileForFpNames; ///< is true, use the .cmp file from CvPcb, else use the netlist
// to know the footprint name of components.
// Functions that handle the Tool Framework (de)initalization
// The Tool Framework initalization
void setupTools();
void destroyTools();
// we'll use lower case function names for private member functions.
void createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* aPopMenu );

View File

@ -264,7 +264,6 @@ set( PCBNEW_CLASS_SRCS
tools/edit_tool.cpp
tools/pcbnew_control.cpp
tools/pcb_editor_control.cpp
tools/pcb_tools.cpp
tools/placement_tool.cpp
tools/common_actions.cpp
)

View File

@ -125,6 +125,9 @@ PCB_BASE_FRAME::~PCB_BASE_FRAME()
{
delete m_Collector;
delete m_toolManager;
delete m_toolDispatcher;
delete m_Pcb;
delete GetGalCanvas();
}

View File

@ -26,6 +26,7 @@
#include <router/pns_routing_settings.h>
#include <base_units.h>
#include <confirm.h>
#include <boost/optional.hpp>
DIALOG_TRACK_VIA_SIZE::DIALOG_TRACK_VIA_SIZE( wxWindow* aParent, PNS_ROUTING_SETTINGS& aSettings ) :
DIALOG_TRACK_VIA_SIZE_BASE( aParent ),

View File

@ -587,6 +587,15 @@ LAYER_WIDGET::LAYER_WIDGET( wxWindow* aParent, wxWindow* aFocusOwner, int aPoint
}
LAYER_WIDGET::~LAYER_WIDGET()
{
delete m_BlankBitmap;
delete m_BlankAlternateBitmap;
delete m_RightArrowBitmap;
delete m_RightArrowAlternateBitmap;
}
wxSize LAYER_WIDGET::GetBestSize() const
{
// size of m_LayerScrolledWindow --------------

View File

@ -227,6 +227,8 @@ public:
wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL );
virtual ~LAYER_WIDGET();
/**
* Function GetBestSize
* returns the preferred minimum size, taking into consideration the

View File

@ -70,6 +70,17 @@
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tools/selection_tool.h>
#include <router/router_tool.h>
#include <tools/edit_tool.h>
#include <tools/drawing_tool.h>
#include <tools/point_editor.h>
#include <tools/pcbnew_control.h>
#include <tools/pcb_editor_control.h>
#include <tools/placement_tool.h>
#include <tools/common_actions.h>
#if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON)
#include <python_scripting.h>
// The name of the pane info handling the python console:
@ -469,7 +480,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
PCB_EDIT_FRAME::~PCB_EDIT_FRAME()
{
destroyTools();
m_RecordingMacros = -1;
for( int i = 0; i < 10; i++ )
@ -524,6 +534,30 @@ bool PCB_EDIT_FRAME::isAutoSaveRequired() const
}
void PCB_EDIT_FRAME::setupTools()
{
// Create the manager and dispatcher & route draw panel events to the dispatcher
m_toolManager = new TOOL_MANAGER;
m_toolManager->SetEnvironment( NULL, GetGalCanvas()->GetView(),
GetGalCanvas()->GetViewControls(), this );
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
// Register tools
m_toolManager->RegisterTool( new SELECTION_TOOL );
m_toolManager->RegisterTool( new ROUTER_TOOL );
m_toolManager->RegisterTool( new EDIT_TOOL );
m_toolManager->RegisterTool( new DRAWING_TOOL );
m_toolManager->RegisterTool( new POINT_EDITOR );
m_toolManager->RegisterTool( new PCBNEW_CONTROL );
m_toolManager->RegisterTool( new PCB_EDITOR_CONTROL );
m_toolManager->RegisterTool( new PLACEMENT_TOOL );
m_toolManager->ResetTools( TOOL_BASE::RUN );
// Run the selection tool, it is supposed to be always active
m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
}
void PCB_EDIT_FRAME::ReFillLayerWidget()
{
m_Layers->ReFill();

View File

@ -19,6 +19,7 @@
*/
#include "pns_routing_settings.h"
#include "direction.h"
PNS_ROUTING_SETTINGS::PNS_ROUTING_SETTINGS()
{
@ -39,6 +40,15 @@ PNS_ROUTING_SETTINGS::PNS_ROUTING_SETTINGS()
}
const DIRECTION_45 PNS_ROUTING_SETTINGS::InitialDirection() const
{
if( m_startDiagonal )
return DIRECTION_45( DIRECTION_45::NE );
else
return DIRECTION_45( DIRECTION_45::N );
}
TIME_LIMIT PNS_ROUTING_SETTINGS::ShoveTimeLimit() const
{
return TIME_LIMIT ( m_shoveTimeLimit );

View File

@ -21,8 +21,9 @@
#ifndef __PNS_ROUTING_SETTINGS
#define __PNS_ROUTING_SETTINGS
#include "direction.h"
#include "time_limit.h"
class DIRECTION_45;
///> Routing modes
enum PNS_MODE
@ -118,13 +119,7 @@ public:
void SetViaDrill( int aDrill ) { m_viaDrill = aDrill; }
int GetViaDrill() const { return m_viaDrill; }
const DIRECTION_45 InitialDirection() const
{
if( m_startDiagonal )
return DIRECTION_45( DIRECTION_45::NE );
else
return DIRECTION_45( DIRECTION_45::N );
}
const DIRECTION_45 InitialDirection() const;
int ShoveIterationLimit() const;
TIME_LIMIT ShoveTimeLimit() const;

View File

@ -22,18 +22,13 @@
#ifndef __ROUTER_TOOL_H
#define __ROUTER_TOOL_H
#include <set>
#include <boost/shared_ptr.hpp>
#include <import_export.h>
#include <math/vector2d.h>
#include <tool/tool_interactive.h>
#include <wxstruct.h>
#include <msgpanel.h>
#include "pns_layerset.h"
#include "pns_routing_settings.h"
class PNS_ROUTER;

View File

@ -1,71 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <wxPcbStruct.h>
#include <wxBasePcbFrame.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <class_draw_panel_gal.h>
#include "selection_tool.h"
#include "edit_tool.h"
#include "drawing_tool.h"
#include "point_editor.h"
#include "pcbnew_control.h"
#include "pcb_editor_control.h"
#include "placement_tool.h"
#include "common_actions.h"
#include <router/router_tool.h>
void PCB_EDIT_FRAME::setupTools()
{
// Create the manager and dispatcher & route draw panel events to the dispatcher
m_toolManager = new TOOL_MANAGER;
m_toolManager->SetEnvironment( NULL, GetGalCanvas()->GetView(),
GetGalCanvas()->GetViewControls(), this );
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
// Register tools
m_toolManager->RegisterTool( new SELECTION_TOOL );
m_toolManager->RegisterTool( new ROUTER_TOOL );
m_toolManager->RegisterTool( new EDIT_TOOL );
m_toolManager->RegisterTool( new DRAWING_TOOL );
m_toolManager->RegisterTool( new POINT_EDITOR );
m_toolManager->RegisterTool( new PCBNEW_CONTROL );
m_toolManager->RegisterTool( new PCB_EDITOR_CONTROL );
m_toolManager->RegisterTool( new PLACEMENT_TOOL );
m_toolManager->ResetTools( TOOL_BASE::RUN );
// Run the selection tool, it is supposed to be always active
m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
}
void PCB_EDIT_FRAME::destroyTools()
{
delete m_toolManager;
delete m_toolDispatcher;
}

View File

@ -54,7 +54,7 @@ SELECTION_TOOL::SELECTION_TOOL() :
SelectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.selected" ),
DeselectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.deselected" ),
ClearedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.cleared" ),
m_additive( false ), m_multiple( false ), m_editModules( false )
m_frame( NULL ), m_additive( false ), m_multiple( false ), m_editModules( false )
{
m_selArea = new SELECTION_AREA;
m_selection.group = new KIGFX::VIEW_GROUP;