Feature #2202
openParent WObject parameter in WTimer single shot function
0%
Description
Hi,
There should be a parameter that should take parent WObject parameter when creating a new WTimer to take the advantage of WObject's memory management and to avoid calling the callback function on a deleted object or avoid accessing deleted objects.
Updated by Wim Dumon over 10 years ago
Saif,
If the receiver parameter inherits from Object, the timer should be disconnected when it fires...
BR,
Wim.
Updated by Saif Rehman over 10 years ago
Oh. But I was using lambda so I thought that there should be a parent parameter
Updated by Wim Dumon over 10 years ago
We cannot do that with lambda currently. We have to come up with a system to improve tracking with lambdas.
BR,
Wim.
Updated by Saif Rehman over 10 years ago
maybe use the parent parameter in case of lambdas?
Updated by Wim Dumon over 10 years ago
- Status changed from New to Feedback
In WObject there's an undocumented class DeletionTracker (in the usage example it's demonstrated to track this, but I believe it can track any WObject).
I'm thinking of something in that direction, but then generalized for use with every functor based connect, ideally in such a way that you can specify multiple tracked objects per connection. You want to be able to express this for any signal, not just for WTimer.
BR,
Wim.
Updated by Saif Rehman over 10 years ago
Can't think of a simple solution however maybe WObject could have a method "trackObject(WObject)" which would add objects to be tracked for deletion.