Skip to content

Commit

Permalink
[virtual] Fix encoding issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Mercier committed Nov 9, 2016
1 parent 5093ec6 commit 164a85a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/providers/virtual/qgsvirtuallayersqlitehelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ QgsScopedSqlite::QgsScopedSqlite( const QString& path, bool withExtension )
sqlite3_auto_extension( reinterpret_cast < void( * )() > ( qgsvlayerModuleInit ) );
}
int r;
r = sqlite3_open( path.toLocal8Bit().constData(), &db_ );
r = sqlite3_open( path.toUtf8().constData(), &db_ );
if ( withExtension )
{
// reset the automatic extensions
Expand All @@ -41,7 +41,7 @@ QgsScopedSqlite::QgsScopedSqlite( const QString& path, bool withExtension )
{
QString err = QStringLiteral( "%1 [%2]" ).arg( sqlite3_errmsg( db_ ), path );
QgsDebugMsg( err );
throw std::runtime_error( err.toLocal8Bit().constData() );
throw std::runtime_error( err.toUtf8().constData() );
}
// enable extended result codes
sqlite3_extended_result_codes( db_, 1 );
Expand Down Expand Up @@ -92,12 +92,12 @@ namespace Sqlite
, stmt_( nullptr )
, nBind_( 1 )
{
QByteArray ba( q.toLocal8Bit() );
QByteArray ba( q.toUtf8() );
int r = sqlite3_prepare_v2( db, ba.constData(), ba.size(), &stmt_, nullptr );
if ( r )
{
QString err = QStringLiteral( "Query preparation error on %1: %2" ).arg( q ).arg( sqlite3_errmsg( db ) );
throw std::runtime_error( err.toLocal8Bit().constData() );
throw std::runtime_error( err.toUtf8().constData() );
}
}

Expand All @@ -110,7 +110,7 @@ namespace Sqlite

Query& Query::bind( const QString& str, int idx )
{
QByteArray ba( str.toLocal8Bit() );
QByteArray ba( str.toUtf8() );
int r = sqlite3_bind_text( stmt_, idx, ba.constData(), ba.size(), SQLITE_TRANSIENT );
if ( r )
{
Expand All @@ -127,11 +127,11 @@ namespace Sqlite
void Query::exec( sqlite3* db, const QString& sql )
{
char *errMsg = nullptr;
int r = sqlite3_exec( db, sql.toLocal8Bit().constData(), nullptr, nullptr, &errMsg );
int r = sqlite3_exec( db, sql.toUtf8().constData(), nullptr, nullptr, &errMsg );
if ( r )
{
QString err = QStringLiteral( "Query execution error on %1: %2 - %3" ).arg( sql ).arg( r ).arg( errMsg );
throw std::runtime_error( err.toLocal8Bit().constData() );
throw std::runtime_error( err.toUtf8().constData() );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/providers/virtual/qgsvirtuallayersqlitemodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void initVirtualLayerMetadata( sqlite3* db )
char *errMsg;
if ( create_meta )
{
r = sqlite3_exec( db, QStringLiteral( "CREATE TABLE _meta (version INT, url TEXT); INSERT INTO _meta (version) VALUES(%1);" ).arg( VIRTUAL_LAYER_VERSION ).toLocal8Bit().constData(), nullptr, nullptr, &errMsg );
r = sqlite3_exec( db, QStringLiteral( "CREATE TABLE _meta (version INT, url TEXT); INSERT INTO _meta (version) VALUES(%1);" ).arg( VIRTUAL_LAYER_VERSION ).toUtf8().constData(), nullptr, nullptr, &errMsg );
if ( r )
{
throw std::runtime_error( errMsg );
Expand Down

0 comments on commit 164a85a

Please sign in to comment.