From be1854c6174229563072b9a1f89375288eaaf739 Mon Sep 17 00:00:00 2001 From: Scott Talbert Date: Wed, 2 Sep 2020 09:30:44 -0400 Subject: [PATCH] Avoid UI functions in non-main thread in wxGStreamerMediaBackend In aa2cd42206 (Report video size changes to the media backend, 2016-02-22), a couple of calls to NotifyMovieSizeChanged() were added, presumably for a good reason. Unfortunately, NotifySizeChanged() makes UI calls on wxGTK, so this resulted in UI calls happening on a non-main thread because many of GStreamer's callbacks occur on arbitrary threads. This is bad because it caused random X11 crashes. Fix this by calling NotifyMovieSizeChanged() with CallAfter(). Closes https://github.com/wxWidgets/wxWidgets/pull/2042 --- src/unix/mediactrl.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/unix/mediactrl.cpp b/src/unix/mediactrl.cpp index 3c55b1ae33..93dbb7c995 100644 --- a/src/unix/mediactrl.cpp +++ b/src/unix/mediactrl.cpp @@ -209,6 +209,7 @@ class wxGStreamerMediaEventHandler : public wxEvtHandler } void OnMediaFinish(wxMediaEvent& event); + void NotifyMovieSizeChanged(); wxGStreamerMediaBackend* m_be; }; @@ -633,14 +634,14 @@ bool wxGStreamerMediaBackend::QueryVideoSizeFromPad(GstPad* pad) gst_caps_unref (caps); #endif - NotifyMovieSizeChanged (); + m_eventHandler->CallAfter(&wxGStreamerMediaEventHandler::NotifyMovieSizeChanged); return true; } // end if caps m_videoSize = wxSize(0,0); - NotifyMovieSizeChanged (); + m_eventHandler->CallAfter(&wxGStreamerMediaEventHandler::NotifyMovieSizeChanged); return false; // not ready/massive failure } @@ -895,6 +896,11 @@ void wxGStreamerMediaEventHandler::OnMediaFinish(wxMediaEvent& WXUNUSED(event)) } } +void wxGStreamerMediaEventHandler::NotifyMovieSizeChanged() +{ + m_be->NotifyMovieSizeChanged(); +} + //----------------------------------------------------------------------------- // // Public methods