Make it build with older Qt versions (< 5.9)
This commit is contained in:
parent
066a0e07ea
commit
506039ab0c
@ -44,21 +44,28 @@ IntegrationPluginDynatrace::IntegrationPluginDynatrace()
|
|||||||
|
|
||||||
void IntegrationPluginDynatrace::discoverThings(ThingDiscoveryInfo *info)
|
void IntegrationPluginDynatrace::discoverThings(ThingDiscoveryInfo *info)
|
||||||
{
|
{
|
||||||
QHostInfo::lookupHost("ufo.home", info, [this, info](const QHostInfo &host){
|
m_asyncDiscoveries.append(info);
|
||||||
if (host.error() != QHostInfo::NoError) {
|
|
||||||
qCDebug(dcDynatrace()) << "Lookup failed:" << host.errorString();
|
|
||||||
info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("An error happened discovering the UFO in the network."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: QHostInfo::lookupHost apparently calls back from a different thread which breaks
|
// NOTE: QHostInfo::lookupHost will call in from another thread using the Funtor syntax!
|
||||||
// QNetworkAccessManager... Decouple it here with a QueuedConnection
|
// https://bugreports.qt.io/browse/QTBUG-83073
|
||||||
QMetaObject::invokeMethod(this, "resolveIds", Qt::QueuedConnection, Q_ARG(ThingDiscoveryInfo*, info), Q_ARG(QHostInfo, host));
|
// Using the old school syntax...
|
||||||
});
|
QHostInfo::lookupHost("ufo.home", this, SLOT(resolveIds(const QHostInfo &)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntegrationPluginDynatrace::resolveIds(ThingDiscoveryInfo *info, const QHostInfo &host)
|
void IntegrationPluginDynatrace::resolveIds(const QHostInfo &host)
|
||||||
{
|
{
|
||||||
|
if (m_asyncDiscoveries.isEmpty()) {
|
||||||
|
qCWarning(dcDynatrace()) << "Discvery result came in but request has vanished...";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ThingDiscoveryInfo *info = m_asyncDiscoveries.takeFirst();
|
||||||
|
if (host.error() != QHostInfo::NoError) {
|
||||||
|
qCDebug(dcDynatrace()) << "Lookup failed:" << host.errorString();
|
||||||
|
info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("An error happened discovering the UFO in the network."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QList<QNetworkReply*> *pendingInfoRequests = new QList<QNetworkReply*>();
|
QList<QNetworkReply*> *pendingInfoRequests = new QList<QNetworkReply*>();
|
||||||
|
|
||||||
foreach (QHostAddress address, host.addresses()) {
|
foreach (QHostAddress address, host.addresses()) {
|
||||||
|
|||||||
@ -54,19 +54,20 @@ public:
|
|||||||
void executeAction(ThingActionInfo *info) override;
|
void executeAction(ThingActionInfo *info) override;
|
||||||
void thingRemoved(Thing *thing) override;
|
void thingRemoved(Thing *thing) override;
|
||||||
|
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onConnectionChanged(bool connected);
|
||||||
|
|
||||||
|
void resolveIds(const QHostInfo &host);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PluginTimer *m_pluginTimer = nullptr;
|
PluginTimer *m_pluginTimer = nullptr;
|
||||||
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;
|
||||||
|
|
||||||
void getId(const QHostAddress &address);
|
void getId(const QHostAddress &address);
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onConnectionChanged(bool connected);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void resolveIds(ThingDiscoveryInfo *info, const QHostInfo &host);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INTEGRATIONPLUGINDYNATRACE_H
|
#endif // INTEGRATIONPLUGINDYNATRACE_H
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user