Fix double close()

AbstractDataSource::requestData() takes the ownership of the file
descriptor. So the second close() will close an already closed fd.
This commit is contained in:
Vlad Zahorodnii 2021-10-01 18:38:52 +03:00
parent d83da1cdac
commit 61eb8ce75b

View file

@ -1704,7 +1704,6 @@ void DataSourceModel::setSource(KWaylandServer::AbstractDataSource *source)
m_source = source; m_source = source;
m_data.clear(); m_data.clear();
if (source) { if (source) {
const auto client = source->client();
m_data.resize(m_source->mimeTypes().size()); m_data.resize(m_source->mimeTypes().size());
for (auto type = m_source->mimeTypes().cbegin(); type != m_source->mimeTypes().cend(); ++type) { for (auto type = m_source->mimeTypes().cbegin(); type != m_source->mimeTypes().cend(); ++type) {
int pipeFds[2]; int pipeFds[2];
@ -1712,9 +1711,6 @@ void DataSourceModel::setSource(KWaylandServer::AbstractDataSource *source)
continue; continue;
} }
source->requestData(*type, pipeFds[1]); source->requestData(*type, pipeFds[1]);
if (client && client != waylandServer()->internalConnection()->client()) {
close(pipeFds[1]);
}
QFuture<QByteArray> data = QtConcurrent::run(readData, pipeFds[0]); QFuture<QByteArray> data = QtConcurrent::run(readData, pipeFds[0]);
auto watcher = new QFutureWatcher<QByteArray>(this); auto watcher = new QFutureWatcher<QByteArray>(this);
watcher->setFuture(data); watcher->setFuture(data);