From c4567dcffce4cf2dca47f5290722ded6f2bac615 Mon Sep 17 00:00:00 2001 From: vit9696 Date: Sat, 23 Jun 2018 00:39:51 +0300 Subject: [PATCH] Attempt to workaround #137 --- ffsengine.h | 2 +- treeitem.cpp | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ffsengine.h b/ffsengine.h index 8b2f327..0a2130d 100644 --- a/ffsengine.h +++ b/ffsengine.h @@ -95,7 +95,7 @@ public: UINT8 replace(const QModelIndex & index, const QByteArray & object, const UINT8 mode); UINT8 remove(const QModelIndex & index); UINT8 rebuild(const QModelIndex & index); - UINT8 doNotRebuild(const QModelIndex & index); + UINT8 doNotRebuild(const QModelIndex & index); UINT8 dump(const QModelIndex & index, const QString & path, const QString & filter = QString()); UINT8 patch(const QModelIndex & index, const QVector & patches); diff --git a/treeitem.cpp b/treeitem.cpp index 925d95b..cdee8c2 100644 --- a/treeitem.cpp +++ b/treeitem.cpp @@ -209,7 +209,22 @@ void TreeItem::setAction(const UINT8 action) // Set rebuild action for parent, if it has no action now if (parentItem && parentItem->type() != Types::Root - && parentItem->action() == Actions::NoAction) + && parentItem->action() == Actions::NoAction) { parentItem->setAction(Actions::Rebuild); -} + // Set rebuild action for subsequent items after parent. + // This is a little ugly, but fixes UEFIReplace image corruption, + // where one cannot manually choose the targets for rebuild. + // See: https://github.com/LongSoft/UEFITool/issues/137 + TreeItem *grandParent = parentItem->parentItem; + if (grandParent) { + QList &parentCousins = grandParent->childItems; + int count = parentCousins.count(); + for (int i = parentCousins.indexOf(parentItem) + 1; i < count; i++) { + TreeItem *parentCousin = parentCousins.value(i, NULL); + if (parentCousin && parentCousin->action() == Actions::NoAction) + parentCousin->setAction(Actions::Rebuild); + } + } + } +}