Bläddra i källkod

Warn of observed oddity, possible Qt bug.

Neal Wilson 11 år sedan
förälder
incheckning
90deb9920f
1 ändrade filer med 17 tillägg och 0 borttagningar
  1. 17
    0
      src/typica.w

+ 17
- 0
src/typica.w Visa fil

@@ -11798,6 +11798,18 @@ QDomDocument* Application::configuration()
11798 11798
 @ The |database()| method provides access to a database connection for use by
11799 11799
 database aware widgets.
11800 11800
 
11801
+\danger Behavior observed on Linux is that this does create a new connection
11802
+which the caller will successfully open, but a |QSqlQuery| created with the
11803
+newly opened |QSqlDatabase| will instead continue to execute queries on the
11804
+default connection instead of the new connection. Replacing the call to
11805
+|QSqlDatabase::database()| with one that does not open the default connection
11806
+or rather than cloning that connection creating a new non-default connection
11807
+results in query execution failing because the connection is not open despite
11808
+the call to |open()| succeeding and |isValid()| and |isOpen()| both returning
11809
+true. If this behavior can be replicated on other platforms, this entire
11810
+exercise would be pointless. At present I believe this to be a bug in Qt, but I
11811
+have not identified it.
11812
+
11801 11813
 @<Application Implementation@>=
11802 11814
 QSqlDatabase Application::database()
11803 11815
 {
@@ -12562,6 +12574,7 @@ void SqlConnectionSetup::testConnection()
12562 12574
 		settings.setValue("database/dbname", dbname->text());
12563 12575
 		settings.setValue("database/user", user->text());
12564 12576
 		settings.setValue("database/password", password->text());
12577
+		database.close();
12565 12578
 		accept();
12566 12579
 	}
12567 12580
 	else
@@ -12597,6 +12610,10 @@ if(!database.open())
12597 12610
 {
12598 12611
 	settings.setValue("database/exists", "false");
12599 12612
 }
12613
+else
12614
+{
12615
+	database.close();
12616
+}
12600 12617
 
12601 12618
 @** Viewing a record of batches.
12602 12619
 

Laddar…
Avbryt
Spara