Fix memory leak with tracked timers in triggers not being released on shutdown#4663
Conversation
|
Hey there! Thanks for helping Mudlet improve. 🌟 Test versionsYou can directly test the changes here:
No need to install anything - just unzip and run. |
|
|
||
| TimerUnit::~TimerUnit() | ||
| { | ||
| for (auto&& timer : qAsConst(mQTimerSet)) { |
There was a problem hiding this comment.
Is that the right form? It seems to me that you are move constructing timer - but what is the qAsConst(...) doing - does it not prevent a copy being made of the items that are accessed in mQTimerSet so that suggests you are trying to both pull the items from the set and yet not modify the set...
😕
TBH If it were me doing this I'd just use:
QMutableSetIterator<QTimer*> itPTimer(mQTimerSet);
while (itPTimer.hasNext()) {
delete itPTimer.next();
}fair enough that it is using a Qt Java style (?) iterator rather than a ranged for but it is clear how it works to me...
There was a problem hiding this comment.
Yeah that is the old-school iterator style.
I am not constructing any timers, just looping the existing list.
There was a problem hiding this comment.
Have a look at https://en.cppreference.com/w/cpp/language/range-for for background
There was a problem hiding this comment.
🤕 TBH I don't want to touch stuff like that - it may be nice and shiny and new-fangled but it confuses the hell out of me.... 👴
Brief overview of PR changes/additions
Delete tracked timers when closing profile
Motivation for adding to Mudlet
Fix memory leak if you open/close profiles without shutting down Mudlet often
Other info (issues closed, discussion etc)
Fixes this leak: