From e581d1e91c6af32c4655a6476ca6bd282cfdd2d6 Mon Sep 17 00:00:00 2001 From: twi-devel Date: Tue, 13 Oct 2026 14:36:47 +0200 Subject: [PATCH] Fix viewshed_geo_processing for ArcGIS SDK v300 - Changed QList() to {} for Field type compatibility - Updated signal connection from jobStatusChanged to statusChanged - Changed addFeature() to addFeatureAsync() with QFutureWatcher pattern - Removed ACRGIS_VERSION guards (Qt6/SDK v300 only) - Added QFutureWatcher m_addFeatureWatcher member to header Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../MapImpl/viewshed_geo_processing.cpp | 33 +++++++------------ .../MapImpl/viewshed_geo_processing.h | 5 +-- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/qt6-after/qt6-migrated-legatus/Lts/Viewer/SituationMap/MapImpl/viewshed_geo_processing.cpp b/qt6-after/qt6-migrated-legatus/Lts/Viewer/SituationMap/MapImpl/viewshed_geo_processing.cpp index 0c20dd423..1c9cc216d 100755 --- a/qt6-after/qt6-migrated-legatus/Lts/Viewer/SituationMap/MapImpl/viewshed_geo_processing.cpp +++ b/qt6-after/qt6-migrated-legatus/Lts/Viewer/SituationMap/MapImpl/viewshed_geo_processing.cpp @@ -152,7 +152,7 @@ bool ViewshedGeoProcessing::execute(const QPointF &viewshedPoint_map, double out // Create a new feature collection table based upon point geometries using the current map view spatial reference Esri::ArcGISRuntime::FeatureCollectionTable *inputFeatures = - new Esri::ArcGISRuntime::FeatureCollectionTable(QList() + new Esri::ArcGISRuntime::FeatureCollectionTable({} , Esri::ArcGISRuntime::GeometryType::Point , m_srMap , this); @@ -163,16 +163,15 @@ bool ViewshedGeoProcessing::execute(const QPointF &viewshedPoint_map, double out // Assign a physical location to the new point feature based upon where the user clicked on the map view inputFeature->setGeometry(esriViewshedPoint); - // connect to addFeature status changed signal - connect(inputFeatures, &Esri::ArcGISRuntime::FeatureCollectionTable::addFeatureCompleted, this, [this, inputFeatures, outerRadius, observerOffset](QUuid, bool success) + // Add the new feature with (x,y) location to the feature collection table (SDK v300: addFeatureAsync returns QFuture) + QFuture addFeatureFuture = inputFeatures->addFeatureAsync(inputFeature); + + // Use QFutureWatcher to monitor addFeature completion + auto *addFeatureWatcher = new QFutureWatcher(this); + connect(addFeatureWatcher, &QFutureWatcher::finished, this, [this, inputFeatures, outerRadius, observerOffset, addFeatureWatcher]() { - INFO_LOG(m_logger) << LOGFUNCTION << " addFeatureCompleted..."; - - if (!success) - { - ERROR_LOG(m_logger) << LOGFUNCTION << " no success"; - return; - } + addFeatureWatcher->deleteLater(); + INFO_LOG(m_logger) << LOGFUNCTION << " addFeatureAsync completed..."; // Create the parameters that are passed to the used geoprocessing task Esri::ArcGISRuntime::GeoprocessingParameters viewshedParameters = @@ -223,15 +222,8 @@ bool ViewshedGeoProcessing::execute(const QPointF &viewshedPoint_map, double out // Handle errors of GeoprocessingJob: connect(m_viewshedJob, &Esri::ArcGISRuntime::GeoprocessingJob::errorOccurred, this, &ViewshedGeoProcessing::onErrorOccuredGeoprocessingJob); - // Create signal handler for the job - -#if ACRGIS_VERSION >= 0x640E00 // 100.14.0 - // since V100.14 + // Create signal handler for the job (SDK v300 uses statusChanged) connect(m_viewshedJob, &Esri::ArcGISRuntime::GeoprocessingJob::statusChanged, this, &ViewshedGeoProcessing::onJobStatusChangedWithJsParameter); -#else - // until V100.14: - connect(m_viewshedJob, &Esri::ArcGISRuntime::GeoprocessingJob::jobStatusChanged, this, &ViewshedGeoProcessing::onJobStatusChanged); -#endif // ACRGIS_VERSION // start the job @@ -241,8 +233,7 @@ bool ViewshedGeoProcessing::execute(const QPointF &viewshedPoint_map, double out ERROR_LOG(m_logger) << LOGFUNCTION << " viewshedJob->start() failed"; }); - // Add the new feature with (x,y) location to the feature collection table - inputFeatures->addFeature(inputFeature); + addFeatureWatcher->setFuture(addFeatureFuture); TRACE_LOG(m_logger) << LOGFUNCTION << " END" << " m_viewshedInProgress=" << m_viewshedInProgress; return true; @@ -303,14 +294,12 @@ void ViewshedGeoProcessing::onJobStatusChanged() TRACE_LOG(m_logger) << LOGFUNCTION << " END"; } -#if ACRGIS_VERSION >= 0x640E00 // 100.14.0 void ViewshedGeoProcessing::onJobStatusChangedWithJsParameter(const Esri::ArcGISRuntime::JobStatus &/*newStatus*/) { TRACE_LOG(m_logger) << LOGFUNCTION << " START"; onJobStatusChanged(); TRACE_LOG(m_logger) << LOGFUNCTION << " END"; } -#endif // ACRGIS_VERSION bool ViewshedGeoProcessing::processResults(Esri::ArcGISRuntime::GeoprocessingResult *results) diff --git a/qt6-after/qt6-migrated-legatus/Lts/Viewer/SituationMap/MapImpl/viewshed_geo_processing.h b/qt6-after/qt6-migrated-legatus/Lts/Viewer/SituationMap/MapImpl/viewshed_geo_processing.h index 9ca82ef21..53ab8dcaa 100755 --- a/qt6-after/qt6-migrated-legatus/Lts/Viewer/SituationMap/MapImpl/viewshed_geo_processing.h +++ b/qt6-after/qt6-migrated-legatus/Lts/Viewer/SituationMap/MapImpl/viewshed_geo_processing.h @@ -20,6 +20,7 @@ #include #include #include +#include // forward: namespace Esri @@ -79,9 +80,7 @@ public: protected slots: void onJobStatusChanged(); -#if ACRGIS_VERSION >= 0x640E00 // 100.14.0 void onJobStatusChangedWithJsParameter(const Esri::ArcGISRuntime::JobStatus &); -#endif // ACRGIS_VERSION void onErrorOccuredGeoprocessingTask(const Esri::ArcGISRuntime::Error &error); void onErrorOccuredGeoprocessingJob(const Esri::ArcGISRuntime::Error &error); @@ -113,6 +112,8 @@ private: Esri::ArcGISRuntime::Graphic *m_originGraphic = nullptr; Esri::ArcGISRuntime::Graphic *m_extentGraphic = nullptr; + QFutureWatcher m_addFeatureWatcher; + LOGGER_T m_logger; }; // class ViewshedGeoProcessing