Commit 69c205c1 authored by Joachim Eibl's avatar Joachim Eibl Committed by Michael Reeves

Fixed crash on resize with word wrap.

Signed-off-by: default avatarjoachim99 <joachim.eibl@gmx.de>
parent 58dac647
......@@ -673,7 +673,7 @@ void DiffTextWindow::convertToLinePos( int x, int y, int& line, int& pos )
int yOffset = - d->m_firstLine * fontHeight;
line = ( y - yOffset ) / fontHeight;
if ( line >= 0 )
if ( line >= 0 && (!d->m_pOptions->m_bWordWrap || line < d->m_diff3WrapLineVector.count()) )
{
QString s = d->getLineString( line );
QTextLayout textLayout( s, font(), this );
......@@ -1226,8 +1226,13 @@ QString DiffTextWindowData::getLineString( int line )
{
if ( m_bWordWrap )
{
int d3LIdx = m_pDiffTextWindow->convertLineToDiff3LineIdx(line);
return getString( d3LIdx ).mid( m_diff3WrapLineVector[line].wrapLineOffset, m_diff3WrapLineVector[line].wrapLineLength );
if ( line < m_diff3WrapLineVector.count() )
{
int d3LIdx = m_pDiffTextWindow->convertLineToDiff3LineIdx(line);
return getString( d3LIdx ).mid( m_diff3WrapLineVector[line].wrapLineOffset, m_diff3WrapLineVector[line].wrapLineLength );
}
else
return QString();
}
else
{
......@@ -1632,13 +1637,13 @@ void DiffTextWindow::recalcWordWrapHelper( bool bWordWrap, int wrapLineVectorSiz
wrapLineCache.push_back( DiffTextWindowData::WrapLineCacheData(i,line.textStart(),line.textLength()) );
}
}
else if ( wrapLineVectorSize > 0 )
else if ( wrapLineVectorSize > 0 && cacheListIdx2 < d->m_wrapLineCacheList.count() )
{
DiffTextWindowData::WrapLineCacheData* pWrapLineCache = d->m_wrapLineCacheList[cacheListIdx2].data();
int cacheIdx = 0;
int clc = d->m_wrapLineCacheList.count()-1 ;
int cllc = d->m_wrapLineCacheList.last().count() ;
int curCount = d->m_wrapLineCacheList[0].count()-1;
int curCount = d->m_wrapLineCacheList[cacheListIdx2].count()-1;
int l=0;
while( (cacheListIdx2 < clc
|| cacheListIdx2 == clc && cacheIdx < cllc)
......@@ -1672,6 +1677,7 @@ void DiffTextWindow::recalcWordWrapHelper( bool bWordWrap, int wrapLineVectorSiz
Diff3Line& d3l = *(*d->m_pDiff3LineVector)[i];
if ( d3l.linesNeededForDisplay<linesNeeded )
{
assert(wrapLineVectorSize==0);
d3l.linesNeededForDisplay = linesNeeded;
}
......
......@@ -181,8 +181,8 @@ KDiff3App::KDiff3App( QWidget* pParent, const char* /*name*/, KDiff3Part* pKDiff
pDialog->exec();
#if !defined(_WIN32) && !defined(Q_OS_OS2)
// A windows program has no console
fprintf( "%s\n", title.toLatin1().constData() );
fprintf( "%s\n", s.toLatin1().constData() );
printf( "%s\n", title.toLatin1().constData() );
printf( "%s\n", s.toLatin1().constData() );
#endif
exit( 1 );
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment