Fix and simplify QString::mid
'position' was being used to initialize 'n' before being fully
validated. To compensate for this, the code attempted to fix 'n' once
'position' was found to be invalid (negative). This would, however, also
attempt to "fix" a perfectly valid value of 'n'.
By fully validating 'position' beforehand we avoid this trap and can
safely use it to validate and reset 'n', as needed.
Arithmetic for boundary conditions of 'n' was rearranged to avoid
triggering integer overflow.
Removed explicit check for shared_null, as the same behaviour can be
supported without it.
Change-Id: Ie9bff7b8137a74f55c7dcfe629bd569045e28f3c
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>