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
This commit is contained in:
Scott Talbert
2020-09-02 09:30:44 -04:00
committed by Vadim Zeitlin
parent 1ce2ab5d49
commit be1854c617

View File

@@ -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