diff options
author | Liang Qi <liang.qi@qt.io> | 2016-11-17 14:15:53 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-11-17 14:43:26 +0100 |
commit | e5ac4afbf954a3e1616ce8543d46ddc668d0374f (patch) | |
tree | be6d97001edebd5cb74c64aaf0010f3cc76a7293 /src/widgets | |
parent | e3ed95dd44b95b6e9361b562807e711d7ce5a58b (diff) | |
parent | 03c1a6ac717e3c5693653a5e294214056bda970e (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
mkspecs/features/mac/default_post.prf
mkspecs/features/uikit/default_post.prf
Change-Id: I2a6f783451f2ac9eb4c1a050f605435d2dacf218
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/accessible/itemviews.cpp | 7 | ||||
-rw-r--r-- | src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp | 8 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicsitem.h | 4 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp | 8 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicstransform_p.h | 2 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicswidget.cpp | 1 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicswidget_p.cpp | 3 | ||||
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 7 | ||||
-rw-r--r-- | src/widgets/styles/qpixmapstyle.cpp | 6 | ||||
-rw-r--r-- | src/widgets/styles/qstylehelper.cpp | 22 | ||||
-rw-r--r-- | src/widgets/styles/qstyleoption.h | 8 | ||||
-rw-r--r-- | src/widgets/widgets/qcombobox.cpp | 14 | ||||
-rw-r--r-- | src/widgets/widgets/qlabel.cpp | 1 | ||||
-rw-r--r-- | src/widgets/widgets/qmainwindow.cpp | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qmdisubwindow_p.h | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qmenu.h | 4 | ||||
-rw-r--r-- | src/widgets/widgets/qsizegrip.cpp | 5 | ||||
-rw-r--r-- | src/widgets/widgets/qtoolbar.h | 4 |
19 files changed, 61 insertions, 49 deletions
diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp index 796d13487b..09eba76fbd 100644 --- a/src/widgets/accessible/itemviews.cpp +++ b/src/widgets/accessible/itemviews.cpp @@ -486,10 +486,9 @@ QAccessibleInterface *QAccessibleTable::child(int logicalIndex) const if (!view()->model()) return 0; - if (childToId.contains(logicalIndex)) { - QAccessible::Id id = childToId.value(logicalIndex); - return QAccessible::accessibleInterface(id); - } + auto id = childToId.constFind(logicalIndex); + if (id != childToId.constEnd()) + return QAccessible::accessibleInterface(id.value()); int vHeader = verticalHeader() ? 1 : 0; int hHeader = horizontalHeader() ? 1 : 0; diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp index 18f8f2df8c..f2db73226b 100644 --- a/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp +++ b/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp @@ -137,11 +137,3 @@ setUpdatesEnabled(false); bigVisualChanges(); setUpdatesEnabled(true); //! [13] - - -//! [14] -... -extern void qt_x11_set_global_double_buffer(bool); -qt_x11_set_global_double_buffer(false); -... -//! [14] diff --git a/src/widgets/graphicsview/qgraphicsitem.h b/src/widgets/graphicsview/qgraphicsitem.h index 59656f5b0b..36f8aac124 100644 --- a/src/widgets/graphicsview/qgraphicsitem.h +++ b/src/widgets/graphicsview/qgraphicsitem.h @@ -1024,14 +1024,14 @@ private: template <class T> inline T qgraphicsitem_cast(QGraphicsItem *item) { - typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Item; + typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Item; return int(Item::Type) == int(QGraphicsItem::Type) || (item && int(Item::Type) == item->type()) ? static_cast<T>(item) : 0; } template <class T> inline T qgraphicsitem_cast(const QGraphicsItem *item) { - typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Item; + typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Item; return int(Item::Type) == int(QGraphicsItem::Type) || (item && int(Item::Type) == item->type()) ? static_cast<T>(item) : 0; } diff --git a/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp b/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp index b884e93290..203cc8007c 100644 --- a/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp +++ b/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp @@ -694,8 +694,7 @@ void QGraphicsSceneBspTreeIndex::itemChange(const QGraphicsItem *item, QGraphics bool QGraphicsSceneBspTreeIndex::event(QEvent *event) { Q_D(QGraphicsSceneBspTreeIndex); - switch (event->type()) { - case QEvent::Timer: + if (event->type() == QEvent::Timer) { if (d->indexTimerId && static_cast<QTimerEvent *>(event)->timerId() == d->indexTimerId) { if (d->restartIndexTimer) { d->restartIndexTimer = false; @@ -704,11 +703,8 @@ bool QGraphicsSceneBspTreeIndex::event(QEvent *event) d->_q_updateIndex(); } } - // Fallthrough intended - support timers in subclasses. - default: - return QObject::event(event); } - return true; + return QObject::event(event); } QT_END_NAMESPACE diff --git a/src/widgets/graphicsview/qgraphicstransform_p.h b/src/widgets/graphicsview/qgraphicstransform_p.h index 39f7ab5487..38dbd51c2e 100644 --- a/src/widgets/graphicsview/qgraphicstransform_p.h +++ b/src/widgets/graphicsview/qgraphicstransform_p.h @@ -77,6 +77,6 @@ public: QT_END_NAMESPACE -#endif //QT_NO_GRAPHCISVIEW +#endif //QT_NO_GRAPHICSVIEW #endif // QGRAPHICSTRANSFORM_P_H diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp index d153915ae6..2adc58e4a4 100644 --- a/src/widgets/graphicsview/qgraphicswidget.cpp +++ b/src/widgets/graphicsview/qgraphicswidget.cpp @@ -1456,6 +1456,7 @@ bool QGraphicsWidget::event(QEvent *event) case QEvent::GraphicsSceneMousePress: if (d->hasDecoration() && windowFrameEvent(event)) return true; + break; case QEvent::GraphicsSceneMouseMove: case QEvent::GraphicsSceneMouseRelease: case QEvent::GraphicsSceneMouseDoubleClick: diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp index 4beb64a254..46d2a4c1aa 100644 --- a/src/widgets/graphicsview/qgraphicswidget_p.cpp +++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp @@ -722,6 +722,9 @@ void QGraphicsWidgetPrivate::windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent #ifndef QT_NO_CURSOR if (needsSetCursorCall) q->setCursor(cursorShape); +#else + Q_UNUSED(needsSetCursorCall); + Q_UNUSED(cursorShape); #endif // update buttons if we hover over them windowData->hoveredSubControl = q->style()->hitTestComplexControl(QStyle::CC_TitleBar, &bar, pos.toPoint(), 0); diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 89eff898fe..358838b4e9 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -2790,6 +2790,8 @@ void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget) // Send enter/leave events followed by a mouse move on the entered widget. QMouseEvent e(QEvent::MouseMove, pos, windowPos, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier); sendMouseEvent(widgetUnderCursor, &e, widgetUnderCursor, tlw, &qt_button_down, qt_last_mouse_receiver); +#else // !QT_NO_CURSOR + Q_UNUSED(widget); #endif // QT_NO_CURSOR } diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index dc04bfb632..ace50f13ee 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -5535,7 +5535,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP return; } } -#endif //QT_NO_GRAFFICSEFFECT +#endif //QT_NO_GRAPHICSEFFECT const bool alsoOnScreen = flags & DrawPaintOnScreen; const bool recursive = flags & DrawRecursive; @@ -9625,11 +9625,6 @@ void QWidget::leaveEvent(QEvent *) Since Qt 4.0, QWidget automatically double-buffers its painting, so there is no need to write double-buffering code in paintEvent() to avoid flicker. - \b{Note for the X11 platform}: It is possible to toggle global double - buffering by calling \c qt_x11_set_global_double_buffer(). For example, - - \snippet code/src_gui_kernel_qwidget.cpp 14 - \note Generally, you should refrain from calling update() or repaint() \b{inside} a paintEvent(). For example, calling update() or repaint() on children inside a paintevent() results in undefined behavior; the child may diff --git a/src/widgets/styles/qpixmapstyle.cpp b/src/widgets/styles/qpixmapstyle.cpp index b51860045d..e973a96a91 100644 --- a/src/widgets/styles/qpixmapstyle.cpp +++ b/src/widgets/styles/qpixmapstyle.cpp @@ -628,10 +628,10 @@ void QPixmapStyle::drawCachedPixmap(QPixmapStyle::ControlDescriptor control, con QPainter *p) const { Q_D(const QPixmapStyle); - if (!d->descriptors.contains(control)) + auto descriptor = d->descriptors.constFind(control); + if (descriptor == d->descriptors.constEnd()) return; - const QPixmapStyleDescriptor &desc = d->descriptors.value(control); - const QPixmap pix = d->getCachedPixmap(control, desc, rect.size()); + const QPixmap pix = d->getCachedPixmap(control, descriptor.value(), rect.size()); Q_ASSERT(!pix.isNull()); p->drawPixmap(rect, pix); } diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index 583385ee8a..602421725f 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -49,6 +49,8 @@ #include "qstylehelper_p.h" #include <qstringbuilder.h> +#include <qdatastream.h> +#include <qcryptographichash.h> QT_BEGIN_NAMESPACE @@ -62,7 +64,6 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize & QString tmp = key % HexString<uint>(option->state) % HexString<uint>(option->direction) % HexString<uint>(complexOption ? uint(complexOption->activeSubControls) : 0u) - % HexString<quint64>(option->palette.cacheKey()) % HexString<uint>(size.width()) % HexString<uint>(size.height()); @@ -73,6 +74,25 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize & % QLatin1Char(spinBox->frame ? '1' : '0'); ; } #endif // QT_NO_SPINBOX + + // QTBUG-56743, try to create a palette cache key reflecting the value, + // as leaks may occur in conjunction with QStyleSheetStyle/QRenderRule modifying + // palettes when using QPalette::cacheKey() + if (option->palette != QGuiApplication::palette()) { + tmp.append(QLatin1Char('P')); +#ifndef QT_NO_DATASTREAM + QByteArray key; + key.reserve(5120); // Observed 5040B for a serialized palette on 64bit + { + QDataStream str(&key, QIODevice::WriteOnly); + str << option->palette; + } + const QByteArray sha1 = QCryptographicHash::hash(key, QCryptographicHash::Sha1).toHex(); + tmp.append(QString::fromLatin1(sha1)); +#else // QT_NO_DATASTREAM + tmp.append(QString::number(option->palette.cacheKey(), 16)); +#endif // !QT_NO_DATASTREAM + } return tmp; } diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h index 9679411402..0e76d53eea 100644 --- a/src/widgets/styles/qstyleoption.h +++ b/src/widgets/styles/qstyleoption.h @@ -665,7 +665,7 @@ protected: template <typename T> T qstyleoption_cast(const QStyleOption *opt) { - typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Opt; + typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt; if (opt && opt->version >= Opt::Version && (opt->type == Opt::Type || int(Opt::Type) == QStyleOption::SO_Default || (int(Opt::Type) == QStyleOption::SO_Complex @@ -677,7 +677,7 @@ T qstyleoption_cast(const QStyleOption *opt) template <typename T> T qstyleoption_cast(QStyleOption *opt) { - typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Opt; + typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt; if (opt && opt->version >= Opt::Version && (opt->type == Opt::Type || int(Opt::Type) == QStyleOption::SO_Default || (int(Opt::Type) == QStyleOption::SO_Complex @@ -728,7 +728,7 @@ public: template <typename T> T qstyleoption_cast(const QStyleHintReturn *hint) { - typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Opt; + typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt; if (hint && hint->version <= Opt::Version && (hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default)) return static_cast<T>(hint); @@ -738,7 +738,7 @@ T qstyleoption_cast(const QStyleHintReturn *hint) template <typename T> T qstyleoption_cast(QStyleHintReturn *hint) { - typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Opt; + typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt; if (hint && hint->version <= Opt::Version && (hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default)) return static_cast<T>(hint); diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 52e7962109..4358e568bf 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -170,18 +170,18 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt menuOption.menuRect = option.rect; menuOption.rect = option.rect; - // Make sure fonts set on the combo box also overrides the font for the popup menu. - if (mCombo->testAttribute(Qt::WA_SetFont) + // Make sure fonts set on the model or on the combo box, in + // that order, also override the font for the popup menu. + QVariant fontRoleData = index.data(Qt::FontRole); + if (fontRoleData.isValid()) { + menuOption.font = fontRoleData.value<QFont>(); + } else if (mCombo->testAttribute(Qt::WA_SetFont) || mCombo->testAttribute(Qt::WA_MacSmallSize) || mCombo->testAttribute(Qt::WA_MacMiniSize) || mCombo->font() != qt_app_fonts_hash()->value("QComboBox", QFont())) { menuOption.font = mCombo->font(); } else { - QVariant fontRoleData = index.data(Qt::FontRole); - if (fontRoleData.isValid()) - menuOption.font = fontRoleData.value<QFont>(); - else - menuOption.font = qt_app_fonts_hash()->value("QComboMenuItem", mCombo->font()); + menuOption.font = qt_app_fonts_hash()->value("QComboMenuItem", mCombo->font()); } menuOption.fontMetrics = QFontMetrics(menuOption.font); diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp index 76713d9880..fa0cff45c9 100644 --- a/src/widgets/widgets/qlabel.cpp +++ b/src/widgets/widgets/qlabel.cpp @@ -583,6 +583,7 @@ QSize QLabelPrivate::sizeForWidth(int w) const #ifndef QT_NO_MOVIE } else if (movie && !movie->currentPixmap().isNull()) { br = movie->currentPixmap().rect(); + br.setSize(br.size() / movie->currentPixmap().devicePixelRatio()); #endif } else if (isTextLabel) { int align = QStyle::visualAlignment(textDirection(), QFlag(this->align)); diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index e32e379198..abfdfbea9b 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -326,7 +326,7 @@ void QMainWindowPrivate::init() direction. Two dock widgets may also be stacked on top of each other. A - QTabBar is then used to select which of the widgets that should be + QTabBar is then used to select which of the widgets should be displayed. We give an example of how to create and add dock widgets to a diff --git a/src/widgets/widgets/qmdisubwindow_p.h b/src/widgets/widgets/qmdisubwindow_p.h index 46a8e99d0a..650d3b0bfb 100644 --- a/src/widgets/widgets/qmdisubwindow_p.h +++ b/src/widgets/widgets/qmdisubwindow_p.h @@ -211,7 +211,7 @@ public: Qt::FocusReason focusInReason; OperationInfoMap operationMap; QPointer<QMenu> systemMenu; -#ifndef QT_NO_ACTIONS +#ifndef QT_NO_ACTION QPointer<QAction> actions[NumWindowStateActions]; #endif QMdiSubWindow::SubWindowOptions options; diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h index bcbd0a95c4..5d218ac1ba 100644 --- a/src/widgets/widgets/qmenu.h +++ b/src/widgets/widgets/qmenu.h @@ -98,7 +98,7 @@ public: #else // addAction(QString): Connect to a QObject slot / functor or function pointer (with context) template<class Obj, typename Func1> - inline typename QtPrivate::QEnableIf<!QtPrivate::is_same<const char*, Func1>::value + inline typename QtPrivate::QEnableIf<!std::is_same<const char*, Func1>::value && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type addAction(const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0) { @@ -126,7 +126,7 @@ public: } // addAction(QIcon, QString): Connect to a QObject slot / functor or function pointer (with context) template<class Obj, typename Func1> - inline typename QtPrivate::QEnableIf<!QtPrivate::is_same<const char*, Func1>::value + inline typename QtPrivate::QEnableIf<!std::is_same<const char*, Func1>::value && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0) { diff --git a/src/widgets/widgets/qsizegrip.cpp b/src/widgets/widgets/qsizegrip.cpp index 5150601366..82857c8805 100644 --- a/src/widgets/widgets/qsizegrip.cpp +++ b/src/widgets/widgets/qsizegrip.cpp @@ -184,9 +184,12 @@ Qt::Corner QSizeGripPrivate::corner() const Put this widget anywhere in a widget tree and the user can use it to resize the top-level window or any widget with the Qt::SubWindow flag set. Generally, this should be in the lower right-hand corner. + Note that QStatusBar already uses this widget, so if you have a status bar (e.g., you are using QMainWindow), then you don't need - to use this widget explicitly. + to use this widget explicitly. The same goes for QDialog, for which + you can just call \l {QDialog::setSizeGripEnabled()} + {QDialog::setSizeGripEnabled()}. On some platforms the size grip automatically hides itself when the window is shown full screen or maximised. diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h index d361513bbf..0ea4d4afeb 100644 --- a/src/widgets/widgets/qtoolbar.h +++ b/src/widgets/widgets/qtoolbar.h @@ -116,7 +116,7 @@ public: #else // addAction(QString): Connect to a QObject slot / functor or function pointer (with context) template<class Obj, typename Func1> - inline typename QtPrivate::QEnableIf<!QtPrivate::is_same<const char*, Func1>::value + inline typename QtPrivate::QEnableIf<!std::is_same<const char*, Func1>::value && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type addAction(const QString &text, const Obj *object, Func1 slot) { @@ -134,7 +134,7 @@ public: } // addAction(QString): Connect to a QObject slot / functor or function pointer (with context) template<class Obj, typename Func1> - inline typename QtPrivate::QEnableIf<!QtPrivate::is_same<const char*, Func1>::value + inline typename QtPrivate::QEnableIf<!std::is_same<const char*, Func1>::value && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot) { |