platforms/drm: fix gpu removal

As soon as m_backends.removeOne(*it) returns, "it" no longer
points to the same value.

CCBUG: 441372
This commit is contained in:
Xaver Hugl 2021-08-23 23:22:28 +02:00
parent 6f6944058b
commit fbff8636b9

View file

@ -151,12 +151,12 @@ void EglMultiBackend::addGpu(DrmGpu *gpu)
void EglMultiBackend::removeGpu(DrmGpu *gpu)
{
auto it = std::find_if(m_backends.constBegin(), m_backends.constEnd(), [gpu](auto backend) {
auto it = std::find_if(m_backends.begin(), m_backends.end(), [gpu](const auto &backend) {
return backend->gpu() == gpu;
});
if (it != m_backends.constEnd()) {
m_backends.removeOne(*it);
if (it != m_backends.end()) {
delete *it;
m_backends.erase(it);
}
}