From f0edb5bace93abfe34e6f52b7dfc499a14119185 Mon Sep 17 00:00:00 2001 From: samschott Date: Sun, 24 Nov 2024 22:41:49 +0100 Subject: [PATCH] update change notes with migration instructions --- changes/256.bugfix.rst | 10 +++++++++- changes/256.removal.rst | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 changes/256.removal.rst diff --git a/changes/256.bugfix.rst b/changes/256.bugfix.rst index 4620765d..5028dcba 100644 --- a/changes/256.bugfix.rst +++ b/changes/256.bugfix.rst @@ -1,2 +1,10 @@ Retain Objective-C objects when creating Python wrappers and release them when the -Python wrapped is garbage collected. +Python wrapped is garbage collected. This means that manual ``retain`` calls and +subsequent ``release`` or ``autorelease`` calls from Python are no longer needed with +very few exceptions such as: + +1. When implementing methods like ``copy`` that are supposed to create an object, if + the returned object is not actually newly created. +2. When dealing with side effects of methods like ``init`` that may release an object + which is still referenced from Python. See for example + https://github.com/beeware/toga/issues/2468. diff --git a/changes/256.removal.rst b/changes/256.removal.rst new file mode 100644 index 00000000..b4a409ac --- /dev/null +++ b/changes/256.removal.rst @@ -0,0 +1,4 @@ +Rubicon no longer skips releasing an Objective-C objects when its Python wrapped is +garbage collected. This means that fewer ``retain`` than ``release`` calls will cause +segfaults on garbage collection. Review your code carefully for unbalanced ``retain`` +and ``release`` calls before updating.