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 15bcded commit afb4739
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
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 = QString( "%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 @@ -89,12 +89,12 @@ namespace Sqlite
{
Query::Query( sqlite3* db, const QString& q ) : db_( db ), 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 = QString( "Query preparation error on %1" ).arg( q );
throw std::runtime_error( err.toLocal8Bit().constData() );
throw std::runtime_error( err.toUtf8().constData() );
}
}

Expand All @@ -107,7 +107,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 @@ -124,11 +124,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 = QString( "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
Expand Up @@ -56,7 +56,7 @@ void initVirtualLayerMetadata( sqlite3* db )
char *errMsg;
if ( create_meta )
{
r = sqlite3_exec( db, QString( "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, QString( "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 afb4739

Please sign in to comment.