Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Index too big"-messages when toggling filtered-view modes #223

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/abstractlogview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1167,21 +1167,25 @@ int AbstractLogView::convertCoordToLine(int yPos) const
QPoint AbstractLogView::convertCoordToFilePos( const QPoint& pos ) const
{
int line = convertCoordToLine( pos.y() );
if ( line >= logData->getNbLine() )
line = logData->getNbLine() - 1;
int nbLine = logData->getNbLine();
if ( line >= nbLine )
line = nbLine - 1;
if ( line < 0 )
line = 0;

// Determine column in screen space and convert it to file space
int column = firstCol + ( pos.x() - leftMarginPx_ ) / charWidth_;
int column = 0;

QString this_line = logData->getExpandedLineString( line );
const int length = this_line.length();
if ( nbLine ) {
// Determine column in screen space and convert it to file space
column = firstCol + ( pos.x() - leftMarginPx_ ) / charWidth_;
QString this_line = logData->getExpandedLineString( line );
const int length = this_line.length();

if ( column >= length )
column = length - 1;
if ( column < 0 )
column = 0;
if ( column >= length )
column = length - 1;
if ( column < 0 )
column = 0;
}

LOG(logDEBUG4) << "AbstractLogView::convertCoordToFilePos col="
<< column << " line=" << line;
Expand Down
6 changes: 4 additions & 2 deletions src/crawlerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,10 @@ void CrawlerWidget::changeFilteredViewVisibility( int index )

filteredView->setVisibility( visibility );

const int lineIndex = logFilteredData_->getLineIndexNumber( currentLineNumber_ );
filteredView->selectAndDisplayLine( lineIndex );
if ( logFilteredData_->getNbLine() > 0 ) {
const int lineIndex = logFilteredData_->getLineIndexNumber( currentLineNumber_ );
filteredView->selectAndDisplayLine( lineIndex );
}
}

void CrawlerWidget::addToSearch( const QString& string )
Expand Down
3 changes: 0 additions & 3 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ LineNumber lookupLineNumber( Iterator begin, Iterator end, LineNumber lineNum )
if ( lowerBound != end ) {
lineIndex = std::distance(begin, lowerBound);
}
else if (begin != end) {
lineIndex = begin->lineNumber();
}
return lineIndex;
}

Expand Down