diff options
author | Robert Griebl <robert.griebl@qt.io> | 2021-08-19 16:42:41 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-12-03 12:45:18 +0000 |
commit | 70bff8fd1eaa340eca40bbc4ffd9bdf1f593603f (patch) | |
tree | 65f53a607e5a37bb9c8ce242bce8667fe1625ce0 /src/networksettings/connman/qnetworksettingsmanager_p.h | |
parent | ceb71e3d596c7e4025d9153fe8deeb9a762f3986 (diff) |
Do not leak QNetworkSettingsService instances for unnamed networks
For unnamed/hidden networks, a QNetworkSettingsService object was allocated
every time connman reported these networks via its ServicesChanged signal.
Depending on the system setup, this could happen as often as every 30sec.
We now track these objects in m_unnamedServices and m_unknownServices to
avoid those re-allocations.
Also fixed a potential dangling pointer being returned from
current{Wifi,Wired}Connection()
Fixes: QTBUG-94864
Change-Id: I0a217b1bd334073cc6621397ad09ce6a98776ab1
Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@qt.io>
(cherry picked from commit b80655d9ec266155e3719d91c17ed69e81a3a103)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/networksettings/connman/qnetworksettingsmanager_p.h')
-rw-r--r-- | src/networksettings/connman/qnetworksettingsmanager_p.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/networksettings/connman/qnetworksettingsmanager_p.h b/src/networksettings/connman/qnetworksettingsmanager_p.h index c696cdd..7d0cd54 100644 --- a/src/networksettings/connman/qnetworksettingsmanager_p.h +++ b/src/networksettings/connman/qnetworksettingsmanager_p.h @@ -43,6 +43,7 @@ #include <QObject> #include <QtDBus> #include <QMap> +#include <QPointer> #include "connmancommon.h" #include "qnetworksettingsmanager.h" #include "qnetworksettingsinterfacemodel.h" @@ -69,10 +70,10 @@ public: void connectBySsid(const QString &name); void clearConnectionState(); void tryNextConnection(); - void setCurrentWifiConnection(QNetworkSettingsService *connection) {m_currentWifiConnection = connection;} - QNetworkSettingsService* currentWifiConnection() const {return m_currentWifiConnection;} - void setCurrentWiredConnection(QNetworkSettingsService *connection) {m_currentWiredConnection = connection;} - QNetworkSettingsService* currentWiredConnection() const {return m_currentWiredConnection;} + void setCurrentWifiConnection(QNetworkSettingsService *connection); + QNetworkSettingsService* currentWifiConnection() const; + void setCurrentWiredConnection(QNetworkSettingsService *connection); + QNetworkSettingsService* currentWiredConnection() const; public slots: void getServicesFinished(QDBusPendingCallWatcher *watcher); @@ -91,6 +92,7 @@ private: protected: QNetworkSettingsInterfaceModel m_interfaceModel; QNetworkSettingsServiceModel *m_serviceModel; + QMap<QString, QNetworkSettingsService*> m_unknownServices; QMap<QString, QNetworkSettingsService*> m_unnamedServices; QMap<QString, QNetworkSettingsService*> m_unnamedServicesForSsidConnection; QNetworkSettingsServiceFilter *m_serviceFilter; @@ -99,8 +101,8 @@ private: QNetworkSettingsUserAgent *m_agent; QDBusServiceWatcher *m_serviceWatcher; QString m_currentSsid; - QNetworkSettingsService *m_currentWifiConnection; - QNetworkSettingsService *m_currentWiredConnection; + QPointer<QNetworkSettingsService> m_currentWifiConnection; + QPointer<QNetworkSettingsService> m_currentWiredConnection; bool m_initialized; }; |