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

QSharedDataPointer detaches on ptrInst == nullptr

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Duplicate
    • P4: Low
    • None
    • 4.0.1, 5.6, 5.7, 5.8, 5.9, 5.10.1, 5.11.0 Beta 1
    • Core: Other
    • None

    Description

      QSharedDataPointer doesn't implement

      friend bool operator==(T *a, QSharedDataPointer<T> const &b) const
      

      and

      friend bool operator==(QSharedDataPointer<T> const &a, T *b) const
      

      Because of this, the shared pointer detaches on

      ptrInst == nullptr
      

      Example:

      QSharedDataPointer<int> ptrInst(new int(-1));
      QSharedDataPointer<int> secondInst = ptrInst; // ref()
      bool isNull;
      isNull = !ptrInst; // ok, no detach()
      isNull = ptrInst == nullptr; // NOT OK, detaches!
      

      Attachments

        Issue Links

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

          Activity

            People

              thiago Thiago Macieira
              mhennings Martin Hennings
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes