OpenGL: destroy QGLContext allocated by QGLContext::fromOpenGLContext

QGLContext already uses ownContext to identify when it "owns" QOpenGLContext
and will delete QOpenGLContext when needed.  In the other way
QGLContext::fromOpenGLContext creates a QGLContext for QOpenGLContext, and is
now using qGLContextDeleteFunction to identify if QOpenGLContext "owns"
QGLContext by QGLContext only passing a delete function when QOpenGLContext
should delete QGLContext, and by QOpenGLContext calling deleteQGLContext() from
destory() to do the destruction avoiding the previous leak and sometimes crash
on exit.

Change-Id: I65e791776e99b456e4d0c70fc5b5cdb33c975893
Task-number: QTBUG-40286
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
tst_QHash: check which of several equal keys is inserted

Add a test that checks that QHash keeps the first of the keys
that compare equal. This may or may not be documented, but is
inconsistent with the values in a QHash, where the last element
with equal key is kept.

Document this as a test. That way, we'll be informed when the
behavior changes (e.g. by a port to std::unordered_map).

Do the equivalent checks in tst_QMap, too. There, of course,
instead of equal keys, check equivalent ones.

Change-Id: I2c5f04f8e8a6bbc7dbaadadd878a4c876e4df042
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Do not add QOffscreenSurface windows to the global list

QOffscreenSurface has to stay usable even after returning from app.exec().
Hence close()ing the underlying hidden window, that is used on platforms that
do not provide real offscreen surfaces, is wrong.

Normally all QWindows are closed (and thus destroy()'ed) when quitting the application,
meaning the the offscreen surface cannot be made current anymore after returning
from exec(). This is an unnecessary limitation and makes certain cleanup operations
impossible.

Backport of ba79f36cb1319a279068adb6d02a8993cbc62613 from dev. This is necessary for
the 5.3 series too to avoid issues on exit in QQickWidget apps, on OS X in particular.

Task-number: QTBUG-40505
Task-number: QTBUG-39908
Change-Id: Iea1489378a18f29ff84ba8f13a6dad2d66d2b315
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>