use custom deleter for QSharedPointer to avoid the object deleted immediately

Instead of the QTimer::singleShot(0) hack