ObjFW  Check-in [5b5c12fa0b]

Overview
Comment:OFNotificationCenter: Don't retain observer

This avoids retain cycles.

A future improvement could be to use a weak reference instead, without
relying on ARC by calling into the runtime functions directly.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5b5c12fa0b816c9714f05db138d89166528d6346551f928172430dbd15836bcd
User & Date: js on 2023-01-13 13:31:07
Other Links: manifest | tags
Context
2023-01-22
21:48
Support for reading extended attributes on Linux check-in: 565d2b3763 user: js tags: trunk
2023-01-13
13:31
OFNotificationCenter: Don't retain observer check-in: 5b5c12fa0b user: js tags: trunk
13:11
OFNotificationCenter: Don't expose internal class check-in: 651875bc1f user: js tags: trunk
Changes

Modified src/OFNotificationCenter.m from [7f71790adf] to [bec84a1cd3].

65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();

		_name = [name copy];
		_observer = [observer retain];
		_selector = selector;
		_object = [object retain];

		_selectorHash = [[OFString stringWithUTF8String:
		    sel_getName(_selector)] hash];

		objc_autoreleasePoolPop(pool);







|







65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();

		_name = [name copy];
		_observer = observer;
		_selector = selector;
		_object = [object retain];

		_selectorHash = [[OFString stringWithUTF8String:
		    sel_getName(_selector)] hash];

		objc_autoreleasePoolPop(pool);
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
	return self;
}
#endif

- (void)dealloc
{
	[_name release];
	[_observer release];
	[_object release];
#ifdef OF_HAVE_BLOCKS
	[_block release];
#endif

	[super dealloc];
}







<







104
105
106
107
108
109
110

111
112
113
114
115
116
117
	return self;
}
#endif

- (void)dealloc
{
	[_name release];

	[_object release];
#ifdef OF_HAVE_BLOCKS
	[_block release];
#endif

	[super dealloc];
}