From 75155a7345dab9033552a8cd9c2f2655965ef83c Mon Sep 17 00:00:00 2001 From: Honglei Zhang Date: Wed, 7 Dec 2011 11:56:45 +0200 Subject: Revert "Fix sqlite driver memory eating due to close failure" This reverts commit 9a5fb6bd5f0fb3b37897bf722e4cc1673309623c. The mentioned fix has caused failure in qtcreator. Thus it has to be reverted and new fix for the memory leak will be made. --- src/sql/drivers/sqlite/qsql_sqlite.cpp | 7 ----- tests/auto/qsqlquery/tst_qsqlquery.cpp | 49 ---------------------------------- 2 files changed, 56 deletions(-) diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp index 38e4a63..8294a55 100644 --- a/src/sql/drivers/sqlite/qsql_sqlite.cpp +++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp @@ -104,7 +104,6 @@ class QSQLiteDriverPrivate public: inline QSQLiteDriverPrivate() : access(0) {} sqlite3 *access; - QList results; }; @@ -287,12 +286,10 @@ QSQLiteResult::QSQLiteResult(const QSQLiteDriver* db) { d = new QSQLiteResultPrivate(this); d->access = db->d->access; - db->d->results.append(this); } QSQLiteResult::~QSQLiteResult() { - qobject_cast(driver())->d->results.removeOne(this); d->cleanup(); delete d; } @@ -556,10 +553,6 @@ bool QSQLiteDriver::open(const QString & db, const QString &, const QString &, c void QSQLiteDriver::close() { if (isOpen()) { - foreach (QSQLiteResult *result, d->results) { - result->d->finalize(); - } - if (sqlite3_close(d->access) != SQLITE_OK) setLastError(qMakeError(d->access, tr("Error closing database"), QSqlError::ConnectionError)); diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index 652a82e..3cbdb63 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -215,8 +215,6 @@ private slots: void QTBUG_14132(); void QTBUG_21884_data() { generic_data("QSQLITE"); } void QTBUG_21884(); - void QTBUG_16967_data() { generic_data("QSQLITE"); } - void QTBUG_16967(); //clean close void sqlite_constraint_data() { generic_data("QSQLITE"); } void sqlite_constraint(); @@ -3152,53 +3150,6 @@ void tst_QSqlQuery::QTBUG_21884() } } -/** - * This test case test sqlite driver close function. Sqlite driver should close cleanly - * even if there is still outstanding prepared statement. - */ -void tst_QSqlQuery::QTBUG_16967() -{ - QFETCH(QString, dbName); - { - QSqlDatabase db = QSqlDatabase::database(dbName); - CHECK_DATABASE(db); - db.close(); - QCOMPARE(db.lastError().type(), QSqlError::NoError); - } - { - QSqlDatabase db = QSqlDatabase::database(dbName); - CHECK_DATABASE(db); - QSqlQuery q(db); - q.prepare("CREATE TABLE t1 (id INTEGER PRIMARY KEY, str TEXT);"); - db.close(); - QCOMPARE(db.lastError().type(), QSqlError::NoError); - } - { - QSqlDatabase db = QSqlDatabase::database(dbName); - CHECK_DATABASE(db); - QSqlQuery q(db); - q.prepare("CREATE TABLE t1 (id INTEGER PRIMARY KEY, str TEXT);"); - q.exec(); - db.close(); - QCOMPARE(db.lastError().type(), QSqlError::NoError); - } - { - QSqlDatabase db = QSqlDatabase::database(dbName); - CHECK_DATABASE(db); - QSqlQuery q(db); - q.exec("INSERT INTO t1 (id, str) VALUES(1, \"test1\");"); - db.close(); - QCOMPARE(db.lastError().type(), QSqlError::NoError); - } - { - QSqlDatabase db = QSqlDatabase::database(dbName); - CHECK_DATABASE(db); - QSqlQuery q(db); - q.exec("SELECT * FROM t1;"); - db.close(); - QCOMPARE(db.lastError().type(), QSqlError::NoError); - } -} void tst_QSqlQuery::oraOCINumber() { -- cgit v0.12