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

Improvement request for QSharedPointer.

XMLWordPrintable

      It is common to encounter situations where pointers managed by QSharedPointer are double-deleted, usually due to:

      • QObject parent-child ownership – the parent deletes the child when it is destroyed.
      • Interaction with QML – forgetting to set CppOwnership and passing a raw pointer to QML

      Proposed Solution

      Introduce a new smart pointer type with the following properties:

      • Only accepts pointers derived from QObject.
      •  Add the functionality of the QPointer, the class instances get informed if the object is deleted.
      •  The default deletion method could then test if the object is already deleted and throw a Q_ASSERT and/or write a warning log.
      • Optionally, the constructor could detect if the QObject already has a parent, and warn the user (to highlight potential double-deletion risks).

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

            thiago Thiago Macieira
            mahdi.belila Mehdi Belila
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes