Merge remote-tracking branch 'origin/5.12' into dev

Change-Id: If1baf48f0f396fb223672d14f0e1847ac42ca1a6
This commit is contained in:
Qt Forward Merge Bot 2018-09-10 01:00:42 +02:00
commit 3d2832790a
13 changed files with 76 additions and 41 deletions

View File

@ -185,12 +185,22 @@ qsizetype QCborArray::size() const noexcept
return d ? d->elements.size() : 0; return d ? d->elements.size() : 0;
} }
/*!
Empties this array.
\sa isEmpty()
*/
void QCborArray::clear()
{
d.reset();
}
/*! /*!
\fn bool QCborArray::isEmpty() const \fn bool QCborArray::isEmpty() const
Returns true if this QCborArray is empty (that is if size() is 0). Returns true if this QCborArray is empty (that is if size() is 0).
\sa size() \sa size(), clear()
*/ */
/*! /*!

View File

@ -180,6 +180,7 @@ public:
qsizetype size() const noexcept; qsizetype size() const noexcept;
bool isEmpty() const { return size() == 0; } bool isEmpty() const { return size() == 0; }
void clear();
QCborValue at(qsizetype i) const; QCborValue at(qsizetype i) const;
QCborValue first() const { return at(0); } QCborValue first() const { return at(0); }

View File

@ -270,7 +270,7 @@ QCborMap &QCborMap::operator=(const QCborMap &other) noexcept
Returns true if this map is empty (that is, size() is 0). 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; 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. Returns a list of all keys in this map.

View File

@ -184,6 +184,7 @@ public:
qsizetype size() const noexcept Q_DECL_PURE_FUNCTION; qsizetype size() const noexcept Q_DECL_PURE_FUNCTION;
bool isEmpty() const { return size() == 0; } bool isEmpty() const { return size() == 0; }
void clear();
QVector<QCborValue> keys() const; QVector<QCborValue> keys() const;
QCborValue value(qint64 key) const QCborValue value(qint64 key) const

View File

@ -984,11 +984,15 @@ bool QOpenGLContext::makeCurrent(QSurface *surface)
#endif #endif
} }
QOpenGLContext *previous = QOpenGLContextPrivate::setCurrentContext(this); if (!d->platformGLContext->makeCurrent(surface->surfaceHandle()))
if (!d->platformGLContext->makeCurrent(surface->surfaceHandle())) {
QOpenGLContextPrivate::setCurrentContext(previous);
return false; return false;
}
QOpenGLContextPrivate::setCurrentContext(this);
#ifndef QT_NO_DEBUG
QOpenGLContextPrivate::toggleMakeCurrentTracker(this, true);
#endif
d->surface = surface;
static bool needsWorkaroundSet = false; static bool needsWorkaroundSet = false;
static bool needsWorkaround = false; static bool needsWorkaround = false;
@ -1030,14 +1034,8 @@ bool QOpenGLContext::makeCurrent(QSurface *surface)
if (needsWorkaround) if (needsWorkaround)
d->workaround_brokenFBOReadBack = true; d->workaround_brokenFBOReadBack = true;
d->surface = surface;
d->shareGroup->d_func()->deletePendingResources(this); d->shareGroup->d_func()->deletePendingResources(this);
#ifndef QT_NO_DEBUG
QOpenGLContextPrivate::toggleMakeCurrentTracker(this, true);
#endif
return true; return true;
} }

View File

@ -169,7 +169,11 @@ QHash<QPlatformTheme::Palette, QPalette*> qt_mac_createRolePalettes()
// Cheap approximation for NSVisualEffectView (see deprecation note for selectedMenuItemTextColor) // Cheap approximation for NSVisualEffectView (see deprecation note for selectedMenuItemTextColor)
selectedMenuItemColor = [[NSColor selectedContentBackgroundColor] highlightWithLevel:0.4]; selectedMenuItemColor = [[NSColor selectedContentBackgroundColor] highlightWithLevel:0.4];
} else { } 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)); pal.setBrush(QPalette::Highlight, qt_mac_toQColor(selectedMenuItemColor));
qc = qt_mac_toQColor([NSColor labelColor]); qc = qt_mac_toQColor([NSColor labelColor]);

View File

@ -80,7 +80,7 @@ QT_FOR_EACH_STATIC_TYPE(RETURN_METATYPENAME_STRING)
return 0; return 0;
} }
Generator::Generator(ClassDef *classDef, const QList<QByteArray> &metaTypes, const QHash<QByteArray, QByteArray> &knownQObjectClasses, const QHash<QByteArray, QByteArray> &knownGadgets, FILE *outfile) Generator::Generator(ClassDef *classDef, const QVector<QByteArray> &metaTypes, const QHash<QByteArray, QByteArray> &knownQObjectClasses, const QHash<QByteArray, QByteArray> &knownGadgets, FILE *outfile)
: out(outfile), cdef(classDef), metaTypes(metaTypes), knownQObjectClasses(knownQObjectClasses) : out(outfile), cdef(classDef), metaTypes(metaTypes), knownQObjectClasses(knownQObjectClasses)
, knownGadgets(knownGadgets) , knownGadgets(knownGadgets)
{ {
@ -461,7 +461,7 @@ void Generator::generateCode()
// //
// Build extra array // Build extra array
// //
QList<QByteArray> extraList; QVector<QByteArray> extraList;
QHash<QByteArray, QByteArray> knownExtraMetaObject = knownGadgets; QHash<QByteArray, QByteArray> knownExtraMetaObject = knownGadgets;
knownExtraMetaObject.unite(knownQObjectClasses); knownExtraMetaObject.unite(knownQObjectClasses);

View File

@ -39,7 +39,7 @@ class Generator
ClassDef *cdef; ClassDef *cdef;
QVector<uint> meta_data; QVector<uint> meta_data;
public: public:
Generator(ClassDef *classDef, const QList<QByteArray> &metaTypes, const QHash<QByteArray, QByteArray> &knownQObjectClasses, const QHash<QByteArray, QByteArray> &knownGadgets, FILE *outfile = 0); Generator(ClassDef *classDef, const QVector<QByteArray> &metaTypes, const QHash<QByteArray, QByteArray> &knownQObjectClasses, const QHash<QByteArray, QByteArray> &knownGadgets, FILE *outfile = 0);
void generateCode(); void generateCode();
private: private:
bool registerableMetaType(const QByteArray &propertyType); bool registerableMetaType(const QByteArray &propertyType);
@ -64,9 +64,9 @@ private:
void strreg(const QByteArray &); // registers a string void strreg(const QByteArray &); // registers a string
int stridx(const QByteArray &); // returns a string's id int stridx(const QByteArray &); // returns a string's id
QList<QByteArray> strings; QVector<QByteArray> strings;
QByteArray purestSuperClass; QByteArray purestSuperClass;
QList<QByteArray> metaTypes; QVector<QByteArray> metaTypes;
QHash<QByteArray, QByteArray> knownQObjectClasses; QHash<QByteArray, QByteArray> knownQObjectClasses;
QHash<QByteArray, QByteArray> knownGadgets; QHash<QByteArray, QByteArray> knownGadgets;
}; };

View File

@ -65,7 +65,7 @@ struct EnumDef
{ {
QByteArray name; QByteArray name;
QByteArray enumName; QByteArray enumName;
QList<QByteArray> values; QVector<QByteArray> values;
bool isEnumClass; // c++11 enum class bool isEnumClass; // c++11 enum class
EnumDef() : isEnumClass(false) {} EnumDef() : isEnumClass(false) {}
}; };
@ -207,10 +207,10 @@ public:
bool noInclude; bool noInclude;
bool mustIncludeQPluginH; bool mustIncludeQPluginH;
QByteArray includePath; QByteArray includePath;
QList<QByteArray> includeFiles; QVector<QByteArray> includeFiles;
QVector<ClassDef> classList; QVector<ClassDef> classList;
QMap<QByteArray, QByteArray> interface2IdMap; QMap<QByteArray, QByteArray> interface2IdMap;
QList<QByteArray> metaTypes; QVector<QByteArray> metaTypes;
// map from class name to fully qualified name // map from class name to fully qualified name
QHash<QByteArray, QByteArray> knownQObjectClasses; QHash<QByteArray, QByteArray> knownQObjectClasses;
QHash<QByteArray, QByteArray> knownGadgets; QHash<QByteArray, QByteArray> knownGadgets;

View File

@ -1816,8 +1816,12 @@ QModelIndex QTableView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifi
break; break;
case MovePageUp: { case MovePageUp: {
int newRow = rowAt(visualRect(current).bottom() - d->viewport->height()); int newRow = rowAt(visualRect(current).bottom() - d->viewport->height());
if (newRow == -1) if (newRow == -1) {
newRow = d->logicalRow(0); int visualRow = 0;
while (visualRow < bottom && isRowHidden(d->logicalRow(visualRow)))
++visualRow;
newRow = d->logicalRow(visualRow);
}
return d->model->index(newRow, current.column(), d->root); return d->model->index(newRow, current.column(), d->root);
} }
case MovePageDown: { case MovePageDown: {

View File

@ -109,10 +109,11 @@ static int menuBarHeightForWidth(QWidget *menubar, int w)
/*! /*!
Constructs a new top-level QLayout, with parent \a parent. 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 The layout is set directly as the top-level layout for
returned by QWidget::layout(). \a parent. There can be only one top-level layout for a
widget. It is returned by QWidget::layout().
*/ */
QLayout::QLayout(QWidget *parent) QLayout::QLayout(QWidget *parent)
: QObject(*new QLayoutPrivate, parent) : QObject(*new QLayoutPrivate, parent)

