Commit 78670eeb authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Pcbnew: Fix a crash on exit when an item was previously deleted. Fix not...

Pcbnew: Fix a crash on exit when an item was previously deleted. Fix not working footprint exchange functions
parent 44bb2e6d
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -127,6 +127,16 @@ public:

    ~PCB_BASE_FRAME();

    /**
     * Function LoadFootprint
     * attempts to load \a aFootprintId from the footprint library table.
     *
     * @param aFootprintId is the #FPID of component footprint to load.
     * @return the #MODULE if found or NULL if \a aFootprintId not found in any of the
     *         libraries in #m_footprintLibTable.
     */
    MODULE* LoadFootprint( const FPID& aFootprintId );

    /**
     * Function GetBoardBoundingBox
     * calculates the bounding box containing all board items (or board edge segments).
+36 −1
Original line number Diff line number Diff line
@@ -336,7 +336,22 @@ MODULE* PCB_BASE_FRAME::loadFootprintFromLibrary( const wxString& aLibraryPath,
    {
        PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );

        wxString libPath = wxGetApp().FindLibraryPath( aLibraryPath );
        // Ensure the library name has the right extension
        // (sometimes the name is given without ext)
        wxString libname = aLibraryPath;

        if( !libname.EndsWith( wxT(".") + LegacyFootprintLibPathExtension) )
            libname <<  wxT(".") << LegacyFootprintLibPathExtension;

        wxString libPath = wxGetApp().FindLibraryPath( libname );

        if( libPath.IsEmpty() )
        {
            wxString msg = wxString::Format( _( "Library '%s' not found." ),
                                             libname.GetData() );
            DisplayError( NULL, msg );
            return NULL;
        }

        MODULE* footprint = pi->FootprintLoad( libPath, aFootprintName );

@@ -429,6 +444,26 @@ MODULE* PCB_BASE_FRAME::loadFootprintFromLibraries(
    return NULL;
}

/* attempts to load aFootprintId from the footprint library table.
 * return the #MODULE if found or NULL if not found or error.
 */
MODULE* PCB_BASE_FRAME::LoadFootprint( const FPID& aFootprintId )
{
    MODULE* module = NULL;

    try
    {
        module = loadFootprint( aFootprintId );
    }
    catch( IO_ERROR ioe )
    {
        wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ),
                    aFootprintId.Format().c_str(), GetChars( ioe.errorText ) );
    }

    return module;
}


MODULE* PCB_BASE_FRAME::loadFootprint( const FPID& aFootprintId )
    throw( IO_ERROR, PARSE_ERROR )
+7 −3
Original line number Diff line number Diff line
@@ -598,6 +598,10 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )

    SaveSettings();

    // Delete board structs and undo/redo lists, to avoid crash on exit
    // when deleting some structs (mainly in undo/redo lists) too late
    Clear_Pcb( false );

    // do not show the window because ScreenPcb will be deleted and we do not
    // want any paint event
    Show( false );
+149 −151

File changed.

Preview size limit exceeded, changes collapsed.