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)
{
if (dockWidget->isVisibleToUser()) {
if (acc) {
acc->ignoreParams(params);
}
return true;
} else {
dirty = true;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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