When a KWindowShadow object is destroyed, it's automatically removed
from _shadows and therefore iterators become invalid. This may cause
problems when one is using qDeleteAll because the latter assumes that
the passed container won't change.
Details
Details
- Reviewers
- None
- Group Reviewers
Plasma
Applications don't crash when switching from Oxygen to
Breeze widget style.
Diff Detail
Diff Detail
- Repository
- R113 Oxygen Theme
- Lint
No Linters Available - Unit
No Unit Test Coverage - Build Status
Buildable 23754 Build 23772: arc lint + arc unit
Comment Actions
I would say it's undefined behavior. Either way, we should not call qDeleteAll on a container which is being "simultaneously" mutated.
Comment Actions
it would be nice to have qSafeDeleteAll or something that takes a copy rather than a const ref.
Comment Actions
Well, we could do something like this (not sure whether it works though)
for (KWindowShadow *shadow : _shadows) disconnect(shadow, nullptr, this, nullptr); qDeleteAll(_shadows);
or switch to QPointers
Comment Actions
Another way around is not to use qDeleteAll, e.g.
for( QWidget* widget : _widgets ) { unregisterWidget( widget ); } // or uninstallShadows()
Either way, I'm open to suggestions. :-)
Comment Actions
Alternatively, we could drop qDeleteAll( _widgets ); because the style is destroyed after all widgets have been deleted. So, it's sort of redundant.