Revision: 29407
http://sourceforge.net/p/bibdesk/svn/29407
Author: hofman
Date: 2025-07-31 09:33:45 +0000 (Thu, 31 Jul 2025)
Log Message:
-----------
Handle some edge cases when changing custom field types, should not happen in
practice
Modified Paths:
--------------
trunk/bibdesk/BDSKEditor.m
Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m 2025-07-30 22:35:41 UTC (rev 29406)
+++ trunk/bibdesk/BDSKEditor.m 2025-07-31 09:33:45 UTC (rev 29407)
@@ -2510,7 +2510,7 @@
currentFields = [self currentFields];
if (currentFields && [self commitEditingTableTextField])
[self reloadTableWithFields:currentFields];
- else if ((change & (BDSKFieldTypeMaskURL | BDSKFieldTypeMaskCitation)) &&
[self commitEditingTableTextField])
+ else if ((change & (BDSKFieldTypeMaskURL | BDSKFieldTypeMaskCitation)))
[self updateTableViewDisplay];
if ((change & BDSKFieldTypeMaskInteger))
[self setupCollectionView];
@@ -3322,10 +3322,28 @@
NSString *value = [publication valueOfField:field] ?: @"";
[textField setRepresentedObject:[self representedObjectForValue:value
forField:field]];
NSFormatter *formatter = [field isEqualToString:BDSKCrossrefString] ?
crossrefFormatter : [field isCitationField] ? citationFormatter :
tableCellFormatter;
- if (formatter != [textField formatter]) {
+ NSFormatter *oldFormatter = [textField formatter];
+ if (formatter != oldFormatter) {
+ id editor = [textField currentEditor];
+ BOOL wasComplexEditing = editor && oldFormatter ==
tableCellFormatter && [tableCellFormatter editAsComplexString];
[textField setFormatter:formatter];
- if ([textField currentEditor])
- [[textField currentEditor] setString:[formatter
editingStringForObjectValue:value]];
+ if (editor) {
+ if (wasComplexEditing) {
+ [tableCellFormatter setEditAsComplexString:NO];
+ [textField setObjectValue:value];
+ } else {
+ if (formatter == tableCellFormatter) {
+ if ([value isComplex])
+ [textField setObjectValue:value];
+ else
+ [tableCellFormatter
editingStringForObjectValue:value];
+ }
+ if (formatter == citationFormatter || oldFormatter ==
citationFormatter)
+ [editor setString:[editor string]];
+ }
+ } else if ([[textField objectValue] isEqualAsComplexString:value]
== NO) {
+ [textField setObjectValue:value];
+ }
}
}];
}
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