Merge 5.12 into 5.12.5

Change-Id: I188926022fa4afc0db2dadc6dc214ea5173b17ea
This commit is contained in:
Paul Wicking 2019-08-23 08:42:17 +02:00
commit 304587e3db
15 changed files with 94 additions and 56 deletions

View File

@ -270,7 +270,7 @@ xcode_product_bundle_identifier_setting.value = "$${xcode_product_bundle_identif
QMAKE_MAC_XCODE_SETTINGS += xcode_product_bundle_identifier_setting
!macx-xcode {
generate_xcode_project.commands = @$(QMAKE) -spec macx-xcode $(EXPORT__PRO_FILE_) $$QMAKE_ARGS
generate_xcode_project.commands = @$(QMAKE) -spec macx-xcode \"$(EXPORT__PRO_FILE_)\" $$QMAKE_ARGS
generate_xcode_project.target = xcodeproj
QMAKE_EXTRA_VARIABLES += _PRO_FILE_
QMAKE_EXTRA_TARGETS += generate_xcode_project

View File

@ -1923,12 +1923,14 @@ void qErrnoWarning(const char *msg, ...)
{
// qt_error_string() will allocate anyway, so we don't have
// to be careful here (like we do in plain qWarning())
QString error_string = qt_error_string(-1); // before vasprintf changes errno/GetLastError()
va_list ap;
va_start(ap, msg);
QString buf = QString::vasprintf(msg, ap);
va_end(ap);
buf += QLatin1String(" (") + qt_error_string(-1) + QLatin1Char(')');
buf += QLatin1String(" (") + error_string + QLatin1Char(')');
QMessageLogContext context;
qt_message_output(QtCriticalMsg, context, buf);
}

View File

@ -112,6 +112,13 @@ QT_BEGIN_NAMESPACE
are returned by classInfo(), and you can search for pairs with
indexOfClassInfo().
\note Operations that use the meta object system are generally thread-
safe, as QMetaObjects are typically static read-only instances
generated at compile time. However, if meta objects are dynamically
modified by the application (for instance, when using QQmlPropertyMap),
then the application has to explicitly synchronize access to the
respective meta object.
\sa QMetaClassInfo, QMetaEnum, QMetaMethod, QMetaProperty, QMetaType,
{Meta-Object System}
*/

View File

@ -264,10 +264,8 @@ public:
bool QOpenGLProgramBinaryCache::load(const QByteArray &cacheKey, uint programId)
{
QMutexLocker lock(&m_mutex);
if (m_memCache.contains(cacheKey)) {
const MemCacheEntry *e = m_memCache[cacheKey];
if (const MemCacheEntry *e = m_memCache.object(cacheKey))
return setProgramBinary(programId, e->format, e->blob.constData(), e->blob.size());
}
QByteArray buf;
const QString fn = cacheFileName(cacheKey);

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

@ -103,17 +103,20 @@ CONFIG += no_app_extension_api_only
qtHaveModule(widgets) {
QT_FOR_CONFIG += widgets
SOURCES += \
qpaintengine_mac.mm \
qprintengine_mac.mm \
qcocoaprintersupport.mm \
qcocoaprintdevice.mm \
SOURCES += qpaintengine_mac.mm
HEADERS += qpaintengine_mac_p.h
HEADERS += \
qpaintengine_mac_p.h \
qprintengine_mac_p.h \
qcocoaprintersupport.h \
qcocoaprintdevice.h \
qtHaveModule(printsupport) {
QT += printsupport-private
SOURCES += \
qprintengine_mac.mm \
qcocoaprintersupport.mm \
qcocoaprintdevice.mm
HEADERS += \
qcocoaprintersupport.h \
qcocoaprintdevice.h \
qprintengine_mac_p.h
}
qtConfig(colordialog) {
SOURCES += qcocoacolordialoghelper.mm
@ -130,7 +133,7 @@ qtHaveModule(widgets) {
HEADERS += qcocoafontdialoghelper.h
}
QT += widgets-private printsupport-private
QT += widgets-private
}
OTHER_FILES += cocoa.json

View File

@ -54,6 +54,8 @@ class QCocoaBackingStore : public QRasterBackingStore
protected:
QCocoaBackingStore(QWindow *window);
QCFType<CGColorSpaceRef> colorSpace() const;
QMacNotificationObserver m_backingPropertiesObserver;
virtual void backingPropertiesChanged() = 0;
};
class QNSWindowBackingStore : public QCocoaBackingStore
@ -69,6 +71,7 @@ private:
bool windowHasUnifiedToolbar() const;
QImage::Format format() const override;
void redrawRoundedBottomCorners(CGRect) const;
void backingPropertiesChanged() override;
};
class QCALayerBackingStore : public QCocoaBackingStore
@ -115,6 +118,8 @@ private:
bool recreateBackBufferIfNeeded();
bool prepareForFlush();
void backingPropertiesChanged() override;
std::list<std::unique_ptr<GraphicsBuffer>> m_buffers;
};

