Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmm crash fix #478

Merged
merged 2 commits into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,10 @@ def __init__(self, parent, kicad_provider=KicadProvider()):

def quit_dialog(self, *_):
"""Destroy dialog on close."""
root = logging.getLogger()
root.removeHandler(self.logging_handler1)
root.removeHandler(self.logging_handler2)

self.Destroy()
self.EndModal(0)

Expand Down Expand Up @@ -1096,19 +1100,19 @@ def init_logger(self):
root = logging.getLogger()
root.setLevel(logging.DEBUG)
# Log to stderr
handler1 = logging.StreamHandler(sys.stderr)
handler1.setLevel(logging.DEBUG)
self.logging_handler1 = logging.StreamHandler(sys.stderr)
self.logging_handler1.setLevel(logging.DEBUG)
# and to our GUI
handler2 = LogBoxHandler(self.logbox, self)
handler2.setLevel(logging.DEBUG)
self.logging_handler2 = LogBoxHandler(self)
self.logging_handler2.setLevel(logging.DEBUG)
formatter = logging.Formatter(
"%(asctime)s - %(levelname)s - %(funcName)s - %(message)s",
datefmt="%Y.%m.%d %H:%M:%S",
)
handler1.setFormatter(formatter)
handler2.setFormatter(formatter)
root.addHandler(handler1)
root.addHandler(handler2)
self.logging_handler1.setFormatter(formatter)
self.logging_handler2.setFormatter(formatter)
root.addHandler(self.logging_handler1)
root.addHandler(self.logging_handler2)
self.logger = logging.getLogger(__name__)

def __del__(self):
Expand All @@ -1119,9 +1123,8 @@ def __del__(self):
class LogBoxHandler(logging.StreamHandler):
"""Logging class for the logging textbox at th ebottom of the mainwindow."""

def __init__(self, textctrl, event_destination):
def __init__(self, event_destination):
logging.StreamHandler.__init__(self)
self.textctrl = textctrl
self.event_destination = event_destination

def emit(self, record):
Expand Down