Merge remote-tracking branch 'origin/5.11' into 5.12

Change-Id: Ic4c1a8041dcfd143861c39e0014fbdaaa3fb25c6
This commit is contained in:
Qt Forward Merge Bot 2018-09-14 01:00:06 +02:00
commit 42f84de26a
6 changed files with 55 additions and 16 deletions

View File

@ -39,7 +39,7 @@
The heavy computation here is the Mandelbrot set, probably the The heavy computation here is the Mandelbrot set, probably the
world's most famous fractal. These days, while sophisticated world's most famous fractal. These days, while sophisticated
programs such as \l{http://xaos.sourceforge.net/}{XaoS} that provide real-time zooming in the programs such as \l{http://matek.hu/xaos/doku.php}{XaoS} that provide real-time zooming in the
Mandelbrot set, the standard Mandelbrot algorithm is just slow Mandelbrot set, the standard Mandelbrot algorithm is just slow
enough for our purposes. enough for our purposes.
@ -201,7 +201,7 @@
\snippet threads/mandelbrot/renderthread.cpp 9 \snippet threads/mandelbrot/renderthread.cpp 9
Once we're done with all the iterations, we call Once we're done with all the iterations, we call
QWaitCondition::wait() to put the thread to sleep by calling, QWaitCondition::wait() to put the thread to sleep,
unless \c restart is \c true. There's no use in keeping a worker unless \c restart is \c true. There's no use in keeping a worker
thread looping indefinitely while there's nothing to do. thread looping indefinitely while there's nothing to do.
@ -232,7 +232,7 @@
\snippet threads/mandelbrot/mandelbrotwidget.cpp 0 \snippet threads/mandelbrot/mandelbrotwidget.cpp 0
The implementation starts with a few contants that we'll need The implementation starts with a few constants that we'll need
later on. later on.
\snippet threads/mandelbrot/mandelbrotwidget.cpp 1 \snippet threads/mandelbrot/mandelbrotwidget.cpp 1
@ -256,15 +256,15 @@
slot later on. Qt knows how to take of copy of many C++ and Qt slot later on. Qt knows how to take of copy of many C++ and Qt
types, but QImage isn't one of them. We must therefore call the types, but QImage isn't one of them. We must therefore call the
template function qRegisterMetaType() before we can use QImage template function qRegisterMetaType() before we can use QImage
as parameter in queued connections. as a parameter in queued connections.
\snippet threads/mandelbrot/mandelbrotwidget.cpp 2 \snippet threads/mandelbrot/mandelbrotwidget.cpp 2
\snippet threads/mandelbrot/mandelbrotwidget.cpp 3 \snippet threads/mandelbrot/mandelbrotwidget.cpp 3
\snippet threads/mandelbrot/mandelbrotwidget.cpp 4 \snippet threads/mandelbrot/mandelbrotwidget.cpp 4
In \l{QWidget::paintEvent()}{paintEvent()}, we start by filling In \l{QWidget::paintEvent()}{paintEvent()}, we start by filling
the background with black. If we have nothing yet to paint (\c the background with black. If we have nothing to paint yet (\c
pixmap is null), we print a message on the widget asking the user pixmap is null), we display a message on the widget asking the user
to be patient and return from the function immediately. to be patient and return from the function immediately.
\snippet threads/mandelbrot/mandelbrotwidget.cpp 5 \snippet threads/mandelbrot/mandelbrotwidget.cpp 5
@ -293,7 +293,7 @@
Notice that we rely on \c resizeEvent() being automatically Notice that we rely on \c resizeEvent() being automatically
called by Qt when the widget is shown the first time to generate called by Qt when the widget is shown the first time to generate
the image the very first time. the initial image.
\snippet threads/mandelbrot/mandelbrotwidget.cpp 11 \snippet threads/mandelbrot/mandelbrotwidget.cpp 11
@ -307,7 +307,7 @@
control the zoom level. QWheelEvent::delta() returns the angle of control the zoom level. QWheelEvent::delta() returns the angle of
the wheel mouse movement, in eights of a degree. For most mice, the wheel mouse movement, in eights of a degree. For most mice,
one wheel step corresponds to 15 degrees. We find out how many one wheel step corresponds to 15 degrees. We find out how many
mouse steps we have and determine the zoom factor in consequence. mouse steps we have and determine the resulting zoom factor.
For example, if we have two wheel steps in the positive direction For example, if we have two wheel steps in the positive direction
(i.e., +30 degrees), the zoom factor becomes \c ZoomInFactor (i.e., +30 degrees), the zoom factor becomes \c ZoomInFactor
to the second power, i.e. 0.8 * 0.8 = 0.64. to the second power, i.e. 0.8 * 0.8 = 0.64.

View File

@ -188,6 +188,8 @@ static bool read_dib_infoheader(QDataStream &s, BMP_INFOHDR &bi)
if (!(comp == BMP_RGB || (nbits == 4 && comp == BMP_RLE4) || if (!(comp == BMP_RGB || (nbits == 4 && comp == BMP_RLE4) ||
(nbits == 8 && comp == BMP_RLE8) || ((nbits == 16 || nbits == 32) && comp == BMP_BITFIELDS))) (nbits == 8 && comp == BMP_RLE8) || ((nbits == 16 || nbits == 32) && comp == BMP_BITFIELDS)))
return false; // weird compression type return false; // weird compression type
if (bi.biWidth < 0 || quint64(bi.biWidth) * qAbs(bi.biHeight) > 16384 * 16384)
return false;
return true; return true;
} }

