Skip to content

Commit

Permalink
Fix uninitialized warnings when building in release mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 27, 2024
1 parent 7bdc228 commit 3156301
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions src/core/pointcloud/qgslazdecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ std::vector< QgsLazDecoder::RequestedAttributeDetails > prepareRequestedAttribut
return requestedAttributeDetails;
}

void decodePoint( char *buf, int lasPointFormat, char *dataBuffer, std::size_t &outputOffset, std::vector< QgsLazDecoder::RequestedAttributeDetails > &requestedAttributeDetails )
bool decodePoint( char *buf, int lasPointFormat, char *dataBuffer, std::size_t &outputOffset, std::vector< QgsLazDecoder::RequestedAttributeDetails > &requestedAttributeDetails )
{
lazperf::las::point10 p10;
lazperf::las::gpstime gps;
Expand Down Expand Up @@ -355,6 +355,7 @@ void decodePoint( char *buf, int lasPointFormat, char *dataBuffer, std::size_t &

default:
Q_ASSERT( false ); // must not happen - we checked earlier that the format is supported
return false;
}

for ( const QgsLazDecoder::RequestedAttributeDetails &requestedAttribute : requestedAttributeDetails )
Expand Down Expand Up @@ -427,7 +428,7 @@ void decodePoint( char *buf, int lasPointFormat, char *dataBuffer, std::size_t &
lazStoreToStream_<unsigned short>( dataBuffer, outputOffset, requestedAttribute.type, rgb.b );
break;
case QgsLazDecoder::LazAttribute::ScannerChannel:
lazStoreToStream_<char>( dataBuffer, outputOffset, requestedAttribute.type, char( p14.scannerChannel() ) );
lazStoreToStream_<char>( dataBuffer, outputOffset, requestedAttribute.type, isLas14 ? char( p14.scannerChannel() ) : 0 );
break;
case QgsLazDecoder::LazAttribute::Synthetic:
lazStoreToStream_<char>( dataBuffer, outputOffset, requestedAttribute.type, isLas14 ? char( ( p14.classFlags() >> 0 ) & 0x01 ) : char( ( p10.classification >> 5 ) & 0x01 ) );
Expand Down Expand Up @@ -510,6 +511,7 @@ void decodePoint( char *buf, int lasPointFormat, char *dataBuffer, std::size_t &

outputOffset += requestedAttribute.size;
}
return true;
}

template<typename FileType>
Expand Down Expand Up @@ -592,11 +594,10 @@ std::unique_ptr<QgsPointCloudBlock> decompressLaz_( FileType &file, const QgsPoi
{
f.readPoint( buf ); // read the point out

decodePoint( buf, lasPointFormat, dataBuffer, outputOffset, requestedAttributeDetails );
bool skipThisPoint = !decodePoint( buf, lasPointFormat, dataBuffer, outputOffset, requestedAttributeDetails );

// check if point needs to be filtered out
bool skipThisPoint = false;
if ( hasFilterRect && attributeX && attributeY )
if ( !skipThisPoint && hasFilterRect && attributeX && attributeY )
{
const double x = attributeX->convertValueToDouble( dataBuffer + outputOffset - requestedPointRecordSize + xAttributeOffset );
const double y = attributeY->convertValueToDouble( dataBuffer + outputOffset - requestedPointRecordSize + yAttributeOffset );
Expand Down Expand Up @@ -703,12 +704,10 @@ std::unique_ptr<QgsPointCloudBlock> QgsLazDecoder::decompressCopc( const QByteAr
decompressor.decompress( decodedData.get() );
char *buf = decodedData.get();

decodePoint( buf, lasPointFormat, dataBuffer, outputOffset, requestedAttributeDetails );
bool skipThisPoint = !decodePoint( buf, lasPointFormat, dataBuffer, outputOffset, requestedAttributeDetails );

// check if point needs to be filtered out
bool skipThisPoint = false;

if ( hasFilterRect && attributeX && attributeY )
if ( !skipThisPoint && hasFilterRect && attributeX && attributeY )
{
const double x = attributeX->convertValueToDouble( dataBuffer + outputOffset - requestedPointRecordSize + xAttributeOffset );
const double y = attributeY->convertValueToDouble( dataBuffer + outputOffset - requestedPointRecordSize + yAttributeOffset );
Expand Down
2 changes: 1 addition & 1 deletion src/core/pointcloud/qgspointcloudlayerrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ void QgsPointCloudLayerRenderer::renderTriangulatedSurface( QgsPointCloudRenderC
QPainter *painter = context.renderContext().painter();
QgsElevationMap *elevationMap = context.renderContext().elevationMap();
QPointF triangle[3];
float elev[3];
float elev[3] {0, 0, 0};
for ( size_t i = 0; i < triangleIndexes.size(); i += 3 )
{
size_t v0 = triangleIndexes[i], v1 = triangleIndexes[i + 1], v2 = triangleIndexes[i + 2];
Expand Down

0 comments on commit 3156301

Please sign in to comment.