mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-20 20:06:12 +00:00
Add createReplacingRefreshDeferrer for convenience
This commit is contained in:
parent
b8c92a460d
commit
d651a0d8be
@ -77,7 +77,7 @@ public:
|
||||
void registerFor(CutterDockWidget *dockWidget);
|
||||
|
||||
signals:
|
||||
void refreshNow(RefreshDeferrerParamsResult paramsResult);
|
||||
void refreshNow(const RefreshDeferrerParamsResult paramsResult);
|
||||
};
|
||||
|
||||
#endif //REFRESHDEFERRER_H
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include <QDockWidget>
|
||||
|
||||
#include "common/RefreshDeferrer.h"
|
||||
|
||||
class MainWindow;
|
||||
|
||||
class CutterDockWidget : public QDockWidget
|
||||
@ -29,6 +31,19 @@ private:
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
template<class ParamResult, typename Func>
|
||||
RefreshDeferrer *createReplacingRefreshDeferrer(Func refreshNowFunc)
|
||||
{
|
||||
auto *deferrer = new RefreshDeferrer(new ReplacingRefreshDeferrerAccumulator<ParamResult>(), 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);
|
||||
});
|
||||
return deferrer;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CUTTERWIDGET_H
|
||||
|
@ -35,14 +35,12 @@ static DisassemblyTextBlockUserData *getUserData(const QTextBlock &block)
|
||||
return static_cast<DisassemblyTextBlockUserData *>(userData);
|
||||
}
|
||||
|
||||
|
||||
DisassemblyWidget::DisassemblyWidget(MainWindow *main, QAction *action)
|
||||
: CutterDockWidget(main, action)
|
||||
, mCtxMenu(new DisassemblyContextMenu(this))
|
||||
, mDisasScrollArea(new DisassemblyScrollArea(this))
|
||||
, mDisasTextEdit(new DisassemblyTextEdit(this))
|
||||
, seekable(new CutterSeekable(this))
|
||||
, disasmRefresh(new ReplacingRefreshDeferrerAccumulator<RVA>)
|
||||
{
|
||||
topOffset = bottomOffset = RVA_INVALID;
|
||||
cursorLineOffset = 0;
|
||||
@ -64,10 +62,8 @@ DisassemblyWidget::DisassemblyWidget(MainWindow *main, QAction *action)
|
||||
setupFonts();
|
||||
setupColors();
|
||||
|
||||
disasmRefresh.registerFor(this);
|
||||
connect(&disasmRefresh, &RefreshDeferrer::refreshNow, this, [this](RefreshDeferrerParamsResult paramsResult) {
|
||||
disasmRefresh = createReplacingRefreshDeferrer<RVA>([this](const RVA *offset) {
|
||||
printf("got refresh now!\n");
|
||||
RVA *offset = static_cast<RVA *>(paramsResult);
|
||||
refreshDisasm(*offset);
|
||||
});
|
||||
|
||||
@ -203,7 +199,7 @@ QWidget *DisassemblyWidget::getTextWidget()
|
||||
|
||||
void DisassemblyWidget::refreshDisasm(RVA offset)
|
||||
{
|
||||
if(!disasmRefresh.attemptRefresh(new RVA(offset))) {
|
||||
if(!disasmRefresh->attemptRefresh(new RVA(offset))) {
|
||||
printf("we tried to refresh, but shouldn't yet.\n");
|
||||
return;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ private:
|
||||
int cursorLineOffset;
|
||||
bool seekFromCursor;
|
||||
|
||||
RefreshDeferrer disasmRefresh;
|
||||
RefreshDeferrer *disasmRefresh;
|
||||
|
||||
RVA readCurrentDisassemblyOffset();
|
||||
RVA readDisassemblyOffset(QTextCursor tc);
|
||||
|
Loading…
Reference in New Issue
Block a user