Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.

Commit

Permalink
Fixed main window detection (closes #34)
Browse files Browse the repository at this point in the history
  • Loading branch information
NeatMonster committed Aug 23, 2018
1 parent c84caa8 commit acdd910
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
4 changes: 3 additions & 1 deletion idarling/interface/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _find_main_window():

def __init__(self, plugin):
super(Interface, self).__init__(plugin)
self._window = self._find_main_window()
self._window = None

self._openAction = OpenAction(plugin)
self._saveAction = SaveAction(plugin)
Expand Down Expand Up @@ -82,6 +82,8 @@ def _install(self):
self._install_our_icon()
self._painter.install()

if self._window is None:
self._window = self._find_main_window()
self._window.statusBar().addPermanentWidget(self._statusWidget)
logger.debug("Installed widgets in status bar")
return True
Expand Down
20 changes: 5 additions & 15 deletions idarling/interface/painter.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def __init__(self):

self._nbytes = 0

self.ida_nav_colorizer = None

def install(self):
"""
Install the painter into the IDA UI.
Expand All @@ -85,20 +87,8 @@ class UIHooks(ida_kernwin.UI_Hooks):
def __init__(self, painter):
ida_kernwin.UI_Hooks.__init__(self)
self._painter = painter
self._initialized = False

def database_inited(self, is_new_database, idc_script):
self._install_nvar_colorizer()
self._initialized = True
return 0

def ready_to_run(self, *_):
if not self._initialized:
self._install_nvar_colorizer()
self._initialized = False
return 0

def _install_nvar_colorizer(self):
"""
We must get the original ida colorizer only one time to avoid
segfault.
Expand All @@ -107,12 +97,12 @@ def _install_nvar_colorizer(self):
#
# get default background and original navbar colorizer
#

self._painter.bg_color = get_ida_bg_color()
colorizer = self._painter.custom_nav_colorizer
ida_nav_colorizer = ida_kernwin.set_nav_colorizer(colorizer)
self._painter.ida_nav_colorizer = ida_nav_colorizer
self._uiHooks.unhook()

def ready_to_run(self, *_):
self._painter.bg_color = get_ida_bg_color()

self._uiHooks = UIHooks(self)
result = self._uiHooks.hook()
Expand Down

0 comments on commit acdd910

Please sign in to comment.