From ba0e6b0e32b23d1a7c1298b5ac5b92234d6f493e Mon Sep 17 00:00:00 2001 From: Kazuya O'moto Date: Wed, 6 Nov 2024 02:48:19 +0900 Subject: [PATCH] Fix InspectionTool crashes due to bad perspective string errros To ensure backward compatibility from version 4.2.3* to 4.2.2, use the config key 'perspective1' for version 4.2.3 and later. LoadPerspective => LoadPaneInfo raises an Exception, not a wx.PyAssertionError. Therefore, change it to catch only Exception. --- wx/lib/agw/aui/framemanager.py | 2 +- wx/lib/inspection.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wx/lib/agw/aui/framemanager.py b/wx/lib/agw/aui/framemanager.py index 6d2e17c9..c01bf9d1 100644 --- a/wx/lib/agw/aui/framemanager.py +++ b/wx/lib/agw/aui/framemanager.py @@ -5178,7 +5178,7 @@ class AuiManager(wx.EvtHandler): elif val_name == "transparent": pane.transparent = int(value) else: - raise Exception("Bad perspective string") + raise Exception("Bad perspective string", val_name) # replace escaped characters so we can # split up the string easily diff --git a/wx/lib/inspection.py b/wx/lib/inspection.py index eddf576c..4d2d1c7d 100644 --- a/wx/lib/inspection.py +++ b/wx/lib/inspection.py @@ -405,11 +405,11 @@ class InspectionFrame(wx.Frame): rect = utils.AdjustRectToScreen(self.GetRect()) self.SetRect(rect) - perspective = config.Read('perspective', '') + perspective = config.Read('perspective1', '') if perspective: try: self.mgr.LoadPerspective(perspective) - except wx.PyAssertionError: + except Exception: # ignore bad perspective string errors pass self.includeSizers = config.ReadBool('includeSizers', False) @@ -430,7 +430,7 @@ class InspectionFrame(wx.Frame): if hasattr(self, "mgr"): perspective = self.mgr.SavePerspective() - config.Write('perspective', perspective) + config.Write('perspective1', perspective) config.WriteBool('includeSizers', self.includeSizers) #---------------------------------------------------------------------------