diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2020-08-04 16:52:09 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2020-08-05 10:13:23 +0000 |
commit | 6a5cc268d260d248e5f8e7ab7606750d3ecc0c81 (patch) | |
tree | 9ae09fb33f5d4fd899e20a5845d6d26bfccfec19 | |
parent | 4d45e2defe0cf0e7ed71dc34af694a4147067d22 (diff) |
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>
-rw-r--r-- | src/plugins/coreplugin/statusbarmanager.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/plugins/coreplugin/statusbarmanager.cpp b/src/plugins/coreplugin/statusbarmanager.cpp index 5d9116379f..182375b264 100644 --- a/src/plugins/coreplugin/statusbarmanager.cpp +++ b/src/plugins/coreplugin/statusbarmanager.cpp @@ -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; |