1
0
Fork 0

GUI: Undo last commit and fix the source problem (viewport->repaint())

This commit is contained in:
Nukem 2015-11-10 19:34:41 -05:00
parent 1515cb2d2d
commit 285e0c16c0
7 changed files with 67 additions and 50 deletions

View File

@ -1,4 +1,5 @@
#include "CPUDisassembly.h"
#include "CPUWidget.h"
#include <QMessageBox>
#include <QClipboard>
#include "Configuration.h"
@ -8,17 +9,20 @@
#include "HexEditDialog.h"
#include "YaraRuleSelectionDialog.h"
CPUDisassembly::CPUDisassembly(QWidget* parent) : Disassembly(parent)
CPUDisassembly::CPUDisassembly(CPUWidget* parent) : Disassembly(parent)
{
// Set specific widget handles
mGoto = nullptr;
mParentCPUWindow = parent;
// Create the action list for the right click context menu
setupRightClickContextMenu();
// Connect bridge<->disasm calls
connect(Bridge::getBridge(), SIGNAL(disassembleAt(dsint, dsint)), this, SLOT(disassembleAt(dsint, dsint)));
connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), this, SLOT(debugStateChangedSlot(DBGSTATE)));
connect(Bridge::getBridge(), SIGNAL(selectionDisasmGet(SELECTIONDATA*)), this, SLOT(selectionGet(SELECTIONDATA*)));
connect(Bridge::getBridge(), SIGNAL(selectionDisasmSet(const SELECTIONDATA*)), this, SLOT(selectionSet(const SELECTIONDATA*)));
mGoto = 0;
}
void CPUDisassembly::mousePressEvent(QMouseEvent* event)
@ -62,24 +66,22 @@ void CPUDisassembly::mouseDoubleClickEvent(QMouseEvent* event)
}
break;
case 1: //opcodes
{
toggleInt3BPAction(); //toggle INT3 breakpoint
}
break;
// (Opcodes) Set INT3 breakpoint
case 1:
toggleInt3BPAction();
break;
case 2: //disassembly
{
// (Disassembly) Assemble dialog
case 2:
assembleAt();
}
break;
break;
case 3: //comments
{
// (Comments) Set comment dialog
case 3:
setComment();
}
break;
break;
// Undefined area
default:
Disassembly::mouseDoubleClickEvent(event);
break;
@ -1420,3 +1422,16 @@ void CPUDisassembly::decompileFunction()
emit decompileAt(start, end);
}
}
void CPUDisassembly::paintEvent(QPaintEvent* event)
{
// Hook/hack to update the sidebar at the same time as this widget.
// Ensures the two widgets are synced and prevents "draw lag"
auto sidebar = mParentCPUWindow->getSidebarWidget();
if (sidebar)
sidebar->repaint();
// Signal to render the original content
Disassembly::paintEvent(event);
}

View File

@ -5,11 +5,15 @@
#include "GotoDialog.h"
#include "SourceViewerManager.h"
// Needed forward declaration for parent container class
class CPUWidget;
class CPUDisassembly : public Disassembly
{
Q_OBJECT
public:
explicit CPUDisassembly(QWidget* parent = 0);
explicit CPUDisassembly(CPUWidget* parent);
// Mouse Management
void contextMenuEvent(QContextMenuEvent* event);
@ -80,6 +84,9 @@ public slots:
void decompileSelection();
void decompileFunction();
protected:
void paintEvent(QPaintEvent* event);
private:
// Menus
QMenu* mBinaryMenu;
@ -91,7 +98,9 @@ private:
QMenu* mSearchMenu;
QMenu* mCopyMenu;
QMenu* mPluginMenu;
QMenu* mDecompileMenu;
// Actions
QAction* mBinaryEditAction;
QAction* mBinaryFillAction;
QAction* mBinaryFillNopsAction;
@ -134,12 +143,14 @@ private:
QAction* mCopyRva;
QAction* mCopyDisassembly;
QAction* mOpenSource;
QMenu* mDecompileMenu;
QAction* mDecompileSelection;
QAction* mDecompileFunction;
// Goto dialog specific
GotoDialog* mGoto;
// Parent CPU window
CPUWidget *mParentCPUWindow;
};
#endif // CPUDISASSEMBLY_H

View File

@ -40,7 +40,7 @@ void CPUSideBar::debugStateChangedSlot(DBGSTATE state)
void CPUSideBar::repaint()
{
fontHeight = CodePtr->getRowHeight();
viewport()->repaint();
viewport()->update();
}
void CPUSideBar::changeTopmostAddress(dsint i)
@ -433,4 +433,3 @@ void CPUSideBar::operator delete(void* p)
{
_aligned_free(p);
}

