summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Wicking <paul.wicking@qt.io>2019-08-23 08:42:17 +0200
committerPaul Wicking <paul.wicking@qt.io>2019-08-23 08:42:17 +0200
commit304587e3dbb46d23180075bf20cebf7bc342a313 (patch)
treecb67b5128ce9debc42aeaa172dab6f53244d3855
parent28ba681eb6f53ec817b191f3d8ff62ffe282bac5 (diff)
parentb1db1dd655788fb685949959c99c901515bfd8ab (diff)
Merge 5.12 into 5.12.5
-rw-r--r--mkspecs/features/mac/default_post.prf2
-rw-r--r--src/corelib/global/qlogging.cpp4
-rw-r--r--src/corelib/kernel/qmetaobject.cpp7
-rw-r--r--src/gui/opengl/qopenglprogrambinarycache.cpp4
-rw-r--r--src/gui/painting/qbezier.cpp32
-rw-r--r--src/plugins/platforms/cocoa/cocoa.pro27
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.h5
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.mm25
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.mm10
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm11
-rw-r--r--src/plugins/platforms/cocoa/qnsview_mouse.mm4
-rw-r--r--src/plugins/platforms/cocoa/qnswindow.mm14
-rw-r--r--src/plugins/platforms/cocoa/qpaintengine_mac.mm4
-rw-r--r--src/plugins/platforms/ios/quiview_accessibility.mm2
15 files changed, 95 insertions, 57 deletions
diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf
index 60b2eb2117..26bd3e2e98 100644
--- a/mkspecs/features/mac/default_post.prf
+++ b/mkspecs/features/mac/default_post.prf
@@ -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
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 1a74757032..bf9c2ed2be 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -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);
}
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 666bb6eace..927d03f830 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -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}
*/
diff --git a/src/gui/opengl/qopenglprogrambinarycache.cpp b/src/gui/opengl/qopenglprogrambinarycache.cpp
index 40237b9935..c3fb375a20 100644
--- a/src/gui/opengl/qopenglprogrambinarycache.cpp
+++ b/src/gui/opengl/qopenglprogrambinarycache.cpp
@@ -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);
diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp
index 8cda4b4072..65e6063fe4 100644
--- a/src/gui/painting/qbezier.cpp
+++ b/src/gui/painting/qbezier.cpp
@@ -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;
}
}
}
diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro
index f0dd013922..4cf9e64447 100644
--- a/src/plugins/platforms/cocoa/cocoa.pro
+++ b/src/plugins/platforms/cocoa/cocoa.pro
@@ -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 \
-
- HEADERS += \
- qpaintengine_mac_p.h \
- qprintengine_mac_p.h \
- qcocoaprintersupport.h \
- qcocoaprintdevice.h \
+ SOURCES += qpaintengine_mac.mm
+ HEADERS += qpaintengine_mac_p.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
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h
index 9be6814ae7..a874936ce6 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.h
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h
@@ -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;
};
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
index af50aabe15..5d5e406d8a 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
@@ -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();
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
index 9bd19dd07c..d0e69bdca5 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
@@ -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
}
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index fef72bc496..c6ce6e6819 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -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();
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index d6f88b4f23..3008a056a2 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -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()
{
diff --git a/src/plugins/platforms/cocoa/qnsview_mouse.mm b/src/plugins/platforms/cocoa/qnsview_mouse.mm
index a887cb841d..3a5a074264 100644
--- a/src/plugins/platforms/cocoa/qnsview_mouse.mm
+++ b/src/plugins/platforms/cocoa/qnsview_mouse.mm
@@ -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;
}
}
diff --git a/src/plugins/platforms/cocoa/qnswindow.mm b/src/plugins/platforms/cocoa/qnswindow.mm
index 52f765eb31..68cb270457 100644
--- a/src/plugins/platforms/cocoa/qnswindow.mm
+++ b/src/plugins/platforms/cocoa/qnswindow.mm
@@ -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
diff --git a/src/plugins/platforms/cocoa/qpaintengine_mac.mm b/src/plugins/platforms/cocoa/qpaintengine_mac.mm
index 3677877538..00b2267f0d 100644
--- a/src/plugins/platforms/cocoa/qpaintengine_mac.mm
+++ b/src/plugins/platforms/cocoa/qpaintengine_mac.mm
@@ -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>
diff --git a/src/plugins/platforms/ios/quiview_accessibility.mm b/src/plugins/platforms/ios/quiview_accessibility.mm
index 458ddcc9b8..6612dc131e 100644
--- a/src/plugins/platforms/ios/quiview_accessibility.mm
+++ b/src/plugins/platforms/ios/quiview_accessibility.mm
@@ -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];
}