Skip to content

Commit fbbdd91

Browse files
committed
Merge branch 'hotfix-0.8.1'
2 parents 8e09989 + 03cc67e commit fbbdd91

File tree

8 files changed

+56
-17
lines changed

8 files changed

+56
-17
lines changed

plugin/lighthouse/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# Plugin Metadata
2121
#------------------------------------------------------------------------------
2222

23-
PLUGIN_VERSION = "0.8.0"
23+
PLUGIN_VERSION = "0.8.1"
2424
AUTHORS = "Markus Gaasedelen"
2525
DATE = "2018"
2626

plugin/lighthouse/metadata.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,25 @@ def get_node(self, address):
127127
#
128128

129129
index = bisect.bisect_right(self._node_addresses, address) - 1
130+
node_metadata = self.nodes.get(self._node_addresses[index], None)
131+
132+
#
133+
# if the given address does not fall within the selected node (or the
134+
# node simply does not exist), then we have no match/metadata to return
135+
#
136+
137+
if not (node_metadata and address in node_metadata):
138+
return None
130139

131140
#
132141
# if the selected node metadata contains the given target address, it
133142
# is a positive hit and we should cache this node (in last_node) for
134143
# faster consecutive lookups
135144
#
136145

137-
node_metadata = self.nodes.get(self._node_addresses[index], None)
138-
if node_metadata and address in node_metadata:
139-
self._last_node = node_metadata
146+
self._last_node = node_metadata
140147

141-
# return the located node_metadata, or None
148+
# return the located node_metadata
142149
return node_metadata
143150

144151
def get_function(self, address):

plugin/lighthouse/painting/ida_painter.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,17 @@ def _clear_nodes(self, nodes_metadata):
181181
self.clear_nodes(nodes_metadata)
182182
self._action_complete.set()
183183

184-
@disassembler.execute_ui
184+
@execute_paint
185185
def _refresh_ui(self):
186+
"""
187+
Note that this has been decorated with @execute_paint (vs @execute_ui)
188+
to help avoid deadlocking on exit.
189+
"""
186190
idaapi.refresh_idaview_anyway()
187191

188192
def _cancel_action(self, job_id):
193+
if idaapi.IDA_SDK_VERSION < 710:
194+
return
189195
idaapi.cancel_exec_request(job_id)
190196

191197
#------------------------------------------------------------------------------

plugin/lighthouse/painting/painter.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,17 @@ def clear_paint(self):
128128
"""
129129
Clear all paint from the current database (based on metadata)
130130
"""
131-
if self.enabled:
131+
132+
#
133+
# we should only disable the painter (as a result of clear_paint()) if
134+
# the user has coverage open & in use. for example, there is no reason
135+
# to *preemptively* disable painting if no other coverage is loaded.
136+
#
137+
138+
if self.enabled and len(self._director.coverage_names):
132139
self.set_enabled(False)
140+
141+
# trigger the database clear
133142
self._msg_queue.put(self.MSG_CLEAR)
134143

135144
#--------------------------------------------------------------------------
@@ -381,7 +390,7 @@ def _async_database_painter(self):
381390
# Asynchronous Database Painting Loop
382391
#
383392

384-
while True:
393+
while not self._end_threads:
385394

386395
# wait for the next command to come through
387396
action = self._msg_queue.get()

plugin/lighthouse/ui/coverage_overview.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ def show(self):
5151
super(CoverageOverview, self).show()
5252
self._visible = True
5353

54+
#
55+
# if no metadata had been collected prior to showing the coverage
56+
# overview (eg, through loading coverage), we should do that now
57+
# before the user can interact with the view...
58+
#
59+
60+
if not self._core.director.metadata.cached:
61+
self._table_controller.refresh_metadata()
62+
5463
def terminate(self):
5564
"""
5665
The CoverageOverview is being hidden / deleted.
@@ -188,7 +197,7 @@ def _ui_layout(self):
188197

189198
# layout the major elements of our widget
190199
layout = QtWidgets.QGridLayout()
191-
layout.setSpacing(get_dpi_scale())
200+
layout.setSpacing(get_dpi_scale()*5.0)
192201
layout.addWidget(self._table_view)
193202
layout.addWidget(self._toolbar)
194203

plugin/lighthouse/ui/coverage_table.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,13 @@ def _ui_init_table(self):
179179

180180
# specify the fixed pixel height for the table headers
181181
spacing = title_fm.height() - title_fm.xHeight()
182-
tweak = 24 - spacing
182+
tweak = 26*get_dpi_scale() - spacing
183183
hh.setFixedHeight(entry_fm.height()+tweak)
184184

185185
# specify the fixed pixel height for the table rows
186+
# NOTE: don't ask too many questions about this voodoo math :D
186187
spacing = entry_fm.height() - entry_fm.xHeight()
187-
tweak = 16 - spacing
188+
tweak = (17*get_dpi_scale() - spacing)/get_dpi_scale()
188189
vh.setDefaultSectionSize(entry_fm.height()+tweak)
189190

190191
def _ui_init_table_ctx_menu_actions(self):

plugin/lighthouse/util/qt/util.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
import time
23
import Queue
34
import logging
@@ -69,8 +70,12 @@ def get_dpi_scale():
6970
"""
7071
Get a DPI-afflicted value useful for consistent UI scaling.
7172
"""
72-
font = QtGui.QFont("Times", 15)
73-
return QtGui.QFontMetricsF(font).xHeight()
73+
font = MonospaceFont()
74+
font.setPointSize(normalize_to_dpi(120))
75+
fm = QtGui.QFontMetricsF(font)
76+
77+
# xHeight is expected to be 40.0 at normal DPI
78+
return fm.height() / 173.0
7479

7580
def move_mouse_event(mouse_event, position):
7681
"""
@@ -89,7 +94,9 @@ def normalize_to_dpi(font_size):
8994
"""
9095
Normalize the given font size based on the system DPI.
9196
"""
92-
return (font_size*get_dpi_scale())/5.0
97+
if sys.platform == "darwin": # macos is lame
98+
return font_size + 3
99+
return font_size
93100

94101
def prompt_string(label, title, default=""):
95102
"""
@@ -105,8 +112,8 @@ def prompt_string(label, title, default=""):
105112
dlg.setWindowTitle(title)
106113
dlg.setTextValue(default)
107114
dlg.resize(
108-
dpi_scale*80,
109-
dpi_scale*10
115+
dpi_scale*400,
116+
dpi_scale*50
110117
)
111118
ok = dlg.exec_()
112119
text = str(dlg.textValue())

plugin/lighthouse/util/qt/waitbox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _ui_init(self):
5656
# configure the main widget / form
5757
self.setSizeGripEnabled(False)
5858
self.setModal(True)
59-
self._dpi_scale = get_dpi_scale()
59+
self._dpi_scale = get_dpi_scale()*5.0
6060

6161
# initialize abort button
6262
self._abort_button = QtWidgets.QPushButton("Cancel")

0 commit comments

Comments
 (0)