mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-19 10:58:51 +00:00
Fix DisassemblyWidget refreshing
This commit is contained in:
parent
d651a0d8be
commit
9ef971263f
@ -29,8 +29,12 @@ class ReplacingRefreshDeferrerAccumulator: public RefreshDeferrerAccumulator
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
T *value = nullptr;
|
T *value = nullptr;
|
||||||
|
bool replaceIfNull;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
explicit ReplacingRefreshDeferrerAccumulator(bool replaceIfNull = true)
|
||||||
|
: replaceIfNull(replaceIfNull) {}
|
||||||
|
|
||||||
~ReplacingRefreshDeferrerAccumulator() override
|
~ReplacingRefreshDeferrerAccumulator() override
|
||||||
{
|
{
|
||||||
delete value;
|
delete value;
|
||||||
@ -39,6 +43,9 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void accumulate(RefreshDeferrerParams params) override
|
void accumulate(RefreshDeferrerParams params) override
|
||||||
{
|
{
|
||||||
|
if (!replaceIfNull && !params) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
delete value;
|
delete value;
|
||||||
value = static_cast<T *>(params);
|
value = static_cast<T *>(params);
|
||||||
}
|
}
|
||||||
|
@ -33,14 +33,13 @@ protected:
|
|||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
||||||
template<class ParamResult, typename Func>
|
template<class ParamResult, typename Func>
|
||||||
RefreshDeferrer *createReplacingRefreshDeferrer(Func refreshNowFunc)
|
RefreshDeferrer *createReplacingRefreshDeferrer(bool replaceIfNull, Func refreshNowFunc)
|
||||||
{
|
{
|
||||||
auto *deferrer = new RefreshDeferrer(new ReplacingRefreshDeferrerAccumulator<ParamResult>(), this);
|
auto *deferrer = new RefreshDeferrer(new ReplacingRefreshDeferrerAccumulator<ParamResult>(replaceIfNull), this);
|
||||||
deferrer->registerFor(this);
|
deferrer->registerFor(this);
|
||||||
connect(deferrer, &RefreshDeferrer::refreshNow, this, [refreshNowFunc](const RefreshDeferrerParamsResult paramsResult) {
|
connect(deferrer, &RefreshDeferrer::refreshNow, this, [refreshNowFunc](const RefreshDeferrerParamsResult paramsResult) {
|
||||||
printf("got refresh now!\n");
|
auto *result = static_cast<const ParamResult *>(paramsResult);
|
||||||
auto *offset = static_cast<const ParamResult *>(paramsResult);
|
refreshNowFunc(result);
|
||||||
refreshNowFunc(offset);
|
|
||||||
});
|
});
|
||||||
return deferrer;
|
return deferrer;
|
||||||
}
|
}
|
||||||
|
@ -62,9 +62,8 @@ DisassemblyWidget::DisassemblyWidget(MainWindow *main, QAction *action)
|
|||||||
setupFonts();
|
setupFonts();
|
||||||
setupColors();
|
setupColors();
|
||||||
|
|
||||||
disasmRefresh = createReplacingRefreshDeferrer<RVA>([this](const RVA *offset) {
|
disasmRefresh = createReplacingRefreshDeferrer<RVA>(false, [this](const RVA *offset) {
|
||||||
printf("got refresh now!\n");
|
refreshDisasm(offset ? *offset : RVA_INVALID);
|
||||||
refreshDisasm(*offset);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
maxLines = 0;
|
maxLines = 0;
|
||||||
@ -199,11 +198,9 @@ QWidget *DisassemblyWidget::getTextWidget()
|
|||||||
|
|
||||||
void DisassemblyWidget::refreshDisasm(RVA offset)
|
void DisassemblyWidget::refreshDisasm(RVA offset)
|
||||||
{
|
{
|
||||||
if(!disasmRefresh->attemptRefresh(new RVA(offset))) {
|
if(!disasmRefresh->attemptRefresh(offset == RVA_INVALID ? nullptr : new RVA(offset))) {
|
||||||
printf("we tried to refresh, but shouldn't yet.\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("ok, actually refreshing now!\n");
|
|
||||||
|
|
||||||
if (offset != RVA_INVALID) {
|
if (offset != RVA_INVALID) {
|
||||||
topOffset = offset;
|
topOffset = offset;
|
||||||
|
Loading…
Reference in New Issue
Block a user