summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2020-12-05 19:01:03 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2020-12-05 19:11:18 +0100
commit731c5db8759565ba8f9a3581166326e8d7bfa069 (patch)
treed0602c960c482483b3a7282fe5cdbe0a6d8d2d84
parent82b53ebf5400ab046c23231218415a2bb711c137 (diff)
downloadrockbox-731c5db875.tar.gz
rockbox-731c5db875.zip
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
-rw-r--r--rbutil/rbutilqt/base/autodetection.cpp17
1 files changed, 7 insertions, 10 deletions
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<struct Detected> 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;
}