Skip to content

Commit acf1f70

Browse files
committedAug 30, 2014
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
1 parent a351385 commit acf1f70

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed
 

‎src/app/ogr/qgsvectorlayersaveasdialog.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( long srsid, const QgsRec
4747
}
4848

4949
mSelectedOnly->setEnabled( layerHasSelectedFeatures );
50+
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( true );
5051
}
5152

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

288+
void QgsVectorLayerSaveAsDialog::on_leFilename_textChanged( const QString& text )
289+
{
290+
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( QFileInfo( text ).absoluteDir().exists() );
291+
}
292+
287293
void QgsVectorLayerSaveAsDialog::on_browseFilename_clicked()
288294
{
289295
QSettings settings;

‎src/app/ogr/qgsvectorlayersaveasdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVectorLayerSav
6767

6868
private slots:
6969
void on_mFormatComboBox_currentIndexChanged( int idx );
70+
void on_leFilename_textChanged( const QString& text );
7071
void on_mCRSSelection_currentIndexChanged( int idx );
7172
void on_browseFilename_clicked();
7273
void on_browseCRS_clicked();

‎src/core/qgsvectorfilewriter.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ QgsVectorFileWriter::QgsVectorFileWriter(
7777
QStringList layOptions = layerOptions;
7878
QStringList dsOptions = datasourceOptions;
7979

80+
if ( theVectorFileName.isEmpty() )
81+
{
82+
mErrorMessage = QObject::tr( "Empty filename given" );
83+
mError = ErrCreateDataSource;
84+
return;
85+
}
86+
8087
QString ogrDriverName;
8188
if ( driverName == "MapInfo MIF" )
8289
{

‎src/providers/ogr/qgsogrprovider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ bool QgsOgrProvider::convertField( QgsField &field, const QTextCodec &encoding )
126126

127127
void QgsOgrProvider::repack()
128128
{
129-
if ( ogrDriverName != "ESRI Shapefile" )
129+
if ( ogrDriverName != "ESRI Shapefile" || ogrOrigLayer == 0 )
130130
return;
131131

132132
QByteArray layerName = OGR_FD_GetName( OGR_L_GetLayerDefn( ogrOrigLayer ) );

0 commit comments

Comments
 (0)
Please sign in to comment.