Removing a channel's sink or source from a device engine was a queued
message, so a channel could be deleted while the engine thread was
still feeding it. When the caller is deleting, the removal now runs on
the engine thread and is waited for, provided that thread is running
and is not the caller. The MIMO engine gains the same deleting flag and
does the same for its MIMO channels.
ScopeVis and GLScope now attach and detach under the vis mutex and each
clears the other on destruction, as SpectrumVis and GLSpectrum already
do, so a scope window closing while its channel is still running no
longer leaves a dangling pointer on either side.
Also drops an unused variable in GLSpectrumView::paintGL.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Fix cppcheck warning:
Using iterator to member container 'm_sinkBuddies' that may be invalid
clearBuddiesLists() was iterating directly over m_sourceBuddies and
m_sinkBuddies while calling removeBuddy(), which modifies the buddy
relationship lists. This could invalidate the active iterator and result in
undefined behavior.
The issue could lead to intermittent failures during buddy cleanup operations,
such as device removal, device reload, or application shutdown, depending on
container state and timing.
Iterate over copies of the buddy lists so that removing relationships does not
affect the iterators used for traversal.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
In std::vector<T,Allocator>::erase, The iterator pos must be valid and
dereferenceable. Thus the end() iterator (which is valid, but is not
dereferenceable) cannot be used as a value for pos.
Protect against that by checking the result of std::find() before erasing
a buddy entry. The buddy should always be present when removeBuddy() is
called, but avoid undefined behavior if that assumption is violated.
Signed-off-by: Robin Getz <rgetz503@gmail.com>