diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2013-01-28 22:33:22 +0400 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2013-01-28 20:32:42 +0100 |
commit | fdc64bc5270f3849220817da0377d8b5dc17e59c (patch) | |
tree | 31129209117870e5fc84bb50a2d4ae85f68b7586 /src | |
parent | 51f6c3ee7fcd26fe7a5071a1d41d8f938c6ccb82 (diff) | |
download | qtserialport-fdc64bc5270f3849220817da0377d8b5dc17e59c.tar.gz |
Windows: Fixed VID/PID detecting
Previously for devices that does not have a VID/PID returns a "garbage" because don't check the return value from the QString::indexOf().
Now instead of "garbage" returned empty string, as described in the methods vendorIdentifier() and productIdentifier().
Change-Id: I60f9aea2debd567ec7559e8565beb09d3184db3e
Reviewed-by: Thiago Augusto Correa <thiago.correa@gmail.com>
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/serialport/qserialportinfo_win.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/serialport/qserialportinfo_win.cpp b/src/serialport/qserialportinfo_win.cpp index 94106f1..7e7125c 100644 --- a/src/serialport/qserialportinfo_win.cpp +++ b/src/serialport/qserialportinfo_win.cpp @@ -170,8 +170,12 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts() deviceRegistryProperty(deviceInfoSet, &deviceInfoData, SPDRP_MFG).toString(); s = deviceRegistryProperty(deviceInfoSet, &deviceInfoData, SPDRP_HARDWAREID).toStringList().first().toUpper(); - info.d_ptr->vendorIdentifier = s.mid(s.indexOf(QLatin1String("VID_")) + 4, 4); - info.d_ptr->productIdentifier = s.mid(s.indexOf(QLatin1String("PID_")) + 4, 4); + int index = s.indexOf(QLatin1String("VID_")); + if (index != -1) + info.d_ptr->vendorIdentifier = s.mid(index + 4, 4); + index = s.indexOf(QLatin1String("PID_")); + if (index != -1) + info.d_ptr->productIdentifier = s.mid(index + 4, 4); ports.append(info); } |