Skip to content
Permalink
Browse files
Fix #9445 (crash during histogram diagram creation)
  • Loading branch information
wonder-sk committed Feb 7, 2014
1 parent fb9a366 commit 5a64215bd2bd6239a868a60c3f5c26ded518c61b
Showing with 16 additions and 1 deletion.
  1. +11 −1 src/app/qgsdiagramproperties.cpp
  2. +3 −0 src/core/diagram/qgshistogramdiagram.cpp
  3. +2 −0 src/core/pal/feature.cpp
@@ -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
@@ -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 )
@@ -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 );
}

0 comments on commit 5a64215

Please sign in to comment.