Use stable sort when cleaning batches.

Ensure valid batches do not change order. This was causing rendering
issues when m_rebuild was 0, as we would not re-sort the list in correct
render order after cleanup.

Change-Id: I912fb313d4029f96e263fad24d68462f252003df
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Fix crash on shutdown with states

When populating deferred properties, we must not set the rootObjectInCreation
flags on the root context and (consequently) on any sub-objects objects created
when initializing deferred properties. Doing so otherwise will end up us
incorrectly linking QQmlContextData together, causing QQmlData::linkedContext
to point to iself and crash on exit upon deletion.

Task-number: QTBUG-37484
Change-Id: Ia5dc92a04e0f66499f15fbac10f14859d387b021
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Fix crash when calling concat on an empty array

Make sure to create the array data. The earlier called copyArrayData()
doesn't have to do that.

Task-number: QTBUG-37506
Change-Id: I6671769fcd471234c4c2eaa1614aa61266db0e5c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Canvas: do not emit paint when resized but hidden

It turns out to be a bad idea (as in, breaks the enterprise controls)
to block paint() altogether when hidden. The original bug report
QTBUG-31830 only complained about paint() being emitted upon resize
while _hidden_, so this change solves exactly that. User is still
free to call requestPaint() even when hidden, and Canvas now doesn't
recklessly ignore the request.

Task-number: QTBUG-31830
Change-Id: Icd82188f65406b3ef6ae3b19b5984944576886ff
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Unset the current gl window when deleted

This does in the QSGGuiThreadRenderLoop what 403045a did for the
QSGThreadedRenderLoop. Fix a memory corruption in Mesa's dri2 EGL
when setting a window current after deleting the previous current
one.

Change-Id: I8df0bacdf12f71e969a9ea39842a402c9a2a303f
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Add docs on using a query in XMLRole with the less obvious boolean()

Added to a documentation snippet since a direct boolean map is useful
in QML for toggles and using "@wanted/boolean()" as the @type example
does, would be wrong.

Change-Id: If412ec0f4891db39fe1a219f9cb89e1f7103fd38
Signed-off-by: David Greaves <david@dgreaves.com>
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Reviewed-by: Martin Smith <martin.smith@digia.com>
Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
qv4isel_moth.cpp: Fix MSVC-warnings about operator unary minus applied to unsigned.

compiler\qv4isel_moth.cpp(1041) : warning C4146: unary minus operator applied to  unsigned type, result still unsigned
compiler\qv4isel_moth.cpp(1056) : warning C4146: unary minus operator applied to  unsigned type, result still unsigned
compiler\qv4isel_moth.cpp(1096) : warning C4146: unary minus operator applied to  unsigned type, result still unsigned

Change-Id: Idb4714a277486ff736f49c50c7e840fd62e2150f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Fix context creation failure message.

Add missing newline, fix placeholders in translator's comment.

Change-Id: If80d237a97096a319a67da4c75c5e32c47576aee
Reviewed-by: Robert Loehning <robert.loehning@digia.com>
Suppress implicit sign conversion warnings in public API

Suppres implicit sign conversion warnings when compiling with the
-wsign-conversion flag.
E.g. “qqml.h:235:5: warning: implicit conversion changes signedness:
'const int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]”

Change-Id: I7a51c51609c39f2431acb95febed6bb741f3c09c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Fix AnimatedSprite interpolation when looping and/or reversing.

Ensure we interpolate in the correct direction, and that interpolation
occurs between loops.

Task-number: QTBUG-36339
Task-number: QTBUG-36340
Change-Id: Iccb097e6a9af9fa6697e2ba9ee852be9eb516edc
Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
Fix potential crash during shutdown for QQuickWindows

The cleanup() function would deregister the render loop from all
windows the render loop had seen, but the render loop doesn't see
windows until the window gets a showEvent and for some implementations
it was removed as a result of hideEvent. So add explicit tracking to
QSGRenderLoop which is managed by QQuickWindow's constructor and
destructor. With this, we no longer need the lists from the
subclasses, so these functions are removed again.

Change-Id: I05e5507ad57e23c80bacd99752654cc7d0890dc1
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Fix crash with lazy binding initialization and compile time calculated dependencies

During lazy binding initialization we may execute bindings where we calculated
dependencies to the context object at compile time. In order to register those
dependencies, the contet object needs to be set in the QQmlContextData.

This patch makes sure to set it before setting up the bindings.

Change-Id: Iacd360140cd9c389487bda82f6a7e6cc3a44c154
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Stabilize tst_qquickwindow and tst_scenegraph.

Change-Id: I6f1b6c0ed86869149658e3ce07545217ce9797a7
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Namespace cleanup

Move the QML IR types into the QmlIR namespace and clean them up.

Change-Id: I2125449e5a519034e23670651efa620f405730b4
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Use QUrl::toLocalFile() when decoding a string URL

Some percent-decoded characters may still be present in the string URL,
so it is best to use QUrl::toLocalFile() to process the string properly.
This also makes some drive handling "magic" obselete as QUrl already
handles this.

This fixes an issue whereby QML apps residing in local paths requiring
percent-encoded characters (or which import local file URLs with
percent-encoded characters) would fail to load, as the path was passed
to the file system engine without fully decoding the URL.

Change-Id: I8ec2b06f0661e0ac7cc9df79d35ec5cee211f672
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Cleanup, part 2

* QQmlCodeGenerator -> QQmlIR::IRBuilder (it doesn't generate code, it
generates the Object/Property/Signal/etc. IR of the .qml file, that's
going to get transformed to QV4::CompiledData::*)

* ParsedQML -> QQmlIR::Document

Change-Id: I329e858487b66e1ae528d44316761f5dd34b79f4
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Item views: improve initial Z-value handling

Respect the initial Z-values of item, highlight, header, footer and
section delegate instances. Mention also the default values in docs.

Change-Id: I2ce4bb537898a0f5fdfa776b79d5747b1c080a7b
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
Minor optimization: Avoid some QString constructors

Change-Id: I51af67e9ba4076216142e05b5de5b2e8f8c526bc
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Add some specialized lookups for two internal classes

Some methods are being called with two different types of objects,
alternating between them. This adds a specialized lookup for that
case. Speeds up the splay test by ~20%.

Also create a clean path to a fallback lookup instead of going back
to the generic lookup and then alternating.

Change-Id: I3082d70d27155ef5f2cf2b680d227c6dd389956d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Small optimization to RegExp

Also add markObjects() calls to all the identifiers we keep
around in the engine. It's probably pure luck this hasn't caused
any issues until now.

Change-Id: Ie31d19793efa53867e4e240ba548070dcde32ec1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>