[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - 2 commits - sd/source

Caolán McNamara caolanm at redhat.com
Thu Dec 12 05:40:28 PST 2013


 sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx |   44 +++++++++++++++++----
 sd/source/ui/slidesorter/cache/SlsRequestQueue.hxx |   12 ++++-
 2 files changed, 46 insertions(+), 10 deletions(-)

New commits:
commit be366ad7690b190c5ef4dc42311a4df6b7dcce4b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Dec 12 12:37:43 2013 +0000

    pages with equal Priority and Class getting dropped
    
    Change-Id: Ib053dc4b6e5fb5f01f48c71a4b295a53c0ec6715
    (cherry picked from commit 9790588da4b2de455ffc7a2cc69f26539823c3da)

diff --git a/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx b/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx
index 8db2bce..cdc2b57 100644
--- a/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx
@@ -40,9 +40,14 @@ public:
         bool operator() (const Request& rRequest1, const Request& rRequest2)
         {
             if (rRequest1.meClass == rRequest2.meClass)
-                return (rRequest1.mnPriorityInClass > rRequest2.mnPriorityInClass);
-            else
-                return (rRequest1.meClass < rRequest2.meClass);
+            {
+                if (rRequest1.mnPriorityInClass == rRequest2.mnPriorityInClass)
+                {
+                    return rRequest1.maKey < rRequest2.maKey;
+                }
+                return rRequest1.mnPriorityInClass > rRequest2.mnPriorityInClass;
+            }
+            return rRequest1.meClass < rRequest2.meClass;
         }
     };
     /** Request data is compared arbitrarily by their addresses in memory.
commit 026e9335d792c6557255f064960e0ef6d28728e0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Dec 12 10:39:06 2013 +0000

    fix occasional crash on dragging and dropping pages in slidesorters
    
    pages go into the cache, and sometimes they get deleted before the
    cache gets processed. Remove deleted pages when they go away
    
    Change-Id: I291072a8541f4ca36979e9914975d81cc23a9497
    (cherry picked from commit abe9d1463282690313aaf91d2a54011d10b900b9)

diff --git a/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx b/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx
index d02bae1..8db2bce 100644
--- a/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx
@@ -89,6 +89,7 @@ RequestQueue::RequestQueue (const SharedCacheContext& rpCacheContext)
 
 RequestQueue::~RequestQueue (void)
 {
+    Clear();
 }
 
 
@@ -115,7 +116,15 @@ void RequestQueue::AddRequest (
     // order.
     sal_Int32 nPriority (mpCacheContext->GetPriority(aKey));
     Request aRequest (aKey, nPriority, eRequestClass);
-    mpRequestQueue->insert(aRequest);
+
+    std::pair<Container::iterator,bool> ret = mpRequestQueue->insert(aRequest);
+    bool bInserted = ret.second == true;
+
+    if (bInserted)
+    {
+        SdrPage *pPage = const_cast<SdrPage*>(aRequest.maKey);
+        pPage->AddPageUser(*this);
+    }
 
     SSCD_SET_REQUEST_CLASS(aKey,eRequestClass);
 
@@ -126,8 +135,11 @@ void RequestQueue::AddRequest (
 #endif
 }
 
-
-
+void RequestQueue::PageInDestruction(const SdrPage& rPage)
+{
+    //remove any requests pending for this page which is going away now
+    RemoveRequest(&rPage);
+}
 
 bool RequestQueue::RemoveRequest (
     CacheKey aKey)
@@ -147,7 +159,11 @@ bool RequestQueue::RemoveRequest (
                 mnMinimumPriority++;
             else if (aRequestIterator->mnPriorityInClass == mnMaximumPriority-1)
                 mnMaximumPriority--;
+
+            SdrPage *pPage = const_cast<SdrPage*>(aRequestIterator->maKey);
+            pPage->RemovePageUser(*this);
             mpRequestQueue->erase(aRequestIterator);
+
             bRequestWasRemoved = true;
 
             if (bRequestWasRemoved)
@@ -224,7 +240,10 @@ void RequestQueue::PopFront (void)
     {
         SSCD_SET_STATUS(maRequestQueue.begin()->mpData->GetPage(),NONE);
 
-        mpRequestQueue->erase(mpRequestQueue->begin());
+        Container::const_iterator aIter(mpRequestQueue->begin());
+        SdrPage *pPage = const_cast<SdrPage*>(aIter->maKey);
+        pPage->RemovePageUser(*this);
+        mpRequestQueue->erase(aIter);
 
         // Reset the priority counter if possible.
         if (mpRequestQueue->empty())
@@ -251,6 +270,12 @@ void RequestQueue::Clear (void)
 {
     ::osl::MutexGuard aGuard (maMutex);
 
+    for (Container::iterator aI = mpRequestQueue->begin(), aEnd = mpRequestQueue->end(); aI != aEnd; ++aI)
+    {
+        SdrPage *pPage = const_cast<SdrPage*>(aI->maKey);
+        pPage->RemovePageUser(*this);
+    }
+
     mpRequestQueue->clear();
     mnMinimumPriority = 0;
     mnMaximumPriority = 1;
diff --git a/sd/source/ui/slidesorter/cache/SlsRequestQueue.hxx b/sd/source/ui/slidesorter/cache/SlsRequestQueue.hxx
index dc5a92f..c9eb9a9 100644
--- a/sd/source/ui/slidesorter/cache/SlsRequestQueue.hxx
+++ b/sd/source/ui/slidesorter/cache/SlsRequestQueue.hxx
@@ -24,7 +24,8 @@
 #include "cache/SlsCacheContext.hxx"
 #include "taskpane/SlideSorterCacheDisplay.hxx"
 #include <drawdoc.hxx>
-#include "osl/mutex.hxx"
+#include <osl/mutex.hxx>
+#include <svx/sdrpageuser.hxx>
 
 
 namespace sd { namespace slidesorter { namespace cache {
@@ -34,11 +35,11 @@ class RequestData;
 /** The request queue stores requests that are described by the RequestData
     sorted according to priority class and then priority.
 */
-class RequestQueue
+class RequestQueue : public sdr::PageUser
 {
 public:
     RequestQueue (const SharedCacheContext& rpCacheContext);
-    ~RequestQueue (void);
+    virtual ~RequestQueue();
 
     /** Insert a request with highest or lowest priority in its priority
         class.  When the request is already present then it is first
@@ -99,6 +100,11 @@ public:
     */
     ::osl::Mutex& GetMutex (void);
 
+    /** Ensure we don't hand out a page deleted before anyone got a
+        chance to process it
+    */
+    virtual void PageInDestruction(const SdrPage& rPage);
+
 private:
     ::osl::Mutex maMutex;
     class Container;


More information about the Libreoffice-commits mailing list