The existing overload unconditionally copies the QVariant, causing it
to unconditional detach in most cases (when calling data() later).
The rvalue overload need not preserve the source object, so doesn't
need to copy.
Implement the lvalue overload in terms of the rvalue one, but keep the
sanity check in both to avoid copying the QVariant just to find that
there's nothing to do.
Following the copy, there were some references to the source object,
but they can all be replaced by references to the target object
instead, which hasn't been touched by then, yet.
[ChangeLog][QtCore][QMetaProperty] Added write() overload taking an
rvalue QVariant.
Fixes: QTBUG-112762
Change-Id: I0a8a91aa32143f071ebc8dae8f1f64b07fad9764
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>