Skip to content

Commit 6b12879

Browse files
committed
Fix a bug on error making.
1 parent bbd32c3 commit 6b12879

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

sqlitecipher/sqlitecipher.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,8 +1318,9 @@ bool SQLiteCipherDriver::open(const QString & db, const QString &, const QString
13181318
}
13191319
case CREATE_KEY:
13201320
{
1321-
if (SQLITE_OK != sqlite3_rekey(d->access, password.toUtf8().constData(), password.size())) {
1322-
setLastError(qMakeError(d->access, tr("Cannot create password. Maybe it is encrypted?"), QSqlError::ConnectionError));
1321+
int res = sqlite3_rekey(d->access, password.toUtf8().constData(), password.size());
1322+
if (SQLITE_OK != res) {
1323+
setLastError(qMakeError(d->access, tr("Cannot create password. Maybe it is encrypted?"), QSqlError::ConnectionError, res));
13231324
setOpenError(true);
13241325
setOpen(false);
13251326
sqlite3_close_v2(d->access);
@@ -1354,15 +1355,11 @@ bool SQLiteCipherDriver::open(const QString & db, const QString &, const QString
13541355
setLastError(qMakeError(d->access, tr("Error opening database"),
13551356
QSqlError::ConnectionError, openResult));
13561357
setOpenError(true);
1357-
1358+
setOpen(false);
13581359
if (d->access) {
13591360
sqlite3_close(d->access);
13601361
d->access = nullptr;
13611362
}
1362-
1363-
setLastError(qMakeError(d->access, tr("Error opening database"), QSqlError::ConnectionError));
1364-
setOpenError(true);
1365-
setOpen(false);
13661363
return false;
13671364
}
13681365
}

0 commit comments

Comments
 (0)