CopperSpice Overview  1.5.1

If a QPointer was pointing to a QWidget (or a subclass of QWidget), the QPointer was nulled by the QWidget destructor. QObject and QWidget were changed so the QPointer is now nulled by the QObject destructor.

In CopperSpice QPointer and QWeakPointer were changed and are now equally efficient. QPointer was changed to use methods in QWeakPointer which are for internal use only. The old guard mechanism in QObject has been removed.

  • QPointer has changed to use QWeakPointer which is more efficient and faster
  • QWeakPointer has been deprecated unless it is used with QSharedPointer
  • QPointer is currently not thread safe
  • Since QPointer is not thread safe, use QWeakPointer and QSharedPointer in multi-threaded applications
  • QWeakPointer::data() has been deprecated

The following table contains a list of the smart pointers currently available in CopperSpice.

Category Classes Description
Shared Pointers QSharedPointer, QWeakPointer Thread safe pointers, they behave like std::shared_ptr and std::weak_ptr
Scoped Pointers QScopedPointer, QScopedArrayPointer Pointer takes ownership of an object and ensures the object is properly deleted at the end of the pointer's scope
Scoped pointers can not be copied
Scoped Pointer QPatternist::AutoPtr AutoPtr in an internal class based on std::auto_ptr
Non-Standard QSharedDataPointer, QExplicitlySharedDataPointer Pointer makes a copy of the data when changed on a write
Non-Standard QPointer Pointer becomes null when the QObject instance is destroyed