Skip to content

Conversation

stevenyoungs
Copy link
Contributor

Fix EditNote so that it passes the object when calling the callback function, rather than the object handle.
Fixes the error described in 13702 and gives consistency with other Edit classes.

To reproduce:

  1. create a new note- type "a"
  2. select "a" and click the Link button
  3. Change the Link Type to Note and click New
  4. type "a" and click ok

Related bugs:

Reviewed and adjusted other places that create an EditNote instance with callback
Reviewed and adjusted other places that call NoteTab.add_callback

This was originally PR #2070 merged into 6.0.2
Rolled back in 6.0.3 due to #13884

This gives consistency with other Edit classes.
Adjust other code accordingly.

Fixes #13702, #13884.
@hgohel
Copy link
Member

hgohel commented Jun 21, 2025

Given the regression in 6.0.3, for safety let's be more explicit about testing. For example the steps from #13884

Select a person. Open it.
Select the "Notes" tab.
Try to pick an existing note to attach to that person
(should not result in an unhandled exception)

@DaveSch-gramps
Copy link
Contributor

6.0.3 on Win10

I tested these changes and it works. A new Note added to be used as the Link in a Note record works with no error.

I double checked that #13884 remained good and it did.

Then had the question... did the adding a new object to be used in a note link work for all other objects?

When adding a new object for a link worked in all other objects except when adding a new Citation.

7930521: ERROR: grampsapp.py: line 188: Unhandled exception
Traceback (most recent call last):
  File "C:\Program Files\GrampsAIO64-6.0.3\gramps\gui\editors\editcitation.py", line 402, in save
    self.callback(self.obj.get_handle())
  File "C:\Program Files\GrampsAIO64-6.0.3\gramps\gui\editors\editlink.py", line 159, in _on_new_callback
    self.selected.set_text(self.display_link(object_class, "handle", obj.handle))
                                                                     ^^^^^^^^^^
AttributeError: 'str' object has no attribute 'handle'

@Nick-Hall
Copy link
Member

Changing the pubic API is also likely to cause third-party addons to crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants