qt/qt-x11-free-3.3.8-bz#243722-mysql.patch

71 lines
1.9 KiB
Diff
Raw Normal View History

diff -Nur qt-x11-free-3.3.8/src/sql/drivers/mysql/qsql_mysql.cpp qt-x11-free-3.3.8-me/src/sql/drivers/mysql/qsql_mysql.cpp
--- qt-x11-free-3.3.8/src/sql/drivers/mysql/qsql_mysql.cpp 2007-01-11 14:38:34.000000000 +0100
+++ qt-x11-free-3.3.8-snapshot-me/src/sql/drivers/mysql/qsql_mysql.cpp 2007-05-22 17:15:26.000000000 +0200
@@ -37,7 +37,6 @@
#include "qsql_mysql.h"
#include <private/qsqlextension_p.h>
-#include <qapplication.h>
#include <qdatetime.h>
#include <qvaluevector.h>
#include <qsqlrecord.h>
@@ -52,6 +51,9 @@
QPtrDict<QSqlOpenExtension> *qSqlOpenExtDict();
+static int qMySqlConnectionCount = 0;
+static bool qMySqlInitHandledByUser = FALSE;
+
class QMYSQLOpenExtension : public QSqlOpenExtension
{
public:
@@ -354,9 +356,8 @@
{
#ifndef Q_NO_MYSQL_EMBEDDED
# if MYSQL_VERSION_ID >= 40000
- static bool init = FALSE;
- if ( init )
- return;
+ if ( qMySqlInitHandledByUser || qMySqlConnectionCount > 1 )
+ return;
// this should only be called once
// has no effect on client/server library
@@ -366,8 +367,6 @@
qWarning( "QMYSQLDriver::qServerInit: unable to start server." );
# endif
}
- qAddPostRoutine(qServerEnd);
- init = TRUE;
# endif // MYSQL_VERSION_ID
#endif // Q_NO_MYSQL_EMBEDDED
@@ -392,8 +391,10 @@
d->mysql = (MYSQL *) con;
setOpen( TRUE );
setOpenError( FALSE );
+ if (qMySqlConnectionCount == 1)
+ qMySqlInitHandledByUser = TRUE;
} else {
- qServerInit();
+ qServerInit();
}
}
@@ -402,10 +403,15 @@
qSqlOpenExtDict()->insert( this, new QMYSQLOpenExtension(this) );
d = new QMYSQLDriverPrivate();
d->mysql = 0;
+ qMySqlConnectionCount++;
}
QMYSQLDriver::~QMYSQLDriver()
{
+ qMySqlConnectionCount--;
+ if (qMySqlConnectionCount == 0 && !qMySqlInitHandledByUser)
+ qServerEnd();
+
delete d;
if ( !qSqlOpenExtDict()->isEmpty() ) {
QSqlOpenExtension *ext = qSqlOpenExtDict()->take( this );