summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-12-12 10:39:06 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-12-12 13:39:29 +0000
commit026e9335d792c6557255f064960e0ef6d28728e0 (patch)
tree0b6b4cbcf2a36910091360534e7cfc2b427178c3
parent3857e8c31fd61d997b94b58b7ed898e7a6546a4a (diff)
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)
-rw-r--r--sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx33
-rw-r--r--sd/source/ui/slidesorter/cache/SlsRequestQueue.hxx12
2 files changed, 38 insertions, 7 deletions
diff --git a/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx b/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx
index d02bae16e630..8db2bced8b64 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 dc5a92fa1c13..c9eb9a95db45 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;