Properly use the lookup id
parent
506039ab0c
commit
130a7202ae
|
|
@ -44,22 +44,23 @@ IntegrationPluginDynatrace::IntegrationPluginDynatrace()
|
||||||
|
|
||||||
void IntegrationPluginDynatrace::discoverThings(ThingDiscoveryInfo *info)
|
void IntegrationPluginDynatrace::discoverThings(ThingDiscoveryInfo *info)
|
||||||
{
|
{
|
||||||
m_asyncDiscoveries.append(info);
|
|
||||||
|
|
||||||
// NOTE: QHostInfo::lookupHost will call in from another thread using the Funtor syntax!
|
// NOTE: QHostInfo::lookupHost will call in from another thread using the Funtor syntax!
|
||||||
// https://bugreports.qt.io/browse/QTBUG-83073
|
// https://bugreports.qt.io/browse/QTBUG-83073
|
||||||
// Using the old school syntax...
|
// Using the old school syntax...
|
||||||
QHostInfo::lookupHost("ufo.home", this, SLOT(resolveIds(const QHostInfo &)));
|
int id = QHostInfo::lookupHost("ufo.home", this, SLOT(resolveIds(const QHostInfo &)));
|
||||||
|
m_asyncDiscoveries.insert(id, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntegrationPluginDynatrace::resolveIds(const QHostInfo &host)
|
void IntegrationPluginDynatrace::resolveIds(const QHostInfo &host)
|
||||||
{
|
{
|
||||||
if (m_asyncDiscoveries.isEmpty()) {
|
int id = host.lookupId();
|
||||||
|
|
||||||
|
if (!m_asyncDiscoveries.contains(id)) {
|
||||||
qCWarning(dcDynatrace()) << "Discvery result came in but request has vanished...";
|
qCWarning(dcDynatrace()) << "Discvery result came in but request has vanished...";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ThingDiscoveryInfo *info = m_asyncDiscoveries.takeFirst();
|
ThingDiscoveryInfo *info = m_asyncDiscoveries.take(id);
|
||||||
if (host.error() != QHostInfo::NoError) {
|
if (host.error() != QHostInfo::NoError) {
|
||||||
qCDebug(dcDynatrace()) << "Lookup failed:" << host.errorString();
|
qCDebug(dcDynatrace()) << "Lookup failed:" << host.errorString();
|
||||||
info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("An error happened discovering the UFO in the network."));
|
info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("An error happened discovering the UFO in the network."));
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ private:
|
||||||
QHash<ThingId, Ufo *> m_ufoConnections;
|
QHash<ThingId, Ufo *> m_ufoConnections;
|
||||||
QHash<QUuid, ThingActionInfo *> m_asyncActions;
|
QHash<QUuid, ThingActionInfo *> m_asyncActions;
|
||||||
QHash<QString, ThingSetupInfo *> m_asyncSetup;
|
QHash<QString, ThingSetupInfo *> m_asyncSetup;
|
||||||
QList<ThingDiscoveryInfo *> m_asyncDiscoveries;
|
QHash<int, ThingDiscoveryInfo *> m_asyncDiscoveries;
|
||||||
|
|
||||||
void getId(const QHostAddress &address);
|
void getId(const QHostAddress &address);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue