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

Phase out QScopedPointer

XMLWordPrintable

    • QT_NO_SCOPED_POINTER
    • d30ae54af (dev), 6e669f90f (6.9), f67d4b676 (6.8), ebaf943ea (dev), e7154b4b8 (6.9), 5a5b4e295 (6.8)

      QScopedPointer has a weird protocol (cleanup() instead of operator()()), weird semantics (swap(), take(), contradicting the "scoped" part, but no move SMFs, so can't be held in containers, cf. e.g. QTBUG-48744), and can't handle stateful deleters.

      std::unique_ptr can do all of the above, and act as a scoped pointer, if marked as const (as QSopedPointer needs to be, to disable take() and swap()).

      Add an opt-out macro, QT_NO_SCOPED_POINTER, make QtCore headers compile with it, and then roll it out across the code base, eventually making it the default for each module, and then all modules, centrally.

      When replacing QScopedPointer<C>, consider not only std::unique_ptr<C>, but also std::optional<C>.

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

            cnn Qt Core & Network
            mmutz Marc Mutz
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: