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:
parent
97db8e04ac
commit
0d336ab313
@ -139,7 +139,7 @@ private:
|
|||||||
|
|
||||||
QNetworkConnectionMonitorPrivate *monitor = nullptr;
|
QNetworkConnectionMonitorPrivate *monitor = nullptr;
|
||||||
|
|
||||||
QAtomicInteger<ULONG> ref = 1; // start at 1 for our own initial reference
|
QAtomicInteger<ULONG> ref = 0;
|
||||||
DWORD cookie = 0;
|
DWORD cookie = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -346,6 +346,8 @@ QNetworkConnectionMonitorPrivate::~QNetworkConnectionMonitorPrivate()
|
|||||||
{
|
{
|
||||||
if (comInitFailed)
|
if (comInitFailed)
|
||||||
return;
|
return;
|
||||||
|
if (monitoring)
|
||||||
|
stopMonitoring();
|
||||||
connectionEvents.Reset();
|
connectionEvents.Reset();
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
}
|
}
|
||||||
@ -496,7 +498,7 @@ private:
|
|||||||
|
|
||||||
QNetworkStatusMonitorPrivate *monitor = nullptr;
|
QNetworkStatusMonitorPrivate *monitor = nullptr;
|
||||||
|
|
||||||
QAtomicInteger<ULONG> ref = 1; // start at 1 for our own initial reference
|
QAtomicInteger<ULONG> ref = 0;
|
||||||
DWORD cookie = 0;
|
DWORD cookie = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user