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:
install the Forms addon
configure at least one Source to be a form
create a new form
in the form dialog, switch to the gallery tab
add an image
select the image you just added
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?
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.
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.
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