summaryrefslogtreecommitdiffstats
path: root/src/plugins/generic/evdevkeyboard
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2012-04-13 20:31:41 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-15 01:41:45 +0200
commitd357b74493c737a51f6a81dcaf30b4433ce22af0 (patch)
tree033b7cf4ecd548df33e98c6ae17f537bb3faa381 /src/plugins/generic/evdevkeyboard
parenta9a1bf3359cf25482eba300097cad7b81a237b04 (diff)
Fixed broken logic in evdev input plugins.
If we do multiple reads we need to accumulate the total amount of bytes read, instead of just taking the last read amount into account. Change-Id: Iaa9b90c269f3ed9d09dae67452ca816d9db6217f Reviewed-by: Johannes Zellner <johannes.zellner@nokia.com> Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Diffstat (limited to 'src/plugins/generic/evdevkeyboard')
-rw-r--r--src/plugins/generic/evdevkeyboard/qevdevkeyboardhandler.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/plugins/generic/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/plugins/generic/evdevkeyboard/qevdevkeyboardhandler.cpp
index 73aa6419d3..eb29b853e7 100644
--- a/src/plugins/generic/evdevkeyboard/qevdevkeyboardhandler.cpp
+++ b/src/plugins/generic/evdevkeyboard/qevdevkeyboardhandler.cpp
@@ -168,16 +168,20 @@ void QEvdevKeyboardHandler::readKeycode()
int n = 0;
forever {
- n = qt_safe_read(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);
+ int result = qt_safe_read(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);
- if (n == 0) {
+ if (result == 0) {
qWarning("Got EOF from the input device.");
return;
- } else if (n < 0 && (errno != EINTR && errno != EAGAIN)) {
- qWarning("Could not read from input device: %s", strerror(errno));
- return;
- } else if (n % sizeof(buffer[0]) == 0) {
- break;
+ } else if (result < 0) {
+ if (errno != EINTR && errno != EAGAIN) {
+ qWarning("Could not read from input device: %s", strerror(errno));
+ return;
+ }
+ } else {
+ n += result;
+ if (n % sizeof(buffer[0]) == 0)
+ break;
}
}