Details
-
Suggestion
-
Resolution: Out of scope
-
P3: Somewhat important
-
None
-
None
-
None
Description
In multi-threaded applications it may be sometimes useful to create connections between objects created in different threads, or invoking methods of an object that lives in another thread and can be destroyed at any time.
Here is an example from QtNfc:
- The main thread contains Manager object
- Manager creates a Worker object, connects signal cardCreated(QPointer<Card>) or Worker to onCardCreated(QPointer<Card>) of Manager.
- A worker thread is then started with an event loop, Worker is moved to that thread.
- Worker creates an instance of Card and emits cardCreated().
- onCardCreated() of Manager is executed, the manager wants to create Target object that is connected to Card.
Right now the last step requires some other protocol to ensure that Card object is not destroyed before Manager finises all the connection. Extending QObject::connect() to accept QPointer arguments would significantly simplify the use case. QMetaObject::invokeMethod() extended with QPointer support is another API that may be useful in similar cases.
Attachments
Issue Links
- relates to
-
QTBUG-97946 PCSCLite/winscard support in QtNfc
-
- Closed
-