[BlackBerry] fix confusing destruction sequence in LayerCompositingThread
[WebKit-https.git] / Source / WebCore / platform / graphics / blackberry / LayerCompositingThread.cpp
index 89a9cf7716a4c40f90c17b9cfd38b9814e3bc629..a41497dfe5de123ace0f02e838423919929f0b6d 100644 (file)
@@ -71,14 +71,6 @@ LayerCompositingThread::LayerCompositingThread(LayerType type, PassRefPtr<LayerT
 {
 }
 
-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()) {
@@ -88,6 +80,13 @@ void LayerCompositingThread::destroyOnCompositingThread()
         return;
     }
 
+    delete this;
+}
+
+LayerCompositingThread::~LayerCompositingThread()
+{
+    ASSERT(isCompositingThread());
+
     m_tiler->layerCompositingThreadDestroyed();
 
     ASSERT(!superlayer());