Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-100124

Creating connections/invoking methods using QPointer

    XMLWordPrintable

    Details

    • Type: Suggestion
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Out of scope
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Core: Object Model
    • Labels:
      None
    • Platform/s:
      All

      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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              Assignee:
              thiago Thiago Macieira
              Reporter:
              ievgenii.meshcheriakov Ievgenii Meshcheriakov
              PM Owner:
              Vladimir Minenko Vladimir Minenko
              RnD Owner:
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes