Skip to content

Commit

Permalink
Merge branch 'hotfix-0.8.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
gaasedelen committed Oct 3, 2018
2 parents 8e09989 + 03cc67e commit fbbdd91
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 17 deletions.
2 changes: 1 addition & 1 deletion plugin/lighthouse/core.py
Expand Up @@ -20,7 +20,7 @@
# Plugin Metadata
#------------------------------------------------------------------------------

PLUGIN_VERSION = "0.8.0"
PLUGIN_VERSION = "0.8.1"
AUTHORS = "Markus Gaasedelen"
DATE = "2018"

Expand Down
15 changes: 11 additions & 4 deletions plugin/lighthouse/metadata.py
Expand Up @@ -127,18 +127,25 @@ def get_node(self, address):
#

index = bisect.bisect_right(self._node_addresses, address) - 1
node_metadata = self.nodes.get(self._node_addresses[index], None)

#
# if the given address does not fall within the selected node (or the
# node simply does not exist), then we have no match/metadata to return
#

if not (node_metadata and address in node_metadata):
return None

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

node_metadata = self.nodes.get(self._node_addresses[index], None)
if node_metadata and address in node_metadata:
self._last_node = node_metadata
self._last_node = node_metadata

# return the located node_metadata, or None
# return the located node_metadata
return node_metadata

def get_function(self, address):
Expand Down
8 changes: 7 additions & 1 deletion plugin/lighthouse/painting/ida_painter.py
Expand Up @@ -181,11 +181,17 @@ def _clear_nodes(self, nodes_metadata):
self.clear_nodes(nodes_metadata)
self._action_complete.set()

@disassembler.execute_ui
@execute_paint
def _refresh_ui(self):
"""
Note that this has been decorated with @execute_paint (vs @execute_ui)
to help avoid deadlocking on exit.
"""
idaapi.refresh_idaview_anyway()

def _cancel_action(self, job_id):
if idaapi.IDA_SDK_VERSION < 710:
return
idaapi.cancel_exec_request(job_id)

#------------------------------------------------------------------------------
Expand Down
13 changes: 11 additions & 2 deletions plugin/lighthouse/painting/painter.py
Expand Up @@ -128,8 +128,17 @@ def clear_paint(self):
"""
Clear all paint from the current database (based on metadata)
"""
if self.enabled:

#
# we should only disable the painter (as a result of clear_paint()) if
# the user has coverage open & in use. for example, there is no reason
# to *preemptively* disable painting if no other coverage is loaded.
#

if self.enabled and len(self._director.coverage_names):
self.set_enabled(False)

# trigger the database clear
self._msg_queue.put(self.MSG_CLEAR)

#--------------------------------------------------------------------------
Expand Down Expand Up @@ -381,7 +390,7 @@ def _async_database_painter(self):
# Asynchronous Database Painting Loop
#

while True:
while not self._end_threads:

# wait for the next command to come through
action = self._msg_queue.get()
Expand Down
11 changes: 10 additions & 1 deletion plugin/lighthouse/ui/coverage_overview.py
Expand Up @@ -51,6 +51,15 @@ def show(self):
super(CoverageOverview, self).show()
self._visible = True

#
# if no metadata had been collected prior to showing the coverage
# overview (eg, through loading coverage), we should do that now
# before the user can interact with the view...
#

if not self._core.director.metadata.cached:
self._table_controller.refresh_metadata()

def terminate(self):
"""
The CoverageOverview is being hidden / deleted.
Expand Down Expand Up @@ -188,7 +197,7 @@ def _ui_layout(self):

# layout the major elements of our widget
layout = QtWidgets.QGridLayout()
layout.setSpacing(get_dpi_scale())
layout.setSpacing(get_dpi_scale()*5.0)
layout.addWidget(self._table_view)
layout.addWidget(self._toolbar)

Expand Down
5 changes: 3 additions & 2 deletions plugin/lighthouse/ui/coverage_table.py
Expand Up @@ -179,12 +179,13 @@ def _ui_init_table(self):

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

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

def _ui_init_table_ctx_menu_actions(self):
Expand Down
17 changes: 12 additions & 5 deletions plugin/lighthouse/util/qt/util.py
@@ -1,3 +1,4 @@
import sys
import time
import Queue
import logging
Expand Down Expand Up @@ -69,8 +70,12 @@ def get_dpi_scale():
"""
Get a DPI-afflicted value useful for consistent UI scaling.
"""
font = QtGui.QFont("Times", 15)
return QtGui.QFontMetricsF(font).xHeight()
font = MonospaceFont()
font.setPointSize(normalize_to_dpi(120))
fm = QtGui.QFontMetricsF(font)

# xHeight is expected to be 40.0 at normal DPI
return fm.height() / 173.0

def move_mouse_event(mouse_event, position):
"""
Expand All @@ -89,7 +94,9 @@ def normalize_to_dpi(font_size):
"""
Normalize the given font size based on the system DPI.
"""
return (font_size*get_dpi_scale())/5.0
if sys.platform == "darwin": # macos is lame
return font_size + 3
return font_size

def prompt_string(label, title, default=""):
"""
Expand All @@ -105,8 +112,8 @@ def prompt_string(label, title, default=""):
dlg.setWindowTitle(title)
dlg.setTextValue(default)
dlg.resize(
dpi_scale*80,
dpi_scale*10
dpi_scale*400,
dpi_scale*50
)
ok = dlg.exec_()
text = str(dlg.textValue())
Expand Down
2 changes: 1 addition & 1 deletion plugin/lighthouse/util/qt/waitbox.py
Expand Up @@ -56,7 +56,7 @@ def _ui_init(self):
# configure the main widget / form
self.setSizeGripEnabled(False)
self.setModal(True)
self._dpi_scale = get_dpi_scale()
self._dpi_scale = get_dpi_scale()*5.0

# initialize abort button
self._abort_button = QtWidgets.QPushButton("Cancel")
Expand Down

0 comments on commit fbbdd91

Please sign in to comment.