Check arguments against None in objreg.

This commit is contained in:
Florian Bruhin 2014-09-29 07:17:11 +02:00
parent 895f51083d
commit 75ba75a0d7

View File

@ -58,6 +58,11 @@ class ObjectRegistry(collections.UserDict):
Sets a slot to remove QObjects when they are destroyed.
"""
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))
if isinstance(obj, QObject):
obj.destroyed.connect(functools.partial(self.on_destroyed, name))
super().__setitem__(name, obj)