diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fbe8d465..6eb3b77a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support for `QMessageLogContext` and sending log messages to the Qt message handler. - Serde support for further types: `QByteArray`, `QSet`, `QStringList`, `QVector`, `QUrl` - Added `QEventLoop` to cxx-qt-lib-extras. +- Add `QScopedMetaObjectConnectionGuard`, which is `QMetaObjectConnectionGuard` with a scoped lifetime. `QMetaObjectConnectionGuard` is now a type alias for `QScopedMetaObjectConnectionGuard<'static>`. ### Removed diff --git a/crates/cxx-qt-gen/src/generator/rust/property/mod.rs b/crates/cxx-qt-gen/src/generator/rust/property/mod.rs index db3e46e6a..2b8352fe1 100644 --- a/crates/cxx-qt-gen/src/generator/rust/property/mod.rs +++ b/crates/cxx-qt-gen/src/generator/rust/property/mod.rs @@ -280,7 +280,7 @@ mod tests { unsafe extern "C++" { #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] - type MyObjectCxxQtSignalHandlertrivialPropertyChanged = cxx_qt::signalhandler::CxxQtSignalHandler; + type MyObjectCxxQtSignalHandlertrivialPropertyChanged<'a> = cxx_qt::signalhandler::CxxQtSignalHandler<'a, super::MyObjectCxxQtSignalClosuretrivialPropertyChanged>; #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] @@ -310,9 +310,9 @@ mod tests { #[doc = "Connect the given function pointer to the signal "] #[doc = "trivialPropertyChanged"] #[doc = ", so that when the signal is emitted the function pointer is executed."] - pub fn connect_trivial_property_changed, ) + 'static + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType) -> cxx_qt::QMetaObjectConnectionGuard + pub fn connect_trivial_property_changed<'a, F: FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + 'a + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { - cxx_qt::QMetaObjectConnectionGuard::from(qobject::MyObject_connect_trivial_property_changed( + cxx_qt::QScopedMetaObjectConnectionGuard::from(qobject::MyObject_connect_trivial_property_changed( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new(Box::new(closure)), conn_type, @@ -330,9 +330,9 @@ mod tests { #[doc = ", so that when the signal is emitted the function pointer is executed."] #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] - pub fn on_trivial_property_changed, ) + 'static + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F) -> cxx_qt::QMetaObjectConnectionGuard + pub fn on_trivial_property_changed<'a, F: FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + 'a + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { - cxx_qt::QMetaObjectConnectionGuard::from(qobject::MyObject_connect_trivial_property_changed( + cxx_qt::QScopedMetaObjectConnectionGuard::from(qobject::MyObject_connect_trivial_property_changed( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new(Box::new(closure)), cxx_qt::ConnectionType::AutoConnection, @@ -353,7 +353,7 @@ mod tests { parse_quote! { impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClosuretrivialPropertyChanged { type Id = cxx::type_id!("::rust::cxxqtgen1::MyObjectCxxQtSignalHandlertrivialPropertyChanged"); - type FnType = dyn FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + 'a + Send; } }, ); @@ -405,7 +405,7 @@ mod tests { unsafe extern "C++" { #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] - type MyObjectCxxQtSignalHandleropaquePropertyChanged = cxx_qt::signalhandler::CxxQtSignalHandler; + type MyObjectCxxQtSignalHandleropaquePropertyChanged<'a> = cxx_qt::signalhandler::CxxQtSignalHandler<'a, super::MyObjectCxxQtSignalClosureopaquePropertyChanged>; #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] @@ -435,9 +435,9 @@ mod tests { #[doc = "Connect the given function pointer to the signal "] #[doc = "opaquePropertyChanged"] #[doc = ", so that when the signal is emitted the function pointer is executed."] - pub fn connect_opaque_property_changed, ) + 'static + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType) -> cxx_qt::QMetaObjectConnectionGuard + pub fn connect_opaque_property_changed<'a, F: FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + 'a + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { - cxx_qt::QMetaObjectConnectionGuard::from(qobject::MyObject_connect_opaque_property_changed( + cxx_qt::QScopedMetaObjectConnectionGuard::from(qobject::MyObject_connect_opaque_property_changed( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new(Box::new(closure)), conn_type, @@ -455,9 +455,9 @@ mod tests { #[doc = ", so that when the signal is emitted the function pointer is executed."] #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] - pub fn on_opaque_property_changed, ) + 'static + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F) -> cxx_qt::QMetaObjectConnectionGuard + pub fn on_opaque_property_changed<'a, F: FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + 'a + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { - cxx_qt::QMetaObjectConnectionGuard::from(qobject::MyObject_connect_opaque_property_changed( + cxx_qt::QScopedMetaObjectConnectionGuard::from(qobject::MyObject_connect_opaque_property_changed( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new(Box::new(closure)), cxx_qt::ConnectionType::AutoConnection, @@ -478,7 +478,7 @@ mod tests { parse_quote! { impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClosureopaquePropertyChanged { type Id = cxx::type_id!("::rust::cxxqtgen1::MyObjectCxxQtSignalHandleropaquePropertyChanged"); - type FnType = dyn FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + 'a + Send; } }, ); @@ -530,7 +530,7 @@ mod tests { unsafe extern "C++" { #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] - type MyObjectCxxQtSignalHandlerunsafePropertyChanged = cxx_qt::signalhandler::CxxQtSignalHandler; + type MyObjectCxxQtSignalHandlerunsafePropertyChanged<'a> = cxx_qt::signalhandler::CxxQtSignalHandler<'a, super::MyObjectCxxQtSignalClosureunsafePropertyChanged>; #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] @@ -560,9 +560,9 @@ mod tests { #[doc = "Connect the given function pointer to the signal "] #[doc = "unsafePropertyChanged"] #[doc = ", so that when the signal is emitted the function pointer is executed."] - pub fn connect_unsafe_property_changed, ) + 'static + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType) -> cxx_qt::QMetaObjectConnectionGuard + pub fn connect_unsafe_property_changed<'a, F: FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + 'a + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { - cxx_qt::QMetaObjectConnectionGuard::from(qobject::MyObject_connect_unsafe_property_changed( + cxx_qt::QScopedMetaObjectConnectionGuard::from(qobject::MyObject_connect_unsafe_property_changed( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new(Box::new(closure)), conn_type, @@ -580,9 +580,9 @@ mod tests { #[doc = ", so that when the signal is emitted the function pointer is executed."] #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] - pub fn on_unsafe_property_changed, ) + 'static + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F) -> cxx_qt::QMetaObjectConnectionGuard + pub fn on_unsafe_property_changed<'a, F: FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + 'a + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { - cxx_qt::QMetaObjectConnectionGuard::from(qobject::MyObject_connect_unsafe_property_changed( + cxx_qt::QScopedMetaObjectConnectionGuard::from(qobject::MyObject_connect_unsafe_property_changed( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new(Box::new(closure)), cxx_qt::ConnectionType::AutoConnection, @@ -603,7 +603,7 @@ mod tests { parse_quote! { impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClosureunsafePropertyChanged { type Id = cxx::type_id!("::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerunsafePropertyChanged"); - type FnType = dyn FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + 'a + Send; } }, ); diff --git a/crates/cxx-qt-gen/src/generator/rust/signals.rs b/crates/cxx-qt-gen/src/generator/rust/signals.rs index 0d18247f1..2b407522c 100644 --- a/crates/cxx-qt-gen/src/generator/rust/signals.rs +++ b/crates/cxx-qt-gen/src/generator/rust/signals.rs @@ -144,7 +144,7 @@ pub fn generate_rust_signal( unsafe extern "C++" { #[doc(hidden)] #[namespace = #namespace_str] - type #signal_handler_alias = cxx_qt::signalhandler::CxxQtSignalHandler; + type #signal_handler_alias<'a> = cxx_qt::signalhandler::CxxQtSignalHandler<'a, super::#closure_struct>; #[doc(hidden)] #[namespace = #namespace_str] @@ -175,9 +175,9 @@ pub fn generate_rust_signal( #[doc = "Connect the given function pointer to the signal "] #[doc = #signal_name_cpp] #[doc = ", so that when the signal is emitted the function pointer is executed."] - pub fn #connect_ident_rust(self: #self_type_qualified, closure: F, conn_type: cxx_qt::ConnectionType) -> cxx_qt::QMetaObjectConnectionGuard + pub fn #connect_ident_rust<'a, F: FnMut(#self_type_qualified, #(#parameters_qualified_type),*) + 'a + Send>(self: #self_type_qualified, closure: F, conn_type: cxx_qt::ConnectionType) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { - cxx_qt::QMetaObjectConnectionGuard::from(#module_ident::#free_connect_ident_rust( + cxx_qt::QScopedMetaObjectConnectionGuard::from(#module_ident::#free_connect_ident_rust( self, cxx_qt::signalhandler::CxxQtSignalHandler::<#closure_struct>::new(Box::new(closure)), conn_type, @@ -194,9 +194,9 @@ pub fn generate_rust_signal( #[doc = ", so that when the signal is emitted the function pointer is executed."] #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] - pub fn #on_ident_rust(self: #self_type_qualified, closure: F) -> cxx_qt::QMetaObjectConnectionGuard + pub fn #on_ident_rust<'a, F: FnMut(#self_type_qualified, #(#parameters_qualified_type),*) + 'a + Send>(self: #self_type_qualified, closure: F) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { - cxx_qt::QMetaObjectConnectionGuard::from(#module_ident::#free_connect_ident_rust( + cxx_qt::QScopedMetaObjectConnectionGuard::from(#module_ident::#free_connect_ident_rust( self, cxx_qt::signalhandler::CxxQtSignalHandler::<#closure_struct>::new(Box::new(closure)), cxx_qt::ConnectionType::AutoConnection, @@ -215,7 +215,7 @@ pub fn generate_rust_signal( #(#cfgs)* impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for #closure_struct { type Id = cxx::type_id!(#signal_handler_alias_namespaced_str); - type FnType = dyn FnMut(#self_type_qualified, #(#parameters_qualified_type),*) + Send; + type FnType<'a> = dyn FnMut(#self_type_qualified, #(#parameters_qualified_type),*) + 'a + Send; } }, parse_quote_spanned! { @@ -294,7 +294,7 @@ mod tests { unsafe extern "C++" { #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] - type MyObjectCxxQtSignalHandlerready = cxx_qt::signalhandler::CxxQtSignalHandler; + type MyObjectCxxQtSignalHandlerready<'a> = cxx_qt::signalhandler::CxxQtSignalHandler<'a, super::MyObjectCxxQtSignalClosureready>; #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] @@ -324,9 +324,9 @@ mod tests { #[doc = "Connect the given function pointer to the signal "] #[doc = "ready"] #[doc = ", so that when the signal is emitted the function pointer is executed."] - pub fn connect_ready, ) + 'static + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType) -> cxx_qt::QMetaObjectConnectionGuard + pub fn connect_ready<'a, F: FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + 'a + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { - cxx_qt::QMetaObjectConnectionGuard::from(qobject::MyObject_connect_ready( + cxx_qt::QScopedMetaObjectConnectionGuard::from(qobject::MyObject_connect_ready( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new(Box::new(closure)), conn_type, @@ -344,9 +344,9 @@ mod tests { #[doc = ", so that when the signal is emitted the function pointer is executed."] #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] - pub fn on_ready, ) + 'static + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F) -> cxx_qt::QMetaObjectConnectionGuard + pub fn on_ready<'a, F: FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + 'a + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { - cxx_qt::QMetaObjectConnectionGuard::from(qobject::MyObject_connect_ready( + cxx_qt::QScopedMetaObjectConnectionGuard::from(qobject::MyObject_connect_ready( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new(Box::new(closure)), cxx_qt::ConnectionType::AutoConnection, @@ -367,7 +367,7 @@ mod tests { quote! { impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClosureready { type Id = cxx::type_id!("::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerready"); - type FnType = dyn FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + 'a + Send; } }, ); @@ -474,7 +474,7 @@ mod tests { unsafe extern "C++" { #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] - type MyObjectCxxQtSignalHandlerdataChanged = cxx_qt::signalhandler::CxxQtSignalHandler; + type MyObjectCxxQtSignalHandlerdataChanged<'a> = cxx_qt::signalhandler::CxxQtSignalHandler<'a, super::MyObjectCxxQtSignalClosuredataChanged>; #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] @@ -504,9 +504,9 @@ mod tests { #[doc = "Connect the given function pointer to the signal "] #[doc = "dataChanged"] #[doc = ", so that when the signal is emitted the function pointer is executed."] - pub fn connect_data_changed, i32, cxx::UniquePtr) + 'static + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType) -> cxx_qt::QMetaObjectConnectionGuard + pub fn connect_data_changed<'a, F: FnMut(core::pin::Pin<&mut qobject::MyObject>, i32, cxx::UniquePtr) + 'a + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { - cxx_qt::QMetaObjectConnectionGuard::from(qobject::MyObject_connect_data_changed( + cxx_qt::QScopedMetaObjectConnectionGuard::from(qobject::MyObject_connect_data_changed( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new(Box::new(closure)), conn_type, @@ -524,9 +524,9 @@ mod tests { #[doc = ", so that when the signal is emitted the function pointer is executed."] #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] - pub fn on_data_changed, i32, cxx::UniquePtr) + 'static + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F) -> cxx_qt::QMetaObjectConnectionGuard + pub fn on_data_changed<'a, F: FnMut(core::pin::Pin<&mut qobject::MyObject>, i32, cxx::UniquePtr) + 'a + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { - cxx_qt::QMetaObjectConnectionGuard::from(qobject::MyObject_connect_data_changed( + cxx_qt::QScopedMetaObjectConnectionGuard::from(qobject::MyObject_connect_data_changed( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new(Box::new(closure)), cxx_qt::ConnectionType::AutoConnection, @@ -547,7 +547,7 @@ mod tests { quote! { impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClosuredataChanged { type Id = cxx::type_id!("::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerdataChanged"); - type FnType = dyn FnMut(core::pin::Pin<&mut qobject::MyObject>, i32, cxx::UniquePtr) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut qobject::MyObject>, i32, cxx::UniquePtr) + 'a + Send; } }, ); @@ -616,7 +616,7 @@ mod tests { unsafe extern "C++" { #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] - type MyObjectCxxQtSignalHandlerunsafeSignal = cxx_qt::signalhandler::CxxQtSignalHandler; + type MyObjectCxxQtSignalHandlerunsafeSignal<'a> = cxx_qt::signalhandler::CxxQtSignalHandler<'a, super::MyObjectCxxQtSignalClosureunsafeSignal>; #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] @@ -646,9 +646,9 @@ mod tests { #[doc = "Connect the given function pointer to the signal "] #[doc = "unsafeSignal"] #[doc = ", so that when the signal is emitted the function pointer is executed."] - pub fn connect_unsafe_signal, *mut T) + 'static +Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType) -> cxx_qt::QMetaObjectConnectionGuard + pub fn connect_unsafe_signal<'a, F: FnMut(core::pin::Pin<&mut qobject::MyObject>, *mut T) + 'a +Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { - cxx_qt::QMetaObjectConnectionGuard::from(qobject::MyObject_connect_unsafe_signal( + cxx_qt::QScopedMetaObjectConnectionGuard::from(qobject::MyObject_connect_unsafe_signal( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new(Box::new(closure)), conn_type, @@ -666,9 +666,9 @@ mod tests { #[doc = ", so that when the signal is emitted the function pointer is executed."] #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] - pub fn on_unsafe_signal, *mut T) + 'static + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F) -> cxx_qt::QMetaObjectConnectionGuard + pub fn on_unsafe_signal<'a, F: FnMut(core::pin::Pin<&mut qobject::MyObject>, *mut T) + 'a + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { - cxx_qt::QMetaObjectConnectionGuard::from(qobject::MyObject_connect_unsafe_signal( + cxx_qt::QScopedMetaObjectConnectionGuard::from(qobject::MyObject_connect_unsafe_signal( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new(Box::new(closure)), cxx_qt::ConnectionType::AutoConnection, @@ -689,7 +689,7 @@ mod tests { quote! { impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClosureunsafeSignal { type Id = cxx::type_id!("::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerunsafeSignal"); - type FnType = dyn FnMut(core::pin::Pin<&mut qobject::MyObject>, *mut T) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut qobject::MyObject>, *mut T) + 'a + Send; } }, ); @@ -759,7 +759,7 @@ mod tests { unsafe extern "C++" { #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] - type MyObjectCxxQtSignalHandlerbaseName = cxx_qt::signalhandler::CxxQtSignalHandler; + type MyObjectCxxQtSignalHandlerbaseName<'a> = cxx_qt::signalhandler::CxxQtSignalHandler<'a, super::MyObjectCxxQtSignalClosurebaseName>; #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] @@ -789,9 +789,9 @@ mod tests { #[doc = "Connect the given function pointer to the signal "] #[doc = "baseName"] #[doc = ", so that when the signal is emitted the function pointer is executed."] - pub fn connect_existing_signal, ) + 'static + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType) -> cxx_qt::QMetaObjectConnectionGuard + pub fn connect_existing_signal<'a, F: FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + 'a + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { - cxx_qt::QMetaObjectConnectionGuard::from(qobject::MyObject_connect_existing_signal( + cxx_qt::QScopedMetaObjectConnectionGuard::from(qobject::MyObject_connect_existing_signal( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new(Box::new(closure)), conn_type, @@ -809,9 +809,9 @@ mod tests { #[doc = ", so that when the signal is emitted the function pointer is executed."] #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] - pub fn on_existing_signal, ) + 'static + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F) -> cxx_qt::QMetaObjectConnectionGuard + pub fn on_existing_signal<'a, F: FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + 'a + Send>(self: core::pin::Pin<&mut qobject::MyObject>, closure: F) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { - cxx_qt::QMetaObjectConnectionGuard::from(qobject::MyObject_connect_existing_signal( + cxx_qt::QScopedMetaObjectConnectionGuard::from(qobject::MyObject_connect_existing_signal( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new(Box::new(closure)), cxx_qt::ConnectionType::AutoConnection, @@ -832,7 +832,7 @@ mod tests { quote! { impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClosurebaseName { type Id = cxx::type_id!("::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerbaseName"); - type FnType = dyn FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut qobject::MyObject>, ) + 'a + Send; } }, ); diff --git a/crates/cxx-qt-gen/test_outputs/cfgs.rs b/crates/cxx-qt-gen/test_outputs/cfgs.rs index af2f2f565..7b9fb6d51 100644 --- a/crates/cxx-qt-gen/test_outputs/cfgs.rs +++ b/crates/cxx-qt-gen/test_outputs/cfgs.rs @@ -99,8 +99,9 @@ mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] - type QObjectEnabledCxxQtSignalHandlersignal_disabled = + type QObjectEnabledCxxQtSignalHandlersignal_disabled<'a> = cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, super::QObjectEnabledCxxQtSignalClosuresignal_disabled, >; #[doc(hidden)] @@ -134,8 +135,9 @@ mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] - type QObjectEnabledCxxQtSignalHandlersignal_enabled = + type QObjectEnabledCxxQtSignalHandlersignal_enabled<'a> = cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, super::QObjectEnabledCxxQtSignalClosuresignal_enabled, >; #[doc(hidden)] @@ -241,8 +243,9 @@ mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] - type QObjectDisabledCxxQtSignalHandlersignal_disabled = + type QObjectDisabledCxxQtSignalHandlersignal_disabled<'a> = cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, super::QObjectDisabledCxxQtSignalClosuresignal_disabled, >; #[doc(hidden)] @@ -276,8 +279,9 @@ mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] - type QObjectDisabledCxxQtSignalHandlersignal_enabled = + type QObjectDisabledCxxQtSignalHandlersignal_enabled<'a> = cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, super::QObjectDisabledCxxQtSignalClosuresignal_enabled, >; #[doc(hidden)] @@ -365,8 +369,9 @@ mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] - type QObjectExternEnabledCxxQtSignalHandlersignal_disabled1 = + type QObjectExternEnabledCxxQtSignalHandlersignal_disabled1<'a> = cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, super::QObjectExternEnabledCxxQtSignalClosuresignal_disabled1, >; #[doc(hidden)] @@ -400,8 +405,9 @@ mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] - type QObjectExternEnabledCxxQtSignalHandlersignal_enabled1 = + type QObjectExternEnabledCxxQtSignalHandlersignal_enabled1<'a> = cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, super::QObjectExternEnabledCxxQtSignalClosuresignal_enabled1, >; #[doc(hidden)] @@ -453,8 +459,9 @@ mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] - type QObjectExternDisabledCxxQtSignalHandlersignal_disabled2 = + type QObjectExternDisabledCxxQtSignalHandlersignal_disabled2<'a> = cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, super::QObjectExternDisabledCxxQtSignalClosuresignal_disabled2, >; #[doc(hidden)] @@ -488,8 +495,9 @@ mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "rust::cxxqtgen1"] - type QObjectExternDisabledCxxQtSignalHandlersignal_enabled2 = + type QObjectExternDisabledCxxQtSignalHandlersignal_enabled2<'a> = cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, super::QObjectExternDisabledCxxQtSignalClosuresignal_enabled2, >; #[doc(hidden)] @@ -526,13 +534,14 @@ impl ffi::QObjectEnabled { #[doc = "signal_disabled"] #[doc = ", so that when the signal is emitted the function pointer is executed."] pub fn connect_signal_disabled< - F: FnMut(core::pin::Pin<&mut ffi::QObjectEnabled>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::QObjectEnabled>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::QObjectEnabled>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::QObjectEnabled_connect_signal_disabled( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::QObjectEnabled_connect_signal_disabled( self, cxx_qt::signalhandler::CxxQtSignalHandler::< QObjectEnabledCxxQtSignalClosuresignal_disabled, @@ -549,12 +558,13 @@ impl ffi::QObjectEnabled { #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] pub fn on_signal_disabled< - F: FnMut(core::pin::Pin<&mut ffi::QObjectEnabled>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::QObjectEnabled>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::QObjectEnabled>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::QObjectEnabled_connect_signal_disabled( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::QObjectEnabled_connect_signal_disabled( self, cxx_qt::signalhandler::CxxQtSignalHandler::< QObjectEnabledCxxQtSignalClosuresignal_disabled, @@ -571,7 +581,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for QObjectEnabledCxxQtSignalClosuresignal_disabled { type Id = cxx::type_id!("::rust::cxxqtgen1::QObjectEnabledCxxQtSignalHandlersignal_disabled"); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::QObjectEnabled>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::QObjectEnabled>) + 'a + Send; } #[cfg(not(enabled))] use core::mem::drop as drop_QObjectEnabled_signal_handler_signal_disabled; @@ -600,13 +610,14 @@ impl ffi::QObjectEnabled { #[doc = "signal_enabled"] #[doc = ", so that when the signal is emitted the function pointer is executed."] pub fn connect_signal_enabled< - F: FnMut(core::pin::Pin<&mut ffi::QObjectEnabled>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::QObjectEnabled>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::QObjectEnabled>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::QObjectEnabled_connect_signal_enabled( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::QObjectEnabled_connect_signal_enabled( self, cxx_qt::signalhandler::CxxQtSignalHandler::< QObjectEnabledCxxQtSignalClosuresignal_enabled, @@ -622,13 +633,11 @@ impl ffi::QObjectEnabled { #[doc = ", so that when the signal is emitted the function pointer is executed."] #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] - pub fn on_signal_enabled< - F: FnMut(core::pin::Pin<&mut ffi::QObjectEnabled>) + 'static + Send, - >( + pub fn on_signal_enabled<'a, F: FnMut(core::pin::Pin<&mut ffi::QObjectEnabled>) + 'a + Send>( self: core::pin::Pin<&mut ffi::QObjectEnabled>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::QObjectEnabled_connect_signal_enabled( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::QObjectEnabled_connect_signal_enabled( self, cxx_qt::signalhandler::CxxQtSignalHandler::< QObjectEnabledCxxQtSignalClosuresignal_enabled, @@ -645,7 +654,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for QObjectEnabledCxxQtSignalClosuresignal_enabled { type Id = cxx::type_id!("::rust::cxxqtgen1::QObjectEnabledCxxQtSignalHandlersignal_enabled"); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::QObjectEnabled>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::QObjectEnabled>) + 'a + Send; } #[cfg(enabled)] use core::mem::drop as drop_QObjectEnabled_signal_handler_signal_enabled; @@ -705,19 +714,22 @@ impl ffi::QObjectDisabled { #[doc = "signal_disabled"] #[doc = ", so that when the signal is emitted the function pointer is executed."] pub fn connect_signal_disabled< - F: FnMut(core::pin::Pin<&mut ffi::QObjectDisabled>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::QObjectDisabled>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::QObjectDisabled>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::QObjectDisabled_connect_signal_disabled( - self, - cxx_qt::signalhandler::CxxQtSignalHandler::< - QObjectDisabledCxxQtSignalClosuresignal_disabled, - >::new(Box::new(closure)), - conn_type, - )) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( + ffi::QObjectDisabled_connect_signal_disabled( + self, + cxx_qt::signalhandler::CxxQtSignalHandler::< + QObjectDisabledCxxQtSignalClosuresignal_disabled, + >::new(Box::new(closure)), + conn_type, + ), + ) } } #[cfg(not(enabled))] @@ -728,18 +740,21 @@ impl ffi::QObjectDisabled { #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] pub fn on_signal_disabled< - F: FnMut(core::pin::Pin<&mut ffi::QObjectDisabled>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::QObjectDisabled>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::QObjectDisabled>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::QObjectDisabled_connect_signal_disabled( - self, - cxx_qt::signalhandler::CxxQtSignalHandler::< - QObjectDisabledCxxQtSignalClosuresignal_disabled, - >::new(Box::new(closure)), - cxx_qt::ConnectionType::AutoConnection, - )) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( + ffi::QObjectDisabled_connect_signal_disabled( + self, + cxx_qt::signalhandler::CxxQtSignalHandler::< + QObjectDisabledCxxQtSignalClosuresignal_disabled, + >::new(Box::new(closure)), + cxx_qt::ConnectionType::AutoConnection, + ), + ) } } #[cfg(not(enabled))] @@ -750,7 +765,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for QObjectDisabledCxxQtSignalClosuresignal_disabled { type Id = cxx::type_id!("::rust::cxxqtgen1::QObjectDisabledCxxQtSignalHandlersignal_disabled"); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::QObjectDisabled>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::QObjectDisabled>) + 'a + Send; } #[cfg(not(enabled))] use core::mem::drop as drop_QObjectDisabled_signal_handler_signal_disabled; @@ -779,13 +794,14 @@ impl ffi::QObjectDisabled { #[doc = "signal_enabled"] #[doc = ", so that when the signal is emitted the function pointer is executed."] pub fn connect_signal_enabled< - F: FnMut(core::pin::Pin<&mut ffi::QObjectDisabled>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::QObjectDisabled>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::QObjectDisabled>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::QObjectDisabled_connect_signal_enabled( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::QObjectDisabled_connect_signal_enabled( self, cxx_qt::signalhandler::CxxQtSignalHandler::< QObjectDisabledCxxQtSignalClosuresignal_enabled, @@ -802,12 +818,13 @@ impl ffi::QObjectDisabled { #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] pub fn on_signal_enabled< - F: FnMut(core::pin::Pin<&mut ffi::QObjectDisabled>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::QObjectDisabled>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::QObjectDisabled>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::QObjectDisabled_connect_signal_enabled( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::QObjectDisabled_connect_signal_enabled( self, cxx_qt::signalhandler::CxxQtSignalHandler::< QObjectDisabledCxxQtSignalClosuresignal_enabled, @@ -824,7 +841,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for QObjectDisabledCxxQtSignalClosuresignal_enabled { type Id = cxx::type_id!("::rust::cxxqtgen1::QObjectDisabledCxxQtSignalHandlersignal_enabled"); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::QObjectDisabled>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::QObjectDisabled>) + 'a + Send; } #[cfg(enabled)] use core::mem::drop as drop_QObjectDisabled_signal_handler_signal_enabled; @@ -892,13 +909,14 @@ impl ffi::QObjectExternEnabled { #[doc = "signal_disabled1"] #[doc = ", so that when the signal is emitted the function pointer is executed."] pub fn connect_signal_disabled1< - F: FnMut(core::pin::Pin<&mut ffi::QObjectExternEnabled>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::QObjectExternEnabled>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::QObjectExternEnabled>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( ffi::QObjectExternEnabled_connect_signal_disabled1( self, cxx_qt::signalhandler::CxxQtSignalHandler::< @@ -917,12 +935,13 @@ impl ffi::QObjectExternEnabled { #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] pub fn on_signal_disabled1< - F: FnMut(core::pin::Pin<&mut ffi::QObjectExternEnabled>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::QObjectExternEnabled>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::QObjectExternEnabled>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( ffi::QObjectExternEnabled_connect_signal_disabled1( self, cxx_qt::signalhandler::CxxQtSignalHandler::< @@ -942,7 +961,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure { type Id = cxx::type_id!("::rust::cxxqtgen1::QObjectExternEnabledCxxQtSignalHandlersignal_disabled1"); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::QObjectExternEnabled>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::QObjectExternEnabled>) + 'a + Send; } #[cfg(not(enabled))] use core::mem::drop as drop_QObjectExternEnabled_signal_handler_signal_disabled1; @@ -975,19 +994,22 @@ impl ffi::QObjectExternEnabled { #[doc = "signal_enabled1"] #[doc = ", so that when the signal is emitted the function pointer is executed."] pub fn connect_signal_enabled1< - F: FnMut(core::pin::Pin<&mut ffi::QObjectExternEnabled>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::QObjectExternEnabled>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::QObjectExternEnabled>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::QObjectExternEnabled_connect_signal_enabled1( - self, - cxx_qt::signalhandler::CxxQtSignalHandler::< - QObjectExternEnabledCxxQtSignalClosuresignal_enabled1, - >::new(Box::new(closure)), - conn_type, - )) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( + ffi::QObjectExternEnabled_connect_signal_enabled1( + self, + cxx_qt::signalhandler::CxxQtSignalHandler::< + QObjectExternEnabledCxxQtSignalClosuresignal_enabled1, + >::new(Box::new(closure)), + conn_type, + ), + ) } } #[cfg(enabled)] @@ -998,18 +1020,21 @@ impl ffi::QObjectExternEnabled { #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] pub fn on_signal_enabled1< - F: FnMut(core::pin::Pin<&mut ffi::QObjectExternEnabled>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::QObjectExternEnabled>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::QObjectExternEnabled>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::QObjectExternEnabled_connect_signal_enabled1( - self, - cxx_qt::signalhandler::CxxQtSignalHandler::< - QObjectExternEnabledCxxQtSignalClosuresignal_enabled1, - >::new(Box::new(closure)), - cxx_qt::ConnectionType::AutoConnection, - )) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( + ffi::QObjectExternEnabled_connect_signal_enabled1( + self, + cxx_qt::signalhandler::CxxQtSignalHandler::< + QObjectExternEnabledCxxQtSignalClosuresignal_enabled1, + >::new(Box::new(closure)), + cxx_qt::ConnectionType::AutoConnection, + ), + ) } } #[cfg(enabled)] @@ -1021,7 +1046,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure { type Id = cxx::type_id!("::rust::cxxqtgen1::QObjectExternEnabledCxxQtSignalHandlersignal_enabled1"); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::QObjectExternEnabled>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::QObjectExternEnabled>) + 'a + Send; } #[cfg(enabled)] use core::mem::drop as drop_QObjectExternEnabled_signal_handler_signal_enabled1; @@ -1062,13 +1087,14 @@ impl ffi::QObjectExternDisabled { #[doc = "signal_disabled2"] #[doc = ", so that when the signal is emitted the function pointer is executed."] pub fn connect_signal_disabled2< - F: FnMut(core::pin::Pin<&mut ffi::QObjectExternDisabled>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::QObjectExternDisabled>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::QObjectExternDisabled>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( ffi::QObjectExternDisabled_connect_signal_disabled2( self, cxx_qt::signalhandler::CxxQtSignalHandler::< @@ -1087,12 +1113,13 @@ impl ffi::QObjectExternDisabled { #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] pub fn on_signal_disabled2< - F: FnMut(core::pin::Pin<&mut ffi::QObjectExternDisabled>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::QObjectExternDisabled>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::QObjectExternDisabled>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( ffi::QObjectExternDisabled_connect_signal_disabled2( self, cxx_qt::signalhandler::CxxQtSignalHandler::< @@ -1112,7 +1139,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure { type Id = cxx::type_id!("::rust::cxxqtgen1::QObjectExternDisabledCxxQtSignalHandlersignal_disabled2"); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::QObjectExternDisabled>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::QObjectExternDisabled>) + 'a + Send; } #[cfg(not(enabled))] use core::mem::drop as drop_QObjectExternDisabled_signal_handler_signal_disabled2; @@ -1145,13 +1172,14 @@ impl ffi::QObjectExternDisabled { #[doc = "signal_enabled2"] #[doc = ", so that when the signal is emitted the function pointer is executed."] pub fn connect_signal_enabled2< - F: FnMut(core::pin::Pin<&mut ffi::QObjectExternDisabled>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::QObjectExternDisabled>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::QObjectExternDisabled>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( ffi::QObjectExternDisabled_connect_signal_enabled2( self, cxx_qt::signalhandler::CxxQtSignalHandler::< @@ -1170,12 +1198,13 @@ impl ffi::QObjectExternDisabled { #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] pub fn on_signal_enabled2< - F: FnMut(core::pin::Pin<&mut ffi::QObjectExternDisabled>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::QObjectExternDisabled>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::QObjectExternDisabled>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( ffi::QObjectExternDisabled_connect_signal_enabled2( self, cxx_qt::signalhandler::CxxQtSignalHandler::< @@ -1195,7 +1224,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure { type Id = cxx::type_id!("::rust::cxxqtgen1::QObjectExternDisabledCxxQtSignalHandlersignal_enabled2"); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::QObjectExternDisabled>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::QObjectExternDisabled>) + 'a + Send; } #[cfg(enabled)] use core::mem::drop as drop_QObjectExternDisabled_signal_handler_signal_enabled2; diff --git a/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs b/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs index 40fe6462d..460f69fed 100644 --- a/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs +++ b/crates/cxx-qt-gen/test_outputs/passthrough_and_naming.rs @@ -105,8 +105,9 @@ pub mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "cxx_qt::multi_object::rust::cxxqtgen1"] - type MyObjectCxxQtSignalHandlerpropertyNameChanged = + type MyObjectCxxQtSignalHandlerpropertyNameChanged<'a> = cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, super::MyObjectCxxQtSignalClosurepropertyNameChanged, >; #[doc(hidden)] @@ -144,8 +145,8 @@ pub mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "cxx_qt::multi_object::rust::cxxqtgen1"] - type MyObjectCxxQtSignalHandlerready = - cxx_qt::signalhandler::CxxQtSignalHandler; + type MyObjectCxxQtSignalHandlerready<'a> = + cxx_qt::signalhandler::CxxQtSignalHandler<'a, super::MyObjectCxxQtSignalClosureready>; #[doc(hidden)] #[namespace = "cxx_qt::multi_object::rust::cxxqtgen1"] #[cxx_name = "MyObject_readyConnect"] @@ -226,8 +227,9 @@ pub mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "second_object::rust::cxxqtgen1"] - type SecondObjectCxxQtSignalHandlerpropertyNameChanged = + type SecondObjectCxxQtSignalHandlerpropertyNameChanged<'a> = cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, super::SecondObjectCxxQtSignalClosurepropertyNameChanged, >; #[doc(hidden)] @@ -271,8 +273,10 @@ pub mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "second_object::rust::cxxqtgen1"] - type SecondObjectCxxQtSignalHandlerready = - cxx_qt::signalhandler::CxxQtSignalHandler; + type SecondObjectCxxQtSignalHandlerready<'a> = cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, + super::SecondObjectCxxQtSignalClosureready, + >; #[doc(hidden)] #[namespace = "second_object::rust::cxxqtgen1"] #[cxx_name = "SecondObject_readyConnect"] @@ -409,8 +413,10 @@ pub mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "cxx_qt::multi_object::rust::cxxqtgen1"] - type QPushButtonCxxQtSignalHandlerclicked = - cxx_qt::signalhandler::CxxQtSignalHandler; + type QPushButtonCxxQtSignalHandlerclicked<'a> = cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, + super::QPushButtonCxxQtSignalClosureclicked, + >; #[doc(hidden)] #[namespace = "cxx_qt::multi_object::rust::cxxqtgen1"] #[cxx_name = "QPushButton_clickedConnect"] @@ -439,9 +445,11 @@ pub mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "mynamespace::rust::cxxqtgen1"] - type ExternObjectCxxQtSignalHandlerdataReady = cxx_qt::signalhandler::CxxQtSignalHandler< - super::ExternObjectCxxQtSignalClosuredataReady, - >; + type ExternObjectCxxQtSignalHandlerdataReady<'a> = + cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, + super::ExternObjectCxxQtSignalClosuredataReady, + >; #[doc(hidden)] #[namespace = "mynamespace::rust::cxxqtgen1"] #[cxx_name = "ExternObjectCpp_dataReadyConnect"] @@ -471,8 +479,9 @@ pub mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "mynamespace::rust::cxxqtgen1"] - type ExternObjectCxxQtSignalHandlererrorOccurred = + type ExternObjectCxxQtSignalHandlererrorOccurred<'a> = cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, super::ExternObjectCxxQtSignalClosureerrorOccurred, >; #[doc(hidden)] @@ -526,13 +535,14 @@ impl ffi::MyObject { #[doc = "propertyNameChanged"] #[doc = ", so that when the signal is emitted the function pointer is executed."] pub fn connect_property_name_changed< - F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::MyObject_connect_property_name_changed( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::MyObject_connect_property_name_changed( self, cxx_qt::signalhandler::CxxQtSignalHandler::< MyObjectCxxQtSignalClosurepropertyNameChanged, @@ -548,12 +558,13 @@ impl ffi::MyObject { #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] pub fn on_property_name_changed< - F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::MyObject_connect_property_name_changed( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::MyObject_connect_property_name_changed( self, cxx_qt::signalhandler::CxxQtSignalHandler::< MyObjectCxxQtSignalClosurepropertyNameChanged, @@ -570,7 +581,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure type Id = cxx::type_id!( "::cxx_qt::multi_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerpropertyNameChanged" ); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send; } use core::mem::drop as drop_MyObject_signal_handler_propertyNameChanged; fn call_MyObject_signal_handler_propertyNameChanged( @@ -593,12 +604,12 @@ impl ffi::MyObject { #[doc = "Connect the given function pointer to the signal "] #[doc = "ready"] #[doc = ", so that when the signal is emitted the function pointer is executed."] - pub fn connect_ready) + 'static + Send>( + pub fn connect_ready<'a, F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send>( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::MyObject_connect_ready( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::MyObject_connect_ready( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new( Box::new(closure), @@ -613,11 +624,11 @@ impl ffi::MyObject { #[doc = ", so that when the signal is emitted the function pointer is executed."] #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] - pub fn on_ready) + 'static + Send>( + pub fn on_ready<'a, F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send>( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::MyObject_connect_ready( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::MyObject_connect_ready( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new( Box::new(closure), @@ -631,7 +642,7 @@ pub struct MyObjectCxxQtSignalClosureready {} impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClosureready { type Id = cxx::type_id!("::cxx_qt::multi_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerready"); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send; } use core::mem::drop as drop_MyObject_signal_handler_ready; fn call_MyObject_signal_handler_ready( @@ -700,19 +711,22 @@ impl ffi::SecondObject { #[doc = "propertyNameChanged"] #[doc = ", so that when the signal is emitted the function pointer is executed."] pub fn connect_property_name_changed< - F: FnMut(core::pin::Pin<&mut ffi::SecondObject>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::SecondObject>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::SecondObject>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::SecondObject_connect_property_name_changed( - self, - cxx_qt::signalhandler::CxxQtSignalHandler::< - SecondObjectCxxQtSignalClosurepropertyNameChanged, - >::new(Box::new(closure)), - conn_type, - )) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( + ffi::SecondObject_connect_property_name_changed( + self, + cxx_qt::signalhandler::CxxQtSignalHandler::< + SecondObjectCxxQtSignalClosurepropertyNameChanged, + >::new(Box::new(closure)), + conn_type, + ), + ) } } impl ffi::SecondObject { @@ -722,18 +736,21 @@ impl ffi::SecondObject { #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] pub fn on_property_name_changed< - F: FnMut(core::pin::Pin<&mut ffi::SecondObject>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::SecondObject>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::SecondObject>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::SecondObject_connect_property_name_changed( - self, - cxx_qt::signalhandler::CxxQtSignalHandler::< - SecondObjectCxxQtSignalClosurepropertyNameChanged, - >::new(Box::new(closure)), - cxx_qt::ConnectionType::AutoConnection, - )) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( + ffi::SecondObject_connect_property_name_changed( + self, + cxx_qt::signalhandler::CxxQtSignalHandler::< + SecondObjectCxxQtSignalClosurepropertyNameChanged, + >::new(Box::new(closure)), + cxx_qt::ConnectionType::AutoConnection, + ), + ) } } #[doc(hidden)] @@ -744,7 +761,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure type Id = cxx::type_id!( "::second_object::rust::cxxqtgen1::SecondObjectCxxQtSignalHandlerpropertyNameChanged" ); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::SecondObject>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::SecondObject>) + 'a + Send; } use core::mem::drop as drop_SecondObject_signal_handler_propertyNameChanged; fn call_SecondObject_signal_handler_propertyNameChanged( @@ -767,12 +784,12 @@ impl ffi::SecondObject { #[doc = "Connect the given function pointer to the signal "] #[doc = "ready"] #[doc = ", so that when the signal is emitted the function pointer is executed."] - pub fn connect_ready) + 'static + Send>( + pub fn connect_ready<'a, F: FnMut(core::pin::Pin<&mut ffi::SecondObject>) + 'a + Send>( self: core::pin::Pin<&mut ffi::SecondObject>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::SecondObject_connect_ready( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::SecondObject_connect_ready( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new( Box::new(closure), @@ -787,11 +804,11 @@ impl ffi::SecondObject { #[doc = ", so that when the signal is emitted the function pointer is executed."] #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] - pub fn on_ready) + 'static + Send>( + pub fn on_ready<'a, F: FnMut(core::pin::Pin<&mut ffi::SecondObject>) + 'a + Send>( self: core::pin::Pin<&mut ffi::SecondObject>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::SecondObject_connect_ready( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::SecondObject_connect_ready( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new( Box::new(closure), @@ -805,7 +822,7 @@ pub struct SecondObjectCxxQtSignalClosureready {} impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for SecondObjectCxxQtSignalClosureready { type Id = cxx::type_id!("::second_object::rust::cxxqtgen1::SecondObjectCxxQtSignalHandlerready"); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::SecondObject>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::SecondObject>) + 'a + Send; } use core::mem::drop as drop_SecondObject_signal_handler_ready; fn call_SecondObject_signal_handler_ready( @@ -899,13 +916,14 @@ impl ffi::QPushButton { #[doc = "clicked"] #[doc = ", so that when the signal is emitted the function pointer is executed."] pub fn connect_clicked< - F: FnMut(core::pin::Pin<&mut ffi::QPushButton>, bool) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::QPushButton>, bool) + 'a + Send, >( self: core::pin::Pin<&mut ffi::QPushButton>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::QPushButton_connect_clicked( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::QPushButton_connect_clicked( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new( Box::new(closure), @@ -920,11 +938,11 @@ impl ffi::QPushButton { #[doc = ", so that when the signal is emitted the function pointer is executed."] #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] - pub fn on_clicked, bool) + 'static + Send>( + pub fn on_clicked<'a, F: FnMut(core::pin::Pin<&mut ffi::QPushButton>, bool) + 'a + Send>( self: core::pin::Pin<&mut ffi::QPushButton>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::QPushButton_connect_clicked( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::QPushButton_connect_clicked( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new( Box::new(closure), @@ -939,7 +957,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for QPushButtonCxxQtSignal type Id = cxx::type_id!( "::cxx_qt::multi_object::rust::cxxqtgen1::QPushButtonCxxQtSignalHandlerclicked" ); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::QPushButton>, bool) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::QPushButton>, bool) + 'a + Send; } use core::mem::drop as drop_QPushButton_signal_handler_clicked; fn call_QPushButton_signal_handler_clicked( @@ -961,12 +979,12 @@ impl ffi::ExternObject { #[doc = "Connect the given function pointer to the signal "] #[doc = "dataReady"] #[doc = ", so that when the signal is emitted the function pointer is executed."] - pub fn connect_data_ready) + 'static + Send>( + pub fn connect_data_ready<'a, F: FnMut(core::pin::Pin<&mut ffi::ExternObject>) + 'a + Send>( self: core::pin::Pin<&mut ffi::ExternObject>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt :: QMetaObjectConnectionGuard :: from (ffi :: ExternObject_connect_data_ready (self , cxx_qt :: signalhandler :: CxxQtSignalHandler :: < ExternObjectCxxQtSignalClosuredataReady > :: new (Box :: new (closure)) , conn_type ,)) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt :: QScopedMetaObjectConnectionGuard :: from (ffi :: ExternObject_connect_data_ready (self , cxx_qt :: signalhandler :: CxxQtSignalHandler :: < ExternObjectCxxQtSignalClosuredataReady > :: new (Box :: new (closure)) , conn_type ,)) } } impl ffi::ExternObject { @@ -975,11 +993,11 @@ impl ffi::ExternObject { #[doc = ", so that when the signal is emitted the function pointer is executed."] #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] - pub fn on_data_ready) + 'static + Send>( + pub fn on_data_ready<'a, F: FnMut(core::pin::Pin<&mut ffi::ExternObject>) + 'a + Send>( self: core::pin::Pin<&mut ffi::ExternObject>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt :: QMetaObjectConnectionGuard :: from (ffi :: ExternObject_connect_data_ready (self , cxx_qt :: signalhandler :: CxxQtSignalHandler :: < ExternObjectCxxQtSignalClosuredataReady > :: new (Box :: new (closure)) , cxx_qt :: ConnectionType :: AutoConnection ,)) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt :: QScopedMetaObjectConnectionGuard :: from (ffi :: ExternObject_connect_data_ready (self , cxx_qt :: signalhandler :: CxxQtSignalHandler :: < ExternObjectCxxQtSignalClosuredataReady > :: new (Box :: new (closure)) , cxx_qt :: ConnectionType :: AutoConnection ,)) } } #[doc(hidden)] @@ -987,7 +1005,7 @@ pub struct ExternObjectCxxQtSignalClosuredataReady {} impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for ExternObjectCxxQtSignalClosuredataReady { type Id = cxx::type_id!("::mynamespace::rust::cxxqtgen1::ExternObjectCxxQtSignalHandlerdataReady"); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::ExternObject>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::ExternObject>) + 'a + Send; } use core::mem::drop as drop_ExternObject_signal_handler_dataReady; fn call_ExternObject_signal_handler_dataReady( @@ -1011,13 +1029,14 @@ impl ffi::ExternObject { #[doc = "errorOccurred"] #[doc = ", so that when the signal is emitted the function pointer is executed."] pub fn connect_error_occurred< - F: FnMut(core::pin::Pin<&mut ffi::ExternObject>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::ExternObject>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::ExternObject>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( ffi::ExternObject_connect_error_occurred( self, cxx_qt::signalhandler::CxxQtSignalHandler::< @@ -1034,11 +1053,11 @@ impl ffi::ExternObject { #[doc = ", so that when the signal is emitted the function pointer is executed."] #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] - pub fn on_error_occurred) + 'static + Send>( + pub fn on_error_occurred<'a, F: FnMut(core::pin::Pin<&mut ffi::ExternObject>) + 'a + Send>( self: core::pin::Pin<&mut ffi::ExternObject>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( ffi::ExternObject_connect_error_occurred( self, cxx_qt::signalhandler::CxxQtSignalHandler::< @@ -1057,7 +1076,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure type Id = cxx::type_id!( "::mynamespace::rust::cxxqtgen1::ExternObjectCxxQtSignalHandlererrorOccurred" ); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::ExternObject>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::ExternObject>) + 'a + Send; } use core::mem::drop as drop_ExternObject_signal_handler_errorOccurred; fn call_ExternObject_signal_handler_errorOccurred( diff --git a/crates/cxx-qt-gen/test_outputs/properties.rs b/crates/cxx-qt-gen/test_outputs/properties.rs index 8a56cbae1..c84cc8b53 100644 --- a/crates/cxx-qt-gen/test_outputs/properties.rs +++ b/crates/cxx-qt-gen/test_outputs/properties.rs @@ -156,9 +156,11 @@ mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] - type MyObjectCxxQtSignalHandlerprimitiveChanged = cxx_qt::signalhandler::CxxQtSignalHandler< - super::MyObjectCxxQtSignalClosureprimitiveChanged, - >; + type MyObjectCxxQtSignalHandlerprimitiveChanged<'a> = + cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, + super::MyObjectCxxQtSignalClosureprimitiveChanged, + >; #[doc(hidden)] #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] #[cxx_name = "MyObject_primitiveChangedConnect"] @@ -189,9 +191,11 @@ mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] - type MyObjectCxxQtSignalHandlertrivialChanged = cxx_qt::signalhandler::CxxQtSignalHandler< - super::MyObjectCxxQtSignalClosuretrivialChanged, - >; + type MyObjectCxxQtSignalHandlertrivialChanged<'a> = + cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, + super::MyObjectCxxQtSignalClosuretrivialChanged, + >; #[doc(hidden)] #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] #[cxx_name = "MyObject_trivialChangedConnect"] @@ -222,8 +226,9 @@ mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] - type MyObjectCxxQtSignalHandlerpropAutoCxxNameChanged = + type MyObjectCxxQtSignalHandlerpropAutoCxxNameChanged<'a> = cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, super::MyObjectCxxQtSignalClosurepropAutoCxxNameChanged, >; #[doc(hidden)] @@ -256,8 +261,9 @@ mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] - type MyObjectCxxQtSignalHandlercustomFunctionPropChanged = + type MyObjectCxxQtSignalHandlercustomFunctionPropChanged<'a> = cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, super::MyObjectCxxQtSignalClosurecustomFunctionPropChanged, >; #[doc(hidden)] @@ -290,8 +296,9 @@ mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] - type MyObjectCxxQtSignalHandlerrenamedPropertyChanged = + type MyObjectCxxQtSignalHandlerrenamedPropertyChanged<'a> = cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, super::MyObjectCxxQtSignalClosurerenamedPropertyChanged, >; #[doc(hidden)] @@ -324,8 +331,9 @@ mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] - type MyObjectCxxQtSignalHandlernamed_prop_2Changed = + type MyObjectCxxQtSignalHandlernamed_prop_2Changed<'a> = cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, super::MyObjectCxxQtSignalClosurenamed_prop_2Changed, >; #[doc(hidden)] @@ -375,9 +383,11 @@ mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] - type MyObjectCxxQtSignalHandlermy_on_changed = cxx_qt::signalhandler::CxxQtSignalHandler< - super::MyObjectCxxQtSignalClosuremy_on_changed, - >; + type MyObjectCxxQtSignalHandlermy_on_changed<'a> = + cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, + super::MyObjectCxxQtSignalClosuremy_on_changed, + >; #[doc(hidden)] #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] #[cxx_name = "MyObject_my_on_changedConnect"] @@ -638,13 +648,14 @@ impl ffi::MyObject { #[doc = "primitiveChanged"] #[doc = ", so that when the signal is emitted the function pointer is executed."] pub fn connect_primitive_changed< - F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( ffi::MyObject_connect_primitive_changed( self, cxx_qt::signalhandler::CxxQtSignalHandler::< @@ -661,11 +672,11 @@ impl ffi::MyObject { #[doc = ", so that when the signal is emitted the function pointer is executed."] #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] - pub fn on_primitive_changed) + 'static + Send>( + pub fn on_primitive_changed<'a, F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send>( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( ffi::MyObject_connect_primitive_changed( self, cxx_qt::signalhandler::CxxQtSignalHandler::< @@ -684,7 +695,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure type Id = cxx::type_id!( "::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerprimitiveChanged" ); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send; } use core::mem::drop as drop_MyObject_signal_handler_primitiveChanged; fn call_MyObject_signal_handler_primitiveChanged( @@ -707,14 +718,12 @@ impl ffi::MyObject { #[doc = "Connect the given function pointer to the signal "] #[doc = "trivialChanged"] #[doc = ", so that when the signal is emitted the function pointer is executed."] - pub fn connect_trivial_changed< - F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'static + Send, - >( + pub fn connect_trivial_changed<'a, F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send>( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt :: QMetaObjectConnectionGuard :: from (ffi :: MyObject_connect_trivial_changed (self , cxx_qt :: signalhandler :: CxxQtSignalHandler :: < MyObjectCxxQtSignalClosuretrivialChanged > :: new (Box :: new (closure)) , conn_type ,)) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt :: QScopedMetaObjectConnectionGuard :: from (ffi :: MyObject_connect_trivial_changed (self , cxx_qt :: signalhandler :: CxxQtSignalHandler :: < MyObjectCxxQtSignalClosuretrivialChanged > :: new (Box :: new (closure)) , conn_type ,)) } } impl ffi::MyObject { @@ -723,11 +732,11 @@ impl ffi::MyObject { #[doc = ", so that when the signal is emitted the function pointer is executed."] #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] - pub fn on_trivial_changed) + 'static + Send>( + pub fn on_trivial_changed<'a, F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send>( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt :: QMetaObjectConnectionGuard :: from (ffi :: MyObject_connect_trivial_changed (self , cxx_qt :: signalhandler :: CxxQtSignalHandler :: < MyObjectCxxQtSignalClosuretrivialChanged > :: new (Box :: new (closure)) , cxx_qt :: ConnectionType :: AutoConnection ,)) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt :: QScopedMetaObjectConnectionGuard :: from (ffi :: MyObject_connect_trivial_changed (self , cxx_qt :: signalhandler :: CxxQtSignalHandler :: < MyObjectCxxQtSignalClosuretrivialChanged > :: new (Box :: new (closure)) , cxx_qt :: ConnectionType :: AutoConnection ,)) } } #[doc(hidden)] @@ -736,7 +745,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClo type Id = cxx::type_id!( "::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlertrivialChanged" ); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send; } use core::mem::drop as drop_MyObject_signal_handler_trivialChanged; fn call_MyObject_signal_handler_trivialChanged( @@ -760,19 +769,22 @@ impl ffi::MyObject { #[doc = "propAutoCxxNameChanged"] #[doc = ", so that when the signal is emitted the function pointer is executed."] pub fn connect_prop_auto_cxx_name_changed< - F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::MyObject_connect_prop_auto_cxx_name_changed( - self, - cxx_qt::signalhandler::CxxQtSignalHandler::< - MyObjectCxxQtSignalClosurepropAutoCxxNameChanged, - >::new(Box::new(closure)), - conn_type, - )) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( + ffi::MyObject_connect_prop_auto_cxx_name_changed( + self, + cxx_qt::signalhandler::CxxQtSignalHandler::< + MyObjectCxxQtSignalClosurepropAutoCxxNameChanged, + >::new(Box::new(closure)), + conn_type, + ), + ) } } impl ffi::MyObject { @@ -782,18 +794,21 @@ impl ffi::MyObject { #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] pub fn on_prop_auto_cxx_name_changed< - F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::MyObject_connect_prop_auto_cxx_name_changed( - self, - cxx_qt::signalhandler::CxxQtSignalHandler::< - MyObjectCxxQtSignalClosurepropAutoCxxNameChanged, - >::new(Box::new(closure)), - cxx_qt::ConnectionType::AutoConnection, - )) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( + ffi::MyObject_connect_prop_auto_cxx_name_changed( + self, + cxx_qt::signalhandler::CxxQtSignalHandler::< + MyObjectCxxQtSignalClosurepropAutoCxxNameChanged, + >::new(Box::new(closure)), + cxx_qt::ConnectionType::AutoConnection, + ), + ) } } #[doc(hidden)] @@ -804,7 +819,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure type Id = cxx::type_id!( "::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerpropAutoCxxNameChanged" ); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send; } use core::mem::drop as drop_MyObject_signal_handler_propAutoCxxNameChanged; fn call_MyObject_signal_handler_propAutoCxxNameChanged( @@ -828,13 +843,14 @@ impl ffi::MyObject { #[doc = "customFunctionPropChanged"] #[doc = ", so that when the signal is emitted the function pointer is executed."] pub fn connect_custom_function_prop_changed< - F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( ffi::MyObject_connect_custom_function_prop_changed( self, cxx_qt::signalhandler::CxxQtSignalHandler::< @@ -852,12 +868,13 @@ impl ffi::MyObject { #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] pub fn on_custom_function_prop_changed< - F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( ffi::MyObject_connect_custom_function_prop_changed( self, cxx_qt::signalhandler::CxxQtSignalHandler::< @@ -876,7 +893,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure type Id = cxx::type_id!( "::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlercustomFunctionPropChanged" ); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send; } use core::mem::drop as drop_MyObject_signal_handler_customFunctionPropChanged; fn call_MyObject_signal_handler_customFunctionPropChanged( @@ -900,19 +917,22 @@ impl ffi::MyObject { #[doc = "renamedPropertyChanged"] #[doc = ", so that when the signal is emitted the function pointer is executed."] pub fn connect_renamed_property_changed< - F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::MyObject_connect_renamed_property_changed( - self, - cxx_qt::signalhandler::CxxQtSignalHandler::< - MyObjectCxxQtSignalClosurerenamedPropertyChanged, - >::new(Box::new(closure)), - conn_type, - )) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( + ffi::MyObject_connect_renamed_property_changed( + self, + cxx_qt::signalhandler::CxxQtSignalHandler::< + MyObjectCxxQtSignalClosurerenamedPropertyChanged, + >::new(Box::new(closure)), + conn_type, + ), + ) } } impl ffi::MyObject { @@ -922,18 +942,21 @@ impl ffi::MyObject { #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] pub fn on_renamed_property_changed< - F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::MyObject_connect_renamed_property_changed( - self, - cxx_qt::signalhandler::CxxQtSignalHandler::< - MyObjectCxxQtSignalClosurerenamedPropertyChanged, - >::new(Box::new(closure)), - cxx_qt::ConnectionType::AutoConnection, - )) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( + ffi::MyObject_connect_renamed_property_changed( + self, + cxx_qt::signalhandler::CxxQtSignalHandler::< + MyObjectCxxQtSignalClosurerenamedPropertyChanged, + >::new(Box::new(closure)), + cxx_qt::ConnectionType::AutoConnection, + ), + ) } } #[doc(hidden)] @@ -944,7 +967,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure type Id = cxx::type_id!( "::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerrenamedPropertyChanged" ); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send; } use core::mem::drop as drop_MyObject_signal_handler_renamedPropertyChanged; fn call_MyObject_signal_handler_renamedPropertyChanged( @@ -968,19 +991,22 @@ impl ffi::MyObject { #[doc = "named_prop_2Changed"] #[doc = ", so that when the signal is emitted the function pointer is executed."] pub fn connect_renamed_property_2_changed< - F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::MyObject_connect_renamed_property_2_changed( - self, - cxx_qt::signalhandler::CxxQtSignalHandler::< - MyObjectCxxQtSignalClosurenamed_prop_2Changed, - >::new(Box::new(closure)), - conn_type, - )) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( + ffi::MyObject_connect_renamed_property_2_changed( + self, + cxx_qt::signalhandler::CxxQtSignalHandler::< + MyObjectCxxQtSignalClosurenamed_prop_2Changed, + >::new(Box::new(closure)), + conn_type, + ), + ) } } impl ffi::MyObject { @@ -990,18 +1016,21 @@ impl ffi::MyObject { #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] pub fn on_renamed_property_2_changed< - F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'static + Send, + 'a, + F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send, >( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::MyObject_connect_renamed_property_2_changed( - self, - cxx_qt::signalhandler::CxxQtSignalHandler::< - MyObjectCxxQtSignalClosurenamed_prop_2Changed, - >::new(Box::new(closure)), - cxx_qt::ConnectionType::AutoConnection, - )) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from( + ffi::MyObject_connect_renamed_property_2_changed( + self, + cxx_qt::signalhandler::CxxQtSignalHandler::< + MyObjectCxxQtSignalClosurenamed_prop_2Changed, + >::new(Box::new(closure)), + cxx_qt::ConnectionType::AutoConnection, + ), + ) } } #[doc(hidden)] @@ -1012,7 +1041,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure type Id = cxx::type_id!( "::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlernamed_prop_2Changed" ); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send; } use core::mem::drop as drop_MyObject_signal_handler_named_prop_2Changed; fn call_MyObject_signal_handler_named_prop_2Changed( @@ -1035,12 +1064,12 @@ impl ffi::MyObject { #[doc = "Connect the given function pointer to the signal "] #[doc = "my_on_changed"] #[doc = ", so that when the signal is emitted the function pointer is executed."] - pub fn connect_my_on_changed) + 'static + Send>( + pub fn connect_my_on_changed<'a, F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send>( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt :: QMetaObjectConnectionGuard :: from (ffi :: MyObject_connect_my_on_changed (self , cxx_qt :: signalhandler :: CxxQtSignalHandler :: < MyObjectCxxQtSignalClosuremy_on_changed > :: new (Box :: new (closure)) , conn_type ,)) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt :: QScopedMetaObjectConnectionGuard :: from (ffi :: MyObject_connect_my_on_changed (self , cxx_qt :: signalhandler :: CxxQtSignalHandler :: < MyObjectCxxQtSignalClosuremy_on_changed > :: new (Box :: new (closure)) , conn_type ,)) } } impl ffi::MyObject { @@ -1049,11 +1078,11 @@ impl ffi::MyObject { #[doc = ", so that when the signal is emitted the function pointer is executed."] #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] - pub fn on_my_on_changed) + 'static + Send>( + pub fn on_my_on_changed<'a, F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send>( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt :: QMetaObjectConnectionGuard :: from (ffi :: MyObject_connect_my_on_changed (self , cxx_qt :: signalhandler :: CxxQtSignalHandler :: < MyObjectCxxQtSignalClosuremy_on_changed > :: new (Box :: new (closure)) , cxx_qt :: ConnectionType :: AutoConnection ,)) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt :: QScopedMetaObjectConnectionGuard :: from (ffi :: MyObject_connect_my_on_changed (self , cxx_qt :: signalhandler :: CxxQtSignalHandler :: < MyObjectCxxQtSignalClosuremy_on_changed > :: new (Box :: new (closure)) , cxx_qt :: ConnectionType :: AutoConnection ,)) } } #[doc(hidden)] @@ -1062,7 +1091,7 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClo type Id = cxx::type_id!( "::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlermy_on_changed" ); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send; } use core::mem::drop as drop_MyObject_signal_handler_my_on_changed; fn call_MyObject_signal_handler_my_on_changed( diff --git a/crates/cxx-qt-gen/test_outputs/signals.rs b/crates/cxx-qt-gen/test_outputs/signals.rs index ba6f41b6e..12088473f 100644 --- a/crates/cxx-qt-gen/test_outputs/signals.rs +++ b/crates/cxx-qt-gen/test_outputs/signals.rs @@ -52,8 +52,8 @@ mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] - type MyObjectCxxQtSignalHandlerready = - cxx_qt::signalhandler::CxxQtSignalHandler; + type MyObjectCxxQtSignalHandlerready<'a> = + cxx_qt::signalhandler::CxxQtSignalHandler<'a, super::MyObjectCxxQtSignalClosureready>; #[doc(hidden)] #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] #[cxx_name = "MyObject_readyConnect"] @@ -87,7 +87,8 @@ mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] - type MyObjectCxxQtSignalHandlerdata_changed = cxx_qt::signalhandler::CxxQtSignalHandler< + type MyObjectCxxQtSignalHandlerdata_changed<'a> = cxx_qt::signalhandler::CxxQtSignalHandler< + 'a, super::MyObjectCxxQtSignalClosuredata_changed, >; #[doc(hidden)] @@ -129,8 +130,8 @@ mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] - type MyObjectCxxQtSignalHandlernewData = - cxx_qt::signalhandler::CxxQtSignalHandler; + type MyObjectCxxQtSignalHandlernewData<'a> = + cxx_qt::signalhandler::CxxQtSignalHandler<'a, super::MyObjectCxxQtSignalClosurenewData>; #[doc(hidden)] #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] #[cxx_name = "MyObject_newDataConnect"] @@ -202,8 +203,8 @@ mod ffi { unsafe extern "C++" { #[doc(hidden)] #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] - type QTimerCxxQtSignalHandlertimeout = - cxx_qt::signalhandler::CxxQtSignalHandler; + type QTimerCxxQtSignalHandlertimeout<'a> = + cxx_qt::signalhandler::CxxQtSignalHandler<'a, super::QTimerCxxQtSignalClosuretimeout>; #[doc(hidden)] #[namespace = "cxx_qt::my_object::rust::cxxqtgen1"] #[cxx_name = "QTimer_timeoutConnect"] @@ -233,12 +234,12 @@ impl ffi::MyObject { #[doc = "Connect the given function pointer to the signal "] #[doc = "ready"] #[doc = ", so that when the signal is emitted the function pointer is executed."] - pub fn connect_ready) + 'static + Send>( + pub fn connect_ready<'a, F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send>( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::MyObject_connect_ready( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::MyObject_connect_ready( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new( Box::new(closure), @@ -253,11 +254,11 @@ impl ffi::MyObject { #[doc = ", so that when the signal is emitted the function pointer is executed."] #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] - pub fn on_ready) + 'static + Send>( + pub fn on_ready<'a, F: FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send>( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::MyObject_connect_ready( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::MyObject_connect_ready( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new( Box::new(closure), @@ -271,7 +272,7 @@ pub struct MyObjectCxxQtSignalClosureready {} impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClosureready { type Id = cxx::type_id!("::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerready"); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::MyObject>) + 'a + Send; } use core::mem::drop as drop_MyObject_signal_handler_ready; fn call_MyObject_signal_handler_ready( @@ -293,6 +294,7 @@ impl ffi::MyObject { #[doc = "data_changed"] #[doc = ", so that when the signal is emitted the function pointer is executed."] pub fn connect_data_changed< + 'a, F: FnMut( core::pin::Pin<&mut ffi::MyObject>, i32, @@ -300,14 +302,14 @@ impl ffi::MyObject { ffi::QPoint, &ffi::QPoint, ) - + 'static + + 'a + Send, >( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt :: QMetaObjectConnectionGuard :: from (ffi :: MyObject_connect_data_changed (self , cxx_qt :: signalhandler :: CxxQtSignalHandler :: < MyObjectCxxQtSignalClosuredata_changed > :: new (Box :: new (closure)) , conn_type ,)) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt :: QScopedMetaObjectConnectionGuard :: from (ffi :: MyObject_connect_data_changed (self , cxx_qt :: signalhandler :: CxxQtSignalHandler :: < MyObjectCxxQtSignalClosuredata_changed > :: new (Box :: new (closure)) , conn_type ,)) } } impl ffi::MyObject { @@ -317,6 +319,7 @@ impl ffi::MyObject { #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] pub fn on_data_changed< + 'a, F: FnMut( core::pin::Pin<&mut ffi::MyObject>, i32, @@ -324,13 +327,13 @@ impl ffi::MyObject { ffi::QPoint, &ffi::QPoint, ) - + 'static + + 'a + Send, >( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt :: QMetaObjectConnectionGuard :: from (ffi :: MyObject_connect_data_changed (self , cxx_qt :: signalhandler :: CxxQtSignalHandler :: < MyObjectCxxQtSignalClosuredata_changed > :: new (Box :: new (closure)) , cxx_qt :: ConnectionType :: AutoConnection ,)) + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt :: QScopedMetaObjectConnectionGuard :: from (ffi :: MyObject_connect_data_changed (self , cxx_qt :: signalhandler :: CxxQtSignalHandler :: < MyObjectCxxQtSignalClosuredata_changed > :: new (Box :: new (closure)) , cxx_qt :: ConnectionType :: AutoConnection ,)) } } #[doc(hidden)] @@ -339,13 +342,15 @@ impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClo type Id = cxx::type_id!( "::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlerdata_changed" ); - type FnType = dyn FnMut( + type FnType<'a> = dyn FnMut( core::pin::Pin<&mut ffi::MyObject>, i32, cxx::UniquePtr, ffi::QPoint, &ffi::QPoint, - ) + Send; + ) + + 'a + + Send; } use core::mem::drop as drop_MyObject_signal_handler_data_changed; fn call_MyObject_signal_handler_data_changed( @@ -371,6 +376,7 @@ impl ffi::MyObject { #[doc = "newData"] #[doc = ", so that when the signal is emitted the function pointer is executed."] pub fn connect_base_class_new_data< + 'a, F: FnMut( core::pin::Pin<&mut ffi::MyObject>, i32, @@ -378,14 +384,14 @@ impl ffi::MyObject { ffi::QPoint, &'a ffi::QPoint, ) - + 'static + + 'a + Send, >( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::MyObject_connect_base_class_new_data( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::MyObject_connect_base_class_new_data( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new( Box::new(closure), @@ -401,6 +407,7 @@ impl ffi::MyObject { #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] pub fn on_base_class_new_data< + 'a, F: FnMut( core::pin::Pin<&mut ffi::MyObject>, i32, @@ -408,13 +415,13 @@ impl ffi::MyObject { ffi::QPoint, &'a ffi::QPoint, ) - + 'static + + 'a + Send, >( self: core::pin::Pin<&mut ffi::MyObject>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::MyObject_connect_base_class_new_data( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::MyObject_connect_base_class_new_data( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new( Box::new(closure), @@ -428,13 +435,15 @@ pub struct MyObjectCxxQtSignalClosurenewData {} impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for MyObjectCxxQtSignalClosurenewData { type Id = cxx::type_id!("::cxx_qt::my_object::rust::cxxqtgen1::MyObjectCxxQtSignalHandlernewData"); - type FnType = dyn FnMut( + type FnType<'a> = dyn FnMut( core::pin::Pin<&mut ffi::MyObject>, i32, cxx::UniquePtr, ffi::QPoint, &'a ffi::QPoint, - ) + Send; + ) + + 'a + + Send; } use core::mem::drop as drop_MyObject_signal_handler_newData; fn call_MyObject_signal_handler_newData( @@ -495,12 +504,12 @@ impl ffi::QTimer { #[doc = "Connect the given function pointer to the signal "] #[doc = "timeout"] #[doc = ", so that when the signal is emitted the function pointer is executed."] - pub fn connect_timeout) + 'static + Send>( + pub fn connect_timeout<'a, F: FnMut(core::pin::Pin<&mut ffi::QTimer>) + 'a + Send>( self: core::pin::Pin<&mut ffi::QTimer>, closure: F, conn_type: cxx_qt::ConnectionType, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::QTimer_connect_timeout( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::QTimer_connect_timeout( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new( Box::new(closure), @@ -515,11 +524,11 @@ impl ffi::QTimer { #[doc = ", so that when the signal is emitted the function pointer is executed."] #[doc = "\n"] #[doc = "Note that this method uses a AutoConnection connection type."] - pub fn on_timeout) + 'static + Send>( + pub fn on_timeout<'a, F: FnMut(core::pin::Pin<&mut ffi::QTimer>) + 'a + Send>( self: core::pin::Pin<&mut ffi::QTimer>, closure: F, - ) -> cxx_qt::QMetaObjectConnectionGuard { - cxx_qt::QMetaObjectConnectionGuard::from(ffi::QTimer_connect_timeout( + ) -> cxx_qt::QScopedMetaObjectConnectionGuard<'a> { + cxx_qt::QScopedMetaObjectConnectionGuard::from(ffi::QTimer_connect_timeout( self, cxx_qt::signalhandler::CxxQtSignalHandler::::new( Box::new(closure), @@ -533,7 +542,7 @@ pub struct QTimerCxxQtSignalClosuretimeout {} impl cxx_qt::signalhandler::CxxQtSignalHandlerClosure for QTimerCxxQtSignalClosuretimeout { type Id = cxx::type_id!("::cxx_qt::my_object::rust::cxxqtgen1::QTimerCxxQtSignalHandlertimeout"); - type FnType = dyn FnMut(core::pin::Pin<&mut ffi::QTimer>) + Send; + type FnType<'a> = dyn FnMut(core::pin::Pin<&mut ffi::QTimer>) + 'a + Send; } use core::mem::drop as drop_QTimer_signal_handler_timeout; fn call_QTimer_signal_handler_timeout( diff --git a/crates/cxx-qt-lib/src/core/mod.rs b/crates/cxx-qt-lib/src/core/mod.rs index 51e9acb5d..ae2313906 100644 --- a/crates/cxx-qt-lib/src/core/mod.rs +++ b/crates/cxx-qt-lib/src/core/mod.rs @@ -42,7 +42,9 @@ mod qmarginsf; pub use qmarginsf::QMarginsF; // Reexport QMetaObjectConnection and guard from cxx-qt -pub use cxx_qt::{QMetaObjectConnection, QMetaObjectConnectionGuard}; +pub use cxx_qt::{ + QMetaObjectConnection, QMetaObjectConnectionGuard, QScopedMetaObjectConnectionGuard, +}; mod qmodelindex; pub use qmodelindex::QModelIndex; diff --git a/crates/cxx-qt/src/connection.rs b/crates/cxx-qt/src/connection.rs index f4ad9fdc1..cf8be73a6 100644 --- a/crates/cxx-qt/src/connection.rs +++ b/crates/cxx-qt/src/connection.rs @@ -3,6 +3,7 @@ // // SPDX-License-Identifier: MIT OR Apache-2.0 use cxx::{type_id, ExternType}; +use std::ffi::c_void; use std::mem::MaybeUninit; #[cxx::bridge] @@ -64,7 +65,7 @@ mod ffi { /// that the connection should be active or call `release`. #[repr(C)] pub struct QMetaObjectConnection { - _space: MaybeUninit, + _space: MaybeUninit<*const c_void>, } impl Default for QMetaObjectConnection { diff --git a/crates/cxx-qt/src/connectionguard.rs b/crates/cxx-qt/src/connectionguard.rs index 438384a7e..0ba553eee 100644 --- a/crates/cxx-qt/src/connectionguard.rs +++ b/crates/cxx-qt/src/connectionguard.rs @@ -3,34 +3,49 @@ // // SPDX-License-Identifier: MIT OR Apache-2.0 +use std::marker::PhantomData; + use crate::QMetaObjectConnection; -/// Represents a guard to a signal-slot (or signal-functor) connection. +/// Represents a scoped guard to a signal-slot (or signal-functor) connection. /// /// This struct can be created from a [QMetaObjectConnection]. /// /// Note that when this struct is dropped the connection is disconnected. -/// So to keep a connection active either hold onto the struct for the duration -/// that the connection should be active or call `release`, hence the `#[must_use]`. -#[must_use] -pub struct QMetaObjectConnectionGuard { +/// So to keep a connection active hold onto the struct for the duration +/// that the connection should be active, hence the `#[must_use]`. +#[must_use = "If unused the connection will immediately be dropped"] +pub struct QScopedMetaObjectConnectionGuard<'a> { connection: QMetaObjectConnection, + _phantom: PhantomData<&'a ()>, } -impl From for QMetaObjectConnectionGuard { +/// Represents a static guard to a signal-slot (or signal-functor) connection. +/// +/// This struct can be created from a [QMetaObjectConnection]. +/// +/// Note that when this struct is dropped the connection is disconnected. +/// So to keep a connection active either hold onto the struct for the duration +/// that the connection should be active or call `release`, hence the `#[must_use]`. +pub type QMetaObjectConnectionGuard = QScopedMetaObjectConnectionGuard<'static>; + +impl From for QScopedMetaObjectConnectionGuard<'static> { fn from(connection: QMetaObjectConnection) -> Self { - Self { connection } + Self { + connection, + _phantom: PhantomData, + } } } -impl Drop for QMetaObjectConnectionGuard { +impl Drop for QScopedMetaObjectConnectionGuard<'_> { /// Disconnect and deconstruct the connection fn drop(&mut self) { self.connection.disconnect(); } } -impl QMetaObjectConnectionGuard { +impl QScopedMetaObjectConnectionGuard<'static> { /// Release the connection without disconnecting pub fn release(mut self) -> QMetaObjectConnection { // Take the connection as our Drop implementation disconnects automatically diff --git a/crates/cxx-qt/src/lib.rs b/crates/cxx-qt/src/lib.rs index 479c313b6..94697d629 100644 --- a/crates/cxx-qt/src/lib.rs +++ b/crates/cxx-qt/src/lib.rs @@ -116,7 +116,7 @@ pub use cxx_qt_macro::qobject; pub use qobject::QObject; pub use connection::{ConnectionType, QMetaObjectConnection}; -pub use connectionguard::QMetaObjectConnectionGuard; +pub use connectionguard::{QMetaObjectConnectionGuard, QScopedMetaObjectConnectionGuard}; pub use threading::{CxxQtThread, ThreadingQueueError}; // Export static assertions that can then be used in cxx-qt-gen generation diff --git a/crates/cxx-qt/src/signalhandler.rs b/crates/cxx-qt/src/signalhandler.rs index 80a1b75d1..dcd265074 100644 --- a/crates/cxx-qt/src/signalhandler.rs +++ b/crates/cxx-qt/src/signalhandler.rs @@ -12,32 +12,32 @@ pub trait CxxQtSignalHandlerClosure { /// The Id of the CXX type type Id; /// The type of the closure - type FnType: ?Sized; + type FnType<'a>: ?Sized; } // A signal handler helper which is used to move a FnMut closure into C++ #[doc(hidden)] #[repr(transparent)] -pub struct CxxQtSignalHandler +pub struct CxxQtSignalHandler<'a, T> where T: CxxQtSignalHandlerClosure, { - closure: Box, + closure: Box>, } -impl CxxQtSignalHandler +impl<'a, T> CxxQtSignalHandler<'a, T> where T: CxxQtSignalHandlerClosure, { /// Create a new signal handler with the given closure // // Note that we cannot use From as we cannot infer the type in the caller - pub fn new(closure: Box) -> Self { + pub fn new(closure: Box>) -> Self { Self { closure } } /// A mutable reference to the inner closure - pub fn closure(&mut self) -> &mut Box { + pub fn closure(&mut self) -> &mut Box> { &mut self.closure } } @@ -45,7 +45,7 @@ where // Safety: // // Static checks on the C++ and Rust side to ensure the size is the same. -unsafe impl ExternType for CxxQtSignalHandler +unsafe impl ExternType for CxxQtSignalHandler<'_, T> where T: CxxQtSignalHandlerClosure, { diff --git a/examples/qml_features/rust/src/signals.rs b/examples/qml_features/rust/src/signals.rs index e028e4701..4023a62da 100644 --- a/examples/qml_features/rust/src/signals.rs +++ b/examples/qml_features/rust/src/signals.rs @@ -65,8 +65,8 @@ pub mod qobject { } use core::pin::Pin; -use cxx_qt::CxxQtType; -use cxx_qt_lib::{ConnectionType, QMetaObjectConnectionGuard, QString, QUrl}; +use cxx_qt::{CxxQtType, QMetaObjectConnectionGuard}; +use cxx_qt_lib::{ConnectionType, QString, QUrl}; /// A QObject which has Q_SIGNALs #[derive(Default)]