'Register an object in the object registry.
Sets a slot to remove QObjects when they are destroyed.'

def __setitem__(self, name, obj):

    if (name is None):
        raise TypeError("Registering    '{}'    with    name    'None'!".format(obj))
    if (obj is None):
        raise TypeError("Registering    object    None    with    name    '{}'!".format(name))
    self._disconnect_destroyed(name)
    if isinstance(obj, QObject):
        func = functools.partial(self.on_destroyed, name)
        obj.destroyed.connect(func)
        self._partial_objs[name] = func
    super().__setitem__(name, obj)
