Skip to content

Commit

Permalink
qsql_db2: fix build failure
Browse files Browse the repository at this point in the history
Casting between Qt::Handle (void*) and db2's SQLHANDLE (int) is
not tolerated by gcc 5. Neither is the missing enum value in the
switch.

Change-Id: Ibce0adc68376e6c411cae238b26abc6682d0392c
Reviewed-by: Andy Shaw <[email protected]>
  • Loading branch information
mabrand committed Nov 23, 2015
1 parent 573f87d commit f906e14
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/sql/drivers/db2/qsql_db2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1132,8 +1132,8 @@ QDB2Driver::QDB2Driver(Qt::HANDLE env, Qt::HANDLE con, QObject* parent)
: QSqlDriver(*new QDB2DriverPrivate, parent)
{
Q_D(QDB2Driver);
d->hEnv = (SQLHANDLE)env;
d->hDbc = (SQLHANDLE)con;
d->hEnv = reinterpret_cast<intptr_t>(env);
d->hDbc = reinterpret_cast<intptr_t>(con);
if (env && con) {
setOpen(true);
setOpenError(false);
Expand Down Expand Up @@ -1197,10 +1197,10 @@ bool QDB2Driver::open(const QString& db, const QString& user, const QString& pas
tmp.toLocal8Bit().constData());
continue;
}
r = SQLSetConnectAttr(d->hDbc, SQL_ATTR_ACCESS_MODE, (SQLPOINTER) v, 0);
r = SQLSetConnectAttr(d->hDbc, SQL_ATTR_ACCESS_MODE, reinterpret_cast<SQLPOINTER>(v), 0);
} else if (opt == QLatin1String("SQL_ATTR_LOGIN_TIMEOUT")) {
v = val.toUInt();
r = SQLSetConnectAttr(d->hDbc, SQL_ATTR_LOGIN_TIMEOUT, (SQLPOINTER) v, 0);
r = SQLSetConnectAttr(d->hDbc, SQL_ATTR_LOGIN_TIMEOUT, reinterpret_cast<SQLPOINTER>(v), 0);
} else if (opt.compare(QLatin1String("PROTOCOL"), Qt::CaseInsensitive) == 0) {
protocol = tmp;
}
Expand Down Expand Up @@ -1506,6 +1506,7 @@ bool QDB2Driver::hasFeature(DriverFeature f) const
case LastInsertId:
case SimpleLocking:
case EventNotifications:
case CancelQuery:
return false;
case BLOB:
case Transactions:
Expand Down Expand Up @@ -1572,7 +1573,7 @@ bool QDB2Driver::setAutoCommit(bool autoCommit)
SQLUINTEGER ac = autoCommit ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF;
SQLRETURN r = SQLSetConnectAttr(d->hDbc,
SQL_ATTR_AUTOCOMMIT,
(SQLPOINTER)ac,
reinterpret_cast<SQLPOINTER>(ac),
sizeof(ac));
if (r != SQL_SUCCESS) {
setLastError(qMakeError(tr("Unable to set autocommit"),
Expand Down

0 comments on commit f906e14

Please sign in to comment.