summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <[email protected]>2018-04-06 11:18:05 +0200
committerAlbert Astals Cid <[email protected]>2018-04-06 11:19:23 +0200
commitd3c89a150511e98b9051bd721b8b513013e76cd4 (patch)
treeb0c4dcbc50775a0999937e8566e86aee55f2d287
parent09109dd6498549dd27a8da1890da25c6aad4686a (diff)
Cancel request when removing an observer
There's no need to continue generating something that won't be useful. Also fixes a crash if the request would report partial updates since at that stage it uses the observer and that is gone
-rw-r--r--core/document.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/core/document.cpp b/core/document.cpp
index e27f492..a70f84c 100644
--- a/core/document.cpp
+++ b/core/document.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
* Copyright (C) 2004-2005 by Enrico Ros <[email protected]> *
* Copyright (C) 2004-2008 by Albert Astals Cid <[email protected]> *
- * Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group *
+ * Copyright (C) 2017, 2018 Klarälvdalens Datakonsult AB, a KDAB Group *
* company, [email protected] Work sponsored by the *
* LiMux project of the city of Munich *
* *
@@ -2741,7 +2741,7 @@ void Document::addObserver( DocumentObserver * pObserver )
void Document::removeObserver( DocumentObserver * pObserver )
{
- // remove observer from the map. it won't receive notifications anymore
+ // remove observer from the set. it won't receive notifications anymore
if ( d->m_observers.contains( pObserver ) )
{
// free observer's pixmap data
@@ -2764,7 +2764,14 @@ void Document::removeObserver( DocumentObserver * pObserver )
++aIt;
}
- // delete observer entry from the map
+ for ( PixmapRequest *executingRequest : qAsConst( d->m_executingPixmapRequests ) )
+ {
+ if ( executingRequest->observer() == pObserver ) {
+ d->cancelRenderingBecauseOf( executingRequest, nullptr );
+ }
+ }
+
+ // remove observer entry from the set
d->m_observers.remove( pObserver );
}
}