def close(self): ''' Overrides the QWidget.close. ''' # Unsubscribe to database events. for cls in [model.ArchitectureBlock, model.View, model.Requirement, model.Bug, model.FunctionPoint]: try: event.remove(cls, 'after_update', self.onDetailUpdate) event.remove(cls, 'after_insert', self.onDetailInsert) except sqlalchemy.exc.InvalidRequestError: # No event handlers were found: ignore. pass self.hasEvents = False ViewerWithTreeBase.close(self)