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>
This commit is contained in:
Mårten Nordheim 2019-08-21 17:19:34 +02:00
parent 97db8e04ac
commit 0d336ab313

View File

@ -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;
};