diff --git a/src/common/RefreshDeferrer.h b/src/common/RefreshDeferrer.h index 6932e022..1052116e 100644 --- a/src/common/RefreshDeferrer.h +++ b/src/common/RefreshDeferrer.h @@ -29,8 +29,12 @@ class ReplacingRefreshDeferrerAccumulator: public RefreshDeferrerAccumulator { private: T *value = nullptr; + bool replaceIfNull; public: + explicit ReplacingRefreshDeferrerAccumulator(bool replaceIfNull = true) + : replaceIfNull(replaceIfNull) {} + ~ReplacingRefreshDeferrerAccumulator() override { delete value; @@ -39,6 +43,9 @@ public: protected: void accumulate(RefreshDeferrerParams params) override { + if (!replaceIfNull && !params) { + return; + } delete value; value = static_cast(params); } diff --git a/src/widgets/CutterDockWidget.h b/src/widgets/CutterDockWidget.h index e643e6d4..8dd926ab 100644 --- a/src/widgets/CutterDockWidget.h +++ b/src/widgets/CutterDockWidget.h @@ -33,14 +33,13 @@ protected: void closeEvent(QCloseEvent *event) override; template - RefreshDeferrer *createReplacingRefreshDeferrer(Func refreshNowFunc) + RefreshDeferrer *createReplacingRefreshDeferrer(bool replaceIfNull, Func refreshNowFunc) { - auto *deferrer = new RefreshDeferrer(new ReplacingRefreshDeferrerAccumulator(), this); + auto *deferrer = new RefreshDeferrer(new ReplacingRefreshDeferrerAccumulator(replaceIfNull), this); deferrer->registerFor(this); connect(deferrer, &RefreshDeferrer::refreshNow, this, [refreshNowFunc](const RefreshDeferrerParamsResult paramsResult) { - printf("got refresh now!\n"); - auto *offset = static_cast(paramsResult); - refreshNowFunc(offset); + auto *result = static_cast(paramsResult); + refreshNowFunc(result); }); return deferrer; } diff --git a/src/widgets/DisassemblyWidget.cpp b/src/widgets/DisassemblyWidget.cpp index 84e2f3a8..6775dad0 100644 --- a/src/widgets/DisassemblyWidget.cpp +++ b/src/widgets/DisassemblyWidget.cpp @@ -62,9 +62,8 @@ DisassemblyWidget::DisassemblyWidget(MainWindow *main, QAction *action) setupFonts(); setupColors(); - disasmRefresh = createReplacingRefreshDeferrer([this](const RVA *offset) { - printf("got refresh now!\n"); - refreshDisasm(*offset); + disasmRefresh = createReplacingRefreshDeferrer(false, [this](const RVA *offset) { + refreshDisasm(offset ? *offset : RVA_INVALID); }); maxLines = 0; @@ -199,11 +198,9 @@ QWidget *DisassemblyWidget::getTextWidget() void DisassemblyWidget::refreshDisasm(RVA offset) { - if(!disasmRefresh->attemptRefresh(new RVA(offset))) { - printf("we tried to refresh, but shouldn't yet.\n"); + if(!disasmRefresh->attemptRefresh(offset == RVA_INVALID ? nullptr : new RVA(offset))) { return; } - printf("ok, actually refreshing now!\n"); if (offset != RVA_INVALID) { topOffset = offset;