Revision: 29307
          http://sourceforge.net/p/bibdesk/svn/29307
Author:   hofman
Date:     2025-07-19 22:44:37 +0000 (Sat, 19 Jul 2025)
Log Message:
-----------
Fix updating note field value in edited text view from external change, making 
sure we don't use the edited mutable string

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

Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m  2025-07-19 22:15:03 UTC (rev 29306)
+++ trunk/bibdesk/BDSKEditor.m  2025-07-19 22:44:37 UTC (rev 29307)
@@ -2405,28 +2405,19 @@
     }
     else if([changeKey isNoteField]){
         if(editorFlags.ignoreFieldChange == NO) {
-            if([changeKey isEqualToString:BDSKAnnoteString]){
-               // make a copy of the current value, so we don't overwrite it 
when we set the field value to the text storage
-                NSString *tmpValue = [[publication 
valueOfField:BDSKAnnoteString inherit:NO] copy];
-                [notesView setString:(tmpValue == nil ? @"" : tmpValue)];
-                if(currentEditedView == notesView){
-                    [[self window] makeFirstResponder:[self window]];
-                    [textViewUndoManager removeAllActions];
-                }
-            } else if([changeKey isEqualToString:BDSKAbstractString]){
-                NSString *tmpValue = [[publication 
valueOfField:BDSKAbstractString inherit:NO] copy];
-                [abstractView setString:(tmpValue == nil ? @"" : tmpValue)];
-                if(currentEditedView == abstractView){
-                    [[self window] makeFirstResponder:[self window]];
-                    [textViewUndoManager removeAllActions];
-                }
-            } else if([changeKey isEqualToString:BDSKRssDescriptionString]){
-                NSString *tmpValue = [[publication 
valueOfField:BDSKRssDescriptionString inherit:NO] copy];
-                [rssDescriptionView setString:(tmpValue == nil ? @"" : 
tmpValue)];
-                if(currentEditedView == rssDescriptionView){
-                    [[self window] makeFirstResponder:[self window]];
-                    [textViewUndoManager removeAllActions];
-                }
+            if (currentEditedView && [[self currentEditedNoteField] 
isEqualToString:changeKey]) {
+                // make sure we are getting the actual current value rather 
than the edited value
+                [publication setEditedField:nil];
+                [currentEditedView setString:[publication 
valueOfField:changeKey inherit:NO] ?: @""];
+                [publication setEditedField:changeKey];
+                // undo actions in the text view are now invalid
+                [textViewUndoManager removeAllActions];
+            } else if ([changeKey isEqualToString:BDSKAnnoteString]) {
+                [notesView setString:[publication 
valueOfField:BDSKAnnoteString inherit:NO] ?: @""];
+            } else if ([changeKey isEqualToString:BDSKAbstractString]) {
+                [abstractView setString:[publication 
valueOfField:BDSKAbstractString inherit:NO] ?: @""];
+            } else if ([changeKey isEqualToString:BDSKRssDescriptionString]) {
+                [rssDescriptionView setString:[publication 
valueOfField:BDSKRssDescriptionString inherit:NO] ?: @""];
             }
         }
     }
@@ -2449,16 +2440,21 @@
         [self synchronizeWindowTitleWithDocumentName];
         [authorTableView reloadData];
         if (editorFlags.ignoreFieldChange == NO) {
-            // make a copy of the current value, so we don't overwrite it when 
we set the field value to the text storage
-            NSString *tmpValue = [[publication valueOfField:BDSKAnnoteString 
inherit:NO] copy];
-            [notesView setString:tmpValue ?: @""];
-            tmpValue = [[publication valueOfField:BDSKAbstractString 
inherit:NO] copy];
-            [abstractView setString:tmpValue ?: @""];
-            tmpValue = [[publication valueOfField:BDSKRssDescriptionString 
inherit:NO] copy];
-            [rssDescriptionView setString:tmpValue ?: @""];
-            if(currentEditedView)
-                [[self window] makeFirstResponder:[self window]];
-            [textViewUndoManager removeAllActions];
+            if (currentEditedView) {
+                NSString *editedKey = [self currentEditedNoteField];
+                // make sure we are getting the actual current value rather 
than the edited value
+                [publication setEditedField:nil];
+                [currentEditedView setString:[publication 
valueOfField:editedKey inherit:NO] ?: @""];
+                [publication setEditedField:editedKey];
+                // undo actions in the text view are now invalid
+                [textViewUndoManager removeAllActions];
+            }
+            if (currentEditedView != notesView)
+                [notesView setString:[publication 
valueOfField:BDSKAnnoteString inherit:NO] ?: @""];
+            if (currentEditedView != abstractView)
+                [abstractView setString:[publication 
valueOfField:BDSKAbstractString inherit:NO] ?: @""];
+            if (currentEditedView != rssDescriptionView)
+                [rssDescriptionView setString:[publication 
valueOfField:BDSKRssDescriptionString inherit:NO] ?: @""];
         }
     }
     else if([changeKey isEqualToString:BDSKColorString] == NO){

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