Kaydet (Commit) abe9d146 authored tarafından Caolán McNamara's avatar Caolán McNamara

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
üst eea8c671
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment