Flag an error if we accidentally introduce a second script object by accident.

This commit is contained in:
David Wendt 2019-12-26 01:45:51 -05:00
parent abb2690367
commit 7c95eff048
1 changed files with 5 additions and 0 deletions

View File

@ -657,6 +657,11 @@ impl<'gc> XMLNode<'gc> {
gc_context: MutationContext<'gc, '_>, gc_context: MutationContext<'gc, '_>,
new_object: Object<'gc>, new_object: Object<'gc>,
) { ) {
if self.get_script_object().is_some() {
log::warn!("An attempt was made to change the already-established link between script object and XML node. This has been denied and is likely a bug.");
return;
}
match &mut *self.0.write(gc_context) { match &mut *self.0.write(gc_context) {
XMLNodeData::Element { script_object, .. } => *script_object = Some(new_object), XMLNodeData::Element { script_object, .. } => *script_object = Some(new_object),
XMLNodeData::Text { script_object, .. } => *script_object = Some(new_object), XMLNodeData::Text { script_object, .. } => *script_object = Some(new_object),