sch groups/lines: correctly handle view lifetime and drawing in group

This commit is contained in:
Mike Williams 2025-04-16 13:23:47 -04:00
parent 6a24c5c5a4
commit 82043e374a
4 changed files with 20 additions and 1 deletions

View File

@ -262,6 +262,12 @@ void SCH_COMMIT::pushSchEdit( const wxString& aMessage, int aCommitFlags )
{
case CHT_ADD:
{
if( selTool && selTool->GetEnteredGroup() && !schItem->GetParentGroup()
&& SCH_GROUP::IsGroupableType( schItem->Type() ) )
{
selTool->GetEnteredGroup()->AddItem( schItem );
}
updateConnectivityFlag();
if( !( aCommitFlags & SKIP_UNDO ) )

View File

@ -27,6 +27,7 @@
#include <eeschema_settings.h>
#include <eda_item.h>
#include <sch_connection.h>
#include <sch_group.h>
#include <sch_item.h>
#include <sch_screen.h>
#include <sch_sheet_path.h>
@ -135,6 +136,9 @@ SCH_ITEM* SCH_ITEM::Duplicate( bool doClone ) const
if( !doClone )
const_cast<KIID&>( newItem->m_Uuid ) = KIID();
if( newItem->GetParentGroup() )
newItem->GetParentGroup()->AddItem( newItem );
newItem->ClearFlags( SELECTED | BRIGHTENED );
newItem->RunOnChildren(

View File

@ -90,6 +90,12 @@ SCH_LINE::SCH_LINE( const SCH_LINE& aLine ) :
m_lastResolvedColor = aLine.m_lastResolvedColor;
m_operatingPoint = aLine.m_operatingPoint;
// Don't apply groups to cloned lines. We have too many areas where we clone them
// temporarily, then modify/split/join them in the line movement routines after the
// segments are committed. Rely on the commit framework to add the lines to the
// entered group as appropriate.
m_group = nullptr;
}

View File

@ -3088,7 +3088,10 @@ void SCH_SELECTION_TOOL::ClearSelection( bool aQuietMode )
void SCH_SELECTION_TOOL::select( EDA_ITEM* aItem )
{
if( m_enteredGroup && !SCH_GROUP::WithinScope( static_cast<SCH_ITEM*>( aItem ), m_enteredGroup, m_isSymbolEditor ) )
// Don't group when we select new items, the schematic editor selects all new items for moving.
// The PCB editor doesn't need this logic because it doesn't select new items for moving.
if( m_enteredGroup && !aItem->IsNew()
&& !SCH_GROUP::WithinScope( static_cast<SCH_ITEM*>( aItem ), m_enteredGroup, m_isSymbolEditor ) )
{
ExitGroup();
}