Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Disconnecting a BlockingQueuedConnection
Forum Updated to NodeBB v4.3 + New Features

Disconnecting a BlockingQueuedConnection

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KevNull
    wrote on last edited by
    #1

    If a signal connected using Qt::BlockingQueuedConnection is emitted and then disconnected before the receiving slot returns, what happens? Does the sender wait to disconnect until after the slot returns?

    jsulmJ 1 Reply Last reply
    0
    • K KevNull

      If a signal connected using Qt::BlockingQueuedConnection is emitted and then disconnected before the receiving slot returns, what happens? Does the sender wait to disconnect until after the slot returns?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @KevNull I don't think anything special will happen. The slot is already being executed and you simply disconnect, so the slot will not be called again if the signal is emitted. disconnect() does not have any influence on the slot. Also disconnect() can only be called from another thread while the slot is still being executed as the connection is blocking. That means, the sender can only call disconnect if the slot has finished.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      kshegunovK 1 Reply Last reply
      0
      • K Offline
        K Offline
        KevNull
        wrote on last edited by
        #3

        That makes sense. So I guess both threads remain busy and further calls to emit signal() will simply not have an effect.

        jsulmJ 1 Reply Last reply
        0
        • K KevNull

          That makes sense. So I guess both threads remain busy and further calls to emit signal() will simply not have an effect.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @KevNull Well, further calls to emit signal will be queued and executed one after the other.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • jsulmJ jsulm

            @KevNull I don't think anything special will happen. The slot is already being executed and you simply disconnect, so the slot will not be called again if the signal is emitted. disconnect() does not have any influence on the slot. Also disconnect() can only be called from another thread while the slot is still being executed as the connection is blocking. That means, the sender can only call disconnect if the slot has finished.

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            @jsulm said in Disconnecting a BlockingQueuedConnection:

            That means, the sender can only call disconnect if the slot has finished.

            This doesn't imply a third thread couldn't call disconnect, but that should not be a problem either, as disconnect() is thread-safe.

            Read and abide by the Qt Code of Conduct

            jsulmJ 1 Reply Last reply
            0
            • kshegunovK kshegunov

              @jsulm said in Disconnecting a BlockingQueuedConnection:

              That means, the sender can only call disconnect if the slot has finished.

              This doesn't imply a third thread couldn't call disconnect, but that should not be a problem either, as disconnect() is thread-safe.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @kshegunov "Also disconnect() can only be called from another thread while the slot is still being executed as the connection is blocking." :-)

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved