Add skeleton unit tests for QEntity and QAspectEngine

QAspectEngine is crashing upon shutdown so adding a test case to
investigate. Without a root entity set we just get warnings about
threads being killed whilst still running. With a root entity set, it
crashes. Need to solve these before we can test any more work towards
a clean shutdown. Next commit solves the crash so merge it together
with this one.

Change-Id: Ic90c0f130ed48b418bb376b38eb10f23ea90590e
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Shutdown the aspect engine before destruction

This solves the crash when deleting an aspect engine with a root entity.

Change-Id: I90cdf04d23e9942e8c764f29c92a76de90debc25
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
d-pointer QRenderAspect

Also save work on subsequent calls to onInitialize().

Change-Id: Ia2074743f8d71a5b5a6c35d9dab3589ce7695b99
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Cleanly exit the render thread

We have to mutex protect accesses to the m_surface variable in the
Renderer as the main thread may call destroy() on the corresponding
QWindow. This can happen in response to the window being closed or
changing QScreens.

Calling swapBuffers() on a QSurface that has been destroyed does not
fail gracefully but crashes. This change works around this by using
the new QPlatformSurfaceEvent in QtGui which is sent to the window
or offsceen surface when the platform surface has been created or
is about to be destroyed.

This event is used to inform the renderer to stop rendering to the
window surface in a safe manner, before the native surface gets
destroyed.

The Renderer::submitRenderViews() now checks at the start of each
frame that the m_surface is still valid.

There is still another crash at shutdown if applications are
sending a lot of updates to the backend.

Change-Id: I742226c7ae8f657e218cbcd45f0dff3d2b7bcc18
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>