Thank you Seth, it works now. @Jean-Pierre : I'll do what you suggested and iterate over screens instead of sheets.
Franck. Le ven. 25 sept. 2020 à 19:10, Seth Hillbrand <s...@kipro-pcb.com> a écrit : > > Hi Franck- > > You cannot delete items from the rtree while iterating over it, the > references are invalidated. You will need to collect the items to delete in > a separate vector and delete them outside of the loop. > > Seth > > On Fri, Sep 25, 2020, 7:29 AM Franck Jullien <franck.jull...@gmail.com> wrote: >> >> Hi, >> >> I'm working on the intersheets references functionality and I'm >> struggling with a segfault. >> Until now, I didn't try to remove iref from sheets. Now, I do this with: >> >> void SCH_EDIT_FRAME::RemoveAllIntersheetsRefs() >> { >> SCH_SHEET_LIST sheets = Schematic().GetSheets(); >> SCH_GLOBALLABEL* gLabel; >> >> m_labelTable.clear(); >> >> for( const SCH_SHEET_PATH& sheet : sheets ) >> { >> SCH_SCREEN* screen = sheet.LastScreen(); >> >> for( SCH_ITEM* item : screen->Items() ) >> { >> >> if( item->Type() == SCH_GLOBAL_LABEL_T ) >> { >> gLabel = (SCH_GLOBALLABEL*)( item ); >> SCH_IREF* iref = gLabel->GetIref(); >> >> if( iref ) >> { >> gLabel->SetIref( nullptr ); >> gLabel->SetIrefSavedPosition( wxDefaultPosition ); >> screen->DeleteItem( iref ); >> } >> } >> } >> } >> } >> >> As soon as I call DeleteItem (or RemoveFromScreen) I get a crash. >> Is there something obvious I don't see ? >> >> I still need to get familiar with screens, sheets, frames, canvas, views.... >> >> Thanks in advance. >> >> Franck. >> >> _______________________________________________ >> Mailing list: https://launchpad.net/~kicad-developers >> Post to : kicad-developers@lists.launchpad.net >> Unsubscribe : https://launchpad.net/~kicad-developers >> More help : https://help.launchpad.net/ListHelp _______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : kicad-developers@lists.launchpad.net Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp