Don't pass Python Future objects to QML
Returning a Future doesn't work on Windows for some reason (https://github.com/thp/pyotherside/issues/116). Instead of using these objects from QML to cancel running coroutines, call a Python QMLBridge function that takes a coroutine UUID and will take care of the cancelling.
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
import QtQuick 2.12
|
||||
import "../Base"
|
||||
import "../Base/Buttons"
|
||||
import "../PythonBridge"
|
||||
|
||||
PasswordPopup {
|
||||
id: popup
|
||||
@@ -13,15 +12,15 @@ PasswordPopup {
|
||||
property var deviceIds // array
|
||||
property var deletedCallback: null
|
||||
|
||||
property Future deleteFuture: null
|
||||
property string deleteFutureId: ""
|
||||
|
||||
function verifyPassword(pass, callback) {
|
||||
deleteFuture = py.callClientCoro(
|
||||
deleteFutureId = py.callClientCoro(
|
||||
userId,
|
||||
"delete_devices_with_password",
|
||||
[deviceIds, pass],
|
||||
() => {
|
||||
deleteFuture = null
|
||||
deleteFutureId = ""
|
||||
callback(true)
|
||||
},
|
||||
(type, args) => {
|
||||
@@ -47,9 +46,9 @@ PasswordPopup {
|
||||
validateButton.icon.name: "sign-out"
|
||||
|
||||
onClosed: {
|
||||
if (deleteFuture) deleteFuture.cancel()
|
||||
if (deleteFutureId) py.cancelCoro(deleteFutureId)
|
||||
|
||||
if (deleteFuture || acceptedPassword && deletedCallback)
|
||||
if (deleteFutureId || acceptedPassword && deletedCallback)
|
||||
deletedCallback()
|
||||
}
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ HColumnPopup {
|
||||
property string roomName
|
||||
property bool invitingAllowed: true
|
||||
|
||||
property var inviteFuture: null
|
||||
property string inviteFutureId: ""
|
||||
property var successfulInvites: []
|
||||
property var failedInvites: []
|
||||
|
||||
@@ -26,12 +26,14 @@ HColumnPopup {
|
||||
user => ! successfulInvites.includes(user)
|
||||
)
|
||||
|
||||
inviteFuture = py.callClientCoro(
|
||||
inviteFutureId = py.callClientCoro(
|
||||
userId,
|
||||
"room_mass_invite",
|
||||
[roomId, ...inviteesLeft],
|
||||
|
||||
([successes, errors]) => {
|
||||
inviteFutureId = ""
|
||||
|
||||
if (errors.length < 1) {
|
||||
popup.close()
|
||||
return
|
||||
@@ -61,10 +63,10 @@ HColumnPopup {
|
||||
}
|
||||
|
||||
onOpened: inviteArea.forceActiveFocus()
|
||||
onClosed: if (inviteFuture) inviteFuture.cancel()
|
||||
onClosed: if (inviteFutureId) py.cancelCoro(inviteFutureId)
|
||||
|
||||
onInvitingAllowedChanged:
|
||||
if (! invitingAllowed && inviteFuture) inviteFuture.cancel()
|
||||
if (! invitingAllowed && inviteFutureId) py.cancelCoro(inviteFutureId)
|
||||
|
||||
SummaryLabel {
|
||||
text: qsTr("Invite members to <i>%1</i>").arg(roomName)
|
||||
|
Reference in New Issue
Block a user