Skip to content
Permalink
Browse files
Use QgsFileUtils::ensureFileNameHasExtension
  • Loading branch information
nyalldawson committed Nov 1, 2021
1 parent 1571606 commit 7efd771c68c3a26bd43fe3b895d235296d871063
Showing with 3 additions and 4 deletions.
  1. +3 −4 src/gui/qgsnewvectorlayerdialog.cpp
@@ -27,6 +27,7 @@
#include "qgssettings.h"
#include "qgsogrprovider.h"
#include "qgsgui.h"
#include "qgsfileutils.h"

#include <QPushButton>
#include <QComboBox>
@@ -282,14 +283,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 );

0 comments on commit 7efd771

Please sign in to comment.