diff --git a/eeschema/dialogs/dialog_label_properties.cpp b/eeschema/dialogs/dialog_label_properties.cpp index f9fe4928ee..a7ec329154 100644 --- a/eeschema/dialogs/dialog_label_properties.cpp +++ b/eeschema/dialogs/dialog_label_properties.cpp @@ -286,7 +286,11 @@ bool DIALOG_LABEL_PROPERTIES::TransferDataToWindow() for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_LOCATE_POWER_T ) ) { const SCH_SYMBOL* power = static_cast( item ); - existingLabels.insert( UnescapeString( power->GetValueFieldText( false ) ) ); + + // Ensure the symbol has the Power (i.e. equivalent to a global label + // before adding its value in list + if( power->IsSymbolLikePowerGlobalLabel() ) + existingLabels.insert( UnescapeString( power->GetValueFieldText( false ) ) ); } } diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 28c01c374c..ae725220a7 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -2279,3 +2279,22 @@ bool SCH_SYMBOL::IsPointClickableAnchor( const VECTOR2I& aPos ) const return false; } + + +bool SCH_SYMBOL::IsSymbolLikePowerGlobalLabel() const +{ + // return true if the symbol is equivalent to a global label: + // It is a Power symbol + // It has only one pin type Power input + + if( !GetLibSymbolRef() || !GetLibSymbolRef()->IsPower() ) + return false; + + std::vector pin_list = GetAllLibPins(); + + if( pin_list.size() != 1 ) + return false; + + return pin_list[0]->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN; +} + diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index 9c5ee0b314..b6b812b4cd 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -755,6 +755,13 @@ public: bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override; + /** + * @return true if the symbol is equivalent to a global label: + * It is a Power symbol + * It has only one pin type Power input + */ + bool IsSymbolLikePowerGlobalLabel() const; + private: BOX2I doGetBoundingBox( bool aIncludePins, bool aIncludeFields ) const;