Merge remote-tracking branch 'origin/patch'

This commit is contained in:
Ryan Kurtz 2023-02-03 11:54:27 -05:00
commit fe1d80a585
2 changed files with 16 additions and 6 deletions

View file

@ -17,6 +17,8 @@ package ghidra.program.database.data;
import java.io.IOException; import java.io.IOException;
import org.apache.commons.lang3.StringUtils;
import db.DBRecord; import db.DBRecord;
import ghidra.docking.settings.*; import ghidra.docking.settings.*;
import ghidra.program.model.data.*; import ghidra.program.model.data.*;
@ -201,6 +203,9 @@ class DataTypeComponentDB implements InternalDataTypeComponent {
@Override @Override
public void setComment(String comment) { public void setComment(String comment) {
if (record != null) { if (record != null) {
if (StringUtils.isBlank(comment)) {
comment = null;
}
record.setString(ComponentDBAdapter.COMPONENT_COMMENT_COL, comment); record.setString(ComponentDBAdapter.COMPONENT_COMMENT_COL, comment);
updateRecord(true); updateRecord(true);
} }
@ -398,16 +403,19 @@ class DataTypeComponentDB implements InternalDataTypeComponent {
* Perform special-case component update that does not result in size or alignment changes. * Perform special-case component update that does not result in size or alignment changes.
* @param name new component name * @param name new component name
* @param dt new resolved datatype * @param dt new resolved datatype
* @param cmt new comment * @param comment new comment
*/ */
void update(String name, DataType dt, String cmt) { void update(String name, DataType dt, String comment) {
if (record != null) { if (record != null) {
if (StringUtils.isBlank(comment)) {
comment = null;
}
// TODO: Need to check field name and throw DuplicateNameException // TODO: Need to check field name and throw DuplicateNameException
// name = checkFieldName(name); // name = checkFieldName(name);
record.setString(ComponentDBAdapter.COMPONENT_FIELD_NAME_COL, name); record.setString(ComponentDBAdapter.COMPONENT_FIELD_NAME_COL, name);
record.setLongValue(ComponentDBAdapter.COMPONENT_DT_ID_COL, record.setLongValue(ComponentDBAdapter.COMPONENT_DT_ID_COL,
dataMgr.getResolvedID(dt)); dataMgr.getResolvedID(dt));
record.setString(ComponentDBAdapter.COMPONENT_COMMENT_COL, cmt); record.setString(ComponentDBAdapter.COMPONENT_COMMENT_COL, comment);
updateRecord(false); updateRecord(false);
} }
} }

View file

@ -17,6 +17,8 @@ package ghidra.program.model.data;
import java.io.Serializable; import java.io.Serializable;
import org.apache.commons.lang3.StringUtils;
import ghidra.docking.settings.Settings; import ghidra.docking.settings.Settings;
import ghidra.docking.settings.SettingsImpl; import ghidra.docking.settings.SettingsImpl;
import ghidra.program.database.data.DataTypeUtilities; import ghidra.program.database.data.DataTypeUtilities;
@ -57,8 +59,8 @@ public class DataTypeComponentImpl implements InternalDataTypeComponent, Seriali
this.offset = offset; this.offset = offset;
this.length = length; this.length = length;
this.fieldName = fieldName; this.fieldName = fieldName;
this.comment = comment;
setDataType(dataType); setDataType(dataType);
setComment(comment);
} }
/** /**
@ -115,7 +117,7 @@ public class DataTypeComponentImpl implements InternalDataTypeComponent, Seriali
@Override @Override
public void setComment(String comment) { public void setComment(String comment) {
this.comment = comment; this.comment = StringUtils.isBlank(comment) ? null : comment;
} }
@Override @Override
@ -198,7 +200,7 @@ public class DataTypeComponentImpl implements InternalDataTypeComponent, Seriali
// this.fieldName = = checkFieldName(name); // this.fieldName = = checkFieldName(name);
this.fieldName = name; this.fieldName = name;
this.dataType = dt; this.dataType = dt;
this.comment = cmt; this.comment = StringUtils.isBlank(cmt) ? null : cmt;
} }
@Override @Override