瀏覽代碼

Fixed removal of type mappings: multiple were left around

Yentl Van Tendeloo 8 年之前
父節點
當前提交
d276553187
共有 1 個文件被更改,包括 10 次插入0 次删除
  1. 10 0
      bootstrap/core_algorithm.alc

+ 10 - 0
bootstrap/core_algorithm.alc

@@ -381,6 +381,8 @@ String function export_typing(model : Element, name : String, user_id : String):
 	instance_of = instantiate_link(core, "instanceOf", "", result, get_entry_id("formalisms/TypeMapping"))
 	instantiate_link(core, "semantics", "", instance_of, get_entry_id("models/conformance_mv"))
 
+	log("Stored new typing: " + result)
+
 	return result!
 
 Void function model_create(model : Element, name : String, user_id : String, type_id : String, kind : String):
@@ -424,6 +426,14 @@ Void function model_overwrite(model : Element, model_id : String, metamodel_id :
 	choice = get_instanceOf_link(model_id, metamodel_id)
 	if (element_neq(choice, read_root())):
 		// There was a link, so we remove it
+
+		// First remove the type mapping it referred to
+		Element tl
+		tl = allAssociationDestinations(core, choice, "typing")
+		while (set_len(tl) > 0):
+			model_delete_element(core, set_pop(tl))
+
+		// Now delete the element itself
 		model_delete_element(core, choice)
 
 	// Create a new instanceOf relation now