Make sure texture factories are delete before libraries are unloaded.

Because scene graph adaptations and custom implementations can
instantiate QQuickTextureFactories, we need to make sure that
their destructors are called before their libraries are unloaded
to avoid crashes on shutdown.

Change-Id: I17d38e2909aabcb4ea7bf4eecc29df86c8479fdb
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Handle scene graph invalidation

Change-Id: Icff592a4ae48444a36406a65c1c04a3a6da77616
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Fix use-after-free in testcase.

The call to setActive does a deleteLater on the window. Then the QTRY_*
macros run the event loop, thereby deleting the window. So, after
wrapping the window in a QPointer, that pointer must either be null, or
the window shouldn't be visible.

Change-Id: Ib3fc5c5284bd5dae378a0f6a17117b262b9a3687
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
MultiPointTouchArea: Guard _mouseTouchPoint with a QPointer.

The touch point can be deleted (for instance, on ungrab()) without
_mouseTouchPoint being reset occurs.

This caused a crash on tst_qquickmultipointtoucharea::inFlickable with
MallocScribble=1 enabled on OS X (use-after-free).

Change-Id: Ife9f59d75827285b18bb1772ddbee30d79a3f0b5
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>