1
0
Fork 0

Fixed persistent crash at registerMenuBuilder; adjust menu order; fix hash msgbox

This commit is contained in:
torusrxxx 2023-10-07 12:28:32 +08:00
parent 8700a5cdb5
commit 07fbd1a9af
No known key found for this signature in database
GPG Key ID: A795C73A0F1CFADD
6 changed files with 61 additions and 50 deletions

View File

@ -836,38 +836,13 @@ void TraceBrowser::setupRightClickContextMenu()
return getTraceFile()->Registers(getInitialSelection()).regcontext.cip;
});
QAction* toggleTraceRecording = makeShortcutAction(DIcon("control-record"), tr("Start recording"), SLOT(toggleTraceRecordingSlot()), "ActionToggleRunTrace");
mMenuBuilder->addAction(toggleTraceRecording, [toggleTraceRecording](QMenu*)
auto mTraceFileNotNull = [](QMenu*)
{
if(!DbgIsDebugging())
return false;
if(isRecording())
{
toggleTraceRecording->setText(tr("Stop recording"));
toggleTraceRecording->setIcon(DIcon("control-stop"));
}
else
{
toggleTraceRecording->setText(tr("Start recording"));
toggleTraceRecording->setIcon(DIcon("control-record"));
}
return true;
});
auto mTraceFileIsNull = [this](QMenu*)
{
return !isFileOpened();
return true; // This should always be true now
};
auto mTraceFileNotNull = [this](QMenu*)
{
return isFileOpened();
};
mMenuBuilder->addAction(makeAction(DIcon("close"), tr("Close recording"), SLOT(closeFileSlot())), mTraceFileNotNull);
mMenuBuilder->addAction(makeAction(DIcon("delete"), tr("Delete recording"), SLOT(closeDeleteSlot())), mTraceFileNotNull);
mMenuBuilder->addSeparator();
auto isDebugging = [this](QMenu*)
{
return isFileOpened() && DbgIsDebugging();
return DbgIsDebugging();
};
MenuBuilder* copyMenu = new MenuBuilder(this, mTraceFileNotNull);
@ -949,6 +924,27 @@ void TraceBrowser::setupRightClickContextMenu()
synchronizeCpuAction->setChecked(mTraceSyncCpu);
mMenuBuilder->addAction(synchronizeCpuAction);
mMenuBuilder->addSeparator();
QAction* toggleTraceRecording = makeShortcutAction(DIcon("control-record"), tr("Start recording"), SLOT(toggleTraceRecordingSlot()), "ActionToggleRunTrace");
mMenuBuilder->addAction(toggleTraceRecording, [toggleTraceRecording](QMenu*)
{
if(!DbgIsDebugging())
return false;
if(isRecording())
{
toggleTraceRecording->setText(tr("Stop recording"));
toggleTraceRecording->setIcon(DIcon("control-stop"));
}
else
{
toggleTraceRecording->setText(tr("Start recording"));
toggleTraceRecording->setIcon(DIcon("control-record"));
}
return true;
});
mMenuBuilder->addAction(makeAction(DIcon("close"), tr("Close recording"), SLOT(closeFileSlot())), mTraceFileNotNull);
mMenuBuilder->addAction(makeAction(DIcon("delete"), tr("Delete recording"), SLOT(closeDeleteSlot())), mTraceFileNotNull);
mMenuBuilder->loadFromConfig();
}
@ -1331,12 +1327,6 @@ void TraceBrowser::parseFinishedSlot()
}
else
{
if(mTraceFile->HashValue() && DbgIsDebugging())
if(DbgFunctions()->DbGetHash() != mTraceFile->HashValue())
{
SimpleWarningBox(this, tr("Trace file is recorded for another debuggee"),
tr("Checksum is different for current trace file and the debugee. This probably means you have opened a wrong trace file. This trace file is recorded for \"%1\"").arg(mTraceFile->ExePath()));
}
setRowCount(mTraceFile->Length());
}
setSingleSelection(0);

View File

