From 6c3d1d25829e7dd6d9c95a6abd02865e04935942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Thu, 30 Nov 2017 15:00:22 +0100 Subject: [PATCH] Fix a bug that caused startup to hang --- src/widgets/DisassemblyWidget.cpp | 29 +++++++++++++++++++++-------- src/widgets/DisassemblyWidget.h | 3 +++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/widgets/DisassemblyWidget.cpp b/src/widgets/DisassemblyWidget.cpp index 57c262be..7fe1ffd7 100644 --- a/src/widgets/DisassemblyWidget.cpp +++ b/src/widgets/DisassemblyWidget.cpp @@ -31,7 +31,12 @@ DisassemblyWidget::DisassemblyWidget(QWidget *parent) setAllowedAreas(Qt::AllDockWidgetAreas); setObjectName("DisassemblyWidget"); - colorsUpdatedSlot(); + + setupFonts(); + setupColors(); + + maxLines = 0; + updateMaxLines(); mDisasTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); mDisasTextEdit->setFont(Config()->getFont()); @@ -52,9 +57,6 @@ DisassemblyWidget::DisassemblyWidget(QWidget *parent) connect(mDisasTextEdit, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showDisasContextMenu(const QPoint &))); - maxLines = 0; - updateMaxLines(); - // Space to switch to graph QShortcut *graphShortcut = new QShortcut(QKeySequence(Qt::Key_Space), this); @@ -453,7 +455,7 @@ void DisassemblyWidget::raisePrioritizedMemoryWidget(CutterCore::MemoryWidgetTyp void DisassemblyWidget::fontsUpdatedSlot() { - mDisasTextEdit->setFont(Config()->getFont()); + setupFonts(); if (!updateMaxLines()) // updateMaxLines() returns true if it already refreshed. { @@ -463,12 +465,23 @@ void DisassemblyWidget::fontsUpdatedSlot() void DisassemblyWidget::colorsUpdatedSlot() { - mDisasTextEdit->setStyleSheet(QString("QPlainTextEdit { background-color: %1; color: %2; }") - .arg(ConfigColor("gui.background").name()) - .arg(ConfigColor("btext").name())); + setupColors(); refreshDisasm(); } +void DisassemblyWidget::setupFonts() +{ + mDisasTextEdit->setFont(Config()->getFont()); +} + +void DisassemblyWidget::setupColors() +{ + mDisasTextEdit->setStyleSheet(QString("QPlainTextEdit { background-color: %1; color: %2; }") + .arg(ConfigColor("gui.background").name()) + .arg(ConfigColor("btext").name())); +} + + DisassemblyScrollArea::DisassemblyScrollArea(QWidget *parent) : QAbstractScrollArea(parent) { } diff --git a/src/widgets/DisassemblyWidget.h b/src/widgets/DisassemblyWidget.h index 5192c571..2113ee6d 100644 --- a/src/widgets/DisassemblyWidget.h +++ b/src/widgets/DisassemblyWidget.h @@ -51,6 +51,9 @@ private: RVA readDisassemblyOffset(QTextCursor tc); bool eventFilter(QObject *obj, QEvent *event); + void setupFonts(); + void setupColors(); + void updateCursorPosition(); void connectCursorPositionChanged(bool disconnect);