NetworkModel: don't leak devices via the statistics lambdas

Original commit message(s)

  • NetworkModel: don't leak devices via the statistics lambdas

Reason for the change

initializeSignals(const Device::Ptr &) connects two lambdas to the device's own DeviceStatistics object and captures the Device::Ptr by value. The device owns that statistics object, so the connection holds a strong reference to its own owner and the device is never destroyed after NetworkManager removes it. A leaked WirelessDevice also keeps its access point list alive, and every one of those objects keeps its PropertiesChanged hook registered with QtDBus.

On a laptop whose Wi-Fi device is torn down and re-created repeatedly (each failed suspend retry does this), plasmashell accumulated on the order of 10^5 signal hooks. QDBusConnectionPrivate::objectDestroyed scans all of them under the write lock for every destroyed QObject, and the GUI thread froze.

The lambdas only ever used the device for uni(), so capture the QString instead.

Test plan

TBD

Screenshots or screen recordings

N/A

Bugs fixed

Merge request reports

Loading
Loading