@ -417,9 +417,9 @@ void TraceFileParser::readFileHeader(TraceFileReader* that)
{
a = a.mid(2);
#ifdef _WIN64
that->hashValue = a.toLongLong(&ok, 16);
that->hashValue = a.toULongLong(&ok, 16);
#else //x86
that->hashValue = a.toLong(&ok, 16);
that->hashValue = a.toULong(&ok, 16);
#endif //_WIN64
if(!ok)
that->hashValue = 0;

View File

@ -88,7 +88,7 @@ void TraceManager::toggleTraceRecording()
void TraceManager::contextMenuEvent(QContextMenuEvent* event)
{
QMenu wMenu;
QAction traceCoverageToggleTraceRecording(tr("Start recording"));
QAction traceCoverageToggleTraceRecording(tr("Start recording"), this);
if(TraceBrowser::isRecording())
{
traceCoverageToggleTraceRecording.setText(tr("Stop trace recording"));
@ -105,7 +105,7 @@ void TraceManager::contextMenuEvent(QContextMenuEvent* event)
traceCoverageToggleTraceRecording.setEnabled(false);
wMenu.addAction(&traceCoverageToggleTraceRecording);
QAction openAction(DIcon("folder-horizontal-open"), tr("Open"));
QAction openAction(DIcon("folder-horizontal-open"), tr("Open"), this);
connect(&openAction, SIGNAL(triggered()), this, SLOT(open()));
wMenu.addAction(&openAction);

View File

@ -120,6 +120,14 @@ void TraceWidget::parseFinishedSlot()
}
else if(mTraceFile->Length() > 0)
{
if(mTraceFile->HashValue() && DbgIsDebugging())
{
if(DbgFunctions()->DbGetHash() != mTraceFile->HashValue())
{
SimpleWarningBox(this, tr("Trace file is recorded for another debuggee"),
tr("Checksum is different for current trace file and the debugee. This probably means you have opened a wrong trace file. This trace file is recorded for \"%1\"").arg(mTraceFile->ExePath()));
}
}
const int count = mTraceFile->MemoryAccessCount(0);
if(count > 0)
{

View File

@ -1095,8 +1095,15 @@ bool Configuration::registerMenuBuilder(MenuBuilder* menu, size_t count)
{
QString id = menu->getId();
for(const auto & i : NamedMenuBuilders)
if(i.type == 0 && i.builder->getId() == id)
return false; //already exists
{
if(i.type == 0)
{
if(i.builder.isNull())
continue;
if(i.builder->getId() == id)
return false; //already exists
}
}
NamedMenuBuilders.append(MenuMap(menu, count));
return true;
}
@ -1112,10 +1119,18 @@ void Configuration::unregisterMenuBuilder(MenuBuilder* menu)
QString id = menu->getId();
for(auto i = NamedMenuBuilders.begin(); i != NamedMenuBuilders.end(); ++i)
{
if(i->type == 0 && i->builder->getId() == id)
if(i->type == 0)
{
NamedMenuBuilders.erase(i);
return;
if(i->builder.isNull())
{
NamedMenuBuilders.erase(i);
continue;
}
if(i->builder->getId() == id)
{
NamedMenuBuilders.erase(i);
return;
}
}
}
}

View File

@ -3,9 +3,11 @@
#include <QObject>
#include <QKeySequence>
#include <QMap>
#include <QPointer>
#include <QColor>
#include <QFont>
#include "Imports.h"
#include "MenuBuilder.h"
// TODO: declare AppearanceDialog and SettingsDialog entries here, so that you only have to do it in once place
#define Config() (Configuration::instance())
@ -17,7 +19,6 @@
#define ConfigHScrollBarStyle() "QScrollBar:horizontal{border:1px solid grey;background:#f1f1f1;height:10px}QScrollBar::handle:horizontal{background:#aaaaaa;min-width:20px;margin:1px}QScrollBar::add-line:horizontal,QScrollBar::sub-line:horizontal{width:0;height:0}"
#define ConfigVScrollBarStyle() "QScrollBar:vertical{border:1px solid grey;background:#f1f1f1;width:10px}QScrollBar::handle:vertical{background:#aaaaaa;min-height:20px;margin:1px}QScrollBar::add-line:vertical,QScrollBar::sub-line:vertical{width:0;height:0}"
class MenuBuilder;
class QAction;
class QWheelEvent;
@ -89,12 +90,9 @@ public:
//custom menu maps
struct MenuMap
{
union
{
QList<QAction*>* mainMenuList;
MenuBuilder* builder;
};
int type;
QList<QAction*>* mainMenuList;
QPointer<MenuBuilder> builder;
int type; // 0: builder; 1: mainMenuList
size_t count;
MenuMap() { }