I came across a deprecated call in the LinkBack code, and discovered that LinkBack acctually doesn't work (anymore).
Apparently nobody uses this?

When the pasteboard contains linkback-data lyx saves the pdf-data + linkback-data in a file with the .linkback extension and adds the size of the pdf-data as a uint32.

When reading/rewriting back the size it's converted with NSSwapBigLongToHost() and NSSwapHostLongToBig() calls.

I suppose that the "Long" refers to 8 bytes.

Replacing the calls by the similar "Int" calls solves the problem.

LinkBack then works with LateXiT and with Omnigraffle.

Enclosed is a patch for this and for replacing the deprecated call.


Regards,

P. De Visschere
diff --git a/src/support/linkback/LinkBackProxy.m 
b/src/support/linkback/LinkBackProxy.m
index bf150c9ad6..574d5713cf 100644
--- a/src/support/linkback/LinkBackProxy.m
+++ b/src/support/linkback/LinkBackProxy.m
@@ -65,7 +65,7 @@
                // The pdf data length are the last 4 bytes.
                UInt32 pdfLen = 0;
                pdfLen = *(UInt32 const *)(((UInt8 const *)[data bytes]) + 
[data length] - 4);
-               pdfLen = NSSwapBigLongToHost(pdfLen); // make it big endian
+               pdfLen = NSSwapBigIntToHost(pdfLen); // make it big endian
                if (pdfLen >= [data length] - 4) {
                        NSLog(@"Invalid file %@ for LinkBack", fileName);
                        return NO;
@@ -154,7 +154,7 @@
                [file writeData:pdfData];
                [file writeData:linkBackData];
 
-               UInt32 pdfLen = NSSwapHostLongToBig([pdfData length]); // big 
endian
+               UInt32 pdfLen = NSSwapHostIntToBig([pdfData length]); // big 
endian
                NSData * lenData = [NSData dataWithBytes:&pdfLen length:4];
                [file writeData:lenData];
                [file closeFile];
diff --git a/src/support/linkback/LinkBackServer.m 
b/src/support/linkback/LinkBackServer.m
index dc8708d66d..38a80e02e6 100644
--- a/src/support/linkback/LinkBackServer.m
+++ b/src/support/linkback/LinkBackServer.m
@@ -154,8 +154,7 @@ NSString* FindLinkBackServer(NSString* bundleIdentifier, 
NSString* serverName, N
 
 void LinkBackRunAppNotFoundPanel(NSString* appName, NSURL* url)
 {
-       int result ;
-
+       
        // strings for panel
        NSBundle* b = [NSBundle bundleForClass: [LinkBack class]] ;
        NSString* title ;
@@ -171,11 +170,17 @@ void LinkBackRunAppNotFoundPanel(NSString* appName, 
NSURL* url)
        urlstr = (url) ? NSLocalizedStringFromTableInBundle(@"_GetApplication", 
@"Localized", b, @"Get application") : nil ;
 
        title = [NSString stringWithFormat: title, appName] ;
-
-       result = NSRunCriticalAlertPanel(title, @"%@", ok, urlstr, nil, msg) ;
-       if (NSAlertAlternateReturn == result) {
-               [[NSWorkspace sharedWorkspace] openURL: url] ;
-       }
+       
+       NSAlert* alert = [[NSAlert alloc] init];
+       [alert setAlertStyle:NSAlertStyleCritical];
+       [alert setMessageText:title];
+       [alert setInformativeText:[NSString stringWithFormat:@"%@", msg]];
+       [alert addButtonWithTitle:ok];
+       [alert addButtonWithTitle:urlstr];
+       [alert beginSheetModalForWindow:[NSApp mainWindow] 
completionHandler:^(NSModalResponse returnCode) {
+               if (returnCode == NSAlertSecondButtonReturn)
+                               [[NSWorkspace sharedWorkspace] openURL: url] ;
+       }];
 }
 
 + (LinkBackServer*)LinkBackServerWithName:(NSString*)aName 
inApplication:(NSString*)bundleIdentifier launchIfNeeded:(BOOL)flag 
fallbackURL:(NSURL*)url appName:(NSString*)appName

Reply via email to