aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-03-24 01:00:15 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-03-24 01:00:15 +0100
commit73894987a22c9821c508c921f38a0db442559c71 (patch)
tree15182a0090157a9b6621e2688ca6b44963962ee6 /src
parent8aa13799516bb412908a5612da5ea5ba0972b998 (diff)
parent861f53d60cc2dd8bd8529c65863af881dbdd8db8 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Diffstat (limited to 'src')
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp8
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp2
-rw-r--r--src/qmlmodels/qqmldelegatemodel.cpp23
-rw-r--r--src/quick/items/qquicktableview.cpp41
-rw-r--r--src/quick/items/qquicktableview_p_p.h4
-rw-r--r--src/quick/items/qquickview.cpp6
6 files changed, 59 insertions, 25 deletions
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index d367edad1b..d10fad191c 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -194,8 +194,8 @@ ReturnedValue QQmlValueTypeWrapper::create(ExecutionEngine *engine, QObject *obj
r->d()->setPropertyCache(QJSEnginePrivate::get(engine)->cache(metaObject));
auto valueType = QQmlValueTypeFactory::valueType(typeId);
if (!valueType) {
- QMetaType metaType(typeId);
- return engine->throwTypeError(QLatin1String("Type %1 is not a value type").arg(metaType.name()));
+ return engine->throwTypeError(QLatin1String("Type %1 is not a value type")
+ .arg(QString::fromUtf8(QMetaType(typeId).name())));
}
r->d()->setValueType(valueType);
r->d()->setGadgetPtr(nullptr);
@@ -211,8 +211,8 @@ ReturnedValue QQmlValueTypeWrapper::create(ExecutionEngine *engine, const QVaria
r->d()->setPropertyCache(QJSEnginePrivate::get(engine)->cache(metaObject));
auto valueType = QQmlValueTypeFactory::valueType(typeId);
if (!valueType) {
- QMetaType metaType(typeId);
- return engine->throwTypeError(QLatin1String("Type %1 is not a value type").arg(metaType.name()));
+ return engine->throwTypeError(QLatin1String("Type %1 is not a value type")
+ .arg(QString::fromUtf8(QMetaType(typeId).name())));
}
r->d()->setValueType(valueType);
r->d()->setGadgetPtr(nullptr);
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 179d5314a8..416aca8667 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -1291,7 +1291,7 @@ void QQmlXMLHttpRequest::requestFromUrl(const QUrl &url)
} else {
QObject::connect(m_network, SIGNAL(readyRead()),
this, SLOT(readyRead()));
- QObject::connect(m_network, SIGNAL(error(QNetworkReply::NetworkError)),
+ QObject::connect(m_network, SIGNAL(errorOccurred(QNetworkReply::NetworkError)),
this, SLOT(error(QNetworkReply::NetworkError)));
QObject::connect(m_network, SIGNAL(finished()),
this, SLOT(finished()));
diff --git a/src/qmlmodels/qqmldelegatemodel.cpp b/src/qmlmodels/qqmldelegatemodel.cpp
index 710cc359b4..646ac5e9f9 100644
--- a/src/qmlmodels/qqmldelegatemodel.cpp
+++ b/src/qmlmodels/qqmldelegatemodel.cpp
@@ -269,13 +269,23 @@ QQmlDelegateModel::~QQmlDelegateModel()
cacheItem->contextData->invalidate();
cacheItem->contextData = nullptr;
cacheItem->scriptRef -= 1;
+ } else if (cacheItem->incubationTask) {
+ // Both the incubationTask and the object may hold a scriptRef,
+ // but if both are present, only one scriptRef is held in total.
+ cacheItem->scriptRef -= 1;
}
+
cacheItem->groups &= ~Compositor::UnresolvedFlag;
cacheItem->objectRef = 0;
+
+ if (cacheItem->incubationTask) {
+ d->releaseIncubator(cacheItem->incubationTask);
+ cacheItem->incubationTask->vdm = nullptr;
+ cacheItem->incubationTask = nullptr;
+ }
+
if (!cacheItem->isReferenced())
delete cacheItem;
- else if (cacheItem->incubationTask)
- cacheItem->incubationTask->vdm = nullptr;
}
}
@@ -641,7 +651,7 @@ QQmlDelegateModel::ReleaseFlags QQmlDelegateModel::release(QObject *item, QQmlIn
void QQmlDelegateModel::cancel(int index)
{
Q_D(QQmlDelegateModel);
- if (!d->m_delegate || index < 0 || index >= d->m_compositor.count(d->m_compositorGroup)) {
+ if (index < 0 || index >= d->m_compositor.count(d->m_compositorGroup)) {
qWarning() << "DelegateModel::cancel: index out range" << index << d->m_compositor.count(d->m_compositorGroup);
return;
}
@@ -936,15 +946,18 @@ void PropertyUpdater::breakBinding()
return;
if (updateCount == 0) {
QObject::disconnect(*it);
+ senderToConnection.erase(it);
QQmlError warning;
- warning.setUrl(qmlContext(QObject::sender())->baseUrl());
+ if (auto context = qmlContext(QObject::sender()))
+ warning.setUrl(context->baseUrl());
+ else
+ return;
auto signalName = QString::fromLatin1(QObject::sender()->metaObject()->method(QObject::senderSignalIndex()).name());
signalName.chop(sizeof("changed")-1);
QString propName = signalName;
propName[0] = propName[0].toLower();
warning.setDescription(QString::fromUtf8("Writing to \"%1\" broke the binding to the underlying model").arg(propName));
qmlWarning(this, warning);
- senderToConnection.erase(it);
} else {
--updateCount;
}
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
index 9b1704421c..cb600c7b47 100644
--- a/src/quick/items/qquicktableview.cpp
+++ b/src/quick/items/qquicktableview.cpp
@@ -493,20 +493,34 @@ QQuickTableViewAttached *QQuickTableViewPrivate::getAttachedObject(const QObject
int QQuickTableViewPrivate::modelIndexAtCell(const QPoint &cell) const
{
- int availableRows = tableSize.height();
- int modelIndex = cell.y() + (cell.x() * availableRows);
- Q_TABLEVIEW_ASSERT(modelIndex < model->count(),
- "modelIndex:" << modelIndex << "cell:" << cell << "count:" << model->count());
- return modelIndex;
+ // QQmlTableInstanceModel expects index to be in column-major
+ // order. This means that if the view is transposed (with a flipped
+ // width and height), we need to calculate it in row-major instead.
+ if (isTransposed) {
+ int availableColumns = tableSize.width();
+ return (cell.y() * availableColumns) + cell.x();
+ } else {
+ int availableRows = tableSize.height();
+ return (cell.x() * availableRows) + cell.y();
+ }
}
QPoint QQuickTableViewPrivate::cellAtModelIndex(int modelIndex) const
{
- int availableRows = tableSize.height();
- Q_TABLEVIEW_ASSERT(availableRows > 0, availableRows);
- int column = int(modelIndex / availableRows);
- int row = modelIndex % availableRows;
- return QPoint(column, row);
+ // QQmlTableInstanceModel expects index to be in column-major
+ // order. This means that if the view is transposed (with a flipped
+ // width and height), we need to calculate it in row-major instead.
+ if (isTransposed) {
+ int availableColumns = tableSize.width();
+ int row = int(modelIndex / availableColumns);
+ int column = modelIndex % availableColumns;
+ return QPoint(column, row);
+ } else {
+ int availableRows = tableSize.height();
+ int column = int(modelIndex / availableRows);
+ int row = modelIndex % availableRows;
+ return QPoint(column, row);
+ }
}
int QQuickTableViewPrivate::edgeToArrayIndex(Qt::Edge edge)
@@ -1234,12 +1248,13 @@ void QQuickTableViewPrivate::updateTableSize()
QSize QQuickTableViewPrivate::calculateTableSize()
{
+ QSize size(0, 0);
if (tableModel)
- return QSize(tableModel->columns(), tableModel->rows());
+ size = QSize(tableModel->columns(), tableModel->rows());
else if (model)
- return QSize(1, model->count());
+ size = QSize(1, model->count());
- return QSize(0, 0);
+ return isTransposed ? size.transposed() : size;
}
qreal QQuickTableViewPrivate::getColumnLayoutWidth(int column)
diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h
index a3cc39419f..93a8d839e0 100644
--- a/src/quick/items/qquicktableview_p_p.h
+++ b/src/quick/items/qquicktableview_p_p.h
@@ -278,6 +278,10 @@ public:
bool inSyncViewportPosRecursive = false;
bool inUpdateContentSize = false;
+ // isTransposed is currently only used by HeaderView.
+ // Consider making it public.
+ bool isTransposed = false;
+
QJSValue rowHeightProvider;
QJSValue columnWidthProvider;
QQuickTableSectionSizeProvider rowHeights;
diff --git a/src/quick/items/qquickview.cpp b/src/quick/items/qquickview.cpp
index 84488dcaca..5b3b954460 100644
--- a/src/quick/items/qquickview.cpp
+++ b/src/quick/items/qquickview.cpp
@@ -486,7 +486,9 @@ void QQuickView::continueExecute()
return;
}
- QObject *obj = d->initialProperties.empty() ? d->component->create() : d->component->createWithInitialProperties(d->initialProperties);
+ QScopedPointer<QObject> obj(d->initialProperties.empty()
+ ? d->component->create()
+ : d->component->createWithInitialProperties(d->initialProperties));
if (d->component->isError()) {
const QList<QQmlError> errorList = d->component->errors();
@@ -498,7 +500,7 @@ void QQuickView::continueExecute()
return;
}
- d->setRootObject(obj);
+ d->setRootObject(obj.take());
emit statusChanged(status());
}