Skip to content

Commit 286c2ac

Browse files
committed
Fixed a bug in IfThenElse/Switch for the following sequence:
1. set binary to valid data and then "expand_all()" 2. clear binary data (invalidate) so that the structure is showed in the dvc. For IfThenElse/Switch this means, that an extra level dvc level is inserted. 3. set binary to valid data again and then "expand_all()" 4. try to modify an item. This produced an error "... wxDataViewMainWindow::DoItemChanged(): invalid item" and is now fixed. Problem was, that when inserting an extra level an removing it again to the parent_dvc_item was not correctly calculated again.
1 parent cd0f178 commit 286c2ac

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

construct_editor/helper/wrapper.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,18 @@ def __init__(
477477
self._dvc_item: t.Optional[dv.DataViewItem] = None
478478
self._dvc_item_expanded: bool = False
479479

480+
def get_debug_infos(self) -> str:
481+
s = ""
482+
s += f"{'.'.join(self.path)}\n"
483+
s += f" - name={str(self.name)}\n"
484+
s += f" - construct={str(self.construct)}\n"
485+
s += f" - entry={self}\n"
486+
s += f" - dvc_item={str(self.dvc_item)}\n"
487+
s += f" - parent={self.parent}\n"
488+
s += f" - parent_dvc_item={self.get_parent_dvc_item()}\n"
489+
s += f" - subentries={self.subentries}"
490+
return s
491+
480492
# default "parent" ########################################################
481493
@property
482494
def parent(self) -> Optional["EntryConstruct"]:
@@ -974,6 +986,7 @@ def _get_subentry(self) -> "Optional[EntryConstruct]":
974986
"""Evaluate the conditional function to detect the type of the subentry"""
975987
obj = self.obj
976988
if obj is None:
989+
self._dvc_item = None # reset dvc_item, so that the subentries can correctly identify its parents dvc_item
977990
return None
978991
else:
979992
metadata = get_gui_metadata(obj)
@@ -1066,6 +1079,7 @@ def _get_subentry(self) -> "Optional[EntryConstruct]":
10661079
"""Evaluate the conditional function to detect the type of the subentry"""
10671080
obj = self.obj
10681081
if obj is None:
1082+
self._dvc_item = None # reset dvc_item, so that the subentries can correctly identify its parents dvc_item
10691083
return None
10701084
else:
10711085
metadata = get_gui_metadata(obj)
@@ -1528,6 +1542,7 @@ def _get_subentry(self) -> "Optional[EntryConstruct]":
15281542
"""Evaluate the conditional function to detect the type of the subentry"""
15291543
obj = self.obj
15301544
if obj is None:
1545+
self._dvc_item = None # reset dvc_item, so that the subentries can correctly identify its parents dvc_item
15311546
return None
15321547
else:
15331548
metadata = get_gui_metadata(obj)
@@ -1607,6 +1622,7 @@ def _get_subentry(self) -> "Optional[EntryConstruct]":
16071622
"""Evaluate the conditional function to detect the type of the subentry"""
16081623
obj = self.obj
16091624
if obj is None:
1625+
self._dvc_item = None # reset dvc_item, so that the subentries can correctly identify its parents dvc_item
16101626
return None
16111627
else:
16121628
metadata = get_gui_metadata(obj)

construct_editor/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ def on_gallery_selection_changed(self, event):
293293
def on_clear_binary_clicked(self, event):
294294
self.example_selector_lbx.SetSelection(wx.NOT_FOUND)
295295
self.construct_hex_editor.binary = bytes()
296+
self.construct_hex_editor.construct_editor.expand_all()
296297

297298
def on_example_selection_changed(self, event):
298299
selection = self.gallery_selector_lbx.GetStringSelection()
@@ -301,6 +302,7 @@ def on_example_selection_changed(self, event):
301302

302303
# Set example binary
303304
self.construct_hex_editor.binary = example_binary
305+
self.construct_hex_editor.construct_editor.expand_all()
304306

305307
def on_load_binary_file_clicked(self, event):
306308
with wx.FileDialog(

0 commit comments

Comments
 (0)