Skip to content

Commit

Permalink
Fix UI error when adding new OW Table
Browse files Browse the repository at this point in the history
The Qt Tree Model would import the same Table Node twice and thus it
would show the new table twice.

This commit also adds log messages when removing an OW table.
  • Loading branch information
kimwnasptd committed Sep 29, 2019
1 parent d7f5216 commit 2fc3752
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
19 changes: 15 additions & 4 deletions core_files/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,15 +867,25 @@ def remove_table(self, i):
ow.remove()

# Clear all of the godam data
log.info("Removing the OW Pointers Table at: {}".format(
conv.HEX(tbl.table_addr)
))
rom.fill_with_data(tbl.table_addr, 259 * 4, 0xFF)

log.info("Removing the OW Data Table at: {}".format(
conv.HEX(tbl.ow_data_addr)
))
rom.fill_with_data(tbl.ow_data_addr, 256 * 36, 0xFF)

log.info("Removing the Frames Pointers data at: {}".format(
conv.HEX(tbl.frames_ptrs_addr)
))
rom.fill_with_data(tbl.frames_ptrs_addr,
256 * 8 * rom.FRAMES_PER_OW,
0xFF)
rom.fill_with_data(tbl.ow_data_addr, 256 * 36, 0xFF)
rom.fill_with_data(tbl.table_addr, 259 * 4, 0xFF)

# Move all the table ptrs to the left
addr = self.ow_tables_addr + (i * 4)
log.info("remove_table: about to remove: " + conv.HEX(addr))
rom.fill_with_data(addr, 4, 0)

addr += 4
Expand All @@ -884,7 +894,8 @@ def remove_table(self, i):
rom.move_data(addr, addr - 4, 4, 0)
addr += 4

# Re-initialise the entire root
# Re-initialise the entire root and update the available free space
rom.update_free_space(0xA000)
self.reload()

def tables_num(self):
Expand Down
16 changes: 7 additions & 9 deletions ui/tree_view_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __init__(self, model_root, root, parent=None):

for ow in range(len(root.tables_list[table].ow_data_ptrs)):
# add the ow nodes
newOWNode = OWNode(ow, newTableNode, self.root)
OWNode(ow, newTableNode, self.root)

def rowCount(self, parent=QtCore.QModelIndex()):
"""
Expand Down Expand Up @@ -285,13 +285,14 @@ def insertRows(self, position, rows, parent=QtCore.QModelIndex()):

if parentNode.typeInfo() == "table_node":
# Adding OWs
childNode = OWNode(position + row, self.root)
success = parentNode.insertChild(position + row, childNode)
ow = OWNode(position + row, self.root)
success = parentNode.insertChild(position + row, ow)
# Re-init the node, so it loads the frame
self.setData(self.index(row + position, 0, parent), None)
if parentNode.typeInfo() == "NODE":
childNode = TableNode(childCount, self.root)
success = parentNode.insertChild(childCount, childNode)
# Create the Table Node on the rootNode
TableNode(childCount, self._rootNode)
success = True

# Only for the OWs, increase the name Id by one,
# in case an OW was INSERTED
Expand Down Expand Up @@ -388,14 +389,11 @@ def resizeOW(self, ow_id, table_id, ow_type, num_of_frames, ui):
ui.item_selected(self.index(ow_id, 0, tableNode))

def insertTable(self, ow_ptrs, data_ptrs, frames_ptrs, frames_addr, ui):
parent = QtCore.QModelIndex()
parentNode = self.getNode(parent)

self.root.custom_table_import(ow_ptrs,
data_ptrs,
frames_ptrs,
frames_addr)
self.insertRows(-1, 1, parent)
self.insertRows(-1, 1)

ui.selected_table = self.tablesCount() - 1
if ui.selected_table == -1:
Expand Down

0 comments on commit 2fc3752

Please sign in to comment.