Display unhandled purple conversation writes in the next run loop. Fixes #13190.
5 // Created by Colin Barrett on Mon Sep 22 2003.
8 #import "AIObjectAdditions.h"
10 // Clever addition by Jonathan Jansson found on cocoadev.com (http://www.cocoadev.com/index.pl?ThreadCommunication)
11 @implementation NSObject (RunLoopMessenger)
13 //Included to allow uniform coding
14 - (void)mainPerformSelector:(SEL)aSelector
16 [self mainPerformSelector:aSelector waitUntilDone:NO];
18 //Included to allow uniform coding - wrapped for performSelectorOnMainThread:withObject:waitUntilDone:
19 - (void)mainPerformSelector:(SEL)aSelector waitUntilDone:(BOOL)flag
21 [self performSelectorOnMainThread:aSelector withObject:nil waitUntilDone:flag];
24 - (id)mainPerformSelector:(SEL)aSelector returnValue:(BOOL)flag
29 NSInvocation *invocation;
31 invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:aSelector]];
32 [invocation setSelector:aSelector];
34 [self performSelectorOnMainThread:@selector(handleInvocation:)
38 [invocation getReturnValue:&returnValue];
42 [self performSelectorOnMainThread:aSelector
50 //Included to allow uniform coding
51 - (void)mainPerformSelector:(SEL)aSelector withObject:(id)argument1
53 [self mainPerformSelector:aSelector withObject:argument1 waitUntilDone:NO];
56 //Included to allow uniform coding - wrapped for performSelectorOnMainThread:withObject:waitUntilDone:
57 - (void)mainPerformSelector:(SEL)aSelector withObject:(id)argument1 waitUntilDone:(BOOL)flag
59 [self performSelectorOnMainThread:aSelector withObject:argument1 waitUntilDone:flag];
62 //Perform a selector on the main thread, optionally taking an argument, and return its return value
63 - (id)mainPerformSelector:(SEL)aSelector withObject:(id)argument1 returnValue:(BOOL)flag
68 NSInvocation *invocation;
70 invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:aSelector]];
71 [invocation setSelector:aSelector];
72 [invocation setArgument:&argument1 atIndex:2];
74 [self performSelectorOnMainThread:@selector(handleInvocation:)
78 [invocation getReturnValue:&returnValue];
82 [self performSelectorOnMainThread:aSelector withObject:argument1 waitUntilDone:NO];
88 - (void)mainPerformSelector:(SEL)aSelector withObject:(id)argument1 withObject:(id)argument2
90 [self mainPerformSelector:aSelector withObject:argument1 withObject:argument2 waitUntilDone:NO];
93 //Perform a selector on the main thread, taking 0-2 arguments, and return its return value
94 - (id)mainPerformSelector:(SEL)aSelector withObject:(id)argument1 withObject:(id)argument2 returnValue:(BOOL)flag
99 NSInvocation *invocation;
101 invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:aSelector]];
102 [invocation setSelector:aSelector];
103 [invocation setArgument:&argument1 atIndex:2];
104 [invocation setArgument:&argument2 atIndex:3];
106 [self performSelectorOnMainThread:@selector(handleInvocation:)
107 withObject:invocation
110 [invocation getReturnValue:&returnValue];
114 [self mainPerformSelector:aSelector withObject:argument1 withObject:argument2 waitUntilDone:NO];
120 - (void)mainPerformSelector:(SEL)aSelector withObject:(id)argument1 withObject:(id)argument2 waitUntilDone:(BOOL)flag
122 NSInvocation *invocation;
123 invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:aSelector]];
125 [invocation setSelector:aSelector];
126 [invocation setArgument:&argument1 atIndex:2];
127 [invocation setArgument:&argument2 atIndex:3];
128 [invocation retainArguments];
130 [self performSelectorOnMainThread:@selector(handleInvocation:) withObject:invocation waitUntilDone:flag];
133 - (void)mainPerformSelector:(SEL)aSelector withObject:(id)argument1 withObject:(id)argument2 withObject:(id)argument3
135 [self mainPerformSelector:aSelector withObject:argument1 withObject:argument2 withObject:argument3 waitUntilDone:NO];
137 //Perform a selector on the main thread, taking 0-3 arguments, and return its return value
138 - (id)mainPerformSelector:(SEL)aSelector withObject:(id)argument1 withObject:(id)argument2 withObject:(id)argument3 returnValue:(BOOL)flag
143 NSInvocation *invocation;
145 invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:aSelector]];
146 [invocation setSelector:aSelector];
147 [invocation setArgument:&argument1 atIndex:2];
148 [invocation setArgument:&argument2 atIndex:3];
149 [invocation setArgument:&argument3 atIndex:4];
151 [self performSelectorOnMainThread:@selector(handleInvocation:)
152 withObject:invocation
155 [invocation getReturnValue:&returnValue];
159 [self mainPerformSelector:aSelector withObject:argument1 withObject:argument2 withObject:argument3 waitUntilDone:NO];
165 - (void)mainPerformSelector:(SEL)aSelector withObject:(id)argument1 withObject:(id)argument2 withObject:(id)argument3 waitUntilDone:(BOOL)flag
167 NSInvocation *invocation;
168 invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:aSelector]];
170 [invocation setSelector:aSelector];
171 [invocation setArgument:&argument1 atIndex:2];
172 [invocation setArgument:&argument2 atIndex:3];
173 [invocation setArgument:&argument3 atIndex:4];
174 [invocation retainArguments];
176 [self performSelectorOnMainThread:@selector(handleInvocation:) withObject:invocation waitUntilDone:flag];
179 - (void)mainPerformSelector:(SEL)aSelector withObject:(id)argument1 withObject:(id)argument2 withObject:(id)argument3 withObject:(id)argument4
181 [self mainPerformSelector:aSelector withObject:argument1 withObject:argument2 withObject:argument3 withObject:argument4 waitUntilDone:NO];
183 - (void)mainPerformSelector:(SEL)aSelector withObject:(id)argument1 withObject:(id)argument2 withObject:(id)argument3 withObject:(id)argument4 waitUntilDone:(BOOL)flag
185 NSInvocation *invocation;
186 invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:aSelector]];
188 [invocation setSelector:aSelector];
189 [invocation setArgument:&argument1 atIndex:2];
190 [invocation setArgument:&argument2 atIndex:3];
191 [invocation setArgument:&argument3 atIndex:4];
192 [invocation setArgument:&argument4 atIndex:5];
193 [invocation retainArguments];
195 [self performSelectorOnMainThread:@selector(handleInvocation:) withObject:invocation waitUntilDone:flag];
199 - (void)mainPerformSelector:(SEL)aSelector withObjects:(id)argument1, ...
201 NSInvocation *invocation;
205 invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:aSelector]];
206 [invocation setSelector:aSelector];
207 [invocation setArgument:&argument1 atIndex:index++];
209 va_start(args, argument1);
212 while ((anArgument = va_arg(args, id))) {
213 [invocation setArgument:&anArgument atIndex:index++];
218 [invocation retainArguments];
220 [self performSelectorOnMainThread:@selector(handleInvocation:) withObject:invocation waitUntilDone:NO];
223 - (void)performSelector:(SEL)aSelector withObject:(id)argument1 withObject:(id)argument2 afterDelay:(NSTimeInterval)delay
225 NSInvocation *invocation;
226 invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:aSelector]];
228 [invocation setSelector:aSelector];
229 [invocation setArgument:&argument1 atIndex:2];
230 [invocation setArgument:&argument2 atIndex:3];
231 [invocation retainArguments];
233 [self performSelector:@selector(handleInvocation:) withObject:invocation afterDelay:delay];
236 - (void)performSelector:(SEL)aSelector withObject:(id)argument1 withObject:(id)argument2 withObject:(id)argument3 afterDelay:(NSTimeInterval)delay
238 NSInvocation *invocation;
239 invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:aSelector]];
241 [invocation setSelector:aSelector];
242 [invocation setArgument:&argument1 atIndex:2];
243 [invocation setArgument:&argument2 atIndex:3];
244 [invocation setArgument:&argument3 atIndex:4];
245 [invocation retainArguments];
247 [self performSelector:@selector(handleInvocation:) withObject:invocation afterDelay:delay];
250 - (void)performSelector:(SEL)aSelector withObject:(id)argument1 withObject:(id)argument2 withObject:(id)argument3
252 NSInvocation *invocation;
253 invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:aSelector]];
255 [invocation setSelector:aSelector];
256 [invocation setArgument:&argument1 atIndex:2];
257 [invocation setArgument:&argument2 atIndex:3];
258 [invocation setArgument:&argument3 atIndex:4];
259 [invocation retainArguments];
261 [self performSelector:@selector(handleInvocation:) withObject:invocation];
264 - (void)performSelector:(SEL)aSelector withObject:(id)argument1 withObject:(id)argument2 withObject:(id)argument3 withObject:(id)argument4 afterDelay:(NSTimeInterval)delay
266 NSInvocation *invocation;
267 invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:aSelector]];
269 [invocation setSelector:aSelector];
270 [invocation setArgument:&argument1 atIndex:2];
271 [invocation setArgument:&argument2 atIndex:3];
272 [invocation setArgument:&argument3 atIndex:4];
273 [invocation setArgument:&argument4 atIndex:5];
274 [invocation retainArguments];
276 [self performSelector:@selector(handleInvocation:) withObject:invocation afterDelay:delay];
279 - (void)handleInvocation:(NSInvocation *)anInvocation
281 [anInvocation invokeWithTarget:self];