Skip to content

Commit

Permalink
perf scripts python: exported-sql-viewer.py: Fix error when shrinking…
Browse files Browse the repository at this point in the history
… / enlarging font

Fix the following error if shrink / enlarge font is used with the help
window.

  Traceback (most recent call last):
    File "tools/perf/scripts/python/exported-sql-viewer.py", line 2791, in ShrinkFont
      ShrinkFont(win.view)
  AttributeError: 'HelpWindow' object has no attribute 'view'

Committer testing:

Before, matches above output:

  $ python ~acme/libexec/perf-core/scripts/python/exported-sql-viewer.py ~/c/adrian.hunter/simple-retpoline.db
  Traceback (most recent call last):
    File "/home/acme/libexec/perf-core/scripts/python/exported-sql-viewer.py", line 2780, in EnlargeFont
      EnlargeFont(win.view)
  AttributeError: 'HelpWindow' object has no attribute 'view'
  $

After:

No more tracebacks, but the fonts don't get enlarged, which is kinda
frustrating...

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190503120828.25326-2-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Adrian Hunter authored and Arnaldo Carvalho de Melo committed May 15, 2019
1 parent be6e747 commit 4b20845
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tools/perf/scripts/python/exported-sql-viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2755,6 +2755,14 @@ def __init__(self, glb, parent=None):
help_menu = menu.addMenu("&Help")
help_menu.addAction(CreateAction("&Exported SQL Viewer Help", "Helpful information", self.Help, self, QKeySequence.HelpContents))

def Try(self, fn):
win = self.mdi_area.activeSubWindow()
if win:
try:
fn(win.view)
except:
pass

def Find(self):
win = self.mdi_area.activeSubWindow()
if win:
Expand All @@ -2772,12 +2780,10 @@ def FetchMoreRecords(self):
pass

def ShrinkFont(self):
win = self.mdi_area.activeSubWindow()
ShrinkFont(win.view)
self.Try(ShrinkFont)

def EnlargeFont(self):
win = self.mdi_area.activeSubWindow()
EnlargeFont(win.view)
self.Try(EnlargeFont)

def EventMenu(self, events, reports_menu):
branches_events = 0
Expand Down

0 comments on commit 4b20845

Please sign in to comment.