We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 810c816 commit 396c671Copy full SHA for 396c671
qmetaobject/src/future.rs
@@ -47,6 +47,9 @@ cpp! {{
47
/// Reference counter.
48
QAtomicInt refs = 0;
49
50
+ // start with refs count of 1, because caller gets the ownership.
51
+ Waker(TraitObject f): future(f), refs(1) {}
52
+
53
void customEvent(QEvent *e) override {
54
Q_UNUSED(e);
55
woken = false;
@@ -102,10 +105,7 @@ pub fn execute_async(f: impl Future<Output = ()> + 'static) {
102
105
let f = Box::into_raw(Box::new(f)) as *mut dyn Future<Output = ()>;
103
106
unsafe {
104
107
let waker = cpp!([f as "TraitObject"] -> *const() as "Waker*" {
- auto w = new Waker;
- w->refs++;
- w->future = f;
108
- return w;
+ return new Waker(f);
109
});
110
poll_with_qt_waker(waker, Pin::new_unchecked(&mut *f));
111
}
0 commit comments