diff options
| author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2016-06-02 13:00:57 +0200 |
|---|---|---|
| committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2016-06-03 10:18:28 +0000 |
| commit | 0a8d3f914c54b057b59942a25d1b76b82e1fa64d (patch) | |
| tree | 0ecec2f10cffd40fa2ab678a99c7a3f7e10330c1 /src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp | |
| parent | 06f7f3fd36f0faec3f7fda559af3bea66d4df47e (diff) | |
evdev: Stop reading on ENODEV
Touch does this correctly for some time already. Keyboard and mouse do not, leading
to flooding the console with the Could not read from ... warning for ever when using
the 'static' device discovery (no libudev) and unplugging a mouse or keyboard.
Change-Id: I6bef44fbed4bc21cc2736b28d1166bf2b7d90edc
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp')
| -rw-r--r-- | src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp index 06751de0ef7..089cc130327 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp @@ -53,7 +53,7 @@ Q_LOGGING_CATEGORY(qLcEvdevKeyMap, "qt.qpa.input.keymap") #include "qevdevkeyboard_defaultmap_p.h" QEvdevKeyboardHandler::QEvdevKeyboardHandler(const QString &device, int fd, bool disableZap, bool enableCompose, const QString &keymapFile) - : m_device(device), m_fd(fd), + : m_device(device), m_fd(fd), m_notify(Q_NULLPTR), m_modifiers(0), m_composing(0), m_dead_unicode(0xffff), m_no_zap(disableZap), m_do_compose(enableCompose), m_keymap(0), m_keymap_size(0), m_keycompose(0), m_keycompose_size(0) @@ -68,9 +68,8 @@ QEvdevKeyboardHandler::QEvdevKeyboardHandler(const QString &device, int fd, bool unloadKeymap(); // socket notifier for events on the keyboard device - QSocketNotifier *notifier; - notifier = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); - connect(notifier, SIGNAL(activated(int)), this, SLOT(readKeycode())); + m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); + connect(m_notify, SIGNAL(activated(int)), this, SLOT(readKeycode())); } QEvdevKeyboardHandler::~QEvdevKeyboardHandler() @@ -155,6 +154,14 @@ void QEvdevKeyboardHandler::readKeycode() } else if (result < 0) { if (errno != EINTR && errno != EAGAIN) { qErrnoWarning(errno, "evdevkeyboard: Could not read from input device"); + // If the device got disconnected, stop reading, otherwise we get flooded + // by the above error over and over again. + if (errno == ENODEV) { + delete m_notify; + m_notify = Q_NULLPTR; + qt_safe_close(m_fd); + m_fd = -1; + } return; } } else { |
