Core: Fix crash on exit

We accessed a reference after removing the value from the container.

Change-Id: Idfb97093b7a23ba04e5cb0582c81031f431dce88
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2020-08-04 16:52:09 +02:00
parent 4d45e2defe
commit 6a5cc268d2

View File

@@ -143,12 +143,11 @@ void StatusBarManager::addStatusBarWidget(QWidget *widget,
void StatusBarManager::destroyStatusBarWidget(QWidget *widget)
{
QTC_ASSERT(widget, return);
for (const QPointer<IContext> &context : m_contexts) {
if (context->widget() == widget) {
m_contexts.removeAll(context);
delete context;
break;
}
const auto it = std::find_if(m_contexts.begin(), m_contexts.end(),
[widget](const auto &context) { return context->widget() == widget; });
if (it != m_contexts.end()) {
delete *it;
m_contexts.erase(it);
}
widget->setParent(nullptr);
delete widget;