Debugger: Prevent overwriting an existing label when trying to add a multibyte label over it
This commit is contained in:
parent
55dc91e60c
commit
681c695d0b
1 changed files with 16 additions and 3 deletions
|
@ -67,8 +67,6 @@ namespace Mesen.GUI.Debugger
|
||||||
UInt32 length = ((CodeLabel)Entity).Length;
|
UInt32 length = ((CodeLabel)Entity).Length;
|
||||||
AddressType type = ((CodeLabel)Entity).AddressType;
|
AddressType type = ((CodeLabel)Entity).AddressType;
|
||||||
CodeLabel sameLabel = LabelManager.GetLabel(txtLabel.Text);
|
CodeLabel sameLabel = LabelManager.GetLabel(txtLabel.Text);
|
||||||
CodeLabel sameAddress = LabelManager.GetLabel(address, type);
|
|
||||||
|
|
||||||
int maxAddress = GetMaxAddress(type);
|
int maxAddress = GetMaxAddress(type);
|
||||||
|
|
||||||
if(maxAddress <= 0) {
|
if(maxAddress <= 0) {
|
||||||
|
@ -77,11 +75,26 @@ namespace Mesen.GUI.Debugger
|
||||||
lblRange.Text = "($0000 - $" + maxAddress.ToString("X4") + ")";
|
lblRange.Text = "($0000 - $" + maxAddress.ToString("X4") + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(UInt32 i = 0; i < length; i++) {
|
||||||
|
CodeLabel sameAddress = LabelManager.GetLabel(address + i, type);
|
||||||
|
if(sameAddress != null) {
|
||||||
|
if(_originalLabel == null) {
|
||||||
|
//A label already exists and we're not editing an existing label, so we can't add it
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if(sameAddress.Label != _originalLabel.Label && !sameAddress.Label.StartsWith(_originalLabel.Label + "+")) {
|
||||||
|
//A label already exists, we're trying to edit an existing label, but the existing label
|
||||||
|
//and the label we're editing aren't the same label. Can't override an existing label with a different one.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
length >= 1 && length <= 65536 &&
|
length >= 1 && length <= 65536 &&
|
||||||
address + (length - 1) <= maxAddress &&
|
address + (length - 1) <= maxAddress &&
|
||||||
(sameLabel == null || sameLabel == _originalLabel)
|
(sameLabel == null || sameLabel == _originalLabel)
|
||||||
&& (sameAddress == null || sameAddress == _originalLabel)
|
|
||||||
&& (_originalLabel != null || txtLabel.Text.Length > 0 || txtComment.Text.Length > 0)
|
&& (_originalLabel != null || txtLabel.Text.Length > 0 || txtComment.Text.Length > 0)
|
||||||
&& !txtComment.Text.Contains('\x1')
|
&& !txtComment.Text.Contains('\x1')
|
||||||
&& (txtLabel.Text.Length == 0 || LabelManager.LabelRegex.IsMatch(txtLabel.Text));
|
&& (txtLabel.Text.Length == 0 || LabelManager.LabelRegex.IsMatch(txtLabel.Text));
|
||||||
|
|
Loading…
Add table
Reference in a new issue