minor fixes.

1. use sender instead of member variable local, which enable previous
connected local tcpsockets in case they're still in use.
2. test if qobject_cast succeed before use parent as BaseController.