Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
handle cases of missing indexes
  • Loading branch information
uclaros authored and nyalldawson committed Apr 6, 2023
1 parent ba1dafa commit 2808373
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/qgsapplayertreeviewmenuprovider.cpp
Expand Up @@ -567,7 +567,7 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
case Qgis::LayerType::VectorTile:
case Qgis::LayerType::PointCloud:
{
bool enableSaveAs = ( pcLayer && pcLayer->isValid() ) ||
bool enableSaveAs = ( pcLayer && pcLayer->isValid() && pcLayer->dataProvider()->hasValidIndex() ) ||
( rlayer && rlayer->isValid() );
QMenu *menuExportRaster = new QMenu( tr( "E&xport" ), menu );
menuExportRaster->setObjectName( QStringLiteral( "exportMenu" ) );
Expand Down
4 changes: 4 additions & 0 deletions src/core/pointcloud/qgspointclouddataprovider.cpp
Expand Up @@ -302,6 +302,10 @@ QVector<QVariantMap> QgsPointCloudDataProvider::identify(
QVector<QVariantMap> acceptedPoints;

QgsPointCloudIndex *index = this->index();

if ( !index || !index->isValid() )
return acceptedPoints;

const IndexedPointCloudNode root = index->root();

const QgsRectangle rootNodeExtent = index->nodeMapExtent( root );
Expand Down
4 changes: 4 additions & 0 deletions src/core/pointcloud/qgspointcloudrenderer.cpp
Expand Up @@ -246,6 +246,10 @@ QVector<QVariantMap> QgsPointCloudRenderer::identify( QgsPointCloudLayer *layer,
QVector<QVariantMap> selectedPoints;

QgsPointCloudIndex *index = layer->dataProvider()->index();

if ( !index || !index->isValid() )
return selectedPoints;

const IndexedPointCloudNode root = index->root();

const double maxErrorPixels = renderContext.convertToPainterUnits( maximumScreenError(), maximumScreenErrorUnit() );// in pixels
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgspointcloudquerybuilder.cpp
Expand Up @@ -110,7 +110,7 @@ void QgsPointCloudQueryBuilder::setupGuiViews()

void QgsPointCloudQueryBuilder::populateAttributes()
{
const QgsFields &fields = mLayer->dataProvider()->index()->attributes().toFields();
const QgsFields &fields = mLayer->dataProvider()->attributes().toFields();
mTxtSql->setFields( fields );
for ( int idx = 0; idx < fields.count(); ++idx )
{
Expand Down

0 comments on commit 2808373

Please sign in to comment.