mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Fix some unhandled db errors in user profiles (thanks to Coverity)
This commit is contained in:
parent
687adbf669
commit
3e3f1d42d9
@ -21,6 +21,7 @@
|
||||
#include <QSettings>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
|
||||
QgsUserProfile::QgsUserProfile( const QString &folder )
|
||||
{
|
||||
@ -76,10 +77,12 @@ const QString QgsUserProfile::alias() const
|
||||
QString profileAlias = name();
|
||||
if ( query.exec() )
|
||||
{
|
||||
query.next();
|
||||
QString alias = query.value( 0 ).toString();
|
||||
if ( !alias.isEmpty() )
|
||||
profileAlias = alias;
|
||||
if ( query.next() )
|
||||
{
|
||||
QString alias = query.value( 0 ).toString();
|
||||
if ( !alias.isEmpty() )
|
||||
profileAlias = alias;
|
||||
}
|
||||
}
|
||||
db.close();
|
||||
return profileAlias;
|
||||
@ -108,7 +111,10 @@ QgsError QgsUserProfile::setAlias( const QString &alias )
|
||||
QString sql = "INSERT OR REPLACE INTO tbl_config_variables VALUES ('ALIAS', :alias);";
|
||||
query.prepare( sql );
|
||||
query.bindValue( ":alias", alias );
|
||||
query.exec();
|
||||
if ( !query.exec() )
|
||||
{
|
||||
error.append( QObject::tr( "Could not save alias to database: %1" ).arg( query.lastError().text() ) );
|
||||
}
|
||||
db.close();
|
||||
return error;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user