Attempt to workaround #137

This commit is contained in:
vit9696 2018-06-23 00:39:51 +03:00
parent 4bb759780f
commit c4567dcffc
2 changed files with 18 additions and 3 deletions

View file

@ -95,7 +95,7 @@ public:
UINT8 replace(const QModelIndex & index, const QByteArray & object, const UINT8 mode); UINT8 replace(const QModelIndex & index, const QByteArray & object, const UINT8 mode);
UINT8 remove(const QModelIndex & index); UINT8 remove(const QModelIndex & index);
UINT8 rebuild(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 dump(const QModelIndex & index, const QString & path, const QString & filter = QString());
UINT8 patch(const QModelIndex & index, const QVector<PatchData> & patches); UINT8 patch(const QModelIndex & index, const QVector<PatchData> & patches);

View file

@ -209,7 +209,22 @@ void TreeItem::setAction(const UINT8 action)
// Set rebuild action for parent, if it has no action now // Set rebuild action for parent, if it has no action now
if (parentItem && parentItem->type() != Types::Root if (parentItem && parentItem->type() != Types::Root
&& parentItem->action() == Actions::NoAction) && parentItem->action() == Actions::NoAction) {
parentItem->setAction(Actions::Rebuild); 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<TreeItem *> &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);
}
}
}
}