mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-12-05 16:51:12 -07:00
Fixes for early crash dialog
CURA-4895
This commit is contained in:
parent
aefe24222f
commit
30b1e74881
2 changed files with 8 additions and 2 deletions
|
|
@ -13,6 +13,7 @@ import ssl
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import urllib.error
|
import urllib.error
|
||||||
import shutil
|
import shutil
|
||||||
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtCore import QT_VERSION_STR, PYQT_VERSION_STR
|
from PyQt5.QtCore import QT_VERSION_STR, PYQT_VERSION_STR
|
||||||
from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QVBoxLayout, QLabel, QTextEdit, QGroupBox, QCheckBox, QPushButton
|
from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QVBoxLayout, QLabel, QTextEdit, QGroupBox, QCheckBox, QPushButton
|
||||||
|
|
@ -140,6 +141,11 @@ class CrashHandler:
|
||||||
if cache_path not in (config_path, data_path):
|
if cache_path not in (config_path, data_path):
|
||||||
folders_to_remove.append(cache_path)
|
folders_to_remove.append(cache_path)
|
||||||
|
|
||||||
|
# need to close the redirected stdout and stderr files, otherwise, on Windows, those opened files will prevent
|
||||||
|
# the directory removal calls below.
|
||||||
|
sys.stdout.close()
|
||||||
|
sys.stderr.close()
|
||||||
|
|
||||||
for folder in folders_to_remove:
|
for folder in folders_to_remove:
|
||||||
shutil.rmtree(folder, ignore_errors = True)
|
shutil.rmtree(folder, ignore_errors = True)
|
||||||
for folder in folders_to_backup:
|
for folder in folders_to_backup:
|
||||||
|
|
@ -159,7 +165,7 @@ class CrashHandler:
|
||||||
shutil.make_archive(zip_file_path, "zip", root_dir = root_dir, base_dir = base_name)
|
shutil.make_archive(zip_file_path, "zip", root_dir = root_dir, base_dir = base_name)
|
||||||
|
|
||||||
# remove the folder only when the backup is successful
|
# remove the folder only when the backup is successful
|
||||||
shutil.rmtree(folder)
|
shutil.rmtree(folder, ignore_errors = True)
|
||||||
# create an empty folder so Resources will not try to copy the old ones
|
# create an empty folder so Resources will not try to copy the old ones
|
||||||
os.makedirs(folder, 0o0755, exist_ok=True)
|
os.makedirs(folder, 0o0755, exist_ok=True)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ def exceptHook(hook_type, value, traceback):
|
||||||
_crash_handler = CrashHandler(hook_type, value, traceback, has_started)
|
_crash_handler = CrashHandler(hook_type, value, traceback, has_started)
|
||||||
if not has_started:
|
if not has_started:
|
||||||
CuraApplication.getInstance().removePostedEvents(None)
|
CuraApplication.getInstance().removePostedEvents(None)
|
||||||
_crash_handler.show()
|
_crash_handler.early_crash_dialog.show()
|
||||||
sys.exit(CuraApplication.getInstance().exec_())
|
sys.exit(CuraApplication.getInstance().exec_())
|
||||||
else:
|
else:
|
||||||
_crash_handler.show()
|
_crash_handler.show()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue