Revision: 5446
http://skim-app.svn.sourceforge.net/skim-app/?rev=5446&view=rev
Author: hofman
Date: 2009-06-23 22:43:36 +0000 (Tue, 23 Jun 2009)
Log Message:
-----------
only pass callback context info when relevant
Modified Paths:
--------------
trunk/SKSheetController.m
Modified: trunk/SKSheetController.m
===================================================================
--- trunk/SKSheetController.m 2009-06-23 17:45:20 UTC (rev 5445)
+++ trunk/SKSheetController.m 2009-06-23 22:43:36 UTC (rev 5446)
@@ -52,11 +52,14 @@
- (void)beginSheetModalForWindow:(NSWindow *)window modalDelegate:(id)delegate
didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo {
[self prepare];
- SKCallbackInfo *info = (SKCallbackInfo
*)NSZoneMalloc(NSDefaultMallocZone(), sizeof(SKCallbackInfo));
- info->delegate = delegate;
- info->selector = didEndSelector;
- info->contextInfo = contextInfo;
-
+ SKCallbackInfo *info = NULL;
+ if (delegate != nil && didEndSelector != NULL) {
+ info = (SKCallbackInfo *)NSZoneMalloc(NSDefaultMallocZone(),
sizeof(SKCallbackInfo));
+ info->delegate = delegate;
+ info->selector = didEndSelector;
+ info->contextInfo = contextInfo;
+ }
+
[self retain]; // make sure we stay around long enough
[NSApp beginSheet:[self window]
@@ -75,13 +78,13 @@
- (void)didEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode
contextInfo:(void *)contextInfo {
SKCallbackInfo *info = (SKCallbackInfo *)contextInfo;
- if(info->delegate != nil && info->selector != NULL){
+ if(info != NULL){
NSInvocation *invocation = [NSInvocation
invocationWithTarget:info->delegate selector:info->selector argument:&self];
[invocation setArgument:&returnCode atIndex:3];
[invocation setArgument:&(info->contextInfo) atIndex:4];
[invocation invoke];
+ NSZoneFree(NSDefaultMallocZone(), info);
}
- NSZoneFree(NSDefaultMallocZone(), info);
}
- (void)endSheetWithReturnCode:(NSInteger)returnCode {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit