1
0

qml: properly destroy ExceptionDialog after close, improve encapsulation

This commit is contained in:
Sander van Grieken
2025-03-28 14:51:12 +01:00
parent 1d07895e8c
commit 1559129016
3 changed files with 16 additions and 17 deletions

View File

@@ -17,6 +17,7 @@ ElDialog
width: parent.width width: parent.width
height: parent.height height: parent.height
z: 1000 // assure topmost of all other dialogs
header: null header: null
@@ -61,12 +62,12 @@ ElDialog
text: qsTr('Please briefly describe what led to the error (optional):') text: qsTr('Please briefly describe what led to the error (optional):')
} }
TextArea { TextArea {
id: user_text
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
background: Rectangle { background: Rectangle {
color: Qt.darker(Material.background, 1.25) color: Qt.darker(Material.background, 1.25)
} }
onTextChanged: AppController.setCrashUserText(text)
} }
Label { Label {
text: qsTr('Do you want to send this report?') text: qsTr('Do you want to send this report?')
@@ -76,7 +77,7 @@ ElDialog
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredWidth: 3 Layout.preferredWidth: 3
text: qsTr('Send Bug Report') text: qsTr('Send Bug Report')
onClicked: AppController.sendReport() onClicked: AppController.sendReport(user_text.text)
} }
Button { Button {
Layout.fillWidth: true Layout.fillWidth: true
@@ -106,10 +107,9 @@ ElDialog
ElDialog { ElDialog {
property string reportText property string reportText
z: 3000
width: parent.width width: parent.width
height: parent.height height: parent.height
z: 1001 // above root
header: null header: null
@@ -125,6 +125,7 @@ ElDialog
width: parent.width width: parent.width
} }
} }
onClosed: destroy()
} }
} }

View File

@@ -423,6 +423,13 @@ ApplicationWindow
} }
} }
Component {
id: crashDialog
ExceptionDialog {
onClosed: destroy()
}
}
property alias channelOpenProgressDialog: _channelOpenProgressDialog property alias channelOpenProgressDialog: _channelOpenProgressDialog
ChannelOpenProgressDialog { ChannelOpenProgressDialog {
id: _channelOpenProgressDialog id: _channelOpenProgressDialog
@@ -486,13 +493,6 @@ ApplicationWindow
width: parent.width width: parent.width
} }
Component {
id: crashDialog
ExceptionDialog {
z: 1000
}
}
Component.onCompleted: { Component.onCompleted: {
coverTimer.start() coverTimer.start()

View File

@@ -303,12 +303,14 @@ class QEAppController(BaseCrashReporter, QObject):
self.exc_args = (e, text, tb) # for BaseCrashReporter self.exc_args = (e, text, tb) # for BaseCrashReporter
self.showException.emit(self.crashData()) self.showException.emit(self.crashData())
@pyqtSlot() @pyqtSlot(str)
def sendReport(self): def sendReport(self, user_text: str):
self._crash_user_text = user_text
network = Network.get_instance() network = Network.get_instance()
proxy = network.proxy proxy = network.proxy
def report_task(): def report_task():
self.logger.debug('starting report_task')
try: try:
response = BaseCrashReporter.send_report(self, network.asyncio_loop, proxy) response = BaseCrashReporter.send_report(self, network.asyncio_loop, proxy)
except Exception as e: except Exception as e:
@@ -330,10 +332,6 @@ class QEAppController(BaseCrashReporter, QObject):
def showNever(self): def showNever(self):
self.config.SHOW_CRASH_REPORTER = False self.config.SHOW_CRASH_REPORTER = False
@pyqtSlot(str)
def setCrashUserText(self, text):
self._crash_user_text = text
def _get_traceback_str_to_display(self) -> str: def _get_traceback_str_to_display(self) -> str:
# The msg_box that shows the report uses rich_text=True, so # The msg_box that shows the report uses rich_text=True, so
# if traceback contains special HTML characters, e.g. '<', # if traceback contains special HTML characters, e.g. '<',