From fa29260e093e85d729dbb4890c07b57f73a703e0 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 23 Apr 2019 19:40:21 -0700 Subject: [PATCH] Work around Qt 5.12 dialog crash on disconnect --- app/gui/StreamSegue.qml | 24 ++++++++---------------- app/gui/main.qml | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/app/gui/StreamSegue.qml b/app/gui/StreamSegue.qml index 12e357f4..6a1d084c 100644 --- a/app/gui/StreamSegue.qml +++ b/app/gui/StreamSegue.qml @@ -20,7 +20,7 @@ Item { function stageFailed(stage, errorCode) { // Display the error dialog after Session::exec() returns - errorDialog.text = "Starting " + stage + " failed: Error " + errorCode + streamSegueErrorDialog.text = "Starting " + stage + " failed: Error " + errorCode } function connectionStarted() @@ -38,7 +38,7 @@ Item { function displayLaunchError(text) { // Display the error dialog after Session::exec() returns - errorDialog.text = text + streamSegueErrorDialog.text = text } function displayLaunchWarning(text) @@ -68,9 +68,10 @@ Item { SdlGamepadKeyNavigation.enable() if (quitAfter) { - if (errorDialog.text) { + if (streamSegueErrorDialog.text) { // Quit when the error dialog is acknowledged - errorDialog.open() + streamSegueErrorDialog.quitAfter = quitAfter + streamSegueErrorDialog.open() } else { // Quit immediately @@ -87,8 +88,9 @@ Item { // the Qt UI is visible again to prevent losing // focus on the dialog which would impact gamepad // users. - if (errorDialog.text) { - errorDialog.open() + if (streamSegueErrorDialog.text) { + streamSegueErrorDialog.quitAfter = quitAfter + streamSegueErrorDialog.open() } } } @@ -171,14 +173,4 @@ Item { wrapMode: Text.Wrap } - - ErrorMessageDialog { - id: errorDialog - - onClosed: { - if (quitAfter) { - Qt.quit() - } - } - } } diff --git a/app/gui/main.qml b/app/gui/main.qml index e4c3ade1..8dd59938 100644 --- a/app/gui/main.qml +++ b/app/gui/main.qml @@ -421,6 +421,29 @@ ApplicationWindow { onAccepted: Qt.quit() } + // HACK: This belongs in StreamSegue but keeping a dialog around after the parent + // dies can trigger bugs in Qt 5.12 that cause the app to crash. For now, we will + // host this dialog in a QML component that is never destroyed. + // + // To repro: Start a stream, cut the network connection to trigger the "Connection + // terminated" dialog, wait until the app grid times out back to the PC grid, then + // try to dismiss the dialog. + ErrorMessageDialog { + id: streamSegueErrorDialog + + property bool quitAfter: false + + onClosed: { + if (quitAfter) { + Qt.quit() + } + + // StreamSegue assumes its dialog will be re-created each time we + // start streaming, so fake it by wiping out the text each time. + text = "" + } + } + NavigableDialog { id: addPcDialog property string label: "Enter the IP address of your GameStream PC:"