Revision: 5447
          http://skim-app.svn.sourceforge.net/skim-app/?rev=5447&view=rev
Author:   hofman
Date:     2009-06-23 23:12:19 +0000 (Tue, 23 Jun 2009)

Log Message:
-----------
just pass the callback invocation as context info to sheet controller

Modified Paths:
--------------
    trunk/SKSheetController.m

Modified: trunk/SKSheetController.m
===================================================================
--- trunk/SKSheetController.m   2009-06-23 22:43:36 UTC (rev 5446)
+++ trunk/SKSheetController.m   2009-06-23 23:12:19 UTC (rev 5447)
@@ -40,24 +40,16 @@
 #import "NSInvocation_SKExtensions.h"
 
 
-typedef struct _SKCallbackInfo {
-    id delegate;
-       SEL selector;
-    void *contextInfo;
-} SKCallbackInfo;
-
-
 @implementation SKSheetController
 
 - (void)beginSheetModalForWindow:(NSWindow *)window modalDelegate:(id)delegate 
didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo {
        [self prepare];
        
-    SKCallbackInfo *info = NULL;
+    NSInvocation *invocation = nil;
     if (delegate != nil && didEndSelector != NULL) {
-        info = (SKCallbackInfo *)NSZoneMalloc(NSDefaultMallocZone(), 
sizeof(SKCallbackInfo));
-        info->delegate = delegate;
-        info->selector = didEndSelector;
-        info->contextInfo = contextInfo;
+        invocation = [NSInvocation invocationWithTarget:delegate 
selector:didEndSelector argument:&self];
+               [invocation setArgument:&returnCode atIndex:3];
+               [invocation setArgument:&contextInfo atIndex:4];
        }
     
        [self retain]; // make sure we stay around long enough
@@ -66,7 +58,7 @@
           modalForWindow:window
                modalDelegate:self
           didEndSelector:@selector(didEndSheet:returnCode:contextInfo:)
-                 contextInfo:info];
+                 contextInfo:[invocation retain]];
 }
 
 - (void)prepare {}
@@ -77,14 +69,9 @@
 }
 
 - (void)didEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode 
contextInfo:(void *)contextInfo {
-       SKCallbackInfo *info = (SKCallbackInfo *)contextInfo;
-    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];
+       NSInvocation *invocation = [(NSInvocation *)contextInfo autorelease];
+    if (invocation)
                [invocation invoke];
-        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

Reply via email to