The original method for releasing the tiles is using an atomic reference counter but it is not thread safe: it is possible for a thread to release and delete the tile while the other thread accessing it, because there is an unprotected time before increasing the reference counter. The goal of this modification was to use an automatic and atomic method to reference the tile right at the moment of access.
I used QSharedPointers which are defined as thread safe. The original code used exact points where the tiles released and deleted. Since there is a delicate locking mechanism and the release of any tiles should not happen during a locked operation, I tried to keep exactly the same release points by forced releasing and clearing of the pointer instances.