Skip to content

Commit 2be8934

Browse files
authored
Merge pull request #1163 from goneng/fix_high_cpu
GUI: Reduce CPU usage II - have smoother UX with faster refresh rate
2 parents d41d19b + 9ac02b0 commit 2be8934

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

opencore_legacy_patcher/constants.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class Constants:
1414
def __init__(self) -> None:
1515
# Patcher Versioning
16-
self.patcher_version: str = "2.3.2" # OpenCore-Legacy-Patcher
16+
self.patcher_version: str = "2.4.0" # OpenCore-Legacy-Patcher
1717
self.patcher_support_pkg_version: str = "1.9.3" # PatcherSupportPkg
1818
self.copyright_date: str = "Copyright © 2020-2025 Dortania"
1919
self.patcher_name: str = "OpenCore Legacy Patcher"
@@ -155,8 +155,7 @@ def __init__(self) -> None:
155155
self.unpack_thread = None # Determine if unpack thread finished (threading.Thread)
156156
self.update_stage: int = 0 # Determine update stage (see gui_support.py)
157157
self.log_filepath: Path = None # Path to log file
158-
self.thread_sleep_interval: float = 0.1 # Sleep interval between UI updates (seconds) - reduce refresh-rate to reduce CPU-usage
159-
self.thread_nap_interval: float = 0.01 # Short Sleep interval between UI updates (seconds) - for faster UI updates of the progress bar
158+
self.thread_sleep_interval: float = 0.01 # Sleep interval between UI updates (seconds) - balance between UI responsiveness and CPU usage
160159

161160
self.commit_info: tuple = (None, None, None) # Commit info (Branch, Commit Date, Commit URL)
162161

opencore_legacy_patcher/wx_gui/gui_macos_installer_flash.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44

55
import wx
6-
import time
76
import logging
87
import plistlib
98
import tempfile
@@ -317,7 +316,7 @@ def _flash():
317316
wx.CallAfter(progress_bar.SetValue, bytes_written)
318317

319318
wx.Yield()
320-
time.sleep(self.constants.thread_sleep_interval)
319+
thread.join(timeout=self.constants.thread_sleep_interval)
321320

322321
if self.result is False:
323322
logging.error("Failed to flash installer, cannot continue.")

opencore_legacy_patcher/wx_gui/gui_support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def wait_for_thread(thread: threading.Thread, sleep_interval=None):
273273

274274
while thread.is_alive():
275275
wx.Yield()
276-
time.sleep(interval)
276+
thread.join(timeout=interval)
277277

278278

279279
class RestartHost:

0 commit comments

Comments
 (0)