summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2019-08-21 17:19:34 +0200
committerMårten Nordheim <marten.nordheim@qt.io>2019-08-25 09:54:06 +0000
commit0d336ab3132c85781fc62b9d92dce690b8ff9d59 (patch)
treec4ac7f9c70368b701883a7117e79bd686159e3d9
parent97db8e04ac2efd924c6de4c0bcdcaf845b090bbc (diff)
QNetworkConnectionMonitor(win): Fix memory leak
Through some misconceptions about ComPtr I ended up thinking that it did not call AddRef internally on creation. But it does. This lead to always having > 1 ref-counter. Also stop the monitor on destruction if it hasn't already been stopped. As was already done for QNetworkStatusMonitorPrivate. Change-Id: Ic72a2f5cb3325f86c018f90b497caaec834cb214 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
-rw-r--r--src/network/kernel/qnetconmonitor_win.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/network/kernel/qnetconmonitor_win.cpp b/src/network/kernel/qnetconmonitor_win.cpp
index f9d660d738..a010df8e3a 100644
--- a/src/network/kernel/qnetconmonitor_win.cpp
+++ b/src/network/kernel/qnetconmonitor_win.cpp
@@ -139,7 +139,7 @@ private:
QNetworkConnectionMonitorPrivate *monitor = nullptr;
- QAtomicInteger<ULONG> ref = 1; // start at 1 for our own initial reference
+ QAtomicInteger<ULONG> ref = 0;
DWORD cookie = 0;
};
@@ -346,6 +346,8 @@ QNetworkConnectionMonitorPrivate::~QNetworkConnectionMonitorPrivate()
{
if (comInitFailed)
return;
+ if (monitoring)
+ stopMonitoring();
connectionEvents.Reset();
CoUninitialize();
}
@@ -496,7 +498,7 @@ private:
QNetworkStatusMonitorPrivate *monitor = nullptr;
- QAtomicInteger<ULONG> ref = 1; // start at 1 for our own initial reference
+ QAtomicInteger<ULONG> ref = 0;
DWORD cookie = 0;
};