I transformed the identify raster cell sample (Identify raster cell | ArcGIS Maps SDK for Qt | ArcGIS Developers) to use the new identifyLayerAsync method using QFutures. However, sometimes the QFuture never finishes.
On every MapQuickView::hoverMoved event I'd like to update the raster cell value and display it on the map.
connect(m_mapView, &MapQuickView::hoverMoved, this, [this](QHoverEvent& e) {
if (!m_identifyLayerFuture.isFinished()) {
qDebug() << "Still identifying...";
return;
}
qDebug() << "IdentifyingLayer";
m_identifyLayerFuture = m_mapView->identifyLayerAsync(m_rasterLayer, e.position(), 10, false, 1);
m_identifyLayerFuture.then(this, [this](IdentifyLayerResult* rawIdentifyResult) {
qDebug() << "Finished identifying";
const auto identifyResult = std::unique_ptr<IdentifyLayerResult>(rawIdentifyResult);
const auto elements = identifyResult->geoElements();
for (GeoElement* geoElement : elements) {
if (RasterCell* rasterCell = dynamic_cast<RasterCell*>(geoElement)) {
const AttributeListModel* attributes = rasterCell->attributes();
const QStringList attributeNames = rasterCell->attributes()->attributeNames();
for (int i = 0; i < attributeNames.size(); ++i) {
const QString value = QVariant((*attributes)[attributeNames[i]]).toString();
if (attributeNames[i] == "Band_0") {
setRasterValue(value);
}
}
}
}
qDebug() << "Finished processing result";
});
});While moving the mouse, panning, zooming, leaving the raster cell area, usually after a few seconds the identifyLayerAsync QFuture suddenly does not finish anymore. If I use qFuture.waitForFinished() the application is stuck. Sometimes the application also crashes due to access violations.
Please find attached the IdentifyRasterCell.cpp, IdentifyRasterCell.h, IdentifyRasterCell.qml files that I use.
Am I doing something wrong in general, or might this be a bug?