Commit 218cb8e7 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: fix Bug #1325311 ("New Board" warning refusal broken)

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