diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/localstorage/plugin.cpp | 22 | ||||
-rw-r--r-- | src/qml/compiler/qv4isel_moth.cpp | 5 | ||||
-rw-r--r-- | src/qml/debugger/qqmlprofiler_p.h | 59 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4profiling_p.h | 5 | ||||
-rw-r--r-- | src/qml/qml/qqmlbinding.cpp | 2 | ||||
-rw-r--r-- | src/quick/doc/images/qml-localstorage-example.png | bin | 14409 -> 13957 bytes | |||
-rw-r--r-- | src/quick/doc/snippets/qml/localstorage/dbtransaction.js | 30 | ||||
-rw-r--r-- | src/quick/items/qquickevents.cpp | 2 | ||||
-rw-r--r-- | src/quick/items/qquickevents_p_p.h | 18 | ||||
-rw-r--r-- | src/quick/items/qquickitemsmodule.cpp | 9 | ||||
-rw-r--r-- | src/quick/items/qquickrendercontrol.cpp | 5 | ||||
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 1 | ||||
-rw-r--r-- | src/quick/scenegraph/coreapi/qsggeometry.cpp | 1 |
13 files changed, 102 insertions, 57 deletions
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index ebffb07346..d3ea93c80a 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -640,14 +640,32 @@ Below you will find an example of a database transaction which catches exception \snippet qml/localstorage/dbtransaction.js 0 +In the example you can see an \c insert statement where values are assigned to the fields, +and the record is written into the table. That is an \c insert statement with a syntax that is usual +for a relational database. It is however also possible to work with JSON objects and +store them in a table. + +Let's suppose a simple example where we store trips in JSON format using \c date as the unique key. +An example of a table that could be used for that purpose: + +\snippet qml/localstorage/dbtransaction.js 3 + +The assignment of values to a JSON object: + +\snippet qml/localstorage/dbtransaction.js 4 + +In that case, the data could be saved in the following way: + +\snippet qml/localstorage/dbtransaction.js 5 + \section3 db.readTransaction(callback(tx)) This method creates a read-only transaction and passed to \e callback. In this function, -you can call \e executeSql on \e tx to read the database (with SELECT statements). +you can call \e executeSql on \e tx to read the database (with \c select statements). \section3 results = tx.executeSql(statement, values) -This method executes a SQL \e statement, binding the list of \e values to SQL positional parameters ("?"). +This method executes an SQL \e statement, binding the list of \e values to SQL positional parameters ("?"). It returns a results object, with the following properties: diff --git a/src/qml/compiler/qv4isel_moth.cpp b/src/qml/compiler/qv4isel_moth.cpp index 1f5c22eb97..9dbebd1128 100644 --- a/src/qml/compiler/qv4isel_moth.cpp +++ b/src/qml/compiler/qv4isel_moth.cpp @@ -242,6 +242,11 @@ void InstructionSelection::run(int functionIndex) addInstruction(set); } exceptionHandler = _block->catchBlock; + } else if (_block->catchBlock == nullptr && _block->index() != 0 && _block->in.isEmpty()) { + exceptionHandler = nullptr; + Instruction::SetExceptionHandler set; + set.offset = 0; + addInstruction(set); } for (IR::Stmt *s : _block->statements()) { diff --git a/src/qml/debugger/qqmlprofiler_p.h b/src/qml/debugger/qqmlprofiler_p.h index 242f26ee0d..3a507bef74 100644 --- a/src/qml/debugger/qqmlprofiler_p.h +++ b/src/qml/debugger/qqmlprofiler_p.h @@ -149,40 +149,38 @@ class Q_QML_PRIVATE_EXPORT QQmlProfiler : public QObject, public QQmlProfilerDef Q_OBJECT public: - class BindingRefCount : public QQmlRefCount { + class FunctionRefCount : public QQmlRefCount { public: - BindingRefCount(QQmlBinding *binding): - m_binding(binding) + FunctionRefCount(QV4::Function *function): + m_function(function) { - m_binding->ref.ref(); + m_function->compilationUnit->addref(); } - BindingRefCount(const BindingRefCount &other) : - QQmlRefCount(other), m_binding(other.m_binding) + FunctionRefCount(const FunctionRefCount &other) : + QQmlRefCount(other), m_function(other.m_function) { - m_binding->ref.ref(); + m_function->compilationUnit->addref(); } - BindingRefCount &operator=(const BindingRefCount &other) + FunctionRefCount &operator=(const FunctionRefCount &other) { if (this != &other) { QQmlRefCount::operator=(other); - other.m_binding->ref.ref(); - if (!m_binding->ref.deref()) - delete m_binding; - m_binding = other.m_binding; + other.m_function->compilationUnit->addref(); + m_function->compilationUnit->release(); + m_function = other.m_function; } return *this; } - ~BindingRefCount() + ~FunctionRefCount() { - if (!m_binding->ref.deref()) - delete m_binding; + m_function->compilationUnit->release(); } private: - QQmlBinding *m_binding; + QV4::Function *m_function; }; struct Location { @@ -199,14 +197,10 @@ public: RefLocation() : Location(), locationType(MaximumRangeType), ref(nullptr), sent(false) {} - RefLocation(QQmlBinding *binding, QV4::FunctionObject *function) : + RefLocation(QV4::Function *function) : Location(function->sourceLocation()), locationType(Binding), - ref(new BindingRefCount(binding), QQmlRefPointer<QQmlRefCount>::Adopt), sent(false) - {} - - RefLocation(QQmlBinding *binding, QV4::Function *function) : - Location(function->sourceLocation()), locationType(Binding), - ref(new BindingRefCount(binding), QQmlRefPointer<QQmlRefCount>::Adopt), sent(false) + ref(new FunctionRefCount(function), + QQmlRefPointer<QQmlRefCount>::Adopt), sent(false) {} RefLocation(QV4::CompiledData::CompilationUnit *ref, const QUrl &url, const QV4::CompiledData::Object *obj, @@ -236,16 +230,21 @@ public: typedef QHash<quintptr, Location> LocationHash; - void startBinding(QQmlBinding *binding, QV4::Function *function) + void startBinding(QV4::Function *function) { - quintptr locationId(id(binding)); + // Use the QV4::Function as ID, as that is common among different instances of the same + // component. QQmlBinding is per instance. + // Add 1 to the ID, to make it different from the IDs the V4 profiler produces. The +1 makes + // the pointer point into the middle of the QV4::Function. Thus it still points to valid + // memory but we cannot accidentally create a duplicate key from another object. + quintptr locationId(id(function) + 1); m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(), (1 << RangeStart | 1 << RangeLocation), Binding, locationId)); RefLocation &location = m_locations[locationId]; if (!location.isValid()) - location = RefLocation(binding, function); + location = RefLocation(function); } // Have toByteArrays() construct another RangeData event from the same QString later. @@ -281,7 +280,8 @@ public: Creating, id(obj))); } - void updateCreating(const QV4::CompiledData::Object *obj, QV4::CompiledData::CompilationUnit *ref, + void updateCreating(const QV4::CompiledData::Object *obj, + QV4::CompiledData::CompilationUnit *ref, const QUrl &url, const QString &type) { quintptr locationId(id(obj)); @@ -330,12 +330,11 @@ struct QQmlProfilerHelper : public QQmlProfilerDefinitions { }; struct QQmlBindingProfiler : public QQmlProfilerHelper { - QQmlBindingProfiler(QQmlProfiler *profiler, QQmlBinding *binding, - QV4::Function *function) : + QQmlBindingProfiler(QQmlProfiler *profiler, QV4::Function *function) : QQmlProfilerHelper(profiler) { Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileBinding, profiler, - startBinding(binding, function)); + startBinding(function)); } ~QQmlBindingProfiler() diff --git a/src/qml/jsruntime/qv4profiling_p.h b/src/qml/jsruntime/qv4profiling_p.h index d27e853343..f75ac4d33a 100644 --- a/src/qml/jsruntime/qv4profiling_p.h +++ b/src/qml/jsruntime/qv4profiling_p.h @@ -158,12 +158,11 @@ public: FunctionCall &operator=(const FunctionCall &other) { if (&other != this) { - if (m_function) - m_function->compilationUnit->release(); + other.m_function->compilationUnit->addref(); + m_function->compilationUnit->release(); m_function = other.m_function; m_start = other.m_start; m_end = other.m_end; - m_function->compilationUnit->addref(); } return *this; } diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index 284ae1f36f..62288a5845 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -163,7 +163,7 @@ void QQmlBinding::update(QQmlPropertyData::WriteFlags flags) if (canUseAccessor()) flags.setFlag(QQmlPropertyData::BypassInterceptor); - QQmlBindingProfiler prof(ep->profiler, this, function()); + QQmlBindingProfiler prof(ep->profiler, function()); doUpdate(watcher, flags, scope); if (!watcher.wasDeleted()) diff --git a/src/quick/doc/images/qml-localstorage-example.png b/src/quick/doc/images/qml-localstorage-example.png Binary files differindex e128574683..64e1cb0315 100644 --- a/src/quick/doc/images/qml-localstorage-example.png +++ b/src/quick/doc/images/qml-localstorage-example.png diff --git a/src/quick/doc/snippets/qml/localstorage/dbtransaction.js b/src/quick/doc/snippets/qml/localstorage/dbtransaction.js index 40eb6d2804..38733a8e2c 100644 --- a/src/quick/doc/snippets/qml/localstorage/dbtransaction.js +++ b/src/quick/doc/snippets/qml/localstorage/dbtransaction.js @@ -43,11 +43,11 @@ var db = LocalStorage.openDatabaseSync("ActivityTrackDB", "", "Database tracking db.transaction( try { function(tx) { - tx.executeSql('INSERT INTO trip_log VALUES(?, ?, ?)', - [ '01/10/2016','Sylling - Vikersund', '53' ]); + tx.executeSql("INSERT INTO trip_log VALUES(?, ?, ?)", + [ "01/10/2016","Sylling - Vikersund", "53" ]); } } catch (err) { - console.log("Error inserting into table Greeting: " + err); + console.log("Error inserting into table trip_log: " + err); } ) //![0] @@ -60,11 +60,11 @@ function db_distance_select(Pdistance) var db = LocalStorage.openDatabaseSync("ActivityTrackDB", "", "Database tracking sports activities", 1000000); db.transaction( function(tx) { - var results = tx.executeSql('SELECT rowid, + var results = tx.executeSql("SELECT rowid, date, trip_desc, distance FROM trip_log - where distance >= ?',[Pdistance]'); + where distance >= ?",[Pdistance]); for (var i = 0; i < results.rows.length; i++) { listModel.append({"id": results.rows.item(i).rowid, "date": results.rows.item(i).date, @@ -76,10 +76,22 @@ db.transaction( //![1] //![2] var db = LocalStorage.openDatabaseSync("ActivityTrackDB", "", "Database tracking sports activities", 1000000); -if (db.version == '0.1') { - db.changeVersion('0.1', '0.2', function(tx) { - tx.executeSql('INSERT INTO trip_log VALUES(?, ?, ?)', - [ '01/10/2016','Sylling - Vikersund', '53' ]); +if (db.version == "0.1") { + db.changeVersion("0.1", "0.2", function(tx) { + tx.executeSql("INSERT INTO trip_log VALUES(?, ?, ?)", + [ "01/10/2016","Sylling - Vikersund", "53" ]); } }); //![2] +//![3] +create table trip_log(date text, data text) +//![3] +//![4] +var obj = {description = "Vikersund - Noresund", distance = "60"} +//![4] +//![5] +db.transaction(function(tx) { + result = tx.executeSQL("insert into trip_log values (?,?)", + ["01/11/2016", JSON.stringify(obj)]) +} +//![5] diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index 42588fd058..2fad9f5a8d 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -552,7 +552,7 @@ void QQuickEventTouchPoint::reset(const QTouchEvent::TouchPoint &tp, ulong times QQuickEventPoint::reset(tp.state(), tp.scenePos(), tp.id(), timestamp); m_rotation = tp.rotation(); m_pressure = tp.pressure(); -// m_uniqueId = tp.uniqueId(); + m_uniqueId = tp.uniqueId(); } /*! diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h index 6179791413..7b281623fe 100644 --- a/src/quick/items/qquickevents_p_p.h +++ b/src/quick/items/qquickevents_p_p.h @@ -302,8 +302,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickEventTouchPoint : public QQuickEventPoint Q_OBJECT Q_PROPERTY(qreal rotation READ rotation) Q_PROPERTY(qreal pressure READ pressure) -// TODO rename to QPointingDeviceUniqueId -// Q_PROPERTY(QPointerUniqueId uniqueId READ uniqueId) + Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId) public: QQuickEventTouchPoint(QQuickPointerTouchEvent *parent); @@ -312,12 +311,12 @@ public: qreal rotation() const { return m_rotation; } qreal pressure() const { return m_pressure; } -// QPointerUniqueId uniqueId() const { return m_uniqueId; } + QPointingDeviceUniqueId uniqueId() const { return m_uniqueId; } private: qreal m_rotation; qreal m_pressure; -// QPointerUniqueId m_uniqueId; + QPointingDeviceUniqueId m_uniqueId; Q_DISABLE_COPY(QQuickEventTouchPoint) }; @@ -451,7 +450,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointerDevice : public QObject Q_PROPERTY(int maximumTouchPoints READ maximumTouchPoints CONSTANT) Q_PROPERTY(int buttonCount READ buttonCount CONSTANT) Q_PROPERTY(QString name READ name CONSTANT) - Q_PROPERTY(qint64 uniqueId READ uniqueId CONSTANT) + Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId CONSTANT) public: enum DeviceType { @@ -498,7 +497,8 @@ public: QQuickPointerDevice(DeviceType devType, PointerType pType, Capabilities caps, int maxPoints, int buttonCount, const QString &name, qint64 uniqueId = 0) : m_deviceType(devType), m_pointerType(pType), m_capabilities(caps) - , m_maximumTouchPoints(maxPoints), m_buttonCount(buttonCount), m_name(name), m_uniqueId(uniqueId), m_event(nullptr) + , m_maximumTouchPoints(maxPoints), m_buttonCount(buttonCount), m_name(name) + , m_uniqueId(QPointingDeviceUniqueId::fromNumericId(uniqueId)), m_event(nullptr) { if (m_deviceType == Mouse) { m_event = new QQuickPointerMouseEvent; @@ -517,7 +517,7 @@ public: int maximumTouchPoints() const { return m_maximumTouchPoints; } int buttonCount() const { return m_buttonCount; } QString name() const { return m_name; } - qint64 uniqueId() const { return m_uniqueId; } + QPointingDeviceUniqueId uniqueId() const { return m_uniqueId; } QQuickPointerEvent *pointerEvent() const { return m_event; } static QQuickPointerDevice *touchDevice(QTouchDevice *d); @@ -532,7 +532,7 @@ private: int m_maximumTouchPoints; int m_buttonCount; QString m_name; - qint64 m_uniqueId; + QPointingDeviceUniqueId m_uniqueId; // the device-specific event instance which is reused during event delivery QQuickPointerEvent *m_event; @@ -555,7 +555,7 @@ QML_DECLARE_TYPE(QQuickMouseEvent) QML_DECLARE_TYPE(QQuickWheelEvent) QML_DECLARE_TYPE(QQuickCloseEvent) QML_DECLARE_TYPE(QQuickPointerDevice) -//QML_DECLARE_TYPE(QPointerUniqueId) +QML_DECLARE_TYPE(QPointingDeviceUniqueId) QML_DECLARE_TYPE(QQuickPointerEvent) #endif // QQUICKEVENTS_P_P_H diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp index dbe30fbc83..b0ddbb0034 100644 --- a/src/quick/items/qquickitemsmodule.cpp +++ b/src/quick/items/qquickitemsmodule.cpp @@ -298,8 +298,10 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor) qmlRegisterType<QQuickGrid, 1>(uri, 2, 1, "Grid"); #endif #if QT_CONFIG(quick_itemview) - qmlRegisterUncreatableType<QQuickItemView, 1>(uri, 2, 1, "ItemView", QQuickItemView::tr("ItemView is an abstract base class")); - qmlRegisterUncreatableType<QQuickItemView, 2>(uri, 2, 3, "ItemView", QQuickItemView::tr("ItemView is an abstract base class")); + const char *itemViewName = "ItemView"; + const QString itemViewMessage = QQuickItemView::tr("ItemView is an abstract base class"); + qmlRegisterUncreatableType<QQuickItemView, 1>(uri, 2, 1, itemViewName, itemViewMessage); + qmlRegisterUncreatableType<QQuickItemView, 2>(uri, 2, 3, itemViewName, itemViewMessage); #endif #if QT_CONFIG(quick_listview) qmlRegisterType<QQuickListView, 1>(uri, 2, 1, "ListView"); @@ -361,6 +363,9 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor) #if QT_CONFIG(quick_pathview) qmlRegisterType<QQuickPathView, 7>(uri, 2, 7, "PathView"); #endif +#if QT_CONFIG(quick_itemview) + qmlRegisterUncreatableType<QQuickItemView, 7>(uri, 2, 7, itemViewName, itemViewMessage); +#endif qmlRegisterUncreatableType<QQuickMouseEvent, 7>(uri, 2, 7, nullptr, QQuickMouseEvent::tr("MouseEvent is only available within handlers in MouseArea")); diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp index 13e13890b7..03d96aea1f 100644 --- a/src/quick/items/qquickrendercontrol.cpp +++ b/src/quick/items/qquickrendercontrol.cpp @@ -380,6 +380,9 @@ QImage QQuickRenderControl::grab() if (d->window->rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL) { #if QT_CONFIG(opengl) + QQuickWindowPrivate *cd = QQuickWindowPrivate::get(d->window); + cd->polishItems(); + cd->syncSceneGraph(); render(); grabContent = qt_gl_read_framebuffer(d->window->size() * d->window->effectiveDevicePixelRatio(), false, false); #endif @@ -394,6 +397,8 @@ QImage QQuickRenderControl::grab() QPaintDevice *prevDev = softwareRenderer->currentPaintDevice(); softwareRenderer->setCurrentPaintDevice(&grabContent); softwareRenderer->markDirty(); + cd->polishItems(); + cd->syncSceneGraph(); render(); softwareRenderer->setCurrentPaintDevice(prevDev); } diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index 6771c0e940..6db96f369c 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -898,6 +898,7 @@ void Renderer::map(Buffer *buffer, int byteSize, bool isIndexBuf) } else if (buffer->size != byteSize) { free(buffer->data); buffer->data = (char *) malloc(byteSize); + Q_CHECK_PTR(buffer->data); } buffer->size = byteSize; } diff --git a/src/quick/scenegraph/coreapi/qsggeometry.cpp b/src/quick/scenegraph/coreapi/qsggeometry.cpp index a278c6079b..69a8c21ed2 100644 --- a/src/quick/scenegraph/coreapi/qsggeometry.cpp +++ b/src/quick/scenegraph/coreapi/qsggeometry.cpp @@ -675,6 +675,7 @@ void QSGGeometry::allocate(int vertexCount, int indexCount) Q_ASSERT(m_index_type == UnsignedIntType || m_index_type == UnsignedShortType); int indexByteSize = indexCount * (m_index_type == UnsignedShortType ? sizeof(quint16) : sizeof(quint32)); m_data = (void *) malloc(vertexByteSize + indexByteSize); + Q_CHECK_PTR(m_data); m_index_data_offset = vertexByteSize; m_owns_data = true; } |