https://bugs.webkit.org/show_bug.cgi?id=81706
Patch by Joe Mason <jmason@rim.com> on 2012-03-27
Reviewed by Rob Buis.
LayerCompositingThread has a destructor that does a synchronous
dispatch to the compositing thread and then does the actual cleanup
from a helper function. This is confusing.It should be the
opposite: the helper function dispatches to the compositing thread,
which calls delete.
No new tests since the existing animation tests will exercise this
code.
* platform/graphics/blackberry/LayerCompositingThread.cpp:
(WebCore::LayerCompositingThread::destroyOnCompositingThread):
(WebCore):
(WebCore::LayerCompositingThread::~LayerCompositingThread):
* platform/graphics/blackberry/LayerCompositingThread.h:
(LayerCompositingThread):
(WTF):
(WTF::::deref):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@112304
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-03-27 Joe Mason <jmason@rim.com>
+
+ [BlackBerry] fix confusing destruction sequence in LayerCompositingThread
+ https://bugs.webkit.org/show_bug.cgi?id=81706
+
+ Reviewed by Rob Buis.
+
+ LayerCompositingThread has a destructor that does a synchronous
+ dispatch to the compositing thread and then does the actual cleanup
+ from a helper function. This is confusing.It should be the
+ opposite: the helper function dispatches to the compositing thread,
+ which calls delete.
+
+ No new tests since the existing animation tests will exercise this
+ code.
+
+ * platform/graphics/blackberry/LayerCompositingThread.cpp:
+ (WebCore::LayerCompositingThread::destroyOnCompositingThread):
+ (WebCore):
+ (WebCore::LayerCompositingThread::~LayerCompositingThread):
+ * platform/graphics/blackberry/LayerCompositingThread.h:
+ (LayerCompositingThread):
+ (WTF):
+ (WTF::::deref):
+
2012-03-27 Alexey Proskuryakov <ap@apple.com>
[Mac] Stop using NSMapTable in FormDataStreamMac.mm
{
}
-LayerCompositingThread::~LayerCompositingThread()
-{
- // Unfortunately, ThreadSafeShared<T> is hardwired to call T::~T().
- // To switch threads in case the last reference is released on the
- // WebKit thread, we send a sync message to the compositing thread.
- destroyOnCompositingThread();
-}
-
void LayerCompositingThread::destroyOnCompositingThread()
{
if (!isCompositingThread()) {
return;
}
+ delete this;
+}
+
+LayerCompositingThread::~LayerCompositingThread()
+{
+ ASSERT(isCompositingThread());
+
m_tiler->layerCompositingThreadDestroyed();
ASSERT(!superlayer());
namespace WebCore {
-class DestroyOnCompositingThread;
class LayerRenderer;
class LayerCompositingThread : public ThreadSafeRefCounted<LayerCompositingThread>, public LayerData, public BlackBerry::Platform::GuardedPointerBase {
private:
LayerCompositingThread(LayerType, PassRefPtr<LayerTiler>);
- friend class DestroyOnCompositingThread;
+ friend class WTF::ThreadSafeRefCounted<WebCore::LayerCompositingThread>;
void destroyOnCompositingThread();
void updateTileContents(const IntRect& tile);
RefPtr<LayerTiler> m_tiler;
};
+} // namespace WebCore
+
+namespace WTF {
+
+// LayerCompositingThread objects must be destroyed on the compositing thread.
+// But it's possible for the last reference to be held by the WebKit thread.
+// So we create a custom specialization of ThreadSafeRefCounted which calls a
+// function that ensures the destructor is called on the correct thread, rather
+// than calling delete directly.
+template<>
+inline void ThreadSafeRefCounted<WebCore::LayerCompositingThread>::deref()
+{
+ if (derefBase())
+ static_cast<WebCore::LayerCompositingThread*>(this)->destroyOnCompositingThread();
}
+} // namespace WTF
+
+
#endif // USE(ACCELERATED_COMPOSITING)
#endif