QNetworkInformation[Win]: Catch potential WinRT exceptions
Some Windows SDKs seem to throw an exception from winrt::check_hresult() We need to handle this accordingly. Catch the exception and print relevant warning. Fixes: QTBUG-110408 Pick-to: 6.5 Change-Id: I1434ec425f0d0e597308b53f25f4f15049640060 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
79ac430537
commit
5564b166a3
@ -102,16 +102,22 @@ bool QNetworkListManagerEvents::start()
|
|||||||
#if QT_CONFIG(cpp_winrt)
|
#if QT_CONFIG(cpp_winrt)
|
||||||
using namespace winrt::Windows::Networking::Connectivity;
|
using namespace winrt::Windows::Networking::Connectivity;
|
||||||
using winrt::Windows::Foundation::IInspectable;
|
using winrt::Windows::Foundation::IInspectable;
|
||||||
// Register for changes in the network and store a token to unregister later:
|
try {
|
||||||
token = NetworkInformation::NetworkStatusChanged(
|
// Register for changes in the network and store a token to unregister later:
|
||||||
[owner = QPointer(this)](const IInspectable sender) {
|
token = NetworkInformation::NetworkStatusChanged(
|
||||||
Q_UNUSED(sender);
|
[owner = QPointer(this)](const IInspectable sender) {
|
||||||
if (owner) {
|
Q_UNUSED(sender);
|
||||||
std::scoped_lock locker(owner->winrtLock);
|
if (owner) {
|
||||||
if (owner->token)
|
std::scoped_lock locker(owner->winrtLock);
|
||||||
owner->emitWinRTUpdates();
|
if (owner->token)
|
||||||
}
|
owner->emitWinRTUpdates();
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
} catch (const winrt::hresult_error &ex) {
|
||||||
|
qCWarning(lcNetInfoNLM) << "Failed to register network status changed callback:"
|
||||||
|
<< QSystemError::windowsComString(ex.code());
|
||||||
|
}
|
||||||
|
|
||||||
// Emit initial state
|
// Emit initial state
|
||||||
emitWinRTUpdates();
|
emitWinRTUpdates();
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user