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

Phase out QScopedPointer

    XMLWordPrintable

Details

    • QT_NO_SCOPED_POINTER

    Description

      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>.

      Attachments

        Issue Links

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

          Activity

            People

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

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes