Added RefreshDeferrer to emulation widgets

This commit is contained in:
xarkes 2019-01-13 19:11:59 +01:00
parent c345981af9
commit b27cd39ddc
13 changed files with 73 additions and 17 deletions

View File

@ -198,12 +198,12 @@ void MainWindow::initUI()
commentsDock = new CommentsWidget(this, ui->actionComments);
stringsDock = new StringsWidget(this, ui->actionStrings);
flagsDock = new FlagsWidget(this, ui->actionFlags);
//stackDock = new StackWidget(this, ui->actionStack);
//backtraceDock = new BacktraceWidget(this, ui->actionBacktrace);
//registersDock = new RegistersWidget(this, ui->actionRegisters);
//memoryMapDock = new MemoryMapWidget(this, ui->actionMemoryMap);
//breakpointDock = new BreakpointWidget(this, ui->actionBreakpoint);
//registerRefsDock = new RegisterRefsWidget(this, ui->actionRegisterRefs);
stackDock = new StackWidget(this, ui->actionStack);
backtraceDock = new BacktraceWidget(this, ui->actionBacktrace);
registersDock = new RegistersWidget(this, ui->actionRegisters);
memoryMapDock = new MemoryMapWidget(this, ui->actionMemoryMap);
breakpointDock = new BreakpointWidget(this, ui->actionBreakpoint);
registerRefsDock = new RegisterRefsWidget(this, ui->actionRegisterRefs);
#ifdef CUTTER_ENABLE_JUPYTER
jupyterDock = new JupyterWidget(this, ui->actionJupyter);
#else
@ -578,13 +578,14 @@ void MainWindow::restoreDocks()
tabifyDockWidget(dashboardDock, vTablesDock);
// Add Stack, Registers and Backtrace vertically stacked
//addDockWidget(Qt::TopDockWidgetArea, stackDock);
//splitDockWidget(stackDock, registersDock, Qt::Vertical);
//tabifyDockWidget(stackDock, backtraceDock);
addDockWidget(Qt::TopDockWidgetArea, stackDock);
splitDockWidget(stackDock, registersDock, Qt::Vertical);
tabifyDockWidget(stackDock, backtraceDock);
// MemoryMap/Breakpoint/RegRefs widget goes in the center tabs
//tabifyDockWidget(dashboardDock, memoryMapDock);
//tabifyDockWidget(dashboardDock, breakpointDock);
//tabifyDockWidget(dashboardDock, registerRefsDock);
tabifyDockWidget(dashboardDock, memoryMapDock);
tabifyDockWidget(dashboardDock, breakpointDock);
tabifyDockWidget(dashboardDock, registerRefsDock);
#ifdef CUTTER_ENABLE_JUPYTER
tabifyDockWidget(dashboardDock, jupyterDock);
#endif

View File

@ -23,6 +23,10 @@ BacktraceWidget::BacktraceWidget(MainWindow *main, QAction *action) :
viewBacktrace->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
ui->verticalLayout->addWidget(viewBacktrace);
refreshDeferrer = createRefreshDeferrer([this]() {
updateContents();
});
connect(Core(), &CutterCore::refreshAll, this, &BacktraceWidget::updateContents);
connect(Core(), &CutterCore::seekChanged, this, &BacktraceWidget::updateContents);
connect(Config(), &Configuration::fontsUpdated, this, &BacktraceWidget::fontsUpdatedSlot);
@ -32,6 +36,9 @@ BacktraceWidget::~BacktraceWidget() {}
void BacktraceWidget::updateContents()
{
if (!refreshDeferrer->attemptRefresh(nullptr)) {
return;
}
setBacktraceGrid();
}

View File

@ -31,4 +31,5 @@ private:
std::unique_ptr<Ui::BacktraceWidget> ui;
QStandardItemModel *modelBacktrace = new QStandardItemModel(1, 5, this);
QTableView *viewBacktrace = new QTableView;
RefreshDeferrer *refreshDeferrer;
};

View File

@ -122,6 +122,10 @@ BreakpointWidget::BreakpointWidget(MainWindow *main, QAction *action) :
ui->breakpointTreeView->setModel(breakpointProxyModel);
ui->breakpointTreeView->sortByColumn(BreakpointModel::AddrColumn, Qt::AscendingOrder);
refreshDeferrer = createRefreshDeferrer([this]() {
refreshBreakpoint();
});
setScrollMode();
actionDelBreakpoint = new QAction(tr("Delete breakpoint"));
actionToggleBreakpoint = new QAction(tr("Toggle breakpoint"));
@ -138,10 +142,14 @@ BreakpointWidget::BreakpointWidget(MainWindow *main, QAction *action) :
this, SLOT(showBreakpointContextMenu(const QPoint &)));
}
BreakpointWidget::~BreakpointWidget() {}
BreakpointWidget::~BreakpointWidget() = default;
void BreakpointWidget::refreshBreakpoint()
{
if (!refreshDeferrer->attemptRefresh(nullptr)) {
return;
}
breakpointModel->beginResetModel();
breakpoints = Core()->getBreakpoints();
breakpointModel->endResetModel();

View File

@ -84,4 +84,6 @@ private:
QAction *actionToggleBreakpoint = nullptr;
void setScrollMode();
RefreshDeferrer *refreshDeferrer;
};

View File

@ -118,14 +118,22 @@ MemoryMapWidget::MemoryMapWidget(MainWindow *main, QAction *action) :
setScrollMode();
refreshDeferrer = createRefreshDeferrer([this]() {
refreshMemoryMap();
});
connect(Core(), &CutterCore::refreshAll, this, &MemoryMapWidget::refreshMemoryMap);
connect(Core(), &CutterCore::registersChanged, this, &MemoryMapWidget::refreshMemoryMap);
}
MemoryMapWidget::~MemoryMapWidget() {}
MemoryMapWidget::~MemoryMapWidget() = default;
void MemoryMapWidget::refreshMemoryMap()
{
if (!refreshDeferrer->attemptRefresh(nullptr)) {
return;
}
memoryModel->beginResetModel();
memoryMaps = Core()->getMemoryMap();
memoryModel->endResetModel();

View File

@ -80,4 +80,6 @@ private:
QList<MemoryMapDescription> memoryMaps;
void setScrollMode();
RefreshDeferrer *refreshDeferrer;
};

View File

@ -119,6 +119,10 @@ RegisterRefsWidget::RegisterRefsWidget(MainWindow *main, QAction *action) :
actionCopyValue = new QAction(tr("Copy register value"));
actionCopyRef = new QAction(tr("Copy register reference"));
refreshDeferrer = createRefreshDeferrer([this](){
refreshRegisterRef();
});
// Ctrl-F to show/hide the filter entry
QShortcut *search_shortcut = new QShortcut(QKeySequence::Find, this);
connect(search_shortcut, &QShortcut::activated, ui->quickFilterView, &QuickFilterView::showFilter);
@ -145,10 +149,14 @@ RegisterRefsWidget::RegisterRefsWidget(MainWindow *main, QAction *action) :
});
}
RegisterRefsWidget::~RegisterRefsWidget() {}
RegisterRefsWidget::~RegisterRefsWidget() = default;
void RegisterRefsWidget::refreshRegisterRef()
{
if (!refreshDeferrer->attemptRefresh(nullptr)) {
return;
}
registerRefModel->beginResetModel();
registerRefs = Core()->getRegisterRefs();
registerRefModel->endResetModel();

View File

@ -83,4 +83,6 @@ private:
QAction *actionCopyRef;
CutterTreeWidget *tree;
void setScrollMode();
RefreshDeferrer *refreshDeferrer;
};

View File

@ -14,14 +14,21 @@ RegistersWidget::RegistersWidget(MainWindow *main, QAction *action) :
registerLayout->setVerticalSpacing(0);
ui->verticalLayout->addLayout(registerLayout);
refreshDeferrer = createRefreshDeferrer([this]() {
updateContents();
});
connect(Core(), &CutterCore::refreshAll, this, &RegistersWidget::updateContents);
connect(Core(), &CutterCore::registersChanged, this, &RegistersWidget::updateContents);
}
RegistersWidget::~RegistersWidget() {}
RegistersWidget::~RegistersWidget() = default;
void RegistersWidget::updateContents()
{
if (!refreshDeferrer->attemptRefresh(nullptr)) {
return;
}
setRegisterGrid();
}

View File

@ -32,4 +32,5 @@ private:
QGridLayout *registerLayout = new QGridLayout;
int numCols = 2;
int registerLen = 0;
RefreshDeferrer *refreshDeferrer;
};

View File

@ -29,6 +29,10 @@ StackWidget::StackWidget(MainWindow *main, QAction *action) :
editAction = new QAction(tr("Edit stack value..."));
viewStack->setContextMenuPolicy(Qt::CustomContextMenu);
refreshDeferrer = createRefreshDeferrer([this]() {
updateContents();
});
connect(Core(), &CutterCore::refreshAll, this, &StackWidget::updateContents);
connect(Core(), &CutterCore::seekChanged, this, &StackWidget::updateContents);
connect(Core(), &CutterCore::stackChanged, this, &StackWidget::updateContents);
@ -40,10 +44,14 @@ StackWidget::StackWidget(MainWindow *main, QAction *action) :
connect(editAction, &QAction::triggered, this, &StackWidget::editStack);
}
StackWidget::~StackWidget() {}
StackWidget::~StackWidget() = default;
void StackWidget::updateContents()
{
if (!refreshDeferrer->attemptRefresh(nullptr)) {
return;
}
setStackGrid();
}

View File

@ -37,4 +37,5 @@ private:
QStandardItemModel *modelStack = new QStandardItemModel(1, 3, this);
QAction *seekAction;
QAction *editAction;
RefreshDeferrer *refreshDeferrer;
};