summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorAndre Hartmann <aha_1980@gmx.de>2016-09-28 21:08:40 +0200
committerAndré Hartmann <aha_1980@gmx.de>2016-09-29 10:40:59 +0000
commit0f237053c578526078b4a7909e5cf6fb7c72d9de (patch)
tree7216ddc3e5cb84f468a6f72fcb86ebc90f59255c /src/tools
parent4e4d0cc26ef55205697b298d480b09ce9f91dd41 (diff)
canbusutil: Simplify plugin resolving
Change-Id: I970132266e0e066ee58527b19ebb046b14b68592 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/canbusutil/canbusutil.cpp33
1 files changed, 13 insertions, 20 deletions
diff --git a/src/tools/canbusutil/canbusutil.cpp b/src/tools/canbusutil/canbusutil.cpp
index 7364716..48094fb 100644
--- a/src/tools/canbusutil/canbusutil.cpp
+++ b/src/tools/canbusutil/canbusutil.cpp
@@ -221,30 +221,23 @@ bool CanBusUtil::parsePayloadField(QString payload, bool &rtrFrame,
bool CanBusUtil::connectCanDevice()
{
- bool foundPlugin = false;
- const QStringList plugins = m_canBus->plugins();
- for (int i = 0; i < plugins.size(); i++)
- {
- if (plugins.at(i) == m_pluginName) {
- m_canDevice.reset(m_canBus->createDevice(plugins.at(i), m_deviceName));
- if (!m_canDevice) {
- m_output << "Unable to create QCanBusDevice with device name: " << m_deviceName << endl;
- return false;
- }
- connect(m_canDevice.data(), &QCanBusDevice::errorOccurred, m_readTask, &ReadTask::receiveError);
- if (!m_canDevice->connectDevice()) {
- m_output << "Unable to connect QCanBusDevice with device name: " << m_deviceName << endl;
- return false;
- }
- foundPlugin = true;
- }
- }
-
- if (!foundPlugin) {
+ if (!m_canBus->plugins().contains(m_pluginName)) {
m_output << "Could not find suitable plugin." << endl;
printPlugins();
return false;
}
+
+ m_canDevice.reset(m_canBus->createDevice(m_pluginName, m_deviceName));
+ if (!m_canDevice) {
+ m_output << "Unable to create QCanBusDevice with device name: " << m_deviceName << endl;
+ return false;
+ }
+ connect(m_canDevice.data(), &QCanBusDevice::errorOccurred, m_readTask, &ReadTask::receiveError);
+ if (!m_canDevice->connectDevice()) {
+ m_output << "Unable to connect QCanBusDevice with device name: " << m_deviceName << endl;
+ return false;
+ }
+
return true;
}