diff options
author | Rob Hoelz <rob@hoelz.ro> | 2014-04-22 00:11:25 -0500 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-05-29 09:35:49 +0200 |
commit | cbf166d0ab01ce277f9f2a317fd6dabf876e7d04 (patch) | |
tree | cba6ac8734206c376d44eeea234d194348943983 /src | |
parent | 0306626a4deb8c36b219ba08a68248d3a454b697 (diff) |
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: I921b94621009f4968144e1cc513c17b4924a792a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/localstorage/plugin.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 7a7649c6f1..d5dbeeb4c2 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -694,7 +694,6 @@ void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args) V4THROW_SQL2(SQLEXCEPTION_VERSION_ERR, QQmlEngine::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) @@ -710,6 +709,7 @@ void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args) } version = ini.value(QLatin1String("Version")).toString(); } + database = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), dbid); database.setDatabaseName(basename+QLatin1String(".sqlite")); } if (!database.isOpen()) |