[Libreoffice-commits] core.git: 3 commits - sd/source

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


 sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx |   62 ++++++++++++++++-----
 sd/source/ui/slidesorter/cache/SlsRequestQueue.hxx |   12 +++-
 2 files changed, 59 insertions(+), 15 deletions(-)

New commits:
commit 9790588da4b2de455ffc7a2cc69f26539823c3da
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

diff --git a/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx b/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx
index c01847d..8c96d83 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 bd6dfbae4fd22767e227c5317d6696a70ed61c58
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Dec 12 12:34:08 2013 +0000

    remove unused ctor variant
    
    Change-Id: I0c9afcb5819fc83f75ee8c639de56b788c3d516d

diff --git a/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx b/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx
index 8db2bce..c01847d 100644
--- a/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx
@@ -49,11 +49,19 @@ public:
         This just establishes an order so that the STL containers are happy.
         The order is not semantically interpreted.
     */
-    class DataComparator { public:
-        DataComparator (const Request&rRequest):maKey(rRequest.maKey){}
-        DataComparator (const CacheKey aKey):maKey(aKey){}
-        bool operator() (const Request& rRequest) { return maKey == rRequest.maKey; }
-    private: const CacheKey maKey;
+    class DataComparator
+    {
+    public:
+        DataComparator (const CacheKey aKey)
+            : maKey(aKey)
+        {
+        }
+        bool operator() (const Request& rRequest) const
+        {
+            return maKey == rRequest.maKey;
+        }
+    private:
+        const CacheKey maKey;
     };
 
     CacheKey maKey;
commit abe9d1463282690313aaf91d2a54011d10b900b9
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

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