Details
-
Suggestion
-
Resolution: Done
-
P3: Somewhat important
-
4.6.0
-
None
-
All
-
90a68926f311ac5bb8f7c53ac8370f9ff7f12c08
Description
When using boost::shared_ptr, you can have your classes derive from boost::enable_shared_from_this, which then allows you to have a method that returns the shared pointer associated with the object. For example, one can have a class like this:
class MyClass : public boost::enable_shared_from_this
{
public:
boost::shared_ptr<MyClass> getSharedThis() const
}
Note that the ref counter is updated with the creation of the new pointer.
In Qt, one could have this method always present in QObject.
Other implementations are possible, such as having:
QSharedPointer<MyClass> sPtr = qSharedFromPointer(ptr);
Etc...
Thanks for considering, as right now I am stuck using a combination of QPointer and boost::shared_ptr to get things working.
Attachments
Issue Links
- replaces
-
QTBUG-7519 Please add boost's 'enable_shared_from_this' functionality to QSharedPointer
-
- Closed
-
For Gerrit Dashboard: QTBUG-7287 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
60346,9 | Add QEnableSharedFromThis class | dev | qt/qtbase | Status: MERGED | +2 | 0 |
74496,1 | Add QEnableSharedFromThis class | stable | qt/qtbase | Status: ABANDONED | -2 | 0 |