Skip to content

Commit 1e5f88f

Browse files
committed
Bugfix: allow copying attacker
Note: attacker entrypoints are not copied correctly still
1 parent 179f612 commit 1e5f88f

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

mal_gui/model_scene.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ def add_attacker(self, position, name = None):
463463
)
464464
new_item.attackerAttachment = new_attacker_attachment
465465
self._attacker_id_to_item[new_attacker_attachment.id] = new_item
466+
return new_item
466467

467468
def create_item(self, itemType, position, name):
468469
"""Create item"""
@@ -599,7 +600,7 @@ def serialize_graphics_items(self, items: list[AssetBase], cut_intended):
599600
# - This is causing issue with Serialization
600601
asset_name = str(item.asset_name)
601602
prop_keys_to_ignore = ['id','type']
602-
603+
print(asset_name, item.asset_type)
603604
item_details = {
604605
'asset_type': item.asset_type,
605606
'asset_name': asset_name,
@@ -613,12 +614,16 @@ def serialize_graphics_items(self, items: list[AssetBase], cut_intended):
613614
if conn.start_item.asset_sequence_id in selected_sequence_ids
614615
and conn.end_item.asset_sequence_id in selected_sequence_ids
615616
],
616-
'asset_properties': [
617+
'asset_properties': []
618+
}
619+
620+
if item.asset_type != "Attacker":
621+
item_details['asset_properties'] = [
617622
(str(key),str(value))
618-
for key,value in item.asset._properties.items()
619-
if key not in prop_keys_to_ignore
623+
for key, value in item.asset._properties.items()
624+
if key not in prop_keys_to_ignore
620625
]
621-
}
626+
622627
objdetails.append(item_details)
623628

624629
serialized_data = pickle.dumps(objdetails)

mal_gui/undo_redo_commands/paste_command.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from PySide6.QtGui import QUndoCommand
66
from PySide6.QtCore import QPointF
77

8+
from maltoolbox.model import AttackerAttachment
9+
810
from ..connection_item import AssociationConnectionItem
911

1012
if TYPE_CHECKING:
@@ -49,14 +51,7 @@ def redo(self):
4951

5052
# AddAsset Equivalent - Start - To Be Discussed
5153
if asset_type == "Attacker":
52-
# newAttackerAttachment = AttackerAttachment()
53-
# self.scene.model.add_attacker(newAttackerAttachment)
54-
55-
new_item = self.scene.asset_factory.get_asset(asset_type)
56-
# new_item.asset_name = "Attacker"
57-
# new_item.type_text_item.setPlainText(str("Attacker"))
58-
new_item.setPos(position)
59-
# self.scene._attacker_id_to_item[newAttackerAttachment.id] = new_item
54+
new_item = self.scene.add_attacker(position)
6055
else:
6156
new_item = self.scene.add_asset(asset_type, position)
6257
# we can assign the properties to new asset

0 commit comments

Comments
 (0)