Merge remote-tracking branch 'qt/5.12' into 5.13

Conflicts:
	src/gui/configure.json
	src/gui/util/qtexturefilereader.cpp
	src/gui/util/util.pri
	tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp

Change-Id: I2bc4f84705b66099e97330cda68e0b816aceb9cc
This commit is contained in:
Paul Olav Tvete 2019-08-19 14:04:00 +02:00 committed by Liang Qi
commit 2f52e1da0d
15 changed files with 141 additions and 68 deletions

View File

@ -281,6 +281,7 @@ Gui, printing, widget options:
es2 (default on Windows), desktop (default on Unix),
dynamic (Windows only)
-opengles3 ........... Enable OpenGL ES 3.x support instead of ES 2.x [auto]
-egl ................. Enable EGL support [auto]
-angle ............... Use bundled ANGLE to support OpenGL ES 2.0 [auto]
(Windows only)
-combined-angle-lib .. Merge LibEGL and LibGLESv2 into LibANGLE (Windows only)

View File

@ -242,6 +242,39 @@ static int doLink(int argc, char **argv)
#endif
static bool setFilePermissions(QFile &file, QFileDevice::Permissions permissions)
{
if (file.setPermissions(permissions))
return true;
fprintf(stderr, "Error setting permissions on %s: %s\n",
qPrintable(file.fileName()), qPrintable(file.errorString()));
return false;
}
static bool copyFileTimes(QFile &targetFile, const QString &sourceFilePath,
bool mustEnsureWritability, QString *errorString)
{
#ifdef Q_OS_WIN
bool mustRestorePermissions = false;
QFileDevice::Permissions targetPermissions;
if (mustEnsureWritability) {
targetPermissions = targetFile.permissions();
if (!targetPermissions.testFlag(QFileDevice::WriteUser)) {
mustRestorePermissions = true;
if (!setFilePermissions(targetFile, targetPermissions | QFileDevice::WriteUser))
return false;
}
}
#endif
if (!IoUtils::touchFile(targetFile.fileName(), sourceFilePath, errorString))
return false;
#ifdef Q_OS_WIN
if (mustRestorePermissions && !setFilePermissions(targetFile, targetPermissions))
return false;
#endif
return true;
}
static int installFile(const QString &source, const QString &target, bool exe = false,
bool preservePermissions = false)
{
@ -270,18 +303,15 @@ static int installFile(const QString &source, const QString &target, bool exe =
targetPermissions |= QFileDevice::ExeOwner | QFileDevice::ExeUser |
QFileDevice::ExeGroup | QFileDevice::ExeOther;
}
if (!targetFile.setPermissions(targetPermissions)) {
fprintf(stderr, "Error setting permissions on %s: %s\n",
qPrintable(target), qPrintable(targetFile.errorString()));
if (!setFilePermissions(targetFile, targetPermissions))
return 3;
}
// Copy file times
QString error;
if (!IoUtils::touchFile(target, sourceFile.fileName(), &error)) {
if (!copyFileTimes(targetFile, sourceFile.fileName(), preservePermissions, &error)) {
fprintf(stderr, "%s", qPrintable(error));
return 3;
}
return 0;
}

View File

@ -820,7 +820,7 @@
},
"datestring": {
"label": "QDate/QTime/QDateTime",
"purpose": "Provides convertion between dates and strings.",
"purpose": "Provides conversion between dates and strings.",
"section": "Data structures",
"condition": "features.textdate",
"output": [ "publicFeature", "feature" ]

View File

@ -109,12 +109,16 @@ QDBusServer::QDBusServer(QObject *parent)
*/
QDBusServer::~QDBusServer()
{
QWriteLocker locker(&d->lock);
QMutex *managerMutex = nullptr;
if (QDBusConnectionManager::instance())
managerMutex = &QDBusConnectionManager::instance()->mutex;
QMutexLocker locker(managerMutex);
QWriteLocker writeLocker(&d->lock);
if (QDBusConnectionManager::instance()) {
QMutexLocker locker(&QDBusConnectionManager::instance()->mutex);
for (const QString &name : qAsConst(d->serverConnectionNames))
QDBusConnectionManager::instance()->removeConnection(name);
d->serverConnectionNames.clear();
locker.unlock();
}
d->serverObject = nullptr;
d->ref.store(0);

View File

@ -263,6 +263,7 @@ public:
bool QOpenGLProgramBinaryCache::load(const QByteArray &cacheKey, uint programId)
{
QMutexLocker lock(&m_mutex);
if (m_memCache.contains(cacheKey)) {
const MemCacheEntry *e = m_memCache[cacheKey];
return setProgramBinary(programId, e->format, e->blob.constData(), e->blob.size());
@ -401,6 +402,7 @@ void QOpenGLProgramBinaryCache::save(const QByteArray &cacheKey, uint programId)
GLint outSize = 0;
#if defined(QT_OPENGL_ES_2)
if (context->isOpenGLES() && context->format().majorVersion() < 3) {
QMutexLocker lock(&m_mutex);
initializeProgramBinaryOES(context);
getProgramBinaryOES(programId, blobSize, &outSize, &blobFormat, p);
} else

View File

@ -54,6 +54,7 @@
#include <QtGui/qtguiglobal.h>
#include <QtGui/qopenglshaderprogram.h>
#include <QtCore/qcache.h>
#include <QtCore/qmutex.h>
QT_BEGIN_NAMESPACE
@ -99,6 +100,7 @@ private:
void initializeProgramBinaryOES(QOpenGLContext *context);
bool m_programBinaryOESInitialized = false;
#endif
QMutex m_mutex;
};
QT_END_NAMESPACE

View File

@ -122,10 +122,10 @@ void QBezier::addToPolygon(QPolygonF *polygon, qreal bezier_flattening_threshold
int levels[10];
beziers[0] = *this;
levels[0] = 9;
QBezier *b = beziers;
int *lvl = levels;
int top = 0;
while (b >= beziers) {
while (top >= 0) {
QBezier *b = &beziers[top];
// check if we can pop the top bezier curve from the stack
qreal y4y1 = b->y4 - b->y1;
qreal x4x1 = b->x4 - b->x1;
@ -139,17 +139,15 @@ void QBezier::addToPolygon(QPolygonF *polygon, qreal bezier_flattening_threshold
qAbs(b->x1 - b->x3) + qAbs(b->y1 - b->y3);
l = 1.;
}
if (d < bezier_flattening_threshold*l || *lvl == 0) {
if (d < bezier_flattening_threshold * l || levels[top] == 0) {
// good enough, we pop it off and add the endpoint
polygon->append(QPointF(b->x4, b->y4));
--b;
--lvl;
--top;
} else {
// split, second half of the polygon goes lower into the stack
b->split(b+1, b);
lvl[1] = --lvl[0];
++b;
++lvl;
levels[top + 1] = --levels[top];
++top;
}
}
}
@ -160,10 +158,10 @@ void QBezier::addToPolygon(QDataBuffer<QPointF> &polygon, qreal bezier_flattenin
int levels[10];
beziers[0] = *this;
levels[0] = 9;
QBezier *b = beziers;
int *lvl = levels;
int top = 0;
while (b >= beziers) {
while (top >= 0) {
QBezier *b = &beziers[top];
// check if we can pop the top bezier curve from the stack
qreal y4y1 = b->y4 - b->y1;
qreal x4x1 = b->x4 - b->x1;
@ -177,17 +175,15 @@ void QBezier::addToPolygon(QDataBuffer<QPointF> &polygon, qreal bezier_flattenin
qAbs(b->x1 - b->x3) + qAbs(b->y1 - b->y3);
l = 1.;
}
if (d < bezier_flattening_threshold*l || *lvl == 0) {
if (d < bezier_flattening_threshold * l || levels[top] == 0) {
// good enough, we pop it off and add the endpoint
polygon.add(QPointF(b->x4, b->y4));
--b;
--lvl;
--top;
} else {
// split, second half of the polygon goes lower into the stack
b->split(b+1, b);
lvl[1] = --lvl[0];
++b;
++lvl;
levels[top + 1] = --levels[top];
++top;
}
}
}

View File

@ -157,32 +157,36 @@ SSL* QSslContext::createSsl()
for (int a = 0; a < protocols.count(); ++a) {
if (protocols.at(a).size() > 255) {
qCWarning(lcSsl) << "TLS NPN extension" << protocols.at(a)
<< "is too long and will be truncated to 255 characters.";
protocols[a] = protocols.at(a).left(255);
<< "is too long and will be ignored.";
continue;
} else if (protocols.at(a).isEmpty()) {
continue;
}
m_supportedNPNVersions.append(protocols.at(a).size()).append(protocols.at(a));
}
m_npnContext.data = reinterpret_cast<unsigned char *>(m_supportedNPNVersions.data());
m_npnContext.len = m_supportedNPNVersions.count();
m_npnContext.status = QSslConfiguration::NextProtocolNegotiationNone;
if (m_supportedNPNVersions.size()) {
m_npnContext.data = reinterpret_cast<unsigned char *>(m_supportedNPNVersions.data());
m_npnContext.len = m_supportedNPNVersions.count();
m_npnContext.status = QSslConfiguration::NextProtocolNegotiationNone;
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
if (QSslSocket::sslLibraryVersionNumber() >= 0x10002000L) {
// Callback's type has a parameter 'const unsigned char ** out'
// since it was introduced in 1.0.2. Internally, OpenSSL's own code
// (tests/examples) cast it to unsigned char * (since it's 'out').
// We just re-use our NPN callback and cast here:
typedef int (*alpn_callback_t) (SSL *, const unsigned char **, unsigned char *,
const unsigned char *, unsigned int, void *);
// With ALPN callback is for a server side only, for a client m_npnContext.status
// will stay in NextProtocolNegotiationNone.
q_SSL_CTX_set_alpn_select_cb(ctx, alpn_callback_t(next_proto_cb), &m_npnContext);
// Client:
q_SSL_set_alpn_protos(ssl, m_npnContext.data, m_npnContext.len);
}
if (QSslSocket::sslLibraryVersionNumber() >= 0x10002000L) {
// Callback's type has a parameter 'const unsigned char ** out'
// since it was introduced in 1.0.2. Internally, OpenSSL's own code
// (tests/examples) cast it to unsigned char * (since it's 'out').
// We just re-use our NPN callback and cast here:
typedef int (*alpn_callback_t) (SSL *, const unsigned char **, unsigned char *,
const unsigned char *, unsigned int, void *);
// With ALPN callback is for a server side only, for a client m_npnContext.status
// will stay in NextProtocolNegotiationNone.
q_SSL_CTX_set_alpn_select_cb(ctx, alpn_callback_t(next_proto_cb), &m_npnContext);
// Client:
q_SSL_set_alpn_protos(ssl, m_npnContext.data, m_npnContext.len);
}
#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L ...
// And in case our peer does not support ALPN, but supports NPN:
q_SSL_CTX_set_next_proto_select_cb(ctx, next_proto_cb, &m_npnContext);
// And in case our peer does not support ALPN, but supports NPN:
q_SSL_CTX_set_next_proto_select_cb(ctx, next_proto_cb, &m_npnContext);
}
}
#endif // OPENSSL_VERSION_NUMBER >= 0x1000100fL ...

View File

@ -928,6 +928,13 @@ bool QSslSocketBackendPrivate::initSslContext()
QCFType<CFMutableArrayRef> cfNames(CFArrayCreateMutable(nullptr, 0, &kCFTypeArrayCallBacks));
if (cfNames) {
for (const QByteArray &name : protocolNames) {
if (name.size() > 255) {
qCWarning(lcSsl) << "TLS ALPN extension" << name
<< "is too long and will be ignored.";
continue;
} else if (name.isEmpty()) {
continue;
}
QCFString cfName(QString::fromLatin1(name).toCFString());
CFArrayAppendValue(cfNames, cfName);
}

View File

@ -342,10 +342,14 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
}
qCDebug(qLcKmsDebug) << "Physical size is" << physSize << "mm" << "for output" << connectorName;
const QByteArray formatStr = userConnectorConfig.value(QStringLiteral("format"), QStringLiteral("xrgb8888"))
const QByteArray formatStr = userConnectorConfig.value(QStringLiteral("format"), QString())
.toByteArray().toLower();
uint32_t drmFormat;
if (formatStr == "xrgb8888") {
bool drmFormatExplicit = true;
if (formatStr.isEmpty()) {
drmFormat = DRM_FORMAT_XRGB8888;
drmFormatExplicit = false;
} else if (formatStr == "xrgb8888") {
drmFormat = DRM_FORMAT_XRGB8888;
} else if (formatStr == "xbgr8888") {
drmFormat = DRM_FORMAT_XBGR8888;
@ -368,7 +372,10 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
} else {
qWarning("Invalid pixel format \"%s\" for output %s", formatStr.constData(), connectorName.constData());
drmFormat = DRM_FORMAT_XRGB8888;
drmFormatExplicit = false;
}
qCDebug(qLcKmsDebug) << "Format is" << hex << drmFormat << dec << "requested_by_user =" << drmFormatExplicit
<< "for output" << connectorName;
const QString cloneSource = userConnectorConfig.value(QStringLiteral("clones")).toString();
if (!cloneSource.isEmpty())
@ -411,6 +418,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
output.forced_plane_id = 0;
output.forced_plane_set = false;
output.drm_format = drmFormat;
output.drm_format_requested_by_user = drmFormatExplicit;
output.clone_source = cloneSource;
output.size = framebufferSize;

View File

@ -201,6 +201,7 @@ struct QKmsOutput
uint32_t forced_plane_id = 0;
bool forced_plane_set = false;
uint32_t drm_format = DRM_FORMAT_XRGB8888;
bool drm_format_requested_by_user = false;
QString clone_source;
QVector<QKmsPlane> available_planes;
struct QKmsPlane *eglfs_plane = nullptr;

View File

@ -21,8 +21,6 @@ SOURCES += main.mm \
qcocoamenuloader.mm \
qcocoahelpers.mm \
qmultitouch_mac.mm \
qcocoaaccessibilityelement.mm \
qcocoaaccessibility.mm \
qcocoacursor.mm \
qcocoaclipboard.mm \
qcocoadrag.mm \
@ -57,8 +55,6 @@ HEADERS += qcocoaintegration.h \
qcocoamenuloader.h \
qcocoahelpers.h \
qmultitouch_mac_p.h \
qcocoaaccessibilityelement.h \
qcocoaaccessibility.h \
qcocoacursor.h \
qcocoaclipboard.h \
qcocoadrag.h \
@ -83,13 +79,21 @@ qtConfig(vulkan) {
HEADERS += qcocoavulkaninstance.h
}
qtConfig(accessibility) {
QT += accessibility_support-private
SOURCES += qcocoaaccessibilityelement.mm \
qcocoaaccessibility.mm
HEADERS += qcocoaaccessibilityelement.h \
qcocoaaccessibility.h
}
RESOURCES += qcocoaresources.qrc
LIBS += -framework AppKit -framework CoreServices -framework Carbon -framework IOKit -framework QuartzCore -framework CoreVideo -framework Metal -framework IOSurface -lcups
QT += \
core-private gui-private \
accessibility_support-private clipboard_support-private theme_support-private \
clipboard_support-private theme_support-private \
fontdatabase_support-private graphics_support-private
qtConfig(vulkan): QT += vulkan_support-private

View File

@ -155,20 +155,33 @@ gbm_surface *QEglFSKmsGbmScreen::createSurface(EGLConfig eglConfig)
qCDebug(qLcEglfsKmsDebug, "Creating gbm_surface for screen %s", qPrintable(name()));
const auto gbmDevice = static_cast<QEglFSKmsGbmDevice *>(device())->gbmDevice();
EGLint native_format = -1;
EGLBoolean success = eglGetConfigAttrib(display(), eglConfig, EGL_NATIVE_VISUAL_ID, &native_format);
qCDebug(qLcEglfsKmsDebug) << "Got native format" << hex << native_format << dec << "from eglGetConfigAttrib() with return code" << bool(success);
// If there was no format override given in the config file,
// query the native (here, gbm) format from the EGL config.
const bool queryFromEgl = !m_output.drm_format_requested_by_user;
if (queryFromEgl) {
EGLint native_format = -1;
EGLBoolean success = eglGetConfigAttrib(display(), eglConfig, EGL_NATIVE_VISUAL_ID, &native_format);
qCDebug(qLcEglfsKmsDebug) << "Got native format" << hex << native_format << dec
<< "from eglGetConfigAttrib() with return code" << bool(success);
if (success)
m_gbm_surface = gbm_surface_create(gbmDevice,
rawGeometry().width(),
rawGeometry().height(),
native_format,
GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
if (success) {
m_gbm_surface = gbm_surface_create(gbmDevice,
rawGeometry().width(),
rawGeometry().height(),
native_format,
GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
if (m_gbm_surface)
m_output.drm_format = gbmFormatToDrmFormat(native_format);
}
}
if (!m_gbm_surface) { // fallback for older drivers
// Fallback for older drivers, and when "format" is explicitly specified
// in the output config. (not guaranteed that the requested format works
// of course, but do what we are told to)
if (!m_gbm_surface) {
uint32_t gbmFormat = drmFormatToGbmFormat(m_output.drm_format);
qCDebug(qLcEglfsKmsDebug, "Could not create surface with EGL_NATIVE_VISUAL_ID, falling back to format %x", gbmFormat);
if (queryFromEgl)
qCDebug(qLcEglfsKmsDebug, "Could not create surface with EGL_NATIVE_VISUAL_ID, falling back to format %x", gbmFormat);
m_gbm_surface = gbm_surface_create(gbmDevice,
rawGeometry().width(),
rawGeometry().height(),

View File

@ -679,9 +679,6 @@ void tst_qmake::qinstall()
QFile srcfile(src.filePath("main.cpp"));
QVERIFY(srcfile.setPermissions(srcfile.permissions() & ~writeFlags));
QDir dst("zort");
#ifdef Q_OS_WIN
QEXPECT_FAIL("", "QTBUG-77299", Abort);
#endif
QVERIFY(qinstall(src.absolutePath(), dst.absolutePath()));
QCOMPARE(src.entryList(QDir::Files, QDir::Name), dst.entryList(QDir::Files, QDir::Name));
}

View File

@ -4842,6 +4842,7 @@ void tst_QLineEdit::inputRejected()
QCOMPARE(spyInputRejected.count(), 0);
QTest::keyClicks(testWidget, "fgh");
QCOMPARE(spyInputRejected.count(), 3);
#if QT_CONFIG(clipboard)
testWidget->clear();
spyInputRejected.clear();
QApplication::clipboard()->setText("ijklmno");
@ -4849,6 +4850,7 @@ void tst_QLineEdit::inputRejected()
// The first 5 characters are accepted, but
// the last 2 are not.
QCOMPARE(spyInputRejected.count(), 1);
#endif
testWidget->setMaxLength(INT_MAX);
testWidget->clear();
@ -4859,11 +4861,13 @@ void tst_QLineEdit::inputRejected()
QCOMPARE(spyInputRejected.count(), 0);
QTest::keyClicks(testWidget, "a#");
QCOMPARE(spyInputRejected.count(), 2);
#if QT_CONFIG(clipboard)
testWidget->clear();
spyInputRejected.clear();
QApplication::clipboard()->setText("a#");
testWidget->paste();
QCOMPARE(spyInputRejected.count(), 1);
#endif
testWidget->clear();
testWidget->setValidator(0);