Make QmlComponentsPool one instance per engine
ClosedPublic

Authored by davidedmundson on Nov 13 2019, 2:23 PM.

Details

Summary

If we create 2 engines in an application the singleton is initialised to
the first engine. If that first engine disappears the internal m_unit is
dangling.

A good example of this is systemsettings in the icon view if we enter
two modules one after another. It's currently only kept alive because
the sidebar created the first reference.

BUG: 414003

Test Plan

System settings in icon view
opened global theme
went back
open fonts theme
didn't crash

Diff Detail

Repository
R169 Kirigami
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
davidedmundson created this revision.Nov 13 2019, 2:23 PM
Restricted Application added a project: Kirigami. · View Herald TranscriptNov 13 2019, 2:23 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
davidedmundson requested review of this revision.Nov 13 2019, 2:23 PM
broulik added inline comments.
src/columnview.cpp
51

Avoid double lookup:

auto *componentPool = privateQmlComponentsPoolSelf->m_instances.value(engine);
if (componentPool) {
    return componentPool;
}

componentPool = new QQmlComponentsPool(engine);
...
return componentPool;

reduce lookup

mart accepted this revision.Nov 14 2019, 6:04 PM
This revision is now accepted and ready to land.Nov 14 2019, 6:04 PM
This revision was automatically updated to reflect the committed changes.