View File

@ -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); const QRect visualRect = view->visualRect(index);
//if (index.column() == 0) const int width = visualRect.width();
//qDebug() << index << visualRect; const int height = visualRect.height();
int width = visualRect.width();
int height = visualRect.height();
for (int w = 0; w < width; ++w) if (width == 0 || height == 0)
return;
const auto widths = (width < 2) ? QVector<int>({ 0, 1 }) : QVector<int>({ 0, 1, width / 2, width - 2, width - 1 });
const auto heights = (height < 2) ? QVector<int>({ 0, 1 }) : QVector<int>({ 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); const QPoint point(visualRect.x() + w, visualRect.y() + h);
if (view->indexAt(point) != index) { const auto idxAt = view->indexAt(point);
if (idxAt != index)
qDebug() << "index" << index << "visualRect" << visualRect << point << view->indexAt(point); qDebug() << "index" << index << "visualRect" << visualRect << point << view->indexAt(point);
} QCOMPARE(idxAt, index);
QCOMPARE(view->indexAt(point), 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 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. 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(); QAbstractItemModel *currentModel = currentView->model();
@ -623,7 +626,6 @@ void tst_QItemView::indexAt()
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll); view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
view->show(); view->show();
view->setModel(treeModel); view->setModel(treeModel);
#if 0
checkChildren(view); checkChildren(view);
QModelIndex index = view->model()->index(0, 0); QModelIndex index = view->model()->index(0, 0);
@ -636,7 +638,6 @@ void tst_QItemView::indexAt()
QPoint p(1, view->height()/2); QPoint p(1, view->height()/2);
QModelIndex idx = view->indexAt(p); QModelIndex idx = view->indexAt(p);
QCOMPARE(idx, QModelIndex()); QCOMPARE(idx, QModelIndex());
#endif
} }
void tst_QItemView::scrollTo_data() void tst_QItemView::scrollTo_data()

View File

@ -1353,6 +1353,11 @@ void tst_QTableView::moveCursorBiggerJump()
QCOMPARE(view.indexAt(QPoint(0,0)), model.index(7,0)); QCOMPARE(view.indexAt(QPoint(0,0)), model.index(7,0));
QTest::keyClick(&view, Qt::Key_PageUp); QTest::keyClick(&view, Qt::Key_PageUp);
QCOMPARE(view.indexAt(QPoint(0,0)), model.index(0,0)); 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() void tst_QTableView::hideRows_data()