Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use QgsFileUtils::ensureFileNameHasExtension
  • Loading branch information
nyalldawson committed Sep 24, 2021
1 parent 988d862 commit 1c21c22
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/gui/qgsnewvectorlayerdialog.cpp
Expand Up @@ -28,6 +28,7 @@
#include "qgsogrprovider.h"
#include "qgsgui.h"
#include "qgsiconutils.h"
#include "qgsfileutils.h"

#include <QPushButton>
#include <QComboBox>
Expand Down Expand Up @@ -291,14 +292,12 @@ void QgsNewVectorLayerDialog::updateExtension()
if ( geometrytype != QgsWkbTypes::NoGeometry )
{
fileName = fileName.replace( fileName.lastIndexOf( QLatin1String( ".dbf" ), -1, Qt::CaseInsensitive ), 4, QLatin1String( ".shp" ) );
if ( !fileName.endsWith( QLatin1String( ".shp" ), Qt::CaseInsensitive ) )
fileName += QLatin1String( ".shp" );
fileName = QgsFileUtils::ensureFileNameHasExtension( fileName, { QStringLiteral( "shp" ) } );
}
else
{
fileName = fileName.replace( fileName.lastIndexOf( QLatin1String( ".shp" ), -1, Qt::CaseInsensitive ), 4, QLatin1String( ".dbf" ) );
if ( !fileName.endsWith( QLatin1String( ".dbf" ), Qt::CaseInsensitive ) )
fileName += QLatin1String( ".dbf" );
fileName = QgsFileUtils::ensureFileNameHasExtension( fileName, { QStringLiteral( "dbf" ) } );
}
}
setFilename( fileName );
Expand Down

0 comments on commit 1c21c22

Please sign in to comment.