Browse Source

Fixes https://github.com/buxx/OpenCombat/issues/36

Bastien Sevajol 6 years ago
parent
commit
fd0cfceb55
1 changed files with 7 additions and 2 deletions
  1. 7 2
      synergine2/share.py

+ 7 - 2
synergine2/share.py View File

31
 
31
 
32
 class SharedData(object):
32
 class SharedData(object):
33
     def __init__(
33
     def __init__(
34
-        self, key: str,
34
+        self,
35
+        key: str,
35
         self_type: bool=False,
36
         self_type: bool=False,
36
         default: typing.Any=None,
37
         default: typing.Any=None,
37
     ) -> None:
38
     ) -> None:
44
         self.self_type = self_type
45
         self.self_type = self_type
45
         self._default = default
46
         self._default = default
46
         self.is_special_type = isinstance(self.default_value, (list, dict))
47
         self.is_special_type = isinstance(self.default_value, (list, dict))
48
+        self.type = type(self.default_value)
47
         if self.is_special_type:
49
         if self.is_special_type:
48
             if isinstance(self.default_value, list):
50
             if isinstance(self.default_value, list):
49
                 self.special_type = TrackedList
51
                 self.special_type = TrackedList
227
             except UnknownSharedData:
229
             except UnknownSharedData:
228
                 pass  # If no shared data, no previous value to remove
230
                 pass  # If no shared data, no previous value to remove
229
 
231
 
230
-            self.set(final_key, value_)
232
+            if not shared_data.is_special_type:
233
+                self.set(final_key, value_)
234
+            else:
235
+                self.set(final_key, shared_data.type(value_))
231
 
236
 
232
             for index in indexes:
237
             for index in indexes:
233
                 index.add(value_)
238
                 index.add(value_)