Revision: 28045
          http://sourceforge.net/p/bibdesk/svn/28045
Author:   hofman
Date:     2022-10-26 21:34:07 +0000 (Wed, 26 Oct 2022)
Log Message:
-----------
make sure selectedRanges to reset does not become invalid

Modified Paths:
--------------
    trunk/bibdesk/BDSKEditor.m
    trunk/bibdesk/BDSKTextImportController.m

Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m  2022-10-26 15:18:57 UTC (rev 28044)
+++ trunk/bibdesk/BDSKEditor.m  2022-10-26 21:34:07 UTC (rev 28045)
@@ -2351,7 +2351,7 @@
        currentEditedView = [aNotification object];
     editorFlags.ignoreFieldChange = YES;
     // we need to preserve selection manually; otherwise you end up editing at 
the end of the string after the call to setField: below
-    NSArray *selRanges = [currentEditedView selectedRanges];
+    NSArray *selRanges = [[[currentEditedView selectedRanges] retain] 
autorelease];
     if(currentEditedView == notesView){
         [publication setField:BDSKAnnoteString toValue:[[notesView 
textStorage] mutableString]];
         [[self undoManager] setActionName:NSLocalizedString(@"Edit 
Annotation",@"Undo action name")];
@@ -3361,7 +3361,7 @@
     NSInteger editedRow = [tableView editedTextRow];
     if (editedRow != -1) {
         editedTitle = [[fields objectAtIndex:editedRow] retain];
-        selection = [(NSTextView *)[[self textFieldAtRow:editedRow] 
currentEditor] selectedRanges];
+        selection = [[[(NSTextView *)[[self textFieldAtRow:editedRow] 
currentEditor] selectedRanges] retain] autorelease];
         if ([[self window] makeFirstResponder:[self window]] == NO)
              [NSException raise:NSInternalInconsistencyException 
format:@"Failed to commit edits in %s, trouble ahead", __func__];
     }

Modified: trunk/bibdesk/BDSKTextImportController.m
===================================================================
--- trunk/bibdesk/BDSKTextImportController.m    2022-10-26 15:18:57 UTC (rev 
28044)
+++ trunk/bibdesk/BDSKTextImportController.m    2022-10-26 21:34:07 UTC (rev 
28045)
@@ -585,7 +585,7 @@
     
        if ([firstResponder isKindOfClass:[NSText class]]) {
                NSTextView *textView = (NSTextView *)firstResponder;
-               NSArray *selection = [textView selectedRanges];
+               NSArray *selection = [[[textView selectedRanges] retain] 
autorelease];
                id textDelegate = [textView delegate];
         if ([textDelegate isKindOfClass:[NSTextField class]] && 
([itemTableView rowForView:textDelegate] != -1 || textDelegate == 
citeKeyField)) {
             

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to