From 1b587ca868ee75758959c2470a9c35a21299377f Mon Sep 17 00:00:00 2001 From: Evgeny Startsev Date: Wed, 22 Jul 2015 19:16:33 +0100 Subject: gui: Fix erasing elements from list during iteration. Fixes issue #357. --- gui/apitrace.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'gui') diff --git a/gui/apitrace.cpp b/gui/apitrace.cpp index fe676ff5..3e449357 100644 --- a/gui/apitrace.cpp +++ b/gui/apitrace.cpp @@ -279,18 +279,19 @@ void ApiTrace::loaderFrameLoaded(ApiTraceFrame *frame, if (!m_queuedErrors.isEmpty()) { QList< QPair >::iterator itr; - for (itr = m_queuedErrors.begin(); itr != m_queuedErrors.end(); - ++itr) { + itr = m_queuedErrors.begin(); + while (itr != m_queuedErrors.end()) { const ApiTraceError &error = (*itr).second; if ((*itr).first == frame) { ApiTraceCall *call = frame->callWithIndex(error.callIndex); if (!call) { + ++itr; continue; } call->setError(error.message); - m_queuedErrors.erase(itr); + itr = m_queuedErrors.erase(itr); if (call->hasError()) { m_errors.insert(call); @@ -298,6 +299,8 @@ void ApiTrace::loaderFrameLoaded(ApiTraceFrame *frame, m_errors.remove(call); } emit changed(call); + } else { + ++itr; } } } -- cgit v1.2.3