Pcbnew: fix Bug #1325311 ("New Board" warning refusal broken)
This commit is contained in:
parent
59dfc053c2
commit
218cb8e7c1
|
@ -170,7 +170,8 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
|
|||
|
||||
case ID_NEW_BOARD:
|
||||
{
|
||||
Clear_Pcb( true );
|
||||
if( ! Clear_Pcb( true ) )
|
||||
break;
|
||||
|
||||
// Clear footprint library table for the new board.
|
||||
Prj().PcbFootprintLibs()->Clear();
|
||||
|
|
|
@ -3,10 +3,6 @@
|
|||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <class_draw_panel_gal.h>
|
||||
#include <view/view.h>
|
||||
#include <pcb_painter.h>
|
||||
#include <confirm.h>
|
||||
#include <wxPcbStruct.h>
|
||||
|
||||
|
@ -21,19 +17,16 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
|
|||
if( GetBoard() == NULL )
|
||||
return false;
|
||||
|
||||
if( aQuery )
|
||||
if( aQuery && GetScreen()->IsModify() && !GetBoard()->IsEmpty() )
|
||||
{
|
||||
if( GetBoard()->m_Drawings || GetBoard()->m_Modules
|
||||
|| GetBoard()->m_Track || GetBoard()->m_Zone )
|
||||
{
|
||||
if( !IsOK( this,
|
||||
_( "Current Board will be lost and this operation cannot be undone. Continue ?" ) ) )
|
||||
return false;
|
||||
}
|
||||
if( !IsOK( this,
|
||||
_( "Current Board will be lost and this operation cannot be undone. Continue ?" ) ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clear undo and redo lists because we want a full deletion
|
||||
GetScreen()->ClearUndoRedoList();
|
||||
GetScreen()->ClrModify();
|
||||
|
||||
// Items visibility flags will be set becuse a new board will be created.
|
||||
// Grid and ratsnest can be left to their previous state
|
||||
|
@ -84,14 +77,11 @@ bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery )
|
|||
if( GetBoard() == NULL )
|
||||
return false;
|
||||
|
||||
if( aQuery && GetScreen()->IsModify() )
|
||||
if( aQuery && GetScreen()->IsModify() && !GetBoard()->IsEmpty() )
|
||||
{
|
||||
if( GetBoard()->m_Modules )
|
||||
{
|
||||
if( !IsOK( this,
|
||||
_( "Current Footprint will be lost and this operation cannot be undone. Continue ?" ) ) )
|
||||
return false;
|
||||
}
|
||||
if( !IsOK( this,
|
||||
_( "Current Footprint will be lost and this operation cannot be undone. Continue ?" ) ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clear undo and redo lists
|
||||
|
|
|
@ -264,6 +264,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
case ID_OPEN_MODULE_VIEWER:
|
||||
{
|
||||
FOOTPRINT_VIEWER_FRAME* viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_PCB_MODULE_VIEWER, false );
|
||||
|
||||
if( !viewer )
|
||||
{
|
||||
viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_PCB_MODULE_VIEWER, true );
|
||||
|
@ -272,11 +273,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
if( viewer->IsIconized() )
|
||||
viewer->Iconize( false );
|
||||
*/
|
||||
|
||||
viewer->Raise();
|
||||
|
||||
// Raising the window does not set the focus on Linux. This should work on
|
||||
|
@ -293,7 +289,9 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
|
||||
case ID_MODEDIT_NEW_MODULE:
|
||||
{
|
||||
Clear_Pcb( true );
|
||||
if( ! Clear_Pcb( true ) )
|
||||
break;
|
||||
|
||||
GetScreen()->ClearUndoRedoList();
|
||||
SetCurItem( NULL );
|
||||
SetCrossHairPosition( wxPoint( 0, 0 ) );
|
||||
|
@ -319,35 +317,46 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
|
||||
case ID_MODEDIT_NEW_MODULE_FROM_WIZARD:
|
||||
{
|
||||
if( GetScreen()->IsModify() && !GetBoard()->IsEmpty() )
|
||||
{
|
||||
if( !IsOK( this,
|
||||
_( "Current Footprint will be lost and this operation cannot be undone. Continue ?" ) ) )
|
||||
break;
|
||||
}
|
||||
|
||||
FOOTPRINT_WIZARD_FRAME* wizard = (FOOTPRINT_WIZARD_FRAME*) Kiway().Player(
|
||||
FRAME_PCB_FOOTPRINT_WIZARD_MODAL, true );
|
||||
|
||||
wizard->Zoom_Automatique( false );
|
||||
|
||||
if( wizard->ShowModal() )
|
||||
if( wizard->ShowModal( NULL, this ) )
|
||||
{
|
||||
// Creates the new footprint from python script wizard
|
||||
MODULE* module = wizard->GetBuiltFootprint();
|
||||
|
||||
if( module ) // i.e. if create module command not aborted
|
||||
{
|
||||
Clear_Pcb( true );
|
||||
GetScreen()->ClearUndoRedoList();
|
||||
SetCurItem( NULL );
|
||||
SetCrossHairPosition( wxPoint( 0, 0 ) );
|
||||
if( module == NULL ) // i.e. if create module command aborted
|
||||
break;
|
||||
|
||||
// Add the new object to board
|
||||
module->SetParent( (EDA_ITEM*)GetBoard() );
|
||||
GetBoard()->m_Modules.Append( module );
|
||||
Clear_Pcb( false );
|
||||
|
||||
// Initialize data relative to nets and netclasses (for a new
|
||||
// module the defaults are used)
|
||||
// This is mandatory to handle and draw pads
|
||||
GetBoard()->BuildListOfNets();
|
||||
redraw = true;
|
||||
module->SetPosition( wxPoint( 0, 0 ) );
|
||||
module->ClearFlags();
|
||||
}
|
||||
GetScreen()->ClearUndoRedoList();
|
||||
SetCurItem( NULL );
|
||||
SetCrossHairPosition( wxPoint( 0, 0 ) );
|
||||
|
||||
// Add the new object to board
|
||||
module->SetParent( (EDA_ITEM*)GetBoard() );
|
||||
GetBoard()->m_Modules.Append( module );
|
||||
|
||||
// Initialize data relative to nets and netclasses (for a new
|
||||
// module the defaults are used)
|
||||
// This is mandatory to handle and draw pads
|
||||
GetBoard()->BuildListOfNets();
|
||||
redraw = true;
|
||||
module->SetPosition( wxPoint( 0, 0 ) );
|
||||
module->ClearFlags();
|
||||
|
||||
Zoom_Automatique( false );
|
||||
|
||||
if( m_Draw3DFrame )
|
||||
m_Draw3DFrame->NewDisplay();
|
||||
}
|
||||
|
||||
wizard->Destroy();
|
||||
|
@ -492,9 +501,9 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
case ID_MODEDIT_LOAD_MODULE:
|
||||
wxLogDebug( wxT( "Loading module from library " ) + getLibPath() );
|
||||
|
||||
GetScreen()->ClearUndoRedoList();
|
||||
SetCurItem( NULL );
|
||||
Clear_Pcb( true );
|
||||
if( ! Clear_Pcb( true ) )
|
||||
break;
|
||||
|
||||
SetCrossHairPosition( wxPoint( 0, 0 ) );
|
||||
|
||||
LoadModuleFromLibrary( getLibNickName(), Prj().PcbFootprintLibs(), true );
|
||||
|
@ -520,11 +529,10 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
val->SetType( TEXTE_MODULE::TEXT_is_VALUE ); // just in case ...
|
||||
|
||||
if( val->GetLength() == 0 )
|
||||
val->SetText( L"Val**" );
|
||||
val->SetText( wxT( "Val**" ) );
|
||||
}
|
||||
}
|
||||
|
||||
GetScreen()->ClrModify();
|
||||
Zoom_Automatique( false );
|
||||
|
||||
if( m_Draw3DFrame )
|
||||
|
|
Loading…
Reference in New Issue