*) Remove more wxString static constructors which were crashing in PAGE_INFO assignment

to a new BOARD in the footprint editor.  This is PAGE_INFO::A4 and company.
   
*) Remove static storage of the BOARD in the module editor.
This commit is contained in:
Dick Hollenbeck 2014-06-11 00:00:30 -05:00
parent 737ef50cc0
commit 3d311f831e
7 changed files with 56 additions and 74 deletions

View File

@ -38,21 +38,22 @@
// Standard paper sizes nicknames.
const wxString PAGE_INFO::A4( wxT( "A4" ) );
const wxString PAGE_INFO::A3( wxT( "A3" ) );
const wxString PAGE_INFO::A2( wxT( "A2" ) );
const wxString PAGE_INFO::A1( wxT( "A1" ) );
const wxString PAGE_INFO::A0( wxT( "A0" ) );
const wxString PAGE_INFO::A( wxT( "A" ) );
const wxString PAGE_INFO::B( wxT( "B" ) );
const wxString PAGE_INFO::C( wxT( "C" ) );
const wxString PAGE_INFO::D( wxT( "D" ) );
const wxString PAGE_INFO::E( wxT( "E" ) );
const wxString PAGE_INFO::GERBER( wxT( "GERBER" ) );
const wxString PAGE_INFO::USLetter( wxT( "USLetter" ) );
const wxString PAGE_INFO::USLegal( wxT( "USLegal" ) );
const wxString PAGE_INFO::USLedger( wxT( "USLedger" ) );
const wxString PAGE_INFO::Custom( wxT( "User" ) );
const wxChar PAGE_INFO::A4[] = wxT( "A4" );
const wxChar PAGE_INFO::A3[] = wxT( "A3" );
const wxChar PAGE_INFO::A2[] = wxT( "A2" );
const wxChar PAGE_INFO::A1[] = wxT( "A1" );
const wxChar PAGE_INFO::A0[] = wxT( "A0" );
const wxChar PAGE_INFO::A[] = wxT( "A" );
const wxChar PAGE_INFO::B[] = wxT( "B" ) ;
const wxChar PAGE_INFO::C[] = wxT( "C" );
const wxChar PAGE_INFO::D[] = wxT( "D" );
const wxChar PAGE_INFO::E[] = wxT( "E" );
const wxChar PAGE_INFO::GERBER[] = wxT( "GERBER" );
const wxChar PAGE_INFO::USLetter[] = wxT( "USLetter" );
const wxChar PAGE_INFO::USLegal[] = wxT( "USLegal" );
const wxChar PAGE_INFO::USLedger[] = wxT( "USLedger" );
const wxChar PAGE_INFO::Custom[] = wxT( "User" );
// Standard page sizes in mils, all constants

View File

