Be careful with destroyed signal

Do not dynamic cast or de-reference QObject, since object is either in destructor or may have already been destroyed.

This fixes Issue #990