View File

@ -51,6 +51,17 @@ QT_BEGIN_NAMESPACE
QCocoaBackingStore::QCocoaBackingStore(QWindow *window)
: QRasterBackingStore(window)
{
// Ideally this would be plumbed from the platform layer to QtGui, and
// the QBackingStore would be recreated, but we don't have that code yet,
// so at least make sure we invalidate our backingstore when the backing
// properties (color space e.g.) are changed.
NSView *view = static_cast<QCocoaWindow *>(window->handle())->view();
m_backingPropertiesObserver = QMacNotificationObserver(view.window,
NSWindowDidChangeBackingPropertiesNotification, [this]() {
qCDebug(lcQpaBackingStore) << "Backing properties for"
<< this->window() << "did change";
backingPropertiesChanged();
});
}
QCFType<CGColorSpaceRef> QCocoaBackingStore::colorSpace() const
@ -212,9 +223,6 @@ void QNSWindowBackingStore::flush(QWindow *window, const QRegion &region, const
CGRect viewRect = viewLocalRect.toCGRect();
if (windowHasUnifiedToolbar())
NSDrawWindowBackground(viewRect);
[backingStoreImage drawInRect:viewRect fromRect:backingStoreRect.toCGRect()
operation:compositingOperation fraction:1.0 respectFlipped:YES hints:nil];
@ -302,6 +310,11 @@ void QNSWindowBackingStore::redrawRoundedBottomCorners(CGRect windowRect) const
#endif
}
void QNSWindowBackingStore::backingPropertiesChanged()
{
m_image = QImage();
}
// ----------------------------------------------------------------------------
// https://stackoverflow.com/a/52722575/2761869
@ -577,6 +590,12 @@ QImage QCALayerBackingStore::toImage() const
return imageCopy;
}
void QCALayerBackingStore::backingPropertiesChanged()
{
m_buffers.clear();
m_buffers.resize(1);
}
QPlatformGraphicsBuffer *QCALayerBackingStore::graphicsBuffer() const
{
return m_buffers.back().get();

View File

@ -59,7 +59,7 @@
#include "qguiapplication.h"
#include <qdebug.h>
#ifndef QT_NO_WIDGETS
#if !defined(QT_NO_WIDGETS) && defined(QT_PRINTSUPPORT_LIB)
#include "qcocoaprintersupport.h"
#include "qprintengine_mac_p.h"
#include <qpa/qplatformprintersupport.h>
@ -153,24 +153,24 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInter
QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport()
{
#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER)
#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER) && defined(QT_PRINTSUPPORT_LIB)
return new QCocoaPrinterSupport();
#else
qFatal("Printing is not supported when Qt is configured with -no-widgets");
qFatal("Printing is not supported when Qt is configured with -no-widgets or -no-feature-printer");
return nullptr;
#endif
}
void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine)
{
#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER)
#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER) && defined(QT_PRINTSUPPORT_LIB)
QMacPrintEnginePrivate *macPrintEnginePriv = static_cast<QMacPrintEngine *>(printEngine)->d_func();
if (macPrintEnginePriv->state == QPrinter::Idle && !macPrintEnginePriv->isPrintSessionInitialized())
macPrintEnginePriv->initialize();
return macPrintEnginePriv->printInfo;
#else
Q_UNUSED(printEngine);
qFatal("Printing is not supported when Qt is configured with -no-widgets");
qFatal("Printing is not supported when Qt is configured with -no-widgets or -no-feature-printer");
return nullptr;
#endif
}

