Skip to content

Commit

Permalink
Merge pull request #46312 from elpaso/bugfix-gh46219-delimited-text-c…
Browse files Browse the repository at this point in the history
…rash-wrong-codec

Fix crash when opening CSV with wrong codec
  • Loading branch information
elpaso committed Dec 3, 2021
2 parents ea2e931 + 808c994 commit 1f8fb2e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/providers/delimitedtext/qgsdelimitedtextfile.cpp
Expand Up @@ -90,6 +90,12 @@ bool QgsDelimitedTextFile::open()
if ( mFile )
{
mCodec = QTextCodec::codecForName( !mEncoding.isEmpty() ? mEncoding.toLatin1() : "UTF-8" );
if ( ! mCodec )
{
QgsDebugMsgLevel( QStringLiteral( "Wrong codec '%1' for %2, falling back to locale default." ).arg( mEncoding, mFileName ), 2 );
mCodec = QTextCodec::codecForLocale( );
mEncoding = mCodec->name();
}
if ( mUseWatcher )
{
mWatcher = new QFileSystemWatcher();
Expand Down

0 comments on commit 1f8fb2e

Please sign in to comment.