Skip to content

Commit

Permalink
More proper solution to #137
Browse files Browse the repository at this point in the history
  • Loading branch information
vit9696 committed Jun 23, 2018
1 parent c4567dc commit 35c207d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
26 changes: 26 additions & 0 deletions ffsengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 1 addition & 17 deletions treeitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}

0 comments on commit 35c207d

Please sign in to comment.