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. Signal emission for destructed receiver across threads
QtWS25 Last Chance

Signal emission for destructed receiver across threads

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 202 Views
  • 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.
  • I Offline
    I Offline
    inforathinam
    wrote on last edited by
    #1

    Hi,

    I have signal/ slot connecting mechanism like this. Sender and receiver are in different threads.

    QObject::connect(recall_cine_control_manager.get(), SIGNAL(signalRenderRecalledFrame(const usimage::Image2dBase::ptr&, const usimageprovider::StreamType&, const CineControlManager::PlaybackTimeTracker&, bool)), recall_viewer.get(),
    SLOT(displayRecalledFrame(const usimage::Image2dBase::ptr&, const usimageprovider::StreamType&, const CineControlManager::PlaybackTimeTracker&, bool)), Qt::DirectConnection);

    Here the receiver gets destructed earlier, so when sender emits signal, the application crash.
    I used Qt::DirectConnection, Does Qt::QueuedConnection solve this problem, how?

    How Queued connection knows about the status of the receiver before signal emission / or disconnection?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @inforathinam said in Signal emission for destructed receiver across threads:

      I used Qt::DirectConnection

      You must not use Qt::DirectConnection when you want to send signals from one thread to another. See https://doc.qt.io/qt-5/threads-qobject.html#signals-and-slots-across-threads
      Normally you don't need to specify the connection type at all - Qt knows which one it has to use.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      4

      • Login

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