Commit 72c70148 authored by Maciej Suminski's avatar Maciej Suminski

Fixed a few memory leaks and Valgrind warnings.

parent da678809
...@@ -38,6 +38,7 @@ RENDER_SETTINGS::RENDER_SETTINGS() ...@@ -38,6 +38,7 @@ RENDER_SETTINGS::RENDER_SETTINGS()
m_highlightEnabled = false; m_highlightEnabled = false;
m_hiContrastEnabled = false; m_hiContrastEnabled = false;
m_hiContrastFactor = 0.2; m_hiContrastFactor = 0.2;
m_highlightNetcode = -1;
m_outlineWidth = 1; m_outlineWidth = 1;
m_worksheetLineWidth = 100000; m_worksheetLineWidth = 100000;
......
...@@ -47,6 +47,8 @@ public: ...@@ -47,6 +47,8 @@ public:
///> Copy constructor ///> Copy constructor
CONTEXT_MENU( const CONTEXT_MENU& aMenu ); CONTEXT_MENU( const CONTEXT_MENU& aMenu );
virtual ~CONTEXT_MENU() {};
/** /**
* Function SetTitle() * Function SetTitle()
* Sets title for the context menu. The title is shown as a text label shown on the top of * Sets title for the context menu. The title is shown as a text label shown on the top of
......
...@@ -117,9 +117,8 @@ protected: ...@@ -117,9 +117,8 @@ protected:
bool m_useCmpFileForFpNames; ///< is true, use the .cmp file from CvPcb, else use the netlist bool m_useCmpFileForFpNames; ///< is true, use the .cmp file from CvPcb, else use the netlist
// to know the footprint name of components. // to know the footprint name of components.
// Functions that handle the Tool Framework (de)initalization // The Tool Framework initalization
void setupTools(); void setupTools();
void destroyTools();
// we'll use lower case function names for private member functions. // we'll use lower case function names for private member functions.
void createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* aPopMenu ); void createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* aPopMenu );
......
...@@ -264,7 +264,6 @@ set( PCBNEW_CLASS_SRCS ...@@ -264,7 +264,6 @@ set( PCBNEW_CLASS_SRCS
tools/edit_tool.cpp tools/edit_tool.cpp
tools/pcbnew_control.cpp tools/pcbnew_control.cpp
tools/pcb_editor_control.cpp tools/pcb_editor_control.cpp
tools/pcb_tools.cpp
tools/placement_tool.cpp tools/placement_tool.cpp
tools/common_actions.cpp tools/common_actions.cpp
) )
......
...@@ -125,6 +125,9 @@ PCB_BASE_FRAME::~PCB_BASE_FRAME() ...@@ -125,6 +125,9 @@ PCB_BASE_FRAME::~PCB_BASE_FRAME()
{ {
delete m_Collector; delete m_Collector;
delete m_toolManager;
delete m_toolDispatcher;
delete m_Pcb; delete m_Pcb;
delete GetGalCanvas(); delete GetGalCanvas();
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <router/pns_routing_settings.h> #include <router/pns_routing_settings.h>
#include <base_units.h> #include <base_units.h>
#include <confirm.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::DIALOG_TRACK_VIA_SIZE( wxWindow* aParent, PNS_ROUTING_SETTINGS& aSettings ) :
DIALOG_TRACK_VIA_SIZE_BASE( aParent ), DIALOG_TRACK_VIA_SIZE_BASE( aParent ),
......
...@@ -587,6 +587,15 @@ LAYER_WIDGET::LAYER_WIDGET( wxWindow* aParent, wxWindow* aFocusOwner, int aPoint ...@@ -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 wxSize LAYER_WIDGET::GetBestSize() const
{ {
// size of m_LayerScrolledWindow -------------- // size of m_LayerScrolledWindow --------------
......
...@@ -227,6 +227,8 @@ public: ...@@ -227,6 +227,8 @@ public:
wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL ); const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL );
virtual ~LAYER_WIDGET();
/** /**
* Function GetBestSize * Function GetBestSize
* returns the preferred minimum size, taking into consideration the * returns the preferred minimum size, taking into consideration the
......
...@@ -70,6 +70,17 @@ ...@@ -70,6 +70,17 @@
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tool/tool_dispatcher.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) #if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON)
#include <python_scripting.h> #include <python_scripting.h>
// The name of the pane info handling the python console: // The name of the pane info handling the python console:
...@@ -469,7 +480,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : ...@@ -469,7 +480,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
PCB_EDIT_FRAME::~PCB_EDIT_FRAME() PCB_EDIT_FRAME::~PCB_EDIT_FRAME()
{ {
destroyTools();
m_RecordingMacros = -1; m_RecordingMacros = -1;
for( int i = 0; i < 10; i++ ) for( int i = 0; i < 10; i++ )
...@@ -524,6 +534,30 @@ bool PCB_EDIT_FRAME::isAutoSaveRequired() const ...@@ -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() void PCB_EDIT_FRAME::ReFillLayerWidget()
{ {
m_Layers->ReFill(); m_Layers->ReFill();
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
*/ */
#include "pns_routing_settings.h" #include "pns_routing_settings.h"
#include "direction.h"
PNS_ROUTING_SETTINGS::PNS_ROUTING_SETTINGS() PNS_ROUTING_SETTINGS::PNS_ROUTING_SETTINGS()
{ {
...@@ -39,6 +40,15 @@ 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 TIME_LIMIT PNS_ROUTING_SETTINGS::ShoveTimeLimit() const
{ {
return TIME_LIMIT ( m_shoveTimeLimit ); return TIME_LIMIT ( m_shoveTimeLimit );
......
...@@ -21,9 +21,10 @@ ...@@ -21,9 +21,10 @@
#ifndef __PNS_ROUTING_SETTINGS #ifndef __PNS_ROUTING_SETTINGS
#define __PNS_ROUTING_SETTINGS #define __PNS_ROUTING_SETTINGS
#include "direction.h"
#include "time_limit.h" #include "time_limit.h"
class DIRECTION_45;
///> Routing modes ///> Routing modes
enum PNS_MODE enum PNS_MODE
{ {
...@@ -118,13 +119,7 @@ public: ...@@ -118,13 +119,7 @@ public:
void SetViaDrill( int aDrill ) { m_viaDrill = aDrill; } void SetViaDrill( int aDrill ) { m_viaDrill = aDrill; }
int GetViaDrill() const { return m_viaDrill; } int GetViaDrill() const { return m_viaDrill; }
const DIRECTION_45 InitialDirection() const const DIRECTION_45 InitialDirection() const;
{
if( m_startDiagonal )
return DIRECTION_45( DIRECTION_45::NE );
else
return DIRECTION_45( DIRECTION_45::N );
}
int ShoveIterationLimit() const; int ShoveIterationLimit() const;
TIME_LIMIT ShoveTimeLimit() const; TIME_LIMIT ShoveTimeLimit() const;
......
...@@ -22,18 +22,13 @@ ...@@ -22,18 +22,13 @@
#ifndef __ROUTER_TOOL_H #ifndef __ROUTER_TOOL_H
#define __ROUTER_TOOL_H #define __ROUTER_TOOL_H
#include <set>
#include <boost/shared_ptr.hpp>
#include <import_export.h> #include <import_export.h>
#include <math/vector2d.h> #include <math/vector2d.h>
#include <tool/tool_interactive.h> #include <tool/tool_interactive.h>
#include <wxstruct.h>
#include <msgpanel.h> #include <msgpanel.h>
#include "pns_layerset.h"
#include "pns_routing_settings.h" #include "pns_routing_settings.h"
class PNS_ROUTER; class PNS_ROUTER;
......
/*
* 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;
}
...@@ -54,7 +54,7 @@ SELECTION_TOOL::SELECTION_TOOL() : ...@@ -54,7 +54,7 @@ SELECTION_TOOL::SELECTION_TOOL() :
SelectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.selected" ), SelectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.selected" ),
DeselectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.deselected" ), DeselectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.deselected" ),
ClearedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.cleared" ), 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_selArea = new SELECTION_AREA;
m_selection.group = new KIGFX::VIEW_GROUP; m_selection.group = new KIGFX::VIEW_GROUP;
......
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