Skip to content
Permalink
Browse files

Merge pull request #39122 from rouault/cppcheck_20201001

Some cppcheck linting with cppcheck master
  • Loading branch information
rouault committed Oct 2, 2020
2 parents 7a38388 + 88c4ee8 commit ad6254a7b21fedbba803ec36019e98ef3018a799
@@ -80,7 +80,7 @@
#include <numeric>

template<typename T>
QVector<T> getAttributeData( Qt3DRender::QAttribute *attribute, QByteArray data )
QVector<T> getAttributeData( Qt3DRender::QAttribute *attribute, const QByteArray &data )
{
uint bytesOffset = attribute->byteOffset();
uint bytesStride = attribute->byteStride();
@@ -93,40 +93,34 @@ QVector<T> getAttributeData( Qt3DRender::QAttribute *attribute, QByteArray data
return result;
}

const char *pData = data.constData();
for ( int i = bytesOffset; i < data.size(); i += bytesStride )
{
for ( unsigned int j = 0; j < vertexSize * sizeof( T ); j += sizeof( T ) )
{
// maybe a problem with endienness can happen?
T v;
char *vArr = ( char * )&v;
for ( unsigned int k = 0; k < sizeof( T ); ++k )
{
vArr[k] = data.at( i + j + k );
}
memcpy( &v, pData + i + j, sizeof( T ) );
result.push_back( v );
}
}
return result;
}

template<typename T>
QVector<uint> _getIndexDataImplementation( QByteArray data )
QVector<uint> _getIndexDataImplementation( const QByteArray &data )
{
QVector<uint> result;
const char *pData = data.constData();
for ( int i = 0; i < data.size(); i += sizeof( T ) )
{
// maybe a problem with indienness can happen?
T v;
char *vArr = ( char * )&v;
for ( unsigned long k = 0; k < sizeof( T ); ++k )
vArr[k] = data.at( i + k );
memcpy( &v, pData + i, sizeof( T ) );
result.push_back( ( uint ) v );
}
return result;
}

QVector<uint> getIndexData( Qt3DRender::QAttribute *indexAttribute, QByteArray data )
QVector<uint> getIndexData( Qt3DRender::QAttribute *indexAttribute, const QByteArray &data )
{
switch ( indexAttribute->vertexBaseType() )
{
@@ -177,6 +177,8 @@ class QgsShadowRenderingFrameGraph
Qt3DRender::QFrameGraphNode *constructForwardRenderPass();
Qt3DRender::QFrameGraphNode *constructTexturesPreviewPass();
Qt3DRender::QFrameGraphNode *constructPostprocessingPass();

Q_DISABLE_COPY( QgsShadowRenderingFrameGraph )
};

#endif // QGSSHADOWRENDERINGFRAMEGRAPH_H
@@ -91,6 +91,8 @@ class QgsAppScreenShots
QgsVectorLayer *mLineLayer = nullptr;
QgsVectorLayer *mPolygonLayer = nullptr;
QgsRasterLayer *mRasterLayer = nullptr;

Q_DISABLE_COPY( QgsAppScreenShots )
};

Q_DECLARE_OPERATORS_FOR_FLAGS( QgsAppScreenShots::Categories )
@@ -580,9 +580,11 @@ void QgsMapLayer::writeCommonStyle( QDomElement &layerElement, QDomDocument &doc
layerElement.appendChild( layerFlagsElem );
}

if ( categories.testFlag( Temporal ) && const_cast< QgsMapLayer * >( this )->temporalProperties() )
if ( categories.testFlag( Temporal ) )
{
const_cast< QgsMapLayer * >( this )->temporalProperties()->writeXml( layerElement, document, context );
QgsMapLayerTemporalProperties *lTemporalProperties = const_cast< QgsMapLayer * >( this )->temporalProperties();
if ( lTemporalProperties )
lTemporalProperties->writeXml( layerElement, document, context );
}

