7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-07 21:55:32 +00:00

Attempt to fix std::initializer_list lifetime issue.

This commit is contained in:
Jeff Young 2022-08-21 20:54:07 +01:00
parent 88c9177ff6
commit 4f0136db3b
52 changed files with 164 additions and 165 deletions

View File

@ -90,7 +90,7 @@ EDA_ITEM* EDA_ITEM::Clone() const
// see base_struct.h
// many classes inherit this method, be careful:
INSPECT_RESULT EDA_ITEM::Visit( INSPECTOR inspector, void* testData,
const std::initializer_list<KICAD_T>& aScanTypes )
const std::vector<KICAD_T>& aScanTypes )
{
#if 0 && defined(DEBUG)
std::cout << GetClass().mb_str() << ' ';

View File

@ -64,13 +64,13 @@ SELECTION_CONDITION SELECTION_CONDITIONS::HasType( KICAD_T aType )
}
SELECTION_CONDITION SELECTION_CONDITIONS::HasTypes( const std::initializer_list<KICAD_T>& aTypes )
SELECTION_CONDITION SELECTION_CONDITIONS::HasTypes( std::vector<KICAD_T> aTypes )
{
return std::bind( &SELECTION_CONDITIONS::hasTypesFunc, _1, aTypes );
}
SELECTION_CONDITION SELECTION_CONDITIONS::OnlyTypes( const std::initializer_list<KICAD_T>& aTypes )
SELECTION_CONDITION SELECTION_CONDITIONS::OnlyTypes( std::vector<KICAD_T> aTypes )
{
return std::bind( &SELECTION_CONDITIONS::onlyTypesFunc, _1, aTypes );
}
@ -109,8 +109,7 @@ bool SELECTION_CONDITIONS::hasTypeFunc( const SELECTION& aSelection, KICAD_T aTy
}
bool SELECTION_CONDITIONS::hasTypesFunc( const SELECTION& aSelection,
const std::initializer_list<KICAD_T>& aTypes )
bool SELECTION_CONDITIONS::hasTypesFunc( const SELECTION& aSelection, std::vector<KICAD_T> aTypes )
{
if( aSelection.Empty() )
return false;
@ -125,8 +124,7 @@ bool SELECTION_CONDITIONS::hasTypesFunc( const SELECTION& aSelection,
}
bool SELECTION_CONDITIONS::onlyTypesFunc( const SELECTION& aSelection,
const std::initializer_list<KICAD_T>& aTypes )
bool SELECTION_CONDITIONS::onlyTypesFunc( const SELECTION& aSelection, std::vector<KICAD_T> aTypes )
{
if( aSelection.Empty() )
return false;

View File

@ -36,7 +36,7 @@
#include "sch_reference_list.h"
const std::initializer_list<KICAD_T> EE_COLLECTOR::EditableItems = {
const std::vector<KICAD_T> EE_COLLECTOR::EditableItems = {
SCH_SHAPE_T,
SCH_TEXT_T,
SCH_TEXTBOX_T,
@ -55,7 +55,7 @@ const std::initializer_list<KICAD_T> EE_COLLECTOR::EditableItems = {
};
const std::initializer_list<KICAD_T> EE_COLLECTOR::MovableItems =
const std::vector<KICAD_T> EE_COLLECTOR::MovableItems =
{
SCH_MARKER_T,
SCH_JUNCTION_T,
@ -78,7 +78,7 @@ const std::initializer_list<KICAD_T> EE_COLLECTOR::MovableItems =
};
const std::initializer_list<KICAD_T> EE_COLLECTOR::FieldOwners = {
const std::vector<KICAD_T> EE_COLLECTOR::FieldOwners = {
SCH_SYMBOL_T,
SCH_SHEET_T,
SCH_LABEL_LOCATE_ANY_T
@ -116,8 +116,7 @@ INSPECT_RESULT EE_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData )
}
void EE_COLLECTOR::Collect( SCH_SCREEN* aScreen,
const std::initializer_list<KICAD_T>& aFilterList,
void EE_COLLECTOR::Collect( SCH_SCREEN* aScreen, const std::vector<KICAD_T>& aFilterList,
const VECTOR2I& aPos, int aUnit, int aConvert )
{
Empty(); // empty the collection just in case
@ -137,8 +136,7 @@ void EE_COLLECTOR::Collect( SCH_SCREEN* aScreen,
}
void EE_COLLECTOR::Collect( LIB_ITEMS_CONTAINER& aItems,
const std::initializer_list<KICAD_T>& aFilterList,
void EE_COLLECTOR::Collect( LIB_ITEMS_CONTAINER& aItems, const std::vector<KICAD_T>& aFilterList,
const VECTOR2I& aPos, int aUnit, int aConvert )
{
Empty(); // empty the collection just in case

View File

@ -39,11 +39,11 @@ class SCH_SYMBOL;
class EE_COLLECTOR : public COLLECTOR
{
public:
static const std::initializer_list<KICAD_T> EditableItems;
static const std::initializer_list<KICAD_T> MovableItems;
static const std::initializer_list<KICAD_T> FieldOwners;
static const std::vector<KICAD_T> EditableItems;
static const std::vector<KICAD_T> MovableItems;
static const std::vector<KICAD_T> FieldOwners;
EE_COLLECTOR( const std::initializer_list<KICAD_T>& aScanTypes = { SCH_LOCATE_ANY_T } ) :
EE_COLLECTOR( const std::vector<KICAD_T>& aScanTypes = { SCH_LOCATE_ANY_T } ) :
m_Unit( 0 ),
m_Convert( 0 ),
m_ShowPinElectricalTypes( false )
@ -71,26 +71,26 @@ public:
* Scan a #EDA_ITEM using this class's Inspector method which does the collection.
*
* @param aScreen The eeschema screen to use for scanning
* @param aFilterList A list of #KICAD_T types that determines what is to be collected and
* the priority order of the resulting collection.
* @param aScanTypes A list of #KICAD_T types that determines what is to be collected and
* the priority order of the resulting collection.
* @param aPos are the coordinates to use in hit testing.
* @param aUnit is the symbol unit filter (for symbol editor).
* @param aConvert is the DeMorgan filter (for symbol editor)
*/
void Collect( SCH_SCREEN* aScreen, const std::initializer_list<KICAD_T>& aFilterList,
void Collect( SCH_SCREEN* aScreen, const std::vector<KICAD_T>& aScanTypes,
const VECTOR2I& aPos, int aUnit = 0, int aConvert = 0 );
/**
* Scan an #EDA_ITEM using this class's Inspector method which does the collection.
*
* @param aItems is a LIB_SYMBOL multivector holding the symbol items.
* @param aFilterList is a list of #KICAD_T types that determines what is to be collected
* and the priority order of the resulting collection.
* @param aScanTypes is a list of #KICAD_T types that determines what is to be collected
* and the priority order of the resulting collection.
* @param aPos are the coordinates to use in hit testing.
* @param aUnit is the symbol unit filter (for symbol editor).
* @param aConvert is the DeMorgan filter (for symbol editor).
*/
void Collect( LIB_ITEMS_CONTAINER& aItems, const std::initializer_list<KICAD_T>& aFilterList,
void Collect( LIB_ITEMS_CONTAINER& aItems, const std::vector<KICAD_T>& aScanTypes,
const VECTOR2I& aPos, int aUnit = 0, int aConvert = 0 );
/**

View File

@ -1238,7 +1238,7 @@ LIB_ITEM* LIB_SYMBOL::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType,
INSPECT_RESULT LIB_SYMBOL::Visit( INSPECTOR aInspector, void* aTestData,
const std::initializer_list<KICAD_T>& aScanTypes )
const std::vector<KICAD_T>& aScanTypes )
{
// The part itself is never inspected, only its children
for( LIB_ITEM& item : m_drawings )

View File

@ -503,7 +503,7 @@ public:
const LIB_ITEMS_CONTAINER& GetDrawItems() const { return m_drawings; }
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
const std::initializer_list<KICAD_T>& aScanTypes ) override;
const std::vector<KICAD_T>& aScanTypes ) override;
/**
* Set the units per symbol count.

View File

@ -69,7 +69,7 @@ public:
return wxT( "SCH_FIELD" );
}
bool IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const override
bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
{
if( SCH_ITEM::IsType( aScanTypes ) )
return true;

View File

@ -157,7 +157,7 @@ public:
return wxT( "SCH_ITEM" );
}
bool IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const override
bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
{
if( EDA_ITEM::IsType( aScanTypes ) )
return true;

View File

@ -190,7 +190,7 @@ const wxString SCH_LABEL_BASE::GetDefaultFieldName( const wxString& aName, bool
}
bool SCH_LABEL_BASE::IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const
bool SCH_LABEL_BASE::IsType( const std::vector<KICAD_T>& aScanTypes ) const
{
if( SCH_TEXT::IsType( aScanTypes ) )
return true;
@ -542,7 +542,7 @@ void SCH_LABEL_BASE::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFun
INSPECT_RESULT SCH_LABEL_BASE::Visit( INSPECTOR aInspector, void* testData,
const std::initializer_list<KICAD_T>& aScanTypes )
const std::vector<KICAD_T>& aScanTypes )
{
if( IsType( aScanTypes ) )
{

View File

@ -44,7 +44,7 @@ public:
// Abstract class
virtual wxString GetClass() const override = 0;
bool IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const override;
bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override;
void SwapData( SCH_ITEM* aItem ) override;
@ -120,7 +120,7 @@ public:
void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
const std::initializer_list<KICAD_T>& scanTypes ) override;
const std::vector<KICAD_T>& scanTypes ) override;
VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;

View File

@ -67,7 +67,7 @@ public:
*/
wxString GetNetname(const SCH_SHEET_PATH &aSheet);
bool IsType( const std::initializer_list<KICAD_T>& aScanTypes ) const override
bool IsType( const std::vector<KICAD_T>& aScanTypes ) const override
{
if( SCH_ITEM::IsType( aScanTypes ) )
return true;

View File

@ -74,7 +74,7 @@ EESCHEMA_SETTINGS* eeconfig()
}
std::initializer_list<KICAD_T> SCH_PAINTER::g_ScaledSelectionTypes = {
std::vector<KICAD_T> SCH_PAINTER::g_ScaledSelectionTypes = {
SCH_MARKER_T,
SCH_JUNCTION_T,
SCH_NO_CONNECT_T,

View File

@ -195,7 +195,7 @@ private:
void boxText( const wxString& aText, const VECTOR2D& aPosition, const TEXT_ATTRIBUTES& aAttrs );
public:
static std::initializer_list<KICAD_T> g_ScaledSelectionTypes;
static std::vector<KICAD_T> g_ScaledSelectionTypes;
private:
SCH_RENDER_SETTINGS m_schSettings;

View File

@ -944,7 +944,7 @@ std::vector<VECTOR2I> SCH_SHEET::GetConnectionPoints() const
INSPECT_RESULT SCH_SHEET::Visit( INSPECTOR aInspector, void* testData,
const std::initializer_list<KICAD_T>& aScanTypes )
const std::vector<KICAD_T>& aScanTypes )
{
for( KICAD_T scanType : aScanTypes )
{

View File

@ -351,7 +351,7 @@ public:
std::vector<VECTOR2I> GetConnectionPoints() const override;
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
const std::initializer_list<KICAD_T>& aScanTypes ) override;
const std::vector<KICAD_T>& aScanTypes ) override;
void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;

View File

@ -1717,7 +1717,7 @@ wxString SCH_SYMBOL::GetSelectMenuText( EDA_UNITS aUnits ) const
INSPECT_RESULT SCH_SYMBOL::Visit( INSPECTOR aInspector, void* aTestData,
const std::initializer_list<KICAD_T>& aScanTypes )
const std::vector<KICAD_T>& aScanTypes )
{
for( KICAD_T scanType : aScanTypes )
{

View File

@ -639,7 +639,7 @@ public:
std::vector<VECTOR2I> GetConnectionPoints() const override;
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
const std::initializer_list<KICAD_T>& aScanTypes ) override;
const std::vector<KICAD_T>& aScanTypes ) override;
/**
* Return the symbol library item at \a aPosition that is part of this symbol.

View File

@ -144,7 +144,7 @@ EE_SELECTION_TOOL::~EE_SELECTION_TOOL()
using E_C = EE_CONDITIONS;
static std::initializer_list<KICAD_T> connectedTypes =
static std::vector<KICAD_T> connectedTypes =
{
SCH_SYMBOL_LOCATE_POWER_T,
SCH_PIN_T,
@ -777,7 +777,7 @@ EE_SELECTION& EE_SELECTION_TOOL::GetSelection()
bool EE_SELECTION_TOOL::CollectHits( EE_COLLECTOR& aCollector, const VECTOR2I& aWhere,
const std::initializer_list<KICAD_T>& aFilterList )
const std::vector<KICAD_T>& aScanTypes )
{
int pixelThreshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
int gridThreshold = KiROUND( getView()->GetGAL()->GetGridSize().EuclideanNorm() / 2 );
@ -791,11 +791,11 @@ bool EE_SELECTION_TOOL::CollectHits( EE_COLLECTOR& aCollector, const VECTOR2I& a
if( !symbol )
return false;
aCollector.Collect( symbol->GetDrawItems(), aFilterList, aWhere, m_unit, m_convert );
aCollector.Collect( symbol->GetDrawItems(), aScanTypes, aWhere, m_unit, m_convert );
}
else
{
aCollector.Collect( m_frame->GetScreen(), aFilterList, aWhere, m_unit, m_convert );
aCollector.Collect( m_frame->GetScreen(), aScanTypes, aWhere, m_unit, m_convert );
if( m_frame->eeconfig()->m_Selection.select_pin_selects_symbol )
{
@ -933,14 +933,14 @@ bool EE_SELECTION_TOOL::selectPoint( EE_COLLECTOR& aCollector, const VECTOR2I& a
bool EE_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere,
const std::initializer_list<KICAD_T>& aFilterList,
const std::vector<KICAD_T>& aScanTypes,
EDA_ITEM** aItem, bool* aSelectionCancelledFlag,
bool aCheckLocked, bool aAdd, bool aSubtract,
bool aExclusiveOr )
{
EE_COLLECTOR collector;
if( !CollectHits( collector, aWhere, aFilterList ) )
if( !CollectHits( collector, aWhere, aScanTypes ) )
return false;
narrowSelection( collector, aWhere, aCheckLocked );
@ -1142,15 +1142,14 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const
}
EE_SELECTION&
EE_SELECTION_TOOL::RequestSelection( const std::initializer_list<KICAD_T>& aFilterList )
EE_SELECTION& EE_SELECTION_TOOL::RequestSelection( const std::vector<KICAD_T>& aScanTypes )
{
if( m_selection.Empty() )
{
VECTOR2D cursorPos = getViewControls()->GetCursorPosition( true );
ClearSelection();
SelectPoint( cursorPos, aFilterList );
SelectPoint( cursorPos, aScanTypes );
m_selection.SetIsHover( true );
m_selection.ClearReferencePoint();
}
@ -1164,7 +1163,7 @@ EE_SELECTION_TOOL::RequestSelection( const std::initializer_list<KICAD_T>& aFilt
EDA_ITEM* item = (EDA_ITEM*) m_selection.GetItem( i );
isMoving |= static_cast<SCH_ITEM*>( item )->IsMoving();
if( !item->IsType( aFilterList ) )
if( !item->IsType( aScanTypes ) )
{
unselect( item );
anyUnselected = true;

View File

@ -81,16 +81,18 @@ public:
/**
* Return either an existing selection (filtered), or the selection at the current
* cursor if the existing selection is empty.
*
* @param aScanTypes an optional type filter indicating the legal KICAD_Ts to be returned.
* @return either the current selection or, if empty, the selection at the cursor.
*/
EE_SELECTION&
RequestSelection( const std::initializer_list<KICAD_T>& aFilterList = { SCH_LOCATE_ANY_T } );
EE_SELECTION& RequestSelection( const std::vector<KICAD_T>& aScanTypes = { SCH_LOCATE_ANY_T } );
/**
* This overload of SelectPoint will create an EE_COLLECTOR and collect hits at location aWhere
* before calling the primary SelectPoint method.
*
* @param aWhere is the location where the item(s) should be collected
* @param aFilterList is a list of items that are acceptable for collection
* @param aScanTypes is a list of items that are acceptable for collection
* @param aItem is set to the newly selected item if only one was selected, otherwise is
* unchanged.
* @param aSelectionCancelledFlag allows the function to inform its caller that a selection
@ -102,7 +104,7 @@ public:
* @param aExclusiveOr indicates if found item(s) should be toggle in the selection
*/
bool SelectPoint( const VECTOR2I& aWhere,
const std::initializer_list<KICAD_T>& aFilterList = { SCH_LOCATE_ANY_T },
const std::vector<KICAD_T>& aScanTypes = { SCH_LOCATE_ANY_T },
EDA_ITEM** aItem = nullptr, bool* aSelectionCancelledFlag = nullptr,
bool aCheckLocked = false, bool aAdd = false, bool aSubtract = false,
bool aExclusiveOr = false );
@ -153,11 +155,11 @@ public:
*
* @param aCollector is the collector object that will store found item(s)
* @param aWhere is the place where the item should be selected.
* @param aFilterList is a list of items that are acceptable for collection
* @param aScanTypes is a list of items that are acceptable for collection
* @param aCheckLocked indicates if locked items should be excluded.
*/
bool CollectHits( EE_COLLECTOR& aCollector, const VECTOR2I& aWhere,
const std::initializer_list<KICAD_T>& aFilterList = { SCH_LOCATE_ANY_T } );
const std::vector<KICAD_T>& aScanTypes = { SCH_LOCATE_ANY_T } );
protected:
SELECTION& selection() override { return m_selection; }

View File

@ -325,9 +325,7 @@ bool SCH_EDIT_TOOL::Init()
return false;
};
static std::initializer_list<KICAD_T> allTextTypes = { SCH_LABEL_LOCATE_ANY_T,
SCH_TEXT_T,
SCH_TEXTBOX_T };
static std::vector<KICAD_T> allTextTypes = { SCH_LABEL_LOCATE_ANY_T, SCH_TEXT_T, SCH_TEXTBOX_T };
auto toChangeCondition = ( E_C::OnlyTypes( allTextTypes ) );
@ -523,7 +521,7 @@ bool SCH_EDIT_TOOL::Init()
}
const std::initializer_list<KICAD_T> rotatableItems = {
const std::vector<KICAD_T> rotatableItems = {
SCH_SHAPE_T,
SCH_TEXT_T,
SCH_TEXTBOX_T,
@ -1080,7 +1078,7 @@ int SCH_EDIT_TOOL::RepeatDrawItem( const TOOL_EVENT& aEvent )
}
static std::initializer_list<KICAD_T> deletableItems =
static std::vector<KICAD_T> deletableItems =
{
SCH_MARKER_T,
SCH_JUNCTION_T,

View File

@ -239,7 +239,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
}
static std::initializer_list<KICAD_T> nonFields =
static std::vector<KICAD_T> nonFields =
{
LIB_SYMBOL_T,
LIB_SHAPE_T,

View File

@ -76,7 +76,7 @@ EDA_RECT GBR_LAYOUT::ComputeBoundingBox() const
INSPECT_RESULT GBR_LAYOUT::Visit( INSPECTOR inspector, void* testData,
const std::initializer_list<KICAD_T>& aScanTypes )
const std::vector<KICAD_T>& aScanTypes )
{
#if 0 && defined(DEBUG)
std::cout << GetClass().mb_str() << ' ';

View File

@ -79,7 +79,7 @@ public:
///< @copydoc EDA_ITEM::Visit()
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
const std::initializer_list<KICAD_T>& aScanTypes ) override;
const std::vector<KICAD_T>& aScanTypes ) override;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }

View File

@ -36,12 +36,12 @@ INSPECT_RESULT GERBER_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
}
void GERBER_COLLECTOR::Collect( EDA_ITEM* aItem, const std::initializer_list<KICAD_T>& aScanList,
void GERBER_COLLECTOR::Collect( EDA_ITEM* aItem, const std::vector<KICAD_T>& aScanTypes,
const VECTOR2I& aRefPos )
{
Empty(); // empty the collection, primary criteria list
SetScanTypes( aScanList );
SetScanTypes( aScanTypes );
// remember where the snapshot was taken from and pass refPos to
// the Inspect() function.

View File

@ -60,11 +60,11 @@ public:
* Scan an EDA_ITEM using this class's Inspector method, which does the collection.
*
* @param aItem An EDA_ITEM to scan
* @param aScanList A list of KICAD_Ts that specs what is to be collected and the priority
* order of the resultant collection in "m_list".
* @param aScanTypes A list of KICAD_Ts that specs what is to be collected and the priority
* order of the resultant collection in "m_list".
* @param aRefPos A VECTOR2I to use in hit-testing.
*/
void Collect( EDA_ITEM* aItem, const std::initializer_list<KICAD_T>& aScanList,
void Collect( EDA_ITEM* aItem, const std::vector<KICAD_T>& aScanTypes,
const VECTOR2I& aRefPos );
};

Some files were not shown because too many files have changed in this diff Show More