From e0e0f56b52ee6e67614c9dfcebd2b6a3686ff589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 10 Sep 2017 14:20:35 +0300 Subject: [PATCH] Fix/hide various clippy warnings in gstreamer-player And let PlayerGMainContextSignalDispatcher::new() return the correct type --- Gir_GstPlayer.toml | 5 ++++ examples/src/bin/player.rs | 7 ++++-- ...player_g_main_context_signal_dispatcher.rs | 9 -------- gstreamer-player/src/lib.rs | 3 +++ ...player_g_main_context_signal_dispatcher.rs | 23 +++++++++++++++++++ 5 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 gstreamer-player/src/player_g_main_context_signal_dispatcher.rs diff --git a/Gir_GstPlayer.toml b/Gir_GstPlayer.toml index 501977b57..2d94f9a68 100644 --- a/Gir_GstPlayer.toml +++ b/Gir_GstPlayer.toml @@ -153,3 +153,8 @@ trait = false name = "GstPlayer.PlayerGMainContextSignalDispatcher" status = "generate" trait = false + + [[object.function]] + name = "new" + # Wrong return value + ignore = true diff --git a/examples/src/bin/player.rs b/examples/src/bin/player.rs index 6540dffb0..36d30c03f 100644 --- a/examples/src/bin/player.rs +++ b/examples/src/bin/player.rs @@ -18,8 +18,11 @@ fn main_loop(uri: &str) -> Result<(), utils::ExampleError> { let main_loop = glib::MainLoop::new(None, false); - let dispatcher = gst_player::PlayerGMainContextSignalDispatcher::new(None).unwrap(); - let player = gst_player::Player::new(None, Some(&dispatcher)); + let dispatcher = gst_player::PlayerGMainContextSignalDispatcher::new(None); + let player = gst_player::Player::new( + None, + Some(&dispatcher.upcast::()), + ); player .set_property("uri", &glib::Value::from(uri)) .expect("Can't set uri property"); diff --git a/gstreamer-player/src/auto/player_g_main_context_signal_dispatcher.rs b/gstreamer-player/src/auto/player_g_main_context_signal_dispatcher.rs index bf5e1387d..33b9c19a6 100644 --- a/gstreamer-player/src/auto/player_g_main_context_signal_dispatcher.rs +++ b/gstreamer-player/src/auto/player_g_main_context_signal_dispatcher.rs @@ -32,15 +32,6 @@ impl PlayerGMainContextSignalDispatcher { value.get() } - pub fn new<'a, P: Into>>(application_context: P) -> Option { - assert_initialized_main_thread!(); - let application_context = application_context.into(); - let application_context = application_context.to_glib_none(); - unsafe { - from_glib_full(ffi::gst_player_g_main_context_signal_dispatcher_new(application_context.0)) - } - } - pub fn connect_property_application_context_notify(&self, f: F) -> SignalHandlerId { unsafe { let f: Box_> = Box_::new(Box_::new(f)); diff --git a/gstreamer-player/src/lib.rs b/gstreamer-player/src/lib.rs index bc79a412a..19f30605c 100644 --- a/gstreamer-player/src/lib.rs +++ b/gstreamer-player/src/lib.rs @@ -38,6 +38,8 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] #[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] #[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))] +#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] +#[cfg_attr(feature = "cargo-clippy", allow(useless_transmute))] mod auto; pub use auto::*; @@ -45,6 +47,7 @@ mod player; mod player_video_overlay_video_renderer; pub use player_video_overlay_video_renderer::PlayerVideoOverlayVideoRendererExtManual; +mod player_g_main_context_signal_dispatcher; // Re-export all the traits in a prelude module, so that applications // can always "use gst::prelude::*" without getting conflicts diff --git a/gstreamer-player/src/player_g_main_context_signal_dispatcher.rs b/gstreamer-player/src/player_g_main_context_signal_dispatcher.rs new file mode 100644 index 000000000..d0150201c --- /dev/null +++ b/gstreamer-player/src/player_g_main_context_signal_dispatcher.rs @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Sebastian Dröge +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use PlayerGMainContextSignalDispatcher; +use ffi; +use glib; +use glib::translate::*; + +impl PlayerGMainContextSignalDispatcher { + pub fn new<'a, P: Into>>(application_context: P) -> PlayerGMainContextSignalDispatcher { + assert_initialized_main_thread!(); + let application_context = application_context.into(); + let application_context = application_context.to_glib_none(); + unsafe { + from_glib_full(ffi::gst_player_g_main_context_signal_dispatcher_new(application_context.0) as *mut ffi::GstPlayerGMainContextSignalDispatcher) + } + } +}