Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-12817

Backing store is not deleted after visible native child widget is reparented

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 4.7.0
    • 4.7.0
    • None
    • None
    • b5360eb2, cb8d2dcc, ea85300f, bc1c4729

    Description

      The following code illustrates this bug:

      QWidget parent1;
      parent1.setGeometry(50, 50, 100, 100);
      
      QWidget parent2;
      parent2.setGeometry(150, 150, 100, 100);
      
      QWidget child(&parent1);
      child.winId();
      child.setGeometry(10, 10, 30, 30);
      
      parent1.show();
      
      // At this point, parent1's backing store has a reference count of 2 (parent1 + child)
      
      parent2.show();
      
      // parent2's backing store has a reference count of 1 (parent2)
      
      child.setParent(&parent2);
      child.show();
      
      // Now parent2's backing store has a reference count of 2 (parent2 + child)
      
      parent1.hide();
      
      // parent1's backing store's reference count should now have gone to zero and it should therefore be deleted, but this does not happen
      

      The reason for this is that, during reparenting, child's control is destroyed and then recreated as a child of parent2. Because the original child control does not receive a 'not visible' event before it gets deleted, it does not decrement the reference count of parent1's backing store. This means that, at the end of the sequence above, parent1's backing store still has a reference count of 1.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              gastockw Gareth Stockwell
              gastockw Gareth Stockwell
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes