Bug 1426351 - WindowSurfaceWayland - delete WaylandDisplay owned by compositor thread at compositor thread, r?jhorak draft
authorMartin Stransky <stransky@redhat.com>
Wed, 20 Dec 2017 14:18:18 +0100
changeset 713483 459c6edc10f74f72c9ae558868859fc4924b5491
parent 713183 2d580aeac901ce5c61a4e5445b46906ce3cf33d8
child 744343 d7709a2ba1df9889b776c341b9d480772121adc9
push id93652
push userstransky@redhat.com
push dateWed, 20 Dec 2017 13:18:45 +0000
reviewersjhorak
bugs1426351
milestone59.0a1
Bug 1426351 - WindowSurfaceWayland - delete WaylandDisplay owned by compositor thread at compositor thread, r?jhorak MozReview-Commit-ID: 6jtdXuiTj1F
widget/gtk/WindowSurfaceWayland.cpp
widget/gtk/WindowSurfaceWayland.h
--- a/widget/gtk/WindowSurfaceWayland.cpp
+++ b/widget/gtk/WindowSurfaceWayland.cpp
@@ -551,16 +551,17 @@ static const struct wl_callback_listener
 
 WindowSurfaceWayland::WindowSurfaceWayland(nsWindow *aWindow)
   : mWindow(aWindow)
   , mWaylandDisplay(WaylandDisplayGet(aWindow->GetWaylandDisplay()))
   , mFrontBuffer(nullptr)
   , mBackBuffer(nullptr)
   , mFrameCallback(nullptr)
   , mFrameCallbackSurface(nullptr)
+  , mDisplayThreadMessageLoop(MessageLoop::current())
   , mDelayedCommit(false)
   , mFullScreenDamage(false)
   , mIsMainThread(NS_IsMainThread())
 {
 }
 
 WindowSurfaceWayland::~WindowSurfaceWayland()
 {
@@ -569,18 +570,18 @@ WindowSurfaceWayland::~WindowSurfaceWayl
 
   if (mFrameCallback) {
     wl_callback_destroy(mFrameCallback);
   }
 
   if (!mIsMainThread) {
     // We can be destroyed from main thread even though we was created/used
     // in compositor thread. We have to unref/delete WaylandDisplay in compositor
-    // thread then.
-    MessageLoop::current()->PostTask(
+    // thread then and we can't use MessageLoop::current() here.
+    mDisplayThreadMessageLoop->PostTask(
       NewRunnableFunction(&WaylandDisplayRelease, mWaylandDisplay->GetDisplay()));
   } else {
     WaylandDisplayRelease(mWaylandDisplay->GetDisplay());
   }
 }
 
 WindowBackBuffer*
 WindowSurfaceWayland::GetBufferToDraw(int aWidth, int aHeight)
--- a/widget/gtk/WindowSurfaceWayland.h
+++ b/widget/gtk/WindowSurfaceWayland.h
@@ -116,16 +116,17 @@ private:
 
   // TODO: Do we need to hold a reference to nsWindow object?
   nsWindow*                 mWindow;
   nsWaylandDisplay*         mWaylandDisplay;
   WindowBackBuffer*         mFrontBuffer;
   WindowBackBuffer*         mBackBuffer;
   wl_callback*              mFrameCallback;
   wl_surface*               mFrameCallbackSurface;
+  MessageLoop*              mDisplayThreadMessageLoop;
   bool                      mDelayedCommit;
   bool                      mFullScreenDamage;
   bool                      mIsMainThread;
 };
 
 }  // namespace widget
 }  // namespace mozilla