mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-22 00:06:12 -05:00
Avoid coverity uncaught exception warnings
The warning is a false positive, since we were already checking that the optional has a value before accessing it. But we can avoid the exception altogether (and gain some performance) by using the std::optional dereference operator, which DOES not throw and which relies on the previous has_value check to avoid undefined behavior.
This commit is contained in:
parent
8f170a6830
commit
e3762c5f6e
@ -232,7 +232,7 @@ QVector<QgsProfileIdentifyResults> QgsAbstractProfileSurfaceResults::identify( c
|
||||
prevElevation = it.value();
|
||||
}
|
||||
if ( result.has_value() )
|
||||
return {result.value()};
|
||||
return {*result};
|
||||
else
|
||||
return {};
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ class CORE_EXPORT QgsTextLabelFeature : public QgsLabelFeature
|
||||
* \see setTextMetrics()
|
||||
* \since QGIS 3.20
|
||||
*/
|
||||
const QgsPrecalculatedTextMetrics *textMetrics() const { return mTextMetrics.has_value() ? &mTextMetrics.value() : nullptr; }
|
||||
const QgsPrecalculatedTextMetrics *textMetrics() const { return mTextMetrics.has_value() ? &( *mTextMetrics ) : nullptr; }
|
||||
|
||||
/**
|
||||
* Sets additional text \a metrics required for curved label placement.
|
||||
|
@ -264,7 +264,7 @@ struct MapIndexedPointCloudNode
|
||||
// here we check the flag set in header to determine if we need to
|
||||
// parse the time as GPS week time or GPS adjusted standard time
|
||||
// however often times the flag is set wrong, so we determine if the value is bigger than the maximum amount of seconds in week then it has to be adjusted standard time
|
||||
if ( copcTimeFlag.value() || pointAttr[QStringLiteral( "GpsTime" )].toDouble() > numberOfSecsInWeek )
|
||||
if ( *copcTimeFlag || pointAttr[QStringLiteral( "GpsTime" )].toDouble() > numberOfSecsInWeek )
|
||||
{
|
||||
const QString utcTime = gpsBaseTime.addSecs( static_cast<qint64>( pointAttr[QStringLiteral( "GpsTime" )].toDouble() + 1e9 ) ).toString( Qt::ISODate );
|
||||
pointAttr[ QStringLiteral( "GpsTime (raw)" )] = pointAttr[QStringLiteral( "GpsTime" )];
|
||||
|
@ -48,7 +48,7 @@ class CORE_EXPORT QgsSettingsProxy
|
||||
*/
|
||||
QgsSettings *operator->()
|
||||
{
|
||||
return mOwnedSettings.has_value() ? &( mOwnedSettings.value() ) : mNonOwnedSettings;
|
||||
return mOwnedSettings.has_value() ? &( *mOwnedSettings ) : mNonOwnedSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,7 +56,7 @@ class CORE_EXPORT QgsSettingsProxy
|
||||
*/
|
||||
QgsSettings &operator* ()
|
||||
{
|
||||
return mOwnedSettings.has_value() ? mOwnedSettings.value() : *mNonOwnedSettings;
|
||||
return mOwnedSettings.has_value() ? *mOwnedSettings : *mNonOwnedSettings;
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user