QNetworkInformation(Win): cleanup dtor

I don't like how it looks, so make stop() work even if it's not
monitoring so that the dtor can call it unconditionally, and without
needing a CoUninitialize call of its own.

Change-Id: I06832d7e1d34317ff49ea2c425c79588719d7cd0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Mårten Nordheim 2021-04-13 15:47:09 +02:00
parent 62efc8990d
commit 7ddf834b86

View File

@ -305,10 +305,7 @@ QNetworkListManagerNetworkInformationBackend::~QNetworkListManagerNetworkInforma
{
if (comInitFailed)
return;
if (monitoring)
stop();
else
CoUninitialize();
stop();
}
void QNetworkListManagerNetworkInformationBackend::setConnectivity(NLM_CONNECTIVITY newConnectivity)
@ -354,12 +351,13 @@ bool QNetworkListManagerNetworkInformationBackend::start()
void QNetworkListManagerNetworkInformationBackend::stop()
{
Q_ASSERT(managerEvents);
Q_ASSERT(monitoring);
// Can return false but realistically shouldn't since that would break everything:
managerEvents->stop();
monitoring = false;
managerEvents.Reset();
if (monitoring) {
Q_ASSERT(managerEvents);
// Can return false but realistically shouldn't since that would break everything:
managerEvents->stop();
monitoring = false;
managerEvents.Reset();
}
CoUninitialize();
comInitFailed = true; // we check this value in start() to see if we need to re-initialize