Fixed bug with FocusedRegionGroupItem not correctly updating the contained byte items

This commit is contained in:
Nav
2023-03-11 16:09:21 +00:00
parent d1e7b900de
commit 4e8bd55acd
4 changed files with 25 additions and 2 deletions

View File

@@ -28,6 +28,27 @@ namespace Bloom::Widgets
}
}
FocusedRegionGroupItem::~FocusedRegionGroupItem() {
const auto updateChildItems = [] (const decltype(this->items)& items, const auto& updateChildItems) -> void {
for (auto& item : items) {
auto* byteItem = dynamic_cast<ByteItem*>(item);
if (byteItem != nullptr) {
byteItem->grouped = false;
continue;
}
auto* groupItem = dynamic_cast<GroupItem*>(item);
if (groupItem != nullptr) {
updateChildItems(groupItem->items, updateChildItems);
}
}
};
updateChildItems(this->items, updateChildItems);
}
void FocusedRegionGroupItem::refreshValue(const HexViewerSharedState& hexViewerState) {
if (!hexViewerState.data.has_value()) {
this->valueLabel = std::nullopt;

View File

@@ -20,6 +20,8 @@ namespace Bloom::Widgets
HexViewerItem* parent
);
~FocusedRegionGroupItem();
void refreshValue(const HexViewerSharedState& hexViewerState);
void paint(

View File

@@ -16,6 +16,8 @@ namespace Bloom::Widgets
class GroupItem: public HexViewerItem
{
public:
std::vector<HexViewerItem*> items;
~GroupItem();
QSize size() const override {
@@ -35,7 +37,6 @@ namespace Bloom::Widgets
}
protected:
std::vector<HexViewerItem*> items;
QSize groupSize = {};
bool multiLine = false;

View File

@@ -35,7 +35,6 @@ namespace Bloom::Widgets
}
byteItem.parent = this;
byteItem.grouped = false;
this->items.push_back(&byteItem);
}