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:
|
||||
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<T *>(params);
|
||||
}
|
||||
|
@ -33,14 +33,13 @@ protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
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);
|
||||
connect(deferrer, &RefreshDeferrer::refreshNow, this, [refreshNowFunc](const RefreshDeferrerParamsResult paramsResult) {
|
||||
printf("got refresh now!\n");
|
||||
auto *offset = static_cast<const ParamResult *>(paramsResult);
|
||||
refreshNowFunc(offset);
|
||||
auto *result = static_cast<const ParamResult *>(paramsResult);
|
||||
refreshNowFunc(result);
|
||||
});
|
||||
return deferrer;
|
||||
}
|
||||
|
@ -62,9 +62,8 @@ DisassemblyWidget::DisassemblyWidget(MainWindow *main, QAction *action)
|
||||
setupFonts();
|
||||
setupColors();
|
||||
|
||||
disasmRefresh = createReplacingRefreshDeferrer<RVA>([this](const RVA *offset) {
|
||||
printf("got refresh now!\n");
|
||||
refreshDisasm(*offset);
|
||||
disasmRefresh = createReplacingRefreshDeferrer<RVA>(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;
|
||||
|
Loading…
Reference in New Issue
Block a user