Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 acf1f70
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/app/ogr/qgsvectorlayersaveasdialog.cpp
Expand Up @@ -47,6 +47,7 @@ QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( long srsid, const QgsRec
}

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

void QgsVectorLayerSaveAsDialog::setup()
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/app/ogr/qgsvectorlayersaveasdialog.h
Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions src/core/qgsvectorfilewriter.cpp
Expand Up @@ -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" )
{
Expand Down
2 changes: 1 addition & 1 deletion src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -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 ) );
Expand Down

0 comments on commit acf1f70

Please sign in to comment.