1
0
Fork 0

close and delete trace file

This commit is contained in:
torusrxxx 2018-08-19 18:31:16 +08:00 committed by Duncan Ogilvie
parent 80c303d48d
commit c5830e5c26
4 changed files with 47 additions and 10 deletions

View File

@ -446,6 +446,10 @@ void TraceBrowser::setupRightClickContextMenu()
{
return mTraceFile != nullptr;
});
mMenuBuilder->addAction(makeAction(DIcon("fatal-error.png"), tr("Close and delete"), SLOT(closeDeleteSlot())), [this](QMenu*)
{
return mTraceFile != nullptr;
});
mMenuBuilder->addSeparator();
auto isValid = [this](QMenu*)
{
@ -921,6 +925,19 @@ void TraceBrowser::closeFileSlot()
reloadData();
}
void TraceBrowser::closeDeleteSlot()
{
QMessageBox msgbox(QMessageBox::Critical, tr("Close and delete"), tr("Are you really going to delete this file?"), QMessageBox::Yes | QMessageBox::Cancel, this);
if(msgbox.exec() == QMessageBox::Yes)
{
if(mTraceFile->Delete() == false)
SimpleErrorBox(this, tr("Error"), "del error");
delete mTraceFile;
mTraceFile = nullptr;
reloadData();
}
}
void TraceBrowser::parseFinishedSlot()
{
if(mTraceFile->isError())

View File

@ -106,6 +106,7 @@ public slots:
void openSlot(const QString & fileName);
void toggleRunTraceSlot();
void closeFileSlot();
void closeDeleteSlot();
void parseFinishedSlot();
void tokenizerConfigUpdatedSlot();

View File

@ -42,6 +42,7 @@ bool TraceFileReader::Open(const QString & fileName)
emit parseFinished();
return false;
}
}
void TraceFileReader::Close()
@ -60,6 +61,23 @@ void TraceFileReader::Close()
error = false;
}
bool TraceFileReader::Delete()
{
if(parser != NULL)
{
parser->requestInterruption();
parser->wait();
}
bool value = traceFile.remove();
progress.store(0);
length = 0;
fileIndex.clear();
hashValue = 0;
EXEPath.clear();
error = false;
return value;
}
void TraceFileReader::parseFinishedSlot()
{
if(!error)
@ -74,27 +92,27 @@ void TraceFileReader::parseFinishedSlot()
//GuiAddLogMessage(QString("%1;%2;%3\r\n").arg(i.first).arg(i.second.first).arg(i.second.second).toUtf8().constData());
}
bool TraceFileReader::isError()
bool TraceFileReader::isError() const
{
return error;
}
int TraceFileReader::Progress()
int TraceFileReader::Progress() const
{
return progress.load();
}
unsigned long long TraceFileReader::Length()
unsigned long long TraceFileReader::Length() const
{
return length;
}
duint TraceFileReader::HashValue()
duint TraceFileReader::HashValue() const
{
return hashValue;
}
QString TraceFileReader::ExePath()
QString TraceFileReader::ExePath() const
{
return EXEPath;
}

View File

@ -17,18 +17,19 @@ public:
TraceFileReader(QObject* parent = NULL);
bool Open(const QString & fileName);
void Close();
bool isError();
int Progress();
bool Delete();
bool isError() const;
int Progress() const;
unsigned long long Length();
unsigned long long Length() const;
REGDUMP Registers(unsigned long long index);
void OpCode(unsigned long long index, unsigned char* buffer, int* opcodeSize);
DWORD ThreadId(unsigned long long index);
int MemoryAccessCount(unsigned long long index);
void MemoryAccessInfo(unsigned long long index, duint* address, duint* oldMemory, duint* newMemory, bool* isValid);
duint HashValue();
QString ExePath();
duint HashValue() const;
QString ExePath() const;
void purgeLastPage();