소스 검색

checking that the method passed in is callable

Dave Schuyler 20 년 전
부모
커밋
5351d31c64
1개의 변경된 파일11개의 추가작업 그리고 1개의 파일을 삭제
  1. 11 1
      direct/src/showbase/Messenger.py

+ 11 - 1
direct/src/showbase/Messenger.py

@@ -54,6 +54,11 @@ class Messenger:
                                    + '\n method: ' + `method`
                                    + '\n extraArgs: ' + `extraArgs`
                                    + '\n persistent: ' + `persistent`)
+        if not callable(method):
+            self.notify.warning(
+                "method not callable in accept (ignoring): %s %s"%
+                (method, extraArgs))
+            return
 
         acceptorDict = self.__callbacks.setdefault(event, {})
         acceptorDict[object] = [method, extraArgs, persistent]
@@ -195,7 +200,12 @@ class Messenger:
                 # we have cleaned up the accept hook, because the
                 # method itself might call accept() or acceptOnce()
                 # again.
-                apply(method, (extraArgs + sentArgs))
+                if callable(method):
+                    apply(method, (extraArgs + sentArgs))
+                else:
+                    self.notify.warning(
+                        "method not callable in send: %s %s %s"%
+                        (method, extraArgs, sentArgs))
 
     def clear(self):
         """