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. How to ensure handling of signals before executing next statement?
QtWS25 Last Chance

How to ensure handling of signals before executing next statement?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 958 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.
  • ModelTechM Offline
    ModelTechM Offline
    ModelTech
    wrote on last edited by
    #1

    I have a sender that emits a signal toDelete(ObjectOfMyClass*). The next statement after this signal will be deletion of the ObjectOfMyClass. How do I ensure that any receivers of this signal execute their slot code before the deletion of the ObjectOfMyClass? Point is that these receivers need to access ObjectOfMyClass before it is actually deleted?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      If you use DirectConnection
      connect( A, SIGNAL(somethingChanged()), B, SLOT(handleChange()), Qt::DirectConnection );
      Then its much like a function call but i never tested if you can rely on it :)

      1 Reply Last reply
      1
      • ModelTechM Offline
        ModelTechM Offline
        ModelTech
        wrote on last edited by
        #3

        Well, I have used it, but found a way where I don't need to rely so much on it anymore. So, solved in two ways at the same time :lol:

        1 Reply Last reply
        1
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Well, a better/other design where it is not need to say goodbye to an instance would be prefered.
          So sounds like you found the truly right solution :)

          1 Reply Last reply
          0
          • ModelTechM Offline
            ModelTechM Offline
            ModelTech
            wrote on last edited by ModelTech
            #5

            Well, I needed it for another occasion and there Qt::DirectConnection seems to work to satisfaction :)

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              Until you start having threads in the mix.

              The design looks a bit dubious, you should rather have some sort of synchronisation mechanism.

              What does the connected objects have to do with your ObjectOfMyClass instance when it's about to get destroyed ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

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