summaryrefslogtreecommitdiffstats
path: root/src/sql/drivers/sqlite/qsql_sqlite_p.h
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2015-11-26 16:54:34 +0100
committerMark Brand <mabrand@mabrand.nl>2015-12-05 00:19:27 +0000
commitd79ae904660af7a83dc42a389c2457a8c94020f7 (patch)
tree84fe3d87a24575d0ca8188553fa5dae9ab6e47e3 /src/sql/drivers/sqlite/qsql_sqlite_p.h
parentf5f47987ce369aa3f7553e6c0da509461a1ddf1a (diff)
qsql: apply Qt's PIMPL idiom to Q*ResultPrivate
QResult and QResultPrivate are not derived from QObject and QObjectPrivate respectively, but can still benefit from Qt's PIMPL idiom. There are several interrelated aspects to this: - Base all driver ResultPrivate classes on QResultPrivate. Previously, each level in the Result hierarchy tended to keep its own private data class. - The ResultPrivate class initializes its own Result (q_ptr) and Driver members. This ensures that these pointers are correctly set in time for the ResultPrivate constructors and Result constructors. This is more efficient and makes it a lot easier to follow what's being allocated, initialized, and cleaned-up. - Use macros Q_DECLARE_PRIVATE, Q_DECLARE_PUBLIC, Q_D, and Q_Q for access to and from ResultPrivate objects. - ResultPrivate classes refer frequently to their counterpart DriverPrivate. Various patterns were used to do this. Now Q_DECLARE_SQLDRIVER_PRIVATE arranges this uniformly while hiding ugly casting. It creates a public method in the ResultPrivate returning the correctly typed pointer to the corresponding DriverPrivate object. Since the method is public, the Result class and helper classes and functions can also use it. - The explicit const is removed from QResultPrivate::sqldriver, even though it is treated (mostly) like a const within the context of Result and ResultPrivate. This is the same pattern seen in Qt's PIMPL idiom. The macro created getter methods take care of const. - qsql_mysql was using a signal/slot connection to zero its own copy of the driver pointer when the driver was destroyed. This is no longer necessary. Change-Id: Ida4933bc92fb3e9a05ea4b53b48085894734e36e Reviewed-by: Israel Lins Albuquerque <israelins85@yahoo.com.br> Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Diffstat (limited to 'src/sql/drivers/sqlite/qsql_sqlite_p.h')
-rw-r--r--src/sql/drivers/sqlite/qsql_sqlite_p.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/sql/drivers/sqlite/qsql_sqlite_p.h b/src/sql/drivers/sqlite/qsql_sqlite_p.h
index 06f7420572..d0dc91daab 100644
--- a/src/sql/drivers/sqlite/qsql_sqlite_p.h
+++ b/src/sql/drivers/sqlite/qsql_sqlite_p.h
@@ -64,7 +64,7 @@ class Q_EXPORT_SQLDRIVER_SQLITE QSQLiteDriver : public QSqlDriver
{
Q_DECLARE_PRIVATE(QSQLiteDriver)
Q_OBJECT
- friend class QSQLiteResult;
+ friend class QSQLiteResultPrivate;
public:
explicit QSQLiteDriver(QObject *parent = 0);
explicit QSQLiteDriver(sqlite3 *connection, QObject *parent = 0);