Fix tst_qqmlecmascript::jsOwnedObjectsDeletedOnEngineDestroy

When destructing the JS engine and deleting the JS wrappers, we may decide
to delete the QObjects of JS owned JS QObject wrappers. During this phase
(engine destruction) we need to delete the QObject instantly instead of
deferred (the default when _running_ the engine).

* Delete the memory manager first in the ExecutionEngine destructor, as
  some of the user code destructors we may end up calling still expect
  a somewhat functioning engine unfortunately.
* Fixed also some bugs in Persistent/WeakValue: When assing a value,
  detach properly if refcount > 0
* Fixed a bug when clearing a weak value during sweep, when we wouldn't
  pick up the correct next pointer for a weak value that didn't have the mark
  bit set

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