Further segfault bug fixes in FListView

This commit is contained in:
Markus Gans 2019-05-27 09:55:29 +02:00
parent 63366b7ef9
commit c93c0b6e33
2 changed files with 34 additions and 10 deletions

View File

@ -2,6 +2,9 @@
* Use the Singleton design pattern to get a single object instance
via FTerm
2019-05-26 Marek Habersack <grendel@twistedcode.net>
* Fix a segfault when processing input to empty FListView
2019-05-17 Markus Gans <guru.mail@muenster.de>
* Move system calls to the new class FSystem

View File

@ -2035,7 +2035,7 @@ void FListView::mouseHeaderClicked()
//----------------------------------------------------------------------
void FListView::wheelUp (int pagesize)
{
if ( current_iter.getPosition() == 0 )
if ( itemlist.empty() || current_iter.getPosition() == 0 )
return;
if ( first_visible_line.getPosition() >= pagesize )
@ -2059,6 +2059,9 @@ void FListView::wheelUp (int pagesize)
//----------------------------------------------------------------------
void FListView::wheelDown (int pagesize)
{
if ( itemlist.empty() )
return;
int element_count = int(getCount());
if ( current_iter.getPosition() + 1 == element_count )
@ -2181,6 +2184,9 @@ FObject::FObjectIterator FListView::appendItem (FListViewItem* item)
//----------------------------------------------------------------------
void FListView::processClick()
{
if ( itemlist.empty() )
return;
emitCallback("clicked");
}
@ -2290,6 +2296,9 @@ inline void FListView::keyRight (int& first_line_position_before)
//----------------------------------------------------------------------
inline void FListView::keyHome()
{
if ( itemlist.empty() )
return;
current_iter -= current_iter.getPosition();
int difference = first_visible_line.getPosition();
first_visible_line -= difference;
@ -2299,6 +2308,9 @@ inline void FListView::keyHome()
//----------------------------------------------------------------------
inline void FListView::keyEnd()
{
if ( itemlist.empty() )
return;
int element_count = int(getCount());
current_iter += element_count - current_iter.getPosition() - 1;
int difference = element_count - last_visible_line.getPosition() - 1;
@ -2352,6 +2364,9 @@ void FListView::setRelativePosition (int ry)
//----------------------------------------------------------------------
void FListView::stepForward()
{
if ( itemlist.empty() )
return;
if ( current_iter == last_visible_line )
{
++last_visible_line;
@ -2371,6 +2386,9 @@ void FListView::stepForward()
//----------------------------------------------------------------------
void FListView::stepBackward()
{
if ( itemlist.empty() )
return;
if ( current_iter == first_visible_line
&& current_iter != itemlist.begin() )
{
@ -2385,6 +2403,9 @@ void FListView::stepBackward()
//----------------------------------------------------------------------
void FListView::stepForward (int distance)
{
if ( itemlist.empty() )
return;
int element_count = int(getCount());
if ( current_iter.getPosition() + 1 == element_count )
@ -2418,7 +2439,7 @@ void FListView::stepForward (int distance)
//----------------------------------------------------------------------
void FListView::stepBackward (int distance)
{
if ( current_iter.getPosition() == 0 )
if ( itemlist.empty() || current_iter.getPosition() == 0 )
return;
if ( current_iter.getPosition() - distance >= 0 )