From cf84f57632cd314fd4e1600ec0297ad054a598c0 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Sat, 29 Oct 2022 13:32:17 +0300 Subject: [PATCH] Don't append duplicates to openedInspectors There is no benefit in storing the same pointer multiple times in openedInspectors. This occurred when an article inspector window was closed then shown again. When the tab corresponding to the duplicated article inspector pointer was closed, ArticleInspector::beforeClosed() erased only one pointer from openedInspectors. This left dangling duplicate pointer(s) in the list and eventually caused a crash when another inspector's showEvent() accessed a dangling pointer at openedInspectors.front(). --- articleinspector.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/articleinspector.cc b/articleinspector.cc index 7ab091a7..2d1c2006 100644 --- a/articleinspector.cc +++ b/articleinspector.cc @@ -47,7 +47,8 @@ void ArticleInspector::showEvent( QShowEvent * event ) setGeometry( p->geometry() ); } - openedInspectors.push_back( this ); + if( std::find( openedInspectors.begin(), openedInspectors.end(), this ) == openedInspectors.end() ) + openedInspectors.push_back( this ); QWebInspector::showEvent( event ); }