From ff5e4b0cf3a9e7b884d9b68a405862dd6de73d4e Mon Sep 17 00:00:00 2001 From: Kingcom Date: Wed, 16 Oct 2013 15:15:00 +0200 Subject: [PATCH 1/3] Highlight branch arrows in a different color if they start/end at the current opcode --- Windows/Debugger/CtrlDisAsmView.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index 36036360ba..aff7157337 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -484,7 +484,18 @@ void CtrlDisAsmView::assembleOpcode(u32 address, std::string defaultText) void CtrlDisAsmView::drawBranchLine(HDC hdc, BranchLine& line) { + HPEN pen; u32 windowEnd = windowStart+(visibleRows+2)*instructionSize; + + // highlight line in a different color if it affects the currently selected opcode + if (line.first == curAddress || line.second == curAddress) + { + pen = CreatePen(0,0,0x257AFA); + } else { + pen = CreatePen(0,0,0xFF3020); + } + + HPEN oldPen = (HPEN) SelectObject(hdc,pen); int topY; int bottomY; @@ -562,6 +573,8 @@ void CtrlDisAsmView::drawBranchLine(HDC hdc, BranchLine& line) LineTo(hdc,x+1,bottomY+5); } } + + SelectObject(hdc,oldPen); } void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam) @@ -577,7 +590,6 @@ void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam) SetBkMode(hdc, TRANSPARENT); HPEN nullPen=CreatePen(0,0,0xffffff); - HPEN condPen=CreatePen(0,0,0xFF3020); HBRUSH nullBrush=CreateSolidBrush(0xffffff); HBRUSH currentBrush=CreateSolidBrush(0xFFEfE8); @@ -665,7 +677,6 @@ void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam) SelectObject(hdc,font); } - SelectObject(hdc,condPen); for (size_t i = 0; i < visibleFunctionAddresses.size(); i++) { auto it = functions.find(visibleFunctionAddresses[i]); @@ -693,7 +704,6 @@ void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam) DeleteDC(hdc); DeleteObject(nullPen); - DeleteObject(condPen); DeleteObject(nullBrush); DeleteObject(currentBrush); From 4483b5cff0f6e0dcc61076725b8d9c628587058f Mon Sep 17 00:00:00 2001 From: Kingcom Date: Wed, 16 Oct 2013 15:19:32 +0200 Subject: [PATCH 2/3] Delete pen --- Windows/Debugger/CtrlDisAsmView.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index aff7157337..a0eff75980 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -575,6 +575,7 @@ void CtrlDisAsmView::drawBranchLine(HDC hdc, BranchLine& line) } SelectObject(hdc,oldPen); + DeleteObject(pen); } void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam) From 35a7cb437b92b5172d74109ff11b6ba0815dbfa4 Mon Sep 17 00:00:00 2001 From: Kingcom Date: Wed, 16 Oct 2013 15:23:12 +0200 Subject: [PATCH 3/3] Don't create the pen before the function is sure to run until the end --- Windows/Debugger/CtrlDisAsmView.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index a0eff75980..86f31f1167 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -487,16 +487,6 @@ void CtrlDisAsmView::drawBranchLine(HDC hdc, BranchLine& line) HPEN pen; u32 windowEnd = windowStart+(visibleRows+2)*instructionSize; - // highlight line in a different color if it affects the currently selected opcode - if (line.first == curAddress || line.second == curAddress) - { - pen = CreatePen(0,0,0x257AFA); - } else { - pen = CreatePen(0,0,0xFF3020); - } - - HPEN oldPen = (HPEN) SelectObject(hdc,pen); - int topY; int bottomY; if (line.first < windowStart) @@ -525,8 +515,18 @@ void CtrlDisAsmView::drawBranchLine(HDC hdc, BranchLine& line) { return; } - + + // highlight line in a different color if it affects the currently selected opcode + if (line.first == curAddress || line.second == curAddress) + { + pen = CreatePen(0,0,0x257AFA); + } else { + pen = CreatePen(0,0,0xFF3020); + } + + HPEN oldPen = (HPEN) SelectObject(hdc,pen); int x = pixelPositions.arrowsStart+line.laneIndex*8; + if (topY < 0) // first is not visible, but second is { MoveToEx(hdc,x-2,bottomY,0);