kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #44525
Help needed
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.
Follow ups