[vlc-commits] qml: avoid crash at exit when dismissing dialog

Pierre Lamot git at videolan.org
Thu Feb 13 11:09:42 CET 2020


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Tue Feb  4 15:44:15 2020 +0100| [38980e95cecf4276c2ab33fb58811a5e2e0f0052] | committer: Jean-Baptiste Kempf

qml: avoid crash at exit when dismissing dialog

  loginDialog.dialogId stayed defined (hence dissmissed at exit) when
  accepting/dismissing the dialog without clicking on a button

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=38980e95cecf4276c2ab33fb58811a5e2e0f0052
---

 modules/gui/qt/dialogs/dialogs/qml/Dialogs.qml | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/modules/gui/qt/dialogs/dialogs/qml/Dialogs.qml b/modules/gui/qt/dialogs/dialogs/qml/Dialogs.qml
index 08df8c67c4..e45abb489d 100644
--- a/modules/gui/qt/dialogs/dialogs/qml/Dialogs.qml
+++ b/modules/gui/qt/dialogs/dialogs/qml/Dialogs.qml
@@ -163,8 +163,7 @@ Item {
                         KeyNavigation.up: savePassword
                         KeyNavigation.right: loginOk
                         onClicked: {
-                            dialogModel.dismiss(loginDialog.dialogId)
-                            loginDialog.dialogId = undefined
+                            loginDialog.reject()
                             loginDialog.close()
                         }
                     }
@@ -176,8 +175,7 @@ Item {
                         focus: true
                         KeyNavigation.up: savePassword
                         onClicked: {
-                            dialogModel.post_login(loginDialog.dialogId, username.text, password.text, savePassword.checked)
-                            loginDialog.dialogId = undefined
+                            loginDialog.accept()
                             loginDialog.close()
                         }
                     }
@@ -186,10 +184,16 @@ Item {
         }
 
         onAccepted: {
-            dialogModel.post_login(dialogId, username.text, password.text, savePassword.checked)
+            if (loginDialog.dialogId !== undefined) {
+                dialogModel.post_login(loginDialog.dialogId, username.text, password.text, savePassword.checked)
+                loginDialog.dialogId = undefined
+            }
         }
         onRejected: {
-            dialogModel.dismiss(dialogId)
+            if (loginDialog.dialogId !== undefined) {
+                dialogModel.dismiss(loginDialog.dialogId)
+                loginDialog.dialogId = undefined
+            }
         }
     }
 
@@ -302,9 +306,11 @@ Item {
         onCancelled: {
             if (questionDialog.dialogId === dialogId) {
                 questionDialog.close()
+                questionDialog.dialogId = undefined
                 dialogModel.dismiss(dialogId)
             } else if (loginDialog.dialogId === dialogId)  {
                 loginDialog.close()
+                loginDialog.dialogId = undefined
                 dialogModel.dismiss(dialogId)
             } else {
                 dialogModel.dismiss(dialogId)
@@ -312,10 +318,12 @@ Item {
         }
 
         Component.onDestruction: {
-            if (questionDialog.dialogId) {
+            if (questionDialog.dialogId !== undefined) {
                 dialogModel.dismiss(questionDialog.dialogId)
-            } if (loginDialog.dialogId) {
+                questionDialog.dialogId = undefined
+            } if (loginDialog.dialogId !== undefined) {
                 dialogModel.dismiss(loginDialog.dialogId)
+                loginDialog.dialogId = undefined
             }
         }
     }



More information about the vlc-commits mailing list