From dcfb814498be938421b56020d7c9946cce7296dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 25 Aug 2016 15:07:33 +0200 Subject: Cocoa: Add support for triple-buffered GL contexts As usual, the requested format may not be available, so clients should check the actual format to confirm triple-buffering. Change-Id: Icf073cc9ddf2c912eb5c3ce0ac80d1694d1c56d7 Reviewed-by: Jake Petroules Reviewed-by: Laszlo Agocs --- src/platformsupport/cglconvenience/cglconvenience.mm | 5 ++++- src/plugins/platforms/cocoa/qcocoaglcontext.mm | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/platformsupport/cglconvenience/cglconvenience.mm b/src/platformsupport/cglconvenience/cglconvenience.mm index 6b0a91e13f..fb609ae485 100644 --- a/src/platformsupport/cglconvenience/cglconvenience.mm +++ b/src/platformsupport/cglconvenience/cglconvenience.mm @@ -81,8 +81,11 @@ void *qcgl_createNSOpenGLPixelFormat(const QSurfaceFormat &format) QVector attrs; - if (format.swapBehavior() != QSurfaceFormat::SingleBuffer) + if (format.swapBehavior() == QSurfaceFormat::DoubleBuffer + || format.swapBehavior() == QSurfaceFormat::DefaultSwapBehavior) attrs.append(NSOpenGLPFADoubleBuffer); + else if (format.swapBehavior() == QSurfaceFormat::TripleBuffer) + attrs.append(NSOpenGLPFATripleBuffer); #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) { diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index 0f9b8b900d..b77ca07141 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -305,8 +305,16 @@ void QCocoaGLContext::updateSurfaceFormat() m_format.setSamples(samples); int doubleBuffered = -1; + int tripleBuffered = -1; [pixelFormat getValues:&doubleBuffered forAttribute:NSOpenGLPFADoubleBuffer forVirtualScreen:0]; - m_format.setSwapBehavior(doubleBuffered == 1 ? QSurfaceFormat::DoubleBuffer : QSurfaceFormat::SingleBuffer); + [pixelFormat getValues:&tripleBuffered forAttribute:NSOpenGLPFATripleBuffer forVirtualScreen:0]; + + if (tripleBuffered == 1) + m_format.setSwapBehavior(QSurfaceFormat::TripleBuffer); + else if (doubleBuffered == 1) + m_format.setSwapBehavior(QSurfaceFormat::DoubleBuffer); + else + m_format.setSwapBehavior(QSurfaceFormat::SingleBuffer); int steroBuffers = -1; [pixelFormat getValues:&steroBuffers forAttribute:NSOpenGLPFAStereo forVirtualScreen:0]; -- cgit v1.2.3 From 17e5d9d7cadb4fceb39cfc875162add57e962db8 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 24 Jun 2016 10:57:10 +0200 Subject: Fix QMainWindow::restoreDockWidget() with GroupedDragging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to account for the fact that the placeholder might be in a floating tab. Task-number: QTBUG-50491 Change-Id: I03d8e49cc40f58691154f5c3984f3b0670a974d5 Reviewed-by: Friedemann Kleint Reviewed-by: Sérgio Martins --- src/widgets/widgets/qdockarealayout.cpp | 53 ++++++++++++++++------- src/widgets/widgets/qdockarealayout_p.h | 1 + src/widgets/widgets/qmainwindowlayout.cpp | 70 ++++++++++++++++++------------- src/widgets/widgets/qmainwindowlayout_p.h | 2 +- 4 files changed, 80 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index d22e89c6e1..1d10de904d 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -2604,6 +2604,21 @@ void QDockAreaLayout::remove(const QList &path) docks[index].remove(path.mid(1)); } +void QDockAreaLayout::removePlaceHolder(const QString &name) +{ + QList index = indexOfPlaceHolder(name); + if (!index.isEmpty()) + remove(index); + foreach (QDockWidgetGroupWindow *dwgw, mainWindow->findChildren( + QString(), Qt::FindDirectChildrenOnly)) { + index = dwgw->layoutInfo()->indexOfPlaceHolder(name); + if (!index.isEmpty()) { + dwgw->layoutInfo()->remove(index); + dwgw->destroyOrHideIfEmpty(); + } + } +} + static inline int qMax(int i1, int i2, int i3) { return qMax(i1, qMax(i2, i3)); } void QDockAreaLayout::getGrid(QVector *_ver_struct_list, @@ -3030,15 +3045,27 @@ QRect QDockAreaLayout::constrainedRect(QRect rect, QWidget* widget) bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget) { - QList index = indexOfPlaceHolder(dockWidget->objectName()); - if (index.isEmpty()) - return false; + QDockAreaLayoutItem *item = 0; + foreach (QDockWidgetGroupWindow *dwgw, mainWindow->findChildren( + QString(), Qt::FindDirectChildrenOnly)) { + QList index = dwgw->layoutInfo()->indexOfPlaceHolder(dockWidget->objectName()); + if (!index.isEmpty()) { + dockWidget->setParent(dwgw); + item = const_cast(&dwgw->layoutInfo()->item(index)); + break; + } + } + if (!item) { + QList index = indexOfPlaceHolder(dockWidget->objectName()); + if (index.isEmpty()) + return false; + item = const_cast(&this->item(index)); + } - QDockAreaLayoutItem &item = this->item(index); - QPlaceHolderItem *placeHolder = item.placeHolderItem; + QPlaceHolderItem *placeHolder = item->placeHolderItem; Q_ASSERT(placeHolder != 0); - item.widgetItem = new QDockWidgetItem(dockWidget); + item->widgetItem = new QDockWidgetItem(dockWidget); if (placeHolder->window) { const QRect r = constrainedRect(placeHolder->topLevelRect, dockWidget); @@ -3050,7 +3077,7 @@ bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget) dockWidget->d_func()->setWindowState(true); #endif - item.placeHolderItem = 0; + item->placeHolderItem = 0; delete placeHolder; return true; @@ -3086,9 +3113,7 @@ void QDockAreaLayout::addDockWidget(QInternal::DockPosition pos, QDockWidget *do info = new_info; } - QList index = indexOfPlaceHolder(dockWidget->objectName()); - if (!index.isEmpty()) - remove(index); + removePlaceHolder(dockWidget->objectName()); } void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second) @@ -3101,9 +3126,7 @@ void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second) Q_ASSERT(info != 0); info->tab(path.last(), new QDockWidgetItem(second)); - QList index = indexOfPlaceHolder(second->objectName()); - if (!index.isEmpty()) - remove(index); + removePlaceHolder(second->objectName()); } void QDockAreaLayout::resizeDocks(const QList &docks, @@ -3165,9 +3188,7 @@ void QDockAreaLayout::splitDockWidget(QDockWidget *after, Q_ASSERT(info != 0); info->split(path.last(), orientation, new QDockWidgetItem(dockWidget)); - QList index = indexOfPlaceHolder(dockWidget->objectName()); - if (!index.isEmpty()) - remove(index); + removePlaceHolder(dockWidget->objectName()); } void QDockAreaLayout::apply(bool animate) diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h index 5d352f0124..8a35d8b035 100644 --- a/src/widgets/widgets/qdockarealayout_p.h +++ b/src/widgets/widgets/qdockarealayout_p.h @@ -255,6 +255,7 @@ public: QLayoutItem *plug(const QList &path); QLayoutItem *unplug(const QList &path); void remove(const QList &path); + void removePlaceHolder(const QString &name); void fitLayout(); diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 6b247d8d11..f581fe4d88 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -215,11 +215,10 @@ public: } void setGeometry(const QRect&r) Q_DECL_OVERRIDE { + static_cast(parent())->destroyOrHideIfEmpty(); QDockAreaLayoutInfo *li = layoutInfo(); - if (li->isEmpty()) { - static_cast(parent())->destroyIfEmpty(); + if (li->isEmpty()) return; - } int fw = frameWidth(); li->reparentWidgets(parentWidget()); li->rect = r.adjusted(fw, fw, -fw, -fw); @@ -272,6 +271,10 @@ bool QDockWidgetGroupWindow::event(QEvent *e) if (qobject_cast(static_cast(e)->child())) adjustFlags(); break; + case QEvent::LayoutRequest: + // We might need to show the widget again + destroyOrHideIfEmpty(); + break; default: break; } @@ -325,34 +328,43 @@ QDockWidget *QDockWidgetGroupWindow::topDockWidget() const } /*! \internal - Destroy this window if there is no more QDockWidget in it. + Destroy or hide this window if there is no more QDockWidget in it. + Otherwise make sure it is shown. */ -void QDockWidgetGroupWindow::destroyIfEmpty() -{ - if (layoutInfo()->isEmpty()) { - // Make sure to reparent the possibly floating or hidden QDockWidgets to the parent - foreach (QDockWidget *dw, - findChildren(QString(), Qt::FindDirectChildrenOnly)) { - bool wasFloating = dw->isFloating(); - bool wasHidden = dw->isHidden(); - dw->setParent(parentWidget()); - if (wasFloating) { - dw->setFloating(true); - } else { - // maybe it was hidden, we still have to put it back in the main layout. - QMainWindowLayout *ml = qt_mainwindow_layout(static_cast(parentWidget())); - Qt::DockWidgetArea area = ml->dockWidgetArea(this); - if (area == Qt::NoDockWidgetArea) - area = Qt::LeftDockWidgetArea; - static_cast(parentWidget())->addDockWidget(area, dw); - } - if (!wasHidden) - dw->show(); +void QDockWidgetGroupWindow::destroyOrHideIfEmpty() +{ + if (!layoutInfo()->isEmpty()) { + show(); // It might have been hidden, + return; + } + // There might still be placeholders + if (!layoutInfo()->item_list.isEmpty()) { + hide(); + return; + } + + // Make sure to reparent the possibly floating or hidden QDockWidgets to the parent + foreach (QDockWidget *dw, findChildren(QString(), Qt::FindDirectChildrenOnly)) { + bool wasFloating = dw->isFloating(); + bool wasHidden = dw->isHidden(); + dw->setParent(parentWidget()); + if (wasFloating) { + dw->setFloating(true); + } else { + // maybe it was hidden, we still have to put it back in the main layout. + QMainWindowLayout *ml = + qt_mainwindow_layout(static_cast(parentWidget())); + Qt::DockWidgetArea area = ml->dockWidgetArea(this); + if (area == Qt::NoDockWidgetArea) + area = Qt::LeftDockWidgetArea; + static_cast(parentWidget())->addDockWidget(area, dw); } - foreach (QTabBar *tb, findChildren(QString(), Qt::FindDirectChildrenOnly)) - tb->setParent(parentWidget()); - deleteLater(); + if (!wasHidden) + dw->show(); } + foreach (QTabBar *tb, findChildren(QString(), Qt::FindDirectChildrenOnly)) + tb->setParent(parentWidget()); + deleteLater(); } /*! \internal @@ -2075,7 +2087,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget) item.subinfo->reparentWidgets(parentWidget()); item.subinfo->setTabBarShape(parentInfo->tabBarShape); } - dwgw->destroyIfEmpty(); + dwgw->destroyOrHideIfEmpty(); } if (QDockWidget *dw = qobject_cast(widget)) { diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index 9a13e5f5ce..7475da8bdc 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -86,7 +86,7 @@ public: : QWidget(parent, f) {} QDockAreaLayoutInfo *layoutInfo() const; QDockWidget *topDockWidget() const; - void destroyIfEmpty(); + void destroyOrHideIfEmpty(); void adjustFlags(); protected: bool event(QEvent *) Q_DECL_OVERRIDE; -- cgit v1.2.3 From ce2815b43c3f10c474c35d30197e14c58c9106ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 19 Aug 2016 14:44:21 +0200 Subject: Guard against calling QWindow::requestUpdate() on non-GUI threads Change-Id: I851ff672bc234146deb61615fc7c56df87d62065 Reviewed-by: Laszlo Agocs Reviewed-by: Timur Pocheptsov --- src/gui/kernel/qwindow.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 2e212e5fdb..bcd29b6fe1 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -2160,6 +2160,9 @@ void QWindowPrivate::deliverUpdateRequest() */ void QWindow::requestUpdate() { + Q_ASSERT_X(QThread::currentThread() == QCoreApplication::instance()->thread(), + "QWindow", "Updates can only be scheduled from the GUI (main) thread"); + Q_D(QWindow); if (d->updateRequestPending || !d->platformWindow) return; -- cgit v1.2.3 From 579283507c392fc5bc0976c054304ecb8938cb06 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 30 Aug 2016 13:42:43 +0200 Subject: QWin32PrintEngine: Fix uninitialized memory read of dpi_x, dpi_y Discovered by purify: QWin32PrintEnginePrivate::initialize() called updateMetrics() via updatePageLayout() after initHDC(), so dpi_x, dpi_y were accessed before initialized from the display resolution. Fix by moving the call initHDC() up and giving default values. Change-Id: Ia360c06d156e569ca6b1472ec5b5cdc52948f913 Reviewed-by: Andy Shaw --- src/printsupport/kernel/qprintengine_win.cpp | 4 ++-- src/printsupport/kernel/qprintengine_win_p.h | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp index a9d316095c..1c02d389fe 100644 --- a/src/printsupport/kernel/qprintengine_win.cpp +++ b/src/printsupport/kernel/qprintengine_win.cpp @@ -918,14 +918,14 @@ void QWin32PrintEnginePrivate::initialize() Q_ASSERT(hPrinter); Q_ASSERT(pInfo); + initHDC(); + if (devMode) { num_copies = devMode->dmCopies; devMode->dmCollate = DMCOLLATE_TRUE; updatePageLayout(); } - initHDC(); - #if defined QT_DEBUG_DRAW || defined QT_DEBUG_METRICS qDebug() << "QWin32PrintEngine::initialize()"; debugMetrics(); diff --git a/src/printsupport/kernel/qprintengine_win_p.h b/src/printsupport/kernel/qprintengine_win_p.h index c1d7b452f9..74b78ae2b1 100644 --- a/src/printsupport/kernel/qprintengine_win_p.h +++ b/src/printsupport/kernel/qprintengine_win_p.h @@ -124,10 +124,14 @@ public: state(QPrinter::Idle), resolution(0), m_pageLayout(QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(0, 0, 0, 0))), + stretch_x(1), stretch_y(1), origin_x(0), origin_y(0), + dpi_x(96), dpi_y(96), dpi_display(96), num_copies(1), printToFile(false), reinit(false), - embed_fonts(true) + complex_xform(false), has_pen(false), has_brush(false), has_custom_paper_size(false), + embed_fonts(true), + txop(0 /* QTransform::TxNone */) { } -- cgit v1.2.3 From 2ca4fd401b90831857a0dcd643e5d382feb75cb0 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 5 Aug 2016 14:43:15 +0200 Subject: QIcon: Set the pixmap's dpr to 1.0 if the window is also set to 1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the pixmap is initially from a higher device pixel ratio and it is being used on a window that does not have a device pixel ratio other than 1.0 set then the pixmap should also have it set to 1.0. This ensures that the size of the pixmap is preserved and it is not scaled down as a result on the normal display. Change-Id: Ie5d96b3e1508867b723000bea182c8157640af02 Reviewed-by: Morten Johan Sørvig --- src/gui/image/qicon.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index e1e5367766..3531be412e 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -835,8 +835,11 @@ QPixmap QIcon::pixmap(QWindow *window, const QSize &size, Mode mode, State state qreal devicePixelRatio = qt_effective_device_pixel_ratio(window); // Handle the simple normal-dpi case: - if (!(devicePixelRatio > 1.0)) - return d->engine->pixmap(size, mode, state); + if (!(devicePixelRatio > 1.0)) { + QPixmap pixmap = d->engine->pixmap(size, mode, state); + pixmap.setDevicePixelRatio(1.0); + return pixmap; + } // Try get a pixmap that is big enough to be displayed at device pixel resolution. QPixmap pixmap = d->engine->pixmap(size * devicePixelRatio, mode, state); -- cgit v1.2.3 From 531a2b1b1c26127f75bfe1230051db615e5874c5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 30 Aug 2016 12:25:00 +0200 Subject: Windows QPA: Fix leaks in native file dialogs Release the IShellItem instances according to the documentation of IFile[Open]Dialog. Task-number: QTBUG-55509 Task-number: QTBUG-55459 Change-Id: Ib79622cde21982b1bda0be7d0483c6e652a1d5fe Reviewed-by: Andreas Holzammer Reviewed-by: Simon Hausmann Reviewed-by: Maurice Kalinowski --- src/plugins/platforms/windows/qwindowsdialoghelpers.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index 6e8df340df..94bb71e429 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -1044,12 +1044,15 @@ void QWindowsNativeFileDialogBase::setDirectory(const QUrl &directory) QString QWindowsNativeFileDialogBase::directory() const { + QString result; #ifndef Q_OS_WINCE IShellItem *item = 0; - if (m_fileDialog && SUCCEEDED(m_fileDialog->GetFolder(&item)) && item) - return QWindowsNativeFileDialogBase::itemPath(item); + if (m_fileDialog && SUCCEEDED(m_fileDialog->GetFolder(&item)) && item) { + result = QWindowsNativeFileDialogBase::itemPath(item); + item->Release(); + } #endif - return QString(); + return result; } void QWindowsNativeFileDialogBase::doExec(HWND owner) @@ -1514,8 +1517,10 @@ QList QWindowsNativeSaveFileDialog::selectedFiles() const QList result; IShellItem *item = 0; const HRESULT hr = fileDialog()->GetCurrentSelection(&item); - if (SUCCEEDED(hr) && item) + if (SUCCEEDED(hr) && item) { result.push_back(QUrl::fromLocalFile(QWindowsNativeSaveFileDialog::itemPath(item))); + item->Release(); + } return result; } -- cgit v1.2.3 From 013210e9dae24288f4e408b4a574433da435ab8a Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Tue, 30 Aug 2016 19:29:37 -0700 Subject: Fix unused variable warning on iOS Change-Id: Ieae5d7833b45a49a743a52a437d5383bd8a962c5 Reviewed-by: Thiago Macieira --- src/gui/opengl/qopenglframebufferobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index 1ee90a0827..56e04c09d8 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -1281,11 +1281,11 @@ static inline QImage qt_gl_read_framebuffer_rgba8(const QSize &size, bool includ ? context->hasExtension(QByteArrayLiteral("GL_EXT_read_format_bgra")) : context->hasExtension(QByteArrayLiteral("GL_EXT_bgra")); +#ifndef Q_OS_IOS const char *renderer = reinterpret_cast(funcs->glGetString(GL_RENDERER)); const char *ver = reinterpret_cast(funcs->glGetString(GL_VERSION)); // Blacklist GPU chipsets that have problems with their BGRA support. -#ifndef Q_OS_IOS const bool blackListed = (qstrcmp(renderer, "PowerVR Rogue G6200") == 0 && ::strstr(ver, "1.3") != 0) || (qstrcmp(renderer, "Mali-T760") == 0 -- cgit v1.2.3 From 816a6238761810c28a991a959ea61a834de2a2a5 Mon Sep 17 00:00:00 2001 From: Dyami Caliri Date: Tue, 16 Aug 2016 20:52:14 -0700 Subject: uic: generate translate calls with Q_NULLPTR instead of 0 uic should use Q_NULLPTR instead of 0 as the default disambiguation context. Task-number: QTBUG-45291 Change-Id: I889182c7fe1c4be3336f3cd645aa60838863c633 Reviewed-by: Marc Mutz --- src/tools/uic/cpp/cppwriteinitialization.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 518944d9d7..a59c14faf9 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -2320,7 +2320,7 @@ QString WriteInitialization::trCall(const QString &str, const QString &commentHi return QLatin1String("QString()"); QString result; - const QString comment = commentHint.isEmpty() ? QString(QLatin1Char('0')) : fixString(commentHint, m_dindent); + const QString comment = commentHint.isEmpty() ? QString(QLatin1String("Q_NULLPTR")) : fixString(commentHint, m_dindent); if (m_option.translateFunction.isEmpty()) { result = QLatin1String("QApplication::translate(\""); -- cgit v1.2.3 From 312d08b290d079f5d72d9afc14a47606ebdde240 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 26 Aug 2016 10:03:05 +0200 Subject: qstrncpy: don't call strncpy_s with invalid parameters According to https://msdn.microsoft.com/en-us/library/5dae5d43.aspx, strncpy_s' second argument must not be 0: > If strDest or strSource is NULL, *or numberOfElements is 0*, the > invalid parameter handler is invoked. Move the existing check for len > 0 up to protect the strncpy_s call, too. Change-Id: I70d339ea60d4b76f3038b2e4e4756f6590a9bd31 Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira --- src/corelib/tools/qbytearray.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 00d15fd518..8bae505d76 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -208,13 +208,14 @@ char *qstrncpy(char *dst, const char *src, uint len) { if (!src || !dst) return 0; + if (len > 0) { #if defined(_MSC_VER) && _MSC_VER >= 1400 - strncpy_s(dst, len, src, len-1); + strncpy_s(dst, len, src, len - 1); #else - strncpy(dst, src, len); + strncpy(dst, src, len); #endif - if (len > 0) dst[len-1] = '\0'; + } return dst; } -- cgit v1.2.3 From 2a6bea7a55308776a76cef838f307e272f23f406 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 1 Sep 2016 08:27:57 +0200 Subject: qcompilerdetection.h: retract Q_COMPILER_DEFAULT_MEMBERS for MSVC < 2015 Earlier versions of the compiler cannot default move special member functions, even though we also define Q_COMPILER_RVALUE_REFS for them. Fix by retracting the less-often-used of the two compiler feature defines. Q_COMPILER_DEFAULT_MEMBERS is not used outside QtBase in neither 5.6 nor 5.7 (5.8 is not released at this time, so wasn't considered). The same is true of the dependent macros Q_COMPILER_DEFAULT_DELETE_MEMBERS and Q_DECL_EQ_DEFAULT. In QtBase, the three uses are: 1. in QAtomic*, where the user also requires Q_COMPILER_CONSTEXPR, which is not defined for any MSVC at this time, 2. for QEnableSharedFromThis, which is a class template with an alternative {} implementa- tion of the default constructor, and uncon- ditional user-defined copy special member functions. 3. The test of the corresponding functionality in tst_compiler, which this commit amends. That means that neither of these two only uses of the macro in Qt libraries are affected by the change. The reason we do this change, then, is that in the future, we want to be able to more easily restore move special member functions for classes for which they are suppressed due to user-defined dtors or copy special member functions. Change-Id: I6f88cad66d6b87a758231f16355c3bddae697b86 Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 2d9e0463b7..e324c043af 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -887,7 +887,8 @@ # endif /* VC 11 */ # if _MSC_VER >= 1800 /* C++11 features in VC12 = VC2013 */ -# define Q_COMPILER_DEFAULT_MEMBERS +/* Implemented, but can't be used on move special members */ +/* # define Q_COMPILER_DEFAULT_MEMBERS */ # define Q_COMPILER_DELETE_MEMBERS # define Q_COMPILER_DELEGATING_CONSTRUCTORS # define Q_COMPILER_EXPLICIT_CONVERSIONS @@ -905,6 +906,7 @@ # endif /* VC 12 SP 2 RC */ # if _MSC_VER >= 1900 /* C++11 features in VC14 = VC2015 */ +# define Q_COMPILER_DEFAULT_MEMBERS # define Q_COMPILER_ALIGNAS # define Q_COMPILER_ALIGNOF // Partial support, insufficient for Qt -- cgit v1.2.3 From c8cb188dd47d89da18f44a08557ca875baefcba7 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 23 Aug 2016 16:40:56 +0200 Subject: Ensure the fontdatabase is initialized when requesting fallbacks Otherwise we will return an empty list of fallbacks if no QFontDatabase has been created yet. Task-number: QTBUG-55222 Change-Id: I50508162fad3206e0acf3cc6eb39aefac5c3e197 Reviewed-by: Peter Varga Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontdatabase.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 0621f2a524..f063541249 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -840,9 +840,13 @@ QStringList QPlatformFontDatabase::fallbacksForFamily(const QString &family, QFo return retList; } +static void initializeDb(); + static QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) { QFontDatabasePrivate *db = privateDb(); + if (!db->count) + initializeDb(); const FallbacksCacheKey cacheKey = { family, style, styleHint, script }; -- cgit v1.2.3 From 24bd7fd6518985f00e4102c2702ef50a8852b731 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 1 Sep 2016 14:00:58 +0200 Subject: Fix crash when rendering to grayscale8 images An entry was missing in one of the tables. This patch adds it back in and adds the enum comments used to keep track of whether they all are there and correctly set. Change-Id: Ic6a55a8f81f9c42a3174a2a75c80c3a354f173b7 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/gui/painting/qdrawhelper.cpp | 65 ++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index ac22c7fc00..ee3863ceb8 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -5384,17 +5384,17 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats blend_src_generic, // ARGB32 blend_transformed_argb, // ARGB32_Premultiplied blend_transformed_rgb565, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, + blend_src_generic, // ARGB8565_Premultiplied + blend_src_generic, // RGB666 + blend_src_generic, // ARGB6666_Premultiplied + blend_src_generic, // RGB555 + blend_src_generic, // ARGB8555_Premultiplied + blend_src_generic, // RGB888 + blend_src_generic, // RGB444 + blend_src_generic, // ARGB4444_Premultiplied + blend_src_generic, // RGBX8888 + blend_src_generic, // RGBA8888 + blend_src_generic, // RGBA8888_Premultiplied blend_src_generic_rgb64, blend_src_generic_rgb64, blend_src_generic_rgb64, @@ -5412,16 +5412,17 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats blend_src_generic, // ARGB32 blend_transformed_tiled_argb, // ARGB32_Premultiplied blend_transformed_tiled_rgb565, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, + blend_src_generic, // ARGB8565_Premultiplied + blend_src_generic, // RGB666 + blend_src_generic, // ARGB6666_Premultiplied + blend_src_generic, // RGB555 + blend_src_generic, // ARGB8555_Premultiplied + blend_src_generic, // RGB888 + blend_src_generic, // RGB444 + blend_src_generic, // ARGB4444_Premultiplied + blend_src_generic, // RGBX8888 + blend_src_generic, // RGBA8888 + blend_src_generic, // RGBA8888_Premultiplied blend_src_generic_rgb64, blend_src_generic_rgb64, blend_src_generic_rgb64, @@ -5439,17 +5440,17 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats blend_src_generic, // ARGB32 blend_src_generic, // ARGB32_Premultiplied blend_transformed_bilinear_rgb565, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, - blend_src_generic, + blend_src_generic, // ARGB8565_Premultiplied + blend_src_generic, // RGB666 + blend_src_generic, // ARGB6666_Premultiplied + blend_src_generic, // RGB555 + blend_src_generic, // ARGB8555_Premultiplied + blend_src_generic, // RGB888 + blend_src_generic, // RGB444 + blend_src_generic, // ARGB4444_Premultiplied + blend_src_generic, // RGBX8888 + blend_src_generic, // RGBA8888 + blend_src_generic, // RGBA8888_Premultiplied blend_src_generic_rgb64, blend_src_generic_rgb64, blend_src_generic_rgb64, -- cgit v1.2.3 From b94111116f09a6e48741d35cf7abea47af99ef26 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Mon, 29 Aug 2016 13:47:08 +0300 Subject: Style sheets: detect and apply font set on QHeaderView section Detect and apply style sheets font set when calculating QHeaderView section content size and drawing it. Change-Id: I542cd0d31bbe62f127c509f297eef0a576fec054 Task-number: QTBUG-55597 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/styles/qstylesheetstyle.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 568a4755e4..eae4658bc9 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -3753,6 +3753,13 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q ParentStyle::drawControl(ce, opt, p, w); return; } + if (subRule.hasFont) { + const QFont oldFont = p->font(); + p->setFont(subRule.font.resolve(p->font())); + baseStyle()->drawControl(ce, opt, p, w); + p->setFont(oldFont); + return; + } } break; case CE_HeaderSection: @@ -4866,13 +4873,14 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op case CT_HeaderSection: { if (const QStyleOptionHeader *hdr = qstyleoption_cast(opt)) { QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection); - if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder()) { + if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder() || subRule.hasFont) { sz = subRule.adjustSize(csz); if (!subRule.hasGeometry()) { QSize nativeContentsSize; bool nullIcon = hdr->icon.isNull(); int iconSize = nullIcon ? 0 : pixelMetric(QStyle::PM_SmallIconSize, hdr, w); - QSize txt = hdr->fontMetrics.size(0, hdr->text); + const QSize txt = subRule.hasFont ? QFontMetrics(subRule.font).size(0, hdr->text) + : hdr->fontMetrics.size(0, hdr->text); nativeContentsSize.setHeight(qMax(iconSize, txt.height())); nativeContentsSize.setWidth(iconSize + txt.width()); sz = sz.expandedTo(nativeContentsSize); -- cgit v1.2.3