diff --git a/src/corelib/serialization/qcborarray.cpp b/src/corelib/serialization/qcborarray.cpp index 05403795b05..921fcf2fca4 100644 --- a/src/corelib/serialization/qcborarray.cpp +++ b/src/corelib/serialization/qcborarray.cpp @@ -185,12 +185,22 @@ qsizetype QCborArray::size() const noexcept return d ? d->elements.size() : 0; } +/*! + Empties this array. + + \sa isEmpty() + */ +void QCborArray::clear() +{ + d.reset(); +} + /*! \fn bool QCborArray::isEmpty() const Returns true if this QCborArray is empty (that is if size() is 0). - \sa size() + \sa size(), clear() */ /*! diff --git a/src/corelib/serialization/qcborarray.h b/src/corelib/serialization/qcborarray.h index 6b07b52a02e..f24bb41759c 100644 --- a/src/corelib/serialization/qcborarray.h +++ b/src/corelib/serialization/qcborarray.h @@ -180,6 +180,7 @@ public: qsizetype size() const noexcept; bool isEmpty() const { return size() == 0; } + void clear(); QCborValue at(qsizetype i) const; QCborValue first() const { return at(0); } diff --git a/src/corelib/serialization/qcbormap.cpp b/src/corelib/serialization/qcbormap.cpp index b18945ded1e..33f92499934 100644 --- a/src/corelib/serialization/qcbormap.cpp +++ b/src/corelib/serialization/qcbormap.cpp @@ -270,7 +270,7 @@ QCborMap &QCborMap::operator=(const QCborMap &other) noexcept Returns true if this map is empty (that is, size() is 0). - \sa size() + \sa size(), clear() */ /*! @@ -283,6 +283,16 @@ qsizetype QCborMap::size() const noexcept return d ? d->elements.size() / 2 : 0; } +/*! + Empties this map. + + \sa isEmpty() + */ +void QCborMap::clear() +{ + d.reset(); +} + /*! Returns a list of all keys in this map. diff --git a/src/corelib/serialization/qcbormap.h b/src/corelib/serialization/qcbormap.h index c895abfa591..45ef430e409 100644 --- a/src/corelib/serialization/qcbormap.h +++ b/src/corelib/serialization/qcbormap.h @@ -184,6 +184,7 @@ public: qsizetype size() const noexcept Q_DECL_PURE_FUNCTION; bool isEmpty() const { return size() == 0; } + void clear(); QVector keys() const; QCborValue value(qint64 key) const diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index d64d31a9e84..c5d5490ea0f 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -984,11 +984,15 @@ bool QOpenGLContext::makeCurrent(QSurface *surface) #endif } - QOpenGLContext *previous = QOpenGLContextPrivate::setCurrentContext(this); - if (!d->platformGLContext->makeCurrent(surface->surfaceHandle())) { - QOpenGLContextPrivate::setCurrentContext(previous); + if (!d->platformGLContext->makeCurrent(surface->surfaceHandle())) return false; - } + + QOpenGLContextPrivate::setCurrentContext(this); +#ifndef QT_NO_DEBUG + QOpenGLContextPrivate::toggleMakeCurrentTracker(this, true); +#endif + + d->surface = surface; static bool needsWorkaroundSet = false; static bool needsWorkaround = false; @@ -1030,14 +1034,8 @@ bool QOpenGLContext::makeCurrent(QSurface *surface) if (needsWorkaround) d->workaround_brokenFBOReadBack = true; - d->surface = surface; - d->shareGroup->d_func()->deletePendingResources(this); -#ifndef QT_NO_DEBUG - QOpenGLContextPrivate::toggleMakeCurrentTracker(this, true); -#endif - return true; } diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm index a6cdf4211f4..60eb8cdf68d 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm @@ -169,7 +169,11 @@ QHash qt_mac_createRolePalettes() // Cheap approximation for NSVisualEffectView (see deprecation note for selectedMenuItemTextColor) selectedMenuItemColor = [[NSColor selectedContentBackgroundColor] highlightWithLevel:0.4]; } else { - selectedMenuItemColor = [NSColor selectedMenuItemTextColor]; + // selectedMenuItemColor would presumably be the correct color to use as the background + // for selected menu items. But that color is always blue, and doesn't follow the + // appearance color in system preferences. So we therefore deliberatly choose to use + // keyboardFocusIndicatorColor instead, which appears to have the same color value. + selectedMenuItemColor = [NSColor keyboardFocusIndicatorColor]; } pal.setBrush(QPalette::Highlight, qt_mac_toQColor(selectedMenuItemColor)); qc = qt_mac_toQColor([NSColor labelColor]); diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index e499d226189..9fb980893f0 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -80,7 +80,7 @@ QT_FOR_EACH_STATIC_TYPE(RETURN_METATYPENAME_STRING) return 0; } -Generator::Generator(ClassDef *classDef, const QList &metaTypes, const QHash &knownQObjectClasses, const QHash &knownGadgets, FILE *outfile) +Generator::Generator(ClassDef *classDef, const QVector &metaTypes, const QHash &knownQObjectClasses, const QHash &knownGadgets, FILE *outfile) : out(outfile), cdef(classDef), metaTypes(metaTypes), knownQObjectClasses(knownQObjectClasses) , knownGadgets(knownGadgets) { @@ -461,7 +461,7 @@ void Generator::generateCode() // // Build extra array // - QList extraList; + QVector extraList; QHash knownExtraMetaObject = knownGadgets; knownExtraMetaObject.unite(knownQObjectClasses); diff --git a/src/tools/moc/generator.h b/src/tools/moc/generator.h index 8b801383021..134166580b5 100644 --- a/src/tools/moc/generator.h +++ b/src/tools/moc/generator.h @@ -39,7 +39,7 @@ class Generator ClassDef *cdef; QVector meta_data; public: - Generator(ClassDef *classDef, const QList &metaTypes, const QHash &knownQObjectClasses, const QHash &knownGadgets, FILE *outfile = 0); + Generator(ClassDef *classDef, const QVector &metaTypes, const QHash &knownQObjectClasses, const QHash &knownGadgets, FILE *outfile = 0); void generateCode(); private: bool registerableMetaType(const QByteArray &propertyType); @@ -64,9 +64,9 @@ private: void strreg(const QByteArray &); // registers a string int stridx(const QByteArray &); // returns a string's id - QList strings; + QVector strings; QByteArray purestSuperClass; - QList metaTypes; + QVector metaTypes; QHash knownQObjectClasses; QHash knownGadgets; }; diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index 56763c5e590..d98c73e1a0f 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -65,7 +65,7 @@ struct EnumDef { QByteArray name; QByteArray enumName; - QList values; + QVector values; bool isEnumClass; // c++11 enum class EnumDef() : isEnumClass(false) {} }; @@ -207,10 +207,10 @@ public: bool noInclude; bool mustIncludeQPluginH; QByteArray includePath; - QList includeFiles; + QVector includeFiles; QVector classList; QMap interface2IdMap; - QList metaTypes; + QVector metaTypes; // map from class name to fully qualified name QHash knownQObjectClasses; QHash knownGadgets; diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index 9c2b3e5b54c..9725a768de7 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -1816,8 +1816,12 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi break; case MovePageUp: { int newRow = rowAt(visualRect(current).bottom() - d->viewport->height()); - if (newRow == -1) - newRow = d->logicalRow(0); + if (newRow == -1) { + int visualRow = 0; + while (visualRow < bottom && isRowHidden(d->logicalRow(visualRow))) + ++visualRow; + newRow = d->logicalRow(visualRow); + } return d->model->index(newRow, current.column(), d->root); } case MovePageDown: { diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index 80ea27fee84..eac56741612 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -109,10 +109,11 @@ static int menuBarHeightForWidth(QWidget *menubar, int w) /*! Constructs a new top-level QLayout, with parent \a parent. - \a parent may not be 0. + \a parent may not be a \c nullptr. - There can be only one top-level layout for a widget. It is - returned by QWidget::layout(). + The layout is set directly as the top-level layout for + \a parent. There can be only one top-level layout for a + widget. It is returned by QWidget::layout(). */ QLayout::QLayout(QWidget *parent) : QObject(*new QLayoutPrivate, parent) diff --git a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp index afd6d84486e..bbdaac5c6ff 100644 --- a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp +++ b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp @@ -546,23 +546,26 @@ void tst_QItemView::walkScreen(QAbstractItemView *view) } } -void walkIndex(QModelIndex index, QAbstractItemView *view) +void walkIndex(const QModelIndex &index, const QAbstractItemView *view) { - QRect visualRect = view->visualRect(index); - //if (index.column() == 0) - //qDebug() << index << visualRect; - int width = visualRect.width(); - int height = visualRect.height(); + const QRect visualRect = view->visualRect(index); + const int width = visualRect.width(); + const int height = visualRect.height(); - for (int w = 0; w < width; ++w) + if (width == 0 || height == 0) + return; + + const auto widths = (width < 2) ? QVector({ 0, 1 }) : QVector({ 0, 1, width / 2, width - 2, width - 1 }); + const auto heights = (height < 2) ? QVector({ 0, 1 }) : QVector({ 0, 1, height / 2, height - 2, height - 1 }); + for (int w : widths) { - for (int h = 0; h < height; ++h) + for (int h : heights) { - QPoint point(visualRect.x()+w, visualRect.y()+h); - if (view->indexAt(point) != index) { + const QPoint point(visualRect.x() + w, visualRect.y() + h); + const auto idxAt = view->indexAt(point); + if (idxAt != index) qDebug() << "index" << index << "visualRect" << visualRect << point << view->indexAt(point); - } - QCOMPARE(view->indexAt(point), index); + QCOMPARE(idxAt, index); } } @@ -579,7 +582,7 @@ void walkIndex(QModelIndex index, QAbstractItemView *view) a bug it will point it out, but the above tests should have already found the basic bugs because it is easier to figure out the problem in those tests then this one. */ -void checkChildren(QAbstractItemView *currentView, const QModelIndex &parent = QModelIndex(), int currentDepth=0) +void checkChildren(const QAbstractItemView *currentView, const QModelIndex &parent = QModelIndex(), int currentDepth = 0) { QAbstractItemModel *currentModel = currentView->model(); @@ -623,7 +626,6 @@ void tst_QItemView::indexAt() view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll); view->show(); view->setModel(treeModel); -#if 0 checkChildren(view); QModelIndex index = view->model()->index(0, 0); @@ -636,7 +638,6 @@ void tst_QItemView::indexAt() QPoint p(1, view->height()/2); QModelIndex idx = view->indexAt(p); QCOMPARE(idx, QModelIndex()); -#endif } void tst_QItemView::scrollTo_data() diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index e1ec38b4e79..228d03350a6 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -1353,6 +1353,11 @@ void tst_QTableView::moveCursorBiggerJump() QCOMPARE(view.indexAt(QPoint(0,0)), model.index(7,0)); QTest::keyClick(&view, Qt::Key_PageUp); QCOMPARE(view.indexAt(QPoint(0,0)), model.index(0,0)); + + QTest::keyClick(&view, Qt::Key_PageDown); + view.verticalHeader()->hideSection(0); + QTest::keyClick(&view, Qt::Key_PageUp); + QTRY_COMPARE(view.currentIndex().row(), view.rowAt(0)); } void tst_QTableView::hideRows_data()