winrt: Fixed listening to tcp socket
For some reason add_ConnectionReceived has to be called on the Xaml thread now. Otherwise the callback function won't be called and thus listening on a TCP socket won't work at all. Task-number: QTBUG-49121 Change-Id: I11ce2f72b0c1d3bb20e9579de5a2ce5150ca966a Reviewed-by: Andrew Knight <andrew.knight@intopalo.com> Reviewed-by: Samuel Nevala <samuel.nevala@intopalo.com> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@theqtcompany.com>
This commit is contained in:
parent
aecf3006bd
commit
08f9a1bd6a
@ -47,11 +47,13 @@
|
||||
|
||||
#include <private/qthread_p.h>
|
||||
#include <private/qabstractsocket_p.h>
|
||||
#include <private/qeventdispatcher_winrt_p.h>
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#include <QSslSocket>
|
||||
#endif
|
||||
|
||||
#include <functional>
|
||||
#include <wrl.h>
|
||||
#include <windows.foundation.collections.h>
|
||||
#include <windows.storage.streams.h>
|
||||
@ -315,9 +317,11 @@ bool QNativeSocketEngine::bind(const QHostAddress &address, quint16 port)
|
||||
Q_ASSERT_SUCCEEDED(hr);
|
||||
}
|
||||
|
||||
hr = d->tcpListener->add_ConnectionReceived(
|
||||
Callback<ClientConnectedHandler>(d, &QNativeSocketEnginePrivate::handleClientConnection).Get(),
|
||||
&d->connectionToken);
|
||||
hr = QEventDispatcherWinRT::runOnXamlThread([d]() {
|
||||
return d->tcpListener->add_ConnectionReceived(
|
||||
Callback<ClientConnectedHandler>(d, &QNativeSocketEnginePrivate::handleClientConnection).Get(),
|
||||
&d->connectionToken);
|
||||
});
|
||||
Q_ASSERT_SUCCEEDED(hr);
|
||||
hr = d->tcpListener->BindEndpointAsync(hostAddress.Get(), portString.Get(), &op);
|
||||
} else if (d->socketType == QAbstractSocket::UdpSocket) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user