More proper solution to #137

This commit is contained in:
vit9696 2018-06-23 19:46:56 +03:00
parent c4567dcffc
commit 35c207dd8c
2 changed files with 27 additions and 17 deletions

View File

@ -2453,6 +2453,32 @@ void FfsEngine::rebasePeiFiles(const QModelIndex & index)
}
}
}
// Rebase VTF in subsequent volumes.
QModelIndex parent = index.parent();
while (parent.isValid() && model->type(parent) != Types::Volume)
parent = parent.parent();
if (parent.isValid()) {
QModelIndex volumeContainer = parent.parent();
// Iterate over volumes starting from the one after.
for (int i = parent.row() + 1; i < model->rowCount(volumeContainer); i++) {
QModelIndex currentVolumeIndex = volumeContainer.child(i, 0);
// Iterate over files within each volume after the current one.
for (int j = 0; j < model->rowCount(currentVolumeIndex); j++) {
QModelIndex currentFileIndex = currentVolumeIndex.child(j, 0);
if (model->header(currentFileIndex).left(sizeof(EFI_GUID)) == EFI_FFS_VOLUME_TOP_FILE_GUID) {
for (int k = 0; k < model->rowCount(currentFileIndex); k++) {
QModelIndex currentSectionIndex = currentFileIndex.child(k, 0);
// If section stores PE32 or TE image
if (model->subtype(currentSectionIndex) == EFI_SECTION_PE32 || model->subtype(currentSectionIndex) == EFI_SECTION_TE)
// Set rebase action
if (model->action(currentSectionIndex) != Actions::Remove)
model->setAction(currentSectionIndex, Actions::Rebase);
}
}
}
}
}
}
UINT8 FfsEngine::insert(const QModelIndex & index, const QByteArray & object, const UINT8 mode)

View File

@ -209,22 +209,6 @@ 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<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);
}
}
}
}