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

QSharedDataPointer doesn't destroy old data on move assignment

    XMLWordPrintable

Details

    • 323b00e38c38cc864d136d70befd106400c50163

    Description

      The current move assignment operator implementation for QSharedDataPointer and QExplicitlySharedDataPointer is a simple swap of the left hand side and right hand side data pointers. I think this is not sufficient since the right hand side pointer isn't cleared afterwards.

      When moving a reference from a shared pointer `p2` to `p1` like this

      p1 = std::move(p2)
      

      the old reference in `p1` is expected to be gone, possibly invoking the data destructor of the object `p1` was referring to. Due to the swap however the old `p1` data now lives on in `p2` and is destroyed on some later, unexpected occasion (or maybe even not at all).

      Attachments

        For Gerrit Dashboard: QTBUG-66322
        # Subject Branch Project Status CR V

        Activity

          People

            thiago Thiago Macieira
            pwuertz Peter Würtz
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes