From 84ce5deeca4d3ccd74f09072ce00a2e7243c331c Mon Sep 17 00:00:00 2001 From: Nikolaj Schlej Date: Sun, 17 Nov 2013 12:13:37 +0100 Subject: [PATCH] Version 0.8.1 - memory management improved - heap corruption is (hopefully) no more --- ffsengine.cpp | 6 +++--- ffsengine.h | 4 ++-- uefitool.cpp | 19 ++++++++++++------- uefitool.h | 3 ++- uefitool.ui | 2 +- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/ffsengine.cpp b/ffsengine.cpp index d39bce0..fab4962 100644 --- a/ffsengine.cpp +++ b/ffsengine.cpp @@ -48,10 +48,10 @@ TreeModel* FfsEngine::model() const void FfsEngine::msg(const QString & message, const QModelIndex index) { - messageItems.enqueue(new MessageListItem(message, NULL, 0, index)); + messageItems.enqueue(MessageListItem(message, NULL, 0, index)); } -QQueue FfsEngine::message() +QQueue FfsEngine::message() { return messageItems; } @@ -2018,7 +2018,7 @@ UINT8 FfsEngine::reconstruct(const QModelIndex & index, QQueue & que return result; // Check for auth status valid attribute if (guidDefinedHeader->Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID) { - msg(tr("reconstruct: %1: GUID defined section signature can become invalid invalid") + msg(tr("reconstruct: %1: GUID defined section signature can now become invalid") .arg(guidToQString(guidDefinedHeader->SectionDefinitionGuid))); } // Replace new section body diff --git a/ffsengine.h b/ffsengine.h index c0ebe90..f7766f0 100644 --- a/ffsengine.h +++ b/ffsengine.h @@ -38,7 +38,7 @@ public: TreeModel* model() const; // Returns message items queue - QQueue message(); + QQueue message(); // Firmware image parsing UINT8 parseInputFile(const QByteArray & buffer); @@ -77,7 +77,7 @@ private: TreeModel *treeModel; // Message helper - QQueue messageItems; + QQueue messageItems; void msg(const QString & message, const QModelIndex index = QModelIndex()); // Internal operations diff --git a/uefitool.cpp b/uefitool.cpp index 104617f..4f708e2 100644 --- a/uefitool.cpp +++ b/uefitool.cpp @@ -64,6 +64,8 @@ void UEFITool::init() ui->actionSaveImageFile->setDisabled(true); // Make new ffsEngine + if (ffsEngine) + delete ffsEngine; ffsEngine = new FfsEngine(this); ui->structureTreeView->setModel(ffsEngine->model()); @@ -200,10 +202,11 @@ void UEFITool::saveImageFile() QByteArray reconstructed; UINT8 result = ffsEngine->reconstructImage(reconstructed); + showMessage(); if (result) { ui->statusBar->showMessage(tr("Reconstruction failed (%1)").arg(result)); - showMessage(); + return; } @@ -211,7 +214,6 @@ void UEFITool::saveImageFile() outputFile.write(reconstructed); outputFile.close(); ui->statusBar->showMessage(tr("Reconstructed image written")); - showMessage(); } void UEFITool::resizeTreeViewColums() @@ -250,12 +252,12 @@ void UEFITool::openImageFile(QString path) init(); UINT8 result = ffsEngine->parseInputFile(buffer); - if (result) + showMessage(); + if (result) ui->statusBar->showMessage(tr("Opened file can't be parsed (%1)").arg(result)); else ui->statusBar->showMessage(tr("Opened: %1").arg(fileInfo.fileName())); - - showMessage(); + resizeTreeViewColums(); } @@ -344,9 +346,12 @@ void UEFITool::dropEvent(QDropEvent* event) void UEFITool::showMessage() { ui->messageListWidget->clear(); - QQueue messageItems = ffsEngine->message(); + if (!ffsEngine) + return; + + messageItems = ffsEngine->message(); for (int i = 0; i < messageItems.count(); i++) { - ui->messageListWidget->addItem(messageItems.at(i)); + ui->messageListWidget->addItem(new MessageListItem(messageItems.at(i))); } } diff --git a/uefitool.h b/uefitool.h index 143a105..0a1d6e4 100644 --- a/uefitool.h +++ b/uefitool.h @@ -65,7 +65,8 @@ private slots: private: Ui::UEFITool * ui; FfsEngine* ffsEngine; - + QQueue messageItems; + void dragEnterEvent(QDragEnterEvent* event); void dropEvent(QDropEvent* event); void showMessage(); diff --git a/uefitool.ui b/uefitool.ui index 0d45587..4e1b01e 100644 --- a/uefitool.ui +++ b/uefitool.ui @@ -20,7 +20,7 @@ true - UEFITool 0.8.0 + UEFITool 0.8.1