From 54db4206e9302e7510bc4f103ff59714c1be942d Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Thu, 30 Nov 2023 14:09:50 +0100 Subject: SL-19801 Inserting emoji characters from system emoji picker does not work on macOS --- indra/llwindow/llopenglview-objc.mm | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index 7936245744..5527094021 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -718,6 +718,19 @@ attributedStringInfo getSegments(NSAttributedString *str) - (void)insertText:(id)aString replacementRange:(NSRange)replacementRange { + // SL-19801 Special workaround for system emoji picker + if ([aString length] == 2) + { + uint32_t b0 = [aString characterAtIndex:0]; + uint32_t b1 = [aString characterAtIndex:1]; + if (((b0 & 0xF000) == 0xD000) && ((b1 & 0xF000) == 0xD000)) + { + uint32_t b = 0x10000 | ((b0 & 0x3F) << 10) | (b1 & 0x3FF); + callUnicodeCallback(b, 0); + return; + } + } + if (!mHasMarkedText) { for (NSInteger i = 0; i < [aString length]; i++) -- cgit v1.2.3 From 0d8bd79c79c1e917bc49669426bdfa89dc48ff04 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 11 Jan 2024 00:19:56 +0200 Subject: SL-20750 MacOS Crash processing attributed string --- indra/llwindow/llopenglview-objc.mm | 68 +++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 26 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index 37f4568b98..0bd4e506a2 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -736,33 +736,49 @@ attributedStringInfo getSegments(NSAttributedString *str) // SL-19801 Special workaround for system emoji picker if ([aString length] == 2) { - uint32_t b0 = [aString characterAtIndex:0]; - uint32_t b1 = [aString characterAtIndex:1]; - if (((b0 & 0xF000) == 0xD000) && ((b1 & 0xF000) == 0xD000)) - { - uint32_t b = 0x10000 | ((b0 & 0x3F) << 10) | (b1 & 0x3FF); - callUnicodeCallback(b, 0); - return; - } - } - - if (!mHasMarkedText) - { - for (NSInteger i = 0; i < [aString length]; i++) - { - callUnicodeCallback([aString characterAtIndex:i], mModifiers); - } - } else { - resetPreedit(); - // We may never get this point since unmarkText may be called before insertText ever gets called once we submit our text. - // But just in case... - - for (NSInteger i = 0; i < [aString length]; i++) - { - handleUnicodeCharacter([aString characterAtIndex:i]); - } - mHasMarkedText = FALSE; + @try + { + uint32_t b0 = [aString characterAtIndex:0]; + uint32_t b1 = [aString characterAtIndex:1]; + if (((b0 & 0xF000) == 0xD000) && ((b1 & 0xF000) == 0xD000)) + { + uint32_t b = 0x10000 | ((b0 & 0x3F) << 10) | (b1 & 0x3FF); + callUnicodeCallback(b, 0); + return; + } + } + @catch(NSException * e) + { + // One of the characters is an attribute string? + NSLog(@"Encountered an unsupported attributed character. Exception: %@ String: %@", e.name, aString); + return; + } } + + @try + { + if (!mHasMarkedText) + { + for (NSInteger i = 0; i < [aString length]; i++) + { + callUnicodeCallback([aString characterAtIndex:i], mModifiers); + } + } else { + resetPreedit(); + // We may never get this point since unmarkText may be called before insertText ever gets called once we submit our text. + // But just in case... + + for (NSInteger i = 0; i < [aString length]; i++) + { + handleUnicodeCharacter([aString characterAtIndex:i]); + } + mHasMarkedText = FALSE; + } + } + @catch(NSException * e) + { + NSLog(@"Failed to process an attributed string. Exception: %@ String: %@", e.name, aString); + } } - (void) insertNewline:(id)sender -- cgit v1.2.3