summaryrefslogtreecommitdiff
path: root/src/serialport/qserialportinfo_unix.cpp
diff options
context:
space:
mode:
authorLaszlo Papp <lpapp@kde.org>2013-10-25 00:22:16 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-28 15:36:30 +0100
commitd4c0885256f3005a8758153c1b82d467ee87478d (patch)
treedb5a0db2ecfcaf77e60497bf4f136ec05c01cc2a /src/serialport/qserialportinfo_unix.cpp
parent609b5c9fa7ba47157e1e1831270e2a2bd926b460 (diff)
downloadqtserialport-d4c0885256f3005a8758153c1b82d467ee87478d.tar.gz
Add support for loading udev at run-time
QtSerialPort is linked against udev by default if the development files can be detected on the system. The reason for this is that, it is more common to link against udev than loading it at run-time. People will usually use distribution packages where there cannot be inconsistency between different versions, and hence ABI breaks, etc. The relevant LINK_LIBUDEV variable will be set. This can be overridden by defining LOAD_LIBUDEV for qmake: qmake "DEFINES += LOAD_LIBUDEV" -r It is also worth noting that the common code is separated into a private header, and it can be included for either type of libudev usage. There is no need for its user to handle the compile-time linking or run-time loading separately on top of that. Task-number: QTBUG-34329 Change-Id: I45ffaaede2a74498587a6452fbe3fec7eaf83483 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Diffstat (limited to 'src/serialport/qserialportinfo_unix.cpp')
-rw-r--r--src/serialport/qserialportinfo_unix.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/serialport/qserialportinfo_unix.cpp b/src/serialport/qserialportinfo_unix.cpp
index ea5a1b3..44a4a2c 100644
--- a/src/serialport/qserialportinfo_unix.cpp
+++ b/src/serialport/qserialportinfo_unix.cpp
@@ -49,11 +49,8 @@
#ifndef Q_OS_MAC
-#ifdef HAVE_LIBUDEV
-extern "C"
-{
-#include <libudev.h>
-}
+#if defined(LINK_LIBUDEV) || defined(LOAD_LIBUDEV)
+#include "qtudev_p.h"
#else
#include <QtCore/qdir.h>
#include <QtCore/qstringlist.h>
@@ -65,7 +62,7 @@ QT_BEGIN_NAMESPACE
#ifndef Q_OS_MAC
-#ifndef HAVE_LIBUDEV
+#if !defined(LINK_LIBUDEV) && !defined(LOAD_LIBUDEV)
static inline const QStringList& filtersOfDevices()
{
@@ -218,6 +215,11 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts()
QList<QSerialPortInfo> QSerialPortInfo::availablePorts()
{
+#ifdef LOAD_LIBUDEV
+ static bool symbolsResolved = resolveSymbols();
+ if (!symbolsResolved)
+ return QList<QSerialPortInfo>();
+#endif
QList<QSerialPortInfo> serialPortInfoList;
// White list for devices without a parent