Error: 'GalleryTab' object has no attribute 'iconlist'

Hi,
I’m seeing a reproducible error when closing a Form and I’m interested if anyone else can reproduce this and advice on the best way to fix.

Steps to reproduce:

  1. install the Forms addon
  2. configure at least one Source to be a form
  3. create a new form
  4. in the form dialog, switch to the gallery tab
  5. add an image
  6. select the image you just added
  7. Click OK on the Form dialog

Step 6 is the critical step. If you do not select the image, there is no error.

I get the following error

2024-12-29 22:25:23.302: ERROR: grampsapp.py: line 188: Unhandled exception
Traceback (most recent call last):
  File "C:\msys64\home\steve\gramps\gramps\gui\editors\displaytabs\buttontab.py", line 320, in _selection_changed
    if self.get_selected() is not None:
       ^^^^^^^^^^^^^^^^^^^
  File "C:\msys64\home\steve\gramps\gramps\gui\editors\displaytabs\gallerytab.py", line 292, in get_selected
    node = self.iconlist.get_selected_items()
           ^^^^^^^^^^^^^
AttributeError: 'GalleryTab' object has no attribute 'iconlist'

I can reproduce the error with the official gramps 5.2.3 release and Forms addon

Here’s the call stack at the time the error is generated

get_selected (c:\msys64\home\steve\gramps\gramps\gui\editors\displaytabs\gallerytab.py:292)
_selection_changed (c:\msys64\home\steve\gramps\gramps\gui\editors\displaytabs\buttontab.py:320)
close_item (c:\msys64\home\steve\gramps\gramps\gui\managedwindow.py:219)
recursive_action (c:\msys64\home\steve\gramps\gramps\gui\managedwindow.py:209)
close_track (c:\msys64\home\steve\gramps\gramps\gui\managedwindow.py:186)
close (c:\msys64\home\steve\gramps\gramps\gui\managedwindow.py:604)
close (c:\Users\steve\AppData\Roaming\gramps\gramps52\plugins\Form\editform.py:399)
save (c:\Users\steve\AppData\Roaming\gramps\gramps52\plugins\Form\editform.py:384)
startgramps (c:\msys64\home\steve\gramps\gramps\gui\grampsgui.py:635)
run (c:\msys64\home\steve\gramps\gramps\grampsapp.py:671)
main (c:\msys64\home\steve\gramps\gramps\grampsapp.py:686)
<module> (c:\msys64\home\steve\gramps\Gramps.py:30)

The obvious fix is to add a guard against self.iconlist not existing GalleryTab.get_selected

    def get_selected(self):
        if self.iconlist:
            node = self.iconlist.get_selected_items()
            if len(node) > 0:
                path = node[0].get_indices()
                return self.media_list[path[0]]
        return None

whilst this fixes the initial problem, it then hits a similar error in buttontab.

I’m wondering if there is a deeper problem here e.g why is it triggering a selection_changed signal whilst destroying a window?

Possibly related to the Form addon being updated today to version 2.0.44 with the following?

Could it be the context changing for button bar dimming?

The gallery has some extra stuff when building its context than the other tabs. Possibly the Button problems is related to the Gallery being allowed to have pointers to invalid data. Missing target files, bad paths, missing thumbnails.

I raised this a few weeks ago

Reply was

Searching this error resulted in this
thread
which seems identical.
It is also on Mantis bugtracker with a minor rating

I chased the issue around a little but gave up because I think it
relates to the OK/Cancel Functionality of the Form.
phil

They were actually my changes but still they need ruling out. I went back to addons-source commit f4085652 (2024-11-23), which is before my changes. The problem is still reproducible. Thanks for the idea though!

Hi Phil
Thanks for the pointer. I’d not thought to check mantis! The thread is useful as it confirms the problem exists for others and is not Windows specific. It also gives a second data point to eliminate my recent changes to the Forms addon.

The fact that cancelling the Form dialog is also sufficient to cause the error also helps eliminate some code.

Additionally, the error does not exist in gramps 5.1.6.

I’ve added a note to this thread to the mantis bug as well.

Hi Steve

Had noticed the 5.1.6. working and at that point realised the issue was
as a result of the upgrade to 5.2.3 and not specifically within the
Forms code I queried the severity rating and then left it at that
My coding skills are totally inadequate for in depth looking at GRAMPS core.
Hope it can be resolved before any more upgrades.
phil

In EditForm.close(), skipping the call to self.gallery_list.clean_up() “fixes” the problem. I suspect we end up leaking \ not destroying some objects but that is just a guess.

self.gallery_list.clean_up() calls GalleryTab.clean_up() which calls GrampsTab.clean_up(). This latter method starts deleting attributes from the GalleryTab. So beyond this point, GalleryTab is partially destroyed

I’ve created a Tentative fix for crash in Form editor by stevenyoungs · Pull Request #629 · gramps-project/addons-source but it needs reviewing by a developer that understands object lifetimes to be confident I’ve not introduced a different problem!

Put in place on my test system will let you know if I have any issues
phil

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.