Skip to content

Commit

Permalink
尝试修复更新文件占用问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
DoiiarX committed Jun 2, 2024
1 parent 00a213b commit 2fcfc4c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion cddagl/ui/views/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
QComboBox, QTextBrowser, QMessageBox, QStyle, QHBoxLayout, QSizePolicy
)
from PyQt5.QtGui import QRegularExpressionValidator
from PyQt5.QtGui import QFontDatabase
from babel.dates import format_datetime
from pywintypes import error as PyWinError

Expand Down Expand Up @@ -324,6 +325,8 @@ def restore_previous(self):
update_group_box.disable_controls(True)

self.restored_previous = False

QFontDatabase.removeAllApplicationFonts()

try:
game_dir = self.dir_combo.currentText()
Expand Down Expand Up @@ -1925,6 +1928,8 @@ def clean_game_dir(self):
len(dir_list) == 1 and dir_list[0] == 'previous_version'):
return None

QFontDatabase.removeAllApplicationFonts()

temp_move_dir = tempfile.mkdtemp(prefix=cons.TEMP_PREFIX)

excluded_entries = set(['previous_version'])
Expand All @@ -1950,6 +1955,8 @@ def restore_previous_content(self, path):
previous_version_dir = os.path.join(game_dir, 'previous_version')
if not os.path.exists(previous_version_dir):
os.makedirs(previous_version_dir)

QFontDatabase.removeAllApplicationFonts()

for entry in os.listdir(path):
entry_path = os.path.join(path, entry)
Expand All @@ -1958,7 +1965,9 @@ def restore_previous_content(self, path):
def restore_backup(self):
game_dir = self.game_dir
previous_version_dir = os.path.join(game_dir, 'previous_version')


QFontDatabase.removeAllApplicationFonts()

if os.path.isdir(previous_version_dir) and os.path.isdir(game_dir):

for entry in os.listdir(previous_version_dir):
Expand Down Expand Up @@ -2245,6 +2254,8 @@ def backup_current_game(self):
if (config_true(get_config_value('prevent_save_move', 'False'))
and 'save' in dir_list):
dir_list.remove('save')

QFontDatabase.removeAllApplicationFonts()

launcher_exe = os.path.abspath(sys.executable)
launcher_dir = os.path.dirname(launcher_exe)
Expand Down Expand Up @@ -2360,6 +2371,8 @@ def extract_new_build(self):
self.extracting_timer = timer

progress_bar.setRange(0, len(self.extracting_infolist))

QFontDatabase.removeAllApplicationFonts()

def timeout():
self.extracting_progress_bar.setValue(self.extracting_index)
Expand Down Expand Up @@ -2728,6 +2741,8 @@ def post_extraction_step3(self):
mods_dir = os.path.join(self.game_dir, 'data', 'mods')
previous_mods_dir = os.path.join(self.game_dir, 'previous_version',
'data', 'mods')

QFontDatabase.removeAllApplicationFonts()

if (os.path.isdir(mods_dir) and os.path.isdir(previous_mods_dir) and
self.in_post_extraction):
Expand Down

0 comments on commit 2fcfc4c

Please sign in to comment.