Bug 1426351 - WindowSurfaceWayland - delete WaylandDisplay owned by compositor thread at compositor thread, r?jhorak
MozReview-Commit-ID: 6jtdXuiTj1F
--- 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