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.
Forum Updated to NodeBB v4.3 + New Features

Signal behaviour when object goes out of scope.

Scheduled Pinned Locked Moved Unsolved Wiki Discussion
3 Posts 2 Posters 1.4k 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.
  • S Offline
    S Offline
    Shivendra Pratap Singh
    wrote on 11 Jun 2020, 13:02 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??

    C 1 Reply Last reply 11 Jun 2020, 13:39
    0
    • S Shivendra Pratap Singh
      11 Jun 2020, 13:02

      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??

      C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 11 Jun 2020, 13:39 last edited by Chris Kawa 6 Nov 2020, 13:40
      #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 12 Jun 2020, 08:23 last edited by
        #3

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

        1 Reply Last reply
        0

        1/3

        11 Jun 2020, 13:02

        • Login

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