mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
navigation: add missing sanity checks
On practice a failure happened due to a race condition, the instance already have been freed, but it could also happen if the instance would be null. Instead of crashing this sanity check is a more suitable option, since with G_DEBUG=fatal-warnings it will crash too. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6475>
This commit is contained in:
parent
106187cc59
commit
b18b3d00b7
1 changed files with 13 additions and 2 deletions
|
@ -93,8 +93,11 @@ gst_navigation_default_init (GstNavigationInterface * iface)
|
|||
void
|
||||
gst_navigation_send_event (GstNavigation * navigation, GstStructure * structure)
|
||||
{
|
||||
GstNavigationInterface *iface = GST_NAVIGATION_GET_INTERFACE (navigation);
|
||||
GstNavigationInterface *iface;
|
||||
|
||||
g_return_if_fail (GST_IS_NAVIGATION (navigation));
|
||||
|
||||
iface = GST_NAVIGATION_GET_INTERFACE (navigation);
|
||||
if (iface->send_event) {
|
||||
iface->send_event (navigation, structure);
|
||||
} else if (iface->send_event_simple) {
|
||||
|
@ -116,6 +119,7 @@ void
|
|||
gst_navigation_send_key_event (GstNavigation * navigation, const char *event,
|
||||
const char *key)
|
||||
{
|
||||
g_return_if_fail (GST_IS_NAVIGATION (navigation));
|
||||
g_return_if_fail (g_strcmp0 (event, "key-press") == 0 ||
|
||||
g_strcmp0 (event, "key-release") == 0);
|
||||
|
||||
|
@ -144,6 +148,7 @@ void
|
|||
gst_navigation_send_mouse_event (GstNavigation * navigation, const char *event,
|
||||
int button, double x, double y)
|
||||
{
|
||||
g_return_if_fail (GST_IS_NAVIGATION (navigation));
|
||||
g_return_if_fail (g_strcmp0 (event, "mouse-button-press") == 0 ||
|
||||
g_strcmp0 (event, "mouse-button-release") == 0 ||
|
||||
g_strcmp0 (event, "mouse-move") == 0);
|
||||
|
@ -173,6 +178,8 @@ void
|
|||
gst_navigation_send_mouse_scroll_event (GstNavigation * navigation,
|
||||
double x, double y, double delta_x, double delta_y)
|
||||
{
|
||||
g_return_if_fail (GST_IS_NAVIGATION (navigation));
|
||||
|
||||
gst_navigation_send_event (navigation,
|
||||
gst_structure_new (GST_NAVIGATION_EVENT_NAME,
|
||||
"event", G_TYPE_STRING, "mouse-scroll",
|
||||
|
@ -193,6 +200,8 @@ void
|
|||
gst_navigation_send_command (GstNavigation * navigation,
|
||||
GstNavigationCommand command)
|
||||
{
|
||||
g_return_if_fail (GST_IS_NAVIGATION (navigation));
|
||||
|
||||
gst_navigation_send_event (navigation,
|
||||
gst_structure_new (GST_NAVIGATION_EVENT_NAME, "event", G_TYPE_STRING,
|
||||
"command", "command-code", G_TYPE_UINT, (guint) command, NULL));
|
||||
|
@ -209,10 +218,12 @@ gst_navigation_send_command (GstNavigation * navigation,
|
|||
void
|
||||
gst_navigation_send_event_simple (GstNavigation * navigation, GstEvent * event)
|
||||
{
|
||||
GstNavigationInterface *iface = GST_NAVIGATION_GET_INTERFACE (navigation);
|
||||
GstNavigationInterface *iface;
|
||||
|
||||
g_return_if_fail (GST_IS_NAVIGATION (navigation));
|
||||
g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_NAVIGATION);
|
||||
|
||||
iface = GST_NAVIGATION_GET_INTERFACE (navigation);
|
||||
if (iface->send_event_simple) {
|
||||
iface->send_event_simple (navigation, event);
|
||||
} else if (iface->send_event) {
|
||||
|
|
Loading…
Reference in a new issue