Skip to content

Commit

Permalink
Fixes segmentation fault when dividing by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed May 17, 2018
1 parent d5cec14 commit 352dbcb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp
Expand Up @@ -259,7 +259,11 @@ void QgsValueRelationWidgetWrapper::populate( )
else if ( mTableWidget )
{
if ( mCache.size() > 0 )
mTableWidget->setRowCount( ( mCache.size() + config( QStringLiteral( "NofColumns" ) ).toInt() - 1 ) / config( QStringLiteral( "NofColumns" ) ).toInt() );
{
const int nofCols = config( QStringLiteral( "NofColumns" ) ).toInt();
const int denom = nofCols != 0 ? nofCols : 1;
mTableWidget->setRowCount( ( mCache.size() + nofCols - 1 ) / denom );
}
else
mTableWidget->setRowCount( 1 );
if ( config( QStringLiteral( "NofColumns" ) ).toInt() > 0 )
Expand Down

0 comments on commit 352dbcb

Please sign in to comment.