Fix small bug in array sorting

Task-number: QTBUG-34321

Change-Id: I33089499f730bce16a9dfdda04cc8402602bc5fa
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Make sure we clean up GL resources before we delete the GL context.

Task-number: QTBUG-34806
Change-Id: I5013baaff0ca86357292474976944c1a3056f219
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>