svtools/source/graphic/grfmgr2.cxx |   29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

New commits:
commit ca436d4da64e6a06832c324ccf5c0236a9ec90d7
Author: Armin Le Grand <a...@apache.org>
Date:   Mon Sep 1 10:32:51 2014 +0000

    i125519 check GraphicObject existance before accessing it

diff --git a/svtools/source/graphic/grfmgr2.cxx 
b/svtools/source/graphic/grfmgr2.cxx
index 5cac068..bc09415 100644
--- a/svtools/source/graphic/grfmgr2.cxx
+++ b/svtools/source/graphic/grfmgr2.cxx
@@ -358,8 +358,33 @@ void GraphicManager::ImplCheckSizeOfSwappedInGraphics()
                 // do not swap out when we have less than 16KB data objects
                 if(nSizeBytes >= (16 * 1024))
                 {
-                    pObj->FireSwapOutRequest();
-                    nUsedSize = (nSizeBytes < nUsedSize) ? nUsedSize - 
nSizeBytes : 0;
+                    // #125519# need to check if GraphicObject is still alive
+                    GraphicObject* pObj2 = 0;
+                    bool bExists(false);
+
+                    for(pObj2 = (GraphicObject*)maObjList.First(); !bExists && 
pObj2; pObj2 = (GraphicObject*)maObjList.Next())
+                    {
+                        if(pObj2 && pObj2 == pObj)
+                        {
+                            bExists = true;
+                        }
+                    }
+
+                    if(bExists)
+                    {
+                        // #125519# okay, swap it out
+                        pObj->FireSwapOutRequest();
+                        nUsedSize = (nSizeBytes < nUsedSize) ? nUsedSize - 
nSizeBytes : 0;
+                    }
+                    else
+                    {
+                        // #125519# error: object was deleted while still a 
member in aCandidates. This means that
+                        // an earlier call to pObj->FireSwapOutRequest() on an 
other GraphicObject has as
+                        // a side effect *deleted* and thus removed another 
GraphicObject from the local
+                        // list (maObjList). This must of course be avoided.
+                        // To check without need to run in debugger, 
optionally temporarily reactivate the beep below
+                        // Sound::Beep();
+                    }
                 }
             }
         }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to