From 731c5db8759565ba8f9a3581166326e8d7bfa069 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Sat, 5 Dec 2020 19:01:03 +0100 Subject: rbutil: Fix autodetection messing up with multiple players. When multiple players are connected, and at least one of them has a USB ID that is shared between multiple targets the resulting list would be off. Fix that by avoiding to modify a list while iterating over it, that's usually not a good idea. Change-Id: I0c1fc5e1a3264f269de2d71c3a7f2b82877636ba --- rbutil/rbutilqt/base/autodetection.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'rbutil/rbutilqt/base') diff --git a/rbutil/rbutilqt/base/autodetection.cpp b/rbutil/rbutilqt/base/autodetection.cpp index 63ed9ad9ff..341f219c30 100644 --- a/rbutil/rbutilqt/base/autodetection.cpp +++ b/rbutil/rbutilqt/base/autodetection.cpp @@ -54,19 +54,24 @@ bool Autodetection::detect(void) // hasn't been merged later. This indicates a problem during detection // (ambiguous player but refining it failed). In this case create an entry // for eacho of those so the user can select. + QList detected; for(int i = 0; i < m_detected.size(); ++i) { int j = m_detected.at(i).usbdevices.size(); if(j > 0) { - struct Detected entry = m_detected.takeAt(i); + struct Detected entry = m_detected.at(i); while(j--) { struct Detected d; d.device = entry.usbdevices.at(j); d.mountpoint = entry.mountpoint; d.status = PlayerAmbiguous; - m_detected.append(d); + detected.append(d); } } + else { + detected.append(m_detected.at(i)); + } } + m_detected = detected; for(int i = 0; i < m_detected.size(); ++i) { LOG_INFO() << "Detected player:" << m_detected.at(i).device << "at" << m_detected.at(i).mountpoint @@ -329,20 +334,12 @@ QString Autodetection::detectAjbrec(QString root) switch(header[11]) { case 2: return "recorderv2"; - break; - case 4: return "fmrecorder"; - break; - case 8: return "ondiofm"; - break; - case 16: return "ondiosp"; - break; - default: break; } -- cgit v1.2.3