@ -703,21 +703,21 @@ void DIALOG_PAGES_SETTINGS::GetPageLayoutInfoFromDialog()
{
PAGE_INFO pageInfo; // SetType() later to lookup size
static const wxString* papers[] = {
static const wxChar* papers[] = {
// longest common string first, since sequential search below
&PAGE_INFO::A4,
&PAGE_INFO::A3,
&PAGE_INFO::A2,
&PAGE_INFO::A1,
&PAGE_INFO::A0,
&PAGE_INFO::A,
&PAGE_INFO::B,
&PAGE_INFO::C,
&PAGE_INFO::D,
&PAGE_INFO::E,
&PAGE_INFO::USLetter,
&PAGE_INFO::USLegal,
&PAGE_INFO::USLedger,
PAGE_INFO::A4,
PAGE_INFO::A3,
PAGE_INFO::A2,
PAGE_INFO::A1,
PAGE_INFO::A0,
PAGE_INFO::A,
PAGE_INFO::B,
PAGE_INFO::C,
PAGE_INFO::D,
PAGE_INFO::E,
PAGE_INFO::USLetter,
PAGE_INFO::USLegal,
PAGE_INFO::USLedger,
};
unsigned i;

View File

@ -201,21 +201,22 @@ public:
// paper size names which are part of the public API, pass to SetType() or
// above constructor.
static const wxString A4;
static const wxString A3;
static const wxString A2;
static const wxString A1;
static const wxString A0;
static const wxString A;
static const wxString B;
static const wxString C;
static const wxString D;
static const wxString E;
static const wxString GERBER;
static const wxString USLetter;
static const wxString USLegal;
static const wxString USLedger;
static const wxString Custom; ///< "User" defined page type
// these were once wxStrings, but it caused static construction sequence problems:
static const wxChar A4[];
static const wxChar A3[];
static const wxChar A2[];
static const wxChar A1[];
static const wxChar A0[];
static const wxChar A[];
static const wxChar B[];
static const wxChar C[];
static const wxChar D[];
static const wxChar E[];
static const wxChar GERBER[];
static const wxChar USLetter[];
static const wxChar USLegal[];
static const wxChar USLedger[];
static const wxChar Custom[]; ///< "User" defined page type
/**

View File

@ -436,6 +436,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// and connexions are kept)
// and the source_module (old module) is deleted
PICKED_ITEMS_LIST pickList;
pcbframe->Exchange_Module( source_module, newmodule, &pickList );
newmodule->SetTimeStamp( module_in_edit->GetLink() );
@ -445,6 +446,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
else // This is an insert command
{
wxPoint cursor_pos = pcbframe->GetCrossHairPosition();
pcbframe->SetCrossHairPosition( wxPoint( 0, 0 ) );
pcbframe->PlaceModule( newmodule, NULL );
pcbframe->SetCrossHairPosition( cursor_pos );
@ -551,7 +553,9 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( GetBoard()->m_Modules )
{
SetCurItem( GetBoard()->m_Modules );
DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) GetScreen()-> GetCurItem() );
int ret = dialog.ShowModal();
GetScreen()->GetCurItem()->ClearFlags();

View File

@ -406,7 +406,6 @@ protected:
/// protected so only friend PCB::IFACE::CreateWindow() can act as sole factory.
FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent );
static BOARD* s_Pcb; ///< retain board across invocations of module editor
/**
* Function GetComponentFromUndoList

View File

@ -52,10 +52,6 @@
#include <wildcards_and_files_ext.h>
static PCB_SCREEN* s_screenModule; // the PCB_SCREEN used by the footprint editor
BOARD* FOOTPRINT_EDIT_FRAME::s_Pcb;
BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU_RANGE( ID_POPUP_PCB_ITEM_SELECTION_START, ID_POPUP_PCB_ITEM_SELECTION_END,
PCB_BASE_FRAME::ProcessItemSelection )
@ -170,32 +166,22 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
// Show a title (frame title + footprint name):
updateTitle();
if( !s_Pcb )
{
s_Pcb = new BOARD();
SetBoard( new BOARD() );
// Ensure all layers and items are visible:
s_Pcb->SetVisibleAlls();
}
GetBoard()->SetVisibleAlls();
SetBoard( s_Pcb );
if( !s_screenModule )
s_screenModule = new PCB_SCREEN( GetPageSettings().GetSizeIU() );
SetScreen( s_screenModule );
SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
GetScreen()->SetCurItem( NULL );
LoadSettings( config() );
GetBoard()->SetVisibleAlls();
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
// In modedit, set the default paper size to A4:
// this should be OK for all footprint to plot/print
SetPageSettings( PAGE_INFO::A4 );
SetPageSettings( PAGE_INFO( PAGE_INFO::A4 ) );
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
ReCreateMenuBar();
@ -244,15 +230,6 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME()
{
// When user reopens the Footprint editor, user would like to find the last edited item.
// Do not delete PCB_SCREEN (by the destructor of EDA_DRAW_FRAME)
SetScreen( NULL );
// Do not allow PCB_BASE_FRAME::~PCB_BASE_FRAME()
// to delete our precious BOARD, which is also in static FOOTPRINT_EDIT_FRAME::s_Pcb.
// That function, PCB_BASE_FRAME::~PCB_BASE_FRAME(), runs immediately next
// as we return from here.
m_Pcb = 0;
}

View File

@ -46,7 +46,7 @@ REVISION=$STABLE
# CMake Options
#OPTS="$OPTS -DBUILD_GITHUB_PLUGIN=OFF"
OPTS="$OPTS -DBUILD_GITHUB_PLUGIN=ON" # needed by $STABLE revision
# Python scripting, uncomment to enable
#OPTS="$OPTS -DKICAD_SCRIPTING=ON -DKICAD_SCRIPTING_MODULES=ON -DKICAD_SCRIPTING_WXPYTHON=ON"