diff --git a/docs/source/upcoming_release_notes/622-fix_long_pos_msg_crash.rst b/docs/source/upcoming_release_notes/622-fix_long_pos_msg_crash.rst new file mode 100644 index 00000000..2b8cd38d --- /dev/null +++ b/docs/source/upcoming_release_notes/622-fix_long_pos_msg_crash.rst @@ -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 diff --git a/typhos/positioner.py b/typhos/positioner.py index b10f405a..7e92c847 100644 --- a/typhos/positioner.py +++ b/typhos/positioner.py @@ -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 diff --git a/typhos/tests/test_positioner.py b/typhos/tests/test_positioner.py index d8fe123b..933a3a09 100644 --- a/typhos/tests/test_positioner.py +++ b/typhos/tests/test_positioner.py @@ -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 @@ -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