From 26e713cddcc8a62e49ce7a3352d3b5f13ffd7d52 Mon Sep 17 00:00:00 2001 From: Rob Hoelz Date: Tue, 22 Apr 2014 00:19:50 -0500 Subject: Don't add the database before verification The local storage facility exposed to QML has a bug; if you attempt to open a versioned connection, the version is wrong, and you try to handle that error, the connection is still stored in a connection pool, but in an unopened state. The next time you attempt to connect, no matter if you have the version right or not, the database handle will complain about being unopened. See also http://qt-project.org/forums/viewthread/38458/ Task-number: QTBUG-38543 Change-Id: I597497aab4895c868275a247ad96fb969e1c8ae5 Reviewed-by: Lars Knoll --- src/declarative/qml/qdeclarativesqldatabase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativesqldatabase.cpp b/src/declarative/qml/qdeclarativesqldatabase.cpp index 4b9e43e1..58e874f1 100644 --- a/src/declarative/qml/qdeclarativesqldatabase.cpp +++ b/src/declarative/qml/qdeclarativesqldatabase.cpp @@ -386,7 +386,6 @@ static QScriptValue qmlsqldatabase_open_sync(QScriptContext *context, QScriptEng THROW_SQL(VERSION_ERR,QDeclarativeEngine::tr("SQL: database version mismatch")); } else { created = !QFile::exists(basename+QLatin1String(".sqlite")); - database = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), dbid); if (created) { ini.setValue(QLatin1String("Name"), dbname); if (dbcreationCallback.isFunction()) @@ -402,6 +401,7 @@ static QScriptValue qmlsqldatabase_open_sync(QScriptContext *context, QScriptEng } version = ini.value(QLatin1String("Version")).toString(); } + database = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), dbid); database.setDatabaseName(basename+QLatin1String(".sqlite")); } if (!database.isOpen()) -- cgit v1.2.3