View File

@ -6,11 +6,10 @@ CPUWidget::CPUWidget(QWidget* parent) : QWidget(parent), ui(new Ui::CPUWidget)
ui->setupUi(this);
setDefaultDisposition();
mDisas = new CPUDisassembly(0);
mDisas = new CPUDisassembly(this);
mSideBar = new CPUSideBar(mDisas);
connect(mDisas, SIGNAL(tableOffsetChanged(dsint)), mSideBar, SLOT(changeTopmostAddress(dsint)));
connect(mDisas, SIGNAL(viewableRows(int)), mSideBar, SLOT(setViewableRows(int)));
connect(mDisas, SIGNAL(repainted()), mSideBar, SLOT(repaint()));
connect(mDisas, SIGNAL(selectionChanged(dsint)), mSideBar, SLOT(setSelection(dsint)));
connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), mSideBar, SLOT(debugStateChangedSlot(DBGSTATE)));
connect(Bridge::getBridge(), SIGNAL(updateSideBar()), mSideBar, SLOT(repaint()));
@ -54,7 +53,6 @@ CPUWidget::CPUWidget(QWidget* parent) : QWidget(parent), ui(new Ui::CPUWidget)
connect(button_changeview, SIGNAL(clicked()), mGeneralRegs, SLOT(onChangeFPUViewAction()));
ui->mTopRightFrameLayout->addWidget(button_changeview);
ui->mTopRightFrameLayout->addWidget(scrollArea);
mDump = new CPUDump(mDisas, 0); //dump widget
@ -99,31 +97,32 @@ void CPUWidget::setDefaultDisposition(void)
ui->mBotHSplitter->setSizes(sizesList);
}
QVBoxLayout* CPUWidget::getTopLeftUpperWidget(void)
QVBoxLayout* CPUWidget::getTopLeftUpperWidget()
{
return ui->mTopLeftUpperFrameLayout;
}
QVBoxLayout* CPUWidget::getTopLeftLowerWidget(void)
QVBoxLayout* CPUWidget::getTopLeftLowerWidget()
{
return ui->mTopLeftLowerFrameLayout;
}
QVBoxLayout* CPUWidget::getTopRightWidget(void)
QVBoxLayout* CPUWidget::getTopRightWidget()
{
return ui->mTopRightFrameLayout;
}
QVBoxLayout* CPUWidget::getBotLeftWidget(void)
QVBoxLayout* CPUWidget::getBotLeftWidget()
{
return ui->mBotLeftFrameLayout;
}
QVBoxLayout* CPUWidget::getBotRightWidget(void)
QVBoxLayout* CPUWidget::getBotRightWidget()
{
return ui->mBotRightFrameLayout;
}
CPUSideBar* CPUWidget::getSidebarWidget()
{
return mSideBar;
}

View File

@ -23,11 +23,16 @@ public:
explicit CPUWidget(QWidget* parent = 0);
~CPUWidget();
void setDefaultDisposition(void);
QVBoxLayout* getTopLeftUpperWidget(void);
QVBoxLayout* getTopLeftLowerWidget(void);
QVBoxLayout* getTopRightWidget(void);
QVBoxLayout* getBotLeftWidget(void);
QVBoxLayout* getBotRightWidget(void);
// Layout getters
QVBoxLayout* getTopLeftUpperWidget();
QVBoxLayout* getTopLeftLowerWidget();
QVBoxLayout* getTopRightWidget();
QVBoxLayout* getBotLeftWidget();
QVBoxLayout* getBotRightWidget();
// Widget getters
CPUSideBar* getSidebarWidget();
public:
CPUSideBar* mSideBar;

View File

@ -144,16 +144,6 @@ void MHTabWidget::setCurrentIndex(int index)
}
}
void MHTabWidget::paintEvent(QPaintEvent *event)
{
QTabWidget::paintEvent(event);
// Force the tab bar to draw AFTER the main elements
// do. This prevents the bar from being hidden
// when using custom CSS.
tabBar()->update();
}
QTabBar* MHTabWidget::tabBar() const
{
return m_tabBar;

View File

@ -40,8 +40,6 @@ public Q_SLOTS:
protected:
QTabBar* tabBar() const;
void paintEvent(QPaintEvent *event);
private:
MHTabBar* m_tabBar;