Paste P440

Masterwork From Distant Lands
ActivePublic

Authored by davidedmundson on Jul 22 2019, 11:41 PM.
commit 35b4dcb232d0a24050d30737d990c19a91e9bf74
Author: David Edmundson <davidedmundson@kde.org>
Date: Tue Jul 23 01:40:36 2019 +0200
asdf
Change-Id: I936aa85e9f25197e7abe6fb3fa729b618c00924d
diff --git a/src/client/qwaylanddataoffer.cpp b/src/client/qwaylanddataoffer.cpp
index 0c732c02..3f6f9005 100644
--- a/src/client/qwaylanddataoffer.cpp
+++ b/src/client/qwaylanddataoffer.cpp
@@ -135,7 +135,7 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
}
int pipefd[2];
- if (qt_safe_pipe(pipefd, O_NONBLOCK) == -1) {
+ if (qt_safe_pipe(pipefd) == -1) {
qWarning("QWaylandMimeData: pipe2() failed");
return QVariant();
}
@@ -158,23 +158,28 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
int QWaylandMimeData::readData(int fd, QByteArray &data) const
{
- char buf[4096];
- int retryCount = 0;
- int n;
- while (true) {
- n = QT_READ(fd, buf, sizeof buf);
- if (n == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) && ++retryCount < 1000)
- usleep(1000);
- else
- break;
- }
- if (retryCount >= 1000)
+ fd_set readset;
+ FD_ZERO(&readset);
+ FD_SET(fd, &readset);
+ struct timeval timeout;
+ timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
+
+ int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
+ if (ready < 0) {
+ qWarning() << "QWaylandDataOffer: error reading data";
+ } else if (ready == 0) {
qWarning("QWaylandDataOffer: timeout reading from pipe");
- if (n > 0) {
- data.append(buf, n);
- n = readData(fd, data);
+ } else {
+ char buf[4096];
+ int n = QT_READ(fd, buf, sizeof buf);
+ if (n > 0) {
+ data.append(buf, n);
+ n = readData(fd, data);
+ }
+ return n;
}
- return n;
+ return 0;
}
}
davidedmundson edited the content of this paste. (Show Details)Jul 22 2019, 11:41 PM
davidedmundson changed the title of this paste from untitled to Masterwork From Distant Lands.