// custom properties
@@ -782,7 +784,8 @@ void QgsMapLayer::setCrs( const QgsCoordinateReferenceSystem &srs, bool emitSign

QgsCoordinateTransformContext QgsMapLayer::transformContext() const
{
return dataProvider() ? dataProvider()->transformContext() : QgsCoordinateTransformContext();
const QgsDataProvider *lDataProvider = dataProvider();
return lDataProvider ? lDataProvider->transformContext() : QgsCoordinateTransformContext();
}

QString QgsMapLayer::formatLayerName( const QString &name )
@@ -1679,9 +1682,11 @@ void QgsMapLayer::readCommonStyle( const QDomElement &layerElement, const QgsRea
setFlags( flags );
}

if ( categories.testFlag( Temporal ) && temporalProperties() )
if ( categories.testFlag( Temporal ) )
{
temporalProperties()->readXml( layerElement.toElement(), context );
QgsMapLayerTemporalProperties *lTemporalProperties = temporalProperties();
if ( lTemporalProperties )
lTemporalProperties->readXml( layerElement.toElement(), context );
}
}

@@ -1918,18 +1923,19 @@ bool QgsMapLayer::setDependencies( const QSet<QgsMapLayerDependency> &oDeps )

void QgsMapLayer::setRefreshOnNotifyEnabled( bool enabled )
{
if ( !dataProvider() )
QgsDataProvider *lDataProvider = dataProvider();
if ( !lDataProvider )
return;

if ( enabled && !isRefreshOnNotifyEnabled() )
{
dataProvider()->setListening( enabled );
connect( dataProvider(), &QgsVectorDataProvider::notify, this, &QgsMapLayer::onNotifiedTriggerRepaint );
lDataProvider->setListening( enabled );
connect( lDataProvider, &QgsVectorDataProvider::notify, this, &QgsMapLayer::onNotifiedTriggerRepaint );
}
else if ( !enabled && isRefreshOnNotifyEnabled() )
{
// we don't want to disable provider listening because someone else could need it (e.g. actions)
disconnect( dataProvider(), &QgsVectorDataProvider::notify, this, &QgsMapLayer::onNotifiedTriggerRepaint );
disconnect( lDataProvider, &QgsVectorDataProvider::notify, this, &QgsMapLayer::onNotifiedTriggerRepaint );
}
mIsRefreshOnNofifyEnabled = enabled;
}
@@ -2007,6 +2007,8 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
friend class QgsServer;

friend class TestQgsProject;

Q_DISABLE_COPY( QgsProject )
};

Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProject::ReadFlags )
@@ -98,6 +98,8 @@ class CORE_EXPORT QgsScopedProxyProgressTask

QgsProxyProgressTask *mTask = nullptr;

// SIP generates .cpp code that doesn't compile if commenting out the legit following line.
// Q_DISABLE_COPY( QgsScopedProxyProgressTask )
};

#endif // QGSPROXYPROGRESSTASK_H
@@ -664,13 +664,33 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes )
value[1] >= '0' && value[1] <= '9' &&
value[2] == ':' &&
value[3] >= '0' && value[3] <= '5' &&
value[4] >= '0' && value[4] <= '9' &&
( value.length() == 5 ||
( value.length() >= 8 && (
value[5] == ':' &&
value[6] >= '0' && value[6] <= '6' &&
value[7] >= '0' && value[7] <= '9' &&
( value.length() == 8 || value[8] == '.' ) ) ) );
value[4] >= '0' && value[4] <= '9';
if ( couldBeTime[i] && value.length() == 5 )
{
// ok
}
else if ( couldBeTime[i] && value.length() >= 8 )
{
couldBeTime[i] = value[5] == ':' &&
value[6] >= '0' && value[6] <= '6' &&
value[7] >= '0' && value[7] <= '9';
if ( couldBeTime[i] && value.length() == 8 )
{
// ok
}
else if ( couldBeTime[i] && value.length() >= 9 )
{
couldBeTime[i] = value[8] == '.';
}
else
{
couldBeTime[i] = false;
}
}
else
{
couldBeTime[i] = false;
}
#endif
}
}

0 comments on commit ad6254a

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