Fix logic errors in DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

(We can't exit out if it doesn't match a particular type as we haven't
checked the other types yet.  Use a switch to prevent this.)

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15206

(cherry picked from commit a16033f624)
This commit is contained in:
Jeff Young 2023-07-16 14:11:10 +01:00
parent 9cf79ffb5a
commit 0562776b7a
1 changed files with 44 additions and 19 deletions

View File

@ -422,7 +422,9 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe
}
}
if( aItem->Type() == SCH_SYMBOL_T )
switch( aItem->Type() )
{
case SCH_SYMBOL_T:
{
SCH_SYMBOL* symbol = (SCH_SYMBOL*) aItem;
@ -446,8 +448,11 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe
}
}
}
break;
}
else if( aItem->Type() == SCH_SHEET_T )
case SCH_SHEET_T:
{
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem );
@ -488,19 +493,28 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe
for( SCH_SHEET_PIN* pin : sheet->GetPins() )
processItem( aSheetPath, pin );
}
break;
}
else if( m_wires->GetValue() && aItem->IsType( { SCH_ITEM_LOCATE_WIRE_T,
SCH_LABEL_LOCATE_WIRE_T } ) )
case SCH_LINE_T:
{
processItem( aSheetPath, aItem );
SCH_LINE* line = static_cast<SCH_LINE*>( aItem );
if( m_schTextAndGraphics->GetValue() && line->GetLayer() == LAYER_NOTES )
processItem( aSheetPath, aItem );
else if( m_wires->GetValue() && line->GetLayer() == LAYER_WIRE )
processItem( aSheetPath, aItem );
else if( m_buses->GetValue() && line->GetLayer() == LAYER_BUS )
processItem( aSheetPath, aItem );
break;
}
else if( m_buses->GetValue() && aItem->IsType( { SCH_ITEM_LOCATE_BUS_T,
SCH_LABEL_LOCATE_BUS_T } ) )
{
processItem( aSheetPath, aItem );
}
else if( aItem->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
{
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIER_LABEL_T:
case SCH_DIRECTIVE_LABEL_T:
if( m_globalLabels->GetValue() && aItem->Type() == SCH_GLOBAL_LABEL_T )
processItem( aSheetPath, aItem );
@ -520,8 +534,10 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe
}
}
}
}
else if( aItem->Type() == SCH_JUNCTION_T )
break;
case SCH_JUNCTION_T:
{
SCH_JUNCTION* junction = static_cast<SCH_JUNCTION*>( aItem );
@ -538,12 +554,20 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe
break;
}
}
break;
}
else if( m_schTextAndGraphics->GetValue() && aItem->IsType( { SCH_TEXT_T, SCH_TEXTBOX_T,
SCH_ITEM_LOCATE_GRAPHIC_LINE_T,
SCH_SHAPE_T } ) )
{
processItem( aSheetPath, aItem );
case SCH_TEXT_T:
case SCH_TEXTBOX_T:
case SCH_SHAPE_T:
if( m_schTextAndGraphics->GetValue() )
processItem( aSheetPath, aItem );
break;
default:
break;
}
}
@ -578,6 +602,7 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow()
// Reset the view to where we left the user
m_parent->SetCurrentSheet( currentSheet );
m_parent->Refresh();
return true;
}