Show message when slicing failed with nonzero exit code

The slicing engine should never crash. If it does though, it's best to show something to the user. Otherwise the slicing process just halts and the user will wait a long time for it to never finish.

Contributes to issue CURA-6568.
This commit is contained in:
Ghostkeeper 2021-07-14 16:58:05 +02:00
parent e9ecba1374
commit 399b378ba6
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A

View file

@ -4,12 +4,12 @@
import argparse #To run the engine in debug mode if the front-end is in debug mode. import argparse #To run the engine in debug mode if the front-end is in debug mode.
from collections import defaultdict from collections import defaultdict
import os import os
from PyQt5.QtCore import QObject, QTimer, pyqtSlot from PyQt5.QtCore import QObject, QTimer, QUrl, pyqtSlot
import sys import sys
from time import time from time import time
from typing import Any, cast, Dict, List, Optional, Set, TYPE_CHECKING from typing import Any, cast, Dict, List, Optional, Set, TYPE_CHECKING
from PyQt5.QtGui import QImage from PyQt5.QtGui import QDesktopServices, QImage
from UM.Backend.Backend import Backend, BackendState from UM.Backend.Backend import Backend, BackendState
from UM.Scene.SceneNode import SceneNode from UM.Scene.SceneNode import SceneNode
@ -922,9 +922,31 @@ class CuraEngineBackend(QObject, Backend):
if not self._restart: if not self._restart:
if self._process: # type: ignore if self._process: # type: ignore
Logger.log("d", "Backend quit with return code %s. Resetting process and socket.", self._process.wait()) # type: ignore return_code = self._process.wait()
if return_code != 0:
Logger.log("e", f"Backend exited abnormally with return code {return_code}!")
message = Message(
text = catalog.i18nc("@message", "Slicing failed with an unexpected error. Please consider reporting a bug on our issue tracker."),
title = catalog.i18nc("@message:title", "Slicing failed")
)
message.addAction(
action_id = "report_bug",
name = catalog.i18nc("@message:button", "Report a bug"),
description = catalog.i18nc("@message:description", "Report a bug on Ultimaker Cura's issue tracker."),
icon = "[no_icon]"
)
message.actionTriggered.connect(self._reportBackendError)
message.show()
else:
Logger.log("d", "Backend finished slicing. Resetting process and socket.")
self._process = None # type: ignore self._process = None # type: ignore
def _reportBackendError(self, _message_id: str, _action_id: str) -> None:
"""
Triggered when the user wants to report an error in the back-end.
"""
QDesktopServices.openUrl(QUrl("https://github.com/Ultimaker/Cura/issues/new/choose"))
def _onGlobalStackChanged(self) -> None: def _onGlobalStackChanged(self) -> None:
"""Called when the global container stack changes""" """Called when the global container stack changes"""