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)
|
void StatusBarManager::destroyStatusBarWidget(QWidget *widget)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(widget, return);
|
QTC_ASSERT(widget, return);
|
||||||
for (const QPointer<IContext> &context : m_contexts) {
|
const auto it = std::find_if(m_contexts.begin(), m_contexts.end(),
|
||||||
if (context->widget() == widget) {
|
[widget](const auto &context) { return context->widget() == widget; });
|
||||||
m_contexts.removeAll(context);
|
if (it != m_contexts.end()) {
|
||||||
delete context;
|
delete *it;
|
||||||
break;
|
m_contexts.erase(it);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
widget->setParent(nullptr);
|
widget->setParent(nullptr);
|
||||||
delete widget;
|
delete widget;
|
||||||
|
Reference in New Issue
Block a user