-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix entry gets deleted after aux import #6746
Conversation
Set changed flag on clone also for Misc entry type, because otherwise it equals the default entry type and no change is triggered which results in the entry not beeing written to the database on save Fixes #6405 Simplify gui code
*/ | ||
@Override | ||
public Object clone() { | ||
BibEntry clone = new BibEntry(type.getValue()); | ||
if (StandardEntryType.Misc.equals(type.getValue())) { | ||
clone.changed = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would doubt that this fixed the issue for the other types. -- When the entry type is Article, the clone is unchanged, too. Thus, no serialization written
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New BibEntryType(entryType) always calls setType() and thus:
The default value for field.get is the default entry type misc.
jabref/src/main/java/org/jabref/model/entry/BibEntry.java
Lines 360 to 371 in 7cc5747
public Optional<FieldChange> setType(EntryType newType, EntriesEventSource eventSource) { | |
Objects.requireNonNull(newType); | |
EntryType oldType = type.get(); | |
if (newType.equals(oldType)) { | |
return Optional.empty(); | |
} | |
changed = true; | |
this.type.setValue(newType); | |
FieldChange change = new FieldChange(this, InternalField.TYPE_HEADER, oldType.getName(), newType.getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all other non default entry types the change flat is correclty set that was what this issue made so special.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't update the changed
flag. The clone method should really clone the original entry, without any modifications (otherwise its not a clone).
However, the aux importer should set the changed flag of all entries (regardless of type), so that they get properly reformatted when writing them to disc (i.e. not using the parsed serialization of the original bib file).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the clone method implicitly sets the changed flags for all entry types except the default entry type.
The aux importer has nothing to do with this changed or serialization stuff. It's only relevant for saving the newly created library. I don't see any reason to add this logic to the AuxImporter
Only the BibTexParser does it.
*/ | ||
@Override | ||
public Object clone() { | ||
BibEntry clone = new BibEntry(type.getValue()); | ||
if (StandardEntryType.Misc.equals(type.getValue())) { | ||
clone.changed = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't update the changed
flag. The clone method should really clone the original entry, without any modifications (otherwise its not a clone).
However, the aux importer should set the changed flag of all entries (regardless of type), so that they get properly reformatted when writing them to disc (i.e. not using the parsed serialization of the original bib file).
Co-authored-by: Tobias Diez <tobiasdiez@gmx.de>
@calixtus and me implemented all required changes. |
Manually tested the changes again, All good. Merge now |
Set changed flag on clone also for Misc entry type, because otherwise it equals the default entry type and no change is triggered which results in the entry not beeing written to the database on save
Fixes #6405
Simplify gui code