Commit fd099a75 authored by Harald Sitter's avatar Harald Sitter 馃挘

actually erase devices

somebody forgot to actually erase 馃槥

this would eventually result in a crash as the container would have
dangling pointers as remove only moves around the entries so the
container would be the same size before and after remove but one of the
pointers would then get deleted in the eventloop

BUG: 428746
FIXED-IN: 5.20.3
parent 3c3827ef
......@@ -85,6 +85,12 @@ private Q_SLOTS:
}
QVERIFY(sawPass);
QVERIFY(sawFail);
// Ensure removing works as well.
// https://bugs.kde.org/show_bug.cgi?id=428746
monitor.removeUDI("udi-pass");
QCOMPARE(monitor.devices().size(), 1);
}
};
......
......@@ -51,7 +51,7 @@ void SMARTMonitor::checkUDI(const QString &udi)
void SMARTMonitor::removeUDI(const QString &udi)
{
std::remove_if(m_devices.begin(), m_devices.end(), [this, udi](Device *dev) {
auto newEnd = std::remove_if(m_devices.begin(), m_devices.end(), [this, udi](Device *dev) {
if (dev->udi() != udi) {
return false;
}
......@@ -60,6 +60,7 @@ void SMARTMonitor::removeUDI(const QString &udi)
dev->deleteLater();
return true;
});
m_devices.erase(newEnd, m_devices.end());
}
void SMARTMonitor::reloadData()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment