From 564a9cc6599047ec2a292a9a6c419c9038eed94f Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Mon, 17 Jun 2024 15:00:07 +0800 Subject: [PATCH 1/3] Catch an error that is reported, but silently ignored during CI testing. --- winforms/src/toga_winforms/widgets/table.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/winforms/src/toga_winforms/widgets/table.py b/winforms/src/toga_winforms/widgets/table.py index bb4689f7d1..eaeca19b28 100644 --- a/winforms/src/toga_winforms/widgets/table.py +++ b/winforms/src/toga_winforms/widgets/table.py @@ -173,9 +173,14 @@ def text(attr): # TODO: ListView only has built-in support for one icon per row. One possible # workaround is in https://stackoverflow.com/a/46128593. - icon = icon(self._accessors[0]) - if icon is not None: - lvi.ImageIndex = self._image_index(icon) + try: + icon = icon(self._accessors[0]) + except IndexError: + # There's no _accessors, so there's no icon. + pass + else: + if icon is not None: + lvi.ImageIndex = self._image_index(icon) return lvi From 634043292298b5b6938cb144eaae7cd32f0d229c Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Mon, 17 Jun 2024 15:03:39 +0800 Subject: [PATCH 2/3] Add changenote. --- changes/2665.misc.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/2665.misc.rst diff --git a/changes/2665.misc.rst b/changes/2665.misc.rst new file mode 100644 index 0000000000..0161579c1e --- /dev/null +++ b/changes/2665.misc.rst @@ -0,0 +1 @@ +An error raised and ignored during testbed testing on Winforms was silenced. From fac654a9c65632a068f04db8e7fba6a4fde7d71e Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Wed, 19 Jun 2024 09:28:51 +0800 Subject: [PATCH 3/3] Ask permission, not forgiveness. --- winforms/src/toga_winforms/widgets/table.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/winforms/src/toga_winforms/widgets/table.py b/winforms/src/toga_winforms/widgets/table.py index eaeca19b28..242ac7be5f 100644 --- a/winforms/src/toga_winforms/widgets/table.py +++ b/winforms/src/toga_winforms/widgets/table.py @@ -171,14 +171,11 @@ def text(attr): [text(attr) for attr in self._accessors], ) - # TODO: ListView only has built-in support for one icon per row. One possible - # workaround is in https://stackoverflow.com/a/46128593. - try: + # If the table has accessors, populate the icons for the table. + if self._accessors: + # TODO: ListView only has built-in support for one icon per row. One possible + # workaround is in https://stackoverflow.com/a/46128593. icon = icon(self._accessors[0]) - except IndexError: - # There's no _accessors, so there's no icon. - pass - else: if icon is not None: lvi.ImageIndex = self._image_index(icon)