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

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

parent 59dfc053
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -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();
+9 −19
Original line number Original line Diff line number Diff line
@@ -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 )
    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
            || GetBoard()->m_Track || GetBoard()->m_Zone )
    {
    {
        if( !IsOK( this,
        if( !IsOK( this,
                   _( "Current Board will be lost and this operation cannot be undone. Continue ?" ) ) )
                   _( "Current Board will be lost and this operation cannot be undone. Continue ?" ) ) )
            return false;
            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,15 +77,12 @@ 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,
        if( !IsOK( this,
                   _( "Current Footprint will be lost and this operation cannot be undone. Continue ?" ) ) )
                   _( "Current Footprint will be lost and this operation cannot be undone. Continue ?" ) ) )
            return false;
            return false;
    }
    }
    }


    // Clear undo and redo lists
    // Clear undo and redo lists
    GetScreen()->ClearUndoRedoList();
    GetScreen()->ClearUndoRedoList();
+41 −33
Original line number Original line Diff line number Diff line
@@ -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 )
            }
            }
            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 )


    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,19 +317,26 @@ 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 );

                Clear_Pcb( false );

                GetScreen()->ClearUndoRedoList();
                GetScreen()->ClearUndoRedoList();
                SetCurItem( NULL );
                SetCurItem( NULL );
                SetCrossHairPosition( wxPoint( 0, 0 ) );
                SetCrossHairPosition( wxPoint( 0, 0 ) );
@@ -347,7 +352,11 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
                redraw = true;
                redraw = true;
                module->SetPosition( wxPoint( 0, 0 ) );
                module->SetPosition( wxPoint( 0, 0 ) );
                module->ClearFlags();
                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 )
    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 )
                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 )