From cbda8ea64d8492d7c8f125cc1b43396b91ecdd8e Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Wed, 10 Mar 2010 10:16:51 +1000 Subject: Don't wait forever when scanning for wifi networks on win32 fails. --- .../bearer/nativewifi/qnativewifiengine.cpp | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/plugins/bearer/nativewifi/qnativewifiengine.cpp b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp index 952a6a3..b6522ad 100644 --- a/src/plugins/bearer/nativewifi/qnativewifiengine.cpp +++ b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp @@ -111,8 +111,6 @@ void QNativeWifiEngine::scanComplete() { QMutexLocker locker(&mutex); - QStringList previous = accessPointConfigurations.keys(); - // enumerate interfaces WLAN_INTERFACE_INFO_LIST *interfaceList; DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList); @@ -120,9 +118,15 @@ void QNativeWifiEngine::scanComplete() #ifdef BEARER_MANAGEMENT_DEBUG qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result); #endif + + locker.unlock(); + emit updateCompleted(); + return; } + QStringList previous = accessPointConfigurations.keys(); + for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) { const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i]; @@ -458,18 +462,31 @@ void QNativeWifiEngine::requestUpdate() #ifdef BEARER_MANAGEMENT_DEBUG qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result); #endif + + locker.unlock(); + emit updateCompleted(); + return; } + bool requested = false; for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) { result = local_WlanScan(handle, &interfaceList->InterfaceInfo[i].InterfaceGuid, 0, 0, 0); + if (result != ERROR_SUCCESS) { #ifdef BEARER_MANAGEMENT_DEBUG - if (result != ERROR_SUCCESS) qDebug("%s: WlanScan failed with error %ld\n", __FUNCTION__, result); #endif + } else { + requested = true; + } } local_WlanFreeMemory(interfaceList); + + if (!requested) { + locker.unlock(); + emit updateCompleted(); + } } QNetworkSession::State QNativeWifiEngine::sessionStateForId(const QString &id) -- cgit v0.12