View File

@ -161,6 +161,7 @@ public:
Q_NOTIFICATION_HANDLER(NSWindowDidOrderOffScreenNotification) void windowDidOrderOffScreen();
Q_NOTIFICATION_HANDLER(NSWindowDidChangeOcclusionStateNotification) void windowDidChangeOcclusionState();
Q_NOTIFICATION_HANDLER(NSWindowDidChangeScreenNotification) void windowDidChangeScreen();
Q_NOTIFICATION_HANDLER(NSWindowDidChangeBackingPropertiesNotification) void windowDidChangeBackingProperties();
Q_NOTIFICATION_HANDLER(NSWindowWillCloseNotification) void windowWillClose();
bool windowShouldClose();

View File

@ -1261,6 +1261,17 @@ void QCocoaWindow::windowDidChangeScreen()
currentScreen->requestUpdate();
}
}
/*
The window's backing scale factor or color space has changed.
*/
void QCocoaWindow::windowDidChangeBackingProperties()
{
// Ideally we would plumb this thought QPA in a way that lets clients
// invalidate their own caches, and recreate QBackingStore. For now we
// trigger an expose, and let QCocoaBackingStore deal with its own
// buffer invalidation.
[m_view setNeedsDisplay:YES];
}
void QCocoaWindow::windowWillClose()
{

View File

@ -389,14 +389,16 @@
}
// Close the popups if the click was outside.
if (!inside) {
bool selfClosed = false;
Qt::WindowType type = QCocoaIntegration::instance()->activePopupWindow()->window()->type();
while (QCocoaWindow *popup = QCocoaIntegration::instance()->popPopupWindow()) {
selfClosed = self == popup->view();
QWindowSystemInterface::handleCloseEvent(popup->window());
QWindowSystemInterface::flushWindowSystemEvents();
}
// Consume the mouse event when closing the popup, except for tool tips
// were it's expected that the event is processed normally.
if (type != Qt::ToolTip)
if (type != Qt::ToolTip || selfClosed)
return;
}
}

View File

@ -253,20 +253,10 @@ static bool isMouseEvent(NSEvent *ev)
return m_platformWindow ? m_platformWindow->isOpaque() : [super isOpaque];
}
/*!
Borderless windows need a transparent background
Technically windows with NSWindowStyleMaskTexturedBackground
(such as windows with unified toolbars) need to draw the textured
background of the NSWindow, and can't have a transparent
background, but as NSWindowStyleMaskBorderless is 0, you can't
have a window with NSWindowStyleMaskTexturedBackground that is
also borderless.
*/
- (NSColor *)backgroundColor
{
return self.styleMask == NSWindowStyleMaskBorderless
? [NSColor clearColor] : [super backgroundColor];
return self.styleMask & NSWindowStyleMaskTexturedBackground ?
[super backgroundColor] : [NSColor clearColor];
}
- (void)sendEvent:(NSEvent*)theEvent

View File

@ -38,14 +38,18 @@
****************************************************************************/
#include "qpaintengine_mac_p.h"
#if defined(QT_PRINTSUPPORT_LIB)
#include "qprintengine_mac_p.h"
#endif
#include <qbitmap.h>
#include <qpaintdevice.h>
#include <qpainterpath.h>
#include <qpixmapcache.h>
#include <private/qpaintengine_raster_p.h>
#if defined(QT_PRINTSUPPORT_LIB)
#include <qprinter.h>
#endif
#include <qstack.h>
#include <qwidget.h>
#include <qvarlengtharray.h>

View File

@ -101,7 +101,7 @@
- (id)accessibilityElementAtIndex:(NSInteger)index
{
[self initAccessibility];
if (index >= [m_accessibleElements count])
if (NSUInteger(index) >= [m_accessibleElements count])
return nil;
return m_accessibleElements[index];
}