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

QSharedDataPointer detaches on ptrInst == nullptr

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Duplicate
    • Icon: P4: Low 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

      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!
      

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

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes