summaryrefslogtreecommitdiffstats
path: root/src/sql/drivers/tds/qsql_tds.cpp
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2013-04-03 21:44:30 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-04 13:13:37 +0200
commit0bdc86d9ef7be8e27598d245c6ca8026f08aff12 (patch)
tree53d6556f439ebfdd92a5dc24d4dac61daf3f9869 /src/sql/drivers/tds/qsql_tds.cpp
parent708d39fa31368f80152440e94e4a361d024b19c1 (diff)
QSqlDriver: use Q_DECLARE_PUBLIC/Q_DECLARE_PRIVATE
406c8ef6e67da introduced deriving the private SQL driver classes from QSqlDriverPrivate. However, the drivers continued to keep their own pointer to the private class, even though QObject provides the same pointer. Worse yet, the private class is allocated too late and not even passed to QSqlDriver. The result is that QSqlDriver allocates a separate instance of QSqlDriverPrivate. This is likely to cause all kinds of chaos. The private class needs to be allocated in time pass it to QSqlDriver which passes it on to QObject. This commit covers the the base class and drivers: ibase mysql odbc psql sqlite tds Fixes for the remaining drivers will follow. Change-Id: Id8e7ec4205b0ca6cd00bd022c9cd24f137089245 Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Diffstat (limited to 'src/sql/drivers/tds/qsql_tds.cpp')
-rw-r--r--src/sql/drivers/tds/qsql_tds.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/sql/drivers/tds/qsql_tds.cpp b/src/sql/drivers/tds/qsql_tds.cpp
index fe59fa8822..8d5f63c879 100644
--- a/src/sql/drivers/tds/qsql_tds.cpp
+++ b/src/sql/drivers/tds/qsql_tds.cpp
@@ -327,12 +327,12 @@ QTDSResult::QTDSResult(const QTDSDriver* db)
: QSqlCachedResult(db)
{
d = new QTDSResultPrivate();
- d->login = db->d->login;
+ d->login = db->d_func()->login;
- d->dbproc = dbopen(d->login, const_cast<char*>(db->d->hostName.toLatin1().constData()));
+ d->dbproc = dbopen(d->login, const_cast<char*>(db->d_func()->hostName.toLatin1().constData()));
if (!d->dbproc)
return;
- if (dbuse(d->dbproc, const_cast<char*>(db->d->db.toLatin1().constData())) == FAIL)
+ if (dbuse(d->dbproc, const_cast<char*>(db->d_func()->db.toLatin1().constData())) == FAIL)
return;
// insert d in error handler dict
@@ -541,14 +541,15 @@ QSqlRecord QTDSResult::record() const
///////////////////////////////////////////////////////////////////
QTDSDriver::QTDSDriver(QObject* parent)
- : QSqlDriver(parent)
+ : QSqlDriver(*new QTDSDriverPrivate, parent)
{
init();
}
QTDSDriver::QTDSDriver(LOGINREC* rec, const QString& host, const QString &db, QObject* parent)
- : QSqlDriver(parent)
+ : QSqlDriver(*new QTDSDriverPrivate, parent)
{
+ Q_D(QTDSDriver);
init();
d->login = rec;
d->hostName = host;
@@ -561,12 +562,13 @@ QTDSDriver::QTDSDriver(LOGINREC* rec, const QString& host, const QString &db, QO
QVariant QTDSDriver::handle() const
{
+ Q_D(const QTDSDriver);
return QVariant(qRegisterMetaType<LOGINREC *>("LOGINREC*"), &d->login);
}
void QTDSDriver::init()
{
- d = new QTDSDriverPrivate();
+ Q_D(QTDSDriver);
d->initialized = (dbinit() == SUCCEED);
// the following two code-lines will fail compilation on some FreeTDS versions
// just comment them out if you have FreeTDS (you won't get any errors and warnings then)
@@ -606,6 +608,7 @@ bool QTDSDriver::open(const QString & db,
int /*port*/,
const QString& /*connOpts*/)
{
+ Q_D(QTDSDriver);
if (isOpen())
close();
if (!d->initialized) {
@@ -645,6 +648,7 @@ bool QTDSDriver::open(const QString & db,
void QTDSDriver::close()
{
+ Q_D(QTDSDriver);
if (isOpen()) {
#ifdef Q_USE_SYBASE
dbloginfree(d->login);