Skip to content

port many Qt shared pointers to standard smart pointers

Xaver Hugl requested to merge work/standard-smart-pointers into master

There are a few benefits to using smart pointers from the standard library:

  • std::unique_ptr has move semantics. With move semantics, transfer of ownership can be properly expressed. This is not the case with QScopedPointer
  • with std::shared_ptr, one can use shared_from_this
  • more developers are used to them, making contributions for newcomers easier

We're also already using a mix of both; because Qt shared pointers provide no benefits, porting to standard smart pointers improves consistency in the code base. Because of that, this commit ports most of the uses of QSharedPointer to std::shared_ptr, and some uses of QScopedPointer to std::unique_ptr

Most of this change was simply done with search-and-replace, but some parts needed manual adjusting. Tabbox and decoration have QSharedPointer in their API for example, I opted to not change them (yet)

Merge request reports