[Libreoffice-commits] .: sd/source

David Tardon dtardon at kemper.freedesktop.org
Mon Dec 27 00:34:10 PST 2010


 sd/source/ui/view/ViewShellManager.cxx |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

New commits:
commit ae8809a3f68044be38d2f39532123bd780bb794c
Author: David Tardon <dtardon at redhat.com>
Date:   Mon Dec 27 09:16:55 2010 +0100

    avoid use of invalidated iterator in comparison

diff --git a/sd/source/ui/view/ViewShellManager.cxx b/sd/source/ui/view/ViewShellManager.cxx
index 397a825..fb7db4b 100644
--- a/sd/source/ui/view/ViewShellManager.cxx
+++ b/sd/source/ui/view/ViewShellManager.cxx
@@ -41,6 +41,7 @@
 #include <svx/fmshell.hxx>
 
 #include <hash_map>
+#include <iterator>
 
 #undef VERBOSE
 //#define VERBOSE 2
@@ -938,7 +939,7 @@ void ViewShellManager::Implementation::UpdateShellStack (void)
 
     
     // 4. Find the lowest shell in which the two stacks differ.
-    ShellStack::const_iterator iSfxShell (aSfxShellStack.begin());
+    ShellStack::iterator iSfxShell (aSfxShellStack.begin());
     ShellStack::iterator iTargetShell (aTargetStack.begin());
     while (iSfxShell != aSfxShellStack.end()
         && iTargetShell!=aTargetStack.end()
@@ -951,15 +952,16 @@ void ViewShellManager::Implementation::UpdateShellStack (void)
     
     // 5. Remove all shells above and including the differing shell from the
     // SFX stack starting with the shell on top of the stack.
-    while (iSfxShell != aSfxShellStack.end())
+    for (std::reverse_iterator<ShellStack::const_iterator> i(aSfxShellStack.end()), iLast(iSfxShell);
+            i != iLast; ++i)
     {
-        SfxShell* pShell = aSfxShellStack.back();
-        aSfxShellStack.pop_back();
+        SfxShell* const pShell = *i;
 #ifdef VERBOSE
         OSL_TRACE("removing shell %p from stack\r", pShell);
 #endif
         mrBase.RemoveSubShell(pShell);
     }
+    aSfxShellStack.erase(iSfxShell, aSfxShellStack.end());
 
     
     // 6. Push shells from the given stack onto the SFX stack.


More information about the Libreoffice-commits mailing list