Re: [PATCH 1/6] perf scripts python: exported-sql-viewer.py: Fix error when shrinking / enlarging font

Arnaldo Carvalho de Melo
2019-05-13T19:57:50Z

Em Fri, May 03, 2019 at 03:08:23PM +0300, Adrian Hunter escreveu:
> 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'

Humm, this is kinda frustrating, I tried it and expected it to either
enlarge/shrink or tell me that that is not possible, and why :-\

Anyway, if you think this is the best approach, applied.

- Arnaldo

> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
> tools/perf/scripts/python/exported-sql-viewer.py | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py
> index c586abfb2b46..289e8dbd1444 100755
> --- a/tools/perf/scripts/python/exported-sql-viewer.py
> +++ b/tools/perf/scripts/python/exported-sql-viewer.py
> @@ -2770,6 +2770,14 @@ class MainWindow(QMainWindow):
> 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:
> @@ -2787,12 +2795,10 @@ class MainWindow(QMainWindow):
> 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
> --
> 2.17.1

--

- Arnaldo