Skip to content

Commit

Permalink
Fix #9445 (crash during histogram diagram creation)
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Feb 7, 2014
1 parent fb9a366 commit 5a64215
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/app/qgsdiagramproperties.cpp
Expand Up @@ -545,7 +545,17 @@ void QgsDiagramProperties::apply()
// Find maximum value
for ( int i = 0; i < mDiagramAttributesTreeWidget->topLevelItemCount(); ++i )
{
maxVal = qMax( maxVal, provider->maximumValue( mDiagramAttributesTreeWidget->topLevelItem( i )->data( 0, Qt::UserRole ).toInt() ).toDouble() );
QString fldName = mDiagramAttributesTreeWidget->topLevelItem( i )->data( 0, Qt::UserRole ).toString();
if ( fldName.count() >= 2 && fldName.at( 0 ) == '"' && fldName.at( fldName.count() - 1 ) == '"' )
fldName = fldName.mid( 1, fldName.count() - 2 ); // remove enclosing double quotes
int fld = provider->fieldNameIndex( fldName );
if ( fld != -1 )
{
bool ok = false;
double val = provider->maximumValue( fld ).toDouble( &ok );
if ( ok )
maxVal = qMax( maxVal, val );
}
}
}
else
Expand Down
3 changes: 3 additions & 0 deletions src/core/diagram/qgshistogramdiagram.cpp
Expand Up @@ -39,6 +39,9 @@ QSizeF QgsHistogramDiagram::diagramSize( const QgsFeature& feature, const QgsRen
return size; //zero size if no attributes
}

if ( is.upperValue - is.lowerValue == 0 )
return size; // invalid value range => zero size

double maxValue = 0;

foreach ( QString cat, s.categoryAttributes )
Expand Down
2 changes: 2 additions & 0 deletions src/core/pal/feature.cpp
Expand Up @@ -65,6 +65,8 @@ namespace pal
: layer( l ), userGeom( userG ), label_x( lx ), label_y( ly ), distlabel( 0 ), labelInfo( NULL ), fixedPos( false ),
quadOffset( false ), offsetPos( false ), fixedRotation( false ), alwaysShow( false )
{
assert( finite( lx ) && finite( ly ) );

uid = new char[strlen( geom_id ) +1];
strcpy( uid, geom_id );
}
Expand Down

0 comments on commit 5a64215

Please sign in to comment.