[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.
This commit is contained in:
parent
419ab4f932
commit
1813e9f5f6
2 changed files with 20 additions and 0 deletions
|
|
@ -17,6 +17,7 @@ Account* ChainDataModel::getAccount(ObjectId id)
|
|||
if( itr == by_id_idx.end() )
|
||||
{
|
||||
auto tmp = new Account;
|
||||
QQmlEngine::setObjectOwnership(tmp, QQmlEngine::CppOwnership);
|
||||
tmp->id = id; --m_account_query_num;
|
||||
tmp->name = QString::number( --m_account_query_num);
|
||||
auto result = m_accounts.insert( tmp );
|
||||
|
|
@ -67,6 +68,7 @@ Account* ChainDataModel::getAccount(QString name)
|
|||
if( itr == by_name_idx.end() )
|
||||
{
|
||||
auto tmp = new Account;
|
||||
QQmlEngine::setObjectOwnership(tmp, QQmlEngine::CppOwnership);
|
||||
tmp->id = --m_account_query_num;
|
||||
tmp->name = name;
|
||||
auto result = m_accounts.insert( tmp );
|
||||
|
|
|
|||
|
|
@ -49,6 +49,24 @@ RowLayout {
|
|||
: 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue