def _invoke_callback(self, cb, event): try: cb(event) except Exception: _handle_exception(self.ignore_callback_errors, self.print_callback_errors, self, cb_event=(cb, event))
def _invoke_callback(self, cb: Union[Callback, Callable[[], None]], event: Optional[Event]): try: if event is not None: cb(event) else: cb() except Exception as e: # dead Qt object with living python pointer. not importing Qt # here... but this error is consistent across backends if (isinstance(e, RuntimeError) and 'C++' in str(e) and str(e).endswith( ('has been deleted', 'already deleted.'))): self.disconnect(cb) return _handle_exception( self.ignore_callback_errors, self.print_callback_errors, self, cb_event=(cb, event), )