Skip to content

Commit 61d6779

Browse files
committed
better global vars duplication prevention
1 parent f814b07 commit 61d6779

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

src/asammdf/gui/widgets/file.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,23 +1278,11 @@ def load_channel_list(self, event=None, file_name=None, manually=False, show_pro
12781278
self.loaded_display_file = file_name, worker.hexdigest()
12791279

12801280
else:
1281-
extension = None
1281+
extension = ".dict"
12821282
info = file_name
12831283
channels = info.get("selected_channels", [])
12841284
self.loaded_display_file = Path(info.get("display_file_name", "")), b""
12851285

1286-
self.functions.update(info.get("functions", {}))
1287-
global_vars = [
1288-
line.strip()
1289-
for line in self.global_variables.splitlines()
1290-
if line.strip()
1291-
]
1292-
for line in info.get('global_variables', '').splitlines():
1293-
line = line.strip()
1294-
if line and line not in global_vars:
1295-
global_vars.append(line)
1296-
self.global_variables = "\n".join(global_vars)
1297-
12981286
if channels:
12991287
iterator = QtWidgets.QTreeWidgetItemIterator(self.channels_tree)
13001288

@@ -1325,7 +1313,16 @@ def load_channel_list(self, event=None, file_name=None, manually=False, show_pro
13251313

13261314
self.clear_windows()
13271315

1328-
if extension in (".dspf", ".dsp"):
1316+
if extension in (".dspf", ".dsp", ".dict"):
1317+
new_global_vars = "\n".join(line.strip() for line in info.get('global_variables', '').splitlines() if line.strip())
1318+
global_vars = "\n".join(line.strip() for line in self.global_variables.splitlines() if line.strip())
1319+
1320+
if new_global_vars not in global_vars:
1321+
global_vars += new_global_vars
1322+
updated_global_vars = True
1323+
else:
1324+
updated_global_vars = False
1325+
13291326
new_functions = {}
13301327

13311328
if "functions" in info:
@@ -1358,8 +1355,8 @@ def load_channel_list(self, event=None, file_name=None, manually=False, show_pro
13581355
"definition": definition,
13591356
}
13601357

1361-
if new_functions or info.get("global_variables", "") != self.global_variables:
1362-
self.update_functions({}, new_functions, f"{self.global_variables}\n{info.get('global_variables', '')}")
1358+
if new_functions or updated_global_vars:
1359+
self.update_functions({}, new_functions, global_vars)
13631360

13641361
windows = info.get("windows", [])
13651362
errors = {}

src/asammdf/gui/widgets/mdi_area.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3424,7 +3424,7 @@ def edit_channel(self, channel, item, widget):
34243424
if old_name in required_channels:
34253425
item = widget.item_by_uuid
34263426

3427-
computed_channel = widget.plot.channel_item_to_config(item)
3427+
computed_channel = widget.channel_item_to_config(item)
34283428
computed_channel["computation"] = replace_computation_dependency(
34293429
computed_channel["computation"], old_name, new_name
34303430
)

0 commit comments

Comments
 (0)