Fix some minor issues and leaks

This commit is contained in:
Florian Märkl 2019-01-13 16:00:07 +01:00 committed by xarkes
parent bbd5ad6b38
commit 0ebe1cf728
7 changed files with 21 additions and 17 deletions

View File

@ -15,6 +15,9 @@ RefreshDeferrer::~RefreshDeferrer()
bool RefreshDeferrer::attemptRefresh(RefreshDeferrerParams params) bool RefreshDeferrer::attemptRefresh(RefreshDeferrerParams params)
{ {
if (dockWidget->isVisibleToUser()) { if (dockWidget->isVisibleToUser()) {
if (acc) {
acc->ignoreParams(params);
}
return true; return true;
} else { } else {
dirty = true; dirty = true;

View File

@ -50,7 +50,6 @@ void CutterDockWidget::updateIsVisibleToUser()
return; return;
} }
isVisibleToUserCurrent = visibleToUser; isVisibleToUserCurrent = visibleToUser;
qDebug() << this << "isVisibleToUser changed to" << isVisibleToUserCurrent;
if (isVisibleToUserCurrent) { if (isVisibleToUserCurrent) {
emit becameVisibleToUser(); emit becameVisibleToUser();
} }

View File

@ -26,7 +26,7 @@ signals:
private: private:
QAction *action; QAction *action;
bool isVisibleToUserCurrent; bool isVisibleToUserCurrent = false;
void updateIsVisibleToUser(); void updateIsVisibleToUser();
protected: protected:

View File

@ -740,18 +740,19 @@ void GraphView::showBlock(GraphBlock *block, bool animated)
target_x = std::min(horizontalScrollBar()->maximum(), target_x); target_x = std::min(horizontalScrollBar()->maximum(), target_x);
target_y = std::min(verticalScrollBar()->maximum(), target_y); target_y = std::min(verticalScrollBar()->maximum(), target_y);
if (animated) { if (animated) {
QPropertyAnimation *animation_x = new QPropertyAnimation(horizontalScrollBar(), "value"); QPropertyAnimation *animation_x = new QPropertyAnimation(horizontalScrollBar(), "value", this);
animation_x->deleteLater();
animation_x->setDuration(500); animation_x->setDuration(500);
animation_x->setStartValue(horizontalScrollBar()->value()); animation_x->setStartValue(horizontalScrollBar()->value());
animation_x->setEndValue(target_x); animation_x->setEndValue(target_x);
animation_x->setEasingCurve(QEasingCurve::InOutQuad); animation_x->setEasingCurve(QEasingCurve::InOutQuad);
animation_x->start(); animation_x->start(QAbstractAnimation::DeleteWhenStopped);
QPropertyAnimation *animation_y = new QPropertyAnimation(verticalScrollBar(), "value"); QPropertyAnimation *animation_y = new QPropertyAnimation(verticalScrollBar(), "value", this);
animation_y->setDuration(500); animation_y->setDuration(500);
animation_y->setStartValue(verticalScrollBar()->value()); animation_y->setStartValue(verticalScrollBar()->value());
animation_y->setEndValue(target_y); animation_y->setEndValue(target_y);
animation_y->setEasingCurve(QEasingCurve::InOutQuad); animation_y->setEasingCurve(QEasingCurve::InOutQuad);
animation_y->start(); animation_y->start(QAbstractAnimation::DeleteWhenStopped);
} else { } else {
horizontalScrollBar()->setValue(target_x); horizontalScrollBar()->setValue(target_x);
verticalScrollBar()->setValue(target_y); verticalScrollBar()->setValue(target_y);

View File

@ -80,6 +80,11 @@ HexdumpWidget::HexdumpWidget(MainWindow *main, QAction *action) :
updateHeaders(); updateHeaders();
this->setWindowTitle(tr("Hexdump")); this->setWindowTitle(tr("Hexdump"));
refreshDeferrer = createReplacingRefreshDeferrer<RVA>(false, [this](const RVA *offset) {
refresh(offset ? *offset : RVA_INVALID);
});
connect(&syncAction, SIGNAL(triggered(bool)), this, SLOT(toggleSync())); connect(&syncAction, SIGNAL(triggered(bool)), this, SLOT(toggleSync()));
// Set hexdump context menu // Set hexdump context menu
@ -119,12 +124,6 @@ HexdumpWidget::HexdumpWidget(MainWindow *main, QAction *action) :
connect(seekable, &CutterSeekable::seekableSeekChanged, this, &HexdumpWidget::onSeekChanged); connect(seekable, &CutterSeekable::seekableSeekChanged, this, &HexdumpWidget::onSeekChanged);
connect(&rangeDialog, &QDialog::accepted, this, &HexdumpWidget::on_rangeDialogAccepted); connect(&rangeDialog, &QDialog::accepted, this, &HexdumpWidget::on_rangeDialogAccepted);
connect(this, &CutterDockWidget::becameVisibleToUser, this, [this]() {
if (hexdumpDirty) {
refresh();
}
});
format = Format::Hex; format = Format::Hex;
initParsing(); initParsing();
selectHexPreview(); selectHexPreview();
@ -320,11 +319,8 @@ void HexdumpWidget::highlightHexWords(const QString &str)
void HexdumpWidget::refresh(RVA addr) void HexdumpWidget::refresh(RVA addr)
{ {
if (!isVisibleToUser()) { if (!refreshDeferrer->attemptRefresh(addr == RVA_INVALID ? nullptr : new RVA(addr))) {
hexdumpDirty = true;
return; return;
} else {
hexdumpDirty = false;
} }
ut64 loadLines = 0; ut64 loadLines = 0;

View File

@ -21,6 +21,8 @@
#include "ui_HexdumpWidget.h" #include "ui_HexdumpWidget.h"
class RefreshDeferrer;
class HexdumpWidget : public CutterDockWidget class HexdumpWidget : public CutterDockWidget
{ {
Q_OBJECT Q_OBJECT
@ -71,7 +73,7 @@ private:
RVA first_loaded_address = RVA_INVALID; RVA first_loaded_address = RVA_INVALID;
RVA last_loaded_address = RVA_INVALID; RVA last_loaded_address = RVA_INVALID;
bool hexdumpDirty = false; RefreshDeferrer *refreshDeferrer;
void refresh(RVA addr = RVA_INVALID); void refresh(RVA addr = RVA_INVALID);
void selectHexPreview(); void selectHexPreview();

View File

@ -50,6 +50,9 @@ void Omnibar::refresh(const QStringList &flagList)
void Omnibar::restoreCompleter() void Omnibar::restoreCompleter()
{ {
QCompleter *completer = this->completer(); QCompleter *completer = this->completer();
if (!completer) {
return;
}
completer->setFilterMode(Qt::MatchContains); completer->setFilterMode(Qt::MatchContains);
} }