Skip to content

Commit

Permalink
Fix race: Object (m_item) is operated on before it is assigned.
Browse files Browse the repository at this point in the history
The race happens in:

QObject *obj = component->create(ctx);
m_item = qobject_cast<QQuickItem *>(obj);

Truncated crash:

#0  0x00007ffff5546354 in QQmlContext::parentContext() const () at /usr/lib/libQt5Qml.so.5
#1  0x00007fff68362cf3 in DelegateRecycler::syncModelProperties() (this=0x55555d3a9210) at delegaterecycler.cpp:162
#2  0x00007fff68336367 in DelegateRecycler::qt_static_metacall() at moc_delegaterecycler.cpp:229
#3  0x00007fff683365bd in DelegateRecycler::qt_metacall() at moc_delegaterecycler.cpp:308
  • Loading branch information
sh-zam authored and Pointedstick committed Jun 13, 2022
1 parent 9503546 commit 8dec608
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/delegaterecycler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ DelegateRecycler::~DelegateRecycler()
void DelegateRecycler::syncIndex()
{
const QVariant newIndex = m_propertiesTracker->property("trackedIndex");
if (!newIndex.isValid()) {
if (!m_item || !newIndex.isValid()) {
return;
}
QQmlContext *ctx = QQmlEngine::contextForObject(m_item)->parentContext();
Expand All @@ -137,7 +137,7 @@ void DelegateRecycler::syncIndex()
void DelegateRecycler::syncModel()
{
const QVariant newModel = m_propertiesTracker->property("trackedModel");
if (!newModel.isValid()) {
if (!m_item || !newModel.isValid()) {
return;
}
QQmlContext *ctx = QQmlEngine::contextForObject(m_item)->parentContext();
Expand All @@ -156,7 +156,7 @@ void DelegateRecycler::syncModel()
void DelegateRecycler::syncModelProperties()
{
const QVariant model = m_propertiesTracker->property("trackedModel");
if (!model.isValid()) {
if (!m_item || !model.isValid()) {
return;
}
QQmlContext *ctx = QQmlEngine::contextForObject(m_item)->parentContext();
Expand All @@ -174,7 +174,7 @@ void DelegateRecycler::syncModelProperties()
void DelegateRecycler::syncModelData()
{
const QVariant newModelData = m_propertiesTracker->property("trackedModelData");
if (!newModelData.isValid()) {
if (!m_item || !newModelData.isValid()) {
return;
}
QQmlContext *ctx = QQmlEngine::contextForObject(m_item)->parentContext();
Expand Down

0 comments on commit 8dec608

Please sign in to comment.