peerplays_migrated/programs/light_client/qml/AccountPicker.qml
Nathan Hourt 1813e9f5f6 [GUI] Fix crash from user-after-free
The QML engine was taking ownership of Account objects, and garbage
collecting them when it was done with them, thus causing a crash when
the C++ accessed them. Fix by explicitly marking Account objects as
being owned by the C++ so QML doesn't garbage collect them.
2015-07-14 16:08:54 -04:00

72 lines
1.8 KiB
QML

import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.2
import Graphene.Client 0.1
import "."
RowLayout {
property Account account
property alias placeholderText: accountNameField.placeholderText
function setFocus() {
accountNameField.forceActiveFocus()
}
Identicon {
name: accountNameField.text
width: Scaling.cm(2)
height: Scaling.cm(2)
}
Column {
Layout.fillWidth: true
TextField {
id: accountNameField
width: parent.width
onEditingFinished: accountDetails.update(text)
}
Label {
id: accountDetails
function update(name) {
if (!name)
{
text = ""
return
}
account = app.model.getAccount(name)
if (account == null)
text = qsTr("Error fetching account.")
else
text = Qt.binding(function() {
if (account == null)
return qsTr("Account does not exist.")
return qsTr("Account ID: %1").arg(account.id < 0? qsTr("Loading...")
: account.id)
})
}
Behavior on text {
SequentialAnimation {
PropertyAnimation {
target: accountDetails
property: "opacity"
from: 1; to: 0
duration: 100
}
PropertyAction { target: accountDetails; property: "text" }
PropertyAnimation {
target: accountDetails
property: "opacity"
from: 0; to: 1
duration: 100
}
}
}
}
}
}