diff options
author | Janne Kangas <janne.kangas@qt.io> | 2019-10-08 12:32:11 +0300 |
---|---|---|
committer | Janne Kangas <janne.kangas@qt.io> | 2019-11-20 16:09:17 +0200 |
commit | 23146bfe5641cb35eb73235f9dddfba99ebfaf76 (patch) | |
tree | 3fd4cef0181acfe80aa707f3b6eb497ffae71af2 /src | |
parent | bcde98fd401af64791de38764246f8f73512db56 (diff) |
Fix crash when effect shader code is changed externally
Remove items in correct manner when iterating m_Contexts vector. Crash fix
also requires Editor-side commit.
Change-Id: I46ab3ae406bb837f204d47b22f95e87305df52e0
Task-id: QT3DS-3990
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/runtimerender/Qt3DSRenderEffectSystem.cpp | 24 | ||||
-rw-r--r-- | src/runtimerender/Qt3DSRenderEffectSystem.h | 3 |
2 files changed, 9 insertions, 18 deletions
diff --git a/src/runtimerender/Qt3DSRenderEffectSystem.cpp b/src/runtimerender/Qt3DSRenderEffectSystem.cpp index 2db30bb..b10345c 100644 --- a/src/runtimerender/Qt3DSRenderEffectSystem.cpp +++ b/src/runtimerender/Qt3DSRenderEffectSystem.cpp @@ -709,9 +709,15 @@ struct SEffectSystem : public IEffectSystem if (iter != m_EffectClasses.end()) m_EffectClasses.erase(iter); - for (QT3DSU32 idx = 0, end = m_Contexts.size(); idx < end; ++idx) { - if (m_Contexts[idx]->m_ClassName == inName) - ReleaseEffectContext(m_Contexts[idx]); + TContextList::iterator ctxIter = m_Contexts.begin(); + + while (ctxIter != m_Contexts.end()) { + if ((*ctxIter)->m_ClassName == inName) { + QT3DS_FREE(m_Allocator, *ctxIter); + ctxIter = m_Contexts.erase(ctxIter); + } else { + ctxIter++; + } } return true; } @@ -1773,18 +1779,6 @@ struct SEffectSystem : public IEffectSystem return true; } - void ReleaseEffectContext(SEffectContext *inContext) override - { - if (inContext == NULL) - return; - for (QT3DSU32 idx = 0, end = m_Contexts.size(); idx < end; ++idx) { - if (m_Contexts[idx] == inContext) { - m_Contexts.replace_with_last(idx); - NVDelete(m_Allocator, inContext); - } - } - } - void ResetEffectFrameData(SEffectContext &inContext) override { // Query for size on every loop intentional for (QT3DSU32 idx = 0; idx < inContext.m_AllocatedBuffers.size(); ++idx) { diff --git a/src/runtimerender/Qt3DSRenderEffectSystem.h b/src/runtimerender/Qt3DSRenderEffectSystem.h index def1539..5bfa5d6 100644 --- a/src/runtimerender/Qt3DSRenderEffectSystem.h +++ b/src/runtimerender/Qt3DSRenderEffectSystem.h @@ -183,9 +183,6 @@ namespace render { virtual ~IEffectSystem() {} public: - // Calling release effect context with no context results in no problems. - virtual void ReleaseEffectContext(SEffectContext *inEffect) = 0; - // If the effect has a context you can call this to clear persistent buffers back to their // original value. virtual void ResetEffectFrameData(SEffectContext &inContext) = 0; |