@@ -442,37 +442,33 @@ void QgsDiagramProperties::on_mRemoveCategoryPushButton_clicked()
442442
443443void QgsDiagramProperties::on_mFindMaximumValueButton_clicked ()
444444{
445- // get maximum value from provider (ignoring not-commited edits)
446- if ( mLayer )
445+ if ( !mLayer )
446+ return ;
447+
448+ float maxValue = 0.0 ;
449+ if ( mSizeAttributeComboBox ->currentIndex () >= mAvailableAttributes )
447450 {
448- // condition removed, keep this useless scope to avoid screewing diff (easier to review)
451+ QgsExpression exp ( mSizeAttributeComboBox ->currentText () );
452+ exp.prepare ( mLayer ->pendingFields () );
453+ if ( !exp.hasEvalError () )
449454 {
450- float maxValue = 0 ;
451- if ( mSizeAttributeComboBox ->currentIndex () >= mAvailableAttributes )
452- {
453- QgsExpression exp ( mSizeAttributeComboBox ->currentText () );
454- exp.prepare ( mLayer ->pendingFields () );
455- if ( exp.hasEvalError () )
456- {
457- QgsDebugMsgLevel ( " Prepare error:" + exp.evalErrorString (), 4 );
458- }
459- else
460- {
461- QgsFeature feature;
462- QgsFeatureIterator features = mLayer ->getFeatures ();
463- while ( features.nextFeature ( *&feature ) )
464- {
465- maxValue = qMax ( maxValue, exp.evaluate ( &feature ).toFloat () );
466- }
467- }
468- }
469- else
455+ QgsFeature feature;
456+ QgsFeatureIterator features = mLayer ->getFeatures ();
457+ while ( features.nextFeature ( *&feature ) )
470458 {
471- maxValue = mLayer -> maximumValue ( mSizeAttributeComboBox -> itemData ( mSizeAttributeComboBox -> currentIndex () ). toInt () ).toFloat ();
459+ maxValue = qMax ( maxValue, exp. evaluate ( &feature ).toFloat () );
472460 }
473- mValueLineEdit ->setText ( QString ( " %1" ).arg ( maxValue ) );
474461 }
462+ else
463+ {
464+ QgsDebugMsgLevel ( " Prepare error:" + exp.evalErrorString (), 4 );
465+ }
466+ }
467+ else
468+ {
469+ maxValue = mLayer ->maximumValue ( mSizeAttributeComboBox ->itemData ( mSizeAttributeComboBox ->currentIndex () ).toInt () ).toFloat ();
475470 }
471+ mValueLineEdit ->setText ( QString ( " %1" ).arg ( maxValue ) );
476472}
477473
478474void QgsDiagramProperties::on_mDisplayDiagramsGroupBox_toggled ( bool checked )
0 commit comments