Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DXF export crash #41918

Merged
merged 1 commit into from
Feb 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 12 additions & 18 deletions src/app/qgsdxfexportdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ void QgsVectorLayerAndAttributeModel::selectAll()
retrieveAllLayers( rootGroup(), allLayers );
applyVisibility( allLayers, rootGroup() );

emit dataChanged( QModelIndex(), QModelIndex() );
emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ) );
}

void QgsVectorLayerAndAttributeModel::deSelectAll()
Expand All @@ -420,7 +420,7 @@ void QgsVectorLayerAndAttributeModel::deSelectAll()
QSet<QString> noLayers;
applyVisibility( noLayers, rootGroup() );

emit dataChanged( QModelIndex(), QModelIndex() );
emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ) );
}

QgsDxfExportDialog::QgsDxfExportDialog( QWidget *parent, Qt::WindowFlags f )
Expand All @@ -441,9 +441,9 @@ QgsDxfExportDialog::QgsDxfExportDialog( QWidget *parent, Qt::WindowFlags f )
mTreeView->setEditTriggers( QAbstractItemView::AllEditTriggers );
mTreeView->setItemDelegate( mFieldSelectorDelegate );

QgsLayerTreeModel *model = new QgsVectorLayerAndAttributeModel( mLayerTreeGroup, this );
model->setFlags( QgsLayerTreeModel::Flags() );
mTreeView->setModel( model );
mModel = new QgsVectorLayerAndAttributeModel( mLayerTreeGroup, this );
mModel->setFlags( QgsLayerTreeModel::Flags() );
mTreeView->setModel( mModel );
mTreeView->resizeColumnToContents( 0 );
mTreeView->header()->show();

Expand Down Expand Up @@ -507,9 +507,7 @@ QgsDxfExportDialog::~QgsDxfExportDialog()
void QgsDxfExportDialog::mVisibilityPresets_currentIndexChanged( int index )
{
Q_UNUSED( index )
QgsVectorLayerAndAttributeModel *model = qobject_cast< QgsVectorLayerAndAttributeModel * >( mTreeView->model() );
Q_ASSERT( model );
model->applyVisibilityPreset( mVisibilityPresets->currentText() );
mModel->applyVisibilityPreset( mVisibilityPresets->currentText() );
}

void QgsDxfExportDialog::cleanGroup( QgsLayerTreeNode *node )
Expand All @@ -522,7 +520,9 @@ void QgsDxfExportDialog::cleanGroup( QgsLayerTreeNode *node )
const auto constChildren = node->children();
for ( QgsLayerTreeNode *child : constChildren )
{
if ( QgsLayerTree::isLayer( child ) && QgsLayerTree::toLayer( child )->layer()->type() != QgsMapLayerType::VectorLayer )
if ( QgsLayerTree::isLayer( child ) &&
( QgsLayerTree::toLayer( child )->layer()->type() != QgsMapLayerType::VectorLayer ||
! QgsLayerTree::toLayer( child )->layer()->isSpatial() ) )
{
toRemove << child;
continue;
Expand All @@ -542,24 +542,18 @@ void QgsDxfExportDialog::cleanGroup( QgsLayerTreeNode *node )

void QgsDxfExportDialog::selectAll()
{
QgsVectorLayerAndAttributeModel *model = qobject_cast< QgsVectorLayerAndAttributeModel *>( mTreeView->model() );
Q_ASSERT( model );
model->selectAll();
mModel->selectAll();
}

void QgsDxfExportDialog::deSelectAll()
{
QgsVectorLayerAndAttributeModel *model = qobject_cast< QgsVectorLayerAndAttributeModel *>( mTreeView->model() );
Q_ASSERT( model );
model->deSelectAll();
mModel->deSelectAll();
}


QList< QgsDxfExport::DxfLayer > QgsDxfExportDialog::layers() const
{
const QgsVectorLayerAndAttributeModel *model = qobject_cast< const QgsVectorLayerAndAttributeModel *>( mTreeView->model() );
Q_ASSERT( model );
return model->layers();
return mModel->layers();
}


Expand Down
1 change: 1 addition & 0 deletions src/app/qgsdxfexportdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class QgsDxfExportDialog : public QDialog, private Ui::QgsDxfExportDialogBase
void cleanGroup( QgsLayerTreeNode *node );
QgsLayerTree *mLayerTreeGroup = nullptr;
FieldSelectorDelegate *mFieldSelectorDelegate = nullptr;
QgsVectorLayerAndAttributeModel *mModel = nullptr;

QgsCoordinateReferenceSystem mCRS;
};
Expand Down