Eeschema: fix subtle find bug when at the end of the search list. (fixes lp 1199689)
This commit is contained in:
parent
ba16d9e763
commit
f2003d8dda
|
@ -338,7 +338,7 @@ bool SCH_COLLECTOR::IsDraggableJunction() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SCH_FIND_COLLECTOR::atEnd() const
|
bool SCH_FIND_COLLECTOR::PassedEnd() const
|
||||||
{
|
{
|
||||||
bool retv = false;
|
bool retv = false;
|
||||||
|
|
||||||
|
@ -351,12 +351,12 @@ bool SCH_FIND_COLLECTOR::atEnd() const
|
||||||
{
|
{
|
||||||
if( flags & wxFR_DOWN )
|
if( flags & wxFR_DOWN )
|
||||||
{
|
{
|
||||||
if( m_foundIndex >= (GetCount() - 1) )
|
if( m_foundIndex >= GetCount() )
|
||||||
retv = true;
|
retv = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( m_foundIndex == 0 )
|
if( m_foundIndex < 0 )
|
||||||
retv = true;
|
retv = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -390,21 +390,15 @@ void SCH_FIND_COLLECTOR::UpdateIndex()
|
||||||
|
|
||||||
if( flags & wxFR_DOWN )
|
if( flags & wxFR_DOWN )
|
||||||
{
|
{
|
||||||
if( !(flags & FR_SEARCH_WRAP) && (m_foundIndex == (GetCount() - 1)) )
|
if( m_foundIndex < GetCount() )
|
||||||
return;
|
m_foundIndex += 1;
|
||||||
|
|
||||||
m_foundIndex += 1;
|
|
||||||
|
|
||||||
if( (m_foundIndex >= GetCount()) && (flags & FR_SEARCH_WRAP) )
|
if( (m_foundIndex >= GetCount()) && (flags & FR_SEARCH_WRAP) )
|
||||||
m_foundIndex = 0;
|
m_foundIndex = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( !(flags & FR_SEARCH_WRAP) && (m_foundIndex == 0) )
|
if( m_foundIndex >= 0 )
|
||||||
return;
|
m_foundIndex -= 1;
|
||||||
|
|
||||||
m_foundIndex -= 1;
|
|
||||||
|
|
||||||
if( (m_foundIndex < 0) && (flags & FR_SEARCH_WRAP) )
|
if( (m_foundIndex < 0) && (flags & FR_SEARCH_WRAP) )
|
||||||
m_foundIndex = GetCount() - 1;
|
m_foundIndex = GetCount() - 1;
|
||||||
}
|
}
|
||||||
|
@ -452,7 +446,7 @@ wxString SCH_FIND_COLLECTOR::GetText()
|
||||||
|
|
||||||
EDA_ITEM* SCH_FIND_COLLECTOR::GetItem( SCH_FIND_COLLECTOR_DATA& aData )
|
EDA_ITEM* SCH_FIND_COLLECTOR::GetItem( SCH_FIND_COLLECTOR_DATA& aData )
|
||||||
{
|
{
|
||||||
if( atEnd() )
|
if( PassedEnd() )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
aData = m_data[ m_foundIndex ];
|
aData = m_data[ m_foundIndex ];
|
||||||
|
@ -462,7 +456,7 @@ EDA_ITEM* SCH_FIND_COLLECTOR::GetItem( SCH_FIND_COLLECTOR_DATA& aData )
|
||||||
|
|
||||||
bool SCH_FIND_COLLECTOR::ReplaceItem()
|
bool SCH_FIND_COLLECTOR::ReplaceItem()
|
||||||
{
|
{
|
||||||
if( atEnd() )
|
if( PassedEnd() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
wxCHECK_MSG( IsValidIndex( m_foundIndex ), false,
|
wxCHECK_MSG( IsValidIndex( m_foundIndex ), false,
|
||||||
|
|
|
@ -238,13 +238,13 @@ class SCH_FIND_COLLECTOR : public COLLECTOR
|
||||||
bool m_forceSearch;
|
bool m_forceSearch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function atEnd
|
* Function PassedEnd
|
||||||
* tests if #m_foundIndex is at the end of the list give the current find/replace
|
* tests if #m_foundIndex is beyond the end of the list give the current
|
||||||
* criterial in #m_findReplaceData.
|
* find/replace criterial in #m_findReplaceData.
|
||||||
*
|
*
|
||||||
* @return True if #m_foundIndex is at the end of the found item list.
|
* @return True if #m_foundIndex has crossed the end of the found item list.
|
||||||
*/
|
*/
|
||||||
bool atEnd() const;
|
bool PassedEnd() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function dump
|
* Function dump
|
||||||
|
|
Loading…
Reference in New Issue