summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-03-14 01:00:21 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2019-03-14 10:49:29 +0100
commit32084b073362e52df597cc388cf54f5173e20b0d (patch)
tree9a6f881f0ab0bc22e3a491fae81d494815cc514f /src/plugins
parent8d4e8217fdc01417ab8ea33303dd0ce7f769d10e (diff)
parenteb25acc05b177c49eb81b190a476854fbf3c6fb1 (diff)
Merge remote-tracking branch 'origin/5.13' into dev
Conflicts: src/corelib/tools/qcollator_win.cpp Change-Id: I6d806d7c58b2057ebde3ad915bb5551f34b700e5
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/ios/qioscontext.mm3
-rw-r--r--src/plugins/sqldrivers/psql/qsql_psql.cpp105
-rw-r--r--src/plugins/sqldrivers/psql/qsql_psql_p.h14
3 files changed, 63 insertions, 59 deletions
diff --git a/src/plugins/platforms/ios/qioscontext.mm b/src/plugins/platforms/ios/qioscontext.mm
index fff66049ff..535e7d7aa6 100644
--- a/src/plugins/platforms/ios/qioscontext.mm
+++ b/src/plugins/platforms/ios/qioscontext.mm
@@ -306,7 +306,7 @@ bool QIOSContext::verifyGraphicsHardwareAvailability()
Q_UNUSED(oldState);
if (applicationBackgrounded && newState != Qt::ApplicationSuspended) {
qCDebug(lcQpaGLContext) << "app no longer backgrounded, rendering enabled";
- applicationBackgrounded = true;
+ applicationBackgrounded = false;
}
}
);
@@ -317,6 +317,7 @@ bool QIOSContext::verifyGraphicsHardwareAvailability()
return;
qCDebug(lcQpaGLContext) << "app backgrounded, rendering disabled";
+ applicationBackgrounded = true;
// By the time we receive this signal the application has moved into
// Qt::ApplactionStateSuspended, and all windows have been obscured,
diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp
index 49b793ce38..c1be91cb22 100644
--- a/src/plugins/sqldrivers/psql/qsql_psql.cpp
+++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp
@@ -53,6 +53,7 @@
#include <qlocale.h>
#include <QtSql/private/qsqlresult_p.h>
#include <QtSql/private/qsqldriver_p.h>
+#include <QtCore/private/qlocale_tools_p.h>
#include <queue>
@@ -135,7 +136,7 @@ protected:
bool nextResult() override;
QVariant data(int i) override;
bool isNull(int field) override;
- bool reset (const QString &query) override;
+ bool reset(const QString &query) override;
int size() override;
int numRowsAffected() override;
QSqlRecord record() const override;
@@ -319,15 +320,15 @@ public:
bool processResults();
};
-static QSqlError qMakeError(const QString& err, QSqlError::ErrorType type,
- const QPSQLDriverPrivate *p, PGresult* result = 0)
+static QSqlError qMakeError(const QString &err, QSqlError::ErrorType type,
+ const QPSQLDriverPrivate *p, PGresult *result = nullptr)
{
const char *s = PQerrorMessage(p->connection);
QString msg = p->isUtf8 ? QString::fromUtf8(s) : QString::fromLocal8Bit(s);
QString errorCode;
if (result) {
- errorCode = QString::fromLatin1(PQresultErrorField(result, PG_DIAG_SQLSTATE));
- msg += QString::fromLatin1("(%1)").arg(errorCode);
+ errorCode = QString::fromLatin1(PQresultErrorField(result, PG_DIAG_SQLSTATE));
+ msg += QString::fromLatin1("(%1)").arg(errorCode);
}
return QSqlError(QLatin1String("QPSQL: ") + err, msg, type, errorCode);
}
@@ -436,7 +437,7 @@ void QPSQLResultPrivate::deallocatePreparedStmt()
preparedStmtId.clear();
}
-QPSQLResult::QPSQLResult(const QPSQLDriver* db)
+QPSQLResult::QPSQLResult(const QPSQLDriver *db)
: QSqlResult(*new QPSQLResultPrivate(this, db))
{
Q_D(QPSQLResult);
@@ -663,27 +664,30 @@ QVariant QPSQLResult::data(int i)
return atoi(val);
case QVariant::Double: {
if (ptype == QNUMERICOID) {
- if (numericalPrecisionPolicy() != QSql::HighPrecision) {
- QVariant retval;
- bool convert;
- double dbl=QString::fromLatin1(val).toDouble(&convert);
- if (numericalPrecisionPolicy() == QSql::LowPrecisionInt64)
- retval = (qlonglong)dbl;
- else if (numericalPrecisionPolicy() == QSql::LowPrecisionInt32)
- retval = (int)dbl;
- else if (numericalPrecisionPolicy() == QSql::LowPrecisionDouble)
- retval = dbl;
- if (!convert)
- return QVariant();
- return retval;
- }
- return QString::fromLatin1(val);
+ if (numericalPrecisionPolicy() == QSql::HighPrecision)
+ return QString::fromLatin1(val);
+ }
+ bool ok;
+ double dbl = qstrtod(val, nullptr, &ok);
+ if (!ok) {
+ if (qstricmp(val, "NaN") == 0)
+ dbl = qQNaN();
+ else if (qstricmp(val, "Infinity") == 0)
+ dbl = qInf();
+ else if (qstricmp(val, "-Infinity") == 0)
+ dbl = -qInf();
+ else
+ return QVariant();
}
- if (qstricmp(val, "Infinity") == 0)
- return qInf();
- if (qstricmp(val, "-Infinity") == 0)
- return -qInf();
- return QString::fromLatin1(val).toDouble();
+ if (ptype == QNUMERICOID) {
+ if (numericalPrecisionPolicy() == QSql::LowPrecisionInt64)
+ return QVariant((qlonglong)dbl);
+ else if (numericalPrecisionPolicy() == QSql::LowPrecisionInt32)
+ return QVariant((int)dbl);
+ else if (numericalPrecisionPolicy() == QSql::LowPrecisionDouble)
+ return QVariant(dbl);
+ }
+ return dbl;
}
case QVariant::Date:
if (val[0] == '\0') {
@@ -711,7 +715,7 @@ QVariant QPSQLResult::data(int i)
#if QT_CONFIG(datestring)
if (dtval.length() < 10) {
return QVariant(QDateTime());
- } else {
+ } else {
QChar sign = dtval[dtval.size() - 3];
if (sign == QLatin1Char('-') || sign == QLatin1Char('+')) dtval += QLatin1String(":00");
return QVariant(QDateTime::fromString(dtval, Qt::ISODate).toLocalTime());
@@ -741,7 +745,7 @@ bool QPSQLResult::isNull(int field)
return PQgetisnull(d->result, currentRow, field);
}
-bool QPSQLResult::reset (const QString& query)
+bool QPSQLResult::reset(const QString &query)
{
Q_D(QPSQLResult);
cleanup();
@@ -868,7 +872,6 @@ QSqlRecord QPSQLResult::record() const
void QPSQLResult::virtual_hook(int id, void *data)
{
Q_ASSERT(data);
-
QSqlResult::virtual_hook(id, data);
}
@@ -966,7 +969,7 @@ bool QPSQLResult::exec()
bool QPSQLDriverPrivate::setEncodingUtf8()
{
- PGresult* result = exec("SET CLIENT_ENCODING TO 'UNICODE'");
+ PGresult *result = exec("SET CLIENT_ENCODING TO 'UNICODE'");
int status = PQresultStatus(result);
PQclear(result);
return status == PGRES_COMMAND_OK;
@@ -974,7 +977,7 @@ bool QPSQLDriverPrivate::setEncodingUtf8()
void QPSQLDriverPrivate::setDatestyle()
{
- PGresult* result = exec("SET DATESTYLE TO 'ISO'");
+ PGresult *result = exec("SET DATESTYLE TO 'ISO'");
int status = PQresultStatus(result);
if (status != PGRES_COMMAND_OK)
qWarning("%s", PQerrorMessage(connection));
@@ -1003,7 +1006,7 @@ void QPSQLDriverPrivate::detectBackslashEscape()
hasBackslashEscape = true;
} else {
hasBackslashEscape = false;
- PGresult* result = exec(QStringLiteral("SELECT '\\\\' x"));
+ PGresult *result = exec(QStringLiteral("SELECT '\\\\' x"));
int status = PQresultStatus(result);
if (status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK)
if (QString::fromLatin1(PQgetvalue(result, 0, 0)) == QLatin1String("\\"))
@@ -1106,7 +1109,7 @@ static QPSQLDriver::Protocol qFindPSQLVersion(const QString &versionString)
QPSQLDriver::Protocol QPSQLDriverPrivate::getPSQLVersion()
{
QPSQLDriver::Protocol serverVersion = QPSQLDriver::Version6;
- PGresult* result = exec("SELECT version()");
+ PGresult *result = exec("SELECT version()");
int status = PQresultStatus(result);
if (status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK) {
serverVersion = qFindPSQLVersion(
@@ -1212,12 +1215,12 @@ static QString qQuote(QString s)
return s;
}
-bool QPSQLDriver::open(const QString & db,
- const QString & user,
- const QString & password,
- const QString & host,
- int port,
- const QString& connOpts)
+bool QPSQLDriver::open(const QString &db,
+ const QString &user,
+ const QString &password,
+ const QString &host,
+ int port,
+ const QString &connOpts)
{
Q_D(QPSQLDriver);
if (isOpen())
@@ -1246,7 +1249,7 @@ bool QPSQLDriver::open(const QString & db,
setLastError(qMakeError(tr("Unable to connect"), QSqlError::ConnectionError, d));
setOpenError(true);
PQfinish(d->connection);
- d->connection = 0;
+ d->connection = nullptr;
return false;
}
@@ -1270,12 +1273,12 @@ void QPSQLDriver::close()
if (d->sn) {
disconnect(d->sn, SIGNAL(activated(int)), this, SLOT(_q_handleNotification(int)));
delete d->sn;
- d->sn = 0;
+ d->sn = nullptr;
}
if (d->connection)
PQfinish(d->connection);
- d->connection = 0;
+ d->connection = nullptr;
setOpen(false);
setOpenError(false);
}
@@ -1293,7 +1296,7 @@ bool QPSQLDriver::beginTransaction()
qWarning("QPSQLDriver::beginTransaction: Database not open");
return false;
}
- PGresult* res = d->exec("BEGIN");
+ PGresult *res = d->exec("BEGIN");
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) {
setLastError(qMakeError(tr("Could not begin transaction"),
QSqlError::TransactionError, d, res));
@@ -1311,7 +1314,7 @@ bool QPSQLDriver::commitTransaction()
qWarning("QPSQLDriver::commitTransaction: Database not open");
return false;
}
- PGresult* res = d->exec("COMMIT");
+ PGresult *res = d->exec("COMMIT");
bool transaction_failed = false;
@@ -1340,7 +1343,7 @@ bool QPSQLDriver::rollbackTransaction()
qWarning("QPSQLDriver::rollbackTransaction: Database not open");
return false;
}
- PGresult* res = d->exec("ROLLBACK");
+ PGresult *res = d->exec("ROLLBACK");
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) {
setLastError(qMakeError(tr("Could not rollback transaction"),
QSqlError::TransactionError, d, res));
@@ -1383,7 +1386,7 @@ static void qSplitTableName(QString &tablename, QString &schema)
tablename = tablename.mid(dot + 1);
}
-QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const
+QSqlIndex QPSQLDriver::primaryIndex(const QString &tablename) const
{
QSqlIndex idx(tablename);
if (!isOpen())
@@ -1420,7 +1423,7 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const
return idx;
}
-QSqlRecord QPSQLDriver::record(const QString& tablename) const
+QSqlRecord QPSQLDriver::record(const QString &tablename) const
{
QSqlRecord info;
if (!isOpen())
@@ -1571,7 +1574,7 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const
QString QPSQLDriver::escapeIdentifier(const QString &identifier, IdentifierType) const
{
QString res = identifier;
- if(!identifier.isEmpty() && !identifier.startsWith(QLatin1Char('"')) && !identifier.endsWith(QLatin1Char('"')) ) {
+ if (!identifier.isEmpty() && !identifier.startsWith(QLatin1Char('"')) && !identifier.endsWith(QLatin1Char('"')) ) {
res.replace(QLatin1Char('"'), QLatin1String("\"\""));
res.prepend(QLatin1Char('"')).append(QLatin1Char('"'));
res.replace(QLatin1Char('.'), QLatin1String("\".\""));
@@ -1660,7 +1663,7 @@ bool QPSQLDriver::unsubscribeFromNotification(const QString &name)
if (d->seid.isEmpty()) {
disconnect(d->sn, SIGNAL(activated(int)), this, SLOT(_q_handleNotification(int)));
delete d->sn;
- d->sn = 0;
+ d->sn = nullptr;
}
return true;
@@ -1678,8 +1681,8 @@ void QPSQLDriver::_q_handleNotification(int)
d->pendingNotifyCheck = false;
PQconsumeInput(d->connection);
- PGnotify *notify = 0;
- while((notify = PQnotifies(d->connection)) != 0) {
+ PGnotify *notify = nullptr;
+ while ((notify = PQnotifies(d->connection)) != nullptr) {
QString name(QLatin1String(notify->relname));
if (d->seid.contains(name)) {
QString payload;
diff --git a/src/plugins/sqldrivers/psql/qsql_psql_p.h b/src/plugins/sqldrivers/psql/qsql_psql_p.h
index 4f372346c6..99e0b5f60f 100644
--- a/src/plugins/sqldrivers/psql/qsql_psql_p.h
+++ b/src/plugins/sqldrivers/psql/qsql_psql_p.h
@@ -100,18 +100,18 @@ public:
explicit QPSQLDriver(PGconn *conn, QObject *parent = nullptr);
~QPSQLDriver();
bool hasFeature(DriverFeature f) const override;
- bool open(const QString & db,
- const QString & user,
- const QString & password,
- const QString & host,
+ bool open(const QString &db,
+ const QString &user,
+ const QString &password,
+ const QString &host,
int port,
- const QString& connOpts) override;
+ const QString &connOpts) override;
bool isOpen() const override;
void close() override;
QSqlResult *createResult() const override;
QStringList tables(QSql::TableType) const override;
- QSqlIndex primaryIndex(const QString& tablename) const override;
- QSqlRecord record(const QString& tablename) const override;
+ QSqlIndex primaryIndex(const QString &tablename) const override;
+ QSqlRecord record(const QString &tablename) const override;
Protocol protocol() const;
QVariant handle() const override;