Skip to content
Permalink
Browse files

Fix #11092:

* fix crash when invalid shapefile layer is repacked
* error out if vector file writer is invoke with an empty filename
* don't allow "Save as..." without a given filename
  • Loading branch information
jef-n committed Aug 30, 2014
1 parent a351385 commit acf1f70f137f5bbb374479eaf81cb4aeebeae5d2
@@ -47,6 +47,7 @@ QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( long srsid, const QgsRec
}

mSelectedOnly->setEnabled( layerHasSelectedFeatures );
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( true );
}

void QgsVectorLayerSaveAsDialog::setup()
@@ -284,6 +285,11 @@ void QgsVectorLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged( int idx
}
}

void QgsVectorLayerSaveAsDialog::on_leFilename_textChanged( const QString& text )
{
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( QFileInfo( text ).absoluteDir().exists() );
}

void QgsVectorLayerSaveAsDialog::on_browseFilename_clicked()
{
QSettings settings;
@@ -67,6 +67,7 @@ class QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVectorLayerSav

private slots:
void on_mFormatComboBox_currentIndexChanged( int idx );
void on_leFilename_textChanged( const QString& text );
void on_mCRSSelection_currentIndexChanged( int idx );
void on_browseFilename_clicked();
void on_browseCRS_clicked();
@@ -77,6 +77,13 @@ QgsVectorFileWriter::QgsVectorFileWriter(
QStringList layOptions = layerOptions;
QStringList dsOptions = datasourceOptions;

if ( theVectorFileName.isEmpty() )
{
mErrorMessage = QObject::tr( "Empty filename given" );
mError = ErrCreateDataSource;
return;
}

QString ogrDriverName;
if ( driverName == "MapInfo MIF" )
{
@@ -126,7 +126,7 @@ bool QgsOgrProvider::convertField( QgsField &field, const QTextCodec &encoding )

void QgsOgrProvider::repack()
{
if ( ogrDriverName != "ESRI Shapefile" )
if ( ogrDriverName != "ESRI Shapefile" || ogrOrigLayer == 0 )
return;

QByteArray layerName = OGR_FD_GetName( OGR_L_GetLayerDefn( ogrOrigLayer ) );

0 comments on commit acf1f70

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