Select to view content in your preferred language

Bug / Crash: Calling GeoView setAttributionTextVisible does not work and causes crash

244
2
Jump to solution
a month ago
Labels (2)
imbachb
Regular Contributor

We're having issues with setting the attribution text to visible / invisible.

We're using ArcGIS_Maps_SDK_Qt_Windows_200_7_0, with Qt 6.8.1

In our map model we have a simple Q_INVOKABLE function

void
DisplayMap::toggleAttribution()
{
	m_attribution = !m_attribution;
	m_mapView->setAttributionTextVisible(m_attribution);
}

 Which gets triggered from QML via a Button

Button {
    text: "Attribution"
    onClicked: model.toggleAttribution()
}

For one, this does not hide the Attribution, it seems to not work at all. Then when clicking it multiple times (basically after "hiding" the attribution, showing it again, and then "hiding" it again) it crashes.

imbachb_0-1750413564698.pngimbachb_1-1750413649457.png

Interestingly enough if we hide the attribution "early", i.e. when the model gets a reference to the map view, hiding the attribution works. Still, enabling it later, disabling, enabling again still causes crashes.

void
DisplayMap::setMapView(MapQuickView* mapView)
{
	if (!mapView || mapView == m_mapView)
		return;

	m_mapView = mapView;
	m_mapView->setMap(m_map);

	m_mapView->setAttributionTextVisible(false); // This works ...

	emit mapViewChanged();
}

Seems like once the map is fully constructed there is no way to change the attribution, and trying so causes the application to crash.

Please find attached a minimalistic example.

1 Solution

Accepted Solutions
GuillaumeBelz
Esri Contributor

Hello imbachb,

Thank you to report this. I was able to reproduce the problem. This is caused by an invalid QSGNode in MapQuickView. We will fix that.

A possible workaround is to clean up manually the nodes used to render the attribution text. For that, create a new class that derives from MapQuickView and override updatePaintNode functions to remove the children nodes of the root node.

class MyView : public MapQuickView {
  Q_OBJECT
public:
  QSGNode* updatePaintNode(QSGNode* node, UpdatePaintNodeData* data) {
    // the QSGNode used to render the map
    auto* mapViewNode = MapQuickView::updatePaintNode(node, data);

    // clean up children nodes if the attribution text is not visible
    if (mapViewNode && !attributionTextVisible()) {
      auto* child = mapViewNode->firstChild();
      while (child) {
        mapViewNode->removeChildNode(child);
        delete child;
        child = node->firstChild();
      }
    }

    return mapViewNode;
  }
};

Let me know if this works for you.

Guillaume

View solution in original post

2 Replies
GuillaumeBelz
Esri Contributor

Hello imbachb,

Thank you to report this. I was able to reproduce the problem. This is caused by an invalid QSGNode in MapQuickView. We will fix that.

A possible workaround is to clean up manually the nodes used to render the attribution text. For that, create a new class that derives from MapQuickView and override updatePaintNode functions to remove the children nodes of the root node.

class MyView : public MapQuickView {
  Q_OBJECT
public:
  QSGNode* updatePaintNode(QSGNode* node, UpdatePaintNodeData* data) {
    // the QSGNode used to render the map
    auto* mapViewNode = MapQuickView::updatePaintNode(node, data);

    // clean up children nodes if the attribution text is not visible
    if (mapViewNode && !attributionTextVisible()) {
      auto* child = mapViewNode->firstChild();
      while (child) {
        mapViewNode->removeChildNode(child);
        delete child;
        child = node->firstChild();
      }
    }

    return mapViewNode;
  }
};

Let me know if this works for you.

Guillaume

imbachb
Regular Contributor

Instead of using setAttributionTextVisible of GeoView we use your workaround which seems to work. Looking forward to the fix so we can remove this workaround sometime in the future.
Many thanks!

0 Kudos