mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
Prevent creating invalid join in add join dialog (fixes crash)
This commit is contained in:
parent
e301cc80f9
commit
693ead28bb
@ -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,6 +105,7 @@ void QgsJoinDialog::setJoinInfo( const QgsVectorJoinInfo& joinInfo )
|
||||
QgsVectorJoinInfo QgsJoinDialog::joinInfo() const
|
||||
{
|
||||
QgsVectorJoinInfo info;
|
||||
if ( mJoinLayerComboBox->currentLayer() )
|
||||
info.joinLayerId = mJoinLayerComboBox->currentLayer()->id();
|
||||
info.joinFieldName = mJoinFieldComboBox->currentField();
|
||||
info.targetFieldName = mTargetFieldComboBox->currentField();
|
||||
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user