mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-21 06:30:52 +10:00
Fix main thread crash from wx invocation in thread
This commit is contained in:
@@ -76,9 +76,11 @@ class InstallOCFrame(wx.Frame):
|
|||||||
|
|
||||||
# Need to clean up output on pre-Sierra
|
# Need to clean up output on pre-Sierra
|
||||||
# Disk images are mixed in with regular disks (ex. payloads.dmg)
|
# Disk images are mixed in with regular disks (ex. payloads.dmg)
|
||||||
|
ignore = ["disk image", "read-only", "virtual"]
|
||||||
for disk in self.available_disks.copy():
|
for disk in self.available_disks.copy():
|
||||||
if "read-only" in self.available_disks[disk]['name']:
|
for string in ignore:
|
||||||
del self.available_disks[disk]
|
if string in self.available_disks[disk]['name'].lower():
|
||||||
|
del self.available_disks[disk]
|
||||||
|
|
||||||
|
|
||||||
def _display_disks(self) -> None:
|
def _display_disks(self) -> None:
|
||||||
|
|||||||
@@ -98,12 +98,12 @@ class macOSInstallerDownloadFrame(wx.Frame):
|
|||||||
self.Show()
|
self.Show()
|
||||||
|
|
||||||
# Grab installer catalog
|
# Grab installer catalog
|
||||||
def fetch_installers():
|
def _fetch_installers():
|
||||||
remote_obj = macos_installer_handler.RemoteInstallerCatalog(seed_override=macos_installer_handler.SeedType.DeveloperSeed)
|
remote_obj = macos_installer_handler.RemoteInstallerCatalog(seed_override=macos_installer_handler.SeedType.DeveloperSeed)
|
||||||
self.available_installers = remote_obj.available_apps
|
self.available_installers = remote_obj.available_apps
|
||||||
self.available_installers_latest = remote_obj.available_apps_latest
|
self.available_installers_latest = remote_obj.available_apps_latest
|
||||||
|
|
||||||
thread = threading.Thread(target=fetch_installers)
|
thread = threading.Thread(target=_fetch_installers)
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
while thread.is_alive():
|
while thread.is_alive():
|
||||||
|
|||||||
@@ -151,17 +151,19 @@ class macOSInstallerFlashFrame(wx.Frame):
|
|||||||
self.SetSize((-1, progress_bar.GetPosition()[1] + progress_bar.GetSize()[1] + 40))
|
self.SetSize((-1, progress_bar.GetPosition()[1] + progress_bar.GetSize()[1] + 40))
|
||||||
|
|
||||||
# Fetch local disks
|
# Fetch local disks
|
||||||
def fetch_disks():
|
def _fetch_disks():
|
||||||
self.available_disks = macos_installer_handler.InstallerCreation().list_disk_to_format()
|
self.available_disks = macos_installer_handler.InstallerCreation().list_disk_to_format()
|
||||||
|
|
||||||
# Need to clean up output on pre-Sierra
|
# Need to clean up output on pre-Sierra
|
||||||
# Disk images are mixed in with regular disks (ex. payloads.dmg)
|
# Disk images are mixed in with regular disks (ex. payloads.dmg)
|
||||||
|
ignore = ["disk image", "read-only", "virtual"]
|
||||||
for disk in self.available_disks.copy():
|
for disk in self.available_disks.copy():
|
||||||
if "read-only" in self.available_disks[disk]['name']:
|
for string in ignore:
|
||||||
del self.available_disks[disk]
|
if string in self.available_disks[disk]['name'].lower():
|
||||||
|
del self.available_disks[disk]
|
||||||
|
|
||||||
|
|
||||||
thread = threading.Thread(target=fetch_disks)
|
thread = threading.Thread(target=_fetch_disks)
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
while thread.is_alive():
|
while thread.is_alive():
|
||||||
@@ -198,7 +200,7 @@ class macOSInstallerFlashFrame(wx.Frame):
|
|||||||
|
|
||||||
# Search for disks again
|
# Search for disks again
|
||||||
search_button = wx.Button(self.frame_modal, label="Search for disks again", pos=(-1, disk_button.GetPosition()[1] + disk_button.GetSize()[1]), size=(160, 30))
|
search_button = wx.Button(self.frame_modal, label="Search for disks again", pos=(-1, disk_button.GetPosition()[1] + disk_button.GetSize()[1]), size=(160, 30))
|
||||||
search_button.Bind(wx.EVT_BUTTON, self.on_select)
|
search_button.Bind(wx.EVT_BUTTON, lambda event, temp=installer: self.on_select(temp))
|
||||||
search_button.Center(wx.HORIZONTAL)
|
search_button.Center(wx.HORIZONTAL)
|
||||||
|
|
||||||
# Button: Return to Main Menu
|
# Button: Return to Main Menu
|
||||||
@@ -276,21 +278,25 @@ class macOSInstallerFlashFrame(wx.Frame):
|
|||||||
root_disk = disk['identifier'][5:]
|
root_disk = disk['identifier'][5:]
|
||||||
initial_bytes_written = float(utilities.monitor_disk_output(root_disk))
|
initial_bytes_written = float(utilities.monitor_disk_output(root_disk))
|
||||||
self.result = False
|
self.result = False
|
||||||
def flash():
|
def _flash():
|
||||||
self.result = self._flash_installer(root_disk)
|
self.result = self._flash_installer(root_disk)
|
||||||
|
|
||||||
thread = threading.Thread(target=flash)
|
thread = threading.Thread(target=_flash)
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
# Wait for installer to be created
|
# Wait for installer to be created
|
||||||
while thread.is_alive():
|
while thread.is_alive():
|
||||||
total_bytes_written = float(utilities.monitor_disk_output(root_disk))
|
try:
|
||||||
|
total_bytes_written = float(utilities.monitor_disk_output(root_disk))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
bytes_written = total_bytes_written - initial_bytes_written
|
bytes_written = total_bytes_written - initial_bytes_written
|
||||||
wx.CallAfter(bytes_written_label.SetLabel, f"Bytes Written: {bytes_written:.2f} MB")
|
wx.CallAfter(bytes_written_label.SetLabel, f"Bytes Written: {bytes_written:.2f} MB")
|
||||||
wx.CallAfter(progress_bar.SetValue, int(bytes_written))
|
wx.CallAfter(progress_bar.SetValue, int(bytes_written))
|
||||||
wx.Yield()
|
wx.Yield()
|
||||||
|
|
||||||
if self.result is False:
|
if self.result is False:
|
||||||
|
self.on_return_to_main_menu()
|
||||||
return
|
return
|
||||||
|
|
||||||
# Next verify the installer
|
# Next verify the installer
|
||||||
@@ -361,7 +367,6 @@ class macOSInstallerFlashFrame(wx.Frame):
|
|||||||
logging.info("- Failed to create macOS installer")
|
logging.info("- Failed to create macOS installer")
|
||||||
popup = wx.MessageDialog(self, f"Failed to create macOS installer\n\nOutput: {output}\n\nError: {error}", "Error", wx.OK | wx.ICON_ERROR)
|
popup = wx.MessageDialog(self, f"Failed to create macOS installer\n\nOutput: {output}\n\nError: {error}", "Error", wx.OK | wx.ICON_ERROR)
|
||||||
popup.ShowModal()
|
popup.ShowModal()
|
||||||
self.on_return_to_main_menu()
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
logging.info("- Successfully created macOS installer")
|
logging.info("- Successfully created macOS installer")
|
||||||
@@ -513,7 +518,7 @@ class macOSInstallerFlashFrame(wx.Frame):
|
|||||||
def _validate_installer_pkg(self, disk: str) -> bool:
|
def _validate_installer_pkg(self, disk: str) -> bool:
|
||||||
verification_success = False
|
verification_success = False
|
||||||
error_message = ""
|
error_message = ""
|
||||||
def integrity_check():
|
def _integrity_check():
|
||||||
nonlocal error_message
|
nonlocal error_message
|
||||||
path = utilities.grab_mount_point_from_disk(disk + "s2")
|
path = utilities.grab_mount_point_from_disk(disk + "s2")
|
||||||
dmg_path = path + f"/{path.split('/')[2]}.app/Contents/SharedSupport/SharedSupport.dmg"
|
dmg_path = path + f"/{path.split('/')[2]}.app/Contents/SharedSupport/SharedSupport.dmg"
|
||||||
@@ -531,7 +536,7 @@ class macOSInstallerFlashFrame(wx.Frame):
|
|||||||
error_message += "\n\nSTDERR: " + result.stderr.decode("utf-8")
|
error_message += "\n\nSTDERR: " + result.stderr.decode("utf-8")
|
||||||
|
|
||||||
|
|
||||||
thread = threading.Thread(target=integrity_check)
|
thread = threading.Thread(target=_integrity_check)
|
||||||
thread.start()
|
thread.start()
|
||||||
while thread.is_alive():
|
while thread.is_alive():
|
||||||
wx.Yield()
|
wx.Yield()
|
||||||
@@ -546,6 +551,9 @@ class macOSInstallerFlashFrame(wx.Frame):
|
|||||||
def on_return_to_main_menu(self, event: wx.Event = None):
|
def on_return_to_main_menu(self, event: wx.Event = None):
|
||||||
if self.frame_modal:
|
if self.frame_modal:
|
||||||
self.frame_modal.Hide()
|
self.frame_modal.Hide()
|
||||||
|
if self:
|
||||||
|
if isinstance(self, wx.Frame):
|
||||||
|
self.Hide()
|
||||||
main_menu_frame = gui_main_menu.MainFrame(
|
main_menu_frame = gui_main_menu.MainFrame(
|
||||||
None,
|
None,
|
||||||
title=self.title,
|
title=self.title,
|
||||||
@@ -555,4 +563,6 @@ class macOSInstallerFlashFrame(wx.Frame):
|
|||||||
main_menu_frame.Show()
|
main_menu_frame.Show()
|
||||||
if self.frame_modal:
|
if self.frame_modal:
|
||||||
self.frame_modal.Destroy()
|
self.frame_modal.Destroy()
|
||||||
self.Destroy()
|
if self:
|
||||||
|
if isinstance(self, wx.Frame):
|
||||||
|
self.Destroy()
|
||||||
@@ -80,10 +80,10 @@ class SysPatchFrame(wx.Frame):
|
|||||||
|
|
||||||
# Generate KDK object
|
# Generate KDK object
|
||||||
self.kdk_obj: kdk_handler.KernelDebugKitObject = None
|
self.kdk_obj: kdk_handler.KernelDebugKitObject = None
|
||||||
def kdk_thread_spawn():
|
def _kdk_thread_spawn():
|
||||||
self.kdk_obj = kdk_handler.KernelDebugKitObject(self.constants, self.constants.detected_os_build, self.constants.detected_os_version)
|
self.kdk_obj = kdk_handler.KernelDebugKitObject(self.constants, self.constants.detected_os_build, self.constants.detected_os_version)
|
||||||
|
|
||||||
kdk_thread = threading.Thread(target=kdk_thread_spawn)
|
kdk_thread = threading.Thread(target=_kdk_thread_spawn)
|
||||||
kdk_thread.start()
|
kdk_thread.start()
|
||||||
|
|
||||||
while kdk_thread.is_alive():
|
while kdk_thread.is_alive():
|
||||||
|
|||||||
Reference in New Issue
Block a user