View File

@ -58,6 +58,7 @@
#include <private/qhighdpiscaling_p.h> #include <private/qhighdpiscaling_p.h>
#include <QTextCharFormat> #include <QTextCharFormat>
#include <QTextBoundaryFinder>
#include <QDebug> #include <QDebug>
@ -1020,8 +1021,19 @@ jint QAndroidInputContext::getCursorCapsMode(jint /*reqModes*/)
return res; return res;
const uint qtInputMethodHints = query->value(Qt::ImHints).toUInt(); const uint qtInputMethodHints = query->value(Qt::ImHints).toUInt();
const int localPos = query->value(Qt::ImCursorPosition).toInt();
if (!(qtInputMethodHints & Qt::ImhLowercaseOnly) && !(qtInputMethodHints & Qt::ImhNoAutoUppercase)) bool atWordBoundary = (localPos == 0);
if (!atWordBoundary) {
QString surroundingText = query->value(Qt::ImSurroundingText).toString();
surroundingText.truncate(localPos);
// Add a character to see if it is at the end of the sentence or not
QTextBoundaryFinder finder(QTextBoundaryFinder::Sentence, surroundingText + QLatin1Char('A'));
finder.setPosition(localPos);
if (finder.isAtBoundary())
atWordBoundary = finder.isAtBoundary();
}
if (atWordBoundary && !(qtInputMethodHints & Qt::ImhLowercaseOnly) && !(qtInputMethodHints & Qt::ImhNoAutoUppercase))
res |= CAP_MODE_SENTENCES; res |= CAP_MODE_SENTENCES;
if (qtInputMethodHints & Qt::ImhUppercaseOnly) if (qtInputMethodHints & Qt::ImhUppercaseOnly)

View File

@ -414,6 +414,8 @@ public:
bool imageNeedsEndianSwap() const bool imageNeedsEndianSwap() const
{ {
if (!hasShm())
return false; // The non-Shm path does its own swapping
#if Q_BYTE_ORDER == Q_BIG_ENDIAN #if Q_BYTE_ORDER == Q_BIG_ENDIAN
return m_setup->image_byte_order != XCB_IMAGE_ORDER_MSB_FIRST; return m_setup->image_byte_order != XCB_IMAGE_ORDER_MSB_FIRST;
#else #else

View File

@ -106,7 +106,7 @@ static QVariant::Type qGetColumnType(const QString &tpName)
} }
static QSqlError qMakeError(sqlite3 *access, const QString &descr, QSqlError::ErrorType type, static QSqlError qMakeError(sqlite3 *access, const QString &descr, QSqlError::ErrorType type,
int errorCode = -1) int errorCode)
{ {
return QSqlError(descr, return QSqlError(descr,
QString(reinterpret_cast<const QChar *>(sqlite3_errmsg16(access))), QString(reinterpret_cast<const QChar *>(sqlite3_errmsg16(access))),
@ -772,7 +772,9 @@ bool QSQLiteDriver::open(const QString & db, const QString &, const QString &, c
openMode |= SQLITE_OPEN_NOMUTEX; openMode |= SQLITE_OPEN_NOMUTEX;
if (sqlite3_open_v2(db.toUtf8().constData(), &d->access, openMode, NULL) == SQLITE_OK) { const int res = sqlite3_open_v2(db.toUtf8().constData(), &d->access, openMode, NULL);
if (res == SQLITE_OK) {
sqlite3_busy_timeout(d->access, timeOut); sqlite3_busy_timeout(d->access, timeOut);
setOpen(true); setOpen(true);
setOpenError(false); setOpenError(false);
@ -785,14 +787,15 @@ bool QSQLiteDriver::open(const QString & db, const QString &, const QString &, c
#endif #endif
return true; return true;
} else { } else {
setLastError(qMakeError(d->access, tr("Error opening database"),
QSqlError::ConnectionError, res));
setOpenError(true);
if (d->access) { if (d->access) {
sqlite3_close(d->access); sqlite3_close(d->access);
d->access = 0; d->access = 0;
} }
setLastError(qMakeError(d->access, tr("Error opening database"),
QSqlError::ConnectionError));
setOpenError(true);
return false; return false;
} }
} }
@ -809,8 +812,10 @@ void QSQLiteDriver::close()
sqlite3_update_hook(d->access, NULL, NULL); sqlite3_update_hook(d->access, NULL, NULL);
} }
if (sqlite3_close(d->access) != SQLITE_OK) const int res = sqlite3_close(d->access);
setLastError(qMakeError(d->access, tr("Error closing database"), QSqlError::ConnectionError));
if (res != SQLITE_OK)
setLastError(qMakeError(d->access, tr("Error closing database"), QSqlError::ConnectionError, res));
d->access = 0; d->access = 0;
setOpen(false); setOpen(false);
setOpenError(false); setOpenError(false);

View File

@ -197,6 +197,8 @@ private slots:
void sqlite_enableRegexp_data() { generic_data("QSQLITE"); } void sqlite_enableRegexp_data() { generic_data("QSQLITE"); }
void sqlite_enableRegexp(); void sqlite_enableRegexp();
void sqlite_openError();
private: private:
void createTestTables(QSqlDatabase db); void createTestTables(QSqlDatabase db);
void dropTestTables(QSqlDatabase db); void dropTestTables(QSqlDatabase db);
@ -2332,6 +2334,22 @@ void tst_QSqlDatabase::sqlite_enableRegexp()
QFAIL_SQL(q, next()); QFAIL_SQL(q, next());
} }
void tst_QSqlDatabase::sqlite_openError()
{
// see QTBUG-70506
if (!QSqlDatabase::drivers().contains("QSQLITE"))
QSKIP("Database driver QSQLITE not available");
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "sqlite_openError");
db.setDatabaseName("/doesnotexist/foo.sqlite");
QVERIFY(db.isValid());
QVERIFY(!db.open());
QSqlError error = db.lastError();
QCOMPARE(error.nativeErrorCode(), "14"); // SQLITE_CANTOPEN
QCOMPARE(error.databaseText(), "unable to open database file");
}
void tst_QSqlDatabase::cloneDatabase() void tst_QSqlDatabase::cloneDatabase()
{ {
QFETCH(QString, dbName); QFETCH(QString, dbName);