Changeset View
Changeset View
Standalone View
Standalone View
libs/handler.cpp
Show First 20 Lines • Show All 490 Lines • ▼ Show 20 Line(s) | 490 | for (NetworkManager::Device::Ptr device : NetworkManager::networkInterfaces()) { | |||
---|---|---|---|---|---|
491 | if (device->type() == NetworkManager::Device::Wifi) { | 491 | if (device->type() == NetworkManager::Device::Wifi) { | ||
492 | NetworkManager::WirelessDevice::Ptr wifiDevice = device.objectCast<NetworkManager::WirelessDevice>(); | 492 | NetworkManager::WirelessDevice::Ptr wifiDevice = device.objectCast<NetworkManager::WirelessDevice>(); | ||
493 | 493 | | |||
494 | if (wifiDevice && wifiDevice->state() != NetworkManager::WirelessDevice::Unavailable) { | 494 | if (wifiDevice && wifiDevice->state() != NetworkManager::WirelessDevice::Unavailable) { | ||
495 | if (!interface.isEmpty() && interface != wifiDevice->interfaceName()) { | 495 | if (!interface.isEmpty() && interface != wifiDevice->interfaceName()) { | ||
496 | continue; | 496 | continue; | ||
497 | } | 497 | } | ||
498 | 498 | | |||
499 | QDateTime now = QDateTime::currentDateTime(); | ||||
500 | QDateTime lastScan = wifiDevice->lastScanTime(); | ||||
501 | QDateTime lastRequestScan = wifiDevice->lastRequestScanTime(); | ||||
502 | // if the last scan finished within the last 10 seconds | ||||
503 | // or a scan request has been sent but hasn't finished yet | ||||
504 | if ((lastScan.isValid() && (lastScan.msecsTo(now) < 10 * 1000)) | ||||
505 | || (lastRequestScan.isValid() && (lastScan < lastRequestScan))) { | ||||
506 | qCDebug(PLASMA_NM) << "Last scan finished " << lastScan.msecsTo(now) << "ms ago and last request scan was sent " | ||||
507 | << lastRequestScan.msecsTo(now) << "ms ago, Skipping scanning on " << wifiDevice->interfaceName() << lastRequestScan << lastScan; | ||||
508 | continue; | ||||
509 | } | ||||
510 | | ||||
499 | qCDebug(PLASMA_NM) << "Requesting wifi scan on device" << wifiDevice->interfaceName(); | 511 | qCDebug(PLASMA_NM) << "Requesting wifi scan on device" << wifiDevice->interfaceName(); | ||
500 | QDBusPendingReply<> reply = wifiDevice->requestScan(); | 512 | QDBusPendingReply<> reply = wifiDevice->requestScan(); | ||
501 | QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); | 513 | QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); | ||
502 | watcher->setProperty("action", Handler::RequestScan); | 514 | watcher->setProperty("action", Handler::RequestScan); | ||
503 | watcher->setProperty("interface", wifiDevice->interfaceName()); | 515 | watcher->setProperty("interface", wifiDevice->interfaceName()); | ||
504 | connect(watcher, &QDBusPendingCallWatcher::finished, this, &Handler::replyFinished); | 516 | connect(watcher, &QDBusPendingCallWatcher::finished, this, &Handler::replyFinished); | ||
505 | } | 517 | } | ||
506 | } | 518 | } | ||
507 | } | 519 | } | ||
508 | } | 520 | } | ||
509 | 521 | | |||
510 | void Handler::scanRequestFailed(const QString &interface) | 522 | void Handler::scanRequestFailed(const QString &interface) | ||
511 | { | 523 | { | ||
512 | if (m_wirelessScanRetryTimer.isActive()) { | 524 | if (m_wirelessScanRetryTimer.isActive()) { | ||
513 | return; | 525 | return; | ||
514 | } | 526 | } | ||
515 | qCDebug(PLASMA_NM) << "Trying soon a new scan on" << interface; | 527 | qCDebug(PLASMA_NM) << "Trying soon a new scan on" << interface; | ||
516 | 528 | | |||
517 | emit wirelessScanTimerEnabled(false); | 529 | emit wirelessScanTimerEnabled(false); | ||
518 | 530 | | |||
519 | auto retryAction = [this,interface]() { | 531 | auto retryAction = [this,interface]() { | ||
jgrulich: This timer never gets deleted. | |||||
timer will be one of the value of hash m_wirelessScanRetryTimer, which are cleaned line 516. meven: timer will be one of the value of hash m_wirelessScanRetryTimer, which are cleaned line 516.
I… | |||||
You remove it just from the map, but it doesn't get deleted, you would need to do something like delete m_wirelessScanRetryTime.take(interface); jgrulich: You remove it just from the map, but it doesn't get deleted, you would need to do something… | |||||
520 | m_wirelessScanRetryTimer.disconnect(); | 532 | m_wirelessScanRetryTimer.disconnect(); | ||
521 | requestScan(interface); | 533 | requestScan(interface); | ||
522 | }; | 534 | }; | ||
523 | connect(&m_wirelessScanRetryTimer, &QTimer::timeout, this, retryAction); | 535 | connect(&m_wirelessScanRetryTimer, &QTimer::timeout, this, retryAction); | ||
524 | m_wirelessScanRetryTimer.start(); | 536 | m_wirelessScanRetryTimer.start(); | ||
525 | } | 537 | } | ||
526 | 538 | | |||
527 | void Handler::initKdedModule() | 539 | void Handler::initKdedModule() | ||
▲ Show 20 Lines • Show All 109 Lines • Show Last 20 Lines |
This timer never gets deleted.