diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2020-12-05 19:01:03 +0100 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2020-12-05 19:11:18 +0100 |
commit | 731c5db8759565ba8f9a3581166326e8d7bfa069 (patch) | |
tree | d0602c960c482483b3a7282fe5cdbe0a6d8d2d84 /rbutil | |
parent | 82b53ebf5400ab046c23231218415a2bb711c137 (diff) | |
download | rockbox-731c5db8759565ba8f9a3581166326e8d7bfa069.tar.gz rockbox-731c5db8759565ba8f9a3581166326e8d7bfa069.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
Diffstat (limited to 'rbutil')
-rw-r--r-- | rbutil/rbutilqt/base/autodetection.cpp | 17 |
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) | |||
54 | // hasn't been merged later. This indicates a problem during detection | 54 | // hasn't been merged later. This indicates a problem during detection |
55 | // (ambiguous player but refining it failed). In this case create an entry | 55 | // (ambiguous player but refining it failed). In this case create an entry |
56 | // for eacho of those so the user can select. | 56 | // for eacho of those so the user can select. |
57 | QList<struct Detected> detected; | ||
57 | for(int i = 0; i < m_detected.size(); ++i) { | 58 | for(int i = 0; i < m_detected.size(); ++i) { |
58 | int j = m_detected.at(i).usbdevices.size(); | 59 | int j = m_detected.at(i).usbdevices.size(); |
59 | if(j > 0) { | 60 | if(j > 0) { |
60 | struct Detected entry = m_detected.takeAt(i); | 61 | struct Detected entry = m_detected.at(i); |
61 | while(j--) { | 62 | while(j--) { |
62 | struct Detected d; | 63 | struct Detected d; |
63 | d.device = entry.usbdevices.at(j); | 64 | d.device = entry.usbdevices.at(j); |
64 | d.mountpoint = entry.mountpoint; | 65 | d.mountpoint = entry.mountpoint; |
65 | d.status = PlayerAmbiguous; | 66 | d.status = PlayerAmbiguous; |
66 | m_detected.append(d); | 67 | detected.append(d); |
67 | } | 68 | } |
68 | } | 69 | } |
70 | else { | ||
71 | detected.append(m_detected.at(i)); | ||
72 | } | ||
69 | } | 73 | } |
74 | m_detected = detected; | ||
70 | for(int i = 0; i < m_detected.size(); ++i) { | 75 | for(int i = 0; i < m_detected.size(); ++i) { |
71 | LOG_INFO() << "Detected player:" << m_detected.at(i).device | 76 | LOG_INFO() << "Detected player:" << m_detected.at(i).device |
72 | << "at" << m_detected.at(i).mountpoint | 77 | << "at" << m_detected.at(i).mountpoint |
@@ -329,20 +334,12 @@ QString Autodetection::detectAjbrec(QString root) | |||
329 | switch(header[11]) { | 334 | switch(header[11]) { |
330 | case 2: | 335 | case 2: |
331 | return "recorderv2"; | 336 | return "recorderv2"; |
332 | break; | ||
333 | |||
334 | case 4: | 337 | case 4: |
335 | return "fmrecorder"; | 338 | return "fmrecorder"; |
336 | break; | ||
337 | |||
338 | case 8: | 339 | case 8: |
339 | return "ondiofm"; | 340 | return "ondiofm"; |
340 | break; | ||
341 | |||
342 | case 16: | 341 | case 16: |
343 | return "ondiosp"; | 342 | return "ondiosp"; |
344 | break; | ||
345 | |||
346 | default: | 343 | default: |
347 | break; | 344 | break; |
348 | } | 345 | } |