Changeset View
Changeset View
Standalone View
Standalone View
gui/SensorBrowser.cpp
Show All 40 Lines | |||||
41 | { | 41 | { | ||
42 | #ifdef SENSOR_MODEL_DO_TEST | 42 | #ifdef SENSOR_MODEL_DO_TEST | ||
43 | new ModelTest(this); | 43 | new ModelTest(this); | ||
44 | #endif | 44 | #endif | ||
45 | mIdCount=1; | 45 | mIdCount=1; | ||
46 | } | 46 | } | ||
47 | SensorBrowserModel::~SensorBrowserModel() | 47 | SensorBrowserModel::~SensorBrowserModel() | ||
48 | { | 48 | { | ||
49 | for (auto* hostInfo : mHostInfoMap.values() ) { | ||||
50 | if (hostInfo->sensorAgent()) | ||||
51 | hostInfo->sensorAgent()->disconnectClient(this); | ||||
52 | } | ||||
49 | qDeleteAll( mHostInfoMap ); | 53 | qDeleteAll( mHostInfoMap ); | ||
anthonyfieroni: When you delete the map content, all agents should loose their connections, no? | |||||
No, it only deletes the HostInfo structure. See the source. It doesn't disconnect anything. Nor does deleting this, as the Agent holds the client as a bare pointer, it can't know that it ceased to exist. It isn't even a QPointer (probably bc. SensorClient isn't a QObject). jpalecek: No, it only deletes the HostInfo structure. See [the source](https://phabricator.kde. | |||||
I agree with Anthony though, if you delete a hostInfo it _should_ remove its connection. So it's better to move this code into a destructor for HostInfo. ahiemstra: I agree with Anthony though, if you delete a hostInfo it _should_ remove its connection. So… | |||||
But the host info, at least in its present form, doesn't have the client pointer to pass to disconnectClient. But I can see your point, I will change it. jpalecek: But the host info, at least in its present form, doesn't have the client pointer to pass to… | |||||
50 | mHostInfoMap.clear(); | 54 | mHostInfoMap.clear(); | ||
51 | qDeleteAll( mSensorInfoMap ); | 55 | qDeleteAll( mSensorInfoMap ); | ||
52 | mSensorInfoMap.clear(); | 56 | mSensorInfoMap.clear(); | ||
53 | } | 57 | } | ||
54 | 58 | | |||
55 | int SensorBrowserModel::columnCount( const QModelIndex &) const { //virtual | 59 | int SensorBrowserModel::columnCount( const QModelIndex &) const { //virtual | ||
56 | return 1; | 60 | return 1; | ||
57 | } | 61 | } | ||
▲ Show 20 Lines • Show All 594 Lines • Show Last 20 Lines |
When you delete the map content, all agents should loose their connections, no?