Skip to content

Commit

Permalink
Merge pull request #622 from ZLLentz/fix_long_pos_msg_crash
Browse files Browse the repository at this point in the history
FIX: set message crash with long error message
  • Loading branch information
ZLLentz authored Oct 11, 2024
2 parents 62aa6bc + e3c291b commit ae1d1c3
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
23 changes: 23 additions & 0 deletions docs/source/upcoming_release_notes/622-fix_long_pos_msg_crash.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
622 fix_long_pos_msg_crash
##########################

API Breaks
----------
- N/A

Features
--------
- N/A

Bugfixes
--------
- Fix an issue where long status messages from positioner widget moves
would fail to display in certain circumstances.

Maintenance
-----------
- N/A

Contributors
------------
- zllentz
2 changes: 1 addition & 1 deletion typhos/positioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ def _set_status_text(
tooltip = f"{text}: {tooltip}"
else:
tooltip = text
text = message.text[:max_length] + '...'
text = text[:max_length] + '...'
self.ui.status_label.setText(text)
if tooltip and "\n" not in tooltip:
# Force rich text, qt auto line wraps if it detects rich text
Expand Down
29 changes: 28 additions & 1 deletion typhos/tests/test_positioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from typhos.alarm import KindLevel
from typhos.positioner import TyphosPositionerWidget
from typhos.status import TyphosStatusResult
from typhos.status import TyphosStatusMessage, TyphosStatusResult
from typhos.utils import SignalRO

from .conftest import RichSignal, show_widget
Expand Down Expand Up @@ -274,3 +274,30 @@ def has_limit_error():
assert 'LimitError' in widget.ui.status_label.text()

qtbot.waitUntil(has_limit_error, timeout=1000)


@pytest.mark.no_gc
def test_positioner_widget_long_status_text(motor_widget):
_, widget = motor_widget

assert widget.ui.status_label.text() == ''

widget._set_status_text("Oh no! " * 1000, max_length=50)

text = widget.ui.status_label.text()
assert text.endswith("...")
assert len(text) < 60

widget._set_status_text("")
assert widget.ui.status_label.text() == ''

widget._set_status_text(
TyphosStatusMessage(
"Error! " * 1000,
tooltip="Test suite giant error string!",
),
max_length=50,
)
text = widget.ui.status_label.text()
assert text.endswith("...")
assert len(text) < 60

0 comments on commit ae1d1c3

Please sign in to comment.