]> git.lyx.org Git - lyx.git/blobdiff - src/support/linkback/LinkBackProxy.m
tiger support on mac snow leopard, include Qt4 frameworks, smart build script with...
[lyx.git] / src / support / linkback / LinkBackProxy.m
index c86649f02bfeb45114d07a1fa5024fdd88ff6f77..9ead1e84da2b483223d465975a070f8caf3c7754 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * \file LinkBackProxy.mm
+ * \file LinkBackProxy.m
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
@@ -179,30 +179,42 @@ static NSAutoreleasePool * pool = nil;
 
 static LyXLinkBackClient * linkBackClient = nil;
 
+void checkAutoReleasePool()
+{
+       if (pool == nil)
+               pool = [[NSAutoreleasePool alloc] init];
+}
+
 int isLinkBackDataInPasteboard()
 {
-       NSArray * linkBackType = [NSArray arrayWithObjects: LinkBackPboardType, nil];
-       NSString * ret = [[NSPasteboard generalPasteboard] availableTypeFromArray:linkBackType];
-       return ret != nil;
+       checkAutoReleasePool() ;
+       {
+               NSArray * linkBackType = [NSArray arrayWithObjects: LinkBackPboardType, nil];
+               NSString * ret = [[NSPasteboard generalPasteboard] availableTypeFromArray:linkBackType];
+               return ret != nil;
+       }
 }
 
-       
+
 void getLinkBackData(void const * * buf, unsigned * len)
 {
-       // get linkback data from pasteboard
-       NSPasteboard * pboard = [NSPasteboard generalPasteboard];
-       id linkBackData = [pboard propertyListForType:LinkBackPboardType];
-       
-       NSData * nsdata
-       = [NSArchiver archivedDataWithRootObject:linkBackData];
-       if (nsdata == nil) {
-               *buf = 0;
-               *len = 0;
-               return;
-       }
+       checkAutoReleasePool() ;
+       {
+               // get linkback data from pasteboard
+               NSPasteboard * pboard = [NSPasteboard generalPasteboard];
+               id linkBackData = [pboard propertyListForType:LinkBackPboardType];
+               
+               NSData * nsdata
+               = [NSArchiver archivedDataWithRootObject:linkBackData];
+               if (nsdata == nil) {
+                       *buf = 0;
+                       *len = 0;
+                       return;
+               }
 
-       *buf = [nsdata bytes];
-       *len = [nsdata length];
+               *buf = [nsdata bytes];
+               *len = [nsdata length];
+       }
 }
 
 
@@ -211,8 +223,7 @@ int editLinkBackFile(char const * docName)
        // setup Obj-C and our client
        if (linkBackClient == nil)
                linkBackClient = [[LyXLinkBackClient alloc] init];
-       if (pool == nil)
-               pool = [[NSAutoreleasePool alloc] init];
+       checkAutoReleasePool() ;
        
        // FIXME: really UTF8 here?
        NSString * nsDocName = [NSString stringWithUTF8String:docName];