GUI: Add error handling for object deletion

This commit is contained in:
Mykola Grymalyuk
2023-05-07 13:29:13 -06:00
parent aaf7519e94
commit bd70c4a24a
5 changed files with 19 additions and 22 deletions

View File

@@ -97,7 +97,6 @@ class BuildFrame(wx.Frame):
)
dialog.SetYesNoLabels("Install to disk", "View build log")
self.on_install() if dialog.ShowModal() == wx.ID_YES else self.install_button.Enable()

View File

@@ -7,9 +7,9 @@ from resources import constants
from resources.wx_gui import (
gui_main_menu,
gui_build,
gui_menubar,
gui_install_oc,
gui_sys_patch
gui_sys_patch,
gui_support
)
from resources.sys_patch import sys_patch_detect
@@ -53,7 +53,8 @@ class EntryPoint:
screen_location=None,
**({"patches": patches} if "--gui_patch" in sys.argv or "--gui_unpatch" in sys.argv else {})
)
self.frame.SetMenuBar(gui_menubar.GenerateMenubar().generate())
if self.frame:
self.frame.SetMenuBar(gui_support.GenerateMenubar().generate())
atexit.register(self.OnCloseFrame)
if "--gui_patch" in sys.argv:

View File

@@ -1,14 +0,0 @@
# Generates menubar for wxPython to use
import wx
class GenerateMenubar:
def __init__(self) -> None:
self.menubar: wx.MenuBar = None
def generate(self) -> wx.MenuBar:
self.menubar = wx.MenuBar()
return self.menubar

View File

@@ -10,6 +10,17 @@ from pathlib import Path
from resources import constants
class GenerateMenubar:
def __init__(self) -> None:
self.menubar: wx.MenuBar = None
def generate(self) -> wx.MenuBar:
self.menubar = wx.MenuBar()
return self.menubar
class PayloadMount:
def __init__(self, global_constants: constants.Constants, frame: wx.Frame) -> None:

View File

@@ -36,13 +36,12 @@ class SysPatchMenu(wx.Frame):
self.return_button: wx.Button = None
self.frame_modal = wx.Dialog(self, title=title, size=(360, 200))
self.SetPosition(screen_location) if screen_location else self.Centre()
if patches:
return
self._generate_elements_display_patches(self.frame_modal, patches)
self.SetPosition(screen_location) if screen_location else self.Centre()
self.frame_modal.ShowWindowModal()
@@ -260,8 +259,9 @@ class SysPatchMenu(wx.Frame):
else:
if patches["Validation: Patching Possible"] is False:
start_button.Disable()
if patches["Validation: Unpatching Possible"] is False:
revert_button.Disable()
if can_unpatch is False:
revert_button.Disable()
# Relaunch as root if not root
uid = os.geteuid()