Fix various code issues found using PVS-Studio

This commit is contained in:
Wojtek Figat
2024-08-22 20:24:52 +02:00
parent 3ecb7c1d81
commit 23f60da40d
11 changed files with 49 additions and 7 deletions

View File

@@ -92,7 +92,7 @@ void SceneAnimationPlayer::Pause()
if (_state != PlayState::Playing)
return;
if (IsActiveInHierarchy() && _state == PlayState::Playing)
if (IsActiveInHierarchy())
{
UNREGISTER_TICK;
}

View File

@@ -1027,6 +1027,13 @@ public:
return *this;
}
Iterator& operator=(Iterator&& v)
{
_array = v._array;
_index = v._index;
return *this;
}
Iterator& operator++()
{
if (_index != _array->_count)

View File

@@ -173,6 +173,14 @@ public:
return *this;
}
Iterator& operator=(Iterator&& v)
{
_collection = v._collection;
_chunkIndex = v._chunkIndex;
_index = v._index;
return *this;
}
Iterator& operator++()
{
// Check if it is not at end

View File

@@ -348,6 +348,13 @@ public:
return *this;
}
Iterator& operator=(Iterator&& v)
{
_collection = v._collection;
_index = v._index;
return *this;
}
Iterator& operator++()
{
const int32 capacity = _collection->_size;

View File

@@ -329,6 +329,13 @@ public:
return *this;
}
Iterator& operator=(Iterator&& v)
{
_collection = v._collection;
_index = v._index;
return *this;
}
Iterator& operator++()
{
const int32 capacity = _collection->_size;

View File

@@ -338,7 +338,7 @@ public:
Platform::MemoryCopy(Base::_data, prev, prevLength * sizeof(T));
Platform::MemoryCopy(Base::_data + prevLength * sizeof(T), data, length * sizeof(T));
if (_isAllocated && prev)
if (_isAllocated)
Allocator::Free(prev);
_isAllocated = true;
}

View File

@@ -28,6 +28,12 @@ protected:
{
}
StringViewBase(const StringViewBase& other)
: _data(other._data)
, _length(other._length)
{
}
public:
typedef T CharType;

View File

@@ -289,9 +289,9 @@ void DrawEmitterCPU(RenderContext& renderContext, ParticleBuffer* buffer, DrawCa
// Check if need to setup ribbon modules
int32 ribbonModuleIndex = 0;
int32 ribbonModulesDrawIndicesPos = 0;
int32 ribbonModulesDrawIndicesStart[PARTICLE_EMITTER_MAX_RIBBONS];
int32 ribbonModulesDrawIndicesCount[PARTICLE_EMITTER_MAX_RIBBONS];
int32 ribbonModulesSegmentCount[PARTICLE_EMITTER_MAX_RIBBONS];
int32 ribbonModulesDrawIndicesStart[PARTICLE_EMITTER_MAX_RIBBONS] = {};
int32 ribbonModulesDrawIndicesCount[PARTICLE_EMITTER_MAX_RIBBONS] = {};
int32 ribbonModulesSegmentCount[PARTICLE_EMITTER_MAX_RIBBONS] = {};
if (emitter->Graph.RibbonRenderingModules.HasItems())
{
// Prepare ribbon data

View File

@@ -481,7 +481,7 @@ bool CachedPSO::Init(GPUShader* shader, bool useDepth)
// Create pipeline states
GPUPipelineState::Description desc = GPUPipelineState::Description::DefaultFullscreenTriangle;
desc.DepthEnable = desc.DepthWriteEnable = useDepth;
desc.DepthEnable = useDepth;
desc.DepthWriteEnable = false;
desc.DepthClipEnable = false;
desc.VS = shader->GetVS("VS");

View File

@@ -40,6 +40,12 @@ struct FLAXENGINE_API ScriptingTypeHandle
{
}
FORCE_INLINE ScriptingTypeHandle(ScriptingTypeHandle&& other)
: Module(other.Module)
, TypeIndex(other.TypeIndex)
{
}
ScriptingTypeHandle(const ScriptingTypeInitializer& initializer);
FORCE_INLINE operator bool() const

View File

@@ -1215,7 +1215,8 @@ Color32* TerrainPatch::GetSplatMapData(int32 index)
void TerrainPatch::ClearSplatMapCache()
{
PROFILE_CPU_NAMED("Terrain.ClearSplatMapCache");
_cachedSplatMap->Clear();
if (_cachedSplatMap)
_cachedSplatMap->Clear();
}
void TerrainPatch::ClearCache()