From 147a1a266f04b7a616cba00567b13da0119946c4 Mon Sep 17 00:00:00 2001 From: samschott Date: Sun, 24 Nov 2024 23:15:49 +0100 Subject: [PATCH] add comment to `copyWithZone_` about the retain call --- cocoa/src/toga_cocoa/widgets/internal/data.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cocoa/src/toga_cocoa/widgets/internal/data.py b/cocoa/src/toga_cocoa/widgets/internal/data.py index b474d0e3a9..bbb05a64a2 100644 --- a/cocoa/src/toga_cocoa/widgets/internal/data.py +++ b/cocoa/src/toga_cocoa/widgets/internal/data.py @@ -5,6 +5,9 @@ class TogaData(NSObject): @objc_method def copyWithZone_(self): # TogaData is used as an immutable reference to a row - # so the same object can be returned as a copy. + # so the same object can be returned as a copy. We need + # to manually `retain` the object before returning because + # the "copy" methods are assumed to return an object that + # is owned by the caller. self.retain() return self