Skip to content

Commit

Permalink
Fix problem with Page.delete_widget().
Browse files Browse the repository at this point in the history
Addresses #3216.
  • Loading branch information
julian-smith-artifex-com committed Mar 1, 2024
1 parent a868c0a commit 62f0d3a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1698,7 +1698,6 @@ def delete_widget(page: fitz.Page, widget: fitz.Widget) -> fitz.Widget:
raise ValueError("bad type: widget")
nextwidget = widget.next
page.delete_annot(annot)
widget._annot.__del__()
widget._annot.parent = None
keylist = list(widget.__dict__.keys())
for key in keylist:
Expand Down
14 changes: 9 additions & 5 deletions tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,15 @@ def test_2391():
field_field_value = field.on_state()
field.update()

# def test_deletewidget():
# pdf = fitz.open(filename)
# page = pdf[0]
# field = page.first_widget
# page.delete_widget(field)
def test_3216():
document = fitz.open(filename)
for page in document:
while 1:
w = page.first_widget
print(f'{w=}')
if not w:
break
page.delete_widget(w)


def test_add_widget():
Expand Down

0 comments on commit 62f0d3a

Please sign in to comment.