Revision: 14860
          http://sourceforge.net/p/skim-app/code/14860
Author:   hofman
Date:     2025-01-12 09:56:25 +0000 (Sun, 12 Jan 2025)
Log Message:
-----------
Prevent setting color of highlight to sRGB black, to work around a bug in 
PDFView display

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

Modified: trunk/PDFAnnotationMarkup_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationMarkup_SKExtensions.m    2025-01-11 17:21:50 UTC (rev 
14859)
+++ trunk/PDFAnnotationMarkup_SKExtensions.m    2025-01-12 09:56:25 UTC (rev 
14860)
@@ -55,6 +55,7 @@
 #import "NSView_SKExtensions.h"
 #import "SKNoteText.h"
 #import "PDFView_SKExtensions.h"
+#import "SKRuntime.h"
 #import <objc/objc-runtime.h>
 
 NSString *SKPDFAnnotationSelectionSpecifierKey = @"selectionSpecifier";
@@ -89,6 +90,19 @@
         [quadPoints addObject:[NSValue valueWithPoint:p[i]]];
 }
 
+static void (*original_setColor)(id, SEL, id) = NULL;
+
+// PDFView raises an exception when a highlight has a sRGB black color
+- (void)replacement_setColor:(NSColor *)color {
+    if ([self markupType] == kPDFMarkupTypeHighlight && [color 
isEqual:[NSColor colorWithSRGBRed:0.0 green:0.0 blue:0.0 alpha:1.0]])
+        color = [NSColor colorWithSRGBRed:0.0000001 green:0.0000001 
blue:0.0000001 alpha:1.0];
+    original_setColor(self, _cmd, color);
+}
+
++ (void)load {
+    original_setColor = (void (*)(id, SEL, 
id))SKReplaceInstanceMethodImplementationFromSelector(self, 
@selector(setColor:), @selector(replacement_setColor:));
+}
+
 - (void)setDefaultSkimNoteProperties {
     NSString *key = nil;
     switch ([self markupType]) {

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