KDAB / cxx-qt

Safe interop between Rust and Qt
https://kdab.github.io/cxx-qt/book/
993 stars 66 forks source link

Investigate moving signals to return a normal type then use a manual guard #844

Closed ahayzen-kdab closed 5 months ago

ahayzen-kdab commented 6 months ago

Instead of having our QMetaObjectConnection automatically be RAII, instead just return the normal type in cxx-qt-gen.

Then in cxx-qt-lib change QMetaObjectConnection to be QMetaObjectConnectionGuard.

This could allow for cxx-qt-gen to not depend on cxx-qt-lib (helping #319 ).

my_qobject.on_signal(...).release();
// becomes
my_qobject.on_signal(...);

let connection = my_object.on_signal(...);
connection.release();
//becomes
let guard = cxx_qt_lib::QMetaObjectConnectiongGuard::from(my_qobject.on_signal(...));
guard.release();

{
  let _ = my_object.on_signal(...);
}  // disconnection
// becomes
{
  let _ = cxx_qt_lib::QMetaObjectConnectiongGuard::from(my_qobject.on_signal(...));
}