Skip to content
Permalink
Browse files

fix bad alloc when mesh's arrows of 3D rendering has too small spacing (

#37195)

* fix bad alloc when mesh's arrows of 3D rendering has too small spacing

* Update src/core/mesh/qgsmeshlayerutils.cpp

Co-authored-by: Harrissou Sant-anna <delazj@gmail.com>

* fix mesh terrain not rendering anymore

Co-authored-by: Harrissou Sant-anna <delazj@gmail.com>
  • Loading branch information
vcloarec and DelazJ committed Jun 16, 2020
1 parent 659ed39 commit 76946dd659a231566f99cf41017c2ce1153ec995
Showing with 16 additions and 2 deletions.
  1. +3 −0 src/3d/mesh/qgsmesh3dmaterial_p.cpp
  2. +2 −1 src/3d/symbols/qgsmesh3dsymbol.cpp
  3. +11 −1 src/core/mesh/qgsmeshlayerutils.cpp
@@ -366,6 +366,9 @@ void QgsMesh3dMaterial::configureArrows( QgsMeshLayer *layer, const QgsDateTimeR
ySpacing,
gridSize,
minCorner );

if ( vectors.isEmpty() )
return;
}

mTechnique->addParameter( arrowsEnabledParameter ) ;
@@ -93,7 +93,8 @@ void QgsMesh3DSymbol::readXml( const QDomElement &elem, const QgsReadWriteContex
mColorRampShader.setMaximumValue( elemAdvancedSettings.attribute( QStringLiteral( "max-color-ramp-shader" ) ).toDouble() );
mSingleColor = QgsSymbolLayerUtils::decodeColor( elemAdvancedSettings.attribute( QStringLiteral( "texture-single-color" ) ) );
mArrowsEnabled = elemAdvancedSettings.attribute( QStringLiteral( "arrows-enabled" ) ).toInt();
mArrowsSpacing = elemAdvancedSettings.attribute( QStringLiteral( "arrows-spacing" ) ).toDouble();
if ( elemAdvancedSettings.hasAttribute( QStringLiteral( "arrows-spacing" ) ) )
mArrowsSpacing = elemAdvancedSettings.attribute( QStringLiteral( "arrows-spacing" ) ).toDouble();
mArrowsFixedSize = elemAdvancedSettings.attribute( QStringLiteral( "arrows-fixed-size" ) ).toInt();
QDomElement elemDDP = elem.firstChildElement( QStringLiteral( "data-defined-properties" ) );
if ( !elemDDP.isNull() )
@@ -22,6 +22,7 @@
#include "qgsmeshlayerutils.h"
#include "qgsmeshtimesettings.h"
#include "qgstriangularmesh.h"
#include "qgslogger.h"
#include "qgsmeshdataprovider.h"
#include "qgsmesh3daveraging.h"
#include "qgsmeshlayer.h"
@@ -129,7 +130,16 @@ QVector<QgsVector> QgsMeshLayerUtils::griddedVectorValues( const QgsMeshLayer *m
if ( dataType == QgsMeshDatasetGroupMetadata::DataOnEdges )
return vectors;

vectors.reserve( size.height()*size.width() );
try
{
vectors.reserve( size.height()*size.width() );
}
catch ( ... )
{
QgsDebugMsgLevel( "Unable to store the arrow grid in memory", 1 );
return QVector<QgsVector>();
}

for ( int iy = 0; iy < size.height(); ++iy )
{
double y = minCorner.y() + iy * ySpacing;

0 comments on commit 76946dd

Please sign in to comment.
You can’t perform that action at this time.