we delay addSourceModel when the source model is fully loaded,
but it might take a long time (ie adding /usr/share)
if then we remove it before it's done, we will have either an assert or a crash
in qconcatenatetablesmodel (depending if Qt asserts are turned on)
we can safely call addsourceModel immediately, so rowsInserted will be
forwarded as they come in
BUG:503593
(cherry picked from commit
f584f1beb3aaafe36c328a761b8eea02b46f20c4)
f584f1be wallpapers/image: don't crash when removing /usr/share
Co-authored-by: Marco Martin <notmart@gmail.com>
Gbp-Pq: Name upstream_e9fd71d9_wallpapers-image-don-t-crash-when-removing-usr-share.patch
m_models.insert(d, m);
added.append(d);
+ // Add the model immediately unconditionally as we might want to remove it before is loaded,
+ // which would crash if we didn't add it yet. when images are loaded the rowsInserted signals
+ // will be properly forwarded
+ addSourceModel(m);
+
if (m->loading().value()) {
connect(m, &ImageProxyModel::loadingChanged, this, &SlideModel::slotSourceModelLoadingChanged);
} else {
// In case it loads immediately
++m_loaded;
- addSourceModel(m);
}
}
}
void SlideModel::slotSourceModelLoadingChanged()
{
- auto m = static_cast<ImageProxyModel *>(sender());
- disconnect(m, &ImageProxyModel::loadingChanged, this, nullptr);
- addSourceModel(m);
-
if (++m_loaded == m_models.size()) {
m_loading = false;
Q_EMIT done();