Skip to content

allow errors to propagate past Qt, add debug logging#1448

Merged
carsen-stringer merged 1 commit intomainfrom
error_reporting
May 7, 2026
Merged

allow errors to propagate past Qt, add debug logging#1448
carsen-stringer merged 1 commit intomainfrom
error_reporting

Conversation

@mrariden
Copy link
Copy Markdown
Collaborator

@mrariden mrariden commented May 7, 2026

Qt silences exceptions originating from built in methods, (e.g. hoverEvent, keyPressEvent, etc) making debugging difficult. This PR adds a function decorator that wraps these problematic functions to guarantee exception reporting.

Current behavior reports that an error occurs to the user and the full stack trace is saved to the log in ~/.cellpose/run.log

Comment thread cellpose/gui/guiparts.py
Comment on lines +651 to +675
is_right_click = ev.button() == QtCore.Qt.RightButton
if self.parent.loaded \
and (is_right_click or ev.modifiers() & QtCore.Qt.ShiftModifier and not ev.double())\
and not self.parent.deleting_multiple:
if not self.parent.in_stroke:
ev.accept()
self.create_start(ev.pos())
self.parent.stroke_appended = False
self.parent.in_stroke = True
self.drawAt(ev.pos(), ev)
else:
ev.accept()
self.end_stroke()
self.parent.in_stroke = False
elif not self.parent.in_stroke:
y, x = int(ev.pos().y()), int(ev.pos().x())
if y >= 0 and y < self.parent.Ly and x >= 0 and x < self.parent.Lx:
if ev.button() == QtCore.Qt.LeftButton and not ev.double():
idx = self.parent.cellpix[self.parent.currentZ][y, x]
if idx > 0:
if ev.modifiers() & QtCore.Qt.ControlModifier:
# delete mask selected
self.parent.remove_cell(idx)
elif ev.modifiers() & QtCore.Qt.AltModifier:
self.parent.merge_cells(idx)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just de-indented the code's try/catch to use the function decorator instead

@carsen-stringer carsen-stringer merged commit f878e3e into main May 7, 2026
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants