Skip to content
Permalink
Browse files

Prevent creating invalid join in add join dialog (fixes crash)

  • Loading branch information
nyalldawson committed Jun 12, 2016
1 parent e301cc8 commit 693ead28bbb8f7837d8d211c1472eb32069084d9
Showing with 18 additions and 1 deletion.
  1. +16 −1 src/app/qgsjoindialog.cpp
  2. +2 −0 src/app/qgsjoindialog.h
@@ -24,6 +24,7 @@
#include "qgsfieldcombobox.h"

#include <QStandardItemModel>
#include <QPushButton>

QgsJoinDialog::QgsJoinDialog( QgsVectorLayer* layer, QList<QgsMapLayer*> alreadyJoinedLayers, QWidget * parent, Qt::WindowFlags f )
: QDialog( parent, f )
@@ -53,6 +54,12 @@ QgsJoinDialog::QgsJoinDialog( QgsVectorLayer* layer, QList<QgsMapLayer*> already
mJoinFieldComboBox->setLayer( joinLayer );
joinedLayerChanged( joinLayer );
}

connect( mJoinLayerComboBox, SIGNAL( layerChanged( QgsMapLayer* ) ), this, SLOT( checkDefinitionValid() ) );
connect( mJoinFieldComboBox, SIGNAL( fieldChanged( QString ) ), this, SLOT( checkDefinitionValid() ) );
connect( mTargetFieldComboBox, SIGNAL( fieldChanged( QString ) ), this, SLOT( checkDefinitionValid() ) );

checkDefinitionValid();
}

QgsJoinDialog::~QgsJoinDialog()
@@ -98,7 +105,8 @@ void QgsJoinDialog::setJoinInfo( const QgsVectorJoinInfo& joinInfo )
QgsVectorJoinInfo QgsJoinDialog::joinInfo() const
{
QgsVectorJoinInfo info;
info.joinLayerId = mJoinLayerComboBox->currentLayer()->id();
if ( mJoinLayerComboBox->currentLayer() )
info.joinLayerId = mJoinLayerComboBox->currentLayer()->id();
info.joinFieldName = mJoinFieldComboBox->currentField();
info.targetFieldName = mTargetFieldComboBox->currentField();
info.memoryCache = mCacheInMemoryCheckBox->isChecked();
@@ -172,3 +180,10 @@ void QgsJoinDialog::joinedLayerChanged( QgsMapLayer* layer )
mCustomPrefix->setText( layer->name() + '_' );
}
}

void QgsJoinDialog::checkDefinitionValid()
{
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( mJoinLayerComboBox->currentIndex() != -1
&& mJoinFieldComboBox->currentIndex() != -1
&& mTargetFieldComboBox->currentIndex() != -1 );
}
@@ -42,6 +42,8 @@ class APP_EXPORT QgsJoinDialog: public QDialog, private Ui::QgsJoinDialogBase
private slots:
void joinedLayerChanged( QgsMapLayer* layer );

void checkDefinitionValid();

private:
/** Target layer*/
QgsVectorLayer* mLayer;

0 comments on commit 693ead2

Please sign in to comment.
You can’t perform that action at this time.