diff --git a/eeschema/dialogs/dialog_label_properties.cpp b/eeschema/dialogs/dialog_label_properties.cpp index db9f2aec6a..38c0f07a0a 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 53b95fd9b7..9d8ef368a2 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -2329,3 +2329,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 7aa4169cbb..11c30a7ed3 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -756,6 +756,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;