forked from qt-creator/qt-creator
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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user