From f906e44c327303c433d8d812ff053a1018ad64e7 Mon Sep 17 00:00:00 2001 From: Joilnen Date: Tue, 26 Jul 2022 02:35:46 -0300 Subject: [PATCH 1/4] simplifying remove render targets in more C++11 style --- OgreMain/src/OgreRenderSystem.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/OgreMain/src/OgreRenderSystem.cpp b/OgreMain/src/OgreRenderSystem.cpp index 76567299512..9ef750ec3e4 100644 --- a/OgreMain/src/OgreRenderSystem.cpp +++ b/OgreMain/src/OgreRenderSystem.cpp @@ -630,22 +630,15 @@ namespace Ogre { // Remove all the render targets. Destroy primary target last since others may depend on it. // Keep mRenderTargets valid all the time, so that render targets could receive // appropriate notifications, for example FBO based about GL context destruction. - RenderTarget* primary = 0; - for (RenderTargetMap::iterator it = mRenderTargets.begin(); it != mRenderTargets.end(); /* note - no increment */) - { - RenderTarget* current = it->second; - if (!primary && current->isPrimary()) - { - ++it; - primary = current; - } - else - { - it = mRenderTargets.erase(it); - OGRE_DELETE current; - } + RenderTarget* current {nullptr}; + for (auto &&a : mRenderTargets) { + current = a.second; + if (a.second->isPrimary()) + continue; + OGRE_DELETE current; + mRenderTargets.erase(a.first); } - OGRE_DELETE primary; + OGRE_DELETE current; mRenderTargets.clear(); mPrioritisedRenderTargets.clear(); From e46991c5f5c819a7ddfc8698f266eae72bca2946 Mon Sep 17 00:00:00 2001 From: Joilnen Date: Tue, 26 Jul 2022 11:54:55 -0300 Subject: [PATCH 2/4] Update OgreRenderSystem.cpp --- OgreMain/src/OgreRenderSystem.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/OgreMain/src/OgreRenderSystem.cpp b/OgreMain/src/OgreRenderSystem.cpp index 9ef750ec3e4..fbf93e740fb 100644 --- a/OgreMain/src/OgreRenderSystem.cpp +++ b/OgreMain/src/OgreRenderSystem.cpp @@ -630,15 +630,18 @@ namespace Ogre { // Remove all the render targets. Destroy primary target last since others may depend on it. // Keep mRenderTargets valid all the time, so that render targets could receive // appropriate notifications, for example FBO based about GL context destruction. + RenderTarget* primary {nullptr}; RenderTarget* current {nullptr}; for (auto &&a : mRenderTargets) { current = a.second; - if (a.second->isPrimary()) + if (!primary && a.second->isPrimary()) { + primary = a.second; continue; + } OGRE_DELETE current; mRenderTargets.erase(a.first); } - OGRE_DELETE current; + OGRE_DELETE primary; mRenderTargets.clear(); mPrioritisedRenderTargets.clear(); From 833dc4f324c37cd0422c6a61ca20df41245b4587 Mon Sep 17 00:00:00 2001 From: Joilnen Date: Tue, 26 Jul 2022 13:44:16 -0300 Subject: [PATCH 3/4] Update OgreMain/src/OgreRenderSystem.cpp Co-authored-by: Pavel Rojtberg --- OgreMain/src/OgreRenderSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OgreMain/src/OgreRenderSystem.cpp b/OgreMain/src/OgreRenderSystem.cpp index fbf93e740fb..8052ce539d4 100644 --- a/OgreMain/src/OgreRenderSystem.cpp +++ b/OgreMain/src/OgreRenderSystem.cpp @@ -638,7 +638,7 @@ namespace Ogre { primary = a.second; continue; } - OGRE_DELETE current; + OGRE_DELETE a.second; mRenderTargets.erase(a.first); } OGRE_DELETE primary; From 7512d8136f36149144faab1eb771d851c85b2d70 Mon Sep 17 00:00:00 2001 From: Joilnen Date: Tue, 26 Jul 2022 14:10:04 -0300 Subject: [PATCH 4/4] Update OgreRenderSystem.cpp discarding not necessary variable --- OgreMain/src/OgreRenderSystem.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/OgreMain/src/OgreRenderSystem.cpp b/OgreMain/src/OgreRenderSystem.cpp index 8052ce539d4..fe90152d0bd 100644 --- a/OgreMain/src/OgreRenderSystem.cpp +++ b/OgreMain/src/OgreRenderSystem.cpp @@ -631,9 +631,7 @@ namespace Ogre { // Keep mRenderTargets valid all the time, so that render targets could receive // appropriate notifications, for example FBO based about GL context destruction. RenderTarget* primary {nullptr}; - RenderTarget* current {nullptr}; for (auto &&a : mRenderTargets) { - current = a.second; if (!primary && a.second->isPrimary()) { primary = a.second; continue;