Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Behind the Scenes
  3. Wiki Discussion
  4. Signal behaviour when object goes out of scope.

Signal behaviour when object goes out of scope.

Scheduled Pinned Locked Moved Unsolved Wiki Discussion
3 Posts 2 Posters 1.4k 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.
  • S Offline
    S Offline
    Shivendra Pratap Singh
    wrote on last edited by
    #1

    I am running a single-threaded application on 2 monitors, these monitors are touch monitors and they are running the same instance of the application.
    Question is what will happen when somebody performs different operations on these 2 monitors at the same time.
    Let me paint a scenario
    There is a pop up on both the monitors with options Save, Don't Save, Cancel for some data.
    Now somehow users manage to fire Save and Don't Save signal at the same time.

    Suppose Save signal calls the SLOT which saves the data and jumps to the next screen i.e. its object goes out of scope.
    Now in the queue, we have Don't Save Signal which has some other SLOT to call but its object is already out of scope.
    Main issue is here what will happen/ how the application is going to behave??

    Chris KawaC 1 Reply Last reply
    0
    • S Shivendra Pratap Singh

      I am running a single-threaded application on 2 monitors, these monitors are touch monitors and they are running the same instance of the application.
      Question is what will happen when somebody performs different operations on these 2 monitors at the same time.
      Let me paint a scenario
      There is a pop up on both the monitors with options Save, Don't Save, Cancel for some data.
      Now somehow users manage to fire Save and Don't Save signal at the same time.

      Suppose Save signal calls the SLOT which saves the data and jumps to the next screen i.e. its object goes out of scope.
      Now in the queue, we have Don't Save Signal which has some other SLOT to call but its object is already out of scope.
      Main issue is here what will happen/ how the application is going to behave??

      Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      Hi, welcome to the forum.

      @Shivendra-Pratap-Singh said in Signal behaviour when object goes out of scope.:

      Now somehow users manage to fire Save and Don't Save signal at the same time.

      First of all, if the app is single threaded, there's no such thing as "at the same time". Those calls will be serialized no matter what.
      Without additional flags a connection on a single thread will call the slot immediately, so basically it's like a function call (with additional minor overhead). When QObject is deleted all connections to it are severed.

      So summing those factors in, if a slot connected to first signal deletes the object, by the time the second signal is fired the object is already gone and the signal is no longer connected to it. If it was the only connection to that signal emitting it will do nothing.

      1 Reply Last reply
      3
      • S Offline
        S Offline
        Shivendra Pratap Singh
        wrote on last edited by
        #3

        Hi, @Chris-Kawa Thanks for your quick reply.

        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