Open sphaerophoria opened 3 years ago
I believe this is due to this fixme. As far as I can tell refcell usages are propagated to C++ and read back, so this isn't an impossible case to guard against, but it's just avoided because of how QML will recurse into our struct again when handling signals.
I don't have a good answer for a fix here, maybe there's a way to use the type system to prevent users from putting async functions requiring QObjects onto the exeuctor. Maybe async functions should just not be supported on QObjects at all.
I believe this shouldn't happen using the threading model shown in the docs. In this case the event loop is blocked until the queued operation is complete. Maybe a warning in the docs around QObjectPinned::borrow_mut and async code is a good enough fix for now
Yeah, I'm trying to make an app and ended up doing exactly this, but the backend code driving some of the UI just freezes 6-8 seconds after starting the app
yeah, the api is actually unsound :-( https://github.com/woboq/qmetaobject-rs/issues/11
Dispatching a future using a mutable reference to an object accessible from QML results in multiple mutable references.
Here is an example that models a use case I've been using.
Pressing the button in the UI shows the following text
To prove this isn't a contrived example, imagine an application that has gui elements driven both by user interaction and code running on a backend. Events from the backend have to be propagated to the gui. This could be done by giving the QT event loop an async call that polls a tokio socket for events.