[bugfix][referenceToSharedPtr] fix exception throw when no shared object exists.
Check the stored weak_ptr of the enable_shared_from_this class to avoid exceptions of bad_weak_ptr when it is clear that there is no weak_ptr.
Check the stored weak_ptr of the enable_shared_from_this class to avoid exceptions of bad_weak_ptr when it is clear that there is